1
0
forked from erp-dev/erp

feat: error_code + api doc + printing-job fields

This commit is contained in:
2026-07-06 23:13:57 +08:00
parent 740d23d04b
commit ddbf798665
21 changed files with 977 additions and 17 deletions

88
flower/error_code.py Normal file
View File

@@ -0,0 +1,88 @@
from enum import IntEnum
class AuthErrorCode(IntEnum):
MISSING_CREDENTIALS = 10001
MISSING_USERNAME = 10002
MISSING_PASSWORD = 10003
USER_NOT_FOUND = 10004
INVALID_PASSWORD = 10005
USER_INACTIVE = 10006
EMPLOYEE_NOT_BOUND = 10007
EMPLOYEE_INACTIVE = 10008
NOT_AUTHENTICATED = 10009
BAD_AUTHORIZATION_HEADER = 10010
TOKEN_NOT_VALID = 10011
TOKEN_USER_NOT_FOUND = 10012
TOKEN_USER_INACTIVE = 10013
PERMISSION_DENIED = 10014
AUTH_ERROR_CODE_DETAILS = {
AuthErrorCode.MISSING_CREDENTIALS: {
'code': 'missing_credentials',
'message': '请输入用户名和密码',
},
AuthErrorCode.MISSING_USERNAME: {
'code': 'missing_username',
'message': '请输入用户名',
},
AuthErrorCode.MISSING_PASSWORD: {
'code': 'missing_password',
'message': '请输入密码',
},
AuthErrorCode.USER_NOT_FOUND: {
'code': 'user_not_found',
'message': '用户不存在',
},
AuthErrorCode.INVALID_PASSWORD: {
'code': 'invalid_password',
'message': '密码错误',
},
AuthErrorCode.USER_INACTIVE: {
'code': 'user_inactive',
'message': '该用户已被禁用',
},
AuthErrorCode.EMPLOYEE_NOT_BOUND: {
'code': 'employee_not_bound',
'message': '该用户未绑定员工身份',
},
AuthErrorCode.EMPLOYEE_INACTIVE: {
'code': 'employee_inactive',
'message': '该员工已离职或停用',
},
AuthErrorCode.NOT_AUTHENTICATED: {
'code': 'not_authenticated',
'message': '未提供认证凭据',
},
AuthErrorCode.BAD_AUTHORIZATION_HEADER: {
'code': 'bad_authorization_header',
'message': 'Authorization 请求头格式错误',
},
AuthErrorCode.TOKEN_NOT_VALID: {
'code': 'token_not_valid',
'message': 'Token 无效或已过期',
},
AuthErrorCode.TOKEN_USER_NOT_FOUND: {
'code': 'token_user_not_found',
'message': 'Token 对应用户不存在',
},
AuthErrorCode.TOKEN_USER_INACTIVE: {
'code': 'token_user_inactive',
'message': 'Token 对应用户已被禁用',
},
AuthErrorCode.PERMISSION_DENIED: {
'code': 'permission_denied',
'message': '无权限访问该资源',
},
}
ERROR_CODE_GROUPS = [
{
'module': 'auth',
'title': '认证',
'enum': AuthErrorCode,
'details': AUTH_ERROR_CODE_DETAILS,
},
]