addNewSubAccount.go 1.5 KB

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