Merge branch 'main' of http://192.168.0.229:3180/OMC/ems_backend
This commit is contained in:
@@ -75,7 +75,7 @@ func (s *FirewallApi) Rule(w http.ResponseWriter, r *http.Request) {
|
||||
var body model.RuleQuerys
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.Type == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
data, err := s.firewallService.RulePage(body)
|
||||
|
||||
@@ -237,13 +237,13 @@ func LoginOMC(w http.ResponseWriter, r *http.Request) {
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil {
|
||||
log.Error("Invalid Json Format")
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
// response 400-5
|
||||
if body.Username == "" || body.Password == "" {
|
||||
log.Error("Wrong parameter value")
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -257,20 +257,20 @@ func LoginOMC(w http.ResponseWriter, r *http.Request) {
|
||||
if captchaEnabled {
|
||||
if body.Code == "" || body.UUID == "" {
|
||||
log.Error("Authentication failed, mismatch captcha")
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "验证码信息错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "Verification code information error"))
|
||||
return
|
||||
}
|
||||
verifyKey := cachekey.CAPTCHA_CODE_KEY + body.UUID
|
||||
captcha, ok := cache.GetLocalTTL(verifyKey)
|
||||
if captcha == nil || !ok {
|
||||
log.Error("Authentication failed, captcha emtry")
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "验证码已失效"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "The verification code has expired"))
|
||||
return
|
||||
}
|
||||
cache.DeleteLocalTTL(verifyKey)
|
||||
if captcha.(string) != body.Code {
|
||||
log.Error("Authentication failed, not match captcha")
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "验证码错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "Verification code error"))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func (s *SysConfigApi) List(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *SysConfigApi) Info(w http.ResponseWriter, r *http.Request) {
|
||||
configId := ctx.Param(r, "configId")
|
||||
if configId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
data := s.sysConfigService.SelectConfigById(configId)
|
||||
@@ -123,14 +123,14 @@ func (s *SysConfigApi) Add(w http.ResponseWriter, r *http.Request) {
|
||||
var body model.SysConfig
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.ConfigID != "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查属性值唯一
|
||||
uniqueConfigKey := s.sysConfigService.CheckUniqueConfigKey(body.ConfigKey, "")
|
||||
if !uniqueConfigKey {
|
||||
msg := fmt.Sprintf("参数配置新增【%s】失败,参数键名已存在", body.ConfigKey)
|
||||
msg := fmt.Sprintf("[%s] Parameter key name already exists", body.ConfigKey)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -151,14 +151,14 @@ func (s *SysConfigApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
var body model.SysConfig
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.ConfigID == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查属性值唯一
|
||||
uniqueConfigKey := s.sysConfigService.CheckUniqueConfigKey(body.ConfigKey, body.ConfigID)
|
||||
if !uniqueConfigKey {
|
||||
msg := fmt.Sprintf("参数配置修改【%s】失败,参数键名已存在", body.ConfigKey)
|
||||
msg := fmt.Sprintf("[%s] Parameter key name already exists", body.ConfigKey)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -166,7 +166,7 @@ func (s *SysConfigApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
// 检查是否存在
|
||||
config := s.sysConfigService.SelectConfigById(body.ConfigID)
|
||||
if config.ConfigID != body.ConfigID {
|
||||
ctx.JSON(w, 200, result.ErrMsg("没有权限访问参数配置数据!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access parameter configuration data!"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ func (s *SysConfigApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *SysConfigApi) Remove(w http.ResponseWriter, r *http.Request) {
|
||||
configIds := ctx.Param(r, "configIds")
|
||||
if configIds == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
// 处理字符转id数组后去重
|
||||
@@ -218,7 +218,7 @@ func (s *SysConfigApi) RefreshCache(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *SysConfigApi) ConfigKey(w http.ResponseWriter, r *http.Request) {
|
||||
configKey := ctx.Param(r, "configKey")
|
||||
if configKey == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
key := s.sysConfigService.SelectConfigValueByKey(configKey)
|
||||
|
||||
@@ -103,7 +103,7 @@ func (s *SysDictDataApi) List(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *SysDictDataApi) Info(w http.ResponseWriter, r *http.Request) {
|
||||
dictCode := ctx.Param(r, "dictCode")
|
||||
if dictCode == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
data := s.sysDictDataService.SelectDictDataByCode(dictCode)
|
||||
@@ -121,21 +121,21 @@ func (s *SysDictDataApi) Add(w http.ResponseWriter, r *http.Request) {
|
||||
var body model.SysDictData
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.DictCode != "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查字典类型是否存在
|
||||
sysDictType := s.sysDictTypeService.SelectDictTypeByType(body.DictType)
|
||||
if sysDictType.DictType != body.DictType {
|
||||
ctx.JSON(w, 200, result.ErrMsg("没有权限访问字典类型数据!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access dictionary type data!"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查字典标签唯一
|
||||
uniqueDictLabel := s.sysDictDataService.CheckUniqueDictLabel(body.DictType, body.DictLabel, "")
|
||||
if !uniqueDictLabel {
|
||||
msg := fmt.Sprintf("数据新增【%s】失败,该字典类型下标签名已存在", body.DictLabel)
|
||||
msg := fmt.Sprintf("[%s] The subscript signature of this dictionary type already exists", body.DictLabel)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func (s *SysDictDataApi) Add(w http.ResponseWriter, r *http.Request) {
|
||||
// 检查字典键值唯一
|
||||
uniqueDictValue := s.sysDictDataService.CheckUniqueDictValue(body.DictType, body.DictValue, "")
|
||||
if !uniqueDictValue {
|
||||
msg := fmt.Sprintf("数据新增【%s】失败,该字典类型下标签值已存在", body.DictValue)
|
||||
msg := fmt.Sprintf("[%s] The label value under this dictionary type already exists", body.DictValue)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -164,28 +164,28 @@ func (s *SysDictDataApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
var body model.SysDictData
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.DictCode == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查字典类型是否存在
|
||||
sysDictType := s.sysDictTypeService.SelectDictTypeByType(body.DictType)
|
||||
if sysDictType.DictType != body.DictType {
|
||||
ctx.JSON(w, 200, result.ErrMsg("没有权限访问字典类型数据!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access dictionary type data!"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查字典编码是否存在
|
||||
SysDictDataApi := s.sysDictDataService.SelectDictDataByCode(body.DictCode)
|
||||
if SysDictDataApi.DictCode != body.DictCode {
|
||||
ctx.JSON(w, 200, result.ErrMsg("没有权限访问字典编码数据!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access dictionary encoding data!"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查字典标签唯一
|
||||
uniqueDictLabel := s.sysDictDataService.CheckUniqueDictLabel(body.DictType, body.DictLabel, body.DictCode)
|
||||
if !uniqueDictLabel {
|
||||
msg := fmt.Sprintf("数据修改【%s】失败,该字典类型下标签名已存在", body.DictLabel)
|
||||
msg := fmt.Sprintf("Data modification failed for [%s], the dictionary type subscript signature already exists", body.DictLabel)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -193,7 +193,7 @@ func (s *SysDictDataApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
// 检查字典键值唯一
|
||||
uniqueDictValue := s.sysDictDataService.CheckUniqueDictValue(body.DictType, body.DictValue, body.DictCode)
|
||||
if !uniqueDictValue {
|
||||
msg := fmt.Sprintf("数据修改【%s】失败,该字典类型下标签值已存在", body.DictValue)
|
||||
msg := fmt.Sprintf("Data modification failed for [%s], label value already exists under this dictionary type", body.DictValue)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -213,7 +213,7 @@ func (s *SysDictDataApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *SysDictDataApi) Remove(w http.ResponseWriter, r *http.Request) {
|
||||
dictCodes := ctx.Param(r, "dictCodes")
|
||||
if dictCodes == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
// 处理字符转id数组后去重
|
||||
@@ -228,7 +228,7 @@ func (s *SysDictDataApi) Remove(w http.ResponseWriter, r *http.Request) {
|
||||
ctx.JSON(w, 200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
||||
msg := fmt.Sprintf("Successfully deleted: %d", rows)
|
||||
ctx.JSON(w, 200, result.OkMsg(msg))
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ func (s *SysDictDataApi) Remove(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *SysDictDataApi) DictType(w http.ResponseWriter, r *http.Request) {
|
||||
dictType := ctx.Param(r, "dictType")
|
||||
if dictType == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ func (s *SysDictTypeApi) List(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *SysDictTypeApi) Info(w http.ResponseWriter, r *http.Request) {
|
||||
dictId := ctx.Param(r, "dictId")
|
||||
if dictId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
data := s.sysDictTypeService.SelectDictTypeByID(dictId)
|
||||
@@ -123,14 +123,14 @@ func (s *SysDictTypeApi) Add(w http.ResponseWriter, r *http.Request) {
|
||||
var body model.SysDictType
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.DictID != "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查字典名称唯一
|
||||
uniqueDictName := s.sysDictTypeService.CheckUniqueDictName(body.DictName, "")
|
||||
if !uniqueDictName {
|
||||
msg := fmt.Sprintf("字典新增【%s】失败,字典名称已存在", body.DictName)
|
||||
msg := fmt.Sprintf("Failed to add dictionary '%s', dictionary name already exists", body.DictName)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -138,7 +138,7 @@ func (s *SysDictTypeApi) Add(w http.ResponseWriter, r *http.Request) {
|
||||
// 检查字典类型唯一
|
||||
uniqueDictType := s.sysDictTypeService.CheckUniqueDictType(body.DictType, "")
|
||||
if !uniqueDictType {
|
||||
msg := fmt.Sprintf("字典新增【%s】失败,字典类型已存在", body.DictType)
|
||||
msg := fmt.Sprintf("Failed to add dictionary '%s', dictionary type already exists", body.DictType)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -159,21 +159,21 @@ func (s *SysDictTypeApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
var body model.SysDictType
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.DictID == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查数据是否存在
|
||||
dictInfo := s.sysDictTypeService.SelectDictTypeByID(body.DictID)
|
||||
if dictInfo.DictID != body.DictID {
|
||||
ctx.JSON(w, 200, result.ErrMsg("没有权限访问字典类型数据!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access dictionary type data!"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查字典名称唯一
|
||||
uniqueDictName := s.sysDictTypeService.CheckUniqueDictName(body.DictName, body.DictID)
|
||||
if !uniqueDictName {
|
||||
msg := fmt.Sprintf("字典修改【%s】失败,字典名称已存在", body.DictName)
|
||||
msg := fmt.Sprintf("Dictionary modification failed for [%s], dictionary name already exists", body.DictName)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -181,7 +181,7 @@ func (s *SysDictTypeApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
// 检查字典类型唯一
|
||||
uniqueDictType := s.sysDictTypeService.CheckUniqueDictType(body.DictType, body.DictID)
|
||||
if !uniqueDictType {
|
||||
msg := fmt.Sprintf("字典修改【%s】失败,字典类型已存在", body.DictType)
|
||||
msg := fmt.Sprintf("Dictionary modification failed for [%s], dictionary type already exists", body.DictType)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -201,7 +201,7 @@ func (s *SysDictTypeApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *SysDictTypeApi) Remove(w http.ResponseWriter, r *http.Request) {
|
||||
dictIds := ctx.Param(r, "dictIds")
|
||||
if dictIds == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
// 处理字符转id数组后去重
|
||||
@@ -216,7 +216,7 @@ func (s *SysDictTypeApi) Remove(w http.ResponseWriter, r *http.Request) {
|
||||
ctx.JSON(w, 200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
||||
msg := fmt.Sprintf("Successfully deleted: %d", rows)
|
||||
ctx.JSON(w, 200, result.OkMsg(msg))
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ func (s *SysMenuApi) List(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *SysMenuApi) Info(w http.ResponseWriter, r *http.Request) {
|
||||
menuId := ctx.Param(r, "menuId")
|
||||
if menuId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
data := s.sysMenuService.SelectMenuById(menuId)
|
||||
@@ -140,7 +140,7 @@ func (s *SysMenuApi) Add(w http.ResponseWriter, r *http.Request) {
|
||||
var body model.SysMenu
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.MenuID != "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -185,13 +185,13 @@ func (s *SysMenuApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
var body model.SysMenu
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.MenuID == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 上级菜单不能选自己
|
||||
if body.MenuID == body.ParentID {
|
||||
msg := fmt.Sprintf("菜单修改【%s】失败,上级菜单不能选择自己", body.MenuName)
|
||||
msg := fmt.Sprintf("Menu modification failed for [%s], parent menu cannot select itself", body.MenuName)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -199,19 +199,19 @@ func (s *SysMenuApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
// 检查数据是否存在
|
||||
menuInfo := s.sysMenuService.SelectMenuById(body.MenuID)
|
||||
if menuInfo.MenuID != body.MenuID {
|
||||
ctx.JSON(w, 200, result.ErrMsg("没有权限访问菜单数据"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access menu data"))
|
||||
return
|
||||
}
|
||||
// 父级ID不为0是要检查
|
||||
if body.ParentID != "0" {
|
||||
menuParent := s.sysMenuService.SelectMenuById(body.ParentID)
|
||||
if menuParent.MenuID != body.ParentID {
|
||||
ctx.JSON(w, 200, result.ErrMsg("没有权限访问菜单数据"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access menu data"))
|
||||
return
|
||||
}
|
||||
// 禁用菜单时检查父菜单是否使用
|
||||
if body.Status == "1" && menuParent.Status == "0" {
|
||||
ctx.JSON(w, 200, result.ErrMsg("父菜单未启用!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("Parent menu not enabled!"))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -266,21 +266,21 @@ func (s *SysMenuApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *SysMenuApi) Remove(w http.ResponseWriter, r *http.Request) {
|
||||
menuId := ctx.Param(r, "menuId")
|
||||
if menuId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查数据是否存在
|
||||
menu := s.sysMenuService.SelectMenuById(menuId)
|
||||
if menu.MenuID != menuId {
|
||||
ctx.JSON(w, 200, result.ErrMsg("没有权限访问菜单数据!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access menu data!"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否存在子菜单
|
||||
hasChild := s.sysMenuService.HasChildByMenuIdAndStatus(menuId, "")
|
||||
if hasChild > 0 {
|
||||
msg := fmt.Sprintf("不允许删除,存在子菜单数:%d", hasChild)
|
||||
msg := fmt.Sprintf("Deletion not allowed, there are sub orders: %d", hasChild)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -288,14 +288,14 @@ func (s *SysMenuApi) Remove(w http.ResponseWriter, r *http.Request) {
|
||||
// 检查是否分配给角色
|
||||
existRole := s.sysMenuService.CheckMenuExistRole(menuId)
|
||||
if existRole > 0 {
|
||||
msg := fmt.Sprintf("不允许删除,菜单已分配给角色数:%d", existRole)
|
||||
msg := fmt.Sprintf("Deletion not allowed, menu already assigned to roles: %d", existRole)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
|
||||
rows := s.sysMenuService.DeleteMenuById(menuId)
|
||||
if rows > 0 {
|
||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
||||
msg := fmt.Sprintf("Successfully deleted: %d", rows)
|
||||
ctx.JSON(w, 200, result.OkMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -329,7 +329,7 @@ func (s *SysMenuApi) TreeSelect(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *SysMenuApi) RoleMenuTreeSelect(w http.ResponseWriter, r *http.Request) {
|
||||
roleId := ctx.Param(r, "roleId")
|
||||
if roleId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ func (s *SysRoleApi) List(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *SysRoleApi) Info(w http.ResponseWriter, r *http.Request) {
|
||||
roleId := ctx.Param(r, "roleId")
|
||||
if roleId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
data := s.sysRoleService.SelectRoleById(roleId)
|
||||
@@ -139,14 +139,14 @@ func (s *SysRoleApi) Add(w http.ResponseWriter, r *http.Request) {
|
||||
var body model.SysRole
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.RoleID != "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 判断角色名称是否唯一
|
||||
uniqueRoleName := s.sysRoleService.CheckUniqueRoleName(body.RoleName, "")
|
||||
if !uniqueRoleName {
|
||||
msg := fmt.Sprintf("角色新增【%s】失败,角色名称已存在", body.RoleName)
|
||||
msg := fmt.Sprintf("[%s] Role name already exists", body.RoleName)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -154,7 +154,7 @@ func (s *SysRoleApi) Add(w http.ResponseWriter, r *http.Request) {
|
||||
// 判断角色键值是否唯一
|
||||
uniqueRoleKey := s.sysRoleService.CheckUniqueRoleKey(body.RoleKey, "")
|
||||
if !uniqueRoleKey {
|
||||
msg := fmt.Sprintf("角色新增【%s】失败,角色键值已存在", body.RoleName)
|
||||
msg := fmt.Sprintf("[%s] The role key value already exists", body.RoleName)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -175,27 +175,27 @@ func (s *SysRoleApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
var body model.SysRole
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.RoleID == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否管理员角色
|
||||
if body.RoleID == "1" {
|
||||
ctx.JSON(w, 200, result.ErrMsg("不允许操作管理员角色"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("Operation of administrator role is not allowed"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否存在
|
||||
role := s.sysRoleService.SelectRoleById(body.RoleID)
|
||||
if role.RoleID != body.RoleID {
|
||||
ctx.JSON(w, 200, result.ErrMsg("没有权限访问角色数据!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access role data!"))
|
||||
return
|
||||
}
|
||||
|
||||
// 判断角色名称是否唯一
|
||||
uniqueRoleName := s.sysRoleService.CheckUniqueRoleName(body.RoleName, body.RoleID)
|
||||
if !uniqueRoleName {
|
||||
msg := fmt.Sprintf("角色修改【%s】失败,角色名称已存在", body.RoleName)
|
||||
msg := fmt.Sprintf("[%s] Role name already exists", body.RoleName)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -203,7 +203,7 @@ func (s *SysRoleApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
// 判断角色键值是否唯一
|
||||
uniqueRoleKey := s.sysRoleService.CheckUniqueRoleKey(body.RoleKey, body.RoleID)
|
||||
if !uniqueRoleKey {
|
||||
msg := fmt.Sprintf("角色修改【%s】失败,角色键值已存在", body.RoleName)
|
||||
msg := fmt.Sprintf("[%s] The role key value already exists", body.RoleName)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -223,7 +223,7 @@ func (s *SysRoleApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *SysRoleApi) Remove(w http.ResponseWriter, r *http.Request) {
|
||||
roleIds := ctx.Param(r, "roleIds")
|
||||
if roleIds == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
// 处理字符转id数组后去重
|
||||
@@ -236,7 +236,7 @@ func (s *SysRoleApi) Remove(w http.ResponseWriter, r *http.Request) {
|
||||
// 检查是否管理员角色
|
||||
for _, id := range uniqueIDs {
|
||||
if id == "1" {
|
||||
ctx.JSON(w, 200, result.ErrMsg("不允许操作管理员角色"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("Operation of administrator role is not allowed"))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -245,7 +245,7 @@ func (s *SysRoleApi) Remove(w http.ResponseWriter, r *http.Request) {
|
||||
ctx.JSON(w, 200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
||||
msg := fmt.Sprintf("Successfully deleted: %d", rows)
|
||||
ctx.JSON(w, 200, result.OkMsg(msg))
|
||||
}
|
||||
|
||||
@@ -261,26 +261,26 @@ func (s *SysRoleApi) Status(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否管理员角色
|
||||
if body.RoleID == "1" {
|
||||
ctx.JSON(w, 200, result.ErrMsg("不允许操作管理员角色"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("Operation of administrator role is not allowed"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否存在
|
||||
role := s.sysRoleService.SelectRoleById(body.RoleID)
|
||||
if role.RoleID != body.RoleID {
|
||||
ctx.JSON(w, 200, result.ErrMsg("没有权限访问角色数据!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access role data!"))
|
||||
return
|
||||
}
|
||||
|
||||
// 与旧值相等不变更
|
||||
if role.Status == body.Status {
|
||||
ctx.JSON(w, 200, result.ErrMsg("变更状态与旧值相等!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("Change status equals old value!"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -306,14 +306,14 @@ func (s *SysRoleApi) AuthUserAllocatedList(w http.ResponseWriter, r *http.Reques
|
||||
querys := ctx.QueryMap(r)
|
||||
roleId, ok := querys["roleId"]
|
||||
if !ok || roleId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否存在
|
||||
role := s.sysRoleService.SelectRoleById(roleId.(string))
|
||||
if role.RoleID != roleId {
|
||||
ctx.JSON(w, 200, result.ErrMsg("没有权限访问角色数据!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access role data!"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ func (s *SysRoleApi) AuthUserChecked(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ func (s *SysRoleApi) AuthUserChecked(w http.ResponseWriter, r *http.Request) {
|
||||
// 检查是否存在
|
||||
role := s.sysRoleService.SelectRoleById(body.RoleID)
|
||||
if role.RoleID != body.RoleID {
|
||||
ctx.JSON(w, 200, result.ErrMsg("没有权限访问角色数据!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access role data!"))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ func (s *SysUserApi) List(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *SysUserApi) Info(w http.ResponseWriter, r *http.Request) {
|
||||
userId := ctx.Param(r, "userId")
|
||||
if userId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
// 查询系统角色列表
|
||||
@@ -137,7 +137,7 @@ func (s *SysUserApi) Info(w http.ResponseWriter, r *http.Request) {
|
||||
// 检查用户是否存在
|
||||
user := s.sysUserService.SelectUserById(userId)
|
||||
if user.Id != userId {
|
||||
ctx.JSON(w, 200, result.ErrMsg("没有权限访问用户数据!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access user data!"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -161,14 +161,14 @@ func (s *SysUserApi) Add(w http.ResponseWriter, r *http.Request) {
|
||||
var body sysUserModel.SysUser
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.Id != "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查用户登录账号是否唯一
|
||||
uniqueUserName := s.sysUserService.CheckUniqueUserName(body.AccountId, "")
|
||||
if !uniqueUserName {
|
||||
msg := fmt.Sprintf("新增用户【%s】失败,登录账号已存在", body.AccountId)
|
||||
msg := fmt.Sprintf("[%s] Login account already exists", body.AccountId)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -188,7 +188,7 @@ func (s *SysUserApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
var body sysUserModel.SysUser
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.Id == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -200,14 +200,14 @@ func (s *SysUserApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
user := s.sysUserService.SelectUserById(body.Id)
|
||||
if user.Id != body.Id {
|
||||
ctx.JSON(w, 200, result.ErrMsg("没有权限访问用户数据!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access user data!"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查用户登录账号是否唯一
|
||||
uniqueUserName := s.sysUserService.CheckUniqueUserName(body.AccountId, body.Id)
|
||||
if !uniqueUserName {
|
||||
msg := fmt.Sprintf("修改用户【%s】失败,登录账号已存在", body.AccountId)
|
||||
msg := fmt.Sprintf("[%s] Login account already exists", body.AccountId)
|
||||
ctx.JSON(w, 200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -228,7 +228,7 @@ func (s *SysUserApi) Edit(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *SysUserApi) Remove(w http.ResponseWriter, r *http.Request) {
|
||||
userIds := ctx.Param(r, "userIds")
|
||||
if userIds == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
// 处理字符转id数组后去重
|
||||
@@ -243,7 +243,7 @@ func (s *SysUserApi) Remove(w http.ResponseWriter, r *http.Request) {
|
||||
ctx.JSON(w, 200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
||||
msg := fmt.Sprintf("Successfully deleted: %d", rows)
|
||||
ctx.JSON(w, 200, result.OkMsg(msg))
|
||||
}
|
||||
|
||||
@@ -256,19 +256,19 @@ func (s *SysUserApi) ResetPwd(w http.ResponseWriter, r *http.Request) {
|
||||
Password string `json:"password" binding:"required"`
|
||||
}
|
||||
if err := ctx.ShouldBindJSON(r, &body); err != nil {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否管理员用户
|
||||
if conf.IsAdmin(body.UserID) {
|
||||
ctx.JSON(w, 200, result.ErrMsg("不允许操作管理员用户"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access user data!"))
|
||||
return
|
||||
}
|
||||
|
||||
user := s.sysUserService.SelectUserById(body.UserID)
|
||||
if user.Id != body.UserID {
|
||||
ctx.JSON(w, 200, result.ErrMsg("没有权限访问用户数据!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access user data!"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -293,20 +293,20 @@ func (s *SysUserApi) Status(w http.ResponseWriter, r *http.Request) {
|
||||
Status string `json:"status" binding:"required"`
|
||||
}
|
||||
if err := ctx.ShouldBindJSON(r, &body); err != nil {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否存在
|
||||
user := s.sysUserService.SelectUserById(body.UserID)
|
||||
if user.Id != body.UserID {
|
||||
ctx.JSON(w, 200, result.ErrMsg("没有权限访问用户数据!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("No permission to access user data!"))
|
||||
return
|
||||
}
|
||||
|
||||
// 与旧值相等不变更
|
||||
if user.Status == body.Status {
|
||||
ctx.JSON(w, 200, result.ErrMsg("变更状态与旧值相等!"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("Change status equals old value!"))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ func TcpdumpNeTask(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.NeType == "" || body.NeId == "" || body.Timeout < 5 || body.Cmd == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ func TcpdumpPcapDownload(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.NeType == "" || body.NeId == "" || body.FileName == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ func TcpdumpNeUPFTask(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.NeType != "UPF" || body.NeId == "" || body.Cmd == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -228,7 +228,7 @@ func (s *UdmUserApi) UdmAuthUserList(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *UdmUserApi) UdmAuthUserSave(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
if neId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ func (s *UdmUserApi) UdmAuthUserInfo(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
imsi := ctx.Param(r, "imsi")
|
||||
if neId == "" || imsi == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -290,14 +290,14 @@ func (s *UdmUserApi) UdmAuthUserInfo(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *UdmUserApi) UdmAuthUserAdd(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
if neId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
var body model.UdmAuthUser
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.Imsi == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -331,14 +331,14 @@ func (s *UdmUserApi) UdmAuthUserAdds(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
num := ctx.Param(r, "num")
|
||||
if neId == "" || num == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
var body model.UdmAuthUser
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.Imsi == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -371,14 +371,14 @@ func (s *UdmUserApi) UdmAuthUserAdds(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *UdmUserApi) UdmAuthUserEdit(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
if neId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
var body model.UdmAuthUser
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.Imsi == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -425,7 +425,7 @@ func (s *UdmUserApi) UdmAuthUserRemove(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
imsi := ctx.Param(r, "imsi")
|
||||
if neId == "" || imsi == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ func (s *UdmUserApi) UdmAuthUserRemoves(w http.ResponseWriter, r *http.Request)
|
||||
imsi := ctx.Param(r, "imsi")
|
||||
num := ctx.Param(r, "num")
|
||||
if neId == "" || imsi == "" || num == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -497,12 +497,12 @@ func (s *UdmUserApi) UdmAuthUserExport(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.NeId == "" || body.Type == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
if !(body.Type == "csv" || body.Type == "txt") {
|
||||
ctx.JSON(w, 200, result.ErrMsg("导出文件类型支持csv、txt"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("Export file types support CSV and txt"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -554,7 +554,7 @@ func (s *UdmUserApi) UdmAuthUserExport(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *UdmUserApi) UdmAuthUserImport(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
if neId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -565,7 +565,7 @@ func (s *UdmUserApi) UdmAuthUserImport(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
if !(strings.HasSuffix(fileHeader.Filename, ".csv") || strings.HasSuffix(fileHeader.Filename, ".txt")) {
|
||||
ctx.JSON(w, 200, result.ErrMsg("请上传.csv、.txt格式文件,内容字段imsi,ki,algo,amf,opc"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("Please upload files in. csv and. txt formats with content fields: imsi,ki,algo,amf,opc"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -634,7 +634,7 @@ func (s *UdmUserApi) UdmSubUserList(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *UdmUserApi) UdmSubUserSave(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
if neId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -650,7 +650,7 @@ func (s *UdmUserApi) UdmSubUserInfo(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
imsi := ctx.Param(r, "imsi")
|
||||
if neId == "" || imsi == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -714,14 +714,14 @@ func (s *UdmUserApi) UdmSubUserInfo(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *UdmUserApi) UdmSubUserAdd(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
if neId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
var body model.UdmSubUser
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.Imsi == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -760,14 +760,14 @@ func (s *UdmUserApi) UdmSubUserAdds(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
num := ctx.Param(r, "num")
|
||||
if neId == "" || num == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
var body model.UdmSubUser
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.Imsi == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -805,14 +805,14 @@ func (s *UdmUserApi) UdmSubUserAdds(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *UdmUserApi) UdmSubUserAdd4G(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
if neId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
var body model.UdmSubUser
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.Imsi == "" || body.SubNum == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -845,14 +845,14 @@ func (s *UdmUserApi) UdmSubUserAdd4G(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *UdmUserApi) UdmSubUserEdit(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
if neId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
var body model.UdmSubUser
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.Imsi == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -940,14 +940,14 @@ func (s *UdmUserApi) UdmSubUserEdit(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *UdmUserApi) UdmSubUser4GIP(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
if neId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
var body model.UdmSubUser
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.Imsi == "" || body.SubNum == "" || body.StaticIp == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -979,14 +979,14 @@ func (s *UdmUserApi) UdmSubUser4GIP(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *UdmUserApi) UdmSubUserSmData(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
if neId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
var body model.UdmSubUser
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.Imsi == "" || body.SubNum == "" || body.SmData == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1020,7 +1020,7 @@ func (s *UdmUserApi) UdmSubUserRemove(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
imsi := ctx.Param(r, "imsi")
|
||||
if neId == "" || imsi == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1055,7 +1055,7 @@ func (s *UdmUserApi) UdmSubUserRemoves(w http.ResponseWriter, r *http.Request) {
|
||||
imsi := ctx.Param(r, "imsi")
|
||||
num := ctx.Param(r, "num")
|
||||
if neId == "" || imsi == "" || num == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1092,12 +1092,12 @@ func (s *UdmUserApi) UdmSubUserExport(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
err := ctx.ShouldBindJSON(r, &body)
|
||||
if err != nil || body.NeId == "" || body.Type == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
if !(body.Type == "csv" || body.Type == "txt") {
|
||||
ctx.JSON(w, 200, result.ErrMsg("导出文件类型支持csv、txt"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("Export file type support csv、txt"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1145,7 +1145,7 @@ func (s *UdmUserApi) UdmSubUserExport(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *UdmUserApi) UdmSubUserImport(w http.ResponseWriter, r *http.Request) {
|
||||
neId := ctx.Param(r, "neId")
|
||||
if neId == "" {
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "参数错误"))
|
||||
ctx.JSON(w, 400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1156,7 +1156,7 @@ func (s *UdmUserApi) UdmSubUserImport(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
if !(strings.HasSuffix(fileHeader.Filename, ".csv") || strings.HasSuffix(fileHeader.Filename, ".txt")) {
|
||||
ctx.JSON(w, 200, result.ErrMsg("请上传.csv、.txt格式文件,内容字段imsi,msisdn,ambr,nssai,arfb,sar,rat,cn,smf_sel,sm_dat,eps_dat"))
|
||||
ctx.JSON(w, 200, result.ErrMsg("Please upload files in. csv and. txt formats with content fields: imsi,msisdn,ambr,nssai,arfb,sar,rat,cn,smf_sel,sm_dat,eps_dat"))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -27,25 +27,25 @@ func Authorize(options map[string][]string) func(http.Handler) http.Handler {
|
||||
// 获取请求头标识信息
|
||||
accessToken := r.Header.Get("AccessToken")
|
||||
if accessToken == "" {
|
||||
ctx.JSON(w, 401, result.CodeMsg(401, "token error 无效身份授权"))
|
||||
ctx.JSON(w, 401, result.CodeMsg(401, "Invalid identity authorization token error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 验证令牌 == 这里直接查数据库session
|
||||
if !dborm.XormExistValidToken(accessToken, 0) {
|
||||
ctx.JSON(w, 401, result.CodeMsg(401, "valid error 无效身份授权"))
|
||||
ctx.JSON(w, 401, result.CodeMsg(401, "Invalid identity authorization valid error"))
|
||||
return
|
||||
}
|
||||
se, err := dborm.XormUpdateSessionShakeTime(accessToken)
|
||||
if err != nil {
|
||||
ctx.JSON(w, 401, result.CodeMsg(401, "shake error 无效身份授权"))
|
||||
ctx.JSON(w, 401, result.CodeMsg(401, "Invalid identity authorization shake error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 获取缓存的用户信息
|
||||
data, ok := cache.GetLocalTTL(se.AccountId)
|
||||
if data == nil || !ok {
|
||||
ctx.JSON(w, 401, result.CodeMsg(401, "info error 无效身份授权"))
|
||||
ctx.JSON(w, 401, result.CodeMsg(401, "Invalid identity authorization info error"))
|
||||
return
|
||||
}
|
||||
loginUser := data.(vo.LoginUser)
|
||||
@@ -59,7 +59,7 @@ func Authorize(options map[string][]string) func(http.Handler) http.Handler {
|
||||
perms := loginUser.Permissions
|
||||
verifyOk := verifyRolePermission(roles, perms, options)
|
||||
if !verifyOk {
|
||||
msg := fmt.Sprintf("无权访问 %s %s", r.Method, r.RequestURI)
|
||||
msg := fmt.Sprintf("Unauthorized access %s %s", r.Method, r.RequestURI)
|
||||
ctx.JSON(w, 403, result.CodeMsg(403, msg))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user