auth.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. package asign
  2. import (
  3. "mtp2_if/global/app"
  4. "mtp2_if/global/e"
  5. "mtp2_if/logger"
  6. "mtp2_if/models"
  7. "net/http"
  8. asignService "mtp2_if/services/asign"
  9. "github.com/gin-gonic/gin"
  10. )
  11. // BankCard4 银行卡四要素认证
  12. // @Summary 银行卡四要素认证
  13. // @Produce json
  14. // @Security ApiKeyAuth
  15. // @accept application/json
  16. // @Param data body asignService.BankCard4Req true "入参"
  17. // @Success 200 {object} asignService.BankCard4Rsp
  18. // @Failure 500 {object} app.Response
  19. // @Router /Asign/BankCard4 [post]
  20. // @Tags 爱签
  21. func BankCard4(c *gin.Context) {
  22. appG := app.Gin{C: c}
  23. // 获取请求参数
  24. var req asignService.BankCard4Req
  25. if err := appG.C.ShouldBindJSON(&req); err != nil {
  26. logger.GetLogger().Errorf(err.Error())
  27. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  28. return
  29. }
  30. if rsp, err := asignService.BankCard4(req); 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. // @Security ApiKeyAuth
  41. // @accept application/json
  42. // @Param data body asignService.CaptchaResendReq true "入参"
  43. // @Success 200 {object} app.Response
  44. // @Failure 500 {object} app.Response
  45. // @Router /Asign/CaptcaResend [post]
  46. // @Tags 爱签
  47. func CaptcaResend(c *gin.Context) {
  48. appG := app.Gin{C: c}
  49. // 获取请求参数
  50. var req asignService.CaptchaResendReq
  51. if err := appG.C.ShouldBindJSON(&req); err != nil {
  52. logger.GetLogger().Errorf(err.Error())
  53. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  54. return
  55. }
  56. if err := asignService.CaptcaResend(req); err == nil {
  57. appG.Response(http.StatusOK, e.SUCCESS, "ok")
  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. // @Security ApiKeyAuth
  67. // @accept application/json
  68. // @Param data body asignService.CaptchaVerifyReq true "入参"
  69. // @Success 200 {object} app.Response
  70. // @Failure 500 {object} app.Response
  71. // @Router /Asign/CaptchaVerify [post]
  72. // @Tags 爱签
  73. func CaptchaVerify(c *gin.Context) {
  74. appG := app.Gin{C: c}
  75. // 获取请求参数
  76. var req asignService.CaptchaVerifyReq
  77. if err := appG.C.ShouldBindJSON(&req); err != nil {
  78. logger.GetLogger().Errorf(err.Error())
  79. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  80. return
  81. }
  82. if err := asignService.CaptchaVerify(req); err == nil {
  83. appG.Response(http.StatusOK, e.SUCCESS, "ok")
  84. } else {
  85. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  86. }
  87. }
  88. // CaptchaVerify 同步合同状态
  89. // @Summary 同步合同状态
  90. // @Description 此接口会调用爱签合同状态查询接口,并同步到交易系统用户电子签记录表记录中
  91. // @Produce json
  92. // @accept application/json
  93. // @Param data body asignService.SyncContractStatusReq true "入参"
  94. // @Success 200 {object} asignService.SyncContractStatusRsp
  95. // @Failure 500 {object} app.Response
  96. // @Router /Asign/SyncContractStatus [post]
  97. // @Tags 爱签
  98. func SyncContractStatus(c *gin.Context) {
  99. appG := app.Gin{C: c}
  100. // 获取请求参数
  101. var req asignService.SyncContractStatusReq
  102. if err := appG.C.ShouldBindJSON(&req); err != nil {
  103. logger.GetLogger().Errorf(err.Error())
  104. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  105. return
  106. }
  107. if rsp, err := asignService.SyncContractStatus(req); 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. // QueryUsereSignRecords 查询用户电子签记录表
  114. // @Summary 查询用户电子签记录表
  115. // @Produce json
  116. // @Security ApiKeyAuth
  117. // @accept application/json
  118. // @Param userId query int true "用户ID"
  119. // @Param memberUserId query int true "所属会员ID"
  120. // @Param recordId query int false "记录ID"
  121. // @Param templateConfigId query int false "模板配置ID"
  122. // @Param templatetype query int false "模板类型 - 1:实名认证 2:开户协议 3:日结算单 4:交易协议"
  123. // @Success 200 {array} models.Useresignrecord
  124. // @Failure 500 {object} app.Response
  125. // @Router /Asign/QueryUsereSignRecords [get]
  126. // @Tags 爱签
  127. func QueryUsereSignRecords(c *gin.Context) {
  128. appG := app.Gin{C: c}
  129. // 获取请求参数
  130. var req asignService.QueryUsereSignRecordsReq
  131. if err := appG.C.ShouldBindQuery(&req); err != nil {
  132. logger.GetLogger().Errorf("QueryUsereSignRecords failed: %s", err.Error())
  133. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  134. return
  135. }
  136. if rsp, err := models.QueryUsereSignRecords(req.UserId, req.MemberUserId, req.RecordId, req.TemplateConfigId, req.Templatetype); err == nil {
  137. appG.Response(http.StatusOK, e.SUCCESS, rsp)
  138. } else {
  139. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  140. }
  141. }