test.go 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. package asign
  2. import (
  3. "io"
  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. getUserReq := asignService.APIReq[asignService.APIGetUserReq]{
  132. Data: req,
  133. }
  134. apiRsp, err := asignService.APIPost[asignService.APIGetUserReq, asignService.APIGetUserRsp](getUserReq, asignService.APIURL_GetUser)
  135. if err != nil {
  136. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  137. return
  138. }
  139. appG.Response(http.StatusOK, e.SUCCESS, apiRsp)
  140. }
  141. // GetUserSeals 查询印章(测试)
  142. // @Summary 查询印章(测试)
  143. // @Produce json
  144. // @accept application/json
  145. // @Param data body asignService.APIGetUserSealsReq true "入参"
  146. // @Success 200 {object} asignService.APIGetUserSealsRsp
  147. // @Failure 500 {object} app.Response
  148. // @Router /Asign/GetUserSeals [post]
  149. // @Tags 爱签
  150. func GetUserSeals(c *gin.Context) {
  151. appG := app.Gin{C: c}
  152. // 获取请求参数
  153. var req asignService.APIGetUserSealsReq
  154. if err := appG.C.ShouldBindJSON(&req); err != nil {
  155. logger.GetLogger().Errorf(err.Error())
  156. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  157. return
  158. }
  159. r := asignService.APIReq[asignService.APIGetUserSealsReq]{
  160. Data: req,
  161. }
  162. apiRsp, err := asignService.APIPost[asignService.APIGetUserSealsReq, asignService.APIGetUserSealsRsp](r, asignService.APIURL_GetUserSeals)
  163. if err != nil {
  164. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  165. return
  166. }
  167. appG.Response(http.StatusOK, e.SUCCESS, apiRsp)
  168. }
  169. // TestCreateContract 上传待签署文件(测试)
  170. // @Summary 上传待签署文件(测试)
  171. // @Produce json
  172. // @accept application/json
  173. // @Param data body asignService.APICreateContractReq true "入参"
  174. // @Success 200 {object} asignService.APICreateContractRsp
  175. // @Failure 500 {object} app.Response
  176. // @Router /Asign/TestCreateContract [post]
  177. // @Tags 爱签
  178. func TestCreateContract(c *gin.Context) {
  179. appG := app.Gin{C: c}
  180. // 获取请求参数
  181. var req asignService.APICreateContractReq
  182. if err := appG.C.ShouldBindJSON(&req); err != nil {
  183. logger.GetLogger().Errorf(err.Error())
  184. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  185. return
  186. }
  187. r := asignService.APIReq[asignService.APICreateContractReq]{
  188. Data: req,
  189. }
  190. apiRsp, err := asignService.APIPost[asignService.APICreateContractReq, asignService.APICreateContractRsp](r, asignService.APIURL_CreateContract)
  191. if err != nil {
  192. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  193. return
  194. }
  195. appG.Response(http.StatusOK, e.SUCCESS, apiRsp)
  196. }
  197. // TestAPI 文本入参(测试)
  198. // @Summary 文本入参(测试)
  199. // @Produce json
  200. // @accept application/json
  201. // @Param data body string true "入参"
  202. // @Success 200 {object} string
  203. // @Failure 500 {object} app.Response
  204. // @Router /Asign/TestAPI [post]
  205. // @Tags 爱签
  206. func TestAPI(c *gin.Context) {
  207. appG := app.Gin{C: c}
  208. b, err := io.ReadAll(appG.C.Request.Body)
  209. if err != nil {
  210. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  211. return
  212. }
  213. req := string(b)
  214. rspBody, err := asignService.TestAPI(req)
  215. if err != nil {
  216. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  217. return
  218. }
  219. appG.Response(http.StatusOK, e.SUCCESS, string(rspBody))
  220. }