style: 响应信息改英文
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user