style: 错误信息英文返回-system 模块路由

This commit is contained in:
TsMask
2023-11-08 14:56:36 +08:00
parent ae7f2d050c
commit a102f772cb
21 changed files with 460 additions and 342 deletions

View File

@@ -60,7 +60,7 @@ func (s *SysProfileController) Info(c *gin.Context) {
}
isAdmin := config.IsAdmin(loginUser.UserID)
if isAdmin {
roleGroup = append(roleGroup, "管理员")
roleGroup = append(roleGroup, "Administrator")
}
// 查询用户所属岗位组
@@ -93,7 +93,7 @@ func (s *SysProfileController) UpdateProfile(c *gin.Context) {
}
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.Sex == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -111,12 +111,14 @@ func (s *SysProfileController) UpdateProfile(c *gin.Context) {
if regular.ValidMobile(body.PhoneNumber) {
uniquePhone := s.sysUserService.CheckUniquePhone(body.PhoneNumber, userId)
if !uniquePhone {
msg := fmt.Sprintf("修改用户【%s】失败手机号码已存在", userName)
// 修改用户【%s】失败手机号码已存在
msg := fmt.Sprintf("Failed to modify user [%s], cell phone number already exists", userName)
c.JSON(200, result.ErrMsg(msg))
return
}
} else {
msg := fmt.Sprintf("修改用户【%s】失败手机号码格式错误", userName)
// 修改用户【%s】失败手机号码格式错误
msg := fmt.Sprintf("Failed to modify user [%s], wrong format of cell phone number", userName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -127,12 +129,14 @@ func (s *SysProfileController) UpdateProfile(c *gin.Context) {
if regular.ValidEmail(body.Email) {
uniqueEmail := s.sysUserService.CheckUniqueEmail(body.Email, userId)
if !uniqueEmail {
msg := fmt.Sprintf("修改用户【%s】失败邮箱已存在", userName)
// 修改用户【%s】失败邮箱已存在
msg := fmt.Sprintf("Failed to modify user [%s], mailbox already exists", userName)
c.JSON(200, result.ErrMsg(msg))
return
}
} else {
msg := fmt.Sprintf("修改用户【%s】失败邮箱格式错误", userName)
// 修改用户【%s】失败邮箱格式错误
msg := fmt.Sprintf("Failed to modify user [%s], mailbox format error", userName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -165,7 +169,8 @@ func (s *SysProfileController) UpdateProfile(c *gin.Context) {
c.JSON(200, result.Ok(nil))
return
}
c.JSON(200, result.ErrMsg("上传图片异常"))
// 上传图片异常
c.JSON(200, result.ErrMsg("Upload Image Exception"))
}
// 个人重置密码
@@ -180,7 +185,7 @@ func (s *SysProfileController) UpdatePwd(c *gin.Context) {
}
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -196,19 +201,22 @@ func (s *SysProfileController) UpdatePwd(c *gin.Context) {
// 查询当前登录用户信息得到密码值
user := s.sysUserService.SelectUserById(userId)
if user.UserID != userId {
c.JSON(200, result.ErrMsg("没有权限访问用户数据!"))
// 没有可访问用户数据!
c.JSON(200, result.ErrMsg("There is no accessible user data!"))
return
}
// 检查匹配用户密码
oldCompare := crypto.BcryptCompare(body.OldPassword, user.Password)
if !oldCompare {
c.JSON(200, result.ErrMsg("修改密码失败,旧密码错误"))
// 修改密码失败,旧密码错误
c.JSON(200, result.ErrMsg("Failed to change password, old password is wrong"))
return
}
newCompare := crypto.BcryptCompare(body.NewPassword, user.Password)
if newCompare {
c.JSON(200, result.ErrMsg("新密码不能与旧密码相同"))
// 新密码不能与旧密码相同
c.JSON(200, result.ErrMsg("The new password cannot be the same as the old one"))
return
}
@@ -232,7 +240,7 @@ func (s *SysProfileController) UpdatePwd(c *gin.Context) {
func (s *SysProfileController) Avatar(c *gin.Context) {
formFile, err := c.FormFile("file")
if err != nil {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}