test.go 6.7 KB

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