certification.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package account
  2. import (
  3. "mtp20access/global"
  4. "mtp20access/model/account/request"
  5. "mtp20access/model/common/response"
  6. signService "mtp20access/service/sign"
  7. "mtp20access/utils"
  8. "net/http"
  9. "github.com/gin-gonic/gin"
  10. "go.uber.org/zap"
  11. )
  12. // AddUser 查询用户电子签记录表
  13. // @Summary 查询用户电子签记录表
  14. // @Security ApiKeyAuth
  15. // @accept application/json
  16. // @Produce application/json
  17. // @Success 200 {object} response.Response{data=[]account.Useresignrecord,msg=string} "出参"
  18. // @Router /Account/QueryUserESignRecord [get]
  19. // @Tags 账户服务
  20. func QueryUserESignRecord(c *gin.Context) {
  21. g := utils.GinUtils{C: c}
  22. // 获取请求账号信息
  23. claims := g.GetClaims()
  24. if g.Err != nil {
  25. return
  26. }
  27. if rsp, err := signService.QueryUserESignRecord(claims.UserID); err == nil {
  28. response.OkWithDetailed(rsp, "查询成功", g.C)
  29. } else {
  30. global.M2A_LOG.Error(err.Error(), zap.Error(err))
  31. response.FailWithMessage(err.Error(), c)
  32. }
  33. }
  34. // AddUser 实名认证添加用户
  35. // @Summary 实名认证添加用户
  36. // @Security ApiKeyAuth
  37. // @accept application/json
  38. // @Produce application/json
  39. // @Param data body request.AddUserReq true "入参"
  40. // @Success 200 {object} response.Response{msg=string} "出参"
  41. // @Router /Account/AddUser [post]
  42. // @Tags 账户服务
  43. func AddUser(c *gin.Context) {
  44. g := utils.GinUtils{C: c}
  45. r := request.AddUserReq{}
  46. g.BindJsonReq(&r)
  47. if g.Err != nil {
  48. return
  49. }
  50. // 获取请求账号信息
  51. claims := g.GetClaims()
  52. if g.Err != nil {
  53. return
  54. }
  55. if err := signService.AddUser(r, claims.UserID); err == nil {
  56. response.Ok(g.C)
  57. } else {
  58. global.M2A_LOG.Error(err.Error(), zap.Error(err))
  59. response.FailWithMessage(err.Error(), c)
  60. }
  61. }
  62. // CreateContractAndAddSigner 上传待签署文件和添加签署方
  63. // @Summary 上传待签署文件和添加签署方
  64. // @Security ApiKeyAuth
  65. // @accept application/json
  66. // @Produce application/json
  67. // @Param data body request.CreateContractAndAddSignerReq true "入参"
  68. // @Success 200 {object} response.Response{data=string,msg=string} "出参"
  69. // @Router /Account/CreateContractAndAddSigner [post]
  70. // @Tags 账户服务
  71. func CreateContractAndAddSigner(c *gin.Context) {
  72. g := utils.GinUtils{C: c}
  73. r := request.CreateContractAndAddSignerReq{}
  74. g.BindJsonReq(&r)
  75. if g.Err != nil {
  76. return
  77. }
  78. // 获取请求账号信息
  79. claims := g.GetClaims()
  80. if g.Err != nil {
  81. return
  82. }
  83. if rsp, err := signService.CreateContractAndAddSigner(r, claims.UserID); err == nil {
  84. response.OkWithDetailed(rsp, "操作成功", g.C)
  85. } else {
  86. global.M2A_LOG.Error(err.Error(), zap.Error(err))
  87. response.FailWithMessage(err.Error(), c)
  88. }
  89. }
  90. // SignCompleted 提交实名认证
  91. // @Summary 提交实名认证
  92. // @Security ApiKeyAuth
  93. // @accept application/json
  94. // @Produce application/json
  95. // @Success 200 {object} response.Response{msg=string} "出参"
  96. // @Router /Account/SignCompleted [post]
  97. // @Tags 账户服务
  98. func SignCompleted(c *gin.Context) {
  99. g := utils.GinUtils{C: c}
  100. // 获取请求账号信息
  101. claims := g.GetClaims()
  102. if g.Err != nil {
  103. return
  104. }
  105. if err := signService.SignCompleted(claims.UserID); err == nil {
  106. response.OkWithMessage("操作成功", g.C)
  107. } else {
  108. global.M2A_LOG.Error(err.Error(), zap.Error(err))
  109. response.FailWithMessage(err.Error(), c)
  110. }
  111. }
  112. // POST
  113. func HandleASignCompleted(c *gin.Context) {
  114. g := utils.GinUtils{C: c}
  115. r := request.HandleASignCompletedReq{}
  116. g.BindJsonReq(&r)
  117. if g.Err != nil {
  118. return
  119. }
  120. if err := signService.HandleASignCompleted(r); err == nil {
  121. g.C.String(http.StatusOK, "%s", "ok")
  122. } else {
  123. global.M2A_LOG.Error(err.Error(), zap.Error(err))
  124. response.FailWithMessage(err.Error(), c)
  125. }
  126. }