|
| 1 | +package errorx |
| 2 | + |
| 3 | +var errorMsg map[int]string |
| 4 | + |
| 5 | +const ( |
| 6 | + ServerErrorCode = 1000 |
| 7 | + ParamErrorCode = 1001 |
| 8 | + CaptchaErrorCode = 1002 |
| 9 | + AccountErrorCode = 1003 |
| 10 | + PasswordErrorCode = 1004 |
| 11 | + NotPermMenuErrorCode = 1005 |
| 12 | + DeletePermMenuErrorCode = 1006 |
| 13 | + ParentPermMenuErrorCode = 1007 |
| 14 | + AddRoleErrorCode = 1008 |
| 15 | + DeleteRoleErrorCode = 1009 |
| 16 | + AddDeptErrorCode = 1010 |
| 17 | + DeleteDeptErrorCode = 1011 |
| 18 | + AddJobErrorCode = 1012 |
| 19 | + DeleteJobErrorCode = 1013 |
| 20 | + AddProfessionErrorCode = 1014 |
| 21 | + DeleteProfessionErrorCode = 1015 |
| 22 | + AddUserErrorCode = 1016 |
| 23 | + DeptHasUserErrorCode = 1017 |
| 24 | + RoleIsUsingErrorCode = 1018 |
| 25 | + ParentRoleErrorCode = 1019 |
| 26 | + ParentDeptErrorCode = 1020 |
| 27 | + AccountDisableErrorCode = 1021 |
| 28 | + SetParentIdErrorCode = 1022 |
| 29 | + SetParentTypeErrorCode = 1023 |
| 30 | + AddConfigErrorCode = 1024 |
| 31 | + AddDictionaryErrorCode = 1025 |
| 32 | + AuthErrorCode = 1026 |
| 33 | + DeleteDictionaryErrorCode = 1027 |
| 34 | + JobIsUsingErrorCode = 1028 |
| 35 | + ProfessionIsUsingErrorCode = 1029 |
| 36 | + ForbiddenErrorCode = 1030 |
| 37 | + UpdateRoleUniqueKeyErrorCode = 1031 |
| 38 | + UpdateDeptUniqueKeyErrorCode = 1032 |
| 39 | + AssigningRolesErrorCode = 1033 |
| 40 | + DeptIdErrorCode = 1034 |
| 41 | + ProfessionIdErrorCode = 1035 |
| 42 | + PostIdErrorCode = 1036 |
| 43 | + ParentRoleIdErrorCode = 1037 |
| 44 | + ParentDeptIdErrorCode = 1038 |
| 45 | + ParentPermMenuIdErrorCode = 1039 |
| 46 | + ParentDictionaryIdErrorCode = 1040 |
| 47 | + DictionaryIdErrorCode = 1041 |
| 48 | + PermMenuIdErrorCode = 1042 |
| 49 | + RoleIdErrorCode = 1043 |
| 50 | + UserIdErrorCode = 1044 |
| 51 | + ConfigErrorCode = 1045 |
| 52 | +) |
| 53 | + |
| 54 | +func init() { |
| 55 | + errorMsg = make(map[int]string) |
| 56 | + errorMsg[ServerErrorCode] = "服务繁忙,请稍后重试" |
| 57 | + errorMsg[CaptchaErrorCode] = "验证码错误" |
| 58 | + errorMsg[AccountErrorCode] = "账号错误" |
| 59 | + errorMsg[PasswordErrorCode] = "密码错误" |
| 60 | + errorMsg[NotPermMenuErrorCode] = "权限不足" |
| 61 | + errorMsg[DeletePermMenuErrorCode] = "该权限菜单存在子级权限菜单" |
| 62 | + errorMsg[ParentPermMenuErrorCode] = "父级菜单不能为自己" |
| 63 | + errorMsg[AddRoleErrorCode] = "角色已存在" |
| 64 | + errorMsg[DeleteRoleErrorCode] = "该角色存在子角色" |
| 65 | + errorMsg[AddDeptErrorCode] = "部门已存在" |
| 66 | + errorMsg[DeleteDeptErrorCode] = "该部门存在子部门" |
| 67 | + errorMsg[AddJobErrorCode] = "岗位已存在" |
| 68 | + errorMsg[DeleteJobErrorCode] = "该岗位正在使用中" |
| 69 | + errorMsg[AddProfessionErrorCode] = "职称已存在" |
| 70 | + errorMsg[DeleteProfessionErrorCode] = "该职称正在使用中" |
| 71 | + errorMsg[AddUserErrorCode] = "账号已存在" |
| 72 | + errorMsg[DeptHasUserErrorCode] = "该部门正在使用中" |
| 73 | + errorMsg[RoleIsUsingErrorCode] = "该角色正在使用中" |
| 74 | + errorMsg[ParentRoleErrorCode] = "父级角色不能为自己" |
| 75 | + errorMsg[ParentDeptErrorCode] = "父级部门不能为自己" |
| 76 | + errorMsg[AccountDisableErrorCode] = "账号已禁用" |
| 77 | + errorMsg[SetParentIdErrorCode] = "不能设置子级为自己的父级" |
| 78 | + errorMsg[SetParentTypeErrorCode] = "权限类型不能作为父级菜单" |
| 79 | + errorMsg[AddConfigErrorCode] = "配置已存在" |
| 80 | + errorMsg[AddDictionaryErrorCode] = "字典已存在" |
| 81 | + errorMsg[AuthErrorCode] = "授权已失效,请重新登录" |
| 82 | + errorMsg[DeleteDictionaryErrorCode] = "该字典集存在配置项" |
| 83 | + errorMsg[JobIsUsingErrorCode] = "该岗位正在使用中" |
| 84 | + errorMsg[ProfessionIsUsingErrorCode] = "该职称正在使用中" |
| 85 | + errorMsg[ForbiddenErrorCode] = "禁止操作" |
| 86 | + errorMsg[UpdateRoleUniqueKeyErrorCode] = "角色标识已存在" |
| 87 | + errorMsg[UpdateDeptUniqueKeyErrorCode] = "部门标识已存在" |
| 88 | + errorMsg[AssigningRolesErrorCode] = "角色不在可控范围" |
| 89 | + errorMsg[DeptIdErrorCode] = "部门不存在" |
| 90 | + errorMsg[ProfessionIdErrorCode] = "职称不存在" |
| 91 | + errorMsg[PostIdErrorCode] = "岗位不存在" |
| 92 | + errorMsg[ParentRoleIdErrorCode] = "父级角色不存在" |
| 93 | + errorMsg[ParentDeptIdErrorCode] = "父级部门不存在" |
| 94 | + errorMsg[ParentPermMenuIdErrorCode] = "父级菜单不存在" |
| 95 | + errorMsg[ParentDictionaryIdErrorCode] = "字典集不存在" |
| 96 | + errorMsg[DictionaryIdErrorCode] = "字典不存在" |
| 97 | + errorMsg[PermMenuIdErrorCode] = "权限菜单不存在" |
| 98 | + errorMsg[RoleIdErrorCode] = "角色不存在" |
| 99 | + errorMsg[UserIdErrorCode] = "用户不存在" |
| 100 | + errorMsg[ConfigErrorCode] = "配置不存在" |
| 101 | +} |
| 102 | + |
| 103 | +func MapErrMsg(errCode int) string { |
| 104 | + if msg, ok := errorMsg[errCode]; ok { |
| 105 | + return msg |
| 106 | + } else { |
| 107 | + return "服务繁忙,请稍后重试" |
| 108 | + } |
| 109 | +} |
0 commit comments