This commit is contained in:
2026-08-16 20:58:57 +08:00
parent a85477be80
commit a9e1f9e6f8
42 changed files with 1569 additions and 156 deletions
+1 -1
View File
@@ -160,7 +160,7 @@ func (h *Menu) AuthorityMenus(c *gin.Context) {
}
menus, err := h.service.AuthorityMenus(c.Request.Context(), req.AuthorityID)
if err != nil {
httpx.Fail(c, "获取失败")
httpx.Write(c, httpx.CodeError, gin.H{"menus": menus}, "获取失败")
return
}
httpx.Write(c, httpx.CodeSuccess, gin.H{"menus": menus}, "获取成功")
+13 -1
View File
@@ -67,7 +67,11 @@ func (h *User) Create(c *gin.Context) {
}
result, err := h.service.CreateUserRequest(c.Request.Context(), &req)
if err != nil {
httpx.Fail(c, "注册失败")
if service.IsPasswordPolicyError(err) {
httpx.Fail(c, err.Error())
return
}
httpx.Write(c, httpx.CodeError, gin.H{"user": dto.UserResponse{}}, "注册失败")
return
}
httpx.Write(c, httpx.CodeSuccess, gin.H{"user": result}, "注册成功")
@@ -138,6 +142,10 @@ func (h *User) ResetPassword(c *gin.Context) {
return
}
if err := h.service.ResetPassword(c.Request.Context(), req.ID, req.Password); err != nil {
if service.IsPasswordPolicyError(err) {
httpx.Fail(c, err.Error())
return
}
httpx.Fail(c, "重置失败"+err.Error())
return
}
@@ -164,6 +172,10 @@ func (h *User) ChangePassword(c *gin.Context) {
return
}
if err := h.service.ChangePassword(c.Request.Context(), claims.ID, req.Password, req.NewPassword); err != nil {
if service.IsPasswordPolicyError(err) {
httpx.Fail(c, err.Error())
return
}
httpx.Fail(c, "修改失败,原密码与当前账户不符")
return
}