test.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. package asign
  2. import (
  3. "mtp2_if/global/app"
  4. "mtp2_if/global/e"
  5. "mtp2_if/logger"
  6. asignService "mtp2_if/services/asign"
  7. "net/http"
  8. "github.com/gin-gonic/gin"
  9. )
  10. // BankCard4 银行卡四要素认证(测试)
  11. // @Summary 银行卡四要素认证(测试)
  12. // @Produce json
  13. // @accept application/json
  14. // @Param data body asignService.APICompanyBankCard4Req true "入参"
  15. // @Success 200 {object} asignService.APIBankCard4Rsp
  16. // @Failure 500 {object} app.Response
  17. // @Router /Asign/TestBankCard4 [post]
  18. // @Tags 爱签
  19. func TestBankCard4(c *gin.Context) {
  20. appG := app.Gin{C: c}
  21. // 获取请求参数
  22. var req asignService.APICompanyBankCard4Req
  23. if err := appG.C.ShouldBindJSON(&req); err != nil {
  24. logger.GetLogger().Errorf(err.Error())
  25. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  26. return
  27. }
  28. if rsp, err := asignService.APIPost[asignService.APICompanyBankCard4Req, asignService.APIBankCard4Rsp](
  29. asignService.APIReq[asignService.APICompanyBankCard4Req]{Data: req}, asignService.APIURL_Company_BankCard4); err == nil {
  30. appG.Response(http.StatusOK, e.SUCCESS, rsp)
  31. } else {
  32. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  33. }
  34. }
  35. // CaptcaResend 重新发送认证验证码(测试)
  36. // @Summary 重新发送认证验证码(测试)
  37. // @Description 在实名认证的过程中,因用户手机原因未收到短信验证码或原验证码超过15分钟有效期而过期时,可以调用此接口重新发送短信验证码。若1分钟内多次调用此接口,则仅会发送一次短信验证码,15分钟内重新发送短信验证码不会变化。
  38. // @Produce json
  39. // @accept application/json
  40. // @Param data body asignService.APICaptchaResendReq true "入参"
  41. // @Success 200 {object} app.Response
  42. // @Failure 500 {object} app.Response
  43. // @Router /Asign/TestCaptcaResend [post]
  44. // @Tags 爱签
  45. func TestCaptcaResend(c *gin.Context) {
  46. appG := app.Gin{C: c}
  47. // 获取请求参数
  48. var req asignService.APICaptchaResendReq
  49. if err := appG.C.ShouldBindJSON(&req); err != nil {
  50. logger.GetLogger().Errorf(err.Error())
  51. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  52. return
  53. }
  54. if rsp, err := asignService.APIPost[asignService.APICaptchaResendReq, interface{}](
  55. asignService.APIReq[asignService.APICaptchaResendReq]{Data: req}, asignService.APIURL_Captcha_Resend); err == nil {
  56. appG.Response(http.StatusOK, e.SUCCESS, rsp)
  57. } else {
  58. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  59. }
  60. }
  61. // CaptchaVerify 认证验证码校验(测试)
  62. // @Summary 认证验证码校验(测试)
  63. // @Description 验证码认证成功后会调用爱签添加用户接口,同时调用交易系统JAVA实名认证接口
  64. // @Produce json
  65. // @accept application/json
  66. // @Param data body asignService.APICaptchaVerifyReq true "入参"
  67. // @Success 200 {object} asignService.APICaptchaVerifyRsp
  68. // @Failure 500 {object} app.Response
  69. // @Router /Asign/TestCaptchaVerify [post]
  70. // @Tags 爱签
  71. func TestCaptchaVerify(c *gin.Context) {
  72. appG := app.Gin{C: c}
  73. // 获取请求参数
  74. var req asignService.APICaptchaVerifyReq
  75. if err := appG.C.ShouldBindJSON(&req); err != nil {
  76. logger.GetLogger().Errorf(err.Error())
  77. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  78. return
  79. }
  80. if rsp, err := asignService.APIPost[asignService.APICaptchaVerifyReq, asignService.APICaptchaVerifyRsp](
  81. asignService.APIReq[asignService.APICaptchaVerifyReq]{Data: req}, asignService.APIURL_Captcha_Verify); err == nil {
  82. appG.Response(http.StatusOK, e.SUCCESS, rsp)
  83. } else {
  84. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  85. }
  86. }
  87. // CaptchaVerify 添加企业用户(V2)(测试)
  88. // @Summary 添加企业用户(V2)(测试)
  89. // @Produce json
  90. // @accept application/json
  91. // @Param data body asignService.APIAddEnterpriseUserReq true "入参"
  92. // @Success 200 {object} asignService.APIAddUserRsp
  93. // @Failure 500 {object} app.Response
  94. // @Router /Asign/TestAddEnterpriseUser [post]
  95. // @Tags 爱签
  96. func TestAddEnterpriseUser(c *gin.Context) {
  97. appG := app.Gin{C: c}
  98. // 获取请求参数
  99. var req asignService.APIAddEnterpriseUserReq
  100. if err := appG.C.ShouldBindJSON(&req); err != nil {
  101. logger.GetLogger().Errorf(err.Error())
  102. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  103. return
  104. }
  105. if rsp, err := asignService.APIPost[asignService.APIAddEnterpriseUserReq, asignService.APIAddUserRsp](
  106. asignService.APIReq[asignService.APIAddEnterpriseUserReq]{Data: req}, asignService.APIURL_V2_User_AddEnterpriseUser); err == nil {
  107. appG.Response(http.StatusOK, e.SUCCESS, rsp)
  108. } else {
  109. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  110. }
  111. }
  112. // TestGetUser 获取用户信息(测试)
  113. // @Summary 获取用户信息(测试)
  114. // @Produce json
  115. // @accept application/json
  116. // @Param data body asignService.APIGetUserReq true "入参"
  117. // @Success 200 {object} asignService.APIGetUserReq
  118. // @Failure 500 {object} app.Response
  119. // @Router /Asign/TestGetUser [post]
  120. // @Tags 爱签
  121. func TestGetUser(c *gin.Context) {
  122. appG := app.Gin{C: c}
  123. // 获取请求参数
  124. var req asignService.APIGetUserReq
  125. if err := appG.C.ShouldBindJSON(&req); err != nil {
  126. logger.GetLogger().Errorf(err.Error())
  127. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  128. return
  129. }
  130. getUserReq := asignService.APIReq[asignService.APIGetUserReq]{
  131. Data: req,
  132. }
  133. apiRsp, err := asignService.APIPost[asignService.APIGetUserReq, []asignService.APIGetUserRsp](getUserReq, asignService.APIURL_GetUser)
  134. if err != nil {
  135. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  136. return
  137. }
  138. appG.Response(http.StatusOK, e.SUCCESS, apiRsp)
  139. }