update_account_info.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package handler
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. log "github.com/sirupsen/logrus"
  6. "youngee_b_api/consts"
  7. "youngee_b_api/model/http_model"
  8. "youngee_b_api/service"
  9. "youngee_b_api/util"
  10. )
  11. func WrapUpdateAccountInfoHandler(ctx *gin.Context) {
  12. handler := newUpdateAccountInfoHandler(ctx)
  13. baseRun(handler)
  14. }
  15. func newUpdateAccountInfoHandler(ctx *gin.Context) *UpdateAccountInfoHandler {
  16. return &UpdateAccountInfoHandler{
  17. req: http_model.NewUpdateAccountInfoRequest(),
  18. resp: http_model.NewUpdateAccountInfoResponse(),
  19. ctx: ctx,
  20. }
  21. }
  22. type UpdateAccountInfoHandler struct {
  23. req *http_model.UpdateAccountInfoRequest
  24. resp *http_model.CommonResponse
  25. ctx *gin.Context
  26. }
  27. func (h *UpdateAccountInfoHandler) getRequest() interface{} {
  28. return h.req
  29. }
  30. func (h *UpdateAccountInfoHandler) getContext() *gin.Context {
  31. return h.ctx
  32. }
  33. func (h *UpdateAccountInfoHandler) getResponse() interface{} {
  34. return h.resp
  35. }
  36. func (h *UpdateAccountInfoHandler) run() {
  37. data, tag, err := service.LoginAuth.UpdateEnterpriseAccountInfo(h.ctx, h.req)
  38. if err != nil {
  39. logrus.Errorf("[UpdateSupplierAccountInfo] call SetSession err:%+v\n", err)
  40. util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, err.Error())
  41. log.Info("UpdateSupplierAccountInfo fail,req:%+v", h.req)
  42. h.resp.Message = err.Error()
  43. h.resp.Status = 40000
  44. return
  45. }
  46. if tag == 1 {
  47. h.resp.Message = "验证码校验错误"
  48. h.resp.Status = 34000
  49. return
  50. }
  51. if tag == 2 {
  52. h.resp.Message = "手机号已经被其他主账号绑定"
  53. h.resp.Status = 35000
  54. return
  55. }
  56. if tag == 3 {
  57. h.resp.Message = "手机号已经被其他子账号绑定"
  58. h.resp.Status = 36000
  59. return
  60. }
  61. h.resp.Data = data
  62. h.resp.Status = 20000
  63. h.resp.Message = "ok"
  64. }
  65. func (h *UpdateAccountInfoHandler) checkParam() error {
  66. return nil
  67. }