marge: 合并代码
This commit is contained in:
@@ -77,7 +77,7 @@ type DatabaseClient struct {
|
|||||||
var DbClient DatabaseClient
|
var DbClient DatabaseClient
|
||||||
|
|
||||||
func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) error {
|
func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) error {
|
||||||
DbClient.dbUrl = fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=true&loc=Local",
|
DbClient.dbUrl = fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbUser, dbPassword, dbHost, dbPort, dbName)
|
dbUser, dbPassword, dbHost, dbPort, dbName)
|
||||||
DbClient.dbType = dbType
|
DbClient.dbType = dbType
|
||||||
DbClient.dbConnMaxLifetime = 0
|
DbClient.dbConnMaxLifetime = 0
|
||||||
@@ -86,7 +86,7 @@ func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) err
|
|||||||
if log.GetLevel() == log.LOG_TRACE {
|
if log.GetLevel() == log.LOG_TRACE {
|
||||||
DbClient.IsShowSQL = true
|
DbClient.IsShowSQL = true
|
||||||
}
|
}
|
||||||
log.Debugf("dbType:%s dbUrl:%s:******@tcp(%s:%s)/%s??charset=utf8&parseTime=true&loc=Local",
|
log.Debugf("dbType:%s dbUrl:%s:******@tcp(%s:%s)/%s??charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbType, dbUser, dbHost, dbPort, dbName)
|
dbType, dbUser, dbHost, dbPort, dbName)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ type DatabaseClient struct {
|
|||||||
var DbClient DatabaseClient
|
var DbClient DatabaseClient
|
||||||
|
|
||||||
func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) error {
|
func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) error {
|
||||||
DbClient.dbUrl = fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=true&loc=Local",
|
DbClient.dbUrl = fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbUser, dbPassword, dbHost, dbPort, dbName)
|
dbUser, dbPassword, dbHost, dbPort, dbName)
|
||||||
DbClient.dbType = dbType
|
DbClient.dbType = dbType
|
||||||
DbClient.dbConnMaxLifetime = 0
|
DbClient.dbConnMaxLifetime = 0
|
||||||
@@ -138,7 +138,7 @@ func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) err
|
|||||||
if log.GetLevel() == log.LOG_TRACE {
|
if log.GetLevel() == log.LOG_TRACE {
|
||||||
DbClient.IsShowSQL = true
|
DbClient.IsShowSQL = true
|
||||||
}
|
}
|
||||||
log.Debugf("dbType:%s dbUrl:%s:******@tcp(%s:%s)/%s??charset=utf8&parseTime=true&loc=Local",
|
log.Debugf("dbType:%s dbUrl:%s:******@tcp(%s:%s)/%s??charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbType, dbUser, dbHost, dbPort, dbName)
|
dbType, dbUser, dbHost, dbPort, dbName)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
@@ -159,9 +159,9 @@ func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) err
|
|||||||
}
|
}
|
||||||
|
|
||||||
func XormConnectDatabase(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) (*xorm.Engine, error) {
|
func XormConnectDatabase(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) (*xorm.Engine, error) {
|
||||||
sqlStr := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=true&loc=Local",
|
sqlStr := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbUser, dbPassword, dbHost, dbPort, dbName)
|
dbUser, dbPassword, dbHost, dbPort, dbName)
|
||||||
log.Debugf("dbType:%s Connect to:%s:******@tcp(%s:%s)/%s?charset=utf8&parseTime=true&loc=Local",
|
log.Debugf("dbType:%s Connect to:%s:******@tcp(%s:%s)/%s?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbType, dbUser, dbHost, dbPort, dbName)
|
dbType, dbUser, dbHost, dbPort, dbName)
|
||||||
var err error
|
var err error
|
||||||
xEngine, err = xorm.NewEngine(dbType, sqlStr) //1、Create xorm engine
|
xEngine, err = xorm.NewEngine(dbType, sqlStr) //1、Create xorm engine
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ var DbClient DatabaseClient
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) error {
|
func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) error {
|
||||||
DbClient.dbUrl = fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=true&loc=Local",
|
DbClient.dbUrl = fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbUser, dbPassword, dbHost, dbPort, dbName)
|
dbUser, dbPassword, dbHost, dbPort, dbName)
|
||||||
DbClient.dbType = dbType
|
DbClient.dbType = dbType
|
||||||
DbClient.dbConnMaxLifetime = 0
|
DbClient.dbConnMaxLifetime = 0
|
||||||
@@ -60,7 +60,7 @@ func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) err
|
|||||||
if log.GetLevel() == log.LOG_TRACE {
|
if log.GetLevel() == log.LOG_TRACE {
|
||||||
DbClient.IsShowSQL = true
|
DbClient.IsShowSQL = true
|
||||||
}
|
}
|
||||||
log.Debugf("dbType:%s dbUrl:%s:******@tcp(%s:%s)/%s??charset=utf8&parseTime=true&loc=Local",
|
log.Debugf("dbType:%s dbUrl:%s:******@tcp(%s:%s)/%s??charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbType, dbUser, dbHost, dbPort, dbName)
|
dbType, dbUser, dbHost, dbPort, dbName)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ type DatabaseClient struct {
|
|||||||
var DbClient DatabaseClient
|
var DbClient DatabaseClient
|
||||||
|
|
||||||
func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) error {
|
func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) error {
|
||||||
DbClient.dbUrl = fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=true&loc=Local",
|
DbClient.dbUrl = fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbUser, dbPassword, dbHost, dbPort, dbName)
|
dbUser, dbPassword, dbHost, dbPort, dbName)
|
||||||
DbClient.dbType = dbType
|
DbClient.dbType = dbType
|
||||||
DbClient.dbConnMaxLifetime = 0
|
DbClient.dbConnMaxLifetime = 0
|
||||||
@@ -103,7 +103,7 @@ func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) err
|
|||||||
if log.GetLevel() == log.LOG_TRACE {
|
if log.GetLevel() == log.LOG_TRACE {
|
||||||
DbClient.IsShowSQL = true
|
DbClient.IsShowSQL = true
|
||||||
}
|
}
|
||||||
log.Debugf("dbType:%s dbUrl:%s:******@tcp(%s:%s)/%s??charset=utf8&parseTime=true&loc=Local",
|
log.Debugf("dbType:%s dbUrl:%s:******@tcp(%s:%s)/%s??charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbType, dbUser, dbHost, dbPort, dbName)
|
dbType, dbUser, dbHost, dbPort, dbName)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
@@ -124,9 +124,9 @@ func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) err
|
|||||||
}
|
}
|
||||||
|
|
||||||
func XormConnectDatabase(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) (*xorm.Engine, error) {
|
func XormConnectDatabase(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) (*xorm.Engine, error) {
|
||||||
sqlStr := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=true&loc=Local",
|
sqlStr := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbUser, dbPassword, dbHost, dbPort, dbName)
|
dbUser, dbPassword, dbHost, dbPort, dbName)
|
||||||
log.Debugf("dbType:%s Connect to:%s:******@tcp(%s:%s)/%s?charset=utf8&parseTime=true&loc=Local",
|
log.Debugf("dbType:%s Connect to:%s:******@tcp(%s:%s)/%s?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbType, dbUser, dbHost, dbPort, dbName)
|
dbType, dbUser, dbHost, dbPort, dbName)
|
||||||
var err error
|
var err error
|
||||||
xEngine, err = xorm.NewEngine(dbType, sqlStr) //1、Create xorm engine
|
xEngine, err = xorm.NewEngine(dbType, sqlStr) //1、Create xorm engine
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ var dbConfig = config.GetYamlConfig().Database
|
|||||||
|
|
||||||
func DatabaseWhoreBackup() {
|
func DatabaseWhoreBackup() {
|
||||||
// MySQL数据库连接信息
|
// MySQL数据库连接信息
|
||||||
sqlStr := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=true&loc=Local",
|
sqlStr := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbConfig.User, dbConfig.Password, dbConfig.Host, dbConfig.Port, dbConfig.Name)
|
dbConfig.User, dbConfig.Password, dbConfig.Host, dbConfig.Port, dbConfig.Name)
|
||||||
db, err := sql.Open("mysql", sqlStr)
|
db, err := sql.Open("mysql", sqlStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -91,7 +91,7 @@ func DatabaseWhoreBackup() {
|
|||||||
|
|
||||||
func DatabaseIncrementalBackup() {
|
func DatabaseIncrementalBackup() {
|
||||||
// MySQL数据库连接信息
|
// MySQL数据库连接信息
|
||||||
sqlStr := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=true&loc=Local",
|
sqlStr := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbConfig.User, dbConfig.Password, dbConfig.Host, dbConfig.Port, dbConfig.Name)
|
dbConfig.User, dbConfig.Password, dbConfig.Host, dbConfig.Port, dbConfig.Name)
|
||||||
db, err := sql.Open("mysql", sqlStr)
|
db, err := sql.Open("mysql", sqlStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -92,12 +92,12 @@ func (r *ServiceSysConfig) DeleteConfigByIds(configIds []string) (int64, error)
|
|||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
configs := r.sysConfigRepository.SelectConfigByIds(configIds)
|
configs := r.sysConfigRepository.SelectConfigByIds(configIds)
|
||||||
if len(configs) <= 0 {
|
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 {
|
for _, config := range configs {
|
||||||
// 检查是否为内置参数
|
// 检查是否为内置参数
|
||||||
if config.ConfigType == "Y" {
|
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)
|
r.clearConfigCache(config.ConfigKey)
|
||||||
@@ -106,7 +106,7 @@ func (r *ServiceSysConfig) DeleteConfigByIds(configIds []string) (int64, error)
|
|||||||
rows := r.sysConfigRepository.DeleteConfigByIds(configIds)
|
rows := r.sysConfigRepository.DeleteConfigByIds(configIds)
|
||||||
return rows, nil
|
return rows, nil
|
||||||
}
|
}
|
||||||
return 0, errors.New("删除参数配置信息失败!")
|
return 0, errors.New("failed to delete parameter configuration information")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetConfigCache 重置参数缓存数据
|
// ResetConfigCache 重置参数缓存数据
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ func (r *ServiceSysDictData) DeleteDictDataByCodes(dictCodes []string) (int64, e
|
|||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
dictDatas := r.sysDictDataRepository.SelectDictDataByCodes(dictCodes)
|
dictDatas := r.sysDictDataRepository.SelectDictDataByCodes(dictCodes)
|
||||||
if len(dictDatas) <= 0 {
|
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) {
|
if len(dictDatas) == len(dictCodes) {
|
||||||
for _, v := range dictDatas {
|
for _, v := range dictDatas {
|
||||||
@@ -89,7 +89,7 @@ func (r *ServiceSysDictData) DeleteDictDataByCodes(dictCodes []string) (int64, e
|
|||||||
rows := r.sysDictDataRepository.DeleteDictDataByCodes(dictCodes)
|
rows := r.sysDictDataRepository.DeleteDictDataByCodes(dictCodes)
|
||||||
return rows, nil
|
return rows, nil
|
||||||
}
|
}
|
||||||
return 0, errors.New("删除字典数据信息失败!")
|
return 0, errors.New("failed to delete dictionary data information")
|
||||||
}
|
}
|
||||||
|
|
||||||
// InsertDictData 新增字典数据信息
|
// InsertDictData 新增字典数据信息
|
||||||
|
|||||||
@@ -108,13 +108,13 @@ func (r *ServiceSysDictType) DeleteDictTypeByIDs(dictIDs []string) (int64, error
|
|||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
dictTypes := r.sysDictTypeRepository.SelectDictTypeByIDs(dictIDs)
|
dictTypes := r.sysDictTypeRepository.SelectDictTypeByIDs(dictIDs)
|
||||||
if len(dictTypes) <= 0 {
|
if len(dictTypes) <= 0 {
|
||||||
return 0, errors.New("没有权限访问字典类型数据!")
|
return 0, errors.New("no permission to access dictionary type data")
|
||||||
}
|
}
|
||||||
for _, v := range dictTypes {
|
for _, v := range dictTypes {
|
||||||
// 字典类型下级含有数据
|
// 字典类型下级含有数据
|
||||||
useCount := r.sysDictDataRepository.CountDictDataByType(v.DictType)
|
useCount := r.sysDictDataRepository.CountDictDataByType(v.DictType)
|
||||||
if useCount > 0 {
|
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)
|
return 0, errors.New(msg)
|
||||||
}
|
}
|
||||||
// 清除缓存
|
// 清除缓存
|
||||||
@@ -124,7 +124,7 @@ func (r *ServiceSysDictType) DeleteDictTypeByIDs(dictIDs []string) (int64, error
|
|||||||
rows := r.sysDictTypeRepository.DeleteDictTypeByIDs(dictIDs)
|
rows := r.sysDictTypeRepository.DeleteDictTypeByIDs(dictIDs)
|
||||||
return rows, nil
|
return rows, nil
|
||||||
}
|
}
|
||||||
return 0, errors.New("删除字典数据信息失败!")
|
return 0, errors.New("failed to delete dictionary data information")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetDictCache 重置字典缓存数据
|
// ResetDictCache 重置字典缓存数据
|
||||||
|
|||||||
@@ -97,17 +97,17 @@ func (r *ServiceSysRole) DeleteRoleByIds(roleIds []string) (int64, error) {
|
|||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
roles := r.sysRoleRepository.SelectRoleByIds(roleIds)
|
roles := r.sysRoleRepository.SelectRoleByIds(roleIds)
|
||||||
if len(roles) <= 0 {
|
if len(roles) <= 0 {
|
||||||
return 0, errors.New("没有权限访问角色数据!")
|
return 0, errors.New("no permission to access role data")
|
||||||
}
|
}
|
||||||
for _, role := range roles {
|
for _, role := range roles {
|
||||||
// 检查是否为已删除
|
// 检查是否为已删除
|
||||||
if role.DelFlag == "1" {
|
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)
|
userCount := r.sysUserRoleRepository.CountUserRoleByRoleId(role.RoleID)
|
||||||
if userCount > 0 {
|
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)
|
return 0, errors.New(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ func (r *ServiceSysRole) DeleteRoleByIds(roleIds []string) (int64, error) {
|
|||||||
rows := r.sysRoleRepository.DeleteRoleByIds(roleIds)
|
rows := r.sysRoleRepository.DeleteRoleByIds(roleIds)
|
||||||
return rows, nil
|
return rows, nil
|
||||||
}
|
}
|
||||||
return 0, errors.New("删除角色信息失败!")
|
return 0, errors.New("failed to delete role information")
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckUniqueRoleName 校验角色名称是否唯一
|
// CheckUniqueRoleName 校验角色名称是否唯一
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ func (r *ServiceSysUser) DeleteUserByIds(userIds []string) (int64, error) {
|
|||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
users := r.sysUserRepository.SelectUserByIds(userIds)
|
users := r.sysUserRepository.SelectUserByIds(userIds)
|
||||||
if len(users) <= 0 {
|
if len(users) <= 0 {
|
||||||
return 0, errors.New("没有权限访问用户数据!")
|
return 0, errors.New("no permission to access user data")
|
||||||
}
|
}
|
||||||
if len(users) == len(userIds) {
|
if len(users) == len(userIds) {
|
||||||
// 删除用户与角色关联
|
// 删除用户与角色关联
|
||||||
@@ -113,7 +113,7 @@ func (r *ServiceSysUser) DeleteUserByIds(userIds []string) (int64, error) {
|
|||||||
rows := r.sysUserRepository.DeleteUserByIds(userIds)
|
rows := r.sysUserRepository.DeleteUserByIds(userIds)
|
||||||
return rows, nil
|
return rows, nil
|
||||||
}
|
}
|
||||||
return 0, errors.New("删除用户信息失败!")
|
return 0, errors.New("failed to delete user information")
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckUniqueUserName 校验用户名称是否唯一
|
// CheckUniqueUserName 校验用户名称是否唯一
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ func Routers() []services.RouterItem {
|
|||||||
Method: "POST",
|
Method: "POST",
|
||||||
Pattern: "/subSave/{neId}",
|
Pattern: "/subSave/{neId}",
|
||||||
Handler: apis.UdmSubUserSave,
|
Handler: apis.UdmSubUserSave,
|
||||||
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM contracted users", collectlogs.BUSINESS_TYPE_INSERT)),
|
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM Contracted User", collectlogs.BUSINESS_TYPE_INSERT)),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Method: "GET",
|
Method: "GET",
|
||||||
@@ -116,55 +116,55 @@ func Routers() []services.RouterItem {
|
|||||||
Method: "POST",
|
Method: "POST",
|
||||||
Pattern: "/sub/{neId}",
|
Pattern: "/sub/{neId}",
|
||||||
Handler: apis.UdmSubUserAdd,
|
Handler: apis.UdmSubUserAdd,
|
||||||
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM contracted users", collectlogs.BUSINESS_TYPE_INSERT)),
|
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM Contracted User", collectlogs.BUSINESS_TYPE_INSERT)),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
Pattern: "/sub/{neId}/{num}",
|
Pattern: "/sub/{neId}/{num}",
|
||||||
Handler: apis.UdmSubUserAdds,
|
Handler: apis.UdmSubUserAdds,
|
||||||
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM contracted users", collectlogs.BUSINESS_TYPE_INSERT)),
|
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM Contracted User", collectlogs.BUSINESS_TYPE_INSERT)),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Method: "PUT",
|
Method: "PUT",
|
||||||
Pattern: "/sub/{neId}",
|
Pattern: "/sub/{neId}",
|
||||||
Handler: apis.UdmSubUserEdit,
|
Handler: apis.UdmSubUserEdit,
|
||||||
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM contracted users", collectlogs.BUSINESS_TYPE_UPDATE)),
|
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM Contracted User", collectlogs.BUSINESS_TYPE_UPDATE)),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Method: "PUT",
|
Method: "PUT",
|
||||||
Pattern: "/sub4gIP/{neId}",
|
Pattern: "/sub4gIP/{neId}",
|
||||||
Handler: apis.UdmSubUser4GIP,
|
Handler: apis.UdmSubUser4GIP,
|
||||||
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM contracted users", collectlogs.BUSINESS_TYPE_UPDATE)),
|
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM Contracted User", collectlogs.BUSINESS_TYPE_UPDATE)),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Method: "PUT",
|
Method: "PUT",
|
||||||
Pattern: "/subSmData/{neId}",
|
Pattern: "/subSmData/{neId}",
|
||||||
Handler: apis.UdmSubUserSmData,
|
Handler: apis.UdmSubUserSmData,
|
||||||
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM contracted users", collectlogs.BUSINESS_TYPE_UPDATE)),
|
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM Contracted User", collectlogs.BUSINESS_TYPE_UPDATE)),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Method: "DELETE",
|
Method: "DELETE",
|
||||||
Pattern: "/sub/{neId}/{imsi}",
|
Pattern: "/sub/{neId}/{imsi}",
|
||||||
Handler: apis.UdmSubUserRemove,
|
Handler: apis.UdmSubUserRemove,
|
||||||
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM contracted users", collectlogs.BUSINESS_TYPE_DELETE)),
|
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM Contracted User", collectlogs.BUSINESS_TYPE_DELETE)),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Method: "DELETE",
|
Method: "DELETE",
|
||||||
Pattern: "/sub/{neId}/{imsi}/{num}",
|
Pattern: "/sub/{neId}/{imsi}/{num}",
|
||||||
Handler: apis.UdmSubUserRemoves,
|
Handler: apis.UdmSubUserRemoves,
|
||||||
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM contracted users", collectlogs.BUSINESS_TYPE_DELETE)),
|
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM Contracted User", collectlogs.BUSINESS_TYPE_DELETE)),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
Pattern: "/subExport",
|
Pattern: "/subExport",
|
||||||
Handler: apis.UdmSubUserExport,
|
Handler: apis.UdmSubUserExport,
|
||||||
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM contracted users", collectlogs.BUSINESS_TYPE_EXPORT)),
|
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM Contracted User", collectlogs.BUSINESS_TYPE_EXPORT)),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
Pattern: "/subImport/{neId}",
|
Pattern: "/subImport/{neId}",
|
||||||
Handler: apis.UdmSubUserImport,
|
Handler: apis.UdmSubUserImport,
|
||||||
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM contracted users", collectlogs.BUSINESS_TYPE_IMPORT)),
|
Middleware: midware.LogOperate(collectlogs.OptionNew("UDM Contracted User", collectlogs.BUSINESS_TYPE_IMPORT)),
|
||||||
},
|
},
|
||||||
// 添加更多的 Router 对象...
|
// 添加更多的 Router 对象...
|
||||||
}
|
}
|
||||||
@@ -344,7 +344,7 @@ func (s *UdmUserApi) UdmAuthUserAdds(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := fmt.Sprintf("bad authdat:start_imsi=%s,sub_num=%s,ki=%s,amf=%s,algo=%s", body.Imsi, num, body.Ki, body.Amf, body.AlgoIndex)
|
msg := fmt.Sprintf("bad authdat:start_imsi=%s,sub_num=%s,ki=%s,amf=%s,algo=%s,opc=%s", body.Imsi, num, body.Ki, body.Amf, body.AlgoIndex, body.Opc)
|
||||||
|
|
||||||
// 发送MML
|
// 发送MML
|
||||||
data, err := mmlclient.MMLSendMsgToString(neInfo.Ip, msg)
|
data, err := mmlclient.MMLSendMsgToString(neInfo.Ip, msg)
|
||||||
@@ -511,9 +511,9 @@ func (s *UdmUserApi) UdmAuthUserExport(w http.ResponseWriter, r *http.Request) {
|
|||||||
if body.Type == "csv" {
|
if body.Type == "csv" {
|
||||||
// 转换数据
|
// 转换数据
|
||||||
data := [][]string{}
|
data := [][]string{}
|
||||||
data = append(data, []string{"imsi", "ki", "amf", "algo", "opc"})
|
data = append(data, []string{"imsi", "ki", "algo", "amf", "opc"})
|
||||||
for _, v := range list {
|
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)
|
err := file.WriterCSVFile(data, filePath)
|
||||||
@@ -527,7 +527,7 @@ func (s *UdmUserApi) UdmAuthUserExport(w http.ResponseWriter, r *http.Request) {
|
|||||||
// 转换数据
|
// 转换数据
|
||||||
data := [][]string{}
|
data := [][]string{}
|
||||||
for _, v := range list {
|
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)
|
err = file.WriterTxtFile(data, filePath)
|
||||||
@@ -661,40 +661,48 @@ func (s *UdmUserApi) UdmSubUserInfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询数据库是否存在并存入
|
// 解析返回的数据
|
||||||
|
cnType, _ := strconv.ParseInt(data["CNType"][:4], 0, 64)
|
||||||
|
rat, _ := strconv.ParseInt(data["RAT"][:4], 0, 64)
|
||||||
|
msisdn := data["MSISDN"]
|
||||||
|
imsMsisdnLen := strings.Index(msisdn, ",")
|
||||||
|
if imsMsisdnLen != -1 {
|
||||||
|
msisdn = msisdn[:imsMsisdnLen]
|
||||||
|
}
|
||||||
|
userInfo := model.UdmSubUser{
|
||||||
|
Imsi: imsi,
|
||||||
|
Msisdn: msisdn,
|
||||||
|
Ambr: data["AMBR"],
|
||||||
|
Arfb: data["AreaForbidden"],
|
||||||
|
Cn: fmt.Sprint(cnType),
|
||||||
|
SmData: data["SM-Data(snssai+dnn[1..n])"],
|
||||||
|
Sar: data["ServiceAreaRestriction"],
|
||||||
|
Nssai: data["NSSAI"],
|
||||||
|
SmfSel: data["Smf-Selection"],
|
||||||
|
Rat: fmt.Sprint(rat),
|
||||||
|
}
|
||||||
|
// 1,64,24,65,def_eps,1,2,010200000000,-
|
||||||
|
if v, ok := data["EPS-Data"]; ok {
|
||||||
|
userInfo.EpsDat = v
|
||||||
|
arr := strings.Split(v, ",")
|
||||||
|
userInfo.EpsFlag = arr[0]
|
||||||
|
userInfo.EpsOdb = arr[1]
|
||||||
|
userInfo.HplmnOdb = arr[2]
|
||||||
|
userInfo.Ard = arr[3]
|
||||||
|
userInfo.Epstpl = arr[4]
|
||||||
|
userInfo.ContextId = arr[5]
|
||||||
|
userInfo.ApnContext = arr[7]
|
||||||
|
userInfo.StaticIp = arr[8]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询数据库是否存在并存入更新
|
||||||
neId = ""
|
neId = ""
|
||||||
var userInfo model.UdmSubUser
|
|
||||||
list := s.subUser.List(model.UdmSubUser{NeID: neId, Imsi: imsi})
|
list := s.subUser.List(model.UdmSubUser{NeID: neId, Imsi: imsi})
|
||||||
if len(list) > 0 {
|
if len(list) > 0 {
|
||||||
userInfo = list[0]
|
listItme := list[0]
|
||||||
|
userInfo.ID = listItme.ID
|
||||||
|
s.subUser.Update(neId, userInfo)
|
||||||
} else {
|
} else {
|
||||||
cnType, _ := strconv.ParseInt(data["CNType"][:4], 0, 64)
|
|
||||||
rat, _ := strconv.ParseInt(data["RAT"][:4], 0, 64)
|
|
||||||
userInfo := model.UdmSubUser{
|
|
||||||
Imsi: imsi,
|
|
||||||
Msisdn: data["MSISDN"],
|
|
||||||
Ambr: data["AMBR"],
|
|
||||||
Arfb: data["AreaForbidden"],
|
|
||||||
Cn: fmt.Sprint(cnType),
|
|
||||||
SmData: data["SM-Data(snssai+dnn[1..n])"],
|
|
||||||
Sar: data["ServiceAreaRestriction"],
|
|
||||||
Nssai: data["NSSAI"],
|
|
||||||
SmfSel: data["Smf-Selection"],
|
|
||||||
Rat: fmt.Sprint(rat),
|
|
||||||
}
|
|
||||||
// 1,64,24,65,def_eps,1,2,010200000000,-
|
|
||||||
if v, ok := data["EPS-Data"]; ok {
|
|
||||||
userInfo.EpsDat = v
|
|
||||||
arr := strings.Split(v, ",")
|
|
||||||
userInfo.EpsFlag = arr[0]
|
|
||||||
userInfo.EpsOdb = arr[1]
|
|
||||||
userInfo.HplmnOdb = arr[2]
|
|
||||||
userInfo.Ard = arr[3]
|
|
||||||
userInfo.Epstpl = arr[4]
|
|
||||||
userInfo.ContextId = arr[5]
|
|
||||||
userInfo.ApnContext = arr[7]
|
|
||||||
userInfo.StaticIp = arr[8]
|
|
||||||
}
|
|
||||||
s.subUser.Insert(neId, userInfo)
|
s.subUser.Insert(neId, userInfo)
|
||||||
}
|
}
|
||||||
ctx.JSON(w, 200, result.OkData(userInfo))
|
ctx.JSON(w, 200, result.OkData(userInfo))
|
||||||
@@ -1102,9 +1110,10 @@ func (s *UdmUserApi) UdmSubUserExport(w http.ResponseWriter, r *http.Request) {
|
|||||||
if body.Type == "csv" {
|
if body.Type == "csv" {
|
||||||
// 转换数据
|
// 转换数据
|
||||||
data := [][]string{}
|
data := [][]string{}
|
||||||
data = append(data, []string{"imsi", "msisdn", "ambr", "arfb", "sar", "rat", "cn", "smf_sel", "sm_dat", "eps_dat"})
|
data = append(data, []string{"imsi", "msisdn", "ambr", "nssai", "arfb", "sar", "rat", "cn", "smf_sel", "sm_dat", "eps_dat"})
|
||||||
for _, v := range list {
|
for _, v := range list {
|
||||||
data = append(data, []string{v.Imsi, v.Msisdn, v.Ambr, v.Arfb, v.Sar, v.Rat, v.Cn, v.SmfSel, v.SmData, v.EpsDat})
|
epsDat := fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s,%s", v.EpsFlag, v.EpsOdb, v.HplmnOdb, v.Ard, v.Epstpl, v.ContextId, v.ApnContext, v.StaticIp)
|
||||||
|
data = append(data, []string{v.Imsi, v.Msisdn, v.Ambr, v.Nssai, v.Arfb, v.Sar, v.Rat, v.Cn, v.SmfSel, v.SmData, epsDat})
|
||||||
}
|
}
|
||||||
// 输出到文件
|
// 输出到文件
|
||||||
err = file.WriterCSVFile(data, filePath)
|
err = file.WriterCSVFile(data, filePath)
|
||||||
@@ -1118,7 +1127,8 @@ func (s *UdmUserApi) UdmSubUserExport(w http.ResponseWriter, r *http.Request) {
|
|||||||
// 转换数据
|
// 转换数据
|
||||||
data := [][]string{}
|
data := [][]string{}
|
||||||
for _, v := range list {
|
for _, v := range list {
|
||||||
data = append(data, []string{v.Imsi, v.Msisdn, v.Ambr, v.Arfb, v.Sar, v.Rat, v.Cn, v.SmfSel, v.SmData, v.EpsDat})
|
epsDat := fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s,%s", v.EpsFlag, v.EpsOdb, v.HplmnOdb, v.Ard, v.Epstpl, v.ContextId, v.ApnContext, v.StaticIp)
|
||||||
|
data = append(data, []string{v.Imsi, v.Msisdn, v.Ambr, v.Nssai, v.Arfb, v.Sar, v.Rat, v.Cn, v.SmfSel, v.SmData, epsDat})
|
||||||
}
|
}
|
||||||
// 输出到文件
|
// 输出到文件
|
||||||
err = file.WriterTxtFile(data, filePath)
|
err = file.WriterTxtFile(data, filePath)
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ func (r *RepoUdmAuthUser) SelectList(auth model.UdmAuthUser) []model.UdmAuthUser
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 查询数据
|
// 查询数据
|
||||||
querySql := r.selectSql + whereSql
|
querySql := r.selectSql + whereSql + " order by imsi asc "
|
||||||
results, err := datasource.RawDB("", querySql, params)
|
results, err := datasource.RawDB("", querySql, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("query err => %v", err)
|
log.Errorf("query err => %v", err)
|
||||||
@@ -210,6 +210,7 @@ func (r *RepoUdmAuthUser) Inserts(authUsers []model.UdmAuthUser) int64 {
|
|||||||
// 调用 InsertMulti 函数将批量数据插入数据库
|
// 调用 InsertMulti 函数将批量数据插入数据库
|
||||||
results, err := datasource.DefaultDB().Table("u_auth_user").InsertMulti(batch)
|
results, err := datasource.DefaultDB().Table("u_auth_user").InsertMulti(batch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Errorf("Insert err => %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
num += results
|
num += results
|
||||||
@@ -267,7 +268,7 @@ func (r *RepoUdmAuthUser) Deletes(neID, imsi, num string) int64 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
results, err := datasource.DefaultDB().Table("u_auth_user").Where("imsi >= ? and imsi <= ? and ne_id = ?", imsiV, imsiV+numV, neID).Delete()
|
results, err := datasource.DefaultDB().Table("u_auth_user").Where("imsi >= ? and imsi < ? and ne_id = ?", imsiV, imsiV+numV, neID).Delete()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ func (r *RepoUdmSubUser) SelectList(auth model.UdmSubUser) []model.UdmSubUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 查询数据
|
// 查询数据
|
||||||
querySql := r.selectSql + whereSql
|
querySql := r.selectSql + whereSql + " order by imsi asc "
|
||||||
results, err := datasource.RawDB("", querySql, params)
|
results, err := datasource.RawDB("", querySql, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("query err => %v", err)
|
log.Errorf("query err => %v", err)
|
||||||
@@ -220,6 +220,7 @@ func (r *RepoUdmSubUser) ClearAndInsert(neID string, subArr []model.UdmSubUser)
|
|||||||
func (r *RepoUdmSubUser) Insert(subUser model.UdmSubUser) int64 {
|
func (r *RepoUdmSubUser) Insert(subUser model.UdmSubUser) int64 {
|
||||||
results, err := datasource.DefaultDB().Table("u_sub_user").Insert(subUser)
|
results, err := datasource.DefaultDB().Table("u_sub_user").Insert(subUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Errorf("Insert err => %v", err)
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
return results
|
return results
|
||||||
@@ -240,6 +241,7 @@ func (r *RepoUdmSubUser) Inserts(subUser []model.UdmSubUser) int64 {
|
|||||||
// 调用 InsertMulti 函数将批量数据插入数据库
|
// 调用 InsertMulti 函数将批量数据插入数据库
|
||||||
results, err := datasource.DefaultDB().Table("u_sub_user").InsertMulti(batch)
|
results, err := datasource.DefaultDB().Table("u_sub_user").InsertMulti(batch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Errorf("Insert err => %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
num += results
|
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)
|
results, err := datasource.DefaultDB().Table("u_sub_user").Insert(subUser)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
log.Errorf("Insert err => %v", err)
|
||||||
insertNum += results
|
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)
|
results, err := datasource.DefaultDB().Table("u_sub_user").Where("imsi = ? and ne_id = ?", user.Imsi, user.NeID).Update(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Errorf("Update err => %v", err)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return results
|
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)
|
results, err := datasource.DefaultDB().Table("u_sub_user").Update(user)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
log.Errorf("Update err => %v", err)
|
||||||
insertNum += results
|
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)
|
results, err := datasource.DefaultDB().Table("u_sub_user").Update(user)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
log.Errorf("Update err => %v", err)
|
||||||
insertNum += results
|
insertNum += results
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -417,6 +423,7 @@ func (r *RepoUdmSubUser) UpdateSmData(neID string, subUser model.UdmSubUser) int
|
|||||||
func (r *RepoUdmSubUser) Delete(neID, imsi string) int64 {
|
func (r *RepoUdmSubUser) Delete(neID, imsi string) int64 {
|
||||||
results, err := datasource.DefaultDB().Table("u_sub_user").Where("imsi = ? and ne_id = ?", imsi, neID).Delete()
|
results, err := datasource.DefaultDB().Table("u_sub_user").Where("imsi = ? and ne_id = ?", imsi, neID).Delete()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Errorf("Delete err => %v", err)
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
return results
|
return results
|
||||||
@@ -434,8 +441,9 @@ func (r *RepoUdmSubUser) Deletes(neID, imsi, num string) int64 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
results, err := datasource.DefaultDB().Table("u_sub_user").Where("imsi >= ? and imsi <= ? and ne_id = ?", imsiV, imsiV+numV, neID).Delete()
|
results, err := datasource.DefaultDB().Table("u_sub_user").Where("imsi >= ? and imsi < ? and ne_id = ?", imsiV, imsiV+numV, neID).Delete()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Errorf("Delete err => %v", err)
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
return results
|
return results
|
||||||
|
|||||||
@@ -37,6 +37,12 @@ func redisUdmAuthUserList() []model.UdmAuthUser {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 跳过-号数据
|
||||||
|
imsi := key[5:]
|
||||||
|
if strings.Contains(imsi, "-") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
status := "0"
|
status := "0"
|
||||||
if _, ok := m["auth_success"]; ok {
|
if _, ok := m["auth_success"]; ok {
|
||||||
status = "1"
|
status = "1"
|
||||||
@@ -46,7 +52,7 @@ func redisUdmAuthUserList() []model.UdmAuthUser {
|
|||||||
amf = strings.Replace(v, "\r\n", "", 1)
|
amf = strings.Replace(v, "\r\n", "", 1)
|
||||||
}
|
}
|
||||||
a := model.UdmAuthUser{
|
a := model.UdmAuthUser{
|
||||||
Imsi: key[5:],
|
Imsi: imsi,
|
||||||
Amf: amf,
|
Amf: amf,
|
||||||
Status: status,
|
Status: status,
|
||||||
Ki: m["ki"],
|
Ki: m["ki"],
|
||||||
@@ -73,7 +79,7 @@ func redisUdmSubUserList() []model.UdmSubUser {
|
|||||||
|
|
||||||
a := model.UdmSubUser{
|
a := model.UdmSubUser{
|
||||||
Imsi: key[7:],
|
Imsi: key[7:],
|
||||||
Msisdn: strings.TrimPrefix(m["gpsi"], "86"),
|
Msisdn: m["gpsi"], // 46003550072 strings.TrimPrefix(m["gpsi"], "86"),
|
||||||
SmfSel: m["smf-sel"],
|
SmfSel: m["smf-sel"],
|
||||||
SmData: m["sm-dat"], // 1-000001&cmnet&ims&3gnet
|
SmData: m["sm-dat"], // 1-000001&cmnet&ims&3gnet
|
||||||
}
|
}
|
||||||
@@ -90,8 +96,12 @@ func redisUdmSubUserList() []model.UdmSubUser {
|
|||||||
}
|
}
|
||||||
// 1,64,24,65,def_eps,1,2,010200000000,-
|
// 1,64,24,65,def_eps,1,2,010200000000,-
|
||||||
if v, ok := m["eps-dat"]; ok {
|
if v, ok := m["eps-dat"]; ok {
|
||||||
a.EpsDat = v
|
|
||||||
arr := strings.Split(v, ",")
|
arr := strings.Split(v, ",")
|
||||||
|
// 跳过非常规数据
|
||||||
|
if len(arr) > 9 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
a.EpsDat = v
|
||||||
a.EpsFlag = arr[0]
|
a.EpsFlag = arr[0]
|
||||||
a.EpsOdb = arr[1]
|
a.EpsOdb = arr[1]
|
||||||
a.HplmnOdb = arr[2]
|
a.HplmnOdb = arr[2]
|
||||||
@@ -99,6 +109,7 @@ func redisUdmSubUserList() []model.UdmSubUser {
|
|||||||
a.Epstpl = arr[4]
|
a.Epstpl = arr[4]
|
||||||
a.ContextId = arr[5]
|
a.ContextId = arr[5]
|
||||||
a.ApnContext = arr[7]
|
a.ApnContext = arr[7]
|
||||||
|
// [6] 是不要的,导入和导出不用
|
||||||
a.StaticIp = arr[8]
|
a.StaticIp = arr[8]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func (r *ServiceUdmAuthUser) List(authUser model.UdmAuthUser) []model.UdmAuthUse
|
|||||||
// imsi长度15,ki长度32,opc长度0或者32
|
// imsi长度15,ki长度32,opc长度0或者32
|
||||||
func (r *ServiceUdmAuthUser) Insert(neID string, authUser model.UdmAuthUser) int64 {
|
func (r *ServiceUdmAuthUser) Insert(neID string, authUser model.UdmAuthUser) int64 {
|
||||||
authUser.NeID = neID
|
authUser.NeID = neID
|
||||||
authUser.Status = "1"
|
authUser.Status = "0"
|
||||||
return r.repoAuthUser.Insert(authUser)
|
return r.repoAuthUser.Insert(authUser)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ func (r *ServiceUdmAuthUser) Inserts(neID string, authUser model.UdmAuthUser, nu
|
|||||||
}
|
}
|
||||||
|
|
||||||
authUser.NeID = neID
|
authUser.NeID = neID
|
||||||
authUser.Status = "1"
|
authUser.Status = "0"
|
||||||
for i := 0; i < numV; i++ {
|
for i := 0; i < numV; i++ {
|
||||||
imsi := fmt.Sprint(imsiV + i)
|
imsi := fmt.Sprint(imsiV + i)
|
||||||
if len(imsi) < imsiVlen {
|
if len(imsi) < imsiVlen {
|
||||||
@@ -83,22 +83,26 @@ func (r *ServiceUdmAuthUser) InsertCSV(neID string, data []map[string]string) in
|
|||||||
for _, v := range data {
|
for _, v := range data {
|
||||||
var authUser model.UdmAuthUser
|
var authUser model.UdmAuthUser
|
||||||
authUser.NeID = neID
|
authUser.NeID = neID
|
||||||
authUser.Status = "1"
|
authUser.Status = "0"
|
||||||
if s, ok := v["imsi"]; ok {
|
if s, ok := v["imsi"]; ok {
|
||||||
authUser.Imsi = s
|
authUser.Imsi = s
|
||||||
}
|
}
|
||||||
if s, ok := v["ki"]; ok {
|
if s, ok := v["ki"]; ok {
|
||||||
authUser.Ki = s
|
authUser.Ki = s
|
||||||
}
|
}
|
||||||
if s, ok := v["amf"]; ok {
|
|
||||||
authUser.Amf = s
|
|
||||||
}
|
|
||||||
if s, ok := v["algo"]; ok {
|
if s, ok := v["algo"]; ok {
|
||||||
authUser.AlgoIndex = s
|
authUser.AlgoIndex = s
|
||||||
}
|
}
|
||||||
|
if s, ok := v["amf"]; ok {
|
||||||
|
authUser.Amf = s
|
||||||
|
}
|
||||||
if s, ok := v["opc"]; ok {
|
if s, ok := v["opc"]; ok {
|
||||||
authUser.Opc = s
|
authUser.Opc = s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if authUser.Imsi == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
arr = append(arr, authUser)
|
arr = append(arr, authUser)
|
||||||
}
|
}
|
||||||
return r.repoAuthUser.Inserts(arr)
|
return r.repoAuthUser.Inserts(arr)
|
||||||
@@ -113,7 +117,7 @@ func (r *ServiceUdmAuthUser) InsertTxt(neID string, data [][]string) int64 {
|
|||||||
}
|
}
|
||||||
var authUser model.UdmAuthUser
|
var authUser model.UdmAuthUser
|
||||||
authUser.NeID = neID
|
authUser.NeID = neID
|
||||||
authUser.Status = "1"
|
authUser.Status = "0"
|
||||||
authUser.Imsi = v[0]
|
authUser.Imsi = v[0]
|
||||||
authUser.Ki = v[1]
|
authUser.Ki = v[1]
|
||||||
authUser.AlgoIndex = v[2]
|
authUser.AlgoIndex = v[2]
|
||||||
@@ -121,6 +125,10 @@ func (r *ServiceUdmAuthUser) InsertTxt(neID string, data [][]string) int64 {
|
|||||||
if len(v) == 5 {
|
if len(v) == 5 {
|
||||||
authUser.Opc = v[4]
|
authUser.Opc = v[4]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if authUser.Imsi == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
arr = append(arr, authUser)
|
arr = append(arr, authUser)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ func (r *ServiceUdmSubUser) Inserts(neID string, subUser model.UdmSubUser, num s
|
|||||||
subUser.Imsi = imsi
|
subUser.Imsi = imsi
|
||||||
|
|
||||||
// IP会自动递增
|
// IP会自动递增
|
||||||
if subUser.StaticIp != "" {
|
if len(subUser.StaticIp) > 5 {
|
||||||
parts := strings.Split(subUser.StaticIp, ".")
|
parts := strings.Split(subUser.StaticIp, ".")
|
||||||
lastPart := parts[3]
|
lastPart := parts[3]
|
||||||
lastNum, _ := strconv.Atoi(lastPart)
|
lastNum, _ := strconv.Atoi(lastPart)
|
||||||
@@ -93,6 +93,9 @@ func (r *ServiceUdmSubUser) Inserts(neID string, subUser model.UdmSubUser, num s
|
|||||||
newIP := strings.Join(parts, ".")
|
newIP := strings.Join(parts, ".")
|
||||||
subUser.StaticIp = newIP
|
subUser.StaticIp = newIP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
subUser.EpsDat = fmt.Sprintf("%s,%s,%s,%s,%s,%s,2,%s,%s", subUser.EpsFlag, subUser.EpsOdb, subUser.HplmnOdb, subUser.Ard, subUser.Epstpl, subUser.ContextId, subUser.ApnContext, subUser.StaticIp)
|
||||||
|
|
||||||
arr = append(arr, subUser)
|
arr = append(arr, subUser)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,11 +135,26 @@ func (r *ServiceUdmSubUser) InsertCSV(neID string, data []map[string]string) int
|
|||||||
if s, ok := v["smf_sel"]; ok {
|
if s, ok := v["smf_sel"]; ok {
|
||||||
subUser.SmfSel = s
|
subUser.SmfSel = s
|
||||||
}
|
}
|
||||||
if s, ok := v["sm_data"]; ok {
|
if s, ok := v["sm_dat"]; ok {
|
||||||
subUser.SmData = s
|
subUser.SmData = s
|
||||||
}
|
}
|
||||||
if s, ok := v["eps_dat"]; ok {
|
if s, ok := v["eps_dat"]; ok {
|
||||||
subUser.EpsDat = s
|
subUser.EpsDat = s
|
||||||
|
arr := strings.Split(s, ",")
|
||||||
|
if len(arr) == 8 {
|
||||||
|
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[6]
|
||||||
|
subUser.StaticIp = arr[7]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if subUser.Imsi == "" {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
arr = append(arr, subUser)
|
arr = append(arr, subUser)
|
||||||
}
|
}
|
||||||
@@ -162,8 +180,20 @@ func (r *ServiceUdmSubUser) InsertTxt(neID string, data [][]string) int64 {
|
|||||||
subUser.Cn = v[7]
|
subUser.Cn = v[7]
|
||||||
subUser.SmfSel = v[8]
|
subUser.SmfSel = v[8]
|
||||||
subUser.SmData = v[9]
|
subUser.SmData = v[9]
|
||||||
if len(v) == 11 {
|
if len(v) > 17 {
|
||||||
subUser.EpsDat = v[10]
|
subUser.EpsFlag = v[10]
|
||||||
|
subUser.EpsOdb = v[11]
|
||||||
|
subUser.HplmnOdb = v[12]
|
||||||
|
subUser.Ard = v[13]
|
||||||
|
subUser.Epstpl = v[14]
|
||||||
|
subUser.ContextId = v[15]
|
||||||
|
subUser.ApnContext = v[16]
|
||||||
|
subUser.StaticIp = v[17]
|
||||||
|
subUser.EpsDat = strings.Join(v[10:], ",")
|
||||||
|
}
|
||||||
|
|
||||||
|
if subUser.Imsi == "" {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
arr = append(arr, subUser)
|
arr = append(arr, subUser)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,20 +12,20 @@ func MMLSendMsg(ip, msg string) (string, error) {
|
|||||||
// 创建MMLClient实例
|
// 创建MMLClient实例
|
||||||
client, err := NewMMLClient(ip)
|
client, err := NewMMLClient(ip)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("创建MMLClient实例失败:%v", err)
|
return "", fmt.Errorf("failed to create MMLClient instance: %v", err)
|
||||||
}
|
}
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
|
|
||||||
// 发送数据
|
// 发送数据
|
||||||
err = client.Send(msg)
|
err = client.Send(msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("发送数据失败:%v", err)
|
return "", fmt.Errorf("sending data failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 接收数据
|
// 接收数据
|
||||||
data, err := client.Receive()
|
data, err := client.Receive()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("接收数据失败:%v", err)
|
return "", fmt.Errorf("failed to receive data: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return data, nil
|
return data, nil
|
||||||
@@ -41,15 +41,16 @@ func MMLSendMsgToString(ip, msg string) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
str = strings.ToLower(str)
|
||||||
|
|
||||||
// 截断
|
// 截断
|
||||||
index := strings.Index(str, "\n")
|
index := strings.Index(str, "\n")
|
||||||
if index != -1 {
|
if index != -1 {
|
||||||
str = str[:index]
|
str = str[:index]
|
||||||
str = strings.ToLower(str)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 命令成功
|
// 命令成功
|
||||||
if strings.Contains(str, "ok") || strings.Contains(str, "OK") {
|
if strings.Contains(str, "ok") || strings.Contains(str, "success") {
|
||||||
return str, nil
|
return str, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,10 +90,10 @@ func MMLSendMsgToMap(ip, msg string) (map[string]string, error) {
|
|||||||
|
|
||||||
if strings.Contains(item, "=") {
|
if strings.Contains(item, "=") {
|
||||||
// 按照分隔符"="进行拆分键值对
|
// 按照分隔符"="进行拆分键值对
|
||||||
pair = strings.Split(item, "=")
|
pair = strings.SplitN(item, "=", 2)
|
||||||
} else if strings.Contains(item, ":") {
|
} else if strings.Contains(item, ":") {
|
||||||
// 按照分隔符":"进行拆分键值对
|
// 按照分隔符":"进行拆分键值对
|
||||||
pair = strings.Split(item, ":")
|
pair = strings.SplitN(item, ":", 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(pair) == 2 {
|
if len(pair) == 2 {
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ func LoginUser(r *http.Request) (vo.LoginUser, error) {
|
|||||||
if v != nil {
|
if v != nil {
|
||||||
return v.(vo.LoginUser), nil
|
return v.(vo.LoginUser), nil
|
||||||
}
|
}
|
||||||
return vo.LoginUser{}, fmt.Errorf("无用户信息")
|
return vo.LoginUser{}, fmt.Errorf("No user information")
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoginUserToUserID 登录用户信息-用户ID
|
// LoginUserToUserID 登录用户信息-用户ID
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ type DatabaseClient struct {
|
|||||||
var DbClient DatabaseClient
|
var DbClient DatabaseClient
|
||||||
|
|
||||||
func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) error {
|
func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) error {
|
||||||
DbClient.dbUrl = fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=true&loc=Local",
|
DbClient.dbUrl = fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbUser, dbPassword, dbHost, dbPort, dbName)
|
dbUser, dbPassword, dbHost, dbPort, dbName)
|
||||||
DbClient.dbType = dbType
|
DbClient.dbType = dbType
|
||||||
DbClient.dbConnMaxLifetime = 0
|
DbClient.dbConnMaxLifetime = 0
|
||||||
@@ -55,7 +55,7 @@ func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) err
|
|||||||
if log.GetLevel() == log.LOG_TRACE {
|
if log.GetLevel() == log.LOG_TRACE {
|
||||||
DbClient.IsShowSQL = true
|
DbClient.IsShowSQL = true
|
||||||
}
|
}
|
||||||
log.Debugf("dbType:%s dbUrl:%s:******@tcp(%s:%s)/%s??charset=utf8&parseTime=true&loc=Local",
|
log.Debugf("dbType:%s dbUrl:%s:******@tcp(%s:%s)/%s??charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbType, dbUser, dbHost, dbPort, dbName)
|
dbType, dbUser, dbHost, dbPort, dbName)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
@@ -106,9 +106,9 @@ func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) err
|
|||||||
var xEngine *xorm.Engine
|
var xEngine *xorm.Engine
|
||||||
|
|
||||||
func XormConnectDatabase(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) (*xorm.Engine, error) {
|
func XormConnectDatabase(dbType, dbUser, dbPassword, dbHost, dbPort, dbName string) (*xorm.Engine, error) {
|
||||||
sqlStr := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=true&loc=Local",
|
sqlStr := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbUser, dbPassword, dbHost, dbPort, dbName)
|
dbUser, dbPassword, dbHost, dbPort, dbName)
|
||||||
log.Debugf("dbType:%s Connect to:%s:******@tcp(%s:%s)/%s?charset=utf8&parseTime=true&loc=Local",
|
log.Debugf("dbType:%s Connect to:%s:******@tcp(%s:%s)/%s?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local",
|
||||||
dbType, dbUser, dbHost, dbPort, dbName)
|
dbType, dbUser, dbHost, dbPort, dbName)
|
||||||
var err error
|
var err error
|
||||||
xEngine, err = xorm.NewEngine(dbType, sqlStr) //1、Create xorm engine
|
xEngine, err = xorm.NewEngine(dbType, sqlStr) //1、Create xorm engine
|
||||||
@@ -820,12 +820,13 @@ func XormCheckLoginUser(name, password, cryptArgo string) (bool, *User, error) {
|
|||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
if oauth.BcryptCompare(user.Password, password) != nil {
|
if oauth.BcryptCompare(user.Password, password) != nil {
|
||||||
err := errors.New("用户名或密码错误")
|
err := errors.New("Incorrect user name or password")
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
// 记录错误
|
// 记录错误
|
||||||
errCoutn := pwdErrCountAdd(user.AccountId, user.Profile, false)
|
errCoutn := pwdErrCountAdd(user.AccountId, user.Profile, false)
|
||||||
if errCoutn > 3 {
|
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
|
return false, nil, err
|
||||||
}
|
}
|
||||||
@@ -841,9 +842,9 @@ func XormCheckLoginUser(name, password, cryptArgo string) (bool, *User, error) {
|
|||||||
errMsg := ""
|
errMsg := ""
|
||||||
switch user.Status {
|
switch user.Status {
|
||||||
case "Closed":
|
case "Closed":
|
||||||
errMsg = "账户已禁用"
|
errMsg = "Account disabled" // 账户已禁用
|
||||||
case "Locked":
|
case "Locked":
|
||||||
errMsg = "账户已锁定"
|
errMsg = "Account locked" // 账户已锁定
|
||||||
case "Pending":
|
case "Pending":
|
||||||
// errMsg = "账户已挂起"
|
// errMsg = "账户已挂起"
|
||||||
_, err := xEngine.Exec("UPDATE user SET status = 'Active' WHERE account_id = ?", user.AccountId)
|
_, 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
|
return false, nil, err
|
||||||
}
|
}
|
||||||
if t.Before(time.Now()) {
|
if t.Before(time.Now()) {
|
||||||
errMsg := "密码到期时间"
|
errMsg := "Password expiration time" // 密码到期时间
|
||||||
// 读取配置信息
|
// 读取配置信息
|
||||||
result, err := XormGetConfig("Security", "pwdStrong")
|
result, err := XormGetConfig("Security", "pwdStrong")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -893,7 +894,7 @@ func XormCheckLoginUser(name, password, cryptArgo string) (bool, *User, error) {
|
|||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
if t.Before(time.Now()) {
|
if t.Before(time.Now()) {
|
||||||
errMsg := "用户账户到期"
|
errMsg := "User account expiration" // 用户账户到期
|
||||||
log.Error("UserExpiration:%s", errMsg)
|
log.Error("UserExpiration:%s", errMsg)
|
||||||
return false, nil, errors.New(errMsg)
|
return false, nil, errors.New(errMsg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,9 +139,9 @@ func init() {
|
|||||||
|
|
||||||
// parameter config management
|
// parameter config management
|
||||||
Register("GET", cm.ParamConfigUri, cm.GetParamConfigFromNF, nil)
|
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("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 management", collectlogs.BUSINESS_TYPE_UPDATE)))
|
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 management", collectlogs.BUSINESS_TYPE_INSERT)))
|
Register("DELETE", cm.ParamConfigUri, cm.DeleteParamConfigToNF, midware.LogOperate(collectlogs.OptionNew("Parameter Config", collectlogs.BUSINESS_TYPE_INSERT)))
|
||||||
|
|
||||||
Register("GET", cm.CustomParamConfigUri, cm.GetParamConfigFromNF, nil)
|
Register("GET", cm.CustomParamConfigUri, cm.GetParamConfigFromNF, nil)
|
||||||
Register("POST", cm.CustomParamConfigUri, cm.PostParamConfigToNF, nil)
|
Register("POST", cm.CustomParamConfigUri, cm.PostParamConfigToNF, nil)
|
||||||
@@ -150,9 +150,9 @@ func init() {
|
|||||||
|
|
||||||
// Get/Create/Modify/Delete NE info
|
// Get/Create/Modify/Delete NE info
|
||||||
Register("GET", cm.UriNeInfo, cm.GetNeInfo, nil)
|
Register("GET", cm.UriNeInfo, cm.GetNeInfo, nil)
|
||||||
Register("POST", cm.UriNeInfo, cm.PostNeInfo, midware.LogOperate(collectlogs.OptionNew("NE info", collectlogs.BUSINESS_TYPE_INSERT)))
|
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("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("DELETE", cm.UriNeInfo, cm.DeleteNeInfo, midware.LogOperate(collectlogs.OptionNew("NE Info", collectlogs.BUSINESS_TYPE_DELETE)))
|
||||||
|
|
||||||
// Get/Create/Modify/Delete NE info
|
// Get/Create/Modify/Delete NE info
|
||||||
Register("GET", cm.CustomUriNeInfo, cm.GetNeInfo, nil)
|
Register("GET", cm.CustomUriNeInfo, cm.GetNeInfo, nil)
|
||||||
@@ -191,12 +191,12 @@ func init() {
|
|||||||
// Software management
|
// Software management
|
||||||
Register("GET", cm.UriSoftware, cm.DownloadSoftwareFile, nil)
|
Register("GET", cm.UriSoftware, cm.DownloadSoftwareFile, nil)
|
||||||
//Register("POST", cm.UriSoftware, cm.UploadSoftwareFile, 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("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 management", collectlogs.BUSINESS_TYPE_DELETE)))
|
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("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 management", 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 management", 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("GET", cm.CustomUriSoftware, cm.DownloadSoftwareFile, nil)
|
||||||
Register("POST", cm.CustomUriSoftware, cm.UploadSoftwareFile, nil)
|
Register("POST", cm.CustomUriSoftware, cm.UploadSoftwareFile, nil)
|
||||||
@@ -207,8 +207,8 @@ func init() {
|
|||||||
Register("PATCH", cm.CustomUriSoftwareNE, cm.RollBackSoftwareToNF, nil)
|
Register("PATCH", cm.CustomUriSoftwareNE, cm.RollBackSoftwareToNF, nil)
|
||||||
|
|
||||||
// License management
|
// License management
|
||||||
Register("POST", cm.UriLicense, 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 management", 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.CustomUriLicense, cm.UploadLicenseFileData, nil)
|
||||||
Register("POST", cm.CustomUriLicenseExt, cm.UploadLicenseFileData, nil)
|
Register("POST", cm.CustomUriLicenseExt, cm.UploadLicenseFileData, nil)
|
||||||
@@ -224,19 +224,19 @@ func init() {
|
|||||||
Register("DELETE", trace.CustomUriTraceTask, trace.DeleteTraceTaskToNF, nil)
|
Register("DELETE", trace.CustomUriTraceTask, trace.DeleteTraceTaskToNF, nil)
|
||||||
|
|
||||||
// 网元发送执行 pcap抓包任务
|
// 网元发送执行 pcap抓包任务
|
||||||
Register("POST", trace.UriTcpdumpTask, 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)))
|
Register("POST", trace.CustomUriTcpdumpTask, trace.TcpdumpNeTask, midware.LogOperate(collectlogs.OptionNew("Packet Capturing Task", collectlogs.BUSINESS_TYPE_INSERT)))
|
||||||
// 网元发送执行 抓包下载pcap文件
|
// 网元发送执行 抓包下载pcap文件
|
||||||
Register("POST", trace.UriTcpdumpPcapDownload, 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)))
|
Register("POST", trace.CustomUriTcpdumpPcapDownload, trace.TcpdumpPcapDownload, midware.LogOperate(collectlogs.OptionNew("Packet Capturing Task", collectlogs.BUSINESS_TYPE_EXPORT)))
|
||||||
// 网元发送执行UPF pcap抓包
|
// 网元发送执行UPF pcap抓包
|
||||||
Register("POST", trace.UriTcpdumpNeUPFTask, 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)))
|
Register("POST", trace.CustomUriTcpdumpNeUPFTask, trace.TcpdumpNeUPFTask, midware.LogOperate(collectlogs.OptionNew("Packet Capturing Task", collectlogs.BUSINESS_TYPE_INSERT)))
|
||||||
|
|
||||||
// file management
|
// file management
|
||||||
Register("POST", file.UriFile, file.UploadFile, midware.LogOperate(collectlogs.OptionNew("File management", collectlogs.BUSINESS_TYPE_INSERT)))
|
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 management", collectlogs.BUSINESS_TYPE_OTHER)))
|
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 management", collectlogs.BUSINESS_TYPE_DELETE)))
|
Register("DELETE", file.UriFile, file.DeleteFile, midware.LogOperate(collectlogs.OptionNew("File", collectlogs.BUSINESS_TYPE_DELETE)))
|
||||||
|
|
||||||
Register("POST", file.CustomUriFile, file.UploadFile, nil)
|
Register("POST", file.CustomUriFile, file.UploadFile, nil)
|
||||||
Register("GET", file.CustomUriFile, file.DownloadFile, nil)
|
Register("GET", file.CustomUriFile, file.DownloadFile, nil)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package services
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
@@ -220,7 +219,7 @@ func HandleUploadFormFile(w http.ResponseWriter, r *http.Request) {
|
|||||||
r.ParseMultipartForm(32 << 20)
|
r.ParseMultipartForm(32 << 20)
|
||||||
//mForm := r.MultipartForm
|
//mForm := r.MultipartForm
|
||||||
|
|
||||||
for k, _ := range r.MultipartForm.File {
|
for k := range r.MultipartForm.File {
|
||||||
// k is the key of file part
|
// k is the key of file part
|
||||||
file, fileHeader, err := r.FormFile(k)
|
file, fileHeader, err := r.FormFile(k)
|
||||||
if err != nil {
|
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") {
|
if !strings.Contains(r.Header.Get("Content-Type"), "multipart/form-data") {
|
||||||
// 不支持的 Content-Type 类型
|
// 不支持的 Content-Type 类型
|
||||||
fmt.Println("Invalid Content-Type: ", r.Header.Get("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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +283,8 @@ func PostFileHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
var buf = &bytes.Buffer{}
|
var buf = &bytes.Buffer{}
|
||||||
// 非文件字段部分大小限制验证(非文件字段,go中filename会是空)
|
// 非文件字段部分大小限制验证(非文件字段,go中filename会是空)
|
||||||
if 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)
|
err = uploadSizeLimit(buf, part, ValuesMax, limitError)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
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)
|
err = uploadSizeLimit(buf, part, FilesMax, limitError)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
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")
|
var chunkNumber = r.Header.Get("chunk-number")
|
||||||
if chunkNumber == "" {
|
if chunkNumber == "" {
|
||||||
http.Error(w, "文件"+fileName+"上传成功", http.StatusOK)
|
// "文件"+fileName+"上传成功"
|
||||||
|
http.Error(w, fmt.Sprintf("File %s uploaded successfully", fileName), http.StatusOK)
|
||||||
} else {
|
} 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
|
maxLimit -= n
|
||||||
if maxLimit < 0 {
|
if maxLimit < 0 {
|
||||||
return errors.New(limitError)
|
return fmt.Errorf(limitError)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,20 +138,14 @@ func ExtGetUriPageLimitString(r *http.Request) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IsJsonContentType(r *http.Request) bool {
|
func IsJsonContentType(r *http.Request) bool {
|
||||||
if strings.Contains(r.Header.Get("Content-Type"), "application/json") {
|
hType := r.Header.Get("Content-Type")
|
||||||
return true
|
return strings.Contains(hType, "application/json")
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsValidOAuthUri(r *http.Request) bool {
|
func IsValidOAuthUri(r *http.Request) bool {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
apiVer := vars["apiVersion"] // 获取Uri
|
apiVer := vars["apiVersion"] // 获取Uri
|
||||||
if apiVer != "v1" {
|
return apiVer == "v1"
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsVallidContentType(r *http.Request, checkFlag bool) bool {
|
func IsVallidContentType(r *http.Request, checkFlag bool) bool {
|
||||||
@@ -386,7 +380,7 @@ func CheckCommonValidRequest(w http.ResponseWriter, r *http.Request) (string, er
|
|||||||
// error processing ...
|
// error processing ...
|
||||||
// 401-1 response
|
// 401-1 response
|
||||||
token, ret = oauth.IsCarriedToken(r)
|
token, ret = oauth.IsCarriedToken(r)
|
||||||
if ret == false {
|
if !ret {
|
||||||
log.Error("accessToken is not carried")
|
log.Error("accessToken is not carried")
|
||||||
ResponseUnauthorized401AccessTokenNotCarried(w)
|
ResponseUnauthorized401AccessTokenNotCarried(w)
|
||||||
return token, err
|
return token, err
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package session
|
|||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -89,7 +89,7 @@ func (smgr *SessManager) SetSessionValue(token string, key interface{}, value in
|
|||||||
session.values[key] = value
|
session.values[key] = value
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errors.New("invalid session ID")
|
return fmt.Errorf("invalid session ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSessionValue get value fo session
|
// GetSessionValue get value fo session
|
||||||
@@ -101,7 +101,7 @@ func (smgr *SessManager) GetSessionValue(token string, key interface{}) (interfa
|
|||||||
return val, nil
|
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 {
|
func (smgr *SessManager) GetTokenFromHttpRequest(r *http.Request) string {
|
||||||
@@ -111,7 +111,6 @@ func (smgr *SessManager) GetTokenFromHttpRequest(r *http.Request) string {
|
|||||||
return v[0]
|
return v[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -94,6 +94,7 @@ cors:
|
|||||||
- "X-Requested-With"
|
- "X-Requested-With"
|
||||||
- "Content-Type"
|
- "Content-Type"
|
||||||
- "Content-Language"
|
- "Content-Language"
|
||||||
|
- "Accept-Language"
|
||||||
- "Accept"
|
- "Accept"
|
||||||
- "Range"
|
- "Range"
|
||||||
- "Accesstoken"
|
- "Accesstoken"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# 应用服务配置
|
# 应用服务配置
|
||||||
server:
|
server:
|
||||||
port: 3040
|
port: 3040
|
||||||
|
proxy: true
|
||||||
|
|
||||||
# 日志
|
# 日志
|
||||||
logger:
|
logger:
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ func ErrorCatch() gin.HandlerFunc {
|
|||||||
defer func() {
|
defer func() {
|
||||||
// 在这里处理 Panic 异常,例如记录日志或返回错误信息给客户端
|
// 在这里处理 Panic 异常,例如记录日志或返回错误信息给客户端
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
logger.Errorf("Panic 异常: %s => %v", c.Request.URL, err)
|
logger.Errorf("Panic Error: %s => %v", c.Request.URL, err)
|
||||||
|
|
||||||
// 返回错误响应给客户端
|
// 返回错误响应给客户端
|
||||||
if config.Env() == "prod" {
|
if config.Env() == "prod" {
|
||||||
c.JSON(500, result.ErrMsg("服务器内部错误"))
|
c.JSON(500, result.ErrMsg("Internal Server Errors"))
|
||||||
} else {
|
} else {
|
||||||
// 通过实现 error 接口的 Error() 方法自定义错误类型进行捕获
|
// 通过实现 error 接口的 Error() 方法自定义错误类型进行捕获
|
||||||
switch v := err.(type) {
|
switch v := err.(type) {
|
||||||
|
|||||||
73
src/framework/i18n/i18n.go
Normal file
73
src/framework/i18n/i18n.go
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
package i18n
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
|
systemService "ems.agt/src/modules/system/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
// localeItem 国际化数据项
|
||||||
|
type localeItem struct {
|
||||||
|
Key string `json:"key"`
|
||||||
|
Value string `json:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// localeMap 国际化数据组
|
||||||
|
var localeMap = make(map[string][]localeItem)
|
||||||
|
|
||||||
|
// ClearLocaleData 清空国际化数据
|
||||||
|
func ClearLocaleData() {
|
||||||
|
localeMap = make(map[string][]localeItem)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadLocaleData 加载国际化数据
|
||||||
|
func LoadLocaleData(language string) []localeItem {
|
||||||
|
dictType := fmt.Sprintf("i18n_%s", language)
|
||||||
|
dictTypeList := systemService.NewSysDictTypeImpl.DictDataCache(dictType)
|
||||||
|
localeData := []localeItem{}
|
||||||
|
for _, v := range dictTypeList {
|
||||||
|
localeData = append(localeData, localeItem{
|
||||||
|
Key: v.DictLabel,
|
||||||
|
Value: v.DictValue,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
localeMap[language] = localeData
|
||||||
|
return localeData
|
||||||
|
}
|
||||||
|
|
||||||
|
// TKey 翻译键
|
||||||
|
func TKey(language, key string) string {
|
||||||
|
value := key
|
||||||
|
if key == "" {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
arr, ok := localeMap[language]
|
||||||
|
if !ok || len(arr) == 0 {
|
||||||
|
arr = LoadLocaleData(language)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range arr {
|
||||||
|
if v.Key == key {
|
||||||
|
value = v.Value
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
// TTemplate 翻译模板字符串
|
||||||
|
func TTemplate(language, key string, params map[string]any) string {
|
||||||
|
templateString := TKey(language, key)
|
||||||
|
|
||||||
|
re := regexp.MustCompile("{(.*?)}")
|
||||||
|
result := re.ReplaceAllStringFunc(templateString, func(match string) string {
|
||||||
|
key := match[1 : len(match)-1]
|
||||||
|
if val, ok := params[key]; ok {
|
||||||
|
return fmt.Sprint(val)
|
||||||
|
}
|
||||||
|
return match
|
||||||
|
})
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
@@ -90,7 +90,8 @@ func RateLimit(option LimitOption) gin.HandlerFunc {
|
|||||||
c.Header("X-RateLimit-Reset", fmt.Sprintf("%d", time.Now().Unix()+int64(rateTime))) // 重置时间戳
|
c.Header("X-RateLimit-Reset", fmt.Sprintf("%d", time.Now().Unix()+int64(rateTime))) // 重置时间戳
|
||||||
|
|
||||||
if rateCount >= option.Count {
|
if rateCount >= option.Count {
|
||||||
c.JSON(200, result.ErrMsg("访问过于频繁,请稍候再试"))
|
// 访问过于频繁,请稍候再试
|
||||||
|
c.JSON(200, result.ErrMsg("Visits are too frequent. Please try again later"))
|
||||||
c.Abort() // 停止执行后续的处理函数
|
c.Abort() // 停止执行后续的处理函数
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ func RepeatSubmit(interval int64) gin.HandlerFunc {
|
|||||||
|
|
||||||
// 小于间隔时间且参数内容一致
|
// 小于间隔时间且参数内容一致
|
||||||
if compareTime < interval && compareParams {
|
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()
|
c.Abort()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,14 +42,16 @@ func referer(c *gin.Context) {
|
|||||||
|
|
||||||
referer := c.GetHeader("Referer")
|
referer := c.GetHeader("Referer")
|
||||||
if referer == "" {
|
if referer == "" {
|
||||||
c.AbortWithStatusJSON(200, result.ErrMsg("无效 Referer 未知"))
|
// 无效 Referer 未知
|
||||||
|
c.AbortWithStatusJSON(200, result.ErrMsg("Invalid referer unknown"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取host
|
// 获取host
|
||||||
u, err := url.Parse(referer)
|
u, err := url.Parse(referer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.AbortWithStatusJSON(200, result.ErrMsg("无效 Referer 未知"))
|
// 无效 Referer 未知
|
||||||
|
c.AbortWithStatusJSON(200, result.ErrMsg("Invalid referer unknown"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
host := u.Host
|
host := u.Host
|
||||||
@@ -70,7 +72,8 @@ func referer(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
c.AbortWithStatusJSON(200, result.ErrMsg("无效 Referer "+host))
|
// 无效 Referer
|
||||||
|
c.AbortWithStatusJSON(200, result.ErrMsg("Invalid referer "+host))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"ems.agt/src/framework/utils/ip2region"
|
"ems.agt/src/framework/utils/ip2region"
|
||||||
"ems.agt/src/framework/utils/ua"
|
"ems.agt/src/framework/utils/ua"
|
||||||
"ems.agt/src/framework/vo"
|
"ems.agt/src/framework/vo"
|
||||||
|
"golang.org/x/text/language"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gin-gonic/gin/binding"
|
"github.com/gin-gonic/gin/binding"
|
||||||
@@ -81,13 +82,13 @@ func UaOsBrowser(c *gin.Context) (string, string) {
|
|||||||
userAgent := c.GetHeader("user-agent")
|
userAgent := c.GetHeader("user-agent")
|
||||||
uaInfo := ua.Info(userAgent)
|
uaInfo := ua.Info(userAgent)
|
||||||
|
|
||||||
browser := "未知 未知"
|
browser := "Unknown Unknown"
|
||||||
bName, bVersion := uaInfo.Browser()
|
bName, bVersion := uaInfo.Browser()
|
||||||
if bName != "" && bVersion != "" {
|
if bName != "" && bVersion != "" {
|
||||||
browser = bName + " " + bVersion
|
browser = bName + " " + bVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
os := "未知 未知"
|
os := "Unknown Unknown"
|
||||||
bos := uaInfo.OS()
|
bos := uaInfo.OS()
|
||||||
if bos != "" {
|
if bos != "" {
|
||||||
os = bos
|
os = bos
|
||||||
@@ -95,13 +96,27 @@ func UaOsBrowser(c *gin.Context) (string, string) {
|
|||||||
return os, browser
|
return os, browser
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AcceptLanguage 解析客户端接收语言 zh:中文 en: 英文
|
||||||
|
func AcceptLanguage(c *gin.Context) string {
|
||||||
|
preferredLanguage := language.English
|
||||||
|
acceptLanguage := c.GetHeader("Accept-Language")
|
||||||
|
tags, _, _ := language.ParseAcceptLanguage(acceptLanguage)
|
||||||
|
if len(tags) > 0 {
|
||||||
|
preferredLanguage = tags[0]
|
||||||
|
}
|
||||||
|
// 只取前缀
|
||||||
|
lang := preferredLanguage.String()
|
||||||
|
arr := strings.Split(lang, "-")
|
||||||
|
return arr[0]
|
||||||
|
}
|
||||||
|
|
||||||
// LoginUser 登录用户信息
|
// LoginUser 登录用户信息
|
||||||
func LoginUser(c *gin.Context) (vo.LoginUser, error) {
|
func LoginUser(c *gin.Context) (vo.LoginUser, error) {
|
||||||
value, exists := c.Get(common.CTX_LOGIN_USER)
|
value, exists := c.Get(common.CTX_LOGIN_USER)
|
||||||
if exists {
|
if exists {
|
||||||
return value.(vo.LoginUser), nil
|
return value.(vo.LoginUser), nil
|
||||||
}
|
}
|
||||||
return vo.LoginUser{}, fmt.Errorf("无效登录用户信息")
|
return vo.LoginUser{}, fmt.Errorf("invalid login user information")
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoginUserToUserID 登录用户信息-用户ID
|
// LoginUserToUserID 登录用户信息-用户ID
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ func WriterCSVFile(data [][]string, filePath string) error {
|
|||||||
// 确保文件夹路径存在
|
// 确保文件夹路径存在
|
||||||
err := os.MkdirAll(dirPath, os.ModePerm)
|
err := os.MkdirAll(dirPath, os.ModePerm)
|
||||||
if err != nil {
|
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 文件
|
// 打开 CSV 文件
|
||||||
file, err := os.Open(filePath)
|
file, err := os.Open(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("无法打开 CSV 文件:%v", err)
|
logger.Errorf("Open CSV file: %v", err)
|
||||||
return arr
|
return arr
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
@@ -62,7 +62,7 @@ func ReadCSVFile(filePath string) []map[string]string {
|
|||||||
// 读取 CSV 头部行
|
// 读取 CSV 头部行
|
||||||
header, err := reader.Read()
|
header, err := reader.Read()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("无法读取 CSV 头部行:%v", err)
|
logger.Errorf("Read CSV header rows: %v", err)
|
||||||
return arr
|
return arr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ func ReadSheet(filePath, sheetName string) ([]map[string]string, error) {
|
|||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := f.Close(); err != nil {
|
if err := f.Close(); err != nil {
|
||||||
logger.Errorf("工作表文件关闭失败 : %v", err)
|
logger.Errorf("ReadSheet to close worksheet file : %v", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ func ReadSheet(filePath, sheetName string) ([]map[string]string, error) {
|
|||||||
sheetName = "Sheet1"
|
sheetName = "Sheet1"
|
||||||
}
|
}
|
||||||
if visible, _ := f.GetSheetVisible(sheetName); !visible {
|
if visible, _ := f.GetSheetVisible(sheetName); !visible {
|
||||||
return data, fmt.Errorf("读取工作簿 %s 失败", sheetName)
|
return data, fmt.Errorf("failed to read workbook %s", sheetName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取工作簿记录
|
// 获取工作簿记录
|
||||||
@@ -99,7 +99,7 @@ func WriteSheet(headerCells map[string]string, dataCells []map[string]any, fileN
|
|||||||
f := excelize.NewFile()
|
f := excelize.NewFile()
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := f.Close(); err != nil {
|
if err := f.Close(); err != nil {
|
||||||
logger.Errorf("工作表文件关闭失败 : %v", err)
|
logger.Errorf("WriteSheet to close worksheet file: %v", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ func WriteSheet(headerCells map[string]string, dataCells []map[string]any, fileN
|
|||||||
}
|
}
|
||||||
index, err := f.NewSheet(sheetName)
|
index, err := f.NewSheet(sheetName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("创建工作表失败 %v", err)
|
return "", fmt.Errorf("failed to create worksheet %v", err)
|
||||||
}
|
}
|
||||||
// 设置工作簿的默认工作表
|
// 设置工作簿的默认工作表
|
||||||
f.SetActiveSheet(index)
|
f.SetActiveSheet(index)
|
||||||
@@ -143,12 +143,12 @@ func WriteSheet(headerCells map[string]string, dataCells []map[string]any, fileN
|
|||||||
|
|
||||||
// 创建文件目录
|
// 创建文件目录
|
||||||
if err := os.MkdirAll(filepath.Dir(saveFilePath), 0750); err != nil {
|
if err := os.MkdirAll(filepath.Dir(saveFilePath), 0750); err != nil {
|
||||||
return "", fmt.Errorf("创建保存文件失败 %v", err)
|
return "", fmt.Errorf("failed to create save file %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据指定路径保存文件
|
// 根据指定路径保存文件
|
||||||
if err := f.SaveAs(saveFilePath); err != nil {
|
if err := f.SaveAs(saveFilePath); err != nil {
|
||||||
return "", fmt.Errorf("保存工作表失败 %v", err)
|
return "", fmt.Errorf("failed to save worksheet %v", err)
|
||||||
}
|
}
|
||||||
return saveFilePath, nil
|
return saveFilePath, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package file
|
package file
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"path"
|
"path"
|
||||||
@@ -74,13 +73,13 @@ func generateFileName(fileName string) string {
|
|||||||
func isAllowWrite(fileName string, allowExts []string, fileSize int64) error {
|
func isAllowWrite(fileName string, allowExts []string, fileSize int64) error {
|
||||||
// 判断上传文件名称长度
|
// 判断上传文件名称长度
|
||||||
if len(fileName) > DEFAULT_FILE_NAME_LENGTH {
|
if len(fileName) > DEFAULT_FILE_NAME_LENGTH {
|
||||||
return fmt.Errorf("上传文件名称长度限制最长为 %d", DEFAULT_FILE_NAME_LENGTH)
|
return fmt.Errorf("the maximum length limit for uploading file names is %d", DEFAULT_FILE_NAME_LENGTH)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 最大上传文件大小
|
// 最大上传文件大小
|
||||||
maxFileSize := uploadFileSize()
|
maxFileSize := uploadFileSize()
|
||||||
if fileSize > maxFileSize {
|
if fileSize > maxFileSize {
|
||||||
return fmt.Errorf("最大上传文件大小 %s", parse.Bit(float64(maxFileSize)))
|
return fmt.Errorf("maximum upload file size %s", parse.Bit(float64(maxFileSize)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断文件拓展是否为允许的拓展类型
|
// 判断文件拓展是否为允许的拓展类型
|
||||||
@@ -96,7 +95,7 @@ func isAllowWrite(fileName string, allowExts []string, fileSize int64) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !hasExt {
|
if !hasExt {
|
||||||
return fmt.Errorf("上传文件类型不支持,仅支持以下类型:%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
|
return nil
|
||||||
@@ -108,7 +107,7 @@ func isAllowWrite(fileName string, allowExts []string, fileSize int64) error {
|
|||||||
func isAllowRead(filePath string) error {
|
func isAllowRead(filePath string) error {
|
||||||
// 禁止目录上跳级别
|
// 禁止目录上跳级别
|
||||||
if strings.Contains(filePath, "..") {
|
if strings.Contains(filePath, "..") {
|
||||||
return fmt.Errorf("禁止目录上跳级别")
|
return fmt.Errorf("prohibit jumping levels on the directory")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查允许下载的文件规则
|
// 检查允许下载的文件规则
|
||||||
@@ -121,7 +120,7 @@ func isAllowRead(filePath string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !hasExt {
|
if !hasExt {
|
||||||
return fmt.Errorf("非法下载的文件规则:%s", fileExt)
|
return fmt.Errorf("rules for illegally downloaded files: %s", fileExt)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -203,7 +202,7 @@ func ReadUploadFileStream(filePath, headerRange string) (map[string]any, error)
|
|||||||
result["chunkSize"] = end - start + 1
|
result["chunkSize"] = end - start + 1
|
||||||
byteArr, err := getFileStream(fileAsbPath, start, end)
|
byteArr, err := getFileStream(fileAsbPath, start, end)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return map[string]any{}, errors.New("读取文件失败")
|
return map[string]any{}, fmt.Errorf("fail to read file")
|
||||||
}
|
}
|
||||||
result["data"] = byteArr
|
result["data"] = byteArr
|
||||||
return result, nil
|
return result, nil
|
||||||
@@ -211,7 +210,7 @@ func ReadUploadFileStream(filePath, headerRange string) (map[string]any, error)
|
|||||||
|
|
||||||
byteArr, err := getFileStream(fileAsbPath, 0, fileSize)
|
byteArr, err := getFileStream(fileAsbPath, 0, fileSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return map[string]any{}, errors.New("读取文件失败")
|
return map[string]any{}, fmt.Errorf("fail to read file")
|
||||||
}
|
}
|
||||||
result["data"] = byteArr
|
result["data"] = byteArr
|
||||||
return result, nil
|
return result, nil
|
||||||
@@ -261,7 +260,7 @@ func ChunkCheckFile(identifier, originalFileName string) ([]string, error) {
|
|||||||
readPath := path.Join(dir, dirPath)
|
readPath := path.Join(dir, dirPath)
|
||||||
fileList, err := getDirFileNameList(readPath)
|
fileList, err := getDirFileNameList(readPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []string{}, errors.New("读取文件失败")
|
return []string{}, fmt.Errorf("fail to read file")
|
||||||
}
|
}
|
||||||
return fileList, nil
|
return fileList, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,10 +51,10 @@ func mergeToNewFile(dirPath string, writePath string, fileName string) error {
|
|||||||
// 读取目录下所有文件并排序,注意文件名称是否数值
|
// 读取目录下所有文件并排序,注意文件名称是否数值
|
||||||
fileNameList, err := getDirFileNameList(dirPath)
|
fileNameList, err := getDirFileNameList(dirPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("读取合并目标文件失败: %v", err)
|
return fmt.Errorf("failed to read merge target file: %v", err)
|
||||||
}
|
}
|
||||||
if len(fileNameList) <= 0 {
|
if len(fileNameList) <= 0 {
|
||||||
return fmt.Errorf("读取合并目标文件失败")
|
return fmt.Errorf("failed to read merge target file")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 排序
|
// 排序
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ func init() {
|
|||||||
func RegionSearchByIp(ip string) (string, int, int64) {
|
func RegionSearchByIp(ip string) (string, int, int64) {
|
||||||
ip = ClientIP(ip)
|
ip = ClientIP(ip)
|
||||||
if ip == LOCAT_HOST {
|
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()
|
tStart := time.Now()
|
||||||
region, err := searcher.SearchByStr(ip)
|
region, err := searcher.SearchByStr(ip)
|
||||||
@@ -59,17 +60,20 @@ func RegionSearchByIp(ip string) (string, int, int64) {
|
|||||||
func RealAddressByIp(ip string) string {
|
func RealAddressByIp(ip string) string {
|
||||||
ip = ClientIP(ip)
|
ip = ClientIP(ip)
|
||||||
if ip == LOCAT_HOST {
|
if ip == LOCAT_HOST {
|
||||||
return "内网IP"
|
return "Intranet IP" // 内网IP
|
||||||
}
|
}
|
||||||
region, err := searcher.SearchByStr(ip)
|
region, err := searcher.SearchByStr(ip)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("failed to SearchIP(%s): %s\n", ip, err)
|
logger.Errorf("failed to SearchIP(%s): %s\n", ip, err)
|
||||||
return "未知"
|
return "unknown" // 未知
|
||||||
}
|
}
|
||||||
parts := strings.Split(region, "|")
|
parts := strings.Split(region, "|")
|
||||||
province := parts[2]
|
province := parts[2]
|
||||||
city := parts[3]
|
city := parts[3]
|
||||||
if province == "0" && city != "0" {
|
if province == "0" && city != "0" {
|
||||||
|
if city == "内网IP" {
|
||||||
|
return "Intranet IP" // 内网IP
|
||||||
|
}
|
||||||
return city
|
return city
|
||||||
}
|
}
|
||||||
return province + " " + city
|
return province + " " + city
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func FileSCPNeToLocal(neIp, nePath, localPath string) error {
|
|||||||
// 确保文件夹路径存在
|
// 确保文件夹路径存在
|
||||||
err := os.MkdirAll(dirPath, os.ModePerm)
|
err := os.MkdirAll(dirPath, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("创建文件夹失败 CreateFile %v", err)
|
log.Errorf("FileSCPNeToLocal MkdirAll err %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package token
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"ems.agt/src/framework/config"
|
"ems.agt/src/framework/config"
|
||||||
@@ -124,13 +124,14 @@ func Verify(tokenString string) (jwt.MapClaims, error) {
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("token String Verify : %v", err)
|
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 {
|
if claims, ok := token.Claims.(jwt.MapClaims); ok && token.Valid {
|
||||||
return claims, nil
|
return claims, nil
|
||||||
}
|
}
|
||||||
return nil, errors.New("token valid error")
|
return nil, fmt.Errorf("token valid error")
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoginUser 缓存的登录用户信息
|
// LoginUser 缓存的登录用户信息
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ func Setup(router *gin.Engine) {
|
|||||||
// 通用请求
|
// 通用请求
|
||||||
commonGroup := router.Group("/common")
|
commonGroup := router.Group("/common")
|
||||||
{
|
{
|
||||||
commonGroup.GET("/hash", middleware.PreAuthorize(nil), controller.NewCommont.Hash)
|
commonGroup.POST("/hash", middleware.PreAuthorize(nil), controller.NewCommont.Hash)
|
||||||
|
commonGroup.GET("/i18n", controller.NewCommont.I18n)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 文件操作处理
|
// 文件操作处理
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ type AccountController struct {
|
|||||||
func (s *AccountController) Login(c *gin.Context) {
|
func (s *AccountController) Login(c *gin.Context) {
|
||||||
var loginBody commonModel.LoginBody
|
var loginBody commonModel.LoginBody
|
||||||
if err := c.ShouldBindJSON(&loginBody); err != nil {
|
if err := c.ShouldBindJSON(&loginBody); err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,8 +74,9 @@ func (s *AccountController) Login(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
s.accountService.UpdateLoginDateAndIP(&loginUser)
|
s.accountService.UpdateLoginDateAndIP(&loginUser)
|
||||||
|
// 登录成功
|
||||||
s.sysLogLoginService.CreateSysLogLogin(
|
s.sysLogLoginService.CreateSysLogLogin(
|
||||||
loginBody.Username, commonConstants.STATUS_YES, "登录成功",
|
loginBody.Username, commonConstants.STATUS_YES, "Login Successful",
|
||||||
ipaddr, location, os, browser,
|
ipaddr, location, os, browser,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -133,13 +134,13 @@ func (s *AccountController) Logout(c *gin.Context) {
|
|||||||
// 当前请求信息
|
// 当前请求信息
|
||||||
ipaddr, location := ctxUtils.IPAddrLocation(c)
|
ipaddr, location := ctxUtils.IPAddrLocation(c)
|
||||||
os, browser := ctxUtils.UaOsBrowser(c)
|
os, browser := ctxUtils.UaOsBrowser(c)
|
||||||
// 创建系统访问记录
|
// 创建系统访问记录 退出成功
|
||||||
s.sysLogLoginService.CreateSysLogLogin(
|
s.sysLogLoginService.CreateSysLogLogin(
|
||||||
userName, commonConstants.STATUS_YES, "退出成功",
|
userName, commonConstants.STATUS_YES, "Exit successful",
|
||||||
ipaddr, location, os, browser,
|
ipaddr, location, os, browser,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(200, result.OkMsg("退出成功"))
|
c.JSON(200, result.OkMsg("Exit successful"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"ems.agt/src/framework/i18n"
|
||||||
|
"ems.agt/src/framework/utils/ctx"
|
||||||
"ems.agt/src/framework/vo/result"
|
"ems.agt/src/framework/vo/result"
|
||||||
commonService "ems.agt/src/modules/common/service"
|
commonService "ems.agt/src/modules/common/service"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -21,11 +23,35 @@ type CommontController struct {
|
|||||||
|
|
||||||
// 哈希加密
|
// 哈希加密
|
||||||
//
|
//
|
||||||
// GET /hash
|
// POST /hash
|
||||||
func (s *CommontController) Hash(c *gin.Context) {
|
func (s *CommontController) Hash(c *gin.Context) {
|
||||||
c.String(200, "commont Hash")
|
c.String(200, "commont Hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 多语言处理
|
||||||
|
//
|
||||||
|
// GET /i18n
|
||||||
|
func (s *CommontController) I18n(c *gin.Context) {
|
||||||
|
language := ctx.AcceptLanguage(c)
|
||||||
|
|
||||||
|
i18nLang := i18n.TKey(language, "i18n")
|
||||||
|
hello := i18n.TKey(language, "hello")
|
||||||
|
ivs := i18n.TTemplate(language, "errorFields", nil)
|
||||||
|
errorFields := i18n.TTemplate(language, "errorFields", map[string]any{
|
||||||
|
"num": 1000,
|
||||||
|
"hello": "你好",
|
||||||
|
"h2o2": false,
|
||||||
|
"fileName": " ====",
|
||||||
|
})
|
||||||
|
c.JSON(200, map[string]any{
|
||||||
|
"lang": language,
|
||||||
|
"i18nLang": i18nLang,
|
||||||
|
"ivs": ivs,
|
||||||
|
"hello": hello,
|
||||||
|
"errorFields": errorFields,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 系统可暴露的配置信息
|
// 系统可暴露的配置信息
|
||||||
//
|
//
|
||||||
// GET /sys-conf
|
// GET /sys-conf
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ type FileController struct{}
|
|||||||
func (s *FileController) Download(c *gin.Context) {
|
func (s *FileController) Download(c *gin.Context) {
|
||||||
filePath := c.Param("filePath")
|
filePath := c.Param("filePath")
|
||||||
if len(filePath) < 8 {
|
if len(filePath) < 8 {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// base64解析出地址
|
// base64解析出地址
|
||||||
@@ -71,13 +71,13 @@ func (s *FileController) Upload(c *gin.Context) {
|
|||||||
// 上传的文件
|
// 上传的文件
|
||||||
formFile, err := c.FormFile("file")
|
formFile, err := c.FormFile("file")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 子路径
|
// 子路径
|
||||||
subPath := c.PostForm("subPath")
|
subPath := c.PostForm("subPath")
|
||||||
if _, ok := uploadsubpath.UploadSubpath[subPath]; !ok {
|
if _, ok := uploadsubpath.UploadSubpath[subPath]; !ok {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ func (s *FileController) ChunkCheck(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := c.ShouldBindJSON(&body)
|
err := c.ShouldBindJSON(&body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,11 +136,11 @@ func (s *FileController) ChunkMerge(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := c.ShouldBindJSON(&body)
|
err := c.ShouldBindJSON(&body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _, ok := uploadsubpath.UploadSubpath[body.SubPath]; !ok {
|
if _, ok := uploadsubpath.UploadSubpath[body.SubPath]; !ok {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ func (s *FileController) ChunkUpload(c *gin.Context) {
|
|||||||
// 上传的文件
|
// 上传的文件
|
||||||
formFile, err := c.FormFile("file")
|
formFile, err := c.FormFile("file")
|
||||||
if index == "" || identifier == "" || err != nil {
|
if index == "" || identifier == "" || err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ type IndexController struct{}
|
|||||||
func (s *IndexController) Handler(c *gin.Context) {
|
func (s *IndexController) Handler(c *gin.Context) {
|
||||||
name := config.Get("framework.name").(string)
|
name := config.Get("framework.name").(string)
|
||||||
version := config.Get("framework.version").(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)))
|
c.JSON(200, result.OkMsg(fmt.Sprintf(str, name, version)))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,21 +34,24 @@ type RegisterController struct {
|
|||||||
func (s *RegisterController) Register(c *gin.Context) {
|
func (s *RegisterController) Register(c *gin.Context) {
|
||||||
var registerBody commonModel.RegisterBody
|
var registerBody commonModel.RegisterBody
|
||||||
if err := c.ShouldBindJSON(®isterBody); err != nil {
|
if err := c.ShouldBindJSON(®isterBody); err != nil {
|
||||||
c.JSON(400, result.ErrMsg("参数错误"))
|
c.JSON(400, result.ErrMsg("parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断必传参数
|
// 判断必传参数
|
||||||
if !regular.ValidUsername(registerBody.Username) {
|
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
|
return
|
||||||
}
|
}
|
||||||
if !regular.ValidPassword(registerBody.Password) {
|
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
|
return
|
||||||
}
|
}
|
||||||
if registerBody.Password != registerBody.ConfirmPassword {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,12 +77,13 @@ func (s *RegisterController) Register(c *gin.Context) {
|
|||||||
|
|
||||||
userID, err := s.registerService.ByUserName(registerBody.Username, registerBody.Password, registerBody.UserType)
|
userID, err := s.registerService.ByUserName(registerBody.Username, registerBody.Password, registerBody.UserType)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
msg := registerBody.Username + " 注册成功 " + userID
|
msg := registerBody.Username + " registered success " + userID
|
||||||
s.sysLogLoginService.CreateSysLogLogin(
|
s.sysLogLoginService.CreateSysLogLogin(
|
||||||
registerBody.Username, commonConstants.STATUS_YES, msg,
|
registerBody.Username, commonConstants.STATUS_YES, msg,
|
||||||
ipaddr, location, os, browser,
|
ipaddr, location, os, browser,
|
||||||
)
|
)
|
||||||
c.JSON(200, result.OkMsg("注册成功"))
|
// 注册成功
|
||||||
|
c.JSON(200, result.OkMsg("registered success"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(200, result.ErrMsg(err.Error()))
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -45,16 +44,19 @@ func (s *AccountImpl) ValidateCaptcha(code, uuid string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if code == "" || uuid == "" {
|
if code == "" || uuid == "" {
|
||||||
return errors.New("验证码信息错误")
|
// 验证码信息错误
|
||||||
|
return fmt.Errorf("captcha message error")
|
||||||
}
|
}
|
||||||
verifyKey := cachekey.CAPTCHA_CODE_KEY + uuid
|
verifyKey := cachekey.CAPTCHA_CODE_KEY + uuid
|
||||||
captcha, _ := redis.Get("", verifyKey)
|
captcha, _ := redis.Get("", verifyKey)
|
||||||
if captcha == "" {
|
if captcha == "" {
|
||||||
return errors.New("验证码已失效")
|
// 验证码已失效
|
||||||
|
return fmt.Errorf("captcha is no longer valid")
|
||||||
}
|
}
|
||||||
redis.Del("", verifyKey)
|
redis.Del("", verifyKey)
|
||||||
if captcha != code {
|
if captcha != code {
|
||||||
return errors.New("验证码错误")
|
// 验证码错误
|
||||||
|
return fmt.Errorf("captcha error")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -72,20 +74,22 @@ func (s *AccountImpl) LoginByUsername(username, password string) (vo.LoginUser,
|
|||||||
// 查询用户登录账号
|
// 查询用户登录账号
|
||||||
sysUser := s.sysUserService.SelectUserByUserName(username)
|
sysUser := s.sysUserService.SelectUserByUserName(username)
|
||||||
if sysUser.UserName != 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 {
|
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 {
|
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)
|
compareBool := crypto.BcryptCompare(password, sysUser.Password)
|
||||||
if !compareBool {
|
if !compareBool {
|
||||||
redis.SetByExpire("", retrykey, retryCount+1, lockTime)
|
redis.SetByExpire("", retrykey, retryCount+1, lockTime)
|
||||||
return loginUser, errors.New("用户不存在或密码错误")
|
// 用户不存在或密码错误
|
||||||
|
return loginUser, fmt.Errorf("user does not exist or wrong password")
|
||||||
} else {
|
} else {
|
||||||
// 清除错误记录次数
|
// 清除错误记录次数
|
||||||
s.ClearLoginRecordCache(username)
|
s.ClearLoginRecordCache(username)
|
||||||
@@ -144,8 +148,9 @@ func (s *AccountImpl) passwordRetryCount(username string) (string, int64, time.D
|
|||||||
// 是否超过错误值
|
// 是否超过错误值
|
||||||
retryCountInt64 := parse.Number(retryCount)
|
retryCountInt64 := parse.Number(retryCount)
|
||||||
if retryCountInt64 >= int64(maxRetryCount) {
|
if retryCountInt64 >= int64(maxRetryCount) {
|
||||||
msg := fmt.Sprintf("密码输入错误 %d 次,帐户锁定 %d 分钟", maxRetryCount, lockTime)
|
// 密码输入错误 %d 次,帐户锁定 %d 分钟
|
||||||
return retrykey, retryCountInt64, time.Duration(lockTime) * time.Minute, errors.New(msg)
|
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
|
return retrykey, retryCountInt64, time.Duration(lockTime) * time.Minute, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"ems.agt/src/framework/constants/cachekey"
|
"ems.agt/src/framework/constants/cachekey"
|
||||||
@@ -37,16 +36,16 @@ func (s *RegisterImpl) ValidateCaptcha(code, uuid string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if code == "" || uuid == "" {
|
if code == "" || uuid == "" {
|
||||||
return errors.New("验证码信息错误")
|
return fmt.Errorf("verification code information error")
|
||||||
}
|
}
|
||||||
verifyKey := cachekey.CAPTCHA_CODE_KEY + uuid
|
verifyKey := cachekey.CAPTCHA_CODE_KEY + uuid
|
||||||
captcha, err := redis.Get("", verifyKey)
|
captcha, err := redis.Get("", verifyKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("验证码已失效")
|
return fmt.Errorf("the verification code has expired")
|
||||||
}
|
}
|
||||||
redis.Del("", verifyKey)
|
redis.Del("", verifyKey)
|
||||||
if captcha != code {
|
if captcha != code {
|
||||||
return errors.New("验证码错误")
|
return fmt.Errorf("verification code error")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -57,13 +56,13 @@ func (s *RegisterImpl) ByUserName(username, password, userType string) (string,
|
|||||||
registerUserStr := s.sysConfigService.SelectConfigValueByKey("sys.account.registerUser")
|
registerUserStr := s.sysConfigService.SelectConfigValueByKey("sys.account.registerUser")
|
||||||
captchaEnabled := parse.Boolean(registerUserStr)
|
captchaEnabled := parse.Boolean(registerUserStr)
|
||||||
if !captchaEnabled {
|
if !captchaEnabled {
|
||||||
return "", fmt.Errorf("注册用户【%s】失败,很抱歉,系统已关闭外部用户注册通道", username)
|
return "", fmt.Errorf("failed to register user [%s]. Sorry, the system has closed the external user registration channel", username)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查用户登录账号是否唯一
|
// 检查用户登录账号是否唯一
|
||||||
uniqueUserName := s.sysUserService.CheckUniqueUserName(username, "")
|
uniqueUserName := s.sysUserService.CheckUniqueUserName(username, "")
|
||||||
if !uniqueUserName {
|
if !uniqueUserName {
|
||||||
return "", fmt.Errorf("注册用户【%s】失败,注册账号已存在", username)
|
return "", fmt.Errorf("failed to register user [%s], registered account already exists", username)
|
||||||
}
|
}
|
||||||
|
|
||||||
sysUser := systemModel.SysUser{
|
sysUser := systemModel.SysUser{
|
||||||
@@ -72,7 +71,7 @@ func (s *RegisterImpl) ByUserName(username, password, userType string) (string,
|
|||||||
Password: password, // 原始密码
|
Password: password, // 原始密码
|
||||||
Status: common.STATUS_YES, // 账号状态激活
|
Status: common.STATUS_YES, // 账号状态激活
|
||||||
DeptID: "100", // 归属部门为根节点
|
DeptID: "100", // 归属部门为根节点
|
||||||
CreateBy: "注册", // 创建来源
|
CreateBy: "register", // 创建来源
|
||||||
}
|
}
|
||||||
// 标记用户类型
|
// 标记用户类型
|
||||||
if userType == "" {
|
if userType == "" {
|
||||||
@@ -87,7 +86,7 @@ func (s *RegisterImpl) ByUserName(username, password, userType string) (string,
|
|||||||
if insertId != "" {
|
if insertId != "" {
|
||||||
return insertId, nil
|
return insertId, nil
|
||||||
}
|
}
|
||||||
return "", fmt.Errorf("注册用户【%s】失败,请联系系统管理人员", username)
|
return "", fmt.Errorf("failed to register user [%s]. Please contact the system administrator", username)
|
||||||
}
|
}
|
||||||
|
|
||||||
// registerRoleInit 注册初始角色
|
// registerRoleInit 注册初始角色
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ func (s *MonitorController) Load(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := c.ShouldBindQuery(&querys)
|
err := c.ShouldBindQuery(&querys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ func (s *SysCacheController) Info(c *gin.Context) {
|
|||||||
// GET /getNames
|
// GET /getNames
|
||||||
func (s *SysCacheController) Names(c *gin.Context) {
|
func (s *SysCacheController) Names(c *gin.Context) {
|
||||||
caches := []model.SysCache{
|
caches := []model.SysCache{
|
||||||
model.NewSysCacheNames("用户信息", cachekey.LOGIN_TOKEN_KEY),
|
model.NewSysCacheNames("user", cachekey.LOGIN_TOKEN_KEY),
|
||||||
model.NewSysCacheNames("配置信息", cachekey.SYS_CONFIG_KEY),
|
model.NewSysCacheNames("configuration", cachekey.SYS_CONFIG_KEY),
|
||||||
model.NewSysCacheNames("数据字典", cachekey.SYS_DICT_KEY),
|
model.NewSysCacheNames("dictionary", cachekey.SYS_DICT_KEY),
|
||||||
model.NewSysCacheNames("验证码", cachekey.CAPTCHA_CODE_KEY),
|
model.NewSysCacheNames("captcha", cachekey.CAPTCHA_CODE_KEY),
|
||||||
model.NewSysCacheNames("防重提交", cachekey.REPEAT_SUBMIT_KEY),
|
model.NewSysCacheNames("anti-submission", cachekey.REPEAT_SUBMIT_KEY),
|
||||||
model.NewSysCacheNames("限流处理", cachekey.RATE_LIMIT_KEY),
|
model.NewSysCacheNames("current-limiting", cachekey.RATE_LIMIT_KEY),
|
||||||
model.NewSysCacheNames("密码错误次数", cachekey.PWD_ERR_CNT_KEY),
|
model.NewSysCacheNames("password-errors-number", cachekey.PWD_ERR_CNT_KEY),
|
||||||
}
|
}
|
||||||
c.JSON(200, result.OkData(caches))
|
c.JSON(200, result.OkData(caches))
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ func (s *SysCacheController) Names(c *gin.Context) {
|
|||||||
func (s *SysCacheController) Keys(c *gin.Context) {
|
func (s *SysCacheController) Keys(c *gin.Context) {
|
||||||
cacheName := c.Param("cacheName")
|
cacheName := c.Param("cacheName")
|
||||||
if cacheName == "" {
|
if cacheName == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
caches := []model.SysCache{}
|
caches := []model.SysCache{}
|
||||||
@@ -71,7 +71,7 @@ func (s *SysCacheController) Value(c *gin.Context) {
|
|||||||
cacheName := c.Param("cacheName")
|
cacheName := c.Param("cacheName")
|
||||||
cacheKey := c.Param("cacheKey")
|
cacheKey := c.Param("cacheKey")
|
||||||
if cacheName == "" || cacheKey == "" {
|
if cacheName == "" || cacheKey == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ func (s *SysCacheController) Value(c *gin.Context) {
|
|||||||
func (s *SysCacheController) ClearCacheName(c *gin.Context) {
|
func (s *SysCacheController) ClearCacheName(c *gin.Context) {
|
||||||
cacheName := c.Param("cacheName")
|
cacheName := c.Param("cacheName")
|
||||||
if cacheName == "" {
|
if cacheName == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ func (s *SysCacheController) ClearCacheKey(c *gin.Context) {
|
|||||||
cacheName := c.Param("cacheName")
|
cacheName := c.Param("cacheName")
|
||||||
cacheKey := c.Param("cacheKey")
|
cacheKey := c.Param("cacheKey")
|
||||||
if cacheName == "" || cacheKey == "" {
|
if cacheName == "" || cacheKey == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,12 +131,12 @@ func (s *SysCacheController) ClearCacheKey(c *gin.Context) {
|
|||||||
// DELETE /clearCacheSafe
|
// DELETE /clearCacheSafe
|
||||||
func (s *SysCacheController) ClearCacheSafe(c *gin.Context) {
|
func (s *SysCacheController) ClearCacheSafe(c *gin.Context) {
|
||||||
caches := []model.SysCache{
|
caches := []model.SysCache{
|
||||||
model.NewSysCacheNames("配置信息", cachekey.SYS_CONFIG_KEY),
|
model.NewSysCacheNames("configuration", cachekey.SYS_CONFIG_KEY),
|
||||||
model.NewSysCacheNames("数据字典", cachekey.SYS_DICT_KEY),
|
model.NewSysCacheNames("dictionary", cachekey.SYS_DICT_KEY),
|
||||||
model.NewSysCacheNames("验证码", cachekey.CAPTCHA_CODE_KEY),
|
model.NewSysCacheNames("captcha", cachekey.CAPTCHA_CODE_KEY),
|
||||||
model.NewSysCacheNames("防重提交", cachekey.REPEAT_SUBMIT_KEY),
|
model.NewSysCacheNames("anti-submission", cachekey.REPEAT_SUBMIT_KEY),
|
||||||
model.NewSysCacheNames("限流处理", cachekey.RATE_LIMIT_KEY),
|
model.NewSysCacheNames("current-limiting", cachekey.RATE_LIMIT_KEY),
|
||||||
model.NewSysCacheNames("密码错误次数", cachekey.PWD_ERR_CNT_KEY),
|
model.NewSysCacheNames("password-errors-number", cachekey.PWD_ERR_CNT_KEY),
|
||||||
}
|
}
|
||||||
for _, v := range caches {
|
for _, v := range caches {
|
||||||
cacheKeys, err := redis.GetKeys("", v.CacheName+":*")
|
cacheKeys, err := redis.GetKeys("", v.CacheName+":*")
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ func (s *SysJobController) List(c *gin.Context) {
|
|||||||
func (s *SysJobController) Info(c *gin.Context) {
|
func (s *SysJobController) Info(c *gin.Context) {
|
||||||
jobId := c.Param("jobId")
|
jobId := c.Param("jobId")
|
||||||
if jobId == "" {
|
if jobId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,20 +69,22 @@ func (s *SysJobController) Add(c *gin.Context) {
|
|||||||
var body model.SysJob
|
var body model.SysJob
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.JobID != "" {
|
if err != nil || body.JobID != "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查cron表达式格式
|
// 检查cron表达式格式
|
||||||
if parse.CronExpression(body.CronExpression) == 0 {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查任务调用传入参数是否json格式
|
// 检查任务调用传入参数是否json格式
|
||||||
if body.TargetParams != "" {
|
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 {
|
if len(body.TargetParams) < 7 {
|
||||||
c.JSON(200, result.ErrMsg(msg))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
@@ -96,7 +98,8 @@ func (s *SysJobController) Add(c *gin.Context) {
|
|||||||
// 检查属性值唯一
|
// 检查属性值唯一
|
||||||
uniqueJob := s.sysJobService.CheckUniqueJobName(body.JobName, body.JobGroup, "")
|
uniqueJob := s.sysJobService.CheckUniqueJobName(body.JobName, body.JobGroup, "")
|
||||||
if !uniqueJob {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -117,20 +120,22 @@ func (s *SysJobController) Edit(c *gin.Context) {
|
|||||||
var body model.SysJob
|
var body model.SysJob
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.JobID == "" {
|
if err != nil || body.JobID == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查cron表达式格式
|
// 检查cron表达式格式
|
||||||
if parse.CronExpression(body.CronExpression) == 0 {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查任务调用传入参数是否json格式
|
// 检查任务调用传入参数是否json格式
|
||||||
if body.TargetParams != "" {
|
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 {
|
if len(body.TargetParams) < 7 {
|
||||||
c.JSON(200, result.ErrMsg(msg))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
@@ -144,7 +149,8 @@ func (s *SysJobController) Edit(c *gin.Context) {
|
|||||||
// 检查属性值唯一
|
// 检查属性值唯一
|
||||||
uniqueJob := s.sysJobService.CheckUniqueJobName(body.JobName, body.JobGroup, body.JobID)
|
uniqueJob := s.sysJobService.CheckUniqueJobName(body.JobName, body.JobGroup, body.JobID)
|
||||||
if !uniqueJob {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -164,7 +170,7 @@ func (s *SysJobController) Edit(c *gin.Context) {
|
|||||||
func (s *SysJobController) Remove(c *gin.Context) {
|
func (s *SysJobController) Remove(c *gin.Context) {
|
||||||
jobIds := c.Param("jobIds")
|
jobIds := c.Param("jobIds")
|
||||||
if jobIds == "" {
|
if jobIds == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 处理字符转id数组后去重
|
// 处理字符转id数组后去重
|
||||||
@@ -179,7 +185,7 @@ func (s *SysJobController) Remove(c *gin.Context) {
|
|||||||
c.JSON(200, result.ErrMsg(err.Error()))
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
msg := fmt.Sprintf("Deleted successfully: %d", rows)
|
||||||
c.JSON(200, result.OkMsg(msg))
|
c.JSON(200, result.OkMsg(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,20 +201,22 @@ func (s *SysJobController) Status(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
job := s.sysJobService.SelectJobById(body.JobId)
|
job := s.sysJobService.SelectJobById(body.JobId)
|
||||||
if job.JobID != body.JobId {
|
if job.JobID != body.JobId {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问调度任务数据!"))
|
// 没有可访问调度任务数据!
|
||||||
|
c.JSON(200, result.ErrMsg("No accessible scheduling task data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 与旧值相等不变更
|
// 与旧值相等不变更
|
||||||
if job.Status == body.Status {
|
if job.Status == body.Status {
|
||||||
c.JSON(200, result.ErrMsg("变更状态与旧值相等!"))
|
// 变更状态与旧值相等!
|
||||||
|
c.JSON(200, result.ErrMsg("Change status equals old value!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,14 +237,15 @@ func (s *SysJobController) Status(c *gin.Context) {
|
|||||||
func (s *SysJobController) Run(c *gin.Context) {
|
func (s *SysJobController) Run(c *gin.Context) {
|
||||||
jobId := c.Param("jobId")
|
jobId := c.Param("jobId")
|
||||||
if jobId == "" {
|
if jobId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
job := s.sysJobService.SelectJobById(jobId)
|
job := s.sysJobService.SelectJobById(jobId)
|
||||||
if job.JobID != jobId {
|
if job.JobID != jobId {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问调度任务数据!"))
|
// 没有可访问调度任务数据!
|
||||||
|
c.JSON(200, result.ErrMsg("No accessible scheduling task data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +273,8 @@ func (s *SysJobController) Export(c *gin.Context) {
|
|||||||
querys := ctx.BodyJSONMap(c)
|
querys := ctx.BodyJSONMap(c)
|
||||||
data := s.sysJobService.SelectJobPage(querys)
|
data := s.sysJobService.SelectJobPage(querys)
|
||||||
if data["total"].(int64) == 0 {
|
if data["total"].(int64) == 0 {
|
||||||
c.JSON(200, result.ErrMsg("导出数据记录为空"))
|
// 导出数据记录为空
|
||||||
|
c.JSON(200, result.ErrMsg("Export data record is empty"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rows := data["rows"].([]model.SysJob)
|
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())
|
fileName := fmt.Sprintf("job_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
||||||
// 第一行表头标题
|
// 第一行表头标题
|
||||||
headerCells := map[string]string{
|
headerCells := map[string]string{
|
||||||
"A1": "任务编号",
|
"A1": "JobID",
|
||||||
"B1": "任务名称",
|
"B1": "JobName",
|
||||||
"C1": "任务组名",
|
"C1": "JobGroupName",
|
||||||
"D1": "调用目标",
|
"D1": "InvokeTarget",
|
||||||
"E1": "传入参数",
|
"E1": "TargetParams",
|
||||||
"F1": "执行表达式",
|
"F1": "CronExpression",
|
||||||
"G1": "出错策略",
|
"G1": "MisfirePolicy",
|
||||||
"H1": "并发执行",
|
"H1": "Concurrent",
|
||||||
"I1": "任务状态",
|
"I1": "Status",
|
||||||
"J1": "备注说明",
|
"J1": "Remark",
|
||||||
}
|
}
|
||||||
// 读取任务组名字典数据
|
// 读取任务组名字典数据
|
||||||
dictSysJobGroup := s.sysDictDataService.SelectDictDataByType("sys_job_group")
|
dictSysJobGroup := s.sysDictDataService.SelectDictDataByType("sys_job_group")
|
||||||
@@ -298,20 +308,20 @@ func (s *SysJobController) Export(c *gin.Context) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
misfirePolicy := "放弃执行"
|
misfirePolicy := "Abandon execution"
|
||||||
if row.MisfirePolicy == "1" {
|
if row.MisfirePolicy == "1" {
|
||||||
misfirePolicy = "立即执行"
|
misfirePolicy = "Execute immediately"
|
||||||
} else if row.MisfirePolicy == "2" {
|
} else if row.MisfirePolicy == "2" {
|
||||||
misfirePolicy = "执行一次"
|
misfirePolicy = "Execute once"
|
||||||
}
|
}
|
||||||
concurrent := "禁止"
|
concurrent := "prohibit"
|
||||||
if row.Concurrent == "1" {
|
if row.Concurrent == "1" {
|
||||||
concurrent = "允许"
|
concurrent = "allow"
|
||||||
}
|
}
|
||||||
// 状态
|
// 状态
|
||||||
statusValue := "失败"
|
statusValue := "fail"
|
||||||
if row.Status == "1" {
|
if row.Status == "1" {
|
||||||
statusValue = "成功"
|
statusValue = "successes"
|
||||||
}
|
}
|
||||||
dataCells = append(dataCells, map[string]any{
|
dataCells = append(dataCells, map[string]any{
|
||||||
"A" + idx: row.JobID,
|
"A" + idx: row.JobID,
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ func (s *SysJobLogController) List(c *gin.Context) {
|
|||||||
func (s *SysJobLogController) Info(c *gin.Context) {
|
func (s *SysJobLogController) Info(c *gin.Context) {
|
||||||
jobLogId := c.Param("jobLogId")
|
jobLogId := c.Param("jobLogId")
|
||||||
if jobLogId == "" {
|
if jobLogId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := s.sysJobLogService.SelectJobLogById(jobLogId)
|
data := s.sysJobLogService.SelectJobLogById(jobLogId)
|
||||||
@@ -67,7 +67,7 @@ func (s *SysJobLogController) Info(c *gin.Context) {
|
|||||||
func (s *SysJobLogController) Remove(c *gin.Context) {
|
func (s *SysJobLogController) Remove(c *gin.Context) {
|
||||||
jobLogIds := c.Param("jobLogIds")
|
jobLogIds := c.Param("jobLogIds")
|
||||||
if jobLogIds == "" {
|
if jobLogIds == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +80,8 @@ func (s *SysJobLogController) Remove(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
rows := s.sysJobLogService.DeleteJobLogByIds(uniqueIDs)
|
rows := s.sysJobLogService.DeleteJobLogByIds(uniqueIDs)
|
||||||
if rows > 0 {
|
if rows > 0 {
|
||||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
// 删除成功:%d
|
||||||
|
msg := fmt.Sprintf("Deleted successfully: %d", rows)
|
||||||
c.JSON(200, result.OkMsg(msg))
|
c.JSON(200, result.OkMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -107,7 +108,7 @@ func (s *SysJobLogController) Export(c *gin.Context) {
|
|||||||
querys := ctx.BodyJSONMap(c)
|
querys := ctx.BodyJSONMap(c)
|
||||||
data := s.sysJobLogService.SelectJobLogPage(querys)
|
data := s.sysJobLogService.SelectJobLogPage(querys)
|
||||||
if data["total"].(int64) == 0 {
|
if data["total"].(int64) == 0 {
|
||||||
c.JSON(200, result.ErrMsg("导出数据记录为空"))
|
c.JSON(200, result.ErrMsg("Export data record is empty"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rows := data["rows"].([]model.SysJobLog)
|
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())
|
fileName := fmt.Sprintf("jobLog_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
||||||
// 第一行表头标题
|
// 第一行表头标题
|
||||||
headerCells := map[string]string{
|
headerCells := map[string]string{
|
||||||
"A1": "日志序号",
|
"A1": "JobLogID",
|
||||||
"B1": "任务名称",
|
"B1": "JobName",
|
||||||
"C1": "任务组名",
|
"C1": "JobGroupName",
|
||||||
"D1": "调用目标",
|
"D1": "InvokeTarget",
|
||||||
"E1": "传入参数",
|
"E1": "TargetParams",
|
||||||
"F1": "日志信息",
|
"F1": "JobMsg",
|
||||||
"G1": "执行状态",
|
"G1": "Status",
|
||||||
"H1": "记录时间",
|
"H1": "Time",
|
||||||
}
|
}
|
||||||
// 读取任务组名字典数据
|
// 读取任务组名字典数据
|
||||||
dictSysJobGroup := s.sysDictDataService.SelectDictDataByType("sys_job_group")
|
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" {
|
if row.Status == "1" {
|
||||||
statusValue = "成功"
|
statusValue = "Success"
|
||||||
}
|
}
|
||||||
dataCells = append(dataCells, map[string]any{
|
dataCells = append(dataCells, map[string]any{
|
||||||
"A" + idx: row.JobLogID,
|
"A" + idx: row.JobLogID,
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ func (s *SysUserOnlineController) List(c *gin.Context) {
|
|||||||
func (s *SysUserOnlineController) ForceLogout(c *gin.Context) {
|
func (s *SysUserOnlineController) ForceLogout(c *gin.Context) {
|
||||||
tokenId := c.Param("tokenId")
|
tokenId := c.Param("tokenId")
|
||||||
if tokenId == "" || tokenId == "*" {
|
if tokenId == "" || tokenId == "*" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,18 +80,18 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysJobLogGroup.DELETE("/:jobLogIds",
|
sysJobLogGroup.DELETE("/:jobLogIds",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:remove"}}),
|
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,
|
controller.NewSysJobLog.Remove,
|
||||||
)
|
)
|
||||||
sysJobLogGroup.DELETE("/clean",
|
sysJobLogGroup.DELETE("/clean",
|
||||||
repeat.RepeatSubmit(5),
|
repeat.RepeatSubmit(5),
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:remove"}}),
|
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,
|
controller.NewSysJobLog.Clean,
|
||||||
)
|
)
|
||||||
sysJobLogGroup.POST("/export",
|
sysJobLogGroup.POST("/export",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job: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,
|
controller.NewSysJobLog.Export,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -109,39 +109,39 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysJobGroup.POST("",
|
sysJobGroup.POST("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:add"}}),
|
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,
|
controller.NewSysJob.Add,
|
||||||
)
|
)
|
||||||
sysJobGroup.PUT("",
|
sysJobGroup.PUT("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:edit"}}),
|
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,
|
controller.NewSysJob.Edit,
|
||||||
)
|
)
|
||||||
sysJobGroup.DELETE("/:jobIds",
|
sysJobGroup.DELETE("/:jobIds",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:remove"}}),
|
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,
|
controller.NewSysJob.Remove,
|
||||||
)
|
)
|
||||||
sysJobGroup.PUT("/changeStatus",
|
sysJobGroup.PUT("/changeStatus",
|
||||||
repeat.RepeatSubmit(5),
|
repeat.RepeatSubmit(5),
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:changeStatus"}}),
|
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,
|
controller.NewSysJob.Status,
|
||||||
)
|
)
|
||||||
sysJobGroup.PUT("/run/:jobId",
|
sysJobGroup.PUT("/run/:jobId",
|
||||||
repeat.RepeatSubmit(10),
|
repeat.RepeatSubmit(10),
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:changeStatus"}}),
|
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,
|
controller.NewSysJob.Run,
|
||||||
)
|
)
|
||||||
sysJobGroup.PUT("/resetQueueJob",
|
sysJobGroup.PUT("/resetQueueJob",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:changeStatus"}}),
|
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,
|
controller.NewSysJob.ResetQueueJob,
|
||||||
)
|
)
|
||||||
sysJobGroup.POST("/export",
|
sysJobGroup.POST("/export",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job: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,
|
controller.NewSysJob.Export,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"fmt"
|
||||||
|
|
||||||
"ems.agt/src/framework/constants/common"
|
"ems.agt/src/framework/constants/common"
|
||||||
"ems.agt/src/framework/cron"
|
"ems.agt/src/framework/cron"
|
||||||
@@ -85,7 +85,8 @@ func (r *SysJobImpl) DeleteJobByIds(jobIds []string) (int64, error) {
|
|||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
jobs := r.sysJobRepository.SelectJobByIds(jobIds)
|
jobs := r.sysJobRepository.SelectJobByIds(jobIds)
|
||||||
if len(jobs) <= 0 {
|
if len(jobs) <= 0 {
|
||||||
return 0, errors.New("没有权限访问调度任务数据!")
|
// 没有可访问调度任务数据!
|
||||||
|
return 0, fmt.Errorf("There is no accessible scheduling task data!")
|
||||||
}
|
}
|
||||||
if len(jobs) == len(jobIds) {
|
if len(jobs) == len(jobIds) {
|
||||||
// 清除任务
|
// 清除任务
|
||||||
@@ -95,7 +96,8 @@ func (r *SysJobImpl) DeleteJobByIds(jobIds []string) (int64, error) {
|
|||||||
rows := r.sysJobRepository.DeleteJobByIds(jobIds)
|
rows := r.sysJobRepository.DeleteJobByIds(jobIds)
|
||||||
return rows, nil
|
return rows, nil
|
||||||
}
|
}
|
||||||
return 0, errors.New("删除调度任务信息失败!")
|
// 删除调度任务信息失败!
|
||||||
|
return 0, fmt.Errorf("Failed to delete scheduling task information!")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeStatus 任务调度状态修改
|
// ChangeStatus 任务调度状态修改
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func (s *NeInfoController) NeTypeAndID(c *gin.Context) {
|
|||||||
neType := c.Query("neType")
|
neType := c.Query("neType")
|
||||||
neId := c.Query("neId")
|
neId := c.Query("neId")
|
||||||
if neType == "" || neId == "" {
|
if neType == "" || neId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ func (s *SysConfigController) List(c *gin.Context) {
|
|||||||
func (s *SysConfigController) Info(c *gin.Context) {
|
func (s *SysConfigController) Info(c *gin.Context) {
|
||||||
configId := c.Param("configId")
|
configId := c.Param("configId")
|
||||||
if configId == "" {
|
if configId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := s.sysConfigService.SelectConfigById(configId)
|
data := s.sysConfigService.SelectConfigById(configId)
|
||||||
@@ -63,14 +63,15 @@ func (s *SysConfigController) Add(c *gin.Context) {
|
|||||||
var body model.SysConfig
|
var body model.SysConfig
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.ConfigID != "" {
|
if err != nil || body.ConfigID != "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查属性值唯一
|
// 检查属性值唯一
|
||||||
uniqueConfigKey := s.sysConfigService.CheckUniqueConfigKey(body.ConfigKey, "")
|
uniqueConfigKey := s.sysConfigService.CheckUniqueConfigKey(body.ConfigKey, "")
|
||||||
if !uniqueConfigKey {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -91,14 +92,15 @@ func (s *SysConfigController) Edit(c *gin.Context) {
|
|||||||
var body model.SysConfig
|
var body model.SysConfig
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.ConfigID == "" {
|
if err != nil || body.ConfigID == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查属性值唯一
|
// 检查属性值唯一
|
||||||
uniqueConfigKey := s.sysConfigService.CheckUniqueConfigKey(body.ConfigKey, body.ConfigID)
|
uniqueConfigKey := s.sysConfigService.CheckUniqueConfigKey(body.ConfigKey, body.ConfigID)
|
||||||
if !uniqueConfigKey {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -106,7 +108,8 @@ func (s *SysConfigController) Edit(c *gin.Context) {
|
|||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
config := s.sysConfigService.SelectConfigById(body.ConfigID)
|
config := s.sysConfigService.SelectConfigById(body.ConfigID)
|
||||||
if config.ConfigID != 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +128,7 @@ func (s *SysConfigController) Edit(c *gin.Context) {
|
|||||||
func (s *SysConfigController) Remove(c *gin.Context) {
|
func (s *SysConfigController) Remove(c *gin.Context) {
|
||||||
configIds := c.Param("configIds")
|
configIds := c.Param("configIds")
|
||||||
if configIds == "" {
|
if configIds == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 处理字符转id数组后去重
|
// 处理字符转id数组后去重
|
||||||
@@ -140,7 +143,7 @@ func (s *SysConfigController) Remove(c *gin.Context) {
|
|||||||
c.JSON(200, result.ErrMsg(err.Error()))
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
msg := fmt.Sprintf("Deleted successfully: %d", rows)
|
||||||
c.JSON(200, result.OkMsg(msg))
|
c.JSON(200, result.OkMsg(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +161,7 @@ func (s *SysConfigController) RefreshCache(c *gin.Context) {
|
|||||||
func (s *SysConfigController) ConfigKey(c *gin.Context) {
|
func (s *SysConfigController) ConfigKey(c *gin.Context) {
|
||||||
configKey := c.Param("configKey")
|
configKey := c.Param("configKey")
|
||||||
if configKey == "" {
|
if configKey == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
key := s.sysConfigService.SelectConfigValueByKey(configKey)
|
key := s.sysConfigService.SelectConfigValueByKey(configKey)
|
||||||
@@ -177,7 +180,8 @@ func (s *SysConfigController) Export(c *gin.Context) {
|
|||||||
querys := ctx.BodyJSONMap(c)
|
querys := ctx.BodyJSONMap(c)
|
||||||
data := s.sysConfigService.SelectConfigPage(querys)
|
data := s.sysConfigService.SelectConfigPage(querys)
|
||||||
if data["total"].(int64) == 0 {
|
if data["total"].(int64) == 0 {
|
||||||
c.JSON(200, result.ErrMsg("导出数据记录为空"))
|
// 导出数据记录为空
|
||||||
|
c.JSON(200, result.ErrMsg("Export data record is empty"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rows := data["rows"].([]model.SysConfig)
|
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())
|
fileName := fmt.Sprintf("config_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
||||||
// 第一行表头标题
|
// 第一行表头标题
|
||||||
headerCells := map[string]string{
|
headerCells := map[string]string{
|
||||||
"A1": "参数编号",
|
"A1": "ConfigID",
|
||||||
"B1": "参数名称",
|
"B1": "ConfigName",
|
||||||
"C1": "参数键名",
|
"C1": "ConfigKey",
|
||||||
"D1": "参数键值",
|
"D1": "ConfigValue",
|
||||||
"E1": "系统内置",
|
"E1": "Type",
|
||||||
}
|
}
|
||||||
// 从第二行开始的数据
|
// 从第二行开始的数据
|
||||||
dataCells := make([]map[string]any, 0)
|
dataCells := make([]map[string]any, 0)
|
||||||
for i, row := range rows {
|
for i, row := range rows {
|
||||||
idx := strconv.Itoa(i + 2)
|
idx := strconv.Itoa(i + 2)
|
||||||
typeValue := "否"
|
typeValue := "clogged"
|
||||||
if row.ConfigType == "Y" {
|
if row.ConfigType == "Y" {
|
||||||
typeValue = "是"
|
typeValue = "be"
|
||||||
}
|
}
|
||||||
dataCells = append(dataCells, map[string]any{
|
dataCells = append(dataCells, map[string]any{
|
||||||
"A" + idx: row.ConfigID,
|
"A" + idx: row.ConfigID,
|
||||||
@@ -228,20 +232,22 @@ func (s *SysConfigController) ConfigValue(c *gin.Context) {
|
|||||||
Value string `json:"value" binding:"required"`
|
Value string `json:"value" binding:"required"`
|
||||||
}
|
}
|
||||||
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
|
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
info := s.sysConfigService.SelectConfigByKey(body.Key)
|
info := s.sysConfigService.SelectConfigByKey(body.Key)
|
||||||
if info.ConfigKey != body.Key {
|
if info.ConfigKey != body.Key {
|
||||||
c.JSON(200, result.ErrMsg("无效 key"))
|
// 无效 key
|
||||||
|
c.JSON(200, result.ErrMsg("Invalid key"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 与旧值相等不变更
|
// 与旧值相等不变更
|
||||||
if info.ConfigValue == body.Value {
|
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
|
return
|
||||||
}
|
}
|
||||||
info.ConfigValue = body.Value
|
info.ConfigValue = body.Value
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func (s *SysDeptController) List(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := c.ShouldBindQuery(&querys)
|
err := c.ShouldBindQuery(&querys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ func (s *SysDeptController) List(c *gin.Context) {
|
|||||||
func (s *SysDeptController) Info(c *gin.Context) {
|
func (s *SysDeptController) Info(c *gin.Context) {
|
||||||
deptId := c.Param("deptId")
|
deptId := c.Param("deptId")
|
||||||
if deptId == "" {
|
if deptId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := s.sysDeptService.SelectDeptById(deptId)
|
data := s.sysDeptService.SelectDeptById(deptId)
|
||||||
@@ -82,7 +82,7 @@ func (s *SysDeptController) Add(c *gin.Context) {
|
|||||||
var body model.SysDept
|
var body model.SysDept
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.DeptID != "" {
|
if err != nil || body.DeptID != "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,16 +90,19 @@ func (s *SysDeptController) Add(c *gin.Context) {
|
|||||||
if body.ParentID != "0" {
|
if body.ParentID != "0" {
|
||||||
deptParent := s.sysDeptService.SelectDeptById(body.ParentID)
|
deptParent := s.sysDeptService.SelectDeptById(body.ParentID)
|
||||||
if deptParent.DeptID != body.ParentID {
|
if deptParent.DeptID != body.ParentID {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问部门数据!"))
|
// 没有可访问部门数据!
|
||||||
|
c.JSON(200, result.ErrMsg("There is no accessible sectoral data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if deptParent.Status == common.STATUS_NO {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if deptParent.DelFlag == common.STATUS_YES {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -111,7 +114,8 @@ func (s *SysDeptController) Add(c *gin.Context) {
|
|||||||
// 检查同级下名称唯一
|
// 检查同级下名称唯一
|
||||||
uniqueDeptName := s.sysDeptService.CheckUniqueDeptName(body.DeptName, body.ParentID, "")
|
uniqueDeptName := s.sysDeptService.CheckUniqueDeptName(body.DeptName, body.ParentID, "")
|
||||||
if !uniqueDeptName {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -132,13 +136,14 @@ func (s *SysDeptController) Edit(c *gin.Context) {
|
|||||||
var body model.SysDept
|
var body model.SysDept
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.DeptID == "" {
|
if err != nil || body.DeptID == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上级部门不能选自己
|
// 上级部门不能选自己
|
||||||
if body.DeptID == body.ParentID {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -146,14 +151,16 @@ func (s *SysDeptController) Edit(c *gin.Context) {
|
|||||||
// 检查数据是否存在
|
// 检查数据是否存在
|
||||||
deptInfo := s.sysDeptService.SelectDeptById(body.DeptID)
|
deptInfo := s.sysDeptService.SelectDeptById(body.DeptID)
|
||||||
if deptInfo.DeptID != body.DeptID {
|
if deptInfo.DeptID != body.DeptID {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问部门数据!"))
|
// 没有可访问部门数据!
|
||||||
|
c.JSON(200, result.ErrMsg("There is no accessible sectoral data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 父级ID不为0是要检查
|
// 父级ID不为0是要检查
|
||||||
if body.ParentID != "0" {
|
if body.ParentID != "0" {
|
||||||
deptParent := s.sysDeptService.SelectDeptById(body.ParentID)
|
deptParent := s.sysDeptService.SelectDeptById(body.ParentID)
|
||||||
if deptParent.DeptID != body.ParentID {
|
if deptParent.DeptID != body.ParentID {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问部门数据!"))
|
// 没有可访问部门数据!
|
||||||
|
c.JSON(200, result.ErrMsg("There is no accessible sectoral data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,7 +168,8 @@ func (s *SysDeptController) Edit(c *gin.Context) {
|
|||||||
// 检查同级下名称唯一
|
// 检查同级下名称唯一
|
||||||
uniqueDeptName := s.sysDeptService.CheckUniqueDeptName(body.DeptName, body.ParentID, body.DeptID)
|
uniqueDeptName := s.sysDeptService.CheckUniqueDeptName(body.DeptName, body.ParentID, body.DeptID)
|
||||||
if !uniqueDeptName {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -170,7 +178,8 @@ func (s *SysDeptController) Edit(c *gin.Context) {
|
|||||||
if body.Status == common.STATUS_NO {
|
if body.Status == common.STATUS_NO {
|
||||||
hasChild := s.sysDeptService.HasChildByDeptId(body.DeptID)
|
hasChild := s.sysDeptService.HasChildByDeptId(body.DeptID)
|
||||||
if hasChild > 0 {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -191,21 +200,23 @@ func (s *SysDeptController) Edit(c *gin.Context) {
|
|||||||
func (s *SysDeptController) Remove(c *gin.Context) {
|
func (s *SysDeptController) Remove(c *gin.Context) {
|
||||||
deptId := c.Param("deptId")
|
deptId := c.Param("deptId")
|
||||||
if deptId == "" {
|
if deptId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查数据是否存在
|
// 检查数据是否存在
|
||||||
dept := s.sysDeptService.SelectDeptById(deptId)
|
dept := s.sysDeptService.SelectDeptById(deptId)
|
||||||
if dept.DeptID != deptId {
|
if dept.DeptID != deptId {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问部门数据!"))
|
// 没有可访问部门数据!
|
||||||
|
c.JSON(200, result.ErrMsg("There is no accessible sectoral data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否存在子部门
|
// 检查是否存在子部门
|
||||||
hasChild := s.sysDeptService.HasChildByDeptId(deptId)
|
hasChild := s.sysDeptService.HasChildByDeptId(deptId)
|
||||||
if hasChild > 0 {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -213,14 +224,16 @@ func (s *SysDeptController) Remove(c *gin.Context) {
|
|||||||
// 检查是否分配给用户
|
// 检查是否分配给用户
|
||||||
existUser := s.sysDeptService.CheckDeptExistUser(deptId)
|
existUser := s.sysDeptService.CheckDeptExistUser(deptId)
|
||||||
if existUser > 0 {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
rows := s.sysDeptService.DeleteDeptById(deptId)
|
rows := s.sysDeptService.DeleteDeptById(deptId)
|
||||||
if rows > 0 {
|
if rows > 0 {
|
||||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
// 删除成功:%d
|
||||||
|
msg := fmt.Sprintf("Deleted successfully: %d", rows)
|
||||||
c.JSON(200, result.OkMsg(msg))
|
c.JSON(200, result.OkMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -233,7 +246,7 @@ func (s *SysDeptController) Remove(c *gin.Context) {
|
|||||||
func (s *SysDeptController) ExcludeChild(c *gin.Context) {
|
func (s *SysDeptController) ExcludeChild(c *gin.Context) {
|
||||||
deptId := c.Param("deptId")
|
deptId := c.Param("deptId")
|
||||||
if deptId == "" {
|
if deptId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,7 +287,7 @@ func (s *SysDeptController) TreeSelect(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := c.ShouldBindQuery(&querys)
|
err := c.ShouldBindQuery(&querys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +308,7 @@ func (s *SysDeptController) TreeSelect(c *gin.Context) {
|
|||||||
func (s *SysDeptController) RoleDeptTreeSelect(c *gin.Context) {
|
func (s *SysDeptController) RoleDeptTreeSelect(c *gin.Context) {
|
||||||
roleId := c.Param("roleId")
|
roleId := c.Param("roleId")
|
||||||
if roleId == "" {
|
if roleId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ func (s *SysDictDataController) List(c *gin.Context) {
|
|||||||
func (s *SysDictDataController) Info(c *gin.Context) {
|
func (s *SysDictDataController) Info(c *gin.Context) {
|
||||||
dictCode := c.Param("dictCode")
|
dictCode := c.Param("dictCode")
|
||||||
if dictCode == "" {
|
if dictCode == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := s.sysDictDataService.SelectDictDataByCode(dictCode)
|
data := s.sysDictDataService.SelectDictDataByCode(dictCode)
|
||||||
@@ -66,21 +66,23 @@ func (s *SysDictDataController) Add(c *gin.Context) {
|
|||||||
var body model.SysDictData
|
var body model.SysDictData
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.DictCode != "" {
|
if err != nil || body.DictCode != "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查字典类型是否存在
|
// 检查字典类型是否存在
|
||||||
sysDictType := s.sysDictTypeService.SelectDictTypeByType(body.DictType)
|
sysDictType := s.sysDictTypeService.SelectDictTypeByType(body.DictType)
|
||||||
if sysDictType.DictType != 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查字典标签唯一
|
// 检查字典标签唯一
|
||||||
uniqueDictLabel := s.sysDictDataService.CheckUniqueDictLabel(body.DictType, body.DictLabel, "")
|
uniqueDictLabel := s.sysDictDataService.CheckUniqueDictLabel(body.DictType, body.DictLabel, "")
|
||||||
if !uniqueDictLabel {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -88,7 +90,8 @@ func (s *SysDictDataController) Add(c *gin.Context) {
|
|||||||
// 检查字典键值唯一
|
// 检查字典键值唯一
|
||||||
uniqueDictValue := s.sysDictDataService.CheckUniqueDictValue(body.DictType, body.DictValue, "")
|
uniqueDictValue := s.sysDictDataService.CheckUniqueDictValue(body.DictType, body.DictValue, "")
|
||||||
if !uniqueDictValue {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -109,28 +112,31 @@ func (s *SysDictDataController) Edit(c *gin.Context) {
|
|||||||
var body model.SysDictData
|
var body model.SysDictData
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.DictCode == "" {
|
if err != nil || body.DictCode == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查字典类型是否存在
|
// 检查字典类型是否存在
|
||||||
sysDictType := s.sysDictTypeService.SelectDictTypeByType(body.DictType)
|
sysDictType := s.sysDictTypeService.SelectDictTypeByType(body.DictType)
|
||||||
if sysDictType.DictType != 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查字典编码是否存在
|
// 检查字典编码是否存在
|
||||||
SysDictDataController := s.sysDictDataService.SelectDictDataByCode(body.DictCode)
|
SysDictDataController := s.sysDictDataService.SelectDictDataByCode(body.DictCode)
|
||||||
if SysDictDataController.DictCode != 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查字典标签唯一
|
// 检查字典标签唯一
|
||||||
uniqueDictLabel := s.sysDictDataService.CheckUniqueDictLabel(body.DictType, body.DictLabel, body.DictCode)
|
uniqueDictLabel := s.sysDictDataService.CheckUniqueDictLabel(body.DictType, body.DictLabel, body.DictCode)
|
||||||
if !uniqueDictLabel {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -138,7 +144,8 @@ func (s *SysDictDataController) Edit(c *gin.Context) {
|
|||||||
// 检查字典键值唯一
|
// 检查字典键值唯一
|
||||||
uniqueDictValue := s.sysDictDataService.CheckUniqueDictValue(body.DictType, body.DictValue, body.DictCode)
|
uniqueDictValue := s.sysDictDataService.CheckUniqueDictValue(body.DictType, body.DictValue, body.DictCode)
|
||||||
if !uniqueDictValue {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -158,7 +165,7 @@ func (s *SysDictDataController) Edit(c *gin.Context) {
|
|||||||
func (s *SysDictDataController) Remove(c *gin.Context) {
|
func (s *SysDictDataController) Remove(c *gin.Context) {
|
||||||
dictCodes := c.Param("dictCodes")
|
dictCodes := c.Param("dictCodes")
|
||||||
if dictCodes == "" {
|
if dictCodes == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 处理字符转id数组后去重
|
// 处理字符转id数组后去重
|
||||||
@@ -173,7 +180,8 @@ func (s *SysDictDataController) Remove(c *gin.Context) {
|
|||||||
c.JSON(200, result.ErrMsg(err.Error()))
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
// 删除成功:%d
|
||||||
|
msg := fmt.Sprintf("Deleted successfully: %d", rows)
|
||||||
c.JSON(200, result.OkMsg(msg))
|
c.JSON(200, result.OkMsg(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +191,7 @@ func (s *SysDictDataController) Remove(c *gin.Context) {
|
|||||||
func (s *SysDictDataController) DictType(c *gin.Context) {
|
func (s *SysDictDataController) DictType(c *gin.Context) {
|
||||||
dictType := c.Param("dictType")
|
dictType := c.Param("dictType")
|
||||||
if dictType == "" {
|
if dictType == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +207,8 @@ func (s *SysDictDataController) Export(c *gin.Context) {
|
|||||||
querys := ctx.BodyJSONMap(c)
|
querys := ctx.BodyJSONMap(c)
|
||||||
data := s.sysDictDataService.SelectDictDataPage(querys)
|
data := s.sysDictDataService.SelectDictDataPage(querys)
|
||||||
if data["total"].(int64) == 0 {
|
if data["total"].(int64) == 0 {
|
||||||
c.JSON(200, result.ErrMsg("导出数据记录为空"))
|
// 导出数据记录为空
|
||||||
|
c.JSON(200, result.ErrMsg("Export data record is empty"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rows := data["rows"].([]model.SysDictData)
|
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())
|
fileName := fmt.Sprintf("dict_data_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
||||||
// 第一行表头标题
|
// 第一行表头标题
|
||||||
headerCells := map[string]string{
|
headerCells := map[string]string{
|
||||||
"A1": "字典编码",
|
"A1": "DictCode",
|
||||||
"B1": "字典排序",
|
"B1": "DictSort",
|
||||||
"C1": "字典标签",
|
"C1": "DictLabel",
|
||||||
"D1": "字典键值",
|
"D1": "DictValue",
|
||||||
"E1": "字典类型",
|
"E1": "DictType",
|
||||||
"F1": "状态",
|
"F1": "Status",
|
||||||
}
|
}
|
||||||
// 从第二行开始的数据
|
// 从第二行开始的数据
|
||||||
dataCells := make([]map[string]any, 0)
|
dataCells := make([]map[string]any, 0)
|
||||||
for i, row := range rows {
|
for i, row := range rows {
|
||||||
idx := strconv.Itoa(i + 2)
|
idx := strconv.Itoa(i + 2)
|
||||||
statusValue := "停用"
|
statusValue := "deactivate"
|
||||||
if row.Status == "1" {
|
if row.Status == "1" {
|
||||||
statusValue = "正常"
|
statusValue = "normalcy"
|
||||||
}
|
}
|
||||||
dataCells = append(dataCells, map[string]any{
|
dataCells = append(dataCells, map[string]any{
|
||||||
"A" + idx: row.DictCode,
|
"A" + idx: row.DictCode,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"ems.agt/src/framework/constants/common"
|
"ems.agt/src/framework/constants/common"
|
||||||
|
"ems.agt/src/framework/i18n"
|
||||||
"ems.agt/src/framework/utils/ctx"
|
"ems.agt/src/framework/utils/ctx"
|
||||||
"ems.agt/src/framework/utils/file"
|
"ems.agt/src/framework/utils/file"
|
||||||
"ems.agt/src/framework/utils/parse"
|
"ems.agt/src/framework/utils/parse"
|
||||||
@@ -46,7 +47,7 @@ func (s *SysDictTypeController) List(c *gin.Context) {
|
|||||||
func (s *SysDictTypeController) Info(c *gin.Context) {
|
func (s *SysDictTypeController) Info(c *gin.Context) {
|
||||||
dictId := c.Param("dictId")
|
dictId := c.Param("dictId")
|
||||||
if dictId == "" {
|
if dictId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := s.sysDictTypeService.SelectDictTypeByID(dictId)
|
data := s.sysDictTypeService.SelectDictTypeByID(dictId)
|
||||||
@@ -64,14 +65,15 @@ func (s *SysDictTypeController) Add(c *gin.Context) {
|
|||||||
var body model.SysDictType
|
var body model.SysDictType
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.DictID != "" {
|
if err != nil || body.DictID != "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查字典名称唯一
|
// 检查字典名称唯一
|
||||||
uniqueDictName := s.sysDictTypeService.CheckUniqueDictName(body.DictName, "")
|
uniqueDictName := s.sysDictTypeService.CheckUniqueDictName(body.DictName, "")
|
||||||
if !uniqueDictName {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -79,7 +81,8 @@ func (s *SysDictTypeController) Add(c *gin.Context) {
|
|||||||
// 检查字典类型唯一
|
// 检查字典类型唯一
|
||||||
uniqueDictType := s.sysDictTypeService.CheckUniqueDictType(body.DictType, "")
|
uniqueDictType := s.sysDictTypeService.CheckUniqueDictType(body.DictType, "")
|
||||||
if !uniqueDictType {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -100,21 +103,23 @@ func (s *SysDictTypeController) Edit(c *gin.Context) {
|
|||||||
var body model.SysDictType
|
var body model.SysDictType
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.DictID == "" {
|
if err != nil || body.DictID == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查数据是否存在
|
// 检查数据是否存在
|
||||||
dictInfo := s.sysDictTypeService.SelectDictTypeByID(body.DictID)
|
dictInfo := s.sysDictTypeService.SelectDictTypeByID(body.DictID)
|
||||||
if dictInfo.DictID != 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查字典名称唯一
|
// 检查字典名称唯一
|
||||||
uniqueDictName := s.sysDictTypeService.CheckUniqueDictName(body.DictName, body.DictID)
|
uniqueDictName := s.sysDictTypeService.CheckUniqueDictName(body.DictName, body.DictID)
|
||||||
if !uniqueDictName {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -122,7 +127,8 @@ func (s *SysDictTypeController) Edit(c *gin.Context) {
|
|||||||
// 检查字典类型唯一
|
// 检查字典类型唯一
|
||||||
uniqueDictType := s.sysDictTypeService.CheckUniqueDictType(body.DictType, body.DictID)
|
uniqueDictType := s.sysDictTypeService.CheckUniqueDictType(body.DictType, body.DictID)
|
||||||
if !uniqueDictType {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -142,7 +148,7 @@ func (s *SysDictTypeController) Edit(c *gin.Context) {
|
|||||||
func (s *SysDictTypeController) Remove(c *gin.Context) {
|
func (s *SysDictTypeController) Remove(c *gin.Context) {
|
||||||
dictIds := c.Param("dictIds")
|
dictIds := c.Param("dictIds")
|
||||||
if dictIds == "" {
|
if dictIds == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 处理字符转id数组后去重
|
// 处理字符转id数组后去重
|
||||||
@@ -157,7 +163,7 @@ func (s *SysDictTypeController) Remove(c *gin.Context) {
|
|||||||
c.JSON(200, result.ErrMsg(err.Error()))
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
msg := fmt.Sprintf("Deleted successfully: %d", rows)
|
||||||
c.JSON(200, result.OkMsg(msg))
|
c.JSON(200, result.OkMsg(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,6 +172,7 @@ func (s *SysDictTypeController) Remove(c *gin.Context) {
|
|||||||
// PUT /refreshCache
|
// PUT /refreshCache
|
||||||
func (s *SysDictTypeController) RefreshCache(c *gin.Context) {
|
func (s *SysDictTypeController) RefreshCache(c *gin.Context) {
|
||||||
s.sysDictTypeService.ResetDictCache()
|
s.sysDictTypeService.ResetDictCache()
|
||||||
|
i18n.ClearLocaleData() // 清空国际化数据
|
||||||
c.JSON(200, result.Ok(nil))
|
c.JSON(200, result.Ok(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +208,8 @@ func (s *SysDictTypeController) Export(c *gin.Context) {
|
|||||||
querys := ctx.BodyJSONMap(c)
|
querys := ctx.BodyJSONMap(c)
|
||||||
data := s.sysDictTypeService.SelectDictTypePage(querys)
|
data := s.sysDictTypeService.SelectDictTypePage(querys)
|
||||||
if data["total"].(int64) == 0 {
|
if data["total"].(int64) == 0 {
|
||||||
c.JSON(200, result.ErrMsg("导出数据记录为空"))
|
// 导出数据记录为空
|
||||||
|
c.JSON(200, result.ErrMsg("Export data record is empty"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rows := data["rows"].([]model.SysDictType)
|
rows := data["rows"].([]model.SysDictType)
|
||||||
@@ -210,18 +218,18 @@ func (s *SysDictTypeController) Export(c *gin.Context) {
|
|||||||
fileName := fmt.Sprintf("dict_type_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
fileName := fmt.Sprintf("dict_type_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
||||||
// 第一行表头标题
|
// 第一行表头标题
|
||||||
headerCells := map[string]string{
|
headerCells := map[string]string{
|
||||||
"A1": "字典主键",
|
"A1": "DictID",
|
||||||
"B1": "字典名称",
|
"B1": "DictName",
|
||||||
"C1": "字典类型",
|
"C1": "DictType",
|
||||||
"D1": "状态",
|
"D1": "Status",
|
||||||
}
|
}
|
||||||
// 从第二行开始的数据
|
// 从第二行开始的数据
|
||||||
dataCells := make([]map[string]any, 0)
|
dataCells := make([]map[string]any, 0)
|
||||||
for i, row := range rows {
|
for i, row := range rows {
|
||||||
idx := strconv.Itoa(i + 2)
|
idx := strconv.Itoa(i + 2)
|
||||||
statusValue := "停用"
|
statusValue := "deactivate"
|
||||||
if row.Status == "1" {
|
if row.Status == "1" {
|
||||||
statusValue = "正常"
|
statusValue = "normalcy"
|
||||||
}
|
}
|
||||||
dataCells = append(dataCells, map[string]any{
|
dataCells = append(dataCells, map[string]any{
|
||||||
"A" + idx: row.DictID,
|
"A" + idx: row.DictID,
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func (s *SysLogLoginController) List(c *gin.Context) {
|
|||||||
func (s *SysLogLoginController) Remove(c *gin.Context) {
|
func (s *SysLogLoginController) Remove(c *gin.Context) {
|
||||||
infoIds := c.Param("infoIds")
|
infoIds := c.Param("infoIds")
|
||||||
if infoIds == "" {
|
if infoIds == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ func (s *SysLogLoginController) Remove(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
rows := s.sysLogLoginService.DeleteSysLogLoginByIds(uniqueIDs)
|
rows := s.sysLogLoginService.DeleteSysLogLoginByIds(uniqueIDs)
|
||||||
if rows > 0 {
|
if rows > 0 {
|
||||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
msg := fmt.Sprintf("Deleted successfully: %d", rows)
|
||||||
c.JSON(200, result.OkMsg(msg))
|
c.JSON(200, result.OkMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ func (s *SysLogLoginController) Clean(c *gin.Context) {
|
|||||||
func (s *SysLogLoginController) Unlock(c *gin.Context) {
|
func (s *SysLogLoginController) Unlock(c *gin.Context) {
|
||||||
userName := c.Param("userName")
|
userName := c.Param("userName")
|
||||||
if userName == "" {
|
if userName == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ok := s.accountService.ClearLoginRecordCache(userName)
|
ok := s.accountService.ClearLoginRecordCache(userName)
|
||||||
@@ -95,7 +95,7 @@ func (s *SysLogLoginController) Unlock(c *gin.Context) {
|
|||||||
c.JSON(200, result.Ok(nil))
|
c.JSON(200, result.Ok(nil))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(200, result.Err(nil))
|
c.JSON(200, result.ErrMsg("unlatched"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出系统登录日志信息
|
// 导出系统登录日志信息
|
||||||
@@ -106,7 +106,8 @@ func (s *SysLogLoginController) Export(c *gin.Context) {
|
|||||||
querys := ctx.BodyJSONMap(c)
|
querys := ctx.BodyJSONMap(c)
|
||||||
data := s.sysLogLoginService.SelectSysLogLoginPage(querys)
|
data := s.sysLogLoginService.SelectSysLogLoginPage(querys)
|
||||||
if data["total"].(int64) == 0 {
|
if data["total"].(int64) == 0 {
|
||||||
c.JSON(200, result.ErrMsg("导出数据记录为空"))
|
// 导出数据记录为空
|
||||||
|
c.JSON(200, result.ErrMsg("Export data record is empty"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rows := data["rows"].([]model.SysLogLogin)
|
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())
|
fileName := fmt.Sprintf("sys_log_login_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
||||||
// 第一行表头标题
|
// 第一行表头标题
|
||||||
headerCells := map[string]string{
|
headerCells := map[string]string{
|
||||||
"A1": "序号",
|
"A1": "ID",
|
||||||
"B1": "用户账号",
|
"B1": "UserName",
|
||||||
"C1": "登录状态",
|
"C1": "Status",
|
||||||
"D1": "登录地址",
|
"D1": "IP",
|
||||||
"E1": "登录地点",
|
"E1": "Location",
|
||||||
"F1": "浏览器",
|
"F1": "Browser",
|
||||||
"G1": "操作系统",
|
"G1": "OS",
|
||||||
"H1": "提示消息",
|
"H1": "Msg",
|
||||||
"I1": "访问时间",
|
"I1": "Time",
|
||||||
}
|
}
|
||||||
// 从第二行开始的数据
|
// 从第二行开始的数据
|
||||||
dataCells := make([]map[string]any, 0)
|
dataCells := make([]map[string]any, 0)
|
||||||
for i, row := range rows {
|
for i, row := range rows {
|
||||||
idx := strconv.Itoa(i + 2)
|
idx := strconv.Itoa(i + 2)
|
||||||
// 状态
|
// 状态
|
||||||
statusValue := "失败"
|
statusValue := "fail"
|
||||||
if row.Status == "1" {
|
if row.Status == "1" {
|
||||||
statusValue = "成功"
|
statusValue = "successes"
|
||||||
}
|
}
|
||||||
dataCells = append(dataCells, map[string]any{
|
dataCells = append(dataCells, map[string]any{
|
||||||
"A" + idx: row.LoginID,
|
"A" + idx: row.LoginID,
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ func (s *SysLogOperateController) List(c *gin.Context) {
|
|||||||
func (s *SysLogOperateController) Remove(c *gin.Context) {
|
func (s *SysLogOperateController) Remove(c *gin.Context) {
|
||||||
operIds := c.Param("operIds")
|
operIds := c.Param("operIds")
|
||||||
if operIds == "" {
|
if operIds == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ func (s *SysLogOperateController) Remove(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
rows := s.SysLogOperateService.DeleteSysLogOperateByIds(uniqueIDs)
|
rows := s.SysLogOperateService.DeleteSysLogOperateByIds(uniqueIDs)
|
||||||
if rows > 0 {
|
if rows > 0 {
|
||||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
msg := fmt.Sprintf("Deleted successfully: %d", rows)
|
||||||
c.JSON(200, result.OkMsg(msg))
|
c.JSON(200, result.OkMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,8 @@ func (s *SysLogOperateController) Export(c *gin.Context) {
|
|||||||
querys := ctx.BodyJSONMap(c)
|
querys := ctx.BodyJSONMap(c)
|
||||||
data := s.SysLogOperateService.SelectSysLogOperatePage(querys)
|
data := s.SysLogOperateService.SelectSysLogOperatePage(querys)
|
||||||
if data["total"].(int64) == 0 {
|
if data["total"].(int64) == 0 {
|
||||||
c.JSON(200, result.ErrMsg("导出数据记录为空"))
|
// 导出数据记录为空
|
||||||
|
c.JSON(200, result.ErrMsg("Export data record is empty"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rows := data["rows"].([]model.SysLogOperate)
|
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())
|
fileName := fmt.Sprintf("sys_log_operate_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
||||||
// 第一行表头标题
|
// 第一行表头标题
|
||||||
headerCells := map[string]string{
|
headerCells := map[string]string{
|
||||||
"A1": "操作序号",
|
"A1": "ID",
|
||||||
"B1": "操作模块",
|
"B1": "Title",
|
||||||
"C1": "业务类型",
|
"C1": "BusinessType",
|
||||||
"D1": "请求方法",
|
"D1": "Method",
|
||||||
"E1": "请求方式",
|
"E1": "RequestMethod",
|
||||||
"F1": "操作类别",
|
"F1": "OperatorType",
|
||||||
"G1": "操作人员",
|
"G1": "OperName",
|
||||||
"H1": "部门名称",
|
"H1": "DeptName",
|
||||||
"I1": "请求地址",
|
"I1": "URL",
|
||||||
"J1": "操作地址",
|
"J1": "IP",
|
||||||
"K1": "操作地点",
|
"K1": "Location",
|
||||||
"L1": "请求参数",
|
"L1": "Param",
|
||||||
"M1": "操作消息",
|
"M1": "Msg",
|
||||||
"N1": "状态",
|
"N1": "Status",
|
||||||
"O1": "消耗时间(毫秒)",
|
"O1": "CostTime (ms)",
|
||||||
"P1": "操作时间",
|
"P1": "OperTime",
|
||||||
}
|
}
|
||||||
// 从第二行开始的数据
|
// 从第二行开始的数据
|
||||||
dataCells := make([]map[string]any, 0)
|
dataCells := make([]map[string]any, 0)
|
||||||
@@ -118,11 +119,11 @@ func (s *SysLogOperateController) Export(c *gin.Context) {
|
|||||||
// 业务类型
|
// 业务类型
|
||||||
businessType := ""
|
businessType := ""
|
||||||
// 操作类别
|
// 操作类别
|
||||||
OperatorType := ""
|
operatorType := ""
|
||||||
// 状态
|
// 状态
|
||||||
statusValue := "失败"
|
statusValue := "fail"
|
||||||
if row.Status == "1" {
|
if row.Status == "1" {
|
||||||
statusValue = "成功"
|
statusValue = "success"
|
||||||
}
|
}
|
||||||
dataCells = append(dataCells, map[string]any{
|
dataCells = append(dataCells, map[string]any{
|
||||||
"A" + idx: row.OperID,
|
"A" + idx: row.OperID,
|
||||||
@@ -130,7 +131,7 @@ func (s *SysLogOperateController) Export(c *gin.Context) {
|
|||||||
"C" + idx: businessType,
|
"C" + idx: businessType,
|
||||||
"D" + idx: row.Method,
|
"D" + idx: row.Method,
|
||||||
"E" + idx: row.RequestMethod,
|
"E" + idx: row.RequestMethod,
|
||||||
"F" + idx: OperatorType,
|
"F" + idx: operatorType,
|
||||||
"G" + idx: row.OperName,
|
"G" + idx: row.OperName,
|
||||||
"H" + idx: row.DeptName,
|
"H" + idx: row.DeptName,
|
||||||
"I" + idx: row.OperURL,
|
"I" + idx: row.OperURL,
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ func (s *SysMenuController) List(c *gin.Context) {
|
|||||||
func (s *SysMenuController) Info(c *gin.Context) {
|
func (s *SysMenuController) Info(c *gin.Context) {
|
||||||
menuId := c.Param("menuId")
|
menuId := c.Param("menuId")
|
||||||
if menuId == "" {
|
if menuId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := s.sysMenuService.SelectMenuById(menuId)
|
data := s.sysMenuService.SelectMenuById(menuId)
|
||||||
@@ -73,7 +73,7 @@ func (s *SysMenuController) Add(c *gin.Context) {
|
|||||||
var body model.SysMenu
|
var body model.SysMenu
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.MenuID != "" {
|
if err != nil || body.MenuID != "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +81,8 @@ func (s *SysMenuController) Add(c *gin.Context) {
|
|||||||
if menu.TYPE_DIR == body.MenuType || menu.TYPE_MENU == body.MenuType {
|
if menu.TYPE_DIR == body.MenuType || menu.TYPE_MENU == body.MenuType {
|
||||||
uniqueNenuPath := s.sysMenuService.CheckUniqueMenuPath(body.Path, body.ParentID, "")
|
uniqueNenuPath := s.sysMenuService.CheckUniqueMenuPath(body.Path, body.ParentID, "")
|
||||||
if !uniqueNenuPath {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -90,14 +91,16 @@ func (s *SysMenuController) Add(c *gin.Context) {
|
|||||||
// 检查名称唯一
|
// 检查名称唯一
|
||||||
uniqueNenuName := s.sysMenuService.CheckUniqueMenuName(body.MenuName, body.ParentID, "")
|
uniqueNenuName := s.sysMenuService.CheckUniqueMenuName(body.MenuName, body.ParentID, "")
|
||||||
if !uniqueNenuName {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 外链菜单需要符合网站http(s)开头
|
// 外链菜单需要符合网站http(s)开头
|
||||||
if body.IsFrame == common.STATUS_NO && !regular.ValidHttp(body.Path) {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -118,13 +121,14 @@ func (s *SysMenuController) Edit(c *gin.Context) {
|
|||||||
var body model.SysMenu
|
var body model.SysMenu
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.MenuID == "" {
|
if err != nil || body.MenuID == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上级菜单不能选自己
|
// 上级菜单不能选自己
|
||||||
if body.MenuID == body.ParentID {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -132,19 +136,21 @@ func (s *SysMenuController) Edit(c *gin.Context) {
|
|||||||
// 检查数据是否存在
|
// 检查数据是否存在
|
||||||
menuInfo := s.sysMenuService.SelectMenuById(body.MenuID)
|
menuInfo := s.sysMenuService.SelectMenuById(body.MenuID)
|
||||||
if menuInfo.MenuID != body.MenuID {
|
if menuInfo.MenuID != body.MenuID {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问菜单数据"))
|
// 没有可访问菜单数据
|
||||||
|
c.JSON(200, result.ErrMsg("No accessible menu data"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 父级ID不为0是要检查
|
// 父级ID不为0是要检查
|
||||||
if body.ParentID != "0" {
|
if body.ParentID != "0" {
|
||||||
menuParent := s.sysMenuService.SelectMenuById(body.ParentID)
|
menuParent := s.sysMenuService.SelectMenuById(body.ParentID)
|
||||||
if menuParent.MenuID != body.ParentID {
|
if menuParent.MenuID != body.ParentID {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问菜单数据"))
|
c.JSON(200, result.ErrMsg("No accessible menu data"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 禁用菜单时检查父菜单是否使用
|
// 禁用菜单时检查父菜单是否使用
|
||||||
if body.Status == common.STATUS_YES && menuParent.Status == common.STATUS_NO {
|
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
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,7 +159,8 @@ func (s *SysMenuController) Edit(c *gin.Context) {
|
|||||||
if menu.TYPE_DIR == body.MenuType || menu.TYPE_MENU == body.MenuType {
|
if menu.TYPE_DIR == body.MenuType || menu.TYPE_MENU == body.MenuType {
|
||||||
uniqueNenuPath := s.sysMenuService.CheckUniqueMenuPath(body.Path, body.ParentID, body.MenuID)
|
uniqueNenuPath := s.sysMenuService.CheckUniqueMenuPath(body.Path, body.ParentID, body.MenuID)
|
||||||
if !uniqueNenuPath {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -162,14 +169,16 @@ func (s *SysMenuController) Edit(c *gin.Context) {
|
|||||||
// 检查名称唯一
|
// 检查名称唯一
|
||||||
uniqueNenuName := s.sysMenuService.CheckUniqueMenuName(body.MenuName, body.ParentID, body.MenuID)
|
uniqueNenuName := s.sysMenuService.CheckUniqueMenuName(body.MenuName, body.ParentID, body.MenuID)
|
||||||
if !uniqueNenuName {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 外链菜单需要符合网站http(s)开头
|
// 外链菜单需要符合网站http(s)开头
|
||||||
if body.IsFrame == common.STATUS_NO && !regular.ValidHttp(body.Path) {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -178,7 +187,8 @@ func (s *SysMenuController) Edit(c *gin.Context) {
|
|||||||
if body.Status == common.STATUS_NO {
|
if body.Status == common.STATUS_NO {
|
||||||
hasStatus := s.sysMenuService.HasChildByMenuIdAndStatus(body.MenuID, common.STATUS_YES)
|
hasStatus := s.sysMenuService.HasChildByMenuIdAndStatus(body.MenuID, common.STATUS_YES)
|
||||||
if hasStatus > 0 {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -199,21 +209,23 @@ func (s *SysMenuController) Edit(c *gin.Context) {
|
|||||||
func (s *SysMenuController) Remove(c *gin.Context) {
|
func (s *SysMenuController) Remove(c *gin.Context) {
|
||||||
menuId := c.Param("menuId")
|
menuId := c.Param("menuId")
|
||||||
if menuId == "" {
|
if menuId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查数据是否存在
|
// 检查数据是否存在
|
||||||
menu := s.sysMenuService.SelectMenuById(menuId)
|
menu := s.sysMenuService.SelectMenuById(menuId)
|
||||||
if menu.MenuID != menuId {
|
if menu.MenuID != menuId {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问菜单数据!"))
|
// 没有可访问菜单数据!
|
||||||
|
c.JSON(200, result.ErrMsg("There is no accessible menu data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否存在子菜单
|
// 检查是否存在子菜单
|
||||||
hasChild := s.sysMenuService.HasChildByMenuIdAndStatus(menuId, "")
|
hasChild := s.sysMenuService.HasChildByMenuIdAndStatus(menuId, "")
|
||||||
if hasChild > 0 {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -221,14 +233,15 @@ func (s *SysMenuController) Remove(c *gin.Context) {
|
|||||||
// 检查是否分配给角色
|
// 检查是否分配给角色
|
||||||
existRole := s.sysMenuService.CheckMenuExistRole(menuId)
|
existRole := s.sysMenuService.CheckMenuExistRole(menuId)
|
||||||
if existRole > 0 {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
rows := s.sysMenuService.DeleteMenuById(menuId)
|
rows := s.sysMenuService.DeleteMenuById(menuId)
|
||||||
if rows > 0 {
|
if rows > 0 {
|
||||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
msg := fmt.Sprintf("Deleted successfully: %d", rows)
|
||||||
c.JSON(200, result.OkMsg(msg))
|
c.JSON(200, result.OkMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -262,7 +275,7 @@ func (s *SysMenuController) TreeSelect(c *gin.Context) {
|
|||||||
func (s *SysMenuController) RoleMenuTreeSelect(c *gin.Context) {
|
func (s *SysMenuController) RoleMenuTreeSelect(c *gin.Context) {
|
||||||
roleId := c.Param("roleId")
|
roleId := c.Param("roleId")
|
||||||
if roleId == "" {
|
if roleId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ func (s *SysNoticeController) List(c *gin.Context) {
|
|||||||
func (s *SysNoticeController) Info(c *gin.Context) {
|
func (s *SysNoticeController) Info(c *gin.Context) {
|
||||||
noticeId := c.Param("noticeId")
|
noticeId := c.Param("noticeId")
|
||||||
if noticeId == "" {
|
if noticeId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := s.sysNoticeService.SelectNoticeById(noticeId)
|
data := s.sysNoticeService.SelectNoticeById(noticeId)
|
||||||
@@ -60,7 +60,7 @@ func (s *SysNoticeController) Add(c *gin.Context) {
|
|||||||
var body model.SysNotice
|
var body model.SysNotice
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.NoticeID != "" {
|
if err != nil || body.NoticeID != "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,14 +80,15 @@ func (s *SysNoticeController) Edit(c *gin.Context) {
|
|||||||
var body model.SysNotice
|
var body model.SysNotice
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.NoticeID == "" {
|
if err != nil || body.NoticeID == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
notice := s.sysNoticeService.SelectNoticeById(body.NoticeID)
|
notice := s.sysNoticeService.SelectNoticeById(body.NoticeID)
|
||||||
if notice.NoticeID != 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +107,7 @@ func (s *SysNoticeController) Edit(c *gin.Context) {
|
|||||||
func (s *SysNoticeController) Remove(c *gin.Context) {
|
func (s *SysNoticeController) Remove(c *gin.Context) {
|
||||||
noticeIds := c.Param("noticeIds")
|
noticeIds := c.Param("noticeIds")
|
||||||
if noticeIds == "" {
|
if noticeIds == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 处理字符转id数组后去重
|
// 处理字符转id数组后去重
|
||||||
@@ -121,6 +122,6 @@ func (s *SysNoticeController) Remove(c *gin.Context) {
|
|||||||
c.JSON(200, result.ErrMsg(err.Error()))
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
msg := fmt.Sprintf("Deleted successfully: %d", rows)
|
||||||
c.JSON(200, result.OkMsg(msg))
|
c.JSON(200, result.OkMsg(msg))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ func (s *SysPostController) List(c *gin.Context) {
|
|||||||
func (s *SysPostController) Info(c *gin.Context) {
|
func (s *SysPostController) Info(c *gin.Context) {
|
||||||
postId := c.Param("postId")
|
postId := c.Param("postId")
|
||||||
if postId == "" {
|
if postId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := s.sysPostService.SelectPostById(postId)
|
data := s.sysPostService.SelectPostById(postId)
|
||||||
@@ -63,14 +63,15 @@ func (s *SysPostController) Add(c *gin.Context) {
|
|||||||
var body model.SysPost
|
var body model.SysPost
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.PostID != "" {
|
if err != nil || body.PostID != "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查名称唯一
|
// 检查名称唯一
|
||||||
uniqueuPostName := s.sysPostService.CheckUniquePostName(body.PostName, "")
|
uniqueuPostName := s.sysPostService.CheckUniquePostName(body.PostName, "")
|
||||||
if !uniqueuPostName {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -78,7 +79,8 @@ func (s *SysPostController) Add(c *gin.Context) {
|
|||||||
// 检查编码属性值唯一
|
// 检查编码属性值唯一
|
||||||
uniquePostCode := s.sysPostService.CheckUniquePostCode(body.PostCode, "")
|
uniquePostCode := s.sysPostService.CheckUniquePostCode(body.PostCode, "")
|
||||||
if !uniquePostCode {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -99,21 +101,23 @@ func (s *SysPostController) Edit(c *gin.Context) {
|
|||||||
var body model.SysPost
|
var body model.SysPost
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.PostID == "" {
|
if err != nil || body.PostID == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
post := s.sysPostService.SelectPostById(body.PostID)
|
post := s.sysPostService.SelectPostById(body.PostID)
|
||||||
if post.PostID != body.PostID {
|
if post.PostID != body.PostID {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问岗位数据!"))
|
// 没有可访问岗位数据!
|
||||||
|
c.JSON(200, result.ErrMsg("There is no accessible post data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查名称唯一
|
// 检查名称唯一
|
||||||
uniqueuPostName := s.sysPostService.CheckUniquePostName(body.PostName, body.PostID)
|
uniqueuPostName := s.sysPostService.CheckUniquePostName(body.PostName, body.PostID)
|
||||||
if !uniqueuPostName {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -121,7 +125,8 @@ func (s *SysPostController) Edit(c *gin.Context) {
|
|||||||
// 检查编码属性值唯一
|
// 检查编码属性值唯一
|
||||||
uniquePostCode := s.sysPostService.CheckUniquePostCode(body.PostCode, body.PostID)
|
uniquePostCode := s.sysPostService.CheckUniquePostCode(body.PostCode, body.PostID)
|
||||||
if !uniquePostCode {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -141,7 +146,7 @@ func (s *SysPostController) Edit(c *gin.Context) {
|
|||||||
func (s *SysPostController) Remove(c *gin.Context) {
|
func (s *SysPostController) Remove(c *gin.Context) {
|
||||||
postIds := c.Param("postIds")
|
postIds := c.Param("postIds")
|
||||||
if postIds == "" {
|
if postIds == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 处理字符转id数组后去重
|
// 处理字符转id数组后去重
|
||||||
@@ -156,7 +161,7 @@ func (s *SysPostController) Remove(c *gin.Context) {
|
|||||||
c.JSON(200, result.ErrMsg(err.Error()))
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
msg := fmt.Sprintf("Deleted successfully: %d", rows)
|
||||||
c.JSON(200, result.OkMsg(msg))
|
c.JSON(200, result.OkMsg(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +173,8 @@ func (s *SysPostController) Export(c *gin.Context) {
|
|||||||
querys := ctx.BodyJSONMap(c)
|
querys := ctx.BodyJSONMap(c)
|
||||||
data := s.sysPostService.SelectPostPage(querys)
|
data := s.sysPostService.SelectPostPage(querys)
|
||||||
if data["total"].(int64) == 0 {
|
if data["total"].(int64) == 0 {
|
||||||
c.JSON(200, result.ErrMsg("导出数据记录为空"))
|
// 导出数据记录为空
|
||||||
|
c.JSON(200, result.ErrMsg("Export data record is empty"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rows := data["rows"].([]model.SysPost)
|
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())
|
fileName := fmt.Sprintf("post_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
||||||
// 第一行表头标题
|
// 第一行表头标题
|
||||||
headerCells := map[string]string{
|
headerCells := map[string]string{
|
||||||
"A1": "岗位编号",
|
"A1": "PostID",
|
||||||
"B1": "岗位编码",
|
"B1": "PostCode",
|
||||||
"C1": "岗位名称",
|
"C1": "PostName",
|
||||||
"D1": "岗位排序",
|
"D1": "PostSort",
|
||||||
"E1": "状态",
|
"E1": "Status",
|
||||||
}
|
}
|
||||||
// 从第二行开始的数据
|
// 从第二行开始的数据
|
||||||
dataCells := make([]map[string]any, 0)
|
dataCells := make([]map[string]any, 0)
|
||||||
for i, row := range rows {
|
for i, row := range rows {
|
||||||
idx := strconv.Itoa(i + 2)
|
idx := strconv.Itoa(i + 2)
|
||||||
statusValue := "停用"
|
statusValue := "deactivate"
|
||||||
if row.Status == "1" {
|
if row.Status == "1" {
|
||||||
statusValue = "正常"
|
statusValue = "normalcy"
|
||||||
}
|
}
|
||||||
dataCells = append(dataCells, map[string]any{
|
dataCells = append(dataCells, map[string]any{
|
||||||
"A" + idx: row.PostID,
|
"A" + idx: row.PostID,
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ func (s *SysProfileController) Info(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
isAdmin := config.IsAdmin(loginUser.UserID)
|
isAdmin := config.IsAdmin(loginUser.UserID)
|
||||||
if isAdmin {
|
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)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.Sex == "" {
|
if err != nil || body.Sex == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,12 +111,14 @@ func (s *SysProfileController) UpdateProfile(c *gin.Context) {
|
|||||||
if regular.ValidMobile(body.PhoneNumber) {
|
if regular.ValidMobile(body.PhoneNumber) {
|
||||||
uniquePhone := s.sysUserService.CheckUniquePhone(body.PhoneNumber, userId)
|
uniquePhone := s.sysUserService.CheckUniquePhone(body.PhoneNumber, userId)
|
||||||
if !uniquePhone {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} 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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -127,12 +129,14 @@ func (s *SysProfileController) UpdateProfile(c *gin.Context) {
|
|||||||
if regular.ValidEmail(body.Email) {
|
if regular.ValidEmail(body.Email) {
|
||||||
uniqueEmail := s.sysUserService.CheckUniqueEmail(body.Email, userId)
|
uniqueEmail := s.sysUserService.CheckUniqueEmail(body.Email, userId)
|
||||||
if !uniqueEmail {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} 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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -165,7 +169,8 @@ func (s *SysProfileController) UpdateProfile(c *gin.Context) {
|
|||||||
c.JSON(200, result.Ok(nil))
|
c.JSON(200, result.Ok(nil))
|
||||||
return
|
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)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,19 +201,22 @@ func (s *SysProfileController) UpdatePwd(c *gin.Context) {
|
|||||||
// 查询当前登录用户信息得到密码值
|
// 查询当前登录用户信息得到密码值
|
||||||
user := s.sysUserService.SelectUserById(userId)
|
user := s.sysUserService.SelectUserById(userId)
|
||||||
if user.UserID != userId {
|
if user.UserID != userId {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问用户数据!"))
|
// 没有可访问用户数据!
|
||||||
|
c.JSON(200, result.ErrMsg("There is no accessible user data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查匹配用户密码
|
// 检查匹配用户密码
|
||||||
oldCompare := crypto.BcryptCompare(body.OldPassword, user.Password)
|
oldCompare := crypto.BcryptCompare(body.OldPassword, user.Password)
|
||||||
if !oldCompare {
|
if !oldCompare {
|
||||||
c.JSON(200, result.ErrMsg("修改密码失败,旧密码错误"))
|
// 修改密码失败,旧密码错误
|
||||||
|
c.JSON(200, result.ErrMsg("Failed to change password, old password is wrong"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
newCompare := crypto.BcryptCompare(body.NewPassword, user.Password)
|
newCompare := crypto.BcryptCompare(body.NewPassword, user.Password)
|
||||||
if newCompare {
|
if newCompare {
|
||||||
c.JSON(200, result.ErrMsg("新密码不能与旧密码相同"))
|
// 新密码不能与旧密码相同
|
||||||
|
c.JSON(200, result.ErrMsg("The new password cannot be the same as the old one"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +240,7 @@ func (s *SysProfileController) UpdatePwd(c *gin.Context) {
|
|||||||
func (s *SysProfileController) Avatar(c *gin.Context) {
|
func (s *SysProfileController) Avatar(c *gin.Context) {
|
||||||
formFile, err := c.FormFile("file")
|
formFile, err := c.FormFile("file")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ func (s *SysRoleController) List(c *gin.Context) {
|
|||||||
func (s *SysRoleController) Info(c *gin.Context) {
|
func (s *SysRoleController) Info(c *gin.Context) {
|
||||||
roleId := c.Param("roleId")
|
roleId := c.Param("roleId")
|
||||||
if roleId == "" {
|
if roleId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := s.sysRoleService.SelectRoleById(roleId)
|
data := s.sysRoleService.SelectRoleById(roleId)
|
||||||
@@ -69,14 +69,15 @@ func (s *SysRoleController) Add(c *gin.Context) {
|
|||||||
var body model.SysRole
|
var body model.SysRole
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.RoleID != "" {
|
if err != nil || body.RoleID != "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断角色名称是否唯一
|
// 判断角色名称是否唯一
|
||||||
uniqueRoleName := s.sysRoleService.CheckUniqueRoleName(body.RoleName, "")
|
uniqueRoleName := s.sysRoleService.CheckUniqueRoleName(body.RoleName, "")
|
||||||
if !uniqueRoleName {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -84,7 +85,8 @@ func (s *SysRoleController) Add(c *gin.Context) {
|
|||||||
// 判断角色键值是否唯一
|
// 判断角色键值是否唯一
|
||||||
uniqueRoleKey := s.sysRoleService.CheckUniqueRoleKey(body.RoleKey, "")
|
uniqueRoleKey := s.sysRoleService.CheckUniqueRoleKey(body.RoleKey, "")
|
||||||
if !uniqueRoleKey {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -105,27 +107,30 @@ func (s *SysRoleController) Edit(c *gin.Context) {
|
|||||||
var body model.SysRole
|
var body model.SysRole
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.RoleID == "" {
|
if err != nil || body.RoleID == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否管理员角色
|
// 检查是否管理员角色
|
||||||
if body.RoleID == admin.ROLE_ID {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
role := s.sysRoleService.SelectRoleById(body.RoleID)
|
role := s.sysRoleService.SelectRoleById(body.RoleID)
|
||||||
if role.RoleID != body.RoleID {
|
if role.RoleID != body.RoleID {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问角色数据!"))
|
// 没有可访问角色数据!
|
||||||
|
c.JSON(200, result.ErrMsg("There is no accessible role data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断角色名称是否唯一
|
// 判断角色名称是否唯一
|
||||||
uniqueRoleName := s.sysRoleService.CheckUniqueRoleName(body.RoleName, body.RoleID)
|
uniqueRoleName := s.sysRoleService.CheckUniqueRoleName(body.RoleName, body.RoleID)
|
||||||
if !uniqueRoleName {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -133,7 +138,8 @@ func (s *SysRoleController) Edit(c *gin.Context) {
|
|||||||
// 判断角色键值是否唯一
|
// 判断角色键值是否唯一
|
||||||
uniqueRoleKey := s.sysRoleService.CheckUniqueRoleKey(body.RoleKey, body.RoleID)
|
uniqueRoleKey := s.sysRoleService.CheckUniqueRoleKey(body.RoleKey, body.RoleID)
|
||||||
if !uniqueRoleKey {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -153,7 +159,7 @@ func (s *SysRoleController) Edit(c *gin.Context) {
|
|||||||
func (s *SysRoleController) Remove(c *gin.Context) {
|
func (s *SysRoleController) Remove(c *gin.Context) {
|
||||||
roleIds := c.Param("roleIds")
|
roleIds := c.Param("roleIds")
|
||||||
if roleIds == "" {
|
if roleIds == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 处理字符转id数组后去重
|
// 处理字符转id数组后去重
|
||||||
@@ -166,7 +172,8 @@ func (s *SysRoleController) Remove(c *gin.Context) {
|
|||||||
// 检查是否管理员角色
|
// 检查是否管理员角色
|
||||||
for _, id := range uniqueIDs {
|
for _, id := range uniqueIDs {
|
||||||
if id == admin.ROLE_ID {
|
if id == admin.ROLE_ID {
|
||||||
c.JSON(200, result.ErrMsg("不允许操作管理员角色"))
|
// 不允许操作管理员角色
|
||||||
|
c.JSON(200, result.ErrMsg("The administrator role is not allowed to operate"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,7 +182,7 @@ func (s *SysRoleController) Remove(c *gin.Context) {
|
|||||||
c.JSON(200, result.ErrMsg(err.Error()))
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
msg := fmt.Sprintf("Deleted successfully: %d", rows)
|
||||||
c.JSON(200, result.OkMsg(msg))
|
c.JSON(200, result.OkMsg(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,26 +198,29 @@ func (s *SysRoleController) Status(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否管理员角色
|
// 检查是否管理员角色
|
||||||
if body.RoleID == admin.ROLE_ID {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
role := s.sysRoleService.SelectRoleById(body.RoleID)
|
role := s.sysRoleService.SelectRoleById(body.RoleID)
|
||||||
if role.RoleID != body.RoleID {
|
if role.RoleID != body.RoleID {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问角色数据!"))
|
// 没有可访问角色数据!
|
||||||
|
c.JSON(200, result.ErrMsg("There is no accessible role data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 与旧值相等不变更
|
// 与旧值相等不变更
|
||||||
if role.Status == body.Status {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,20 +255,22 @@ func (s *SysRoleController) DataScope(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否管理员角色
|
// 检查是否管理员角色
|
||||||
if body.RoleID == admin.ROLE_ID {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
role := s.sysRoleService.SelectRoleById(body.RoleID)
|
role := s.sysRoleService.SelectRoleById(body.RoleID)
|
||||||
if role.RoleID != body.RoleID {
|
if role.RoleID != body.RoleID {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问角色数据!"))
|
// 没有可访问角色数据!
|
||||||
|
c.JSON(200, result.ErrMsg("There is no accessible role data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,14 +298,15 @@ func (s *SysRoleController) AuthUserAllocatedList(c *gin.Context) {
|
|||||||
querys := ctx.QueryMap(c)
|
querys := ctx.QueryMap(c)
|
||||||
roleId, ok := querys["roleId"]
|
roleId, ok := querys["roleId"]
|
||||||
if !ok || roleId == "" {
|
if !ok || roleId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
role := s.sysRoleService.SelectRoleById(roleId.(string))
|
role := s.sysRoleService.SelectRoleById(roleId.(string))
|
||||||
if role.RoleID != roleId {
|
if role.RoleID != roleId {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问角色数据!"))
|
// 没有可访问角色数据!
|
||||||
|
c.JSON(200, result.ErrMsg("There is no accessible role data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +329,7 @@ func (s *SysRoleController) AuthUserChecked(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,7 +344,7 @@ func (s *SysRoleController) AuthUserChecked(c *gin.Context) {
|
|||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
role := s.sysRoleService.SelectRoleById(body.RoleID)
|
role := s.sysRoleService.SelectRoleById(body.RoleID)
|
||||||
if role.RoleID != body.RoleID {
|
if role.RoleID != body.RoleID {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问角色数据!"))
|
c.JSON(200, result.ErrMsg("There is no accessible role data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,7 +370,8 @@ func (s *SysRoleController) Export(c *gin.Context) {
|
|||||||
dataScopeSQL := ctx.LoginUserToDataScopeSQL(c, "d", "")
|
dataScopeSQL := ctx.LoginUserToDataScopeSQL(c, "d", "")
|
||||||
data := s.sysRoleService.SelectRolePage(querys, dataScopeSQL)
|
data := s.sysRoleService.SelectRolePage(querys, dataScopeSQL)
|
||||||
if data["total"].(int64) == 0 {
|
if data["total"].(int64) == 0 {
|
||||||
c.JSON(200, result.ErrMsg("导出数据记录为空"))
|
// 导出数据记录为空
|
||||||
|
c.JSON(200, result.ErrMsg("Export data record is empty"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rows := data["rows"].([]model.SysRole)
|
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())
|
fileName := fmt.Sprintf("role_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
||||||
// 第一行表头标题
|
// 第一行表头标题
|
||||||
headerCells := map[string]string{
|
headerCells := map[string]string{
|
||||||
"A1": "角色序号",
|
"A1": "RoleID",
|
||||||
"B1": "角色名称",
|
"B1": "RoleName",
|
||||||
"C1": "角色权限",
|
"C1": "RoleKey",
|
||||||
"D1": "角色排序",
|
"D1": "RoleSort",
|
||||||
"E1": "数据范围",
|
"E1": "DataScope",
|
||||||
"F1": "角色状态",
|
"F1": "Status",
|
||||||
}
|
}
|
||||||
// 从第二行开始的数据
|
// 从第二行开始的数据
|
||||||
dataCells := make([]map[string]any, 0)
|
dataCells := make([]map[string]any, 0)
|
||||||
for i, row := range rows {
|
for i, row := range rows {
|
||||||
idx := strconv.Itoa(i + 2)
|
idx := strconv.Itoa(i + 2)
|
||||||
// 数据范围
|
// 数据范围
|
||||||
dataScope := "空"
|
dataScope := "Empty"
|
||||||
if v, ok := roledatascope.RoleDataScope[row.DataScope]; ok {
|
if v, ok := roledatascope.RoleDataScope[row.DataScope]; ok {
|
||||||
dataScope = v
|
dataScope = v
|
||||||
}
|
}
|
||||||
// 角色状态
|
// 角色状态
|
||||||
statusValue := "停用"
|
statusValue := "deactivate"
|
||||||
if row.Status == "1" {
|
if row.Status == "1" {
|
||||||
statusValue = "正常"
|
statusValue = "normalcy"
|
||||||
}
|
}
|
||||||
dataCells = append(dataCells, map[string]any{
|
dataCells = append(dataCells, map[string]any{
|
||||||
"A" + idx: row.RoleID,
|
"A" + idx: row.RoleID,
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ func (s *SysUserController) List(c *gin.Context) {
|
|||||||
func (s *SysUserController) Info(c *gin.Context) {
|
func (s *SysUserController) Info(c *gin.Context) {
|
||||||
userId := c.Param("userId")
|
userId := c.Param("userId")
|
||||||
if userId == "" {
|
if userId == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 查询系统角色列表
|
// 查询系统角色列表
|
||||||
@@ -95,7 +95,7 @@ func (s *SysUserController) Info(c *gin.Context) {
|
|||||||
// 检查用户是否存在
|
// 检查用户是否存在
|
||||||
user := s.sysUserService.SelectUserById(userId)
|
user := s.sysUserService.SelectUserById(userId)
|
||||||
if user.UserID != userId {
|
if user.UserID != userId {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问用户数据!"))
|
c.JSON(200, result.ErrMsg("There is no accessible user data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ func (s *SysUserController) Add(c *gin.Context) {
|
|||||||
var body model.SysUser
|
var body model.SysUser
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.UserID != "" {
|
if err != nil || body.UserID != "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ func (s *SysUserController) Add(c *gin.Context) {
|
|||||||
Password string `json:"password" binding:"required"`
|
Password string `json:"password" binding:"required"`
|
||||||
}
|
}
|
||||||
if err := c.ShouldBindBodyWith(&bodyPassword, binding.JSON); err != nil {
|
if err := c.ShouldBindBodyWith(&bodyPassword, binding.JSON); err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
body.Password = bodyPassword.Password
|
body.Password = bodyPassword.Password
|
||||||
@@ -145,7 +145,8 @@ func (s *SysUserController) Add(c *gin.Context) {
|
|||||||
// 检查用户登录账号是否唯一
|
// 检查用户登录账号是否唯一
|
||||||
uniqueUserName := s.sysUserService.CheckUniqueUserName(body.UserName, "")
|
uniqueUserName := s.sysUserService.CheckUniqueUserName(body.UserName, "")
|
||||||
if !uniqueUserName {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -155,12 +156,14 @@ func (s *SysUserController) Add(c *gin.Context) {
|
|||||||
if regular.ValidMobile(body.PhoneNumber) {
|
if regular.ValidMobile(body.PhoneNumber) {
|
||||||
uniquePhone := s.sysUserService.CheckUniquePhone(body.PhoneNumber, "")
|
uniquePhone := s.sysUserService.CheckUniquePhone(body.PhoneNumber, "")
|
||||||
if !uniquePhone {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} 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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -171,12 +174,14 @@ func (s *SysUserController) Add(c *gin.Context) {
|
|||||||
if regular.ValidEmail(body.Email) {
|
if regular.ValidEmail(body.Email) {
|
||||||
uniqueEmail := s.sysUserService.CheckUniqueEmail(body.Email, "")
|
uniqueEmail := s.sysUserService.CheckUniqueEmail(body.Email, "")
|
||||||
if !uniqueEmail {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} 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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -198,26 +203,29 @@ func (s *SysUserController) Edit(c *gin.Context) {
|
|||||||
var body model.SysUser
|
var body model.SysUser
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil || body.UserID == "" {
|
if err != nil || body.UserID == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否管理员用户
|
// 检查是否管理员用户
|
||||||
if config.IsAdmin(body.UserID) {
|
if config.IsAdmin(body.UserID) {
|
||||||
c.JSON(200, result.ErrMsg("不允许操作管理员用户"))
|
// 不允许操作管理员用户
|
||||||
|
c.JSON(200, result.ErrMsg("Administrator users are not allowed to operate"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
user := s.sysUserService.SelectUserById(body.UserID)
|
user := s.sysUserService.SelectUserById(body.UserID)
|
||||||
if user.UserID != body.UserID {
|
if user.UserID != body.UserID {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问用户数据!"))
|
// 没有可访问用户数据!
|
||||||
|
c.JSON(200, result.ErrMsg("There is no accessible user data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查用户登录账号是否唯一
|
// 检查用户登录账号是否唯一
|
||||||
uniqueUserName := s.sysUserService.CheckUniqueUserName(body.UserName, body.UserID)
|
uniqueUserName := s.sysUserService.CheckUniqueUserName(body.UserName, body.UserID)
|
||||||
if !uniqueUserName {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -227,12 +235,14 @@ func (s *SysUserController) Edit(c *gin.Context) {
|
|||||||
if regular.ValidMobile(body.PhoneNumber) {
|
if regular.ValidMobile(body.PhoneNumber) {
|
||||||
uniquePhone := s.sysUserService.CheckUniquePhone(body.PhoneNumber, body.UserID)
|
uniquePhone := s.sysUserService.CheckUniquePhone(body.PhoneNumber, body.UserID)
|
||||||
if !uniquePhone {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} 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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -243,12 +253,14 @@ func (s *SysUserController) Edit(c *gin.Context) {
|
|||||||
if regular.ValidEmail(body.Email) {
|
if regular.ValidEmail(body.Email) {
|
||||||
uniqueEmail := s.sysUserService.CheckUniqueEmail(body.Email, body.UserID)
|
uniqueEmail := s.sysUserService.CheckUniqueEmail(body.Email, body.UserID)
|
||||||
if !uniqueEmail {
|
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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} 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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -273,7 +285,7 @@ func (s *SysUserController) Edit(c *gin.Context) {
|
|||||||
func (s *SysUserController) Remove(c *gin.Context) {
|
func (s *SysUserController) Remove(c *gin.Context) {
|
||||||
userIds := c.Param("userIds")
|
userIds := c.Param("userIds")
|
||||||
if userIds == "" {
|
if userIds == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 处理字符转id数组后去重
|
// 处理字符转id数组后去重
|
||||||
@@ -288,7 +300,8 @@ func (s *SysUserController) Remove(c *gin.Context) {
|
|||||||
c.JSON(200, result.ErrMsg(err.Error()))
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
// 删除成功:%d
|
||||||
|
msg := fmt.Sprintf("Deleted successfully: %d", rows)
|
||||||
c.JSON(200, result.OkMsg(msg))
|
c.JSON(200, result.OkMsg(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,23 +314,26 @@ func (s *SysUserController) ResetPwd(c *gin.Context) {
|
|||||||
Password string `json:"password" binding:"required"`
|
Password string `json:"password" binding:"required"`
|
||||||
}
|
}
|
||||||
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
|
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否管理员用户
|
// 检查是否管理员用户
|
||||||
if config.IsAdmin(body.UserID) {
|
if config.IsAdmin(body.UserID) {
|
||||||
c.JSON(200, result.ErrMsg("不允许操作管理员用户"))
|
// 不允许操作管理员用户
|
||||||
|
c.JSON(200, result.ErrMsg("Administrator users are not allowed to operate"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
user := s.sysUserService.SelectUserById(body.UserID)
|
user := s.sysUserService.SelectUserById(body.UserID)
|
||||||
if user.UserID != body.UserID {
|
if user.UserID != body.UserID {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问用户数据!"))
|
// 没有可访问用户数据!
|
||||||
|
c.JSON(200, result.ErrMsg("There is no accessible user data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !regular.ValidPassword(body.Password) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,20 +360,22 @@ func (s *SysUserController) Status(c *gin.Context) {
|
|||||||
Status string `json:"status" binding:"required"`
|
Status string `json:"status" binding:"required"`
|
||||||
}
|
}
|
||||||
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
|
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
user := s.sysUserService.SelectUserById(body.UserID)
|
user := s.sysUserService.SelectUserById(body.UserID)
|
||||||
if user.UserID != body.UserID {
|
if user.UserID != body.UserID {
|
||||||
c.JSON(200, result.ErrMsg("没有权限访问用户数据!"))
|
// 没有可访问用户数据!
|
||||||
|
c.JSON(200, result.ErrMsg("There is no accessible user data!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 与旧值相等不变更
|
// 与旧值相等不变更
|
||||||
if user.Status == body.Status {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,7 +402,8 @@ func (s *SysUserController) Export(c *gin.Context) {
|
|||||||
dataScopeSQL := ctx.LoginUserToDataScopeSQL(c, "d", "u")
|
dataScopeSQL := ctx.LoginUserToDataScopeSQL(c, "d", "u")
|
||||||
data := s.sysUserService.SelectUserPage(querys, dataScopeSQL)
|
data := s.sysUserService.SelectUserPage(querys, dataScopeSQL)
|
||||||
if data["total"].(int64) == 0 {
|
if data["total"].(int64) == 0 {
|
||||||
c.JSON(200, result.ErrMsg("导出数据记录为空"))
|
// 导出数据记录为空
|
||||||
|
c.JSON(200, result.ErrMsg("Export data record is empty"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rows := data["rows"].([]model.SysUser)
|
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())
|
fileName := fmt.Sprintf("user_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
||||||
// 第一行表头标题
|
// 第一行表头标题
|
||||||
headerCells := map[string]string{
|
headerCells := map[string]string{
|
||||||
"A1": "用户编号",
|
"A1": "UserID",
|
||||||
"B1": "登录名称",
|
"B1": "UserName",
|
||||||
"C1": "用户名称",
|
"C1": "NickName",
|
||||||
"D1": "用户邮箱",
|
"D1": "Email",
|
||||||
"E1": "手机号码",
|
"E1": "PhoneNumber",
|
||||||
"F1": "用户性别",
|
"F1": "UserSex",
|
||||||
"G1": "帐号状态",
|
"G1": "Status",
|
||||||
"H1": "部门编号",
|
"H1": "DeptID",
|
||||||
"I1": "部门名称",
|
"I1": "DeptName",
|
||||||
"J1": "部门负责人",
|
"J1": "DeptLeader",
|
||||||
"K1": "最后登录IP",
|
"K1": "LoginIP",
|
||||||
"L1": "最后登录时间",
|
"L1": "LoginDate",
|
||||||
}
|
}
|
||||||
// 读取用户性别字典数据
|
// 读取用户性别字典数据
|
||||||
dictSysUserSex := s.sysDictDataService.SelectDictDataByType("sys_user_sex")
|
dictSysUserSex := s.sysDictDataService.SelectDictDataByType("sys_user_sex")
|
||||||
@@ -413,7 +432,7 @@ func (s *SysUserController) Export(c *gin.Context) {
|
|||||||
for i, row := range rows {
|
for i, row := range rows {
|
||||||
idx := strconv.Itoa(i + 2)
|
idx := strconv.Itoa(i + 2)
|
||||||
// 用户性别
|
// 用户性别
|
||||||
sysUserSex := "未知"
|
sysUserSex := "unknown"
|
||||||
for _, v := range dictSysUserSex {
|
for _, v := range dictSysUserSex {
|
||||||
if row.Sex == v.DictValue {
|
if row.Sex == v.DictValue {
|
||||||
sysUserSex = v.DictLabel
|
sysUserSex = v.DictLabel
|
||||||
@@ -421,9 +440,9 @@ func (s *SysUserController) Export(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 帐号状态
|
// 帐号状态
|
||||||
statusValue := "停用"
|
statusValue := "deactivate"
|
||||||
if row.Status == "1" {
|
if row.Status == "1" {
|
||||||
statusValue = "正常"
|
statusValue = "normalcy"
|
||||||
}
|
}
|
||||||
dataCells = append(dataCells, map[string]any{
|
dataCells = append(dataCells, map[string]any{
|
||||||
"A" + idx: row.UserID,
|
"A" + idx: row.UserID,
|
||||||
@@ -485,7 +504,7 @@ func (s *SysUserController) ImportData(c *gin.Context) {
|
|||||||
// 上传的文件
|
// 上传的文件
|
||||||
formFile, err := c.FormFile("file")
|
formFile, err := c.FormFile("file")
|
||||||
if err != nil || updateSupport == "" {
|
if err != nil || updateSupport == "" {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"fmt"
|
||||||
|
|
||||||
"ems.agt/src/framework/constants/cachekey"
|
"ems.agt/src/framework/constants/cachekey"
|
||||||
"ems.agt/src/framework/redis"
|
"ems.agt/src/framework/redis"
|
||||||
@@ -93,12 +93,13 @@ func (r *SysConfigImpl) DeleteConfigByIds(configIds []string) (int64, error) {
|
|||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
configs := r.sysConfigRepository.SelectConfigByIds(configIds)
|
configs := r.sysConfigRepository.SelectConfigByIds(configIds)
|
||||||
if len(configs) <= 0 {
|
if len(configs) <= 0 {
|
||||||
return 0, errors.New("没有权限访问参数配置数据!")
|
return 0, fmt.Errorf("there is no accessible parameter configuration data")
|
||||||
}
|
}
|
||||||
for _, config := range configs {
|
for _, config := range configs {
|
||||||
// 检查是否为内置参数
|
// 检查是否为内置参数
|
||||||
if config.ConfigType == "Y" {
|
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)
|
r.clearConfigCache(config.ConfigKey)
|
||||||
@@ -107,7 +108,8 @@ func (r *SysConfigImpl) DeleteConfigByIds(configIds []string) (int64, error) {
|
|||||||
rows := r.sysConfigRepository.DeleteConfigByIds(configIds)
|
rows := r.sysConfigRepository.DeleteConfigByIds(configIds)
|
||||||
return rows, nil
|
return rows, nil
|
||||||
}
|
}
|
||||||
return 0, errors.New("删除参数配置信息失败!")
|
// 删除参数配置信息失败!
|
||||||
|
return 0, fmt.Errorf("failed to delete parameter configuration information")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetConfigCache 重置参数缓存数据
|
// ResetConfigCache 重置参数缓存数据
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"fmt"
|
||||||
|
|
||||||
"ems.agt/src/modules/system/model"
|
"ems.agt/src/modules/system/model"
|
||||||
"ems.agt/src/modules/system/repository"
|
"ems.agt/src/modules/system/repository"
|
||||||
@@ -77,7 +77,8 @@ func (r *SysDictDataImpl) DeleteDictDataByCodes(dictCodes []string) (int64, erro
|
|||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
dictDatas := r.sysDictDataRepository.SelectDictDataByCodes(dictCodes)
|
dictDatas := r.sysDictDataRepository.SelectDictDataByCodes(dictCodes)
|
||||||
if len(dictDatas) <= 0 {
|
if len(dictDatas) <= 0 {
|
||||||
return 0, errors.New("没有权限访问字典编码数据!")
|
// 没有可访问字典编码数据!
|
||||||
|
return 0, fmt.Errorf("there is no accessible dictionary-encoded data")
|
||||||
}
|
}
|
||||||
if len(dictDatas) == len(dictCodes) {
|
if len(dictDatas) == len(dictCodes) {
|
||||||
for _, v := range dictDatas {
|
for _, v := range dictDatas {
|
||||||
@@ -88,7 +89,8 @@ func (r *SysDictDataImpl) DeleteDictDataByCodes(dictCodes []string) (int64, erro
|
|||||||
rows := r.sysDictDataRepository.DeleteDictDataByCodes(dictCodes)
|
rows := r.sysDictDataRepository.DeleteDictDataByCodes(dictCodes)
|
||||||
return rows, nil
|
return rows, nil
|
||||||
}
|
}
|
||||||
return 0, errors.New("删除字典数据信息失败!")
|
// 删除字典数据信息失败!
|
||||||
|
return 0, fmt.Errorf("failed to delete dictionary data information")
|
||||||
}
|
}
|
||||||
|
|
||||||
// InsertDictData 新增字典数据信息
|
// InsertDictData 新增字典数据信息
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"ems.agt/src/framework/constants/cachekey"
|
"ems.agt/src/framework/constants/cachekey"
|
||||||
@@ -107,14 +106,15 @@ func (r *SysDictTypeImpl) DeleteDictTypeByIDs(dictIDs []string) (int64, error) {
|
|||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
dictTypes := r.sysDictTypeRepository.SelectDictTypeByIDs(dictIDs)
|
dictTypes := r.sysDictTypeRepository.SelectDictTypeByIDs(dictIDs)
|
||||||
if len(dictTypes) <= 0 {
|
if len(dictTypes) <= 0 {
|
||||||
return 0, errors.New("没有权限访问字典类型数据!")
|
// 没有可访问字典类型数据!
|
||||||
|
return 0, fmt.Errorf("there is no accessible dictionary type data")
|
||||||
}
|
}
|
||||||
for _, v := range dictTypes {
|
for _, v := range dictTypes {
|
||||||
// 字典类型下级含有数据
|
// 字典类型下级含有数据
|
||||||
useCount := r.sysDictDataRepository.CountDictDataByType(v.DictType)
|
useCount := r.sysDictDataRepository.CountDictDataByType(v.DictType)
|
||||||
if useCount > 0 {
|
if useCount > 0 {
|
||||||
msg := fmt.Sprintf("【%s】存在字典数据,不能删除", v.DictName)
|
// 【%s】存在字典数据,不能删除
|
||||||
return 0, errors.New(msg)
|
return 0, fmt.Errorf("[%s] dictionary data exists and cannot be deleted", v.DictName)
|
||||||
}
|
}
|
||||||
// 清除缓存
|
// 清除缓存
|
||||||
r.ClearDictCache(v.DictType)
|
r.ClearDictCache(v.DictType)
|
||||||
@@ -123,7 +123,8 @@ func (r *SysDictTypeImpl) DeleteDictTypeByIDs(dictIDs []string) (int64, error) {
|
|||||||
rows := r.sysDictTypeRepository.DeleteDictTypeByIDs(dictIDs)
|
rows := r.sysDictTypeRepository.DeleteDictTypeByIDs(dictIDs)
|
||||||
return rows, nil
|
return rows, nil
|
||||||
}
|
}
|
||||||
return 0, errors.New("删除字典数据信息失败!")
|
// 删除字典数据信息失败!
|
||||||
|
return 0, fmt.Errorf("failed to delete dictionary data information")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetDictCache 重置字典缓存数据
|
// ResetDictCache 重置字典缓存数据
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"fmt"
|
||||||
|
|
||||||
"ems.agt/src/modules/system/model"
|
"ems.agt/src/modules/system/model"
|
||||||
"ems.agt/src/modules/system/repository"
|
"ems.agt/src/modules/system/repository"
|
||||||
@@ -55,17 +55,19 @@ func (r *SysNoticeImpl) DeleteNoticeByIds(noticeIds []string) (int64, error) {
|
|||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
notices := r.sysNoticeRepository.SelectNoticeByIds(noticeIds)
|
notices := r.sysNoticeRepository.SelectNoticeByIds(noticeIds)
|
||||||
if len(notices) <= 0 {
|
if len(notices) <= 0 {
|
||||||
return 0, errors.New("没有权限访问公告信息数据!")
|
return 0, fmt.Errorf("there is no accessible bulletin information data")
|
||||||
}
|
}
|
||||||
for _, notice := range notices {
|
for _, notice := range notices {
|
||||||
// 检查是否为已删除
|
// 检查是否为已删除
|
||||||
if notice.DelFlag == "1" {
|
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) {
|
if len(notices) == len(noticeIds) {
|
||||||
rows := r.sysNoticeRepository.DeleteNoticeByIds(noticeIds)
|
rows := r.sysNoticeRepository.DeleteNoticeByIds(noticeIds)
|
||||||
return rows, nil
|
return rows, nil
|
||||||
}
|
}
|
||||||
return 0, errors.New("删除公告信息失败!")
|
// 删除公告信息失败!
|
||||||
|
return 0, fmt.Errorf("failed to delete the announcement message")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"ems.agt/src/modules/system/model"
|
"ems.agt/src/modules/system/model"
|
||||||
@@ -54,20 +53,22 @@ func (r *SysPostImpl) DeletePostByIds(postIds []string) (int64, error) {
|
|||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
posts := r.sysPostRepository.SelectPostByIds(postIds)
|
posts := r.sysPostRepository.SelectPostByIds(postIds)
|
||||||
if len(posts) <= 0 {
|
if len(posts) <= 0 {
|
||||||
return 0, errors.New("没有权限访问岗位数据!")
|
// 没有可访问岗位数据!
|
||||||
|
return 0, fmt.Errorf("there is no accessible post data")
|
||||||
}
|
}
|
||||||
for _, post := range posts {
|
for _, post := range posts {
|
||||||
useCount := r.sysUserPostRepository.CountUserPostByPostId(post.PostID)
|
useCount := r.sysUserPostRepository.CountUserPostByPostId(post.PostID)
|
||||||
if useCount > 0 {
|
if useCount > 0 {
|
||||||
msg := fmt.Sprintf("【%s】已分配给用户,不能删除", post.PostName)
|
// 【%s】已分配给用户,不能删除
|
||||||
return 0, errors.New(msg)
|
return 0, fmt.Errorf("[%s] has been assigned to a user and cannot be deleted", post.PostName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(posts) == len(postIds) {
|
if len(posts) == len(postIds) {
|
||||||
rows := r.sysPostRepository.DeletePostByIds(postIds)
|
rows := r.sysPostRepository.DeletePostByIds(postIds)
|
||||||
return rows, nil
|
return rows, nil
|
||||||
}
|
}
|
||||||
return 0, errors.New("删除岗位信息失败!")
|
// 删除岗位信息失败!
|
||||||
|
return 0, fmt.Errorf("failed to delete post information")
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdatePost 修改岗位信息
|
// UpdatePost 修改岗位信息
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"ems.agt/src/modules/system/model"
|
"ems.agt/src/modules/system/model"
|
||||||
@@ -99,18 +98,20 @@ func (r *SysRoleImpl) DeleteRoleByIds(roleIds []string) (int64, error) {
|
|||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
roles := r.sysRoleRepository.SelectRoleByIds(roleIds)
|
roles := r.sysRoleRepository.SelectRoleByIds(roleIds)
|
||||||
if len(roles) <= 0 {
|
if len(roles) <= 0 {
|
||||||
return 0, errors.New("没有权限访问角色数据!")
|
// 没有可访问角色数据!
|
||||||
|
return 0, fmt.Errorf("there is no accessible role data")
|
||||||
}
|
}
|
||||||
for _, role := range roles {
|
for _, role := range roles {
|
||||||
// 检查是否为已删除
|
// 检查是否为已删除
|
||||||
if role.DelFlag == "1" {
|
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)
|
userCount := r.sysUserRoleRepository.CountUserRoleByRoleId(role.RoleID)
|
||||||
if userCount > 0 {
|
if userCount > 0 {
|
||||||
msg := fmt.Sprintf("【%s】已分配给用户,不能删除", role.RoleName)
|
// 【%s】已分配给用户,不能删除
|
||||||
return 0, errors.New(msg)
|
return 0, fmt.Errorf("[%s] has been assigned to a user and cannot be deleted", role.RoleName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(roles) == len(roleIds) {
|
if len(roles) == len(roleIds) {
|
||||||
@@ -121,7 +122,8 @@ func (r *SysRoleImpl) DeleteRoleByIds(roleIds []string) (int64, error) {
|
|||||||
rows := r.sysRoleRepository.DeleteRoleByIds(roleIds)
|
rows := r.sysRoleRepository.DeleteRoleByIds(roleIds)
|
||||||
return rows, nil
|
return rows, nil
|
||||||
}
|
}
|
||||||
return 0, errors.New("删除角色信息失败!")
|
// 删除角色信息失败!
|
||||||
|
return 0, fmt.Errorf("failed to delete role information")
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckUniqueRoleName 校验角色名称是否唯一
|
// CheckUniqueRoleName 校验角色名称是否唯一
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -138,7 +137,8 @@ func (r *SysUserImpl) DeleteUserByIds(userIds []string) (int64, error) {
|
|||||||
// 检查是否存在
|
// 检查是否存在
|
||||||
users := r.sysUserRepository.SelectUserByIds(userIds)
|
users := r.sysUserRepository.SelectUserByIds(userIds)
|
||||||
if len(users) <= 0 {
|
if len(users) <= 0 {
|
||||||
return 0, errors.New("没有权限访问用户数据!")
|
// 没有可访问用户数据!
|
||||||
|
return 0, fmt.Errorf("there is no accessible user data")
|
||||||
}
|
}
|
||||||
if len(users) == len(userIds) {
|
if len(users) == len(userIds) {
|
||||||
// 删除用户与角色关联
|
// 删除用户与角色关联
|
||||||
@@ -150,7 +150,7 @@ func (r *SysUserImpl) DeleteUserByIds(userIds []string) (int64, error) {
|
|||||||
rows := r.sysUserRepository.DeleteUserByIds(userIds)
|
rows := r.sysUserRepository.DeleteUserByIds(userIds)
|
||||||
return rows, nil
|
return rows, nil
|
||||||
}
|
}
|
||||||
return 0, errors.New("删除用户信息失败!")
|
return 0, fmt.Errorf("failed to delete user information")
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckUniqueUserName 校验用户名称是否唯一
|
// CheckUniqueUserName 校验用户名称是否唯一
|
||||||
@@ -211,7 +211,8 @@ func (r *SysUserImpl) ImportUser(rows []map[string]string, isUpdateSupport bool,
|
|||||||
if !ownItem {
|
if !ownItem {
|
||||||
mustItemArrStr := strings.Join(mustItemArr, "、")
|
mustItemArrStr := strings.Join(mustItemArr, "、")
|
||||||
failureNum++
|
failureNum++
|
||||||
failureMsgArr = append(failureMsgArr, fmt.Sprintf("表格中必填列表项,%s}", mustItemArrStr))
|
// 表格中必填列表项,
|
||||||
|
failureMsgArr = append(failureMsgArr, fmt.Sprintf("Required list items in the form, %s}", mustItemArrStr))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +225,7 @@ func (r *SysUserImpl) ImportUser(rows []map[string]string, isUpdateSupport bool,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sysUserStatus := common.STATUS_NO
|
sysUserStatus := common.STATUS_NO
|
||||||
if row["G"] == "正常" {
|
if row["G"] == "Normal" {
|
||||||
sysUserStatus = common.STATUS_YES
|
sysUserStatus = common.STATUS_YES
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,13 +247,15 @@ func (r *SysUserImpl) ImportUser(rows []map[string]string, isUpdateSupport bool,
|
|||||||
if regular.ValidMobile(newSysUser.PhoneNumber) {
|
if regular.ValidMobile(newSysUser.PhoneNumber) {
|
||||||
uniquePhone := r.CheckUniquePhone(newSysUser.PhoneNumber, "")
|
uniquePhone := r.CheckUniquePhone(newSysUser.PhoneNumber, "")
|
||||||
if !uniquePhone {
|
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++
|
failureNum++
|
||||||
failureMsgArr = append(failureMsgArr, msg)
|
failureMsgArr = append(failureMsgArr, msg)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} else {
|
} 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++
|
failureNum++
|
||||||
failureMsgArr = append(failureMsgArr, msg)
|
failureMsgArr = append(failureMsgArr, msg)
|
||||||
continue
|
continue
|
||||||
@@ -264,13 +267,15 @@ func (r *SysUserImpl) ImportUser(rows []map[string]string, isUpdateSupport bool,
|
|||||||
if regular.ValidEmail(newSysUser.Email) {
|
if regular.ValidEmail(newSysUser.Email) {
|
||||||
uniqueEmail := r.CheckUniqueEmail(newSysUser.Email, "")
|
uniqueEmail := r.CheckUniqueEmail(newSysUser.Email, "")
|
||||||
if !uniqueEmail {
|
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++
|
failureNum++
|
||||||
failureMsgArr = append(failureMsgArr, msg)
|
failureMsgArr = append(failureMsgArr, msg)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} else {
|
} 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++
|
failureNum++
|
||||||
failureMsgArr = append(failureMsgArr, msg)
|
failureMsgArr = append(failureMsgArr, msg)
|
||||||
continue
|
continue
|
||||||
@@ -283,11 +288,13 @@ func (r *SysUserImpl) ImportUser(rows []map[string]string, isUpdateSupport bool,
|
|||||||
newSysUser.CreateBy = operName
|
newSysUser.CreateBy = operName
|
||||||
insertId := r.InsertUser(newSysUser)
|
insertId := r.InsertUser(newSysUser)
|
||||||
if insertId != "" {
|
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++
|
successNum++
|
||||||
successMsgArr = append(successMsgArr, msg)
|
successMsgArr = append(successMsgArr, msg)
|
||||||
} else {
|
} 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++
|
failureNum++
|
||||||
failureMsgArr = append(failureMsgArr, msg)
|
failureMsgArr = append(failureMsgArr, msg)
|
||||||
}
|
}
|
||||||
@@ -300,11 +307,13 @@ func (r *SysUserImpl) ImportUser(rows []map[string]string, isUpdateSupport bool,
|
|||||||
newSysUser.UpdateBy = operName
|
newSysUser.UpdateBy = operName
|
||||||
rows := r.UpdateUser(newSysUser)
|
rows := r.UpdateUser(newSysUser)
|
||||||
if rows > 0 {
|
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++
|
successNum++
|
||||||
successMsgArr = append(successMsgArr, msg)
|
successMsgArr = append(successMsgArr, msg)
|
||||||
} else {
|
} 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++
|
failureNum++
|
||||||
failureMsgArr = append(failureMsgArr, msg)
|
failureMsgArr = append(failureMsgArr, msg)
|
||||||
}
|
}
|
||||||
@@ -313,10 +322,12 @@ func (r *SysUserImpl) ImportUser(rows []map[string]string, isUpdateSupport bool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if failureNum > 0 {
|
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/>")
|
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/>")
|
return strings.Join(successMsgArr, "<br/>")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,34 +31,34 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysConfigGroup.POST("",
|
sysConfigGroup.POST("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:config:add"}}),
|
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,
|
controller.NewSysConfig.Add,
|
||||||
)
|
)
|
||||||
sysConfigGroup.PUT("",
|
sysConfigGroup.PUT("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:config:edit"}}),
|
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,
|
controller.NewSysConfig.Edit,
|
||||||
)
|
)
|
||||||
sysConfigGroup.DELETE("/:configIds",
|
sysConfigGroup.DELETE("/:configIds",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:config:remove"}}),
|
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,
|
controller.NewSysConfig.Remove,
|
||||||
)
|
)
|
||||||
sysConfigGroup.PUT("/refreshCache",
|
sysConfigGroup.PUT("/refreshCache",
|
||||||
repeat.RepeatSubmit(5),
|
repeat.RepeatSubmit(5),
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:config:remove"}}),
|
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,
|
controller.NewSysConfig.RefreshCache,
|
||||||
)
|
)
|
||||||
sysConfigGroup.GET("/configKey/:configKey", controller.NewSysConfig.ConfigKey)
|
sysConfigGroup.GET("/configKey/:configKey", controller.NewSysConfig.ConfigKey)
|
||||||
sysConfigGroup.POST("/export",
|
sysConfigGroup.POST("/export",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:config: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,
|
controller.NewSysConfig.Export,
|
||||||
)
|
)
|
||||||
sysConfigGroup.PUT("/changeValue",
|
sysConfigGroup.PUT("/changeValue",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:config:edit"}}),
|
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,
|
controller.NewSysConfig.ConfigValue,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -76,17 +76,17 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysDeptGroup.POST("",
|
sysDeptGroup.POST("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dept:add"}}),
|
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,
|
controller.NewSysDept.Add,
|
||||||
)
|
)
|
||||||
sysDeptGroup.PUT("",
|
sysDeptGroup.PUT("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dept:edit"}}),
|
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,
|
controller.NewSysDept.Edit,
|
||||||
)
|
)
|
||||||
sysDeptGroup.DELETE("/:deptId",
|
sysDeptGroup.DELETE("/:deptId",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dept:remove"}}),
|
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,
|
controller.NewSysDept.Remove,
|
||||||
)
|
)
|
||||||
sysDeptGroup.GET("/list/exclude/:deptId",
|
sysDeptGroup.GET("/list/exclude/:deptId",
|
||||||
@@ -116,17 +116,17 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysDictDataGroup.POST("",
|
sysDictDataGroup.POST("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict:add"}}),
|
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,
|
controller.NewSysDictData.Add,
|
||||||
)
|
)
|
||||||
sysDictDataGroup.PUT("",
|
sysDictDataGroup.PUT("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict:edit"}}),
|
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,
|
controller.NewSysDictData.Edit,
|
||||||
)
|
)
|
||||||
sysDictDataGroup.DELETE("/:dictCodes",
|
sysDictDataGroup.DELETE("/:dictCodes",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict:remove"}}),
|
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,
|
controller.NewSysDictData.Remove,
|
||||||
)
|
)
|
||||||
sysDictDataGroup.GET("/type/:dictType",
|
sysDictDataGroup.GET("/type/:dictType",
|
||||||
@@ -135,7 +135,7 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysDictDataGroup.POST("/export",
|
sysDictDataGroup.POST("/export",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict: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,
|
controller.NewSysDictData.Export,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -153,22 +153,22 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysDictTypeGroup.POST("",
|
sysDictTypeGroup.POST("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict:add"}}),
|
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,
|
controller.NewSysDictType.Add,
|
||||||
)
|
)
|
||||||
sysDictTypeGroup.PUT("",
|
sysDictTypeGroup.PUT("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict:edit"}}),
|
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,
|
controller.NewSysDictType.Edit,
|
||||||
)
|
)
|
||||||
sysDictTypeGroup.DELETE("/:dictIds",
|
sysDictTypeGroup.DELETE("/:dictIds",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict:remove"}}),
|
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,
|
controller.NewSysDictType.Remove,
|
||||||
)
|
)
|
||||||
sysDictTypeGroup.PUT("/refreshCache",
|
sysDictTypeGroup.PUT("/refreshCache",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict:remove"}}),
|
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,
|
controller.NewSysDictType.RefreshCache,
|
||||||
)
|
)
|
||||||
sysDictTypeGroup.GET("/getDictOptionselect",
|
sysDictTypeGroup.GET("/getDictOptionselect",
|
||||||
@@ -177,7 +177,7 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysDictTypeGroup.POST("/export",
|
sysDictTypeGroup.POST("/export",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:dict: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,
|
controller.NewSysDictType.Export,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -195,17 +195,17 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysMenuGroup.POST("",
|
sysMenuGroup.POST("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:menu:add"}}),
|
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,
|
controller.NewSysMenu.Add,
|
||||||
)
|
)
|
||||||
sysMenuGroup.PUT("",
|
sysMenuGroup.PUT("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:menu:edit"}}),
|
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,
|
controller.NewSysMenu.Edit,
|
||||||
)
|
)
|
||||||
sysMenuGroup.DELETE("/:menuId",
|
sysMenuGroup.DELETE("/:menuId",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:menu:remove"}}),
|
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,
|
controller.NewSysMenu.Remove,
|
||||||
)
|
)
|
||||||
sysMenuGroup.GET("/treeSelect",
|
sysMenuGroup.GET("/treeSelect",
|
||||||
@@ -231,17 +231,17 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysNoticeGroup.POST("",
|
sysNoticeGroup.POST("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:notice:add"}}),
|
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,
|
controller.NewSysNotice.Add,
|
||||||
)
|
)
|
||||||
sysNoticeGroup.PUT("",
|
sysNoticeGroup.PUT("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:notice:edit"}}),
|
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,
|
controller.NewSysNotice.Edit,
|
||||||
)
|
)
|
||||||
sysNoticeGroup.DELETE("/:noticeIds",
|
sysNoticeGroup.DELETE("/:noticeIds",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:notice:remove"}}),
|
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,
|
controller.NewSysNotice.Remove,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -259,17 +259,17 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysPostGroup.POST("",
|
sysPostGroup.POST("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:post:add"}}),
|
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,
|
controller.NewSysPost.Add,
|
||||||
)
|
)
|
||||||
sysPostGroup.PUT("",
|
sysPostGroup.PUT("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:post:edit"}}),
|
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,
|
controller.NewSysPost.Edit,
|
||||||
)
|
)
|
||||||
sysPostGroup.DELETE("/:postIds",
|
sysPostGroup.DELETE("/:postIds",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:post:remove"}}),
|
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,
|
controller.NewSysPost.Remove,
|
||||||
)
|
)
|
||||||
sysPostGroup.POST("/export",
|
sysPostGroup.POST("/export",
|
||||||
@@ -291,12 +291,12 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysProfileGroup.PUT("/updatePwd",
|
sysProfileGroup.PUT("/updatePwd",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
collectlogs.OperateLog(collectlogs.OptionNew("个人信息", collectlogs.BUSINESS_TYPE_UPDATE)),
|
collectlogs.OperateLog(collectlogs.OptionNew("Personal", collectlogs.BUSINESS_TYPE_UPDATE)),
|
||||||
controller.NewSysProfile.UpdatePwd,
|
controller.NewSysProfile.UpdatePwd,
|
||||||
)
|
)
|
||||||
sysProfileGroup.POST("/avatar",
|
sysProfileGroup.POST("/avatar",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
collectlogs.OperateLog(collectlogs.OptionNew("用户头像", collectlogs.BUSINESS_TYPE_UPDATE)),
|
collectlogs.OperateLog(collectlogs.OptionNew("Personal Avatar", collectlogs.BUSINESS_TYPE_UPDATE)),
|
||||||
controller.NewSysProfile.Avatar,
|
controller.NewSysProfile.Avatar,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -314,29 +314,29 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysRoleGroup.POST("",
|
sysRoleGroup.POST("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:role:add"}}),
|
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,
|
controller.NewSysRole.Add,
|
||||||
)
|
)
|
||||||
sysRoleGroup.PUT("",
|
sysRoleGroup.PUT("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:role:edit"}}),
|
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,
|
controller.NewSysRole.Edit,
|
||||||
)
|
)
|
||||||
sysRoleGroup.DELETE("/:roleIds",
|
sysRoleGroup.DELETE("/:roleIds",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:role:remove"}}),
|
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,
|
controller.NewSysRole.Remove,
|
||||||
)
|
)
|
||||||
sysRoleGroup.PUT("/changeStatus",
|
sysRoleGroup.PUT("/changeStatus",
|
||||||
repeat.RepeatSubmit(5),
|
repeat.RepeatSubmit(5),
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:role:edit"}}),
|
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,
|
controller.NewSysRole.Status,
|
||||||
)
|
)
|
||||||
sysRoleGroup.PUT("/dataScope",
|
sysRoleGroup.PUT("/dataScope",
|
||||||
repeat.RepeatSubmit(5),
|
repeat.RepeatSubmit(5),
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:edit"}}),
|
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,
|
controller.NewSysRole.DataScope,
|
||||||
)
|
)
|
||||||
sysRoleGroup.GET("/authUser/allocatedList",
|
sysRoleGroup.GET("/authUser/allocatedList",
|
||||||
@@ -345,12 +345,12 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysRoleGroup.PUT("/authUser/checked",
|
sysRoleGroup.PUT("/authUser/checked",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:edit"}}),
|
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,
|
controller.NewSysRole.AuthUserChecked,
|
||||||
)
|
)
|
||||||
sysRoleGroup.POST("/export",
|
sysRoleGroup.POST("/export",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user: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,
|
controller.NewSysRole.Export,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -368,33 +368,33 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysUserGroup.POST("",
|
sysUserGroup.POST("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:add"}}),
|
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,
|
controller.NewSysUser.Add,
|
||||||
)
|
)
|
||||||
sysUserGroup.PUT("",
|
sysUserGroup.PUT("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:edit"}}),
|
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,
|
controller.NewSysUser.Edit,
|
||||||
)
|
)
|
||||||
sysUserGroup.DELETE("/:userIds",
|
sysUserGroup.DELETE("/:userIds",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:remove"}}),
|
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,
|
controller.NewSysUser.Remove,
|
||||||
)
|
)
|
||||||
sysUserGroup.PUT("/resetPwd",
|
sysUserGroup.PUT("/resetPwd",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user: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,
|
controller.NewSysUser.ResetPwd,
|
||||||
)
|
)
|
||||||
sysUserGroup.PUT("/changeStatus",
|
sysUserGroup.PUT("/changeStatus",
|
||||||
repeat.RepeatSubmit(5),
|
repeat.RepeatSubmit(5),
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:edit"}}),
|
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,
|
controller.NewSysUser.Status,
|
||||||
)
|
)
|
||||||
sysUserGroup.POST("/export",
|
sysUserGroup.POST("/export",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user: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,
|
controller.NewSysUser.Export,
|
||||||
)
|
)
|
||||||
sysUserGroup.GET("/importTemplate",
|
sysUserGroup.GET("/importTemplate",
|
||||||
@@ -403,7 +403,7 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysUserGroup.POST("/importData",
|
sysUserGroup.POST("/importData",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:user:import"}}),
|
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,
|
controller.NewSysUser.ImportData,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -417,17 +417,17 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysOperLogGroup.DELETE("/:operIds",
|
sysOperLogGroup.DELETE("/:operIds",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:log:operate:remove"}}),
|
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,
|
controller.NewSysLogOperate.Remove,
|
||||||
)
|
)
|
||||||
sysOperLogGroup.DELETE("/clean",
|
sysOperLogGroup.DELETE("/clean",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:log:operate:remove"}}),
|
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,
|
controller.NewSysLogOperate.Clean,
|
||||||
)
|
)
|
||||||
sysOperLogGroup.POST("/export",
|
sysOperLogGroup.POST("/export",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:log:operate: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,
|
controller.NewSysLogOperate.Export,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -441,22 +441,22 @@ func Setup(router *gin.Engine) {
|
|||||||
)
|
)
|
||||||
sysLogininforGroup.DELETE("/:loginIds",
|
sysLogininforGroup.DELETE("/:loginIds",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:log:login:remove"}}),
|
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,
|
controller.NewSysLogLogin.Remove,
|
||||||
)
|
)
|
||||||
sysLogininforGroup.DELETE("/clean",
|
sysLogininforGroup.DELETE("/clean",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:log:login:remove"}}),
|
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,
|
controller.NewSysLogLogin.Clean,
|
||||||
)
|
)
|
||||||
sysLogininforGroup.PUT("/unlock/:userName",
|
sysLogininforGroup.PUT("/unlock/:userName",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:log:login:unlock"}}),
|
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,
|
controller.NewSysLogLogin.Unlock,
|
||||||
)
|
)
|
||||||
sysLogininforGroup.POST("/export",
|
sysLogininforGroup.POST("/export",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:log:login: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,
|
controller.NewSysLogLogin.Export,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,14 +43,15 @@ func (s *TcpdumpController) NeTask(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查网元信息
|
// 检查网元信息
|
||||||
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
||||||
if neInfo.NeId != 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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -85,14 +86,15 @@ func (s *TcpdumpController) Download(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查网元信息
|
// 检查网元信息
|
||||||
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
||||||
if neInfo.NeId != 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))
|
c.JSON(200, result.ErrMsg(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -121,7 +123,7 @@ func (s *TcpdumpController) NeUPFTask(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,5 +260,5 @@ func (s *TcpdumpController) NeUPFTask(c *gin.Context) {
|
|||||||
return
|
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"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,17 +18,17 @@ func Setup(router *gin.Engine) {
|
|||||||
{
|
{
|
||||||
tcpdumpGroup.POST("/ne",
|
tcpdumpGroup.POST("/ne",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
collectlogs.OperateLog(collectlogs.OptionNew("信令抓包", collectlogs.BUSINESS_TYPE_OTHER)),
|
collectlogs.OperateLog(collectlogs.OptionNew("Signaling Grab", collectlogs.BUSINESS_TYPE_OTHER)),
|
||||||
controller.NewTcpdump.NeTask,
|
controller.NewTcpdump.NeTask,
|
||||||
)
|
)
|
||||||
tcpdumpGroup.POST("/neUPF",
|
tcpdumpGroup.POST("/neUPF",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
collectlogs.OperateLog(collectlogs.OptionNew("信令抓包", collectlogs.BUSINESS_TYPE_OTHER)),
|
collectlogs.OperateLog(collectlogs.OptionNew("Signaling Grab", collectlogs.BUSINESS_TYPE_OTHER)),
|
||||||
controller.NewTcpdump.NeUPFTask,
|
controller.NewTcpdump.NeUPFTask,
|
||||||
)
|
)
|
||||||
tcpdumpGroup.POST("/download",
|
tcpdumpGroup.POST("/download",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
collectlogs.OperateLog(collectlogs.OptionNew("信令抓包", collectlogs.BUSINESS_TYPE_IMPORT)),
|
collectlogs.OperateLog(collectlogs.OptionNew("Signaling Grab", collectlogs.BUSINESS_TYPE_IMPORT)),
|
||||||
controller.NewTcpdump.Download,
|
controller.NewTcpdump.Download,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user