package handler import ( "youngee_b_api/consts" "youngee_b_api/model/http_model" "youngee_b_api/service" "youngee_b_api/util" "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" ) func WrapPasswordLoginHandler(ctx *gin.Context) { handler := newPasswordLoginHandler(ctx) baseRun(handler) } func newPasswordLoginHandler(ctx *gin.Context) *PasswordLoginHandler { return &PasswordLoginHandler{ req: http_model.NewPasswordLoginRequest(), resp: http_model.NewPasswordLoginResponse(), ctx: ctx, } } type PasswordLoginHandler struct { req *http_model.PasswordLoginRequest resp *http_model.CommonResponse ctx *gin.Context } func (h *PasswordLoginHandler) getRequest() interface{} { return h.req } func (h *PasswordLoginHandler) getContext() *gin.Context { return h.ctx } func (h *PasswordLoginHandler) getResponse() interface{} { return h.resp } func (h *PasswordLoginHandler) run() { data := http_model.PasswordLoginData{} data.Token = h.req.UserPhone auth := service.LoginAuth.AuthPassword(h.ctx, h.req.UserPhone, h.req.UserPasswd) if auth == nil { util.HandlerPackErrorResp(h.resp, consts.ErrorInternal) log.Info("login fail,req:%+v", h.req) return } h.resp.Data = data } func (h *PasswordLoginHandler) checkParam() error { return nil }