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

@@ -1,7 +1,6 @@
package service
import (
"errors"
"fmt"
"strings"
@@ -138,7 +137,8 @@ func (r *SysUserImpl) DeleteUserByIds(userIds []string) (int64, error) {
// 检查是否存在
users := r.sysUserRepository.SelectUserByIds(userIds)
if len(users) <= 0 {
return 0, errors.New("没有权限访问用户数据!")
// 没有可访问用户数据!
return 0, fmt.Errorf("there is no accessible user data")
}
if len(users) == len(userIds) {
// 删除用户与角色关联
@@ -150,7 +150,7 @@ func (r *SysUserImpl) DeleteUserByIds(userIds []string) (int64, error) {
rows := r.sysUserRepository.DeleteUserByIds(userIds)
return rows, nil
}
return 0, errors.New("删除用户信息失败!")
return 0, fmt.Errorf("failed to delete user information")
}
// CheckUniqueUserName 校验用户名称是否唯一
@@ -211,7 +211,8 @@ func (r *SysUserImpl) ImportUser(rows []map[string]string, isUpdateSupport bool,
if !ownItem {
mustItemArrStr := strings.Join(mustItemArr, "、")
failureNum++
failureMsgArr = append(failureMsgArr, fmt.Sprintf("表格中必填列表项,%s}", mustItemArrStr))
// 表格中必填列表项,
failureMsgArr = append(failureMsgArr, fmt.Sprintf("Required list items in the form, %s}", mustItemArrStr))
continue
}
@@ -224,7 +225,7 @@ func (r *SysUserImpl) ImportUser(rows []map[string]string, isUpdateSupport bool,
}
}
sysUserStatus := common.STATUS_NO
if row["G"] == "正常" {
if row["G"] == "Normal" {
sysUserStatus = common.STATUS_YES
}
@@ -246,13 +247,15 @@ func (r *SysUserImpl) ImportUser(rows []map[string]string, isUpdateSupport bool,
if regular.ValidMobile(newSysUser.PhoneNumber) {
uniquePhone := r.CheckUniquePhone(newSysUser.PhoneNumber, "")
if !uniquePhone {
msg := fmt.Sprintf("用户编号:%s 手机号码 %s 已存在", row["A"], row["E"])
// 用户编号:%s 手机号码 %s 已存在
msg := fmt.Sprintf("UserID: %s PhoneNumber: %s pre-existing", row["A"], row["E"])
failureNum++
failureMsgArr = append(failureMsgArr, msg)
continue
}
} else {
msg := fmt.Sprintf("用户编号:%s 手机号码 %s 格式错误", row["A"], row["E"])
// 用户编号:%s 手机号码 %s 格式错误
msg := fmt.Sprintf("UserID: %s PhoneNumber: %s formatting error", row["A"], row["E"])
failureNum++
failureMsgArr = append(failureMsgArr, msg)
continue
@@ -264,13 +267,15 @@ func (r *SysUserImpl) ImportUser(rows []map[string]string, isUpdateSupport bool,
if regular.ValidEmail(newSysUser.Email) {
uniqueEmail := r.CheckUniqueEmail(newSysUser.Email, "")
if !uniqueEmail {
msg := fmt.Sprintf("用户编号:%s 用户邮箱 %s 已存在", row["A"], row["D"])
// 用户编号:%s 用户邮箱 %s 已存在
msg := fmt.Sprintf("UserID: %s Email: %s pre-existing", row["A"], row["D"])
failureNum++
failureMsgArr = append(failureMsgArr, msg)
continue
}
} else {
msg := fmt.Sprintf("用户编号:%s 用户邮箱 %s 格式错误", row["A"], row["D"])
// 用户编号:%s 用户邮箱 %s 格式错误
msg := fmt.Sprintf("UserID: %s Email: %s formatting error", row["A"], row["D"])
failureNum++
failureMsgArr = append(failureMsgArr, msg)
continue
@@ -283,11 +288,13 @@ func (r *SysUserImpl) ImportUser(rows []map[string]string, isUpdateSupport bool,
newSysUser.CreateBy = operName
insertId := r.InsertUser(newSysUser)
if insertId != "" {
msg := fmt.Sprintf("用户编号:%s 登录名称 %s 导入成功", row["A"], row["B"])
// 用户编号:%s 登录名称 %s 导入成功
msg := fmt.Sprintf("UserID: %s UserName: %s import successfully", row["A"], row["B"])
successNum++
successMsgArr = append(successMsgArr, msg)
} else {
msg := fmt.Sprintf("用户编号:%s 登录名称 %s 导入失败", row["A"], row["B"])
// 用户编号:%s 登录名称 %s 导入失败
msg := fmt.Sprintf("UserID: %s UserName: %s import failure", row["A"], row["B"])
failureNum++
failureMsgArr = append(failureMsgArr, msg)
}
@@ -300,11 +307,13 @@ func (r *SysUserImpl) ImportUser(rows []map[string]string, isUpdateSupport bool,
newSysUser.UpdateBy = operName
rows := r.UpdateUser(newSysUser)
if rows > 0 {
msg := fmt.Sprintf("用户编号:%s 登录名称 %s 更新成功", row["A"], row["B"])
// 用户编号:%s 登录名称 %s 更新成功
msg := fmt.Sprintf("UserID: %s UserName: %s Update Successful", row["A"], row["B"])
successNum++
successMsgArr = append(successMsgArr, msg)
} else {
msg := fmt.Sprintf("用户编号:%s 登录名称 %s 更新失败", row["A"], row["B"])
// 用户编号:%s 登录名称 %s 更新失败
msg := fmt.Sprintf("UserID: %s UserName: %s Update Failed", row["A"], row["B"])
failureNum++
failureMsgArr = append(failureMsgArr, msg)
}
@@ -313,10 +322,12 @@ func (r *SysUserImpl) ImportUser(rows []map[string]string, isUpdateSupport bool,
}
if failureNum > 0 {
failureMsgArr = append([]string{fmt.Sprintf("很抱歉,导入失败!共 %d 条数据格式不正确,错误如下:", failureNum)}, failureMsgArr...)
// 很抱歉,导入失败!共 %d 条数据格式不正确,错误如下:
failureMsgArr = append([]string{fmt.Sprintf("Sorry, the import failed! A total of %d entries were formatted incorrectly with the following error:", failureNum)}, failureMsgArr...)
return strings.Join(failureMsgArr, "<br/>")
}
successMsgArr = append([]string{fmt.Sprintf("恭喜您,数据已全部导入成功!共 %d 条,数据如下:", successNum)}, successMsgArr...)
// 恭喜您,数据已全部导入成功!共 %d 条,数据如下:
successMsgArr = append([]string{fmt.Sprintf("Congratulations, the data has been imported successfully! Total %d entries, data below:", successNum)}, successMsgArr...)
return strings.Join(successMsgArr, "<br/>")
}