package handler import ( "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus" "youngee_b_api/model/http_model" "youngee_b_api/service" ) func WrapCodeLoginHandler(ctx *gin.Context) { handler := newCodeLoginHandler(ctx) baseRun(handler) } func newCodeLoginHandler(ctx *gin.Context) *CodeLoginHandler { return &CodeLoginHandler{ req: http_model.NewCodeLoginRequest(), resp: http_model.NewCodeLoginResponse(), ctx: ctx, } } type CodeLoginHandler struct { req *http_model.CodeLoginRequest resp *http_model.CommonResponse ctx *gin.Context } func (h *CodeLoginHandler) getRequest() interface{} { return h.req } func (h *CodeLoginHandler) getContext() *gin.Context { return h.ctx } func (h *CodeLoginHandler) getResponse() interface{} { return h.resp } func (h *CodeLoginHandler) run() { tag, userData, err := service.LoginAuth.AuthCode(h.ctx, h.req.Phone, h.req.Code) if err != nil { logrus.Errorf("[CodeLoginHandler] call AuthCode err:%+v\n", err) // util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, msg) log.Info("login fail,req:%+v", h.req) h.resp.Status = 40000 h.resp.Message = err.Error() h.resp.Data = nil return } if tag == 1 { h.resp.Status = 34000 h.resp.Message = "验证码校验错误" h.resp.Data = nil return } if tag == 2 { h.resp.Status = 34500 h.resp.Message = "账户已停用" h.resp.Data = nil return } var data *http_model.CodeLoginData data = userData h.resp.Data = data } func (h *CodeLoginHandler) checkParam() error { return nil }