This commit is contained in:
2023-11-08 16:56:20 +08:00
63 changed files with 781 additions and 556 deletions

View File

@@ -2,6 +2,21 @@
后端
## redis 配置文件相关
```conf
# IP绑定与端口
bind 0.0.0.0
port 6379
# 安全设置
protected-mode yes
requirepass ""
# 从节点只能读取数据,不能直接写入数据
slaveof 192.168.114.114 6379
# 允许从节点进行读写操作
replica-read-only no
```
## 版本发布空间
\\192.168.1.205\share\release\omc

View File

@@ -92,12 +92,12 @@ func (r *ServiceSysConfig) DeleteConfigByIds(configIds []string) (int64, error)
// 检查是否存在
configs := r.sysConfigRepository.SelectConfigByIds(configIds)
if len(configs) <= 0 {
return 0, errors.New("没有权限访问参数配置数据!")
return 0, errors.New("does not have permission to access parameter configuration data")
}
for _, config := range configs {
// 检查是否为内置参数
if config.ConfigType == "Y" {
return 0, errors.New(config.ConfigID + " 配置参数属于内置参数,禁止删除!")
return 0, errors.New(config.ConfigID + " Configuration parameters are built-in parameters and their deletion is prohibited!")
}
// 清除缓存
r.clearConfigCache(config.ConfigKey)
@@ -106,7 +106,7 @@ func (r *ServiceSysConfig) DeleteConfigByIds(configIds []string) (int64, error)
rows := r.sysConfigRepository.DeleteConfigByIds(configIds)
return rows, nil
}
return 0, errors.New("删除参数配置信息失败!")
return 0, errors.New("failed to delete parameter configuration information")
}
// ResetConfigCache 重置参数缓存数据

View File

@@ -78,7 +78,7 @@ func (r *ServiceSysDictData) DeleteDictDataByCodes(dictCodes []string) (int64, e
// 检查是否存在
dictDatas := r.sysDictDataRepository.SelectDictDataByCodes(dictCodes)
if len(dictDatas) <= 0 {
return 0, errors.New("没有权限访问字典编码数据!")
return 0, errors.New("does not have permission to access dictionary-encoded data")
}
if len(dictDatas) == len(dictCodes) {
for _, v := range dictDatas {
@@ -89,7 +89,7 @@ func (r *ServiceSysDictData) DeleteDictDataByCodes(dictCodes []string) (int64, e
rows := r.sysDictDataRepository.DeleteDictDataByCodes(dictCodes)
return rows, nil
}
return 0, errors.New("删除字典数据信息失败!")
return 0, errors.New("failed to delete dictionary data information")
}
// InsertDictData 新增字典数据信息

View File

@@ -108,13 +108,13 @@ func (r *ServiceSysDictType) DeleteDictTypeByIDs(dictIDs []string) (int64, error
// 检查是否存在
dictTypes := r.sysDictTypeRepository.SelectDictTypeByIDs(dictIDs)
if len(dictTypes) <= 0 {
return 0, errors.New("没有权限访问字典类型数据!")
return 0, errors.New("no permission to access dictionary type data")
}
for _, v := range dictTypes {
// 字典类型下级含有数据
useCount := r.sysDictDataRepository.CountDictDataByType(v.DictType)
if useCount > 0 {
msg := fmt.Sprintf("%s】存在字典数据,不能删除", v.DictName)
msg := fmt.Sprintf("[%s] Dictionary data exists and cannot be deleted. ", v.DictName)
return 0, errors.New(msg)
}
// 清除缓存
@@ -124,7 +124,7 @@ func (r *ServiceSysDictType) DeleteDictTypeByIDs(dictIDs []string) (int64, error
rows := r.sysDictTypeRepository.DeleteDictTypeByIDs(dictIDs)
return rows, nil
}
return 0, errors.New("删除字典数据信息失败!")
return 0, errors.New("failed to delete dictionary data information")
}
// ResetDictCache 重置字典缓存数据

View File

@@ -97,17 +97,17 @@ func (r *ServiceSysRole) DeleteRoleByIds(roleIds []string) (int64, error) {
// 检查是否存在
roles := r.sysRoleRepository.SelectRoleByIds(roleIds)
if len(roles) <= 0 {
return 0, errors.New("没有权限访问角色数据!")
return 0, errors.New("no permission to access role data")
}
for _, role := range roles {
// 检查是否为已删除
if role.DelFlag == "1" {
return 0, errors.New(role.RoleID + " 角色信息已经删除!")
return 0, errors.New(role.RoleID + " The character information has been deleted")
}
// 检查分配用户
userCount := r.sysUserRoleRepository.CountUserRoleByRoleId(role.RoleID)
if userCount > 0 {
msg := fmt.Sprintf("%s】已分配给用户,不能删除", role.RoleName)
msg := fmt.Sprintf("[%s] has been assigned to a user and cannot be deleted", role.RoleName)
return 0, errors.New(msg)
}
}
@@ -117,7 +117,7 @@ func (r *ServiceSysRole) DeleteRoleByIds(roleIds []string) (int64, error) {
rows := r.sysRoleRepository.DeleteRoleByIds(roleIds)
return rows, nil
}
return 0, errors.New("删除角色信息失败!")
return 0, errors.New("failed to delete role information")
}
// CheckUniqueRoleName 校验角色名称是否唯一

View File

@@ -103,7 +103,7 @@ func (r *ServiceSysUser) DeleteUserByIds(userIds []string) (int64, error) {
// 检查是否存在
users := r.sysUserRepository.SelectUserByIds(userIds)
if len(users) <= 0 {
return 0, errors.New("没有权限访问用户数据!")
return 0, errors.New("no permission to access user data")
}
if len(users) == len(userIds) {
// 删除用户与角色关联
@@ -113,7 +113,7 @@ func (r *ServiceSysUser) DeleteUserByIds(userIds []string) (int64, error) {
rows := r.sysUserRepository.DeleteUserByIds(userIds)
return rows, nil
}
return 0, errors.New("删除用户信息失败!")
return 0, errors.New("failed to delete user information")
}
// CheckUniqueUserName 校验用户名称是否唯一

View File

@@ -511,9 +511,9 @@ func (s *UdmUserApi) UdmAuthUserExport(w http.ResponseWriter, r *http.Request) {
if body.Type == "csv" {
// 转换数据
data := [][]string{}
data = append(data, []string{"imsi", "ki", "amf", "algo", "opc"})
data = append(data, []string{"imsi", "ki", "algo", "amf", "opc"})
for _, v := range list {
data = append(data, []string{v.Imsi, v.Ki, v.Amf, v.AlgoIndex, v.Opc})
data = append(data, []string{v.Imsi, v.Ki, v.AlgoIndex, v.Amf, v.Opc})
}
// 输出到文件
err := file.WriterCSVFile(data, filePath)
@@ -527,7 +527,7 @@ func (s *UdmUserApi) UdmAuthUserExport(w http.ResponseWriter, r *http.Request) {
// 转换数据
data := [][]string{}
for _, v := range list {
data = append(data, []string{v.Imsi, v.Ki, v.Amf, v.AlgoIndex, v.Opc})
data = append(data, []string{v.Imsi, v.Ki, v.AlgoIndex, v.Amf, v.Opc})
}
// 输出到文件
err = file.WriterTxtFile(data, filePath)
@@ -1168,7 +1168,9 @@ func (s *UdmUserApi) UdmSubUserImport(w http.ResponseWriter, r *http.Request) {
ctx.JSON(w, 200, result.ErrMsg(err.Error()))
return
}
data2 := file.ReadCSVFile(localPath)
neId = ""
go s.subUser.InsertCSV(neId, data2)
// 复制到远程
err = ssh.FileSCPLocalToNe(neInfo.Ip, localPath, nePath)
if err != nil {

View File

@@ -210,6 +210,7 @@ func (r *RepoUdmAuthUser) Inserts(authUsers []model.UdmAuthUser) int64 {
// 调用 InsertMulti 函数将批量数据插入数据库
results, err := datasource.DefaultDB().Table("u_auth_user").InsertMulti(batch)
if err != nil {
log.Errorf("Insert err => %v", err)
continue
}
num += results

View File

@@ -220,6 +220,7 @@ func (r *RepoUdmSubUser) ClearAndInsert(neID string, subArr []model.UdmSubUser)
func (r *RepoUdmSubUser) Insert(subUser model.UdmSubUser) int64 {
results, err := datasource.DefaultDB().Table("u_sub_user").Insert(subUser)
if err != nil {
log.Errorf("Insert err => %v", err)
return results
}
return results
@@ -240,6 +241,7 @@ func (r *RepoUdmSubUser) Inserts(subUser []model.UdmSubUser) int64 {
// 调用 InsertMulti 函数将批量数据插入数据库
results, err := datasource.DefaultDB().Table("u_sub_user").InsertMulti(batch)
if err != nil {
log.Errorf("Insert err => %v", err)
continue
}
num += results
@@ -266,6 +268,7 @@ func (r *RepoUdmSubUser) Insert4G(neID string, subUser model.UdmSubUser) int64 {
results, err := datasource.DefaultDB().Table("u_sub_user").Insert(subUser)
if err == nil {
log.Errorf("Insert err => %v", err)
insertNum += results
}
}
@@ -336,6 +339,7 @@ func (r *RepoUdmSubUser) Update(neID string, authUser model.UdmSubUser) int64 {
results, err := datasource.DefaultDB().Table("u_sub_user").Where("imsi = ? and ne_id = ?", user.Imsi, user.NeID).Update(user)
if err != nil {
log.Errorf("Update err => %v", err)
return 0
}
return results
@@ -373,6 +377,7 @@ func (r *RepoUdmSubUser) Update4GIP(neID string, subUser model.UdmSubUser) int64
// 更新
results, err := datasource.DefaultDB().Table("u_sub_user").Update(user)
if err == nil {
log.Errorf("Update err => %v", err)
insertNum += results
}
}
@@ -406,6 +411,7 @@ func (r *RepoUdmSubUser) UpdateSmData(neID string, subUser model.UdmSubUser) int
// 更新
results, err := datasource.DefaultDB().Table("u_sub_user").Update(user)
if err == nil {
log.Errorf("Update err => %v", err)
insertNum += results
}
}
@@ -417,6 +423,7 @@ func (r *RepoUdmSubUser) UpdateSmData(neID string, subUser model.UdmSubUser) int
func (r *RepoUdmSubUser) Delete(neID, imsi string) int64 {
results, err := datasource.DefaultDB().Table("u_sub_user").Where("imsi = ? and ne_id = ?", imsi, neID).Delete()
if err != nil {
log.Errorf("Delete err => %v", err)
return results
}
return results
@@ -436,6 +443,7 @@ func (r *RepoUdmSubUser) Deletes(neID, imsi, num string) int64 {
results, err := datasource.DefaultDB().Table("u_sub_user").Where("imsi >= ? and imsi < ? and ne_id = ?", imsiV, imsiV+numV, neID).Delete()
if err != nil {
log.Errorf("Delete err => %v", err)
return results
}
return results

View File

@@ -90,12 +90,12 @@ func (r *ServiceUdmAuthUser) InsertCSV(neID string, data []map[string]string) in
if s, ok := v["ki"]; ok {
authUser.Ki = s
}
if s, ok := v["amf"]; ok {
authUser.Amf = s
}
if s, ok := v["algo"]; ok {
authUser.AlgoIndex = s
}
if s, ok := v["amf"]; ok {
authUser.Amf = s
}
if s, ok := v["opc"]; ok {
authUser.Opc = s
}

View File

@@ -137,6 +137,17 @@ func (r *ServiceUdmSubUser) InsertCSV(neID string, data []map[string]string) int
}
if s, ok := v["eps_dat"]; ok {
subUser.EpsDat = s
arr := strings.Split(s, ",")
if len(arr) == 9 {
subUser.EpsFlag = arr[0]
subUser.EpsOdb = arr[1]
subUser.HplmnOdb = arr[2]
subUser.Ard = arr[3]
subUser.Epstpl = arr[4]
subUser.ContextId = arr[5]
subUser.ApnContext = arr[7]
subUser.StaticIp = arr[8]
}
}
arr = append(arr, subUser)
}

View File

@@ -128,7 +128,7 @@ func LoginUser(r *http.Request) (vo.LoginUser, error) {
if v != nil {
return v.(vo.LoginUser), nil
}
return vo.LoginUser{}, fmt.Errorf("无用户信息")
return vo.LoginUser{}, fmt.Errorf("No user information")
}
// LoginUserToUserID 登录用户信息-用户ID

View File

@@ -820,12 +820,13 @@ func XormCheckLoginUser(name, password, cryptArgo string) (bool, *User, error) {
return false, nil, err
}
if oauth.BcryptCompare(user.Password, password) != nil {
err := errors.New("用户名或密码错误")
err := errors.New("Incorrect user name or password")
log.Error(err)
// 记录错误
errCoutn := pwdErrCountAdd(user.AccountId, user.Profile, false)
if errCoutn > 3 {
return false, nil, errors.New("登录失败次数过多请30分钟后重试")
// 登录失败次数过多请30分钟后重试
return false, nil, errors.New("Login failed too many times, please retry after 30 minutes")
}
return false, nil, err
}
@@ -841,9 +842,9 @@ func XormCheckLoginUser(name, password, cryptArgo string) (bool, *User, error) {
errMsg := ""
switch user.Status {
case "Closed":
errMsg = "账户已禁用"
errMsg = "Account disabled" // 账户已禁用
case "Locked":
errMsg = "账户已锁定"
errMsg = "Account locked" // 账户已锁定
case "Pending":
// errMsg = "账户已挂起"
_, err := xEngine.Exec("UPDATE user SET status = 'Active' WHERE account_id = ?", user.AccountId)
@@ -865,7 +866,7 @@ func XormCheckLoginUser(name, password, cryptArgo string) (bool, *User, error) {
return false, nil, err
}
if t.Before(time.Now()) {
errMsg := "密码到期时间"
errMsg := "Password expiration time" // 密码到期时间
// 读取配置信息
result, err := XormGetConfig("Security", "pwdStrong")
if err != nil {
@@ -893,7 +894,7 @@ func XormCheckLoginUser(name, password, cryptArgo string) (bool, *User, error) {
return false, nil, err
}
if t.Before(time.Now()) {
errMsg := "用户账户到期"
errMsg := "User account expiration" // 用户账户到期
log.Error("UserExpiration:%s", errMsg)
return false, nil, errors.New(errMsg)
}

View File

@@ -139,9 +139,9 @@ func init() {
// parameter config management
Register("GET", cm.ParamConfigUri, cm.GetParamConfigFromNF, nil)
Register("POST", cm.ParamConfigUri, cm.PostParamConfigToNF, midware.LogOperate(collectlogs.OptionNew("Parameter config management", collectlogs.BUSINESS_TYPE_INSERT)))
Register("PUT", cm.ParamConfigUri, cm.PutParamConfigToNF, midware.LogOperate(collectlogs.OptionNew("Parameter config management", collectlogs.BUSINESS_TYPE_UPDATE)))
Register("DELETE", cm.ParamConfigUri, cm.DeleteParamConfigToNF, midware.LogOperate(collectlogs.OptionNew("Parameter config management", collectlogs.BUSINESS_TYPE_INSERT)))
Register("POST", cm.ParamConfigUri, cm.PostParamConfigToNF, midware.LogOperate(collectlogs.OptionNew("Parameter Config", collectlogs.BUSINESS_TYPE_INSERT)))
Register("PUT", cm.ParamConfigUri, cm.PutParamConfigToNF, midware.LogOperate(collectlogs.OptionNew("Parameter Config", collectlogs.BUSINESS_TYPE_UPDATE)))
Register("DELETE", cm.ParamConfigUri, cm.DeleteParamConfigToNF, midware.LogOperate(collectlogs.OptionNew("Parameter Config", collectlogs.BUSINESS_TYPE_INSERT)))
Register("GET", cm.CustomParamConfigUri, cm.GetParamConfigFromNF, nil)
Register("POST", cm.CustomParamConfigUri, cm.PostParamConfigToNF, nil)
@@ -150,9 +150,9 @@ func init() {
// Get/Create/Modify/Delete NE info
Register("GET", cm.UriNeInfo, cm.GetNeInfo, nil)
Register("POST", cm.UriNeInfo, cm.PostNeInfo, midware.LogOperate(collectlogs.OptionNew("NE info", collectlogs.BUSINESS_TYPE_INSERT)))
Register("PUT", cm.UriNeInfo, cm.PutNeInfo, midware.LogOperate(collectlogs.OptionNew("NE info", collectlogs.BUSINESS_TYPE_UPDATE)))
Register("DELETE", cm.UriNeInfo, cm.DeleteNeInfo, midware.LogOperate(collectlogs.OptionNew("NE info", collectlogs.BUSINESS_TYPE_DELETE)))
Register("POST", cm.UriNeInfo, cm.PostNeInfo, midware.LogOperate(collectlogs.OptionNew("NE Info", collectlogs.BUSINESS_TYPE_INSERT)))
Register("PUT", cm.UriNeInfo, cm.PutNeInfo, midware.LogOperate(collectlogs.OptionNew("NE Info", collectlogs.BUSINESS_TYPE_UPDATE)))
Register("DELETE", cm.UriNeInfo, cm.DeleteNeInfo, midware.LogOperate(collectlogs.OptionNew("NE Info", collectlogs.BUSINESS_TYPE_DELETE)))
// Get/Create/Modify/Delete NE info
Register("GET", cm.CustomUriNeInfo, cm.GetNeInfo, nil)
@@ -191,12 +191,12 @@ func init() {
// Software management
Register("GET", cm.UriSoftware, cm.DownloadSoftwareFile, nil)
//Register("POST", cm.UriSoftware, cm.UploadSoftwareFile, nil)
Register("POST", cm.UriSoftware, cm.UploadSoftwareMultiFile, midware.LogOperate(collectlogs.OptionNew("Software management", collectlogs.BUSINESS_TYPE_UPDATE)))
Register("DELETE", cm.UriSoftware, cm.DeleteSoftwareFile, midware.LogOperate(collectlogs.OptionNew("Software management", collectlogs.BUSINESS_TYPE_DELETE)))
Register("POST", cm.UriSoftware, cm.UploadSoftwareMultiFile, midware.LogOperate(collectlogs.OptionNew("Software", collectlogs.BUSINESS_TYPE_UPDATE)))
Register("DELETE", cm.UriSoftware, cm.DeleteSoftwareFile, midware.LogOperate(collectlogs.OptionNew("Software", collectlogs.BUSINESS_TYPE_DELETE)))
Register("POST", cm.UriSoftwareNE, cm.DistributeSoftwareToNF, midware.LogOperate(collectlogs.OptionNew("Software management", collectlogs.BUSINESS_TYPE_OTHER)))
Register("PUT", cm.UriSoftwareNE, cm.ActiveSoftwareToNF, midware.LogOperate(collectlogs.OptionNew("Software management", collectlogs.BUSINESS_TYPE_OTHER)))
Register("PATCH", cm.UriSoftwareNE, cm.RollBackSoftwareToNF, midware.LogOperate(collectlogs.OptionNew("Software management", collectlogs.BUSINESS_TYPE_OTHER)))
Register("POST", cm.UriSoftwareNE, cm.DistributeSoftwareToNF, midware.LogOperate(collectlogs.OptionNew("Software", collectlogs.BUSINESS_TYPE_OTHER)))
Register("PUT", cm.UriSoftwareNE, cm.ActiveSoftwareToNF, midware.LogOperate(collectlogs.OptionNew("Software", collectlogs.BUSINESS_TYPE_OTHER)))
Register("PATCH", cm.UriSoftwareNE, cm.RollBackSoftwareToNF, midware.LogOperate(collectlogs.OptionNew("Software", collectlogs.BUSINESS_TYPE_OTHER)))
Register("GET", cm.CustomUriSoftware, cm.DownloadSoftwareFile, nil)
Register("POST", cm.CustomUriSoftware, cm.UploadSoftwareFile, nil)
@@ -207,8 +207,8 @@ func init() {
Register("PATCH", cm.CustomUriSoftwareNE, cm.RollBackSoftwareToNF, nil)
// License management
Register("POST", cm.UriLicense, cm.UploadLicenseFileData, midware.LogOperate(collectlogs.OptionNew("License management", collectlogs.BUSINESS_TYPE_INSERT)))
Register("POST", cm.UriLicenseExt, cm.UploadLicenseFileData, midware.LogOperate(collectlogs.OptionNew("License management", collectlogs.BUSINESS_TYPE_INSERT)))
Register("POST", cm.UriLicense, cm.UploadLicenseFileData, midware.LogOperate(collectlogs.OptionNew("License", collectlogs.BUSINESS_TYPE_INSERT)))
Register("POST", cm.UriLicenseExt, cm.UploadLicenseFileData, midware.LogOperate(collectlogs.OptionNew("License", collectlogs.BUSINESS_TYPE_INSERT)))
Register("POST", cm.CustomUriLicense, cm.UploadLicenseFileData, nil)
Register("POST", cm.CustomUriLicenseExt, cm.UploadLicenseFileData, nil)
@@ -224,19 +224,19 @@ func init() {
Register("DELETE", trace.CustomUriTraceTask, trace.DeleteTraceTaskToNF, nil)
// 网元发送执行 pcap抓包任务
Register("POST", trace.UriTcpdumpTask, trace.TcpdumpNeTask, midware.LogOperate(collectlogs.OptionNew("Packet capturing task", collectlogs.BUSINESS_TYPE_INSERT)))
Register("POST", trace.CustomUriTcpdumpTask, trace.TcpdumpNeTask, midware.LogOperate(collectlogs.OptionNew("Packet capturing task", collectlogs.BUSINESS_TYPE_INSERT)))
Register("POST", trace.UriTcpdumpTask, trace.TcpdumpNeTask, midware.LogOperate(collectlogs.OptionNew("Packet Capturing Task", collectlogs.BUSINESS_TYPE_INSERT)))
Register("POST", trace.CustomUriTcpdumpTask, trace.TcpdumpNeTask, midware.LogOperate(collectlogs.OptionNew("Packet Capturing Task", collectlogs.BUSINESS_TYPE_INSERT)))
// 网元发送执行 抓包下载pcap文件
Register("POST", trace.UriTcpdumpPcapDownload, trace.TcpdumpPcapDownload, midware.LogOperate(collectlogs.OptionNew("Packet capturing task", collectlogs.BUSINESS_TYPE_EXPORT)))
Register("POST", trace.CustomUriTcpdumpPcapDownload, trace.TcpdumpPcapDownload, midware.LogOperate(collectlogs.OptionNew("Packet capturing task", collectlogs.BUSINESS_TYPE_EXPORT)))
Register("POST", trace.UriTcpdumpPcapDownload, trace.TcpdumpPcapDownload, midware.LogOperate(collectlogs.OptionNew("Packet Capturing Task", collectlogs.BUSINESS_TYPE_EXPORT)))
Register("POST", trace.CustomUriTcpdumpPcapDownload, trace.TcpdumpPcapDownload, midware.LogOperate(collectlogs.OptionNew("Packet Capturing Task", collectlogs.BUSINESS_TYPE_EXPORT)))
// 网元发送执行UPF pcap抓包
Register("POST", trace.UriTcpdumpNeUPFTask, trace.TcpdumpNeUPFTask, midware.LogOperate(collectlogs.OptionNew("Packet capturing task", collectlogs.BUSINESS_TYPE_INSERT)))
Register("POST", trace.CustomUriTcpdumpNeUPFTask, trace.TcpdumpNeUPFTask, midware.LogOperate(collectlogs.OptionNew("Packet capturing task", collectlogs.BUSINESS_TYPE_INSERT)))
Register("POST", trace.UriTcpdumpNeUPFTask, trace.TcpdumpNeUPFTask, midware.LogOperate(collectlogs.OptionNew("Packet Capturing Task", collectlogs.BUSINESS_TYPE_INSERT)))
Register("POST", trace.CustomUriTcpdumpNeUPFTask, trace.TcpdumpNeUPFTask, midware.LogOperate(collectlogs.OptionNew("Packet Capturing Task", collectlogs.BUSINESS_TYPE_INSERT)))
// file management
Register("POST", file.UriFile, file.UploadFile, midware.LogOperate(collectlogs.OptionNew("File management", collectlogs.BUSINESS_TYPE_INSERT)))
Register("GET", file.UriFile, file.DownloadFile, midware.LogOperate(collectlogs.OptionNew("File management", collectlogs.BUSINESS_TYPE_OTHER)))
Register("DELETE", file.UriFile, file.DeleteFile, midware.LogOperate(collectlogs.OptionNew("File management", collectlogs.BUSINESS_TYPE_DELETE)))
Register("POST", file.UriFile, file.UploadFile, midware.LogOperate(collectlogs.OptionNew("File", collectlogs.BUSINESS_TYPE_INSERT)))
Register("GET", file.UriFile, file.DownloadFile, midware.LogOperate(collectlogs.OptionNew("File", collectlogs.BUSINESS_TYPE_OTHER)))
Register("DELETE", file.UriFile, file.DeleteFile, midware.LogOperate(collectlogs.OptionNew("File", collectlogs.BUSINESS_TYPE_DELETE)))
Register("POST", file.CustomUriFile, file.UploadFile, nil)
Register("GET", file.CustomUriFile, file.DownloadFile, nil)

View File

@@ -3,7 +3,6 @@ package services
import (
"bufio"
"bytes"
"errors"
"fmt"
"io"
"mime/multipart"
@@ -220,7 +219,7 @@ func HandleUploadFormFile(w http.ResponseWriter, r *http.Request) {
r.ParseMultipartForm(32 << 20)
//mForm := r.MultipartForm
for k, _ := range r.MultipartForm.File {
for k := range r.MultipartForm.File {
// k is the key of file part
file, fileHeader, err := r.FormFile(k)
if err != nil {
@@ -253,7 +252,7 @@ func PostFileHandler(w http.ResponseWriter, r *http.Request) {
if !strings.Contains(r.Header.Get("Content-Type"), "multipart/form-data") {
// 不支持的 Content-Type 类型
fmt.Println("Invalid Content-Type: ", r.Header.Get("Content-Type"))
http.Error(w, " 不支持的 Content-Type 类型", http.StatusBadRequest)
http.Error(w, " Unsupported Content-Type Types", http.StatusBadRequest)
return
}
@@ -284,7 +283,8 @@ func PostFileHandler(w http.ResponseWriter, r *http.Request) {
var buf = &bytes.Buffer{}
// 非文件字段部分大小限制验证非文件字段go中filename会是空
if fileName == "" {
var limitError = "请求主体中非文件字段" + formName + "超出大小限制"
// "请求主体中非文件字段" + formName + "超出大小限制"
var limitError = fmt.Sprintf("Non-file field %s in request body exceeds size limit", formName)
err = uploadSizeLimit(buf, part, ValuesMax, limitError)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
@@ -294,7 +294,8 @@ func PostFileHandler(w http.ResponseWriter, r *http.Request) {
}
// 文件字段部分大小限制验证
var limitError = "请求主体中文件字段" + fileName + "超出大小限制"
// "请求主体中文件字段" + fileName + "超出大小限制"
var limitError = fmt.Sprintf("File field %s in request body exceeds size limit", fileName)
err = uploadSizeLimit(buf, part, FilesMax, limitError)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
@@ -310,9 +311,11 @@ func PostFileHandler(w http.ResponseWriter, r *http.Request) {
// 非逻辑内容,仅为测试使用
var chunkNumber = r.Header.Get("chunk-number")
if chunkNumber == "" {
http.Error(w, "文件"+fileName+"上传成功", http.StatusOK)
// "文件"+fileName+"上传成功"
http.Error(w, fmt.Sprintf("File %s uploaded successfully", fileName), http.StatusOK)
} else {
http.Error(w, "分片文件"+fileName+chunkNumber+"上传成功", http.StatusOK)
// "分片文件 %s %s 上传成功"
http.Error(w, fmt.Sprintf("Sliced file %s %s uploaded successfully.", fileName, chunkNumber), http.StatusOK)
}
}
}
@@ -326,7 +329,7 @@ func uploadSizeLimit(buf *bytes.Buffer, part *multipart.Part, maxLimit int64, li
}
maxLimit -= n
if maxLimit < 0 {
return errors.New(limitError)
return fmt.Errorf(limitError)
}
return nil
}

View File

@@ -138,20 +138,14 @@ func ExtGetUriPageLimitString(r *http.Request) string {
}
func IsJsonContentType(r *http.Request) bool {
if strings.Contains(r.Header.Get("Content-Type"), "application/json") {
return true
}
return false
hType := r.Header.Get("Content-Type")
return strings.Contains(hType, "application/json")
}
func IsValidOAuthUri(r *http.Request) bool {
vars := mux.Vars(r)
apiVer := vars["apiVersion"] // 获取Uri
if apiVer != "v1" {
return false
}
return true
return apiVer == "v1"
}
func IsVallidContentType(r *http.Request, checkFlag bool) bool {
@@ -386,7 +380,7 @@ func CheckCommonValidRequest(w http.ResponseWriter, r *http.Request) (string, er
// error processing ...
// 401-1 response
token, ret = oauth.IsCarriedToken(r)
if ret == false {
if !ret {
log.Error("accessToken is not carried")
ResponseUnauthorized401AccessTokenNotCarried(w)
return token, err

View File

@@ -3,7 +3,7 @@ package session
import (
"crypto/rand"
"encoding/base64"
"errors"
"fmt"
"io"
"net/http"
"strconv"
@@ -89,7 +89,7 @@ func (smgr *SessManager) SetSessionValue(token string, key interface{}, value in
session.values[key] = value
return nil
}
return errors.New("invalid session ID")
return fmt.Errorf("invalid session ID")
}
// GetSessionValue get value fo session
@@ -101,7 +101,7 @@ func (smgr *SessManager) GetSessionValue(token string, key interface{}) (interfa
return val, nil
}
}
return nil, errors.New("invalid session ID")
return nil, fmt.Errorf("invalid session ID")
}
func (smgr *SessManager) GetTokenFromHttpRequest(r *http.Request) string {
@@ -111,7 +111,6 @@ func (smgr *SessManager) GetTokenFromHttpRequest(r *http.Request) string {
return v[0]
}
}
return ""
}

View File

@@ -90,7 +90,8 @@ func RateLimit(option LimitOption) gin.HandlerFunc {
c.Header("X-RateLimit-Reset", fmt.Sprintf("%d", time.Now().Unix()+int64(rateTime))) // 重置时间戳
if rateCount >= option.Count {
c.JSON(200, result.ErrMsg("访问过于频繁,请稍候再试"))
// 访问过于频繁,请稍候再试
c.JSON(200, result.ErrMsg("Visits are too frequent. Please try again later"))
c.Abort() // 停止执行后续的处理函数
return
}

View File

@@ -60,7 +60,8 @@ func RepeatSubmit(interval int64) gin.HandlerFunc {
// 小于间隔时间且参数内容一致
if compareTime < interval && compareParams {
c.JSON(200, result.ErrMsg("不允许重复提交,请稍候再试"))
// 不允许重复提交,请稍候再试
c.JSON(200, result.ErrMsg("Duplicate submissions are not allowed. Please try again later"))
c.Abort()
return
}

View File

@@ -42,14 +42,16 @@ func referer(c *gin.Context) {
referer := c.GetHeader("Referer")
if referer == "" {
c.AbortWithStatusJSON(200, result.ErrMsg("无效 Referer 未知"))
// 无效 Referer 未知
c.AbortWithStatusJSON(200, result.ErrMsg("Invalid referer unknown"))
return
}
// 获取host
u, err := url.Parse(referer)
if err != nil {
c.AbortWithStatusJSON(200, result.ErrMsg("无效 Referer 未知"))
// 无效 Referer 未知
c.AbortWithStatusJSON(200, result.ErrMsg("Invalid referer unknown"))
return
}
host := u.Host
@@ -70,7 +72,8 @@ func referer(c *gin.Context) {
}
}
if !ok {
c.AbortWithStatusJSON(200, result.ErrMsg("无效 Referer "+host))
// 无效 Referer
c.AbortWithStatusJSON(200, result.ErrMsg("Invalid referer "+host))
return
}
}

View File

@@ -9,6 +9,7 @@ import (
"ems.agt/src/framework/constants/roledatascope"
"ems.agt/src/framework/constants/token"
"ems.agt/src/framework/utils/ip2region"
"ems.agt/src/framework/utils/parse"
"ems.agt/src/framework/utils/ua"
"ems.agt/src/framework/vo"
@@ -81,13 +82,13 @@ func UaOsBrowser(c *gin.Context) (string, string) {
userAgent := c.GetHeader("user-agent")
uaInfo := ua.Info(userAgent)
browser := "未知 未知"
browser := "Unknown Unknown"
bName, bVersion := uaInfo.Browser()
if bName != "" && bVersion != "" {
browser = bName + " " + bVersion
}
os := "未知 未知"
os := "Unknown Unknown"
bos := uaInfo.OS()
if bos != "" {
os = bos
@@ -95,13 +96,22 @@ func UaOsBrowser(c *gin.Context) (string, string) {
return os, browser
}
// ClientLanguage 解析请求客户端接受语言
func ClientLanguage(c *gin.Context) string {
acceptLanguage := c.GetHeader("Accept-Language")
fmt.Println(acceptLanguage)
lang := parse.AcceptLanguage(acceptLanguage)
fmt.Println(lang)
return lang
}
// LoginUser 登录用户信息
func LoginUser(c *gin.Context) (vo.LoginUser, error) {
value, exists := c.Get(common.CTX_LOGIN_USER)
if exists {
return value.(vo.LoginUser), nil
}
return vo.LoginUser{}, fmt.Errorf("无效登录用户信息")
return vo.LoginUser{}, fmt.Errorf("invalid login user information")
}
// LoginUserToUserID 登录用户信息-用户ID

View File

@@ -22,7 +22,7 @@ func WriterCSVFile(data [][]string, filePath string) error {
// 确保文件夹路径存在
err := os.MkdirAll(dirPath, os.ModePerm)
if err != nil {
logger.Errorf("创建文件夹失败 CreateFile %v", err)
logger.Errorf("MkdirAll dir %v", err)
}
// 创建或打开文件
@@ -51,7 +51,7 @@ func ReadCSVFile(filePath string) []map[string]string {
// 打开 CSV 文件
file, err := os.Open(filePath)
if err != nil {
logger.Errorf("无法打开 CSV 文件:%v", err)
logger.Errorf("Open CSV file: %v", err)
return arr
}
defer file.Close()
@@ -62,7 +62,7 @@ func ReadCSVFile(filePath string) []map[string]string {
// 读取 CSV 头部行
header, err := reader.Read()
if err != nil {
logger.Errorf("无法读取 CSV 头部行:%v", err)
logger.Errorf("Read CSV header rows: %v", err)
return arr
}

View File

@@ -73,13 +73,13 @@ func generateFileName(fileName string) string {
func isAllowWrite(fileName string, allowExts []string, fileSize int64) error {
// 判断上传文件名称长度
if len(fileName) > DEFAULT_FILE_NAME_LENGTH {
return fmt.Errorf("The maximum length limit for uploading file names is %d", DEFAULT_FILE_NAME_LENGTH)
return fmt.Errorf("the maximum length limit for uploading file names is %d", DEFAULT_FILE_NAME_LENGTH)
}
// 最大上传文件大小
maxFileSize := uploadFileSize()
if fileSize > maxFileSize {
return fmt.Errorf("Maximum upload file size %s", parse.Bit(float64(maxFileSize)))
return fmt.Errorf("maximum upload file size %s", parse.Bit(float64(maxFileSize)))
}
// 判断文件拓展是否为允许的拓展类型
@@ -95,7 +95,7 @@ func isAllowWrite(fileName string, allowExts []string, fileSize int64) error {
}
}
if !hasExt {
return fmt.Errorf("The upload file type is not supported, only the following types are supported:%s", strings.Join(allowExts, ","))
return fmt.Errorf("the upload file type is not supported, only the following types are supported: %s", strings.Join(allowExts, ","))
}
return nil
@@ -107,7 +107,7 @@ func isAllowWrite(fileName string, allowExts []string, fileSize int64) error {
func isAllowRead(filePath string) error {
// 禁止目录上跳级别
if strings.Contains(filePath, "..") {
return fmt.Errorf("Prohibit jumping levels on the directory")
return fmt.Errorf("prohibit jumping levels on the directory")
}
// 检查允许下载的文件规则
@@ -120,7 +120,7 @@ func isAllowRead(filePath string) error {
}
}
if !hasExt {
return fmt.Errorf("Rules for illegally downloaded files: %s", fileExt)
return fmt.Errorf("rules for illegally downloaded files: %s", fileExt)
}
return nil

View File

@@ -42,7 +42,8 @@ func init() {
func RegionSearchByIp(ip string) (string, int, int64) {
ip = ClientIP(ip)
if ip == LOCAT_HOST {
return "0|0|0|内网IP|内网IP", 0, 0
// "0|0|0|内网IP|内网IP"
return "0|0|0|Intranet IP|Intranet IP", 0, 0
}
tStart := time.Now()
region, err := searcher.SearchByStr(ip)
@@ -59,12 +60,12 @@ func RegionSearchByIp(ip string) (string, int, int64) {
func RealAddressByIp(ip string) string {
ip = ClientIP(ip)
if ip == LOCAT_HOST {
return "内网IP"
return "Intranet IP" // 内网IP
}
region, err := searcher.SearchByStr(ip)
if err != nil {
logger.Errorf("failed to SearchIP(%s): %s\n", ip, err)
return "未知"
return "unknown" // 未知
}
parts := strings.Split(region, "|")
province := parts[2]

View File

@@ -165,3 +165,33 @@ func Color(colorStr string) *color.RGBA {
A: 255, // 不透明
}
}
// AcceptLanguage 解析 Accept-Language 头部并返回语言标签及其对应的权重值
// "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7"
func AcceptLanguage(acceptLanguage string) string {
language := "en"
maxQ := 0.0
for _, tag := range strings.Split(acceptLanguage, ",") {
parts := strings.Split(strings.TrimSpace(tag), ";q=")
lang := parts[0]
if strings.Contains(lang, "-") {
langParts := strings.Split(strings.TrimSpace(lang), "-")
lang = langParts[0]
}
q := 0.0 // 默认权重值
if len(parts) > 1 {
// 解析权重值
qValue := parts[1]
_, err := fmt.Sscanf(qValue, "%f", &q)
if err != nil {
q = 0.0 // 若解析失败,则使用默认值
}
}
// 取最大
if q > maxQ {
maxQ = q
language = lang
}
}
return language
}

View File

@@ -32,7 +32,7 @@ func FileSCPNeToLocal(neIp, nePath, localPath string) error {
// 确保文件夹路径存在
err := os.MkdirAll(dirPath, os.ModePerm)
if err != nil {
log.Errorf("创建文件夹失败 CreateFile %v", err)
log.Errorf("FileSCPNeToLocal MkdirAll err %v", err)
return err
}

View File

@@ -2,7 +2,7 @@ package token
import (
"encoding/json"
"errors"
"fmt"
"time"
"ems.agt/src/framework/config"
@@ -124,13 +124,14 @@ func Verify(tokenString string) (jwt.MapClaims, error) {
})
if err != nil {
logger.Errorf("token String Verify : %v", err)
return nil, errors.New("无效身份授权")
// 无效身份授权
return nil, fmt.Errorf("invalid identity authorization")
}
// 如果解析负荷成功并通过签名校验
if claims, ok := token.Claims.(jwt.MapClaims); ok && token.Valid {
return claims, nil
}
return nil, errors.New("token valid error")
return nil, fmt.Errorf("token valid error")
}
// LoginUser 缓存的登录用户信息

View File

@@ -36,7 +36,7 @@ type AccountController struct {
func (s *AccountController) Login(c *gin.Context) {
var loginBody commonModel.LoginBody
if err := c.ShouldBindJSON(&loginBody); err != nil {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -74,8 +74,9 @@ func (s *AccountController) Login(c *gin.Context) {
return
} else {
s.accountService.UpdateLoginDateAndIP(&loginUser)
// 登录成功
s.sysLogLoginService.CreateSysLogLogin(
loginBody.Username, commonConstants.STATUS_YES, "登录成功",
loginBody.Username, commonConstants.STATUS_YES, "Login Successful",
ipaddr, location, os, browser,
)
}
@@ -133,13 +134,13 @@ func (s *AccountController) Logout(c *gin.Context) {
// 当前请求信息
ipaddr, location := ctxUtils.IPAddrLocation(c)
os, browser := ctxUtils.UaOsBrowser(c)
// 创建系统访问记录
// 创建系统访问记录 退出成功
s.sysLogLoginService.CreateSysLogLogin(
userName, commonConstants.STATUS_YES, "退出成功",
userName, commonConstants.STATUS_YES, "Exit successful",
ipaddr, location, os, browser,
)
}
}
c.JSON(200, result.OkMsg("退出成功"))
c.JSON(200, result.OkMsg("Exit successful"))
}

View File

@@ -27,7 +27,7 @@ type FileController struct{}
func (s *FileController) Download(c *gin.Context) {
filePath := c.Param("filePath")
if len(filePath) < 8 {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// base64解析出地址
@@ -71,13 +71,13 @@ func (s *FileController) Upload(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
}
// 子路径
subPath := c.PostForm("subPath")
if _, ok := uploadsubpath.UploadSubpath[subPath]; !ok {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -109,7 +109,7 @@ func (s *FileController) ChunkCheck(c *gin.Context) {
}
err := c.ShouldBindJSON(&body)
if err != nil {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -136,11 +136,11 @@ func (s *FileController) ChunkMerge(c *gin.Context) {
}
err := c.ShouldBindJSON(&body)
if err != nil {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
if _, ok := uploadsubpath.UploadSubpath[body.SubPath]; !ok {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -171,7 +171,7 @@ func (s *FileController) ChunkUpload(c *gin.Context) {
// 上传的文件
formFile, err := c.FormFile("file")
if index == "" || identifier == "" || err != nil {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}

View File

@@ -23,6 +23,7 @@ type IndexController struct{}
func (s *IndexController) Handler(c *gin.Context) {
name := config.Get("framework.name").(string)
version := config.Get("framework.version").(string)
str := "欢迎使用%s后台管理框架,当前版本:%s请通过前端管理地址访问。"
// str := "欢迎使用%s核心网管理平台,当前版本:%s请通过前地址访问。"
str := "Welcome to the %s Core Network Management Platform, current version: %s, please access via the frontend address."
c.JSON(200, result.OkMsg(fmt.Sprintf(str, name, version)))
}

View File

@@ -34,21 +34,24 @@ type RegisterController struct {
func (s *RegisterController) Register(c *gin.Context) {
var registerBody commonModel.RegisterBody
if err := c.ShouldBindJSON(&registerBody); err != nil {
c.JSON(400, result.ErrMsg("参数错误"))
c.JSON(400, result.ErrMsg("parameter error"))
return
}
// 判断必传参数
if !regular.ValidUsername(registerBody.Username) {
c.JSON(200, result.ErrMsg("账号不能以数字开头可包含大写小写字母数字且不少于5位"))
// 账号不能以数字开头可包含大写小写字母数字且不少于5位
c.JSON(200, result.ErrMsg("The account cannot start with a number and can contain uppercase and lowercase letters, numbers, and no less than 5 digits"))
return
}
if !regular.ValidPassword(registerBody.Password) {
c.JSON(200, result.ErrMsg("登录密码至少包含大小写字母、数字、特殊符号且不少于6位"))
// 登录密码至少包含大小写字母、数字、特殊符号且不少于6位
c.JSON(200, result.ErrMsg("The login password should contain at least uppercase and lowercase letters, numbers, special symbols, and no less than 6 digits"))
return
}
if registerBody.Password != registerBody.ConfirmPassword {
c.JSON(200, result.ErrMsg("用户确认输入密码不一致"))
// 用户确认输入密码不一致
c.JSON(200, result.ErrMsg("The user confirmed that the input password is inconsistent"))
return
}
@@ -74,12 +77,13 @@ func (s *RegisterController) Register(c *gin.Context) {
userID, err := s.registerService.ByUserName(registerBody.Username, registerBody.Password, registerBody.UserType)
if err == nil {
msg := registerBody.Username + " 注册成功 " + userID
msg := registerBody.Username + " registered success " + userID
s.sysLogLoginService.CreateSysLogLogin(
registerBody.Username, commonConstants.STATUS_YES, msg,
ipaddr, location, os, browser,
)
c.JSON(200, result.OkMsg("注册成功"))
// 注册成功
c.JSON(200, result.OkMsg("registered success"))
return
}
c.JSON(200, result.ErrMsg(err.Error()))

View File

@@ -1,7 +1,6 @@
package service
import (
"errors"
"fmt"
"time"
@@ -45,16 +44,19 @@ func (s *AccountImpl) ValidateCaptcha(code, uuid string) error {
return nil
}
if code == "" || uuid == "" {
return errors.New("验证码信息错误")
// 验证码信息错误
return fmt.Errorf("Captcha message error")
}
verifyKey := cachekey.CAPTCHA_CODE_KEY + uuid
captcha, _ := redis.Get("", verifyKey)
if captcha == "" {
return errors.New("验证码已失效")
// 验证码已失效
return fmt.Errorf("Captcha is no longer valid")
}
redis.Del("", verifyKey)
if captcha != code {
return errors.New("验证码错误")
// 验证码错误
return fmt.Errorf("Captcha error")
}
return nil
}
@@ -72,20 +74,22 @@ func (s *AccountImpl) LoginByUsername(username, password string) (vo.LoginUser,
// 查询用户登录账号
sysUser := s.sysUserService.SelectUserByUserName(username)
if sysUser.UserName != username {
return loginUser, errors.New("用户不存在或密码错误")
return loginUser, fmt.Errorf("User does not exist or wrong password")
}
if sysUser.DelFlag == common.STATUS_YES {
return loginUser, errors.New("对不起,您的账号已被删除")
// 对不起,您的账号已被删除
return loginUser, fmt.Errorf("Sorry, your account has been deleted")
}
if sysUser.Status == common.STATUS_NO {
return loginUser, errors.New("对不起,您的账号已禁用")
return loginUser, fmt.Errorf("Sorry, your account has been disabled")
}
// 检验用户密码
compareBool := crypto.BcryptCompare(password, sysUser.Password)
if !compareBool {
redis.SetByExpire("", retrykey, retryCount+1, lockTime)
return loginUser, errors.New("用户不存在或密码错误")
// 用户不存在或密码错误
return loginUser, fmt.Errorf("User does not exist or wrong password")
} else {
// 清除错误记录次数
s.ClearLoginRecordCache(username)
@@ -144,8 +148,9 @@ func (s *AccountImpl) passwordRetryCount(username string) (string, int64, time.D
// 是否超过错误值
retryCountInt64 := parse.Number(retryCount)
if retryCountInt64 >= int64(maxRetryCount) {
msg := fmt.Sprintf("密码输入错误 %d 次,帐户锁定 %d 分钟", maxRetryCount, lockTime)
return retrykey, retryCountInt64, time.Duration(lockTime) * time.Minute, errors.New(msg)
// 密码输入错误 %d 次,帐户锁定 %d 分钟
errorMsg := fmt.Errorf("password entered incorrectly %d times, account locked for %d minutes", maxRetryCount, lockTime)
return retrykey, retryCountInt64, time.Duration(lockTime) * time.Minute, errorMsg
}
return retrykey, retryCountInt64, time.Duration(lockTime) * time.Minute, nil
}

View File

@@ -40,7 +40,7 @@ func (s *MonitorController) Load(c *gin.Context) {
}
err := c.ShouldBindQuery(&querys)
if err != nil {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}

View File

@@ -33,13 +33,13 @@ func (s *SysCacheController) Info(c *gin.Context) {
// GET /getNames
func (s *SysCacheController) Names(c *gin.Context) {
caches := []model.SysCache{
model.NewSysCacheNames("用户信息", cachekey.LOGIN_TOKEN_KEY),
model.NewSysCacheNames("配置信息", cachekey.SYS_CONFIG_KEY),
model.NewSysCacheNames("数据字典", cachekey.SYS_DICT_KEY),
model.NewSysCacheNames("验证码", cachekey.CAPTCHA_CODE_KEY),
model.NewSysCacheNames("防重提交", cachekey.REPEAT_SUBMIT_KEY),
model.NewSysCacheNames("限流处理", cachekey.RATE_LIMIT_KEY),
model.NewSysCacheNames("密码错误次数", cachekey.PWD_ERR_CNT_KEY),
model.NewSysCacheNames("user", cachekey.LOGIN_TOKEN_KEY),
model.NewSysCacheNames("configuration", cachekey.SYS_CONFIG_KEY),
model.NewSysCacheNames("dictionary", cachekey.SYS_DICT_KEY),
model.NewSysCacheNames("captcha", cachekey.CAPTCHA_CODE_KEY),
model.NewSysCacheNames("anti-submission", cachekey.REPEAT_SUBMIT_KEY),
model.NewSysCacheNames("current-limiting", cachekey.RATE_LIMIT_KEY),
model.NewSysCacheNames("password-errors-number", cachekey.PWD_ERR_CNT_KEY),
}
c.JSON(200, result.OkData(caches))
}
@@ -50,7 +50,7 @@ func (s *SysCacheController) Names(c *gin.Context) {
func (s *SysCacheController) Keys(c *gin.Context) {
cacheName := c.Param("cacheName")
if cacheName == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
caches := []model.SysCache{}
@@ -71,7 +71,7 @@ func (s *SysCacheController) Value(c *gin.Context) {
cacheName := c.Param("cacheName")
cacheKey := c.Param("cacheKey")
if cacheName == "" || cacheKey == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -90,7 +90,7 @@ func (s *SysCacheController) Value(c *gin.Context) {
func (s *SysCacheController) ClearCacheName(c *gin.Context) {
cacheName := c.Param("cacheName")
if cacheName == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -114,7 +114,7 @@ func (s *SysCacheController) ClearCacheKey(c *gin.Context) {
cacheName := c.Param("cacheName")
cacheKey := c.Param("cacheKey")
if cacheName == "" || cacheKey == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -131,12 +131,12 @@ func (s *SysCacheController) ClearCacheKey(c *gin.Context) {
// DELETE /clearCacheSafe
func (s *SysCacheController) ClearCacheSafe(c *gin.Context) {
caches := []model.SysCache{
model.NewSysCacheNames("配置信息", cachekey.SYS_CONFIG_KEY),
model.NewSysCacheNames("数据字典", cachekey.SYS_DICT_KEY),
model.NewSysCacheNames("验证码", cachekey.CAPTCHA_CODE_KEY),
model.NewSysCacheNames("防重提交", cachekey.REPEAT_SUBMIT_KEY),
model.NewSysCacheNames("限流处理", cachekey.RATE_LIMIT_KEY),
model.NewSysCacheNames("密码错误次数", cachekey.PWD_ERR_CNT_KEY),
model.NewSysCacheNames("configuration", cachekey.SYS_CONFIG_KEY),
model.NewSysCacheNames("dictionary", cachekey.SYS_DICT_KEY),
model.NewSysCacheNames("captcha", cachekey.CAPTCHA_CODE_KEY),
model.NewSysCacheNames("anti-submission", cachekey.REPEAT_SUBMIT_KEY),
model.NewSysCacheNames("current-limiting", cachekey.RATE_LIMIT_KEY),
model.NewSysCacheNames("password-errors-number", cachekey.PWD_ERR_CNT_KEY),
}
for _, v := range caches {
cacheKeys, err := redis.GetKeys("", v.CacheName+":*")

View File

@@ -50,7 +50,7 @@ func (s *SysJobController) List(c *gin.Context) {
func (s *SysJobController) Info(c *gin.Context) {
jobId := c.Param("jobId")
if jobId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -69,20 +69,22 @@ func (s *SysJobController) Add(c *gin.Context) {
var body model.SysJob
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.JobID != "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查cron表达式格式
if parse.CronExpression(body.CronExpression) == 0 {
msg := fmt.Sprintf("调度任务新增【%s】失败Cron表达式不正确", body.JobName)
// 调度任务新增【%s】失败Cron表达式不正确
msg := fmt.Sprintf("Scheduling task add [%s] fails with incorrect Cron expression", body.JobName)
c.JSON(200, result.ErrMsg(msg))
return
}
// 检查任务调用传入参数是否json格式
if body.TargetParams != "" {
msg := fmt.Sprintf("调度任务新增【%s】失败任务传入参数json字符串不正确", body.JobName)
// 调度任务新增【%s】失败任务传入参数json字符串不正确
msg := fmt.Sprintf("Scheduling task add [%s] failed, task incoming parameter json string is incorrect", body.JobName)
if len(body.TargetParams) < 7 {
c.JSON(200, result.ErrMsg(msg))
return
@@ -96,7 +98,8 @@ func (s *SysJobController) Add(c *gin.Context) {
// 检查属性值唯一
uniqueJob := s.sysJobService.CheckUniqueJobName(body.JobName, body.JobGroup, "")
if !uniqueJob {
msg := fmt.Sprintf("调度任务新增【%s】失败同任务组内有相同任务名称", body.JobName)
// 调度任务新增【%s】失败同任务组内有相同任务名称
msg := fmt.Sprintf("Scheduling tasks with new [%s] failures, with the same task name in the same task group", body.JobName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -117,20 +120,22 @@ func (s *SysJobController) Edit(c *gin.Context) {
var body model.SysJob
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.JobID == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查cron表达式格式
if parse.CronExpression(body.CronExpression) == 0 {
msg := fmt.Sprintf("调度任务修改【%s】失败Cron表达式不正确", body.JobName)
// 调度任务修改【%s】失败Cron表达式不正确
msg := fmt.Sprintf("Scheduling task modification [%s] fails with incorrect Cron expression", body.JobName)
c.JSON(200, result.ErrMsg(msg))
return
}
// 检查任务调用传入参数是否json格式
if body.TargetParams != "" {
msg := fmt.Sprintf("调度任务修改【%s】失败任务传入参数json字符串不正确", body.JobName)
// 调度任务修改【%s】失败任务传入参数json字符串不正确
msg := fmt.Sprintf("Scheduling task modification [%s] failed, task incoming parameter json string is not correct", body.JobName)
if len(body.TargetParams) < 7 {
c.JSON(200, result.ErrMsg(msg))
return
@@ -144,7 +149,8 @@ func (s *SysJobController) Edit(c *gin.Context) {
// 检查属性值唯一
uniqueJob := s.sysJobService.CheckUniqueJobName(body.JobName, body.JobGroup, body.JobID)
if !uniqueJob {
msg := fmt.Sprintf("调度任务修改【%s】失败同任务组内有相同任务名称", body.JobName)
// 调度任务修改【%s】失败同任务组内有相同任务名称
msg := fmt.Sprintf("Scheduling task modification [%s] failed with the same task name in the same task group", body.JobName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -164,7 +170,7 @@ func (s *SysJobController) Edit(c *gin.Context) {
func (s *SysJobController) Remove(c *gin.Context) {
jobIds := c.Param("jobIds")
if jobIds == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 处理字符转id数组后去重
@@ -179,7 +185,7 @@ func (s *SysJobController) Remove(c *gin.Context) {
c.JSON(200, result.ErrMsg(err.Error()))
return
}
msg := fmt.Sprintf("删除成功:%d", rows)
msg := fmt.Sprintf("Deleted successfully: %d", rows)
c.JSON(200, result.OkMsg(msg))
}
@@ -195,20 +201,22 @@ func (s *SysJobController) Status(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
}
// 检查是否存在
job := s.sysJobService.SelectJobById(body.JobId)
if job.JobID != body.JobId {
c.JSON(200, result.ErrMsg("没有权限访问调度任务数据!"))
// 没有可访问调度任务数据!
c.JSON(200, result.ErrMsg("No accessible scheduling task data!"))
return
}
// 与旧值相等不变更
if job.Status == body.Status {
c.JSON(200, result.ErrMsg("变更状态与旧值相等!"))
// 变更状态与旧值相等!
c.JSON(200, result.ErrMsg("Change status equals old value!"))
return
}
@@ -229,14 +237,15 @@ func (s *SysJobController) Status(c *gin.Context) {
func (s *SysJobController) Run(c *gin.Context) {
jobId := c.Param("jobId")
if jobId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查是否存在
job := s.sysJobService.SelectJobById(jobId)
if job.JobID != jobId {
c.JSON(200, result.ErrMsg("没有权限访问调度任务数据!"))
// 没有可访问调度任务数据!
c.JSON(200, result.ErrMsg("No accessible scheduling task data!"))
return
}
@@ -264,7 +273,8 @@ func (s *SysJobController) Export(c *gin.Context) {
querys := ctx.BodyJSONMap(c)
data := s.sysJobService.SelectJobPage(querys)
if data["total"].(int64) == 0 {
c.JSON(200, result.ErrMsg("导出数据记录为空"))
// 导出数据记录为空
c.JSON(200, result.ErrMsg("Export data record is empty"))
return
}
rows := data["rows"].([]model.SysJob)
@@ -273,16 +283,16 @@ func (s *SysJobController) Export(c *gin.Context) {
fileName := fmt.Sprintf("job_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
// 第一行表头标题
headerCells := map[string]string{
"A1": "任务编号",
"B1": "任务名称",
"C1": "任务组名",
"D1": "调用目标",
"E1": "传入参数",
"F1": "执行表达式",
"G1": "出错策略",
"H1": "并发执行",
"I1": "任务状态",
"J1": "备注说明",
"A1": "JobID",
"B1": "JobName",
"C1": "JobGroupName",
"D1": "InvokeTarget",
"E1": "TargetParams",
"F1": "CronExpression",
"G1": "MisfirePolicy",
"H1": "Concurrent",
"I1": "Status",
"J1": "Remark",
}
// 读取任务组名字典数据
dictSysJobGroup := s.sysDictDataService.SelectDictDataByType("sys_job_group")
@@ -298,20 +308,20 @@ func (s *SysJobController) Export(c *gin.Context) {
break
}
}
misfirePolicy := "放弃执行"
misfirePolicy := "Abandon execution"
if row.MisfirePolicy == "1" {
misfirePolicy = "立即执行"
misfirePolicy = "Execute immediately"
} else if row.MisfirePolicy == "2" {
misfirePolicy = "执行一次"
misfirePolicy = "Execute once"
}
concurrent := "禁止"
concurrent := "prohibit"
if row.Concurrent == "1" {
concurrent = "允许"
concurrent = "allow"
}
// 状态
statusValue := "失败"
statusValue := "fail"
if row.Status == "1" {
statusValue = "成功"
statusValue = "successes"
}
dataCells = append(dataCells, map[string]any{
"A" + idx: row.JobID,

View File

@@ -50,7 +50,7 @@ func (s *SysJobLogController) List(c *gin.Context) {
func (s *SysJobLogController) Info(c *gin.Context) {
jobLogId := c.Param("jobLogId")
if jobLogId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
data := s.sysJobLogService.SelectJobLogById(jobLogId)
@@ -67,7 +67,7 @@ func (s *SysJobLogController) Info(c *gin.Context) {
func (s *SysJobLogController) Remove(c *gin.Context) {
jobLogIds := c.Param("jobLogIds")
if jobLogIds == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -80,7 +80,8 @@ func (s *SysJobLogController) Remove(c *gin.Context) {
}
rows := s.sysJobLogService.DeleteJobLogByIds(uniqueIDs)
if rows > 0 {
msg := fmt.Sprintf("删除成功:%d", rows)
// 删除成功:%d
msg := fmt.Sprintf("Deleted successfully: %d", rows)
c.JSON(200, result.OkMsg(msg))
return
}
@@ -107,7 +108,7 @@ func (s *SysJobLogController) Export(c *gin.Context) {
querys := ctx.BodyJSONMap(c)
data := s.sysJobLogService.SelectJobLogPage(querys)
if data["total"].(int64) == 0 {
c.JSON(200, result.ErrMsg("导出数据记录为空"))
c.JSON(200, result.ErrMsg("Export data record is empty"))
return
}
rows := data["rows"].([]model.SysJobLog)
@@ -116,14 +117,14 @@ func (s *SysJobLogController) Export(c *gin.Context) {
fileName := fmt.Sprintf("jobLog_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
// 第一行表头标题
headerCells := map[string]string{
"A1": "日志序号",
"B1": "任务名称",
"C1": "任务组名",
"D1": "调用目标",
"E1": "传入参数",
"F1": "日志信息",
"G1": "执行状态",
"H1": "记录时间",
"A1": "JobLogID",
"B1": "JobName",
"C1": "JobGroupName",
"D1": "InvokeTarget",
"E1": "TargetParams",
"F1": "JobMsg",
"G1": "Status",
"H1": "Time",
}
// 读取任务组名字典数据
dictSysJobGroup := s.sysDictDataService.SelectDictDataByType("sys_job_group")
@@ -140,9 +141,9 @@ func (s *SysJobLogController) Export(c *gin.Context) {
}
}
// 状态
statusValue := "失败"
statusValue := "Fail"
if row.Status == "1" {
statusValue = "成功"
statusValue = "Success"
}
dataCells = append(dataCells, map[string]any{
"A" + idx: row.JobLogID,

View File

@@ -112,7 +112,7 @@ func (s *SysUserOnlineController) List(c *gin.Context) {
func (s *SysUserOnlineController) ForceLogout(c *gin.Context) {
tokenId := c.Param("tokenId")
if tokenId == "" || tokenId == "*" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}

View File

@@ -80,18 +80,18 @@ func Setup(router *gin.Engine) {
)
sysJobLogGroup.DELETE("/:jobLogIds",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("调度任务日志信息", collectlogs.BUSINESS_TYPE_DELETE)),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task Log", collectlogs.BUSINESS_TYPE_DELETE)),
controller.NewSysJobLog.Remove,
)
sysJobLogGroup.DELETE("/clean",
repeat.RepeatSubmit(5),
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("调度任务日志信息", collectlogs.BUSINESS_TYPE_CLEAN)),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task Log", collectlogs.BUSINESS_TYPE_CLEAN)),
controller.NewSysJobLog.Clean,
)
sysJobLogGroup.POST("/export",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:export"}}),
collectlogs.OperateLog(collectlogs.OptionNew("调度任务日志信息", collectlogs.BUSINESS_TYPE_EXPORT)),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task Log", collectlogs.BUSINESS_TYPE_EXPORT)),
controller.NewSysJobLog.Export,
)
}
@@ -109,39 +109,39 @@ func Setup(router *gin.Engine) {
)
sysJobGroup.POST("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:add"}}),
collectlogs.OperateLog(collectlogs.OptionNew("调度任务信息", collectlogs.BUSINESS_TYPE_INSERT)),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task", collectlogs.BUSINESS_TYPE_INSERT)),
controller.NewSysJob.Add,
)
sysJobGroup.PUT("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:edit"}}),
collectlogs.OperateLog(collectlogs.OptionNew("调度任务信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysJob.Edit,
)
sysJobGroup.DELETE("/:jobIds",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("调度任务信息", collectlogs.BUSINESS_TYPE_DELETE)),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task", collectlogs.BUSINESS_TYPE_DELETE)),
controller.NewSysJob.Remove,
)
sysJobGroup.PUT("/changeStatus",
repeat.RepeatSubmit(5),
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:changeStatus"}}),
collectlogs.OperateLog(collectlogs.OptionNew("调度任务信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysJob.Status,
)
sysJobGroup.PUT("/run/:jobId",
repeat.RepeatSubmit(10),
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:changeStatus"}}),
collectlogs.OperateLog(collectlogs.OptionNew("调度任务信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysJob.Run,
)
sysJobGroup.PUT("/resetQueueJob",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:changeStatus"}}),
collectlogs.OperateLog(collectlogs.OptionNew("调度任务信息", collectlogs.BUSINESS_TYPE_CLEAN)),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task", collectlogs.BUSINESS_TYPE_CLEAN)),
controller.NewSysJob.ResetQueueJob,
)
sysJobGroup.POST("/export",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:export"}}),
collectlogs.OperateLog(collectlogs.OptionNew("调度任务信息", collectlogs.BUSINESS_TYPE_EXPORT)),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task", collectlogs.BUSINESS_TYPE_EXPORT)),
controller.NewSysJob.Export,
)
}

View File

@@ -1,7 +1,7 @@
package service
import (
"errors"
"fmt"
"ems.agt/src/framework/constants/common"
"ems.agt/src/framework/cron"
@@ -85,7 +85,8 @@ func (r *SysJobImpl) DeleteJobByIds(jobIds []string) (int64, error) {
// 检查是否存在
jobs := r.sysJobRepository.SelectJobByIds(jobIds)
if len(jobs) <= 0 {
return 0, errors.New("没有权限访问调度任务数据!")
// 没有可访问调度任务数据!
return 0, fmt.Errorf("There is no accessible scheduling task data!")
}
if len(jobs) == len(jobIds) {
// 清除任务
@@ -95,7 +96,8 @@ func (r *SysJobImpl) DeleteJobByIds(jobIds []string) (int64, error) {
rows := r.sysJobRepository.DeleteJobByIds(jobIds)
return rows, nil
}
return 0, errors.New("删除调度任务信息失败!")
// 删除调度任务信息失败!
return 0, fmt.Errorf("Failed to delete scheduling task information!")
}
// ChangeStatus 任务调度状态修改

View File

@@ -26,7 +26,7 @@ func (s *NeInfoController) NeTypeAndID(c *gin.Context) {
neType := c.Query("neType")
neId := c.Query("neId")
if neType == "" || neId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}

View File

@@ -45,7 +45,7 @@ func (s *SysConfigController) List(c *gin.Context) {
func (s *SysConfigController) Info(c *gin.Context) {
configId := c.Param("configId")
if configId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
data := s.sysConfigService.SelectConfigById(configId)
@@ -63,14 +63,15 @@ func (s *SysConfigController) Add(c *gin.Context) {
var body model.SysConfig
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.ConfigID != "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查属性值唯一
uniqueConfigKey := s.sysConfigService.CheckUniqueConfigKey(body.ConfigKey, "")
if !uniqueConfigKey {
msg := fmt.Sprintf("参数配置新增【%s】失败参数键名已存在", body.ConfigKey)
// 参数配置新增【%s】失败参数键名已存在
msg := fmt.Sprintf("Parameter configuration add [%s] failed, parameter key name already exists", body.ConfigKey)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -91,14 +92,15 @@ func (s *SysConfigController) Edit(c *gin.Context) {
var body model.SysConfig
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.ConfigID == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查属性值唯一
uniqueConfigKey := s.sysConfigService.CheckUniqueConfigKey(body.ConfigKey, body.ConfigID)
if !uniqueConfigKey {
msg := fmt.Sprintf("参数配置修改【%s】失败参数键名已存在", body.ConfigKey)
// 参数配置修改【%s】失败参数键名已存在
msg := fmt.Sprintf("Parameter configuration modification [%s] failed, parameter key name already exists", body.ConfigKey)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -106,7 +108,8 @@ func (s *SysConfigController) Edit(c *gin.Context) {
// 检查是否存在
config := s.sysConfigService.SelectConfigById(body.ConfigID)
if config.ConfigID != body.ConfigID {
c.JSON(200, result.ErrMsg("没有权限访问参数配置数据!"))
// 没有可访问参数配置数据!
c.JSON(200, result.ErrMsg("There is no accessible parameter configuration data!"))
return
}
@@ -125,7 +128,7 @@ func (s *SysConfigController) Edit(c *gin.Context) {
func (s *SysConfigController) Remove(c *gin.Context) {
configIds := c.Param("configIds")
if configIds == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 处理字符转id数组后去重
@@ -140,7 +143,7 @@ func (s *SysConfigController) Remove(c *gin.Context) {
c.JSON(200, result.ErrMsg(err.Error()))
return
}
msg := fmt.Sprintf("删除成功:%d", rows)
msg := fmt.Sprintf("Deleted successfully: %d", rows)
c.JSON(200, result.OkMsg(msg))
}
@@ -158,7 +161,7 @@ func (s *SysConfigController) RefreshCache(c *gin.Context) {
func (s *SysConfigController) ConfigKey(c *gin.Context) {
configKey := c.Param("configKey")
if configKey == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
key := s.sysConfigService.SelectConfigValueByKey(configKey)
@@ -177,7 +180,8 @@ func (s *SysConfigController) Export(c *gin.Context) {
querys := ctx.BodyJSONMap(c)
data := s.sysConfigService.SelectConfigPage(querys)
if data["total"].(int64) == 0 {
c.JSON(200, result.ErrMsg("导出数据记录为空"))
// 导出数据记录为空
c.JSON(200, result.ErrMsg("Export data record is empty"))
return
}
rows := data["rows"].([]model.SysConfig)
@@ -186,19 +190,19 @@ func (s *SysConfigController) Export(c *gin.Context) {
fileName := fmt.Sprintf("config_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
// 第一行表头标题
headerCells := map[string]string{
"A1": "参数编号",
"B1": "参数名称",
"C1": "参数键名",
"D1": "参数键值",
"E1": "系统内置",
"A1": "ConfigID",
"B1": "ConfigName",
"C1": "ConfigKey",
"D1": "ConfigValue",
"E1": "Type",
}
// 从第二行开始的数据
dataCells := make([]map[string]any, 0)
for i, row := range rows {
idx := strconv.Itoa(i + 2)
typeValue := ""
typeValue := "clogged"
if row.ConfigType == "Y" {
typeValue = ""
typeValue = "be"
}
dataCells = append(dataCells, map[string]any{
"A" + idx: row.ConfigID,
@@ -228,20 +232,22 @@ func (s *SysConfigController) ConfigValue(c *gin.Context) {
Value string `json:"value" binding:"required"`
}
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查是否存在
info := s.sysConfigService.SelectConfigByKey(body.Key)
if info.ConfigKey != body.Key {
c.JSON(200, result.ErrMsg("无效 key"))
// 无效 key
c.JSON(200, result.ErrMsg("Invalid key"))
return
}
// 与旧值相等不变更
if info.ConfigValue == body.Value {
c.JSON(200, result.ErrMsg("变更状态与旧值相等!"))
// 变更状态与旧值相等!
c.JSON(200, result.ErrMsg("The change status is equal to the old value!"))
return
}
info.ConfigValue = body.Value

View File

@@ -43,7 +43,7 @@ func (s *SysDeptController) List(c *gin.Context) {
}
err := c.ShouldBindQuery(&querys)
if err != nil {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -64,7 +64,7 @@ func (s *SysDeptController) List(c *gin.Context) {
func (s *SysDeptController) Info(c *gin.Context) {
deptId := c.Param("deptId")
if deptId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
data := s.sysDeptService.SelectDeptById(deptId)
@@ -82,7 +82,7 @@ func (s *SysDeptController) Add(c *gin.Context) {
var body model.SysDept
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.DeptID != "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -90,16 +90,19 @@ func (s *SysDeptController) Add(c *gin.Context) {
if body.ParentID != "0" {
deptParent := s.sysDeptService.SelectDeptById(body.ParentID)
if deptParent.DeptID != body.ParentID {
c.JSON(200, result.ErrMsg("没有权限访问部门数据!"))
// 没有可访问部门数据!
c.JSON(200, result.ErrMsg("There is no accessible sectoral data!"))
return
}
if deptParent.Status == common.STATUS_NO {
msg := fmt.Sprintf("上级部门【%s】停用不允许新增", deptParent.DeptName)
// 上级部门【%s】停用不允许新增
msg := fmt.Sprintf("Upper division [%s] deactivated, no new additions allowed", deptParent.DeptName)
c.JSON(200, result.ErrMsg(msg))
return
}
if deptParent.DelFlag == common.STATUS_YES {
msg := fmt.Sprintf("上级部门【%s】已删除不允许新增", deptParent.DeptName)
// 上级部门【%s】已删除不允许新增
msg := fmt.Sprintf("The parent department [%s] has been deleted and is not allowed to be added", deptParent.DeptName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -111,7 +114,8 @@ func (s *SysDeptController) Add(c *gin.Context) {
// 检查同级下名称唯一
uniqueDeptName := s.sysDeptService.CheckUniqueDeptName(body.DeptName, body.ParentID, "")
if !uniqueDeptName {
msg := fmt.Sprintf("部门新增【%s】失败部门名称已存在", body.DeptName)
// 部门新增【%s】失败部门名称已存在
msg := fmt.Sprintf("Department add [%s] failed, department name already exists", body.DeptName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -132,13 +136,14 @@ func (s *SysDeptController) Edit(c *gin.Context) {
var body model.SysDept
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.DeptID == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 上级部门不能选自己
if body.DeptID == body.ParentID {
msg := fmt.Sprintf("部门修改【%s】失败上级部门不能是自己", body.DeptName)
// 部门修改【%s】失败上级部门不能是自己
msg := fmt.Sprintf("Departmental modification [%s] failed, the parent department cannot be itself", body.DeptName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -146,14 +151,16 @@ func (s *SysDeptController) Edit(c *gin.Context) {
// 检查数据是否存在
deptInfo := s.sysDeptService.SelectDeptById(body.DeptID)
if deptInfo.DeptID != body.DeptID {
c.JSON(200, result.ErrMsg("没有权限访问部门数据!"))
// 没有可访问部门数据!
c.JSON(200, result.ErrMsg("There is no accessible sectoral data!"))
return
}
// 父级ID不为0是要检查
if body.ParentID != "0" {
deptParent := s.sysDeptService.SelectDeptById(body.ParentID)
if deptParent.DeptID != body.ParentID {
c.JSON(200, result.ErrMsg("没有权限访问部门数据!"))
// 没有可访问部门数据!
c.JSON(200, result.ErrMsg("There is no accessible sectoral data!"))
return
}
}
@@ -161,7 +168,8 @@ func (s *SysDeptController) Edit(c *gin.Context) {
// 检查同级下名称唯一
uniqueDeptName := s.sysDeptService.CheckUniqueDeptName(body.DeptName, body.ParentID, body.DeptID)
if !uniqueDeptName {
msg := fmt.Sprintf("部门修改【%s】失败部门名称已存在", body.DeptName)
// 部门修改【%s】失败部门名称已存在
msg := fmt.Sprintf("Department modification [%s] failed, department name already exists", body.DeptName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -170,7 +178,8 @@ func (s *SysDeptController) Edit(c *gin.Context) {
if body.Status == common.STATUS_NO {
hasChild := s.sysDeptService.HasChildByDeptId(body.DeptID)
if hasChild > 0 {
msg := fmt.Sprintf("该部门包含未停用的子部门数量:%d", hasChild)
// 该部门包含未停用的子部门数量:%d
msg := fmt.Sprintf("Number of subsectors not deactivated included in this sector: %d", hasChild)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -191,21 +200,23 @@ func (s *SysDeptController) Edit(c *gin.Context) {
func (s *SysDeptController) Remove(c *gin.Context) {
deptId := c.Param("deptId")
if deptId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查数据是否存在
dept := s.sysDeptService.SelectDeptById(deptId)
if dept.DeptID != deptId {
c.JSON(200, result.ErrMsg("没有权限访问部门数据!"))
// 没有可访问部门数据!
c.JSON(200, result.ErrMsg("There is no accessible sectoral data!"))
return
}
// 检查是否存在子部门
hasChild := s.sysDeptService.HasChildByDeptId(deptId)
if hasChild > 0 {
msg := fmt.Sprintf("不允许删除,存在子部门数:%d", hasChild)
// 不允许删除,存在子部门数:%d
msg := fmt.Sprintf("Deletion not allowed, number of subsectors present: %d", hasChild)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -213,14 +224,16 @@ func (s *SysDeptController) Remove(c *gin.Context) {
// 检查是否分配给用户
existUser := s.sysDeptService.CheckDeptExistUser(deptId)
if existUser > 0 {
msg := fmt.Sprintf("不允许删除,部门已分配给用户数:%d", existUser)
// 不允许删除,部门已分配给用户数:%d
msg := fmt.Sprintf("Deletions are not allowed and the department has been assigned to the number of users: %d", existUser)
c.JSON(200, result.ErrMsg(msg))
return
}
rows := s.sysDeptService.DeleteDeptById(deptId)
if rows > 0 {
msg := fmt.Sprintf("删除成功:%d", rows)
// 删除成功:%d
msg := fmt.Sprintf("Deleted successfully: %d", rows)
c.JSON(200, result.OkMsg(msg))
return
}
@@ -233,7 +246,7 @@ func (s *SysDeptController) Remove(c *gin.Context) {
func (s *SysDeptController) ExcludeChild(c *gin.Context) {
deptId := c.Param("deptId")
if deptId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -274,7 +287,7 @@ func (s *SysDeptController) TreeSelect(c *gin.Context) {
}
err := c.ShouldBindQuery(&querys)
if err != nil {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -295,7 +308,7 @@ func (s *SysDeptController) TreeSelect(c *gin.Context) {
func (s *SysDeptController) RoleDeptTreeSelect(c *gin.Context) {
roleId := c.Param("roleId")
if roleId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}

View File

@@ -48,7 +48,7 @@ func (s *SysDictDataController) List(c *gin.Context) {
func (s *SysDictDataController) Info(c *gin.Context) {
dictCode := c.Param("dictCode")
if dictCode == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
data := s.sysDictDataService.SelectDictDataByCode(dictCode)
@@ -66,21 +66,23 @@ func (s *SysDictDataController) Add(c *gin.Context) {
var body model.SysDictData
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.DictCode != "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查字典类型是否存在
sysDictType := s.sysDictTypeService.SelectDictTypeByType(body.DictType)
if sysDictType.DictType != body.DictType {
c.JSON(200, result.ErrMsg("没有权限访问字典类型数据!"))
// 没有可访问字典类型数据!
c.JSON(200, result.ErrMsg("There is no accessible dictionary type data!"))
return
}
// 检查字典标签唯一
uniqueDictLabel := s.sysDictDataService.CheckUniqueDictLabel(body.DictType, body.DictLabel, "")
if !uniqueDictLabel {
msg := fmt.Sprintf("数据新增【%s】失败该字典类型下标签名已存在", body.DictLabel)
// 数据新增【%s】失败该字典类型下标签名已存在
msg := fmt.Sprintf("Data addition [%s] failed, tag name already exists under this dictionary type", body.DictLabel)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -88,7 +90,8 @@ func (s *SysDictDataController) Add(c *gin.Context) {
// 检查字典键值唯一
uniqueDictValue := s.sysDictDataService.CheckUniqueDictValue(body.DictType, body.DictValue, "")
if !uniqueDictValue {
msg := fmt.Sprintf("数据新增【%s】失败该字典类型下标签值已存在", body.DictValue)
// 数据新增【%s】失败该字典类型下标签值已存在
msg := fmt.Sprintf("Data addition [%s] failed, tagged value already exists under this dictionary type", body.DictValue)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -109,28 +112,31 @@ func (s *SysDictDataController) Edit(c *gin.Context) {
var body model.SysDictData
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.DictCode == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查字典类型是否存在
sysDictType := s.sysDictTypeService.SelectDictTypeByType(body.DictType)
if sysDictType.DictType != body.DictType {
c.JSON(200, result.ErrMsg("没有权限访问字典类型数据!"))
// 没有可访问字典类型数据!
c.JSON(200, result.ErrMsg("There is no accessible dictionary type data!"))
return
}
// 检查字典编码是否存在
SysDictDataController := s.sysDictDataService.SelectDictDataByCode(body.DictCode)
if SysDictDataController.DictCode != body.DictCode {
c.JSON(200, result.ErrMsg("没有权限访问字典编码数据!"))
// 没有可访问字典编码数据!
c.JSON(200, result.ErrMsg("There is no accessible dictionary-encoded data!"))
return
}
// 检查字典标签唯一
uniqueDictLabel := s.sysDictDataService.CheckUniqueDictLabel(body.DictType, body.DictLabel, body.DictCode)
if !uniqueDictLabel {
msg := fmt.Sprintf("数据修改【%s】失败该字典类型下标签名已存在", body.DictLabel)
// 数据修改【%s】失败该字典类型下标签名已存在
msg := fmt.Sprintf("Data modification [%s] failed, tag name already exists under this dictionary type", body.DictLabel)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -138,7 +144,8 @@ func (s *SysDictDataController) Edit(c *gin.Context) {
// 检查字典键值唯一
uniqueDictValue := s.sysDictDataService.CheckUniqueDictValue(body.DictType, body.DictValue, body.DictCode)
if !uniqueDictValue {
msg := fmt.Sprintf("数据修改【%s】失败该字典类型下标签值已存在", body.DictValue)
// 数据修改【%s】失败该字典类型下标签值已存在
msg := fmt.Sprintf("Data modification [%s] failed, tagged value already exists under this dictionary type", body.DictValue)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -158,7 +165,7 @@ func (s *SysDictDataController) Edit(c *gin.Context) {
func (s *SysDictDataController) Remove(c *gin.Context) {
dictCodes := c.Param("dictCodes")
if dictCodes == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 处理字符转id数组后去重
@@ -173,7 +180,8 @@ func (s *SysDictDataController) Remove(c *gin.Context) {
c.JSON(200, result.ErrMsg(err.Error()))
return
}
msg := fmt.Sprintf("删除成功:%d", rows)
// 删除成功:%d
msg := fmt.Sprintf("Deleted successfully: %d", rows)
c.JSON(200, result.OkMsg(msg))
}
@@ -183,7 +191,7 @@ func (s *SysDictDataController) Remove(c *gin.Context) {
func (s *SysDictDataController) DictType(c *gin.Context) {
dictType := c.Param("dictType")
if dictType == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -199,7 +207,8 @@ func (s *SysDictDataController) Export(c *gin.Context) {
querys := ctx.BodyJSONMap(c)
data := s.sysDictDataService.SelectDictDataPage(querys)
if data["total"].(int64) == 0 {
c.JSON(200, result.ErrMsg("导出数据记录为空"))
// 导出数据记录为空
c.JSON(200, result.ErrMsg("Export data record is empty"))
return
}
rows := data["rows"].([]model.SysDictData)
@@ -208,20 +217,20 @@ func (s *SysDictDataController) Export(c *gin.Context) {
fileName := fmt.Sprintf("dict_data_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
// 第一行表头标题
headerCells := map[string]string{
"A1": "字典编码",
"B1": "字典排序",
"C1": "字典标签",
"D1": "字典键值",
"E1": "字典类型",
"F1": "状态",
"A1": "DictCode",
"B1": "DictSort",
"C1": "DictLabel",
"D1": "DictValue",
"E1": "DictType",
"F1": "Status",
}
// 从第二行开始的数据
dataCells := make([]map[string]any, 0)
for i, row := range rows {
idx := strconv.Itoa(i + 2)
statusValue := "停用"
statusValue := "deactivate"
if row.Status == "1" {
statusValue = "正常"
statusValue = "normalcy"
}
dataCells = append(dataCells, map[string]any{
"A" + idx: row.DictCode,

View File

@@ -46,7 +46,7 @@ func (s *SysDictTypeController) List(c *gin.Context) {
func (s *SysDictTypeController) Info(c *gin.Context) {
dictId := c.Param("dictId")
if dictId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
data := s.sysDictTypeService.SelectDictTypeByID(dictId)
@@ -64,14 +64,15 @@ func (s *SysDictTypeController) Add(c *gin.Context) {
var body model.SysDictType
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.DictID != "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查字典名称唯一
uniqueDictName := s.sysDictTypeService.CheckUniqueDictName(body.DictName, "")
if !uniqueDictName {
msg := fmt.Sprintf("字典新增【%s】失败字典名称已存在", body.DictName)
// 字典新增【%s】失败字典名称已存在
msg := fmt.Sprintf("Dictionary add [%s] failed, dictionary name already exists", body.DictName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -79,7 +80,8 @@ func (s *SysDictTypeController) Add(c *gin.Context) {
// 检查字典类型唯一
uniqueDictType := s.sysDictTypeService.CheckUniqueDictType(body.DictType, "")
if !uniqueDictType {
msg := fmt.Sprintf("字典新增【%s】失败字典类型已存在", body.DictType)
// 字典新增【%s】失败字典类型已存在
msg := fmt.Sprintf("Dictionary add [%s] failed, dictionary type already exists", body.DictType)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -100,21 +102,23 @@ func (s *SysDictTypeController) Edit(c *gin.Context) {
var body model.SysDictType
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.DictID == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查数据是否存在
dictInfo := s.sysDictTypeService.SelectDictTypeByID(body.DictID)
if dictInfo.DictID != body.DictID {
c.JSON(200, result.ErrMsg("没有权限访问字典类型数据!"))
// 没有可访问字典类型数据!
c.JSON(200, result.ErrMsg("There is no accessible dictionary type data!"))
return
}
// 检查字典名称唯一
uniqueDictName := s.sysDictTypeService.CheckUniqueDictName(body.DictName, body.DictID)
if !uniqueDictName {
msg := fmt.Sprintf("字典修改【%s】失败字典名称已存在", body.DictName)
// 字典修改【%s】失败字典名称已存在
msg := fmt.Sprintf("Dictionary modification [%s] failed, dictionary name already exists", body.DictName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -122,7 +126,8 @@ func (s *SysDictTypeController) Edit(c *gin.Context) {
// 检查字典类型唯一
uniqueDictType := s.sysDictTypeService.CheckUniqueDictType(body.DictType, body.DictID)
if !uniqueDictType {
msg := fmt.Sprintf("字典修改【%s】失败字典类型已存在", body.DictType)
// 字典修改【%s】失败字典类型已存在
msg := fmt.Sprintf("Dictionary modification [%s] failed, dictionary type already exists", body.DictType)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -142,7 +147,7 @@ func (s *SysDictTypeController) Edit(c *gin.Context) {
func (s *SysDictTypeController) Remove(c *gin.Context) {
dictIds := c.Param("dictIds")
if dictIds == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 处理字符转id数组后去重
@@ -157,7 +162,7 @@ func (s *SysDictTypeController) Remove(c *gin.Context) {
c.JSON(200, result.ErrMsg(err.Error()))
return
}
msg := fmt.Sprintf("删除成功:%d", rows)
msg := fmt.Sprintf("Deleted successfully: %d", rows)
c.JSON(200, result.OkMsg(msg))
}
@@ -201,7 +206,8 @@ func (s *SysDictTypeController) Export(c *gin.Context) {
querys := ctx.BodyJSONMap(c)
data := s.sysDictTypeService.SelectDictTypePage(querys)
if data["total"].(int64) == 0 {
c.JSON(200, result.ErrMsg("导出数据记录为空"))
// 导出数据记录为空
c.JSON(200, result.ErrMsg("Export data record is empty"))
return
}
rows := data["rows"].([]model.SysDictType)
@@ -210,18 +216,18 @@ func (s *SysDictTypeController) Export(c *gin.Context) {
fileName := fmt.Sprintf("dict_type_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
// 第一行表头标题
headerCells := map[string]string{
"A1": "字典主键",
"B1": "字典名称",
"C1": "字典类型",
"D1": "状态",
"A1": "DictID",
"B1": "DictName",
"C1": "DictType",
"D1": "Status",
}
// 从第二行开始的数据
dataCells := make([]map[string]any, 0)
for i, row := range rows {
idx := strconv.Itoa(i + 2)
statusValue := "停用"
statusValue := "deactivate"
if row.Status == "1" {
statusValue = "正常"
statusValue = "normalcy"
}
dataCells = append(dataCells, map[string]any{
"A" + idx: row.DictID,

View File

@@ -49,7 +49,7 @@ func (s *SysLogLoginController) List(c *gin.Context) {
func (s *SysLogLoginController) Remove(c *gin.Context) {
infoIds := c.Param("infoIds")
if infoIds == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -62,7 +62,7 @@ func (s *SysLogLoginController) Remove(c *gin.Context) {
}
rows := s.sysLogLoginService.DeleteSysLogLoginByIds(uniqueIDs)
if rows > 0 {
msg := fmt.Sprintf("删除成功:%d", rows)
msg := fmt.Sprintf("Deleted successfully: %d", rows)
c.JSON(200, result.OkMsg(msg))
return
}
@@ -87,7 +87,7 @@ func (s *SysLogLoginController) Clean(c *gin.Context) {
func (s *SysLogLoginController) Unlock(c *gin.Context) {
userName := c.Param("userName")
if userName == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
ok := s.accountService.ClearLoginRecordCache(userName)
@@ -106,7 +106,8 @@ func (s *SysLogLoginController) Export(c *gin.Context) {
querys := ctx.BodyJSONMap(c)
data := s.sysLogLoginService.SelectSysLogLoginPage(querys)
if data["total"].(int64) == 0 {
c.JSON(200, result.ErrMsg("导出数据记录为空"))
// 导出数据记录为空
c.JSON(200, result.ErrMsg("Export data record is empty"))
return
}
rows := data["rows"].([]model.SysLogLogin)
@@ -115,24 +116,24 @@ func (s *SysLogLoginController) Export(c *gin.Context) {
fileName := fmt.Sprintf("sys_log_login_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
// 第一行表头标题
headerCells := map[string]string{
"A1": "序号",
"B1": "用户账号",
"C1": "登录状态",
"D1": "登录地址",
"E1": "登录地点",
"F1": "浏览器",
"G1": "操作系统",
"H1": "提示消息",
"I1": "访问时间",
"A1": "ID",
"B1": "UserName",
"C1": "Status",
"D1": "IP",
"E1": "Location",
"F1": "Browser",
"G1": "OS",
"H1": "Msg",
"I1": "Time",
}
// 从第二行开始的数据
dataCells := make([]map[string]any, 0)
for i, row := range rows {
idx := strconv.Itoa(i + 2)
// 状态
statusValue := "失败"
statusValue := "fail"
if row.Status == "1" {
statusValue = "成功"
statusValue = "successes"
}
dataCells = append(dataCells, map[string]any{
"A" + idx: row.LoginID,

View File

@@ -45,7 +45,7 @@ func (s *SysLogOperateController) List(c *gin.Context) {
func (s *SysLogOperateController) Remove(c *gin.Context) {
operIds := c.Param("operIds")
if operIds == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -58,7 +58,7 @@ func (s *SysLogOperateController) Remove(c *gin.Context) {
}
rows := s.SysLogOperateService.DeleteSysLogOperateByIds(uniqueIDs)
if rows > 0 {
msg := fmt.Sprintf("删除成功:%d", rows)
msg := fmt.Sprintf("Deleted successfully: %d", rows)
c.JSON(200, result.OkMsg(msg))
return
}
@@ -85,7 +85,8 @@ func (s *SysLogOperateController) Export(c *gin.Context) {
querys := ctx.BodyJSONMap(c)
data := s.SysLogOperateService.SelectSysLogOperatePage(querys)
if data["total"].(int64) == 0 {
c.JSON(200, result.ErrMsg("导出数据记录为空"))
// 导出数据记录为空
c.JSON(200, result.ErrMsg("Export data record is empty"))
return
}
rows := data["rows"].([]model.SysLogOperate)
@@ -94,22 +95,22 @@ func (s *SysLogOperateController) Export(c *gin.Context) {
fileName := fmt.Sprintf("sys_log_operate_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
// 第一行表头标题
headerCells := map[string]string{
"A1": "操作序号",
"B1": "操作模块",
"C1": "业务类型",
"D1": "请求方法",
"E1": "请求方式",
"F1": "操作类别",
"G1": "操作人员",
"H1": "部门名称",
"I1": "请求地址",
"J1": "操作地址",
"K1": "操作地点",
"L1": "请求参数",
"M1": "操作消息",
"N1": "状态",
"O1": "消耗时间(毫秒)",
"P1": "操作时间",
"A1": "ID",
"B1": "Title",
"C1": "BusinessType",
"D1": "Method",
"E1": "RequestMethod",
"F1": "OperatorType",
"G1": "OperName",
"H1": "DeptName",
"I1": "URL",
"J1": "IP",
"K1": "Location",
"L1": "Param",
"M1": "Msg",
"N1": "Status",
"O1": "CostTime (ms)",
"P1": "OperTime",
}
// 从第二行开始的数据
dataCells := make([]map[string]any, 0)
@@ -118,11 +119,11 @@ func (s *SysLogOperateController) Export(c *gin.Context) {
// 业务类型
businessType := ""
// 操作类别
OperatorType := ""
operatorType := ""
// 状态
statusValue := "失败"
statusValue := "fail"
if row.Status == "1" {
statusValue = "成功"
statusValue = "success"
}
dataCells = append(dataCells, map[string]any{
"A" + idx: row.OperID,
@@ -130,7 +131,7 @@ func (s *SysLogOperateController) Export(c *gin.Context) {
"C" + idx: businessType,
"D" + idx: row.Method,
"E" + idx: row.RequestMethod,
"F" + idx: OperatorType,
"F" + idx: operatorType,
"G" + idx: row.OperName,
"H" + idx: row.DeptName,
"I" + idx: row.OperURL,

View File

@@ -55,7 +55,7 @@ func (s *SysMenuController) List(c *gin.Context) {
func (s *SysMenuController) Info(c *gin.Context) {
menuId := c.Param("menuId")
if menuId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
data := s.sysMenuService.SelectMenuById(menuId)
@@ -73,7 +73,7 @@ func (s *SysMenuController) Add(c *gin.Context) {
var body model.SysMenu
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.MenuID != "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -81,7 +81,8 @@ func (s *SysMenuController) Add(c *gin.Context) {
if menu.TYPE_DIR == body.MenuType || menu.TYPE_MENU == body.MenuType {
uniqueNenuPath := s.sysMenuService.CheckUniqueMenuPath(body.Path, body.ParentID, "")
if !uniqueNenuPath {
msg := fmt.Sprintf("菜单新增【%s】失败菜单路由地址已存在", body.MenuName)
// 菜单新增【%s】失败菜单路由地址已存在
msg := fmt.Sprintf("Menu add [%s] failed, menu routing address already exists", body.MenuName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -90,14 +91,16 @@ func (s *SysMenuController) Add(c *gin.Context) {
// 检查名称唯一
uniqueNenuName := s.sysMenuService.CheckUniqueMenuName(body.MenuName, body.ParentID, "")
if !uniqueNenuName {
msg := fmt.Sprintf("菜单新增【%s】失败菜单名称已存在", body.MenuName)
// 菜单新增【%s】失败菜单名称已存在
msg := fmt.Sprintf("Menu add [%s] failed, menu name already exists", body.MenuName)
c.JSON(200, result.ErrMsg(msg))
return
}
// 外链菜单需要符合网站http(s)开头
if body.IsFrame == common.STATUS_NO && !regular.ValidHttp(body.Path) {
msg := fmt.Sprintf("菜单新增【%s】失败非内部地址必须以http(s)://开头", body.MenuName)
// 菜单新增【%s】失败非内部地址必须以http(s)://开头
msg := fmt.Sprintf("Menu adds [%s] failure, non-internal addresses must start with http(s)://", body.MenuName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -118,13 +121,14 @@ func (s *SysMenuController) Edit(c *gin.Context) {
var body model.SysMenu
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.MenuID == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 上级菜单不能选自己
if body.MenuID == body.ParentID {
msg := fmt.Sprintf("菜单修改【%s】失败上级菜单不能选择自己", body.MenuName)
// 菜单修改【%s】失败上级菜单不能选择自己
msg := fmt.Sprintf("Menu modification [%s] fails, the parent menu cannot select itself", body.MenuName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -132,19 +136,21 @@ func (s *SysMenuController) Edit(c *gin.Context) {
// 检查数据是否存在
menuInfo := s.sysMenuService.SelectMenuById(body.MenuID)
if menuInfo.MenuID != body.MenuID {
c.JSON(200, result.ErrMsg("没有权限访问菜单数据"))
// 没有可访问菜单数据
c.JSON(200, result.ErrMsg("No accessible menu data"))
return
}
// 父级ID不为0是要检查
if body.ParentID != "0" {
menuParent := s.sysMenuService.SelectMenuById(body.ParentID)
if menuParent.MenuID != body.ParentID {
c.JSON(200, result.ErrMsg("没有权限访问菜单数据"))
c.JSON(200, result.ErrMsg("No accessible menu data"))
return
}
// 禁用菜单时检查父菜单是否使用
if body.Status == common.STATUS_YES && menuParent.Status == common.STATUS_NO {
c.JSON(200, result.ErrMsg("上级菜单未启用!"))
// 上级菜单未启用!
c.JSON(200, result.ErrMsg("The parent menu is not enabled!"))
return
}
}
@@ -153,7 +159,8 @@ func (s *SysMenuController) Edit(c *gin.Context) {
if menu.TYPE_DIR == body.MenuType || menu.TYPE_MENU == body.MenuType {
uniqueNenuPath := s.sysMenuService.CheckUniqueMenuPath(body.Path, body.ParentID, body.MenuID)
if !uniqueNenuPath {
msg := fmt.Sprintf("菜单修改【%s】失败菜单路由地址已存在", body.MenuName)
// 菜单修改【%s】失败菜单路由地址已存在
msg := fmt.Sprintf("Menu modification [%s] failed, menu routing address already exists", body.MenuName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -162,14 +169,16 @@ func (s *SysMenuController) Edit(c *gin.Context) {
// 检查名称唯一
uniqueNenuName := s.sysMenuService.CheckUniqueMenuName(body.MenuName, body.ParentID, body.MenuID)
if !uniqueNenuName {
msg := fmt.Sprintf("菜单修改【%s】失败菜单名称已存在", body.MenuName)
// 菜单修改【%s】失败菜单名称已存在
msg := fmt.Sprintf("Menu modification [%s] failed, menu name already exists", body.MenuName)
c.JSON(200, result.ErrMsg(msg))
return
}
// 外链菜单需要符合网站http(s)开头
if body.IsFrame == common.STATUS_NO && !regular.ValidHttp(body.Path) {
msg := fmt.Sprintf("菜单修改【%s】失败非内部地址必须以http(s)://开头", body.MenuName)
// 菜单修改【%s】失败非内部地址必须以http(s)://开头
msg := fmt.Sprintf("Menu change [%s] failed, non-internal address must start with http(s)://", body.MenuName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -178,7 +187,8 @@ func (s *SysMenuController) Edit(c *gin.Context) {
if body.Status == common.STATUS_NO {
hasStatus := s.sysMenuService.HasChildByMenuIdAndStatus(body.MenuID, common.STATUS_YES)
if hasStatus > 0 {
msg := fmt.Sprintf("不允许禁用,存在使用子菜单数:%d", hasStatus)
// 不允许禁用,存在使用子菜单数:%d
msg := fmt.Sprintf("Disabling is not allowed, number of submenus present for use: %d", hasStatus)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -199,21 +209,23 @@ func (s *SysMenuController) Edit(c *gin.Context) {
func (s *SysMenuController) Remove(c *gin.Context) {
menuId := c.Param("menuId")
if menuId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查数据是否存在
menu := s.sysMenuService.SelectMenuById(menuId)
if menu.MenuID != menuId {
c.JSON(200, result.ErrMsg("没有权限访问菜单数据!"))
// 没有可访问菜单数据!
c.JSON(200, result.ErrMsg("There is no accessible menu data!"))
return
}
// 检查是否存在子菜单
hasChild := s.sysMenuService.HasChildByMenuIdAndStatus(menuId, "")
if hasChild > 0 {
msg := fmt.Sprintf("不允许删除,存在子菜单数:%d", hasChild)
// 不允许删除,存在子菜单数:%d
msg := fmt.Sprintf("Deletion not allowed, number of submenus present: %d", hasChild)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -221,14 +233,15 @@ func (s *SysMenuController) Remove(c *gin.Context) {
// 检查是否分配给角色
existRole := s.sysMenuService.CheckMenuExistRole(menuId)
if existRole > 0 {
msg := fmt.Sprintf("不允许删除,菜单已分配给角色数:%d", existRole)
// 不允许删除,菜单已分配给角色数:%d
msg := fmt.Sprintf("Deletion not allowed, number of roles assigned to the menu: %d", existRole)
c.JSON(200, result.ErrMsg(msg))
return
}
rows := s.sysMenuService.DeleteMenuById(menuId)
if rows > 0 {
msg := fmt.Sprintf("删除成功:%d", rows)
msg := fmt.Sprintf("Deleted successfully: %d", rows)
c.JSON(200, result.OkMsg(msg))
return
}
@@ -262,7 +275,7 @@ func (s *SysMenuController) TreeSelect(c *gin.Context) {
func (s *SysMenuController) RoleMenuTreeSelect(c *gin.Context) {
roleId := c.Param("roleId")
if roleId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}

View File

@@ -42,7 +42,7 @@ func (s *SysNoticeController) List(c *gin.Context) {
func (s *SysNoticeController) Info(c *gin.Context) {
noticeId := c.Param("noticeId")
if noticeId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
data := s.sysNoticeService.SelectNoticeById(noticeId)
@@ -60,7 +60,7 @@ func (s *SysNoticeController) Add(c *gin.Context) {
var body model.SysNotice
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.NoticeID != "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -80,14 +80,15 @@ func (s *SysNoticeController) Edit(c *gin.Context) {
var body model.SysNotice
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.NoticeID == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查是否存在
notice := s.sysNoticeService.SelectNoticeById(body.NoticeID)
if notice.NoticeID != body.NoticeID {
c.JSON(200, result.ErrMsg("没有权限访问公告信息数据!"))
// 没有可访问公告信息数据!
c.JSON(200, result.ErrMsg("There is no accessible bulletin information data!"))
return
}
@@ -106,7 +107,7 @@ func (s *SysNoticeController) Edit(c *gin.Context) {
func (s *SysNoticeController) Remove(c *gin.Context) {
noticeIds := c.Param("noticeIds")
if noticeIds == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 处理字符转id数组后去重
@@ -121,6 +122,6 @@ func (s *SysNoticeController) Remove(c *gin.Context) {
c.JSON(200, result.ErrMsg(err.Error()))
return
}
msg := fmt.Sprintf("删除成功:%d", rows)
msg := fmt.Sprintf("Deleted successfully: %d", rows)
c.JSON(200, result.OkMsg(msg))
}

View File

@@ -45,7 +45,7 @@ func (s *SysPostController) List(c *gin.Context) {
func (s *SysPostController) Info(c *gin.Context) {
postId := c.Param("postId")
if postId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
data := s.sysPostService.SelectPostById(postId)
@@ -63,14 +63,15 @@ func (s *SysPostController) Add(c *gin.Context) {
var body model.SysPost
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.PostID != "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查名称唯一
uniqueuPostName := s.sysPostService.CheckUniquePostName(body.PostName, "")
if !uniqueuPostName {
msg := fmt.Sprintf("岗位新增【%s】失败岗位名称已存在", body.PostName)
// 岗位新增【%s】失败岗位名称已存在
msg := fmt.Sprintf("Job addition [%s] failed, job name already exists", body.PostName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -78,7 +79,8 @@ func (s *SysPostController) Add(c *gin.Context) {
// 检查编码属性值唯一
uniquePostCode := s.sysPostService.CheckUniquePostCode(body.PostCode, "")
if !uniquePostCode {
msg := fmt.Sprintf("岗位新增【%s】失败岗位编码已存在", body.PostCode)
// 岗位新增【%s】失败岗位编码已存在
msg := fmt.Sprintf("Job addition [%s] failed, job code already exists", body.PostCode)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -99,21 +101,23 @@ func (s *SysPostController) Edit(c *gin.Context) {
var body model.SysPost
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.PostID == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查是否存在
post := s.sysPostService.SelectPostById(body.PostID)
if post.PostID != body.PostID {
c.JSON(200, result.ErrMsg("没有权限访问岗位数据!"))
// 没有可访问岗位数据!
c.JSON(200, result.ErrMsg("There is no accessible post data!"))
return
}
// 检查名称唯一
uniqueuPostName := s.sysPostService.CheckUniquePostName(body.PostName, body.PostID)
if !uniqueuPostName {
msg := fmt.Sprintf("岗位修改【%s】失败岗位名称已存在", body.PostName)
// 岗位修改【%s】失败岗位名称已存在
msg := fmt.Sprintf("Post modification [%s] failed, post name already exists", body.PostName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -121,7 +125,8 @@ func (s *SysPostController) Edit(c *gin.Context) {
// 检查编码属性值唯一
uniquePostCode := s.sysPostService.CheckUniquePostCode(body.PostCode, body.PostID)
if !uniquePostCode {
msg := fmt.Sprintf("岗位修改【%s】失败岗位编码已存在", body.PostCode)
// 岗位修改【%s】失败岗位编码已存在
msg := fmt.Sprintf("Post modification [%s] failed, post code already exists", body.PostCode)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -141,7 +146,7 @@ func (s *SysPostController) Edit(c *gin.Context) {
func (s *SysPostController) Remove(c *gin.Context) {
postIds := c.Param("postIds")
if postIds == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 处理字符转id数组后去重
@@ -156,7 +161,7 @@ func (s *SysPostController) Remove(c *gin.Context) {
c.JSON(200, result.ErrMsg(err.Error()))
return
}
msg := fmt.Sprintf("删除成功:%d", rows)
msg := fmt.Sprintf("Deleted successfully: %d", rows)
c.JSON(200, result.OkMsg(msg))
}
@@ -168,7 +173,8 @@ func (s *SysPostController) Export(c *gin.Context) {
querys := ctx.BodyJSONMap(c)
data := s.sysPostService.SelectPostPage(querys)
if data["total"].(int64) == 0 {
c.JSON(200, result.ErrMsg("导出数据记录为空"))
// 导出数据记录为空
c.JSON(200, result.ErrMsg("Export data record is empty"))
return
}
rows := data["rows"].([]model.SysPost)
@@ -177,19 +183,19 @@ func (s *SysPostController) Export(c *gin.Context) {
fileName := fmt.Sprintf("post_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
// 第一行表头标题
headerCells := map[string]string{
"A1": "岗位编号",
"B1": "岗位编码",
"C1": "岗位名称",
"D1": "岗位排序",
"E1": "状态",
"A1": "PostID",
"B1": "PostCode",
"C1": "PostName",
"D1": "PostSort",
"E1": "Status",
}
// 从第二行开始的数据
dataCells := make([]map[string]any, 0)
for i, row := range rows {
idx := strconv.Itoa(i + 2)
statusValue := "停用"
statusValue := "deactivate"
if row.Status == "1" {
statusValue = "正常"
statusValue = "normalcy"
}
dataCells = append(dataCells, map[string]any{
"A" + idx: row.PostID,

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
}

View File

@@ -51,7 +51,7 @@ func (s *SysRoleController) List(c *gin.Context) {
func (s *SysRoleController) Info(c *gin.Context) {
roleId := c.Param("roleId")
if roleId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
data := s.sysRoleService.SelectRoleById(roleId)
@@ -69,14 +69,15 @@ func (s *SysRoleController) Add(c *gin.Context) {
var body model.SysRole
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.RoleID != "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 判断角色名称是否唯一
uniqueRoleName := s.sysRoleService.CheckUniqueRoleName(body.RoleName, "")
if !uniqueRoleName {
msg := fmt.Sprintf("角色新增【%s】失败角色名称已存在", body.RoleName)
// 角色新增【%s】失败角色名称已存在
msg := fmt.Sprintf("Character addition [%s] failed, character name already exists", body.RoleName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -84,7 +85,8 @@ func (s *SysRoleController) Add(c *gin.Context) {
// 判断角色键值是否唯一
uniqueRoleKey := s.sysRoleService.CheckUniqueRoleKey(body.RoleKey, "")
if !uniqueRoleKey {
msg := fmt.Sprintf("角色新增【%s】失败角色键值已存在", body.RoleName)
// 角色新增【%s】失败角色键值已存在
msg := fmt.Sprintf("Character addition [%s] failed, character key already exists", body.RoleName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -105,27 +107,30 @@ func (s *SysRoleController) Edit(c *gin.Context) {
var body model.SysRole
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.RoleID == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查是否管理员角色
if body.RoleID == admin.ROLE_ID {
c.JSON(200, result.ErrMsg("不允许操作管理员角色"))
// 不允许操作管理员角色
c.JSON(200, result.ErrMsg("The administrator role is not allowed to operate"))
return
}
// 检查是否存在
role := s.sysRoleService.SelectRoleById(body.RoleID)
if role.RoleID != body.RoleID {
c.JSON(200, result.ErrMsg("没有权限访问角色数据!"))
// 没有可访问角色数据!
c.JSON(200, result.ErrMsg("There is no accessible role data!"))
return
}
// 判断角色名称是否唯一
uniqueRoleName := s.sysRoleService.CheckUniqueRoleName(body.RoleName, body.RoleID)
if !uniqueRoleName {
msg := fmt.Sprintf("角色修改【%s】失败角色名称已存在", body.RoleName)
// 角色修改【%s】失败角色名称已存在
msg := fmt.Sprintf("Character modification [%s] failed, character name already exists", body.RoleName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -133,7 +138,8 @@ func (s *SysRoleController) Edit(c *gin.Context) {
// 判断角色键值是否唯一
uniqueRoleKey := s.sysRoleService.CheckUniqueRoleKey(body.RoleKey, body.RoleID)
if !uniqueRoleKey {
msg := fmt.Sprintf("角色修改【%s】失败角色键值已存在", body.RoleName)
// 角色修改【%s】失败角色键值已存在
msg := fmt.Sprintf("Character modification [%s] failed, character key already exists", body.RoleName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -153,7 +159,7 @@ func (s *SysRoleController) Edit(c *gin.Context) {
func (s *SysRoleController) Remove(c *gin.Context) {
roleIds := c.Param("roleIds")
if roleIds == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 处理字符转id数组后去重
@@ -166,7 +172,8 @@ func (s *SysRoleController) Remove(c *gin.Context) {
// 检查是否管理员角色
for _, id := range uniqueIDs {
if id == admin.ROLE_ID {
c.JSON(200, result.ErrMsg("不允许操作管理员角色"))
// 不允许操作管理员角色
c.JSON(200, result.ErrMsg("The administrator role is not allowed to operate"))
return
}
}
@@ -175,7 +182,7 @@ func (s *SysRoleController) Remove(c *gin.Context) {
c.JSON(200, result.ErrMsg(err.Error()))
return
}
msg := fmt.Sprintf("删除成功:%d", rows)
msg := fmt.Sprintf("Deleted successfully: %d", rows)
c.JSON(200, result.OkMsg(msg))
}
@@ -191,26 +198,29 @@ func (s *SysRoleController) Status(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
}
// 检查是否管理员角色
if body.RoleID == admin.ROLE_ID {
c.JSON(200, result.ErrMsg("不允许操作管理员角色"))
// 不允许操作管理员角色
c.JSON(200, result.ErrMsg("The administrator role is not allowed to operate"))
return
}
// 检查是否存在
role := s.sysRoleService.SelectRoleById(body.RoleID)
if role.RoleID != body.RoleID {
c.JSON(200, result.ErrMsg("没有权限访问角色数据!"))
// 没有可访问角色数据!
c.JSON(200, result.ErrMsg("There is no accessible role data!"))
return
}
// 与旧值相等不变更
if role.Status == body.Status {
c.JSON(200, result.ErrMsg("变更状态与旧值相等!"))
// 变更状态与旧值相等!
c.JSON(200, result.ErrMsg("The change status is equal to the old value!"))
return
}
@@ -245,20 +255,22 @@ func (s *SysRoleController) DataScope(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
}
// 检查是否管理员角色
if body.RoleID == admin.ROLE_ID {
c.JSON(200, result.ErrMsg("不允许操作管理员角色"))
// 不允许操作管理员角色
c.JSON(200, result.ErrMsg("The administrator role is not allowed to operate"))
return
}
// 检查是否存在
role := s.sysRoleService.SelectRoleById(body.RoleID)
if role.RoleID != body.RoleID {
c.JSON(200, result.ErrMsg("没有权限访问角色数据!"))
// 没有可访问角色数据!
c.JSON(200, result.ErrMsg("There is no accessible role data!"))
return
}
@@ -286,14 +298,15 @@ func (s *SysRoleController) AuthUserAllocatedList(c *gin.Context) {
querys := ctx.QueryMap(c)
roleId, ok := querys["roleId"]
if !ok || roleId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查是否存在
role := s.sysRoleService.SelectRoleById(roleId.(string))
if role.RoleID != roleId {
c.JSON(200, result.ErrMsg("没有权限访问角色数据!"))
// 没有可访问角色数据!
c.JSON(200, result.ErrMsg("There is no accessible role data!"))
return
}
@@ -316,7 +329,7 @@ func (s *SysRoleController) AuthUserChecked(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
}
@@ -331,7 +344,7 @@ func (s *SysRoleController) AuthUserChecked(c *gin.Context) {
// 检查是否存在
role := s.sysRoleService.SelectRoleById(body.RoleID)
if role.RoleID != body.RoleID {
c.JSON(200, result.ErrMsg("没有权限访问角色数据!"))
c.JSON(200, result.ErrMsg("There is no accessible role data!"))
return
}
@@ -357,7 +370,8 @@ func (s *SysRoleController) Export(c *gin.Context) {
dataScopeSQL := ctx.LoginUserToDataScopeSQL(c, "d", "")
data := s.sysRoleService.SelectRolePage(querys, dataScopeSQL)
if data["total"].(int64) == 0 {
c.JSON(200, result.ErrMsg("导出数据记录为空"))
// 导出数据记录为空
c.JSON(200, result.ErrMsg("Export data record is empty"))
return
}
rows := data["rows"].([]model.SysRole)
@@ -366,26 +380,26 @@ func (s *SysRoleController) Export(c *gin.Context) {
fileName := fmt.Sprintf("role_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
// 第一行表头标题
headerCells := map[string]string{
"A1": "角色序号",
"B1": "角色名称",
"C1": "角色权限",
"D1": "角色排序",
"E1": "数据范围",
"F1": "角色状态",
"A1": "RoleID",
"B1": "RoleName",
"C1": "RoleKey",
"D1": "RoleSort",
"E1": "DataScope",
"F1": "Status",
}
// 从第二行开始的数据
dataCells := make([]map[string]any, 0)
for i, row := range rows {
idx := strconv.Itoa(i + 2)
// 数据范围
dataScope := ""
dataScope := "Empty"
if v, ok := roledatascope.RoleDataScope[row.DataScope]; ok {
dataScope = v
}
// 角色状态
statusValue := "停用"
statusValue := "deactivate"
if row.Status == "1" {
statusValue = "正常"
statusValue = "normalcy"
}
dataCells = append(dataCells, map[string]any{
"A" + idx: row.RoleID,

View File

@@ -59,7 +59,7 @@ func (s *SysUserController) List(c *gin.Context) {
func (s *SysUserController) Info(c *gin.Context) {
userId := c.Param("userId")
if userId == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 查询系统角色列表
@@ -95,7 +95,7 @@ func (s *SysUserController) Info(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
}
@@ -128,7 +128,7 @@ func (s *SysUserController) Add(c *gin.Context) {
var body model.SysUser
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.UserID != "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
@@ -137,7 +137,7 @@ func (s *SysUserController) Add(c *gin.Context) {
Password string `json:"password" binding:"required"`
}
if err := c.ShouldBindBodyWith(&bodyPassword, binding.JSON); err != nil {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
body.Password = bodyPassword.Password
@@ -145,7 +145,8 @@ func (s *SysUserController) Add(c *gin.Context) {
// 检查用户登录账号是否唯一
uniqueUserName := s.sysUserService.CheckUniqueUserName(body.UserName, "")
if !uniqueUserName {
msg := fmt.Sprintf("新增用户【%s】失败登录账号已存在", body.UserName)
// 新增用户【%s】失败登录账号已存在
msg := fmt.Sprintf("Failed to add user [%s], login account already exists", body.UserName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -155,12 +156,14 @@ func (s *SysUserController) Add(c *gin.Context) {
if regular.ValidMobile(body.PhoneNumber) {
uniquePhone := s.sysUserService.CheckUniquePhone(body.PhoneNumber, "")
if !uniquePhone {
msg := fmt.Sprintf("新增用户【%s】失败手机号码已存在", body.UserName)
// 新增用户【%s】失败手机号码已存在
msg := fmt.Sprintf("Failed to add user [%s], cell phone number already exists", body.UserName)
c.JSON(200, result.ErrMsg(msg))
return
}
} else {
msg := fmt.Sprintf("新增用户【%s】失败手机号码格式错误", body.UserName)
// 新增用户【%s】失败手机号码格式错误
msg := fmt.Sprintf("Failed to add user [%s], wrong format of cell phone number", body.UserName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -171,12 +174,14 @@ func (s *SysUserController) Add(c *gin.Context) {
if regular.ValidEmail(body.Email) {
uniqueEmail := s.sysUserService.CheckUniqueEmail(body.Email, "")
if !uniqueEmail {
msg := fmt.Sprintf("新增用户【%s】失败邮箱已存在", body.UserName)
// 新增用户【%s】失败邮箱已存在
msg := fmt.Sprintf("Failed to add user [%s], mailbox already exists", body.UserName)
c.JSON(200, result.ErrMsg(msg))
return
}
} else {
msg := fmt.Sprintf("新增用户【%s】失败邮箱格式错误", body.UserName)
// 新增用户【%s】失败邮箱格式错误
msg := fmt.Sprintf("Failed to add user [%s], mailbox format error", body.UserName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -198,26 +203,29 @@ func (s *SysUserController) Edit(c *gin.Context) {
var body model.SysUser
err := c.ShouldBindBodyWith(&body, binding.JSON)
if err != nil || body.UserID == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查是否管理员用户
if config.IsAdmin(body.UserID) {
c.JSON(200, result.ErrMsg("不允许操作管理员用户"))
// 不允许操作管理员用户
c.JSON(200, result.ErrMsg("Administrator users are not allowed to operate"))
return
}
user := s.sysUserService.SelectUserById(body.UserID)
if user.UserID != body.UserID {
c.JSON(200, result.ErrMsg("没有权限访问用户数据!"))
// 没有可访问用户数据!
c.JSON(200, result.ErrMsg("There is no accessible user data!"))
return
}
// 检查用户登录账号是否唯一
uniqueUserName := s.sysUserService.CheckUniqueUserName(body.UserName, body.UserID)
if !uniqueUserName {
msg := fmt.Sprintf("修改用户【%s】失败登录账号已存在", body.UserName)
// 修改用户【%s】失败登录账号已存在
msg := fmt.Sprintf("Failed to modify user [%s], login account already exists", body.UserName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -227,12 +235,14 @@ func (s *SysUserController) Edit(c *gin.Context) {
if regular.ValidMobile(body.PhoneNumber) {
uniquePhone := s.sysUserService.CheckUniquePhone(body.PhoneNumber, body.UserID)
if !uniquePhone {
msg := fmt.Sprintf("修改用户【%s】失败手机号码已存在", body.UserName)
// 修改用户【%s】失败手机号码已存在
msg := fmt.Sprintf("Failed to modify user [%s], cell phone number already exists", body.UserName)
c.JSON(200, result.ErrMsg(msg))
return
}
} else {
msg := fmt.Sprintf("修改用户【%s】失败手机号码格式错误", body.UserName)
// 修改用户【%s】失败手机号码格式错误
msg := fmt.Sprintf("Failed to modify user [%s], wrong format of cell phone number", body.UserName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -243,12 +253,14 @@ func (s *SysUserController) Edit(c *gin.Context) {
if regular.ValidEmail(body.Email) {
uniqueEmail := s.sysUserService.CheckUniqueEmail(body.Email, body.UserID)
if !uniqueEmail {
msg := fmt.Sprintf("修改用户【%s】失败邮箱已存在", body.UserName)
// 修改用户【%s】失败邮箱已存在
msg := fmt.Sprintf("Failed to modify user [%s], mailbox already exists", body.UserName)
c.JSON(200, result.ErrMsg(msg))
return
}
} else {
msg := fmt.Sprintf("修改用户【%s】失败邮箱格式错误", body.UserName)
// 修改用户【%s】失败邮箱格式错误
msg := fmt.Sprintf("Failed to modify user [%s], mailbox format error", body.UserName)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -273,7 +285,7 @@ func (s *SysUserController) Edit(c *gin.Context) {
func (s *SysUserController) Remove(c *gin.Context) {
userIds := c.Param("userIds")
if userIds == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 处理字符转id数组后去重
@@ -288,7 +300,8 @@ func (s *SysUserController) Remove(c *gin.Context) {
c.JSON(200, result.ErrMsg(err.Error()))
return
}
msg := fmt.Sprintf("删除成功:%d", rows)
// 删除成功:%d
msg := fmt.Sprintf("Deleted successfully: %d", rows)
c.JSON(200, result.OkMsg(msg))
}
@@ -301,23 +314,26 @@ func (s *SysUserController) ResetPwd(c *gin.Context) {
Password string `json:"password" binding:"required"`
}
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查是否管理员用户
if config.IsAdmin(body.UserID) {
c.JSON(200, result.ErrMsg("不允许操作管理员用户"))
// 不允许操作管理员用户
c.JSON(200, result.ErrMsg("Administrator users are not allowed to operate"))
return
}
user := s.sysUserService.SelectUserById(body.UserID)
if user.UserID != body.UserID {
c.JSON(200, result.ErrMsg("没有权限访问用户数据!"))
// 没有可访问用户数据!
c.JSON(200, result.ErrMsg("There is no accessible user data!"))
return
}
if !regular.ValidPassword(body.Password) {
c.JSON(200, result.ErrMsg("登录密码至少包含大小写字母、数字、特殊符号且不少于6位"))
// 登录密码至少包含大小写字母、数字、特殊符号且不少于6位
c.JSON(200, result.ErrMsg("Login password contains at least upper and lower case letters, numbers, special symbols, and not less than 6 digits"))
return
}
@@ -344,20 +360,22 @@ func (s *SysUserController) Status(c *gin.Context) {
Status string `json:"status" binding:"required"`
}
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}
// 检查是否存在
user := s.sysUserService.SelectUserById(body.UserID)
if user.UserID != body.UserID {
c.JSON(200, result.ErrMsg("没有权限访问用户数据!"))
// 没有可访问用户数据!
c.JSON(200, result.ErrMsg("There is no accessible user data!"))
return
}
// 与旧值相等不变更
if user.Status == body.Status {
c.JSON(200, result.ErrMsg("变更状态与旧值相等!"))
// 变更状态与旧值相等!
c.JSON(200, result.ErrMsg("The change status is equal to the old value!"))
return
}
@@ -384,7 +402,8 @@ func (s *SysUserController) Export(c *gin.Context) {
dataScopeSQL := ctx.LoginUserToDataScopeSQL(c, "d", "u")
data := s.sysUserService.SelectUserPage(querys, dataScopeSQL)
if data["total"].(int64) == 0 {
c.JSON(200, result.ErrMsg("导出数据记录为空"))
// 导出数据记录为空
c.JSON(200, result.ErrMsg("Export data record is empty"))
return
}
rows := data["rows"].([]model.SysUser)
@@ -393,18 +412,18 @@ func (s *SysUserController) Export(c *gin.Context) {
fileName := fmt.Sprintf("user_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
// 第一行表头标题
headerCells := map[string]string{
"A1": "用户编号",
"B1": "登录名称",
"C1": "用户名称",
"D1": "用户邮箱",
"E1": "手机号码",
"F1": "用户性别",
"G1": "帐号状态",
"H1": "部门编号",
"I1": "部门名称",
"J1": "部门负责人",
"K1": "最后登录IP",
"L1": "最后登录时间",
"A1": "UserID",
"B1": "UserName",
"C1": "NickName",
"D1": "Email",
"E1": "PhoneNumber",
"F1": "UserSex",
"G1": "Status",
"H1": "DeptID",
"I1": "DeptName",
"J1": "DeptLeader",
"K1": "LoginIP",
"L1": "LoginDate",
}
// 读取用户性别字典数据
dictSysUserSex := s.sysDictDataService.SelectDictDataByType("sys_user_sex")
@@ -413,7 +432,7 @@ func (s *SysUserController) Export(c *gin.Context) {
for i, row := range rows {
idx := strconv.Itoa(i + 2)
// 用户性别
sysUserSex := "未知"
sysUserSex := "unknown"
for _, v := range dictSysUserSex {
if row.Sex == v.DictValue {
sysUserSex = v.DictLabel
@@ -421,9 +440,9 @@ func (s *SysUserController) Export(c *gin.Context) {
}
}
// 帐号状态
statusValue := "停用"
statusValue := "deactivate"
if row.Status == "1" {
statusValue = "正常"
statusValue = "normalcy"
}
dataCells = append(dataCells, map[string]any{
"A" + idx: row.UserID,
@@ -485,7 +504,7 @@ func (s *SysUserController) ImportData(c *gin.Context) {
// 上传的文件
formFile, err := c.FormFile("file")
if err != nil || updateSupport == "" {
c.JSON(400, result.CodeMsg(400, "参数错误"))
c.JSON(400, result.CodeMsg(400, "parameter error"))
return
}

View File

@@ -1,7 +1,7 @@
package service
import (
"errors"
"fmt"
"ems.agt/src/framework/constants/cachekey"
"ems.agt/src/framework/redis"
@@ -93,12 +93,13 @@ func (r *SysConfigImpl) DeleteConfigByIds(configIds []string) (int64, error) {
// 检查是否存在
configs := r.sysConfigRepository.SelectConfigByIds(configIds)
if len(configs) <= 0 {
return 0, errors.New("没有权限访问参数配置数据!")
return 0, fmt.Errorf("there is no accessible parameter configuration data")
}
for _, config := range configs {
// 检查是否为内置参数
if config.ConfigType == "Y" {
return 0, errors.New(config.ConfigID + " 配置参数属于内置参数,禁止删除!")
// 【%s】 配置参数属于内置参数,禁止删除!
return 0, fmt.Errorf("[%s] Configuration parameters are built-in parameters and their deletion is prohibited", config.ConfigID)
}
// 清除缓存
r.clearConfigCache(config.ConfigKey)
@@ -107,7 +108,8 @@ func (r *SysConfigImpl) DeleteConfigByIds(configIds []string) (int64, error) {
rows := r.sysConfigRepository.DeleteConfigByIds(configIds)
return rows, nil
}
return 0, errors.New("删除参数配置信息失败!")
// 删除参数配置信息失败!
return 0, fmt.Errorf("failed to delete parameter configuration information")
}
// ResetConfigCache 重置参数缓存数据

View File

@@ -1,7 +1,7 @@
package service
import (
"errors"
"fmt"
"ems.agt/src/modules/system/model"
"ems.agt/src/modules/system/repository"
@@ -77,7 +77,8 @@ func (r *SysDictDataImpl) DeleteDictDataByCodes(dictCodes []string) (int64, erro
// 检查是否存在
dictDatas := r.sysDictDataRepository.SelectDictDataByCodes(dictCodes)
if len(dictDatas) <= 0 {
return 0, errors.New("没有权限访问字典编码数据!")
// 没有可访问字典编码数据!
return 0, fmt.Errorf("there is no accessible dictionary-encoded data")
}
if len(dictDatas) == len(dictCodes) {
for _, v := range dictDatas {
@@ -88,7 +89,8 @@ func (r *SysDictDataImpl) DeleteDictDataByCodes(dictCodes []string) (int64, erro
rows := r.sysDictDataRepository.DeleteDictDataByCodes(dictCodes)
return rows, nil
}
return 0, errors.New("删除字典数据信息失败!")
// 删除字典数据信息失败!
return 0, fmt.Errorf("failed to delete dictionary data information")
}
// InsertDictData 新增字典数据信息

View File

@@ -2,7 +2,6 @@ package service
import (
"encoding/json"
"errors"
"fmt"
"ems.agt/src/framework/constants/cachekey"
@@ -107,14 +106,15 @@ func (r *SysDictTypeImpl) DeleteDictTypeByIDs(dictIDs []string) (int64, error) {
// 检查是否存在
dictTypes := r.sysDictTypeRepository.SelectDictTypeByIDs(dictIDs)
if len(dictTypes) <= 0 {
return 0, errors.New("没有权限访问字典类型数据!")
// 没有可访问字典类型数据!
return 0, fmt.Errorf("there is no accessible dictionary type data")
}
for _, v := range dictTypes {
// 字典类型下级含有数据
useCount := r.sysDictDataRepository.CountDictDataByType(v.DictType)
if useCount > 0 {
msg := fmt.Sprintf("【%s】存在字典数据,不能删除", v.DictName)
return 0, errors.New(msg)
// 【%s】存在字典数据,不能删除
return 0, fmt.Errorf("[%s] dictionary data exists and cannot be deleted", v.DictName)
}
// 清除缓存
r.ClearDictCache(v.DictType)
@@ -123,7 +123,8 @@ func (r *SysDictTypeImpl) DeleteDictTypeByIDs(dictIDs []string) (int64, error) {
rows := r.sysDictTypeRepository.DeleteDictTypeByIDs(dictIDs)
return rows, nil
}
return 0, errors.New("删除字典数据信息失败!")
// 删除字典数据信息失败!
return 0, fmt.Errorf("failed to delete dictionary data information")
}
// ResetDictCache 重置字典缓存数据

View File

@@ -1,7 +1,7 @@
package service
import (
"errors"
"fmt"
"ems.agt/src/modules/system/model"
"ems.agt/src/modules/system/repository"
@@ -55,17 +55,19 @@ func (r *SysNoticeImpl) DeleteNoticeByIds(noticeIds []string) (int64, error) {
// 检查是否存在
notices := r.sysNoticeRepository.SelectNoticeByIds(noticeIds)
if len(notices) <= 0 {
return 0, errors.New("没有权限访问公告信息数据!")
return 0, fmt.Errorf("there is no accessible bulletin information data")
}
for _, notice := range notices {
// 检查是否为已删除
if notice.DelFlag == "1" {
return 0, errors.New(notice.NoticeID + " 公告信息已经删除!")
// 【%s】公告信息已经删除!
return 0, fmt.Errorf("the [%s] announcement message has been deleted", notice.NoticeID)
}
}
if len(notices) == len(noticeIds) {
rows := r.sysNoticeRepository.DeleteNoticeByIds(noticeIds)
return rows, nil
}
return 0, errors.New("删除公告信息失败!")
// 删除公告信息失败!
return 0, fmt.Errorf("failed to delete the announcement message")
}

View File

@@ -1,7 +1,6 @@
package service
import (
"errors"
"fmt"
"ems.agt/src/modules/system/model"
@@ -54,20 +53,22 @@ func (r *SysPostImpl) DeletePostByIds(postIds []string) (int64, error) {
// 检查是否存在
posts := r.sysPostRepository.SelectPostByIds(postIds)
if len(posts) <= 0 {
return 0, errors.New("没有权限访问岗位数据!")
// 没有可访问岗位数据!
return 0, fmt.Errorf("there is no accessible post data")
}
for _, post := range posts {
useCount := r.sysUserPostRepository.CountUserPostByPostId(post.PostID)
if useCount > 0 {
msg := fmt.Sprintf("【%s】已分配给用户,不能删除", post.PostName)
return 0, errors.New(msg)
// 【%s】已分配给用户,不能删除
return 0, fmt.Errorf("[%s] has been assigned to a user and cannot be deleted", post.PostName)
}
}
if len(posts) == len(postIds) {
rows := r.sysPostRepository.DeletePostByIds(postIds)
return rows, nil
}
return 0, errors.New("删除岗位信息失败!")
// 删除岗位信息失败!
return 0, fmt.Errorf("failed to delete post information")
}
// UpdatePost 修改岗位信息

View File

@@ -1,7 +1,6 @@
package service
import (
"errors"
"fmt"
"ems.agt/src/modules/system/model"
@@ -99,18 +98,20 @@ func (r *SysRoleImpl) DeleteRoleByIds(roleIds []string) (int64, error) {
// 检查是否存在
roles := r.sysRoleRepository.SelectRoleByIds(roleIds)
if len(roles) <= 0 {
return 0, errors.New("没有权限访问角色数据!")
// 没有可访问角色数据!
return 0, fmt.Errorf("there is no accessible role data")
}
for _, role := range roles {
// 检查是否为已删除
if role.DelFlag == "1" {
return 0, errors.New(role.RoleID + " 角色信息已经删除!")
// 【%s】角色信息已经删除!
return 0, fmt.Errorf("[%s] Role information has been deleted", role.RoleID)
}
// 检查分配用户
userCount := r.sysUserRoleRepository.CountUserRoleByRoleId(role.RoleID)
if userCount > 0 {
msg := fmt.Sprintf("【%s】已分配给用户,不能删除", role.RoleName)
return 0, errors.New(msg)
// 【%s】已分配给用户,不能删除
return 0, fmt.Errorf("[%s] has been assigned to a user and cannot be deleted", role.RoleName)
}
}
if len(roles) == len(roleIds) {
@@ -121,7 +122,8 @@ func (r *SysRoleImpl) DeleteRoleByIds(roleIds []string) (int64, error) {
rows := r.sysRoleRepository.DeleteRoleByIds(roleIds)
return rows, nil
}
return 0, errors.New("删除角色信息失败!")
// 删除角色信息失败!
return 0, fmt.Errorf("failed to delete role information")
}
// CheckUniqueRoleName 校验角色名称是否唯一

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/>")
}

View File

@@ -31,34 +31,34 @@ func Setup(router *gin.Engine) {
)
sysConfigGroup.POST("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:config:add"}}),
collectlogs.OperateLog(collectlogs.OptionNew("参数配置信息", collectlogs.BUSINESS_TYPE_INSERT)),
collectlogs.OperateLog(collectlogs.OptionNew("Parameter Configuration", collectlogs.BUSINESS_TYPE_INSERT)),
controller.NewSysConfig.Add,
)
sysConfigGroup.PUT("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:config:edit"}}),
collectlogs.OperateLog(collectlogs.OptionNew("参数配置信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("Parameter Configuration", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysConfig.Edit,
)
sysConfigGroup.DELETE("/:configIds",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:config:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("参数配置信息", collectlogs.BUSINESS_TYPE_DELETE)),
collectlogs.OperateLog(collectlogs.OptionNew("Parameter Configuration", collectlogs.BUSINESS_TYPE_DELETE)),
controller.NewSysConfig.Remove,
)
sysConfigGroup.PUT("/refreshCache",
repeat.RepeatSubmit(5),
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:config:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("参数配置信息", collectlogs.BUSINESS_TYPE_CLEAN)),
collectlogs.OperateLog(collectlogs.OptionNew("Parameter Configuration", collectlogs.BUSINESS_TYPE_CLEAN)),
controller.NewSysConfig.RefreshCache,
)
sysConfigGroup.GET("/configKey/:configKey", controller.NewSysConfig.ConfigKey)
sysConfigGroup.POST("/export",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:config:export"}}),
collectlogs.OperateLog(collectlogs.OptionNew("参数配置信息", collectlogs.BUSINESS_TYPE_EXPORT)),
collectlogs.OperateLog(collectlogs.OptionNew("Parameter Configuration", collectlogs.BUSINESS_TYPE_EXPORT)),
controller.NewSysConfig.Export,
)
sysConfigGroup.PUT("/changeValue",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:config:edit"}}),
collectlogs.OperateLog(collectlogs.OptionNew("参数配置信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("Parameter Configuration", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysConfig.ConfigValue,
)
}
@@ -76,17 +76,17 @@ func Setup(router *gin.Engine) {
)
sysDeptGroup.POST("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dept:add"}}),
collectlogs.OperateLog(collectlogs.OptionNew("部门信息", collectlogs.BUSINESS_TYPE_INSERT)),
collectlogs.OperateLog(collectlogs.OptionNew("Sectoral", collectlogs.BUSINESS_TYPE_INSERT)),
controller.NewSysDept.Add,
)
sysDeptGroup.PUT("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dept:edit"}}),
collectlogs.OperateLog(collectlogs.OptionNew("部门信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("Sectoral", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysDept.Edit,
)
sysDeptGroup.DELETE("/:deptId",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dept:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("部门信息", collectlogs.BUSINESS_TYPE_DELETE)),
collectlogs.OperateLog(collectlogs.OptionNew("Sectoral", collectlogs.BUSINESS_TYPE_DELETE)),
controller.NewSysDept.Remove,
)
sysDeptGroup.GET("/list/exclude/:deptId",
@@ -116,17 +116,17 @@ func Setup(router *gin.Engine) {
)
sysDictDataGroup.POST("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict:add"}}),
collectlogs.OperateLog(collectlogs.OptionNew("字典数据信息", collectlogs.BUSINESS_TYPE_INSERT)),
collectlogs.OperateLog(collectlogs.OptionNew("Dictionary Data", collectlogs.BUSINESS_TYPE_INSERT)),
controller.NewSysDictData.Add,
)
sysDictDataGroup.PUT("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict:edit"}}),
collectlogs.OperateLog(collectlogs.OptionNew("字典数据信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("Dictionary Data", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysDictData.Edit,
)
sysDictDataGroup.DELETE("/:dictCodes",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("字典数据信息", collectlogs.BUSINESS_TYPE_DELETE)),
collectlogs.OperateLog(collectlogs.OptionNew("Dictionary Data", collectlogs.BUSINESS_TYPE_DELETE)),
controller.NewSysDictData.Remove,
)
sysDictDataGroup.GET("/type/:dictType",
@@ -135,7 +135,7 @@ func Setup(router *gin.Engine) {
)
sysDictDataGroup.POST("/export",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict:export"}}),
collectlogs.OperateLog(collectlogs.OptionNew("字典类型信息", collectlogs.BUSINESS_TYPE_EXPORT)),
collectlogs.OperateLog(collectlogs.OptionNew("Dictionary Type", collectlogs.BUSINESS_TYPE_EXPORT)),
controller.NewSysDictData.Export,
)
}
@@ -153,22 +153,22 @@ func Setup(router *gin.Engine) {
)
sysDictTypeGroup.POST("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict:add"}}),
collectlogs.OperateLog(collectlogs.OptionNew("字典类型信息", collectlogs.BUSINESS_TYPE_INSERT)),
collectlogs.OperateLog(collectlogs.OptionNew("Dictionary Type", collectlogs.BUSINESS_TYPE_INSERT)),
controller.NewSysDictType.Add,
)
sysDictTypeGroup.PUT("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict:edit"}}),
collectlogs.OperateLog(collectlogs.OptionNew("字典类型信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("Dictionary Type", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysDictType.Edit,
)
sysDictTypeGroup.DELETE("/:dictIds",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("字典类型信息", collectlogs.BUSINESS_TYPE_DELETE)),
collectlogs.OperateLog(collectlogs.OptionNew("Dictionary Type", collectlogs.BUSINESS_TYPE_DELETE)),
controller.NewSysDictType.Remove,
)
sysDictTypeGroup.PUT("/refreshCache",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("字典类型信息", collectlogs.BUSINESS_TYPE_CLEAN)),
collectlogs.OperateLog(collectlogs.OptionNew("Dictionary Type", collectlogs.BUSINESS_TYPE_CLEAN)),
controller.NewSysDictType.RefreshCache,
)
sysDictTypeGroup.GET("/getDictOptionselect",
@@ -177,7 +177,7 @@ func Setup(router *gin.Engine) {
)
sysDictTypeGroup.POST("/export",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict:export"}}),
collectlogs.OperateLog(collectlogs.OptionNew("字典类型信息", collectlogs.BUSINESS_TYPE_EXPORT)),
collectlogs.OperateLog(collectlogs.OptionNew("Dictionary Type", collectlogs.BUSINESS_TYPE_EXPORT)),
controller.NewSysDictType.Export,
)
}
@@ -195,17 +195,17 @@ func Setup(router *gin.Engine) {
)
sysMenuGroup.POST("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:menu:add"}}),
collectlogs.OperateLog(collectlogs.OptionNew("菜单信息", collectlogs.BUSINESS_TYPE_INSERT)),
collectlogs.OperateLog(collectlogs.OptionNew("Menu", collectlogs.BUSINESS_TYPE_INSERT)),
controller.NewSysMenu.Add,
)
sysMenuGroup.PUT("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:menu:edit"}}),
collectlogs.OperateLog(collectlogs.OptionNew("菜单信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("Menu", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysMenu.Edit,
)
sysMenuGroup.DELETE("/:menuId",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:menu:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("菜单信息", collectlogs.BUSINESS_TYPE_DELETE)),
collectlogs.OperateLog(collectlogs.OptionNew("Menu", collectlogs.BUSINESS_TYPE_DELETE)),
controller.NewSysMenu.Remove,
)
sysMenuGroup.GET("/treeSelect",
@@ -231,17 +231,17 @@ func Setup(router *gin.Engine) {
)
sysNoticeGroup.POST("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:notice:add"}}),
collectlogs.OperateLog(collectlogs.OptionNew("参数配置信息", collectlogs.BUSINESS_TYPE_INSERT)),
collectlogs.OperateLog(collectlogs.OptionNew("Notice", collectlogs.BUSINESS_TYPE_INSERT)),
controller.NewSysNotice.Add,
)
sysNoticeGroup.PUT("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:notice:edit"}}),
collectlogs.OperateLog(collectlogs.OptionNew("参数配置信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("Notice", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysNotice.Edit,
)
sysNoticeGroup.DELETE("/:noticeIds",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:notice:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("参数配置信息", collectlogs.BUSINESS_TYPE_DELETE)),
collectlogs.OperateLog(collectlogs.OptionNew("Notice", collectlogs.BUSINESS_TYPE_DELETE)),
controller.NewSysNotice.Remove,
)
}
@@ -259,17 +259,17 @@ func Setup(router *gin.Engine) {
)
sysPostGroup.POST("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:post:add"}}),
collectlogs.OperateLog(collectlogs.OptionNew("岗位信息", collectlogs.BUSINESS_TYPE_INSERT)),
collectlogs.OperateLog(collectlogs.OptionNew("Post", collectlogs.BUSINESS_TYPE_INSERT)),
controller.NewSysPost.Add,
)
sysPostGroup.PUT("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:post:edit"}}),
collectlogs.OperateLog(collectlogs.OptionNew("岗位信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("Post", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysPost.Edit,
)
sysPostGroup.DELETE("/:postIds",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:post:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("岗位信息", collectlogs.BUSINESS_TYPE_DELETE)),
collectlogs.OperateLog(collectlogs.OptionNew("Post", collectlogs.BUSINESS_TYPE_DELETE)),
controller.NewSysPost.Remove,
)
sysPostGroup.POST("/export",
@@ -291,12 +291,12 @@ func Setup(router *gin.Engine) {
)
sysProfileGroup.PUT("/updatePwd",
middleware.PreAuthorize(nil),
collectlogs.OperateLog(collectlogs.OptionNew("个人信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("Personal", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysProfile.UpdatePwd,
)
sysProfileGroup.POST("/avatar",
middleware.PreAuthorize(nil),
collectlogs.OperateLog(collectlogs.OptionNew("用户头像", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("Personal Avatar", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysProfile.Avatar,
)
}
@@ -314,29 +314,29 @@ func Setup(router *gin.Engine) {
)
sysRoleGroup.POST("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:role:add"}}),
collectlogs.OperateLog(collectlogs.OptionNew("角色信息", collectlogs.BUSINESS_TYPE_INSERT)),
collectlogs.OperateLog(collectlogs.OptionNew("Role", collectlogs.BUSINESS_TYPE_INSERT)),
controller.NewSysRole.Add,
)
sysRoleGroup.PUT("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:role:edit"}}),
collectlogs.OperateLog(collectlogs.OptionNew("角色信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("Role", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysRole.Edit,
)
sysRoleGroup.DELETE("/:roleIds",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:role:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("角色信息", collectlogs.BUSINESS_TYPE_DELETE)),
collectlogs.OperateLog(collectlogs.OptionNew("Role", collectlogs.BUSINESS_TYPE_DELETE)),
controller.NewSysRole.Remove,
)
sysRoleGroup.PUT("/changeStatus",
repeat.RepeatSubmit(5),
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:role:edit"}}),
collectlogs.OperateLog(collectlogs.OptionNew("角色信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("Role", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysRole.Status,
)
sysRoleGroup.PUT("/dataScope",
repeat.RepeatSubmit(5),
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:edit"}}),
collectlogs.OperateLog(collectlogs.OptionNew("角色信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("Role", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysRole.DataScope,
)
sysRoleGroup.GET("/authUser/allocatedList",
@@ -345,12 +345,12 @@ func Setup(router *gin.Engine) {
)
sysRoleGroup.PUT("/authUser/checked",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:edit"}}),
collectlogs.OperateLog(collectlogs.OptionNew("角色信息", collectlogs.BUSINESS_TYPE_GRANT)),
collectlogs.OperateLog(collectlogs.OptionNew("Role", collectlogs.BUSINESS_TYPE_GRANT)),
controller.NewSysRole.AuthUserChecked,
)
sysRoleGroup.POST("/export",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:export"}}),
collectlogs.OperateLog(collectlogs.OptionNew("角色信息", collectlogs.BUSINESS_TYPE_EXPORT)),
collectlogs.OperateLog(collectlogs.OptionNew("Role", collectlogs.BUSINESS_TYPE_EXPORT)),
controller.NewSysRole.Export,
)
}
@@ -368,33 +368,33 @@ func Setup(router *gin.Engine) {
)
sysUserGroup.POST("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:add"}}),
collectlogs.OperateLog(collectlogs.OptionNew("用户信息", collectlogs.BUSINESS_TYPE_INSERT)),
collectlogs.OperateLog(collectlogs.OptionNew("User", collectlogs.BUSINESS_TYPE_INSERT)),
controller.NewSysUser.Add,
)
sysUserGroup.PUT("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:edit"}}),
collectlogs.OperateLog(collectlogs.OptionNew("用户信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("User", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysUser.Edit,
)
sysUserGroup.DELETE("/:userIds",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("用户信息", collectlogs.BUSINESS_TYPE_DELETE)),
collectlogs.OperateLog(collectlogs.OptionNew("User", collectlogs.BUSINESS_TYPE_DELETE)),
controller.NewSysUser.Remove,
)
sysUserGroup.PUT("/resetPwd",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:resetPwd"}}),
collectlogs.OperateLog(collectlogs.OptionNew("用户信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("User", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysUser.ResetPwd,
)
sysUserGroup.PUT("/changeStatus",
repeat.RepeatSubmit(5),
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:edit"}}),
collectlogs.OperateLog(collectlogs.OptionNew("用户信息", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("User", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysUser.Status,
)
sysUserGroup.POST("/export",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:export"}}),
collectlogs.OperateLog(collectlogs.OptionNew("用户信息", collectlogs.BUSINESS_TYPE_EXPORT)),
collectlogs.OperateLog(collectlogs.OptionNew("User", collectlogs.BUSINESS_TYPE_EXPORT)),
controller.NewSysUser.Export,
)
sysUserGroup.GET("/importTemplate",
@@ -403,7 +403,7 @@ func Setup(router *gin.Engine) {
)
sysUserGroup.POST("/importData",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:import"}}),
collectlogs.OperateLog(collectlogs.OptionNew("用户信息", collectlogs.BUSINESS_TYPE_INSERT)),
collectlogs.OperateLog(collectlogs.OptionNew("User", collectlogs.BUSINESS_TYPE_INSERT)),
controller.NewSysUser.ImportData,
)
}
@@ -417,17 +417,17 @@ func Setup(router *gin.Engine) {
)
sysOperLogGroup.DELETE("/:operIds",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:log:operate:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("操作日志", collectlogs.BUSINESS_TYPE_DELETE)),
collectlogs.OperateLog(collectlogs.OptionNew("Operation", collectlogs.BUSINESS_TYPE_DELETE)),
controller.NewSysLogOperate.Remove,
)
sysOperLogGroup.DELETE("/clean",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:log:operate:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("操作日志", collectlogs.BUSINESS_TYPE_CLEAN)),
collectlogs.OperateLog(collectlogs.OptionNew("Operation", collectlogs.BUSINESS_TYPE_CLEAN)),
controller.NewSysLogOperate.Clean,
)
sysOperLogGroup.POST("/export",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:log:operate:export"}}),
collectlogs.OperateLog(collectlogs.OptionNew("操作日志", collectlogs.BUSINESS_TYPE_EXPORT)),
collectlogs.OperateLog(collectlogs.OptionNew("Operation", collectlogs.BUSINESS_TYPE_EXPORT)),
controller.NewSysLogOperate.Export,
)
}
@@ -441,22 +441,22 @@ func Setup(router *gin.Engine) {
)
sysLogininforGroup.DELETE("/:loginIds",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:log:login:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("系统登录信息", collectlogs.BUSINESS_TYPE_DELETE)),
collectlogs.OperateLog(collectlogs.OptionNew("System Login", collectlogs.BUSINESS_TYPE_DELETE)),
controller.NewSysLogLogin.Remove,
)
sysLogininforGroup.DELETE("/clean",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:log:login:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("系统登录信息", collectlogs.BUSINESS_TYPE_CLEAN)),
collectlogs.OperateLog(collectlogs.OptionNew("System Login", collectlogs.BUSINESS_TYPE_CLEAN)),
controller.NewSysLogLogin.Clean,
)
sysLogininforGroup.PUT("/unlock/:userName",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:log:login:unlock"}}),
collectlogs.OperateLog(collectlogs.OptionNew("系统登录信息", collectlogs.BUSINESS_TYPE_CLEAN)),
collectlogs.OperateLog(collectlogs.OptionNew("System Login", collectlogs.BUSINESS_TYPE_CLEAN)),
controller.NewSysLogLogin.Unlock,
)
sysLogininforGroup.POST("/export",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:log:login:export"}}),
collectlogs.OperateLog(collectlogs.OptionNew("系统登录信息", collectlogs.BUSINESS_TYPE_EXPORT)),
collectlogs.OperateLog(collectlogs.OptionNew("System Login", collectlogs.BUSINESS_TYPE_EXPORT)),
controller.NewSysLogLogin.Export,
)
}

View File

@@ -43,14 +43,15 @@ func (s *TcpdumpController) NeTask(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
}
// 检查网元信息
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
if neInfo.NeId != body.NeId {
msg := fmt.Sprintf("找不到 %s %s 对应网元信息", body.NeType, body.NeId)
// 找不到 %s %s 对应网元信息
msg := fmt.Sprintf("Cannot find %s %s network element information.", body.NeType, body.NeId)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -85,14 +86,15 @@ func (s *TcpdumpController) Download(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
}
// 检查网元信息
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
if neInfo.NeId != body.NeId {
msg := fmt.Sprintf("找不到 %s %s 对应网元信息", body.NeType, body.NeId)
// 找不到 %s %s 对应网元信息
msg := fmt.Sprintf("Cannot find %s %s network element information.", body.NeType, body.NeId)
c.JSON(200, result.ErrMsg(msg))
return
}
@@ -121,7 +123,7 @@ func (s *TcpdumpController) NeUPFTask(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
}
@@ -258,5 +260,5 @@ func (s *TcpdumpController) NeUPFTask(c *gin.Context) {
return
}
c.JSON(200, result.ErrMsg("请选择RunType执行start_telnet/stop_telnet/start_str/stop_str"))
c.JSON(200, result.ErrMsg("Please select RunType to execute: start_telnet/stop_telnet/start_str/stop_str"))
}

View File

@@ -18,17 +18,17 @@ func Setup(router *gin.Engine) {
{
tcpdumpGroup.POST("/ne",
middleware.PreAuthorize(nil),
collectlogs.OperateLog(collectlogs.OptionNew("信令抓包", collectlogs.BUSINESS_TYPE_OTHER)),
collectlogs.OperateLog(collectlogs.OptionNew("Signaling Grab", collectlogs.BUSINESS_TYPE_OTHER)),
controller.NewTcpdump.NeTask,
)
tcpdumpGroup.POST("/neUPF",
middleware.PreAuthorize(nil),
collectlogs.OperateLog(collectlogs.OptionNew("信令抓包", collectlogs.BUSINESS_TYPE_OTHER)),
collectlogs.OperateLog(collectlogs.OptionNew("Signaling Grab", collectlogs.BUSINESS_TYPE_OTHER)),
controller.NewTcpdump.NeUPFTask,
)
tcpdumpGroup.POST("/download",
middleware.PreAuthorize(nil),
collectlogs.OperateLog(collectlogs.OptionNew("信令抓包", collectlogs.BUSINESS_TYPE_IMPORT)),
collectlogs.OperateLog(collectlogs.OptionNew("Signaling Grab", collectlogs.BUSINESS_TYPE_IMPORT)),
controller.NewTcpdump.Download,
)
}