auth.go 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. // CaptchaVerify 创建印章
  12. // @Summary 创建印章
  13. // @Produce json
  14. // @Security ApiKeyAuth
  15. // @accept application/json
  16. // @Param data body asignService.CreateSealReq true "入参"
  17. // @Success 200 {object} app.Response
  18. // @Failure 500 {object} app.Response
  19. // @Router /Asign/CreateSeal [post]
  20. // @Tags 爱签
  21. func CreateSeal(c *gin.Context) {
  22. appG := app.Gin{C: c}
  23. // 获取请求参数
  24. var req asignService.CreateSealReq
  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 err := asignService.CreateSeal(req); err == nil {
  31. appG.Response(http.StatusOK, e.SUCCESS, "ok")
  32. } else {
  33. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  34. }
  35. }
  36. // BankCard4 银行卡四要素认证
  37. // @Summary 银行卡四要素认证
  38. // @Produce json
  39. // @Security ApiKeyAuth
  40. // @accept application/json
  41. // @Param data body asignService.BankCard4Req true "入参"
  42. // @Success 200 {object} asignService.BankCard4Rsp
  43. // @Failure 500 {object} app.Response
  44. // @Router /Asign/BankCard4 [post]
  45. // @Tags 爱签
  46. func BankCard4(c *gin.Context) {
  47. appG := app.Gin{C: c}
  48. // 获取请求参数
  49. var req asignService.BankCard4Req
  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.BankCard4(req); 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. // CaptcaResend 重新发送认证验证码
  62. // @Summary 重新发送认证验证码
  63. // @Description 在实名认证的过程中,因用户手机原因未收到短信验证码或原验证码超过15分钟有效期而过期时,可以调用此接口重新发送短信验证码。若1分钟内多次调用此接口,则仅会发送一次短信验证码,15分钟内重新发送短信验证码不会变化。
  64. // @Produce json
  65. // @Security ApiKeyAuth
  66. // @accept application/json
  67. // @Param data body asignService.CaptchaResendReq true "入参"
  68. // @Success 200 {object} app.Response
  69. // @Failure 500 {object} app.Response
  70. // @Router /Asign/CaptcaResend [post]
  71. // @Tags 爱签
  72. func CaptcaResend(c *gin.Context) {
  73. appG := app.Gin{C: c}
  74. // 获取请求参数
  75. var req asignService.CaptchaResendReq
  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 err := asignService.CaptcaResend(req); err == nil {
  82. appG.Response(http.StatusOK, e.SUCCESS, "ok")
  83. } else {
  84. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  85. }
  86. }
  87. // CaptchaVerify 认证验证码校验
  88. // @Summary 认证验证码校验
  89. // @Description 验证码认证成功后会调用爱签添加用户接口,同时调用交易系统JAVA实名认证接口
  90. // @Produce json
  91. // @Security ApiKeyAuth
  92. // @accept application/json
  93. // @Param data body asignService.CaptchaVerifyReq true "入参"
  94. // @Success 200 {object} app.Response
  95. // @Failure 500 {object} app.Response
  96. // @Router /Asign/CaptchaVerify [post]
  97. // @Tags 爱签
  98. func CaptchaVerify(c *gin.Context) {
  99. appG := app.Gin{C: c}
  100. // 获取请求参数
  101. var req asignService.CaptchaVerifyReq
  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 err := asignService.CaptchaVerify(req); err == nil {
  108. appG.Response(http.StatusOK, e.SUCCESS, "ok")
  109. } else {
  110. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  111. }
  112. }
  113. // CaptchaVerify 同步合同状态
  114. // @Summary 同步合同状态
  115. // @Description 此接口会调用爱签合同状态查询接口,并同步到交易系统用户电子签记录表记录中
  116. // @Produce json
  117. // @accept application/json
  118. // @Param data body asignService.SyncContractStatusReq true "入参"
  119. // @Success 200 {object} asignService.SyncContractStatusRsp
  120. // @Failure 500 {object} app.Response
  121. // @Router /Asign/SyncContractStatus [post]
  122. // @Tags 爱签
  123. func SyncContractStatus(c *gin.Context) {
  124. appG := app.Gin{C: c}
  125. // 获取请求参数
  126. var req asignService.SyncContractStatusReq
  127. if err := appG.C.ShouldBindJSON(&req); err != nil {
  128. logger.GetLogger().Errorf(err.Error())
  129. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  130. return
  131. }
  132. if rsp, err := asignService.SyncContractStatus(req); err == nil {
  133. appG.Response(http.StatusOK, e.SUCCESS, rsp)
  134. } else {
  135. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  136. }
  137. }
  138. // QueryUsereSignRecords 查询用户电子签记录表
  139. // @Summary 查询用户电子签记录表
  140. // @Produce json
  141. // @Security ApiKeyAuth
  142. // @accept application/json
  143. // @Param userId query int true "用户ID"
  144. // @Param memberUserId query int true "所属会员ID"
  145. // @Param recordId query int false "记录ID"
  146. // @Param templateConfigId query int false "模板配置ID"
  147. // @Param templatetype query int false "模板类型 - 1:实名认证 2:开户协议 3:日结算单 4:交易协议"
  148. // @Success 200 {array} models.Useresignrecord
  149. // @Failure 500 {object} app.Response
  150. // @Router /Asign/QueryUsereSignRecords [get]
  151. // @Tags 爱签
  152. func QueryUsereSignRecords(c *gin.Context) {
  153. appG := app.Gin{C: c}
  154. // 获取请求参数
  155. var req asignService.QueryUsereSignRecordsReq
  156. if err := appG.C.ShouldBindQuery(&req); err != nil {
  157. logger.GetLogger().Errorf("QueryUsereSignRecords failed: %s", err.Error())
  158. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  159. return
  160. }
  161. if rsp, err := models.QueryUsereSignRecords(req.UserId, req.MemberUserId, req.RecordId, req.TemplateConfigId, req.Templatetype); err == nil {
  162. appG.Response(http.StatusOK, e.SUCCESS, rsp)
  163. } else {
  164. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  165. }
  166. }
  167. // BankCard4 个人意愿核身认证(双录)
  168. // @Summary 个人意愿核身认证(双录)
  169. // @Produce json
  170. // @Security ApiKeyAuth
  171. // @accept application/json
  172. // @Param data body asignService.WillFaceReq true "入参"
  173. // @Success 200 {object} asignService.WillFaceRsp
  174. // @Failure 500 {object} app.Response
  175. // @Router /Asign/WillFace [post]
  176. // @Tags 爱签
  177. func WillFace(c *gin.Context) {
  178. appG := app.Gin{C: c}
  179. // 获取请求参数
  180. var req asignService.WillFaceReq
  181. if err := appG.C.ShouldBindJSON(&req); err != nil {
  182. logger.GetLogger().Errorf(err.Error())
  183. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  184. return
  185. }
  186. if rsp, err := asignService.WillFace(req); err == nil {
  187. appG.Response(http.StatusOK, e.SUCCESS, rsp)
  188. } else {
  189. appG.ResponseByMsg(http.StatusBadRequest, e.ERROR, err.Error(), nil)
  190. }
  191. }