style: 响应信息改英文

This commit is contained in:
TsMask
2023-10-12 11:55:00 +08:00
parent 936aa5906f
commit 8b3999d076
11 changed files with 127 additions and 127 deletions

View File

@@ -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
}