package handlers import ( "github.com/gin-gonic/gin" "shopperthree_manage_v2/app/business" "shopperthree_manage_v2/app/models" "shopperthree_manage_v2/logger" "shopperthree_manage_v2/pkg/ierr" ) /** * showdoc * @catalog 登录 * @title 登录接口 * @description 登录接口 * @method POST * @url ~/v1/login * @param phone 必选 string 手机号码 * @param password 必选 string 密码 * @return {"code":0,"data":{"user_id":"3543","phone":"18522905678","token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOiIzNTQzIiwiUGhvbmUiOiIxODUyMjkwNTY3OCIsIkV4cGlyZSI6MTU5OTc1MDE1OSwiUm9sZSI6Mn0.yzhKxq4CAYG-YdRIZOj83Buupp2WsooS4K4iAgCFnT0","role":2}} * @return_param user_id string 用户id * @return_param phone string 手机号码 * @return_param token string 后面要用的token * @return_param role int 角色(1商户2管理员) * @remark (请求需要在header上面带上token,如果是商户key为merchant_token,如果是管理员key为admin_token) * @number 2 */ func Login(c *gin.Context) { var req models.LoginRequest if err := c.ShouldBind(&req); err != nil { logger.Error("Login bind err", logger.Err(err), logger.Any("req", req), ) ResponseErr(c, ierr.NewIError(ierr.ParamErr, err.Error())) return } reply, err := business.Login(&req) if err != nil { logger.Error("Login err", logger.Err(err), logger.Any("req", req), ) ResponseErr(c, err) return } ResponseSuccess(c, reply) }