123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- 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"
- "github.com/sirupsen/logrus"
- log "github.com/sirupsen/logrus"
- )
- 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() {
- token, 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, token)
- log.Info("login fail,req:%+v", h.req)
- return
- }
- data := http_model.CodeLoginData{}
- data.Token = token
- // h.resp.Message = "登陆成功"
- h.resp.Data = data
- }
- func (h *CodeLoginHandler) checkParam() error {
- return nil
- }
|