addNewSubAccount.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package handler
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "youngee_b_api/model/http_model"
  5. "youngee_b_api/service"
  6. )
  7. func WrapAddNewSubAccountHandler(ctx *gin.Context) {
  8. handler := newAddNewSubAccountHandler(ctx)
  9. baseRun(handler)
  10. }
  11. func newAddNewSubAccountHandler(ctx *gin.Context) *AddNewSubAccountHandler {
  12. return &AddNewSubAccountHandler{
  13. req: http_model.NewAddSubAccountRequest(),
  14. resp: http_model.NewAddSubAccountResponse(),
  15. ctx: ctx,
  16. }
  17. }
  18. type AddNewSubAccountHandler struct {
  19. req *http_model.AddNewSubAccountRequest
  20. resp *http_model.CommonResponse
  21. ctx *gin.Context
  22. }
  23. func (h *AddNewSubAccountHandler) getRequest() interface{} {
  24. return h.req
  25. }
  26. func (h *AddNewSubAccountHandler) getContext() *gin.Context {
  27. return h.ctx
  28. }
  29. func (h *AddNewSubAccountHandler) getResponse() interface{} {
  30. return h.resp
  31. }
  32. func (h *AddNewSubAccountHandler) run() {
  33. // 1. 验证码校验
  34. tag, data, err := service.LoginAuth.SubAccountAuthCode(h.ctx, h.req)
  35. if err != nil {
  36. h.resp.Data = data
  37. h.resp.Message = err.Error()
  38. h.resp.Status = 40000
  39. return
  40. }
  41. if tag == 1 {
  42. h.resp.Data = data
  43. h.resp.Message = "验证码校验错误"
  44. h.resp.Status = 34000
  45. return
  46. }
  47. if tag == 2 {
  48. h.resp.Data = data
  49. h.resp.Message = "此手机号已被已认证的服务商主账号绑定"
  50. h.resp.Status = 35000
  51. return
  52. }
  53. if tag == 3 {
  54. h.resp.Data = data
  55. h.resp.Message = "此手机号已被服务商子账号绑定"
  56. h.resp.Status = 36000
  57. return
  58. }
  59. h.resp.Data = data
  60. h.resp.Message = "ok"
  61. h.resp.Status = 20000
  62. }
  63. func (h *AddNewSubAccountHandler) checkParam() error {
  64. return nil
  65. }