This commit is contained in:
oneao committed 2025-08-14 21:45:18 +08:00
1 parent 4e42a01b97
commit 428d370874
8 files changed
+84 -44

No files matched your search

@@ -2,9 +2,9 @@ package handle
import (
"base-framework/pkg/config"
"base-framework/pkg/reponse"
"base-framework/pkg/router"
"base-framework/pkg/utils/jwt"
"base-framework/pkg/utils/response"
)
// Login 登录接口
@@ -17,23 +17,23 @@ func Login(c *router.Context) {
}
if err := c.BindJSON(&req); err != nil {
response.Error(c).Message("请求体不能为空").Send()
reponse.Error(c).Message("请求体不能为空").Send()
return
}
if req.OrgID == "" {
response.Error(c).Message("机构码不能为空").Send()
reponse.Error(c).Message("机构码不能为空").Send()
return
}
// 参数校验
if req.UserID == "" {
response.Error(c).Message("账户不能为空").Send()
reponse.Error(c).Message("账户不能为空").Send()
return
}
if req.Password == "" {
response.Error(c).Message("密码不能为空").Send()
reponse.Error(c).Message("密码不能为空").Send()
return
}
@@ -47,7 +47,7 @@ func Login(c *router.Context) {
}
if !hasOrg {
response.Error(c).Code(response.CodeInvalidOrgCode).Send()
reponse.Error(c).Code(reponse.CodeInvalidOrgCode).Send()
return
}
@@ -55,11 +55,11 @@ func Login(c *router.Context) {
token, err := jwt.CreateToken(req.OrgID, req.UserID)
if err != nil {
response.Error(c).Message("生成令牌失败")
reponse.Error(c).Message("生成令牌失败")
return
}
response.Success(c).Data(
reponse.Success(c).Data(
map[string]string{
"token": token,
}).Send()