update_sub_account.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 WrapUpdateSubAccountHandler(ctx *gin.Context) {
  12. handler := newUpdateSubAccountHandler(ctx)
  13. baseRun(handler)
  14. }
  15. func newUpdateSubAccountHandler(ctx *gin.Context) *UpdateSubAccountHandler {
  16. return &UpdateSubAccountHandler{
  17. req: http_model.NewUpdateSubAccountRequest(),
  18. resp: http_model.NewUpdateSubAccountResponse(),
  19. ctx: ctx,
  20. }
  21. }
  22. type UpdateSubAccountHandler struct {
  23. req *http_model.UpdateSubAccountRequest
  24. resp *http_model.CommonResponse
  25. ctx *gin.Context
  26. }
  27. func (h *UpdateSubAccountHandler) getRequest() interface{} {
  28. return h.req
  29. }
  30. func (h *UpdateSubAccountHandler) getContext() *gin.Context {
  31. return h.ctx
  32. }
  33. func (h *UpdateSubAccountHandler) getResponse() interface{} {
  34. return h.resp
  35. }
  36. func (h *UpdateSubAccountHandler) run() {
  37. tag, data, err := service.LoginAuth.UpdateSubAccount(h.ctx, *h.req)
  38. if err != nil {
  39. logrus.Errorf("[FindSubAccountBySupplierId] call SetSession err:%+v\n", err)
  40. util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, err.Error())
  41. log.Info("FindSubAccountBySupplierId fail,req:%+v", h.req)
  42. h.resp.Message = err.Error()
  43. h.resp.Data = nil
  44. h.resp.Status = 40000
  45. return
  46. }
  47. if tag == 1 {
  48. h.resp.Data = data
  49. h.resp.Status = 34000
  50. h.resp.Message = "验证码校验错误"
  51. return
  52. }
  53. if tag == 2 {
  54. h.resp.Data = data
  55. h.resp.Status = 35000
  56. h.resp.Message = "此号码已被其他主账号绑定"
  57. return
  58. }
  59. if tag == 3 {
  60. h.resp.Data = data
  61. h.resp.Status = 36000
  62. h.resp.Message = "此号码已被其他子账号绑定"
  63. return
  64. }
  65. h.resp.Data = data
  66. h.resp.Status = 20000
  67. h.resp.Message = "ok"
  68. }
  69. func (h *UpdateSubAccountHandler) checkParam() error {
  70. return nil
  71. }