12345678910111213141516171819202122232425262728293031323334 |
- package controller
- import (
- "github.com/gin-gonic/gin"
- "github.com/go-playground/validator/v10"
- "hongze/fms_api/controller/resp"
- "hongze/fms_api/global"
- "hongze/fms_api/models/system"
- systemService "hongze/fms_api/services/system"
- )
- type AuthController struct {
- }
- func (a *AuthController) Login(c *gin.Context) {
- req := new(system.LoginReq)
- err := c.ShouldBind(&req)
- if err != nil {
- errs, ok := err.(validator.ValidationErrors)
- if !ok {
- resp.FailData("参数解析失败", "Err:"+err.Error(), c)
- return
- }
- resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
- return
- }
- ret, err, errMsg := systemService.Login(req.AdminName, req.Password, req.IsRemember)
- if err != nil {
- resp.FailMsg(errMsg, err.Error(), c)
- return
- }
- resp.OkData("登录成功", ret, c)
- return
- }
|