chore: 拆分app结构,将中间件、异常、子应用拆分成单独的模块
This commit is contained in:
@@ -1,116 +1,12 @@
|
|||||||
from fastapi import FastAPI, Request
|
|
||||||
from fastapi.exceptions import HTTPException
|
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
|
||||||
from fastapi.staticfiles import StaticFiles
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from contextlib import asynccontextmanager
|
from server import app, AppConfig
|
||||||
from module_admin.controller.login_controller import loginController
|
|
||||||
from module_admin.controller.captcha_controller import captchaController
|
|
||||||
from module_admin.controller.user_controller import userController
|
|
||||||
from module_admin.controller.menu_controller import menuController
|
|
||||||
from module_admin.controller.dept_controller import deptController
|
|
||||||
from module_admin.controller.role_controller import roleController
|
|
||||||
from module_admin.controller.post_controler import postController
|
|
||||||
from module_admin.controller.dict_controller import dictController
|
|
||||||
from module_admin.controller.config_controller import configController
|
|
||||||
from module_admin.controller.notice_controller import noticeController
|
|
||||||
from module_admin.controller.log_controller import logController
|
|
||||||
from module_admin.controller.online_controller import onlineController
|
|
||||||
from module_admin.controller.job_controller import jobController
|
|
||||||
from module_admin.controller.server_controller import serverController
|
|
||||||
from module_admin.controller.cache_controller import cacheController
|
|
||||||
from module_admin.controller.common_controller import commonController
|
|
||||||
from config.env import AppConfig, UploadConfig
|
|
||||||
from config.get_redis import RedisUtil
|
|
||||||
from config.get_db import init_create_table
|
|
||||||
from config.get_scheduler import SchedulerUtil
|
|
||||||
from utils.response_util import *
|
|
||||||
from utils.log_util import logger
|
|
||||||
from utils.common_util import worship
|
|
||||||
|
|
||||||
|
|
||||||
@asynccontextmanager
|
|
||||||
async def lifespan(app: FastAPI):
|
|
||||||
logger.info(f"{AppConfig.app_name}开始启动")
|
|
||||||
worship()
|
|
||||||
await init_create_table()
|
|
||||||
app.state.redis = await RedisUtil.create_redis_pool()
|
|
||||||
await RedisUtil.init_sys_dict(app.state.redis)
|
|
||||||
await RedisUtil.init_sys_config(app.state.redis)
|
|
||||||
await SchedulerUtil.init_system_scheduler()
|
|
||||||
logger.info(f"{AppConfig.app_name}启动成功")
|
|
||||||
yield
|
|
||||||
await RedisUtil.close_redis_pool(app)
|
|
||||||
await SchedulerUtil.close_system_scheduler()
|
|
||||||
|
|
||||||
|
|
||||||
app = FastAPI(
|
|
||||||
title=AppConfig.app_name,
|
|
||||||
description=f'{AppConfig.app_name}接口文档',
|
|
||||||
version=AppConfig.app_version,
|
|
||||||
lifespan=lifespan
|
|
||||||
)
|
|
||||||
|
|
||||||
# 前端页面url
|
|
||||||
origins = [
|
|
||||||
"http://localhost:81",
|
|
||||||
"http://127.0.0.1:81",
|
|
||||||
]
|
|
||||||
|
|
||||||
# 后台api允许跨域
|
|
||||||
app.add_middleware(
|
|
||||||
CORSMiddleware,
|
|
||||||
allow_origins=origins,
|
|
||||||
allow_credentials=True,
|
|
||||||
allow_methods=["*"],
|
|
||||||
allow_headers=["*"],
|
|
||||||
)
|
|
||||||
|
|
||||||
# 挂载静态文件路径
|
|
||||||
app.mount(f"{UploadConfig.UPLOAD_PREFIX}", StaticFiles(directory=f"{UploadConfig.UPLOAD_PATH}"), name="profile")
|
|
||||||
|
|
||||||
|
|
||||||
# 自定义token检验异常
|
|
||||||
@app.exception_handler(AuthException)
|
|
||||||
async def auth_exception_handler(request: Request, exc: AuthException):
|
|
||||||
return ResponseUtil.unauthorized(data=exc.data, msg=exc.message)
|
|
||||||
|
|
||||||
|
|
||||||
# 自定义权限检验异常
|
|
||||||
@app.exception_handler(PermissionException)
|
|
||||||
async def permission_exception_handler(request: Request, exc: PermissionException):
|
|
||||||
return ResponseUtil.forbidden(data=exc.data, msg=exc.message)
|
|
||||||
|
|
||||||
|
|
||||||
@app.exception_handler(HTTPException)
|
|
||||||
async def http_exception_handler(request: Request, exc: HTTPException):
|
|
||||||
return JSONResponse(
|
|
||||||
content=jsonable_encoder({"message": exc.detail, "code": exc.status_code}),
|
|
||||||
status_code=exc.status_code
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
controller_list = [
|
|
||||||
{'router': loginController, 'tags': ['登录模块']},
|
|
||||||
{'router': captchaController, 'tags': ['验证码模块']},
|
|
||||||
{'router': userController, 'tags': ['系统管理-用户管理']},
|
|
||||||
{'router': roleController, 'tags': ['系统管理-角色管理']},
|
|
||||||
{'router': menuController, 'tags': ['系统管理-菜单管理']},
|
|
||||||
{'router': deptController, 'tags': ['系统管理-部门管理']},
|
|
||||||
{'router': postController, 'tags': ['系统管理-岗位管理']},
|
|
||||||
{'router': dictController, 'tags': ['系统管理-字典管理']},
|
|
||||||
{'router': configController, 'tags': ['系统管理-参数管理']},
|
|
||||||
{'router': noticeController, 'tags': ['系统管理-通知公告管理']},
|
|
||||||
{'router': logController, 'tags': ['系统管理-日志管理']},
|
|
||||||
{'router': onlineController, 'tags': ['系统监控-在线用户']},
|
|
||||||
{'router': jobController, 'tags': ['系统监控-定时任务']},
|
|
||||||
{'router': serverController, 'tags': ['系统监控-菜单管理']},
|
|
||||||
{'router': cacheController, 'tags': ['系统监控-缓存监控']},
|
|
||||||
{'router': commonController, 'tags': ['通用模块']}
|
|
||||||
]
|
|
||||||
|
|
||||||
for controller in controller_list:
|
|
||||||
app.include_router(router=controller.get('router'), tags=controller.get('tags'))
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
uvicorn.run(app='app:app', host=AppConfig.app_host, port=AppConfig.app_port, root_path=AppConfig.app_root_path, reload=AppConfig.app_reload)
|
uvicorn.run(
|
||||||
|
app='app:app',
|
||||||
|
host=AppConfig.app_host,
|
||||||
|
port=AppConfig.app_port,
|
||||||
|
root_path=AppConfig.app_root_path,
|
||||||
|
reload=AppConfig.app_reload
|
||||||
|
)
|
||||||
|
28
ruoyi-fastapi-backend/exceptions/exception.py
Normal file
28
ruoyi-fastapi-backend/exceptions/exception.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
class LoginException(Exception):
|
||||||
|
"""
|
||||||
|
自定义登录异常LoginException
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, data: str = None, message: str = None):
|
||||||
|
self.data = data
|
||||||
|
self.message = message
|
||||||
|
|
||||||
|
|
||||||
|
class AuthException(Exception):
|
||||||
|
"""
|
||||||
|
自定义令牌异常AuthException
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, data: str = None, message: str = None):
|
||||||
|
self.data = data
|
||||||
|
self.message = message
|
||||||
|
|
||||||
|
|
||||||
|
class PermissionException(Exception):
|
||||||
|
"""
|
||||||
|
自定义权限异常PermissionException
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, data: str = None, message: str = None):
|
||||||
|
self.data = data
|
||||||
|
self.message = message
|
27
ruoyi-fastapi-backend/exceptions/handle.py
Normal file
27
ruoyi-fastapi-backend/exceptions/handle.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
from fastapi import Request
|
||||||
|
from fastapi.exceptions import HTTPException
|
||||||
|
from server import app
|
||||||
|
from exceptions.auth_exception import AuthException
|
||||||
|
from exceptions.permission_exception import PermissionException
|
||||||
|
from utils.response_util import ResponseUtil, JSONResponse, jsonable_encoder
|
||||||
|
|
||||||
|
|
||||||
|
# 自定义token检验异常
|
||||||
|
@app.exception_handler(AuthException)
|
||||||
|
async def auth_exception_handler(request: Request, exc: AuthException):
|
||||||
|
return ResponseUtil.unauthorized(data=exc.data, msg=exc.message)
|
||||||
|
|
||||||
|
|
||||||
|
# 自定义权限检验异常
|
||||||
|
@app.exception_handler(PermissionException)
|
||||||
|
async def permission_exception_handler(request: Request, exc: PermissionException):
|
||||||
|
return ResponseUtil.forbidden(data=exc.data, msg=exc.message)
|
||||||
|
|
||||||
|
|
||||||
|
# 处理其他http请求异常
|
||||||
|
@app.exception_handler(HTTPException)
|
||||||
|
async def http_exception_handler(request: Request, exc: HTTPException):
|
||||||
|
return JSONResponse(
|
||||||
|
content=jsonable_encoder({"code": exc.status_code, "msg": exc.detail}),
|
||||||
|
status_code=exc.status_code
|
||||||
|
)
|
18
ruoyi-fastapi-backend/middlewares/cors_middleware.py
Normal file
18
ruoyi-fastapi-backend/middlewares/cors_middleware.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
from server import app
|
||||||
|
|
||||||
|
|
||||||
|
# 前端页面url
|
||||||
|
origins = [
|
||||||
|
"http://localhost:80",
|
||||||
|
"http://127.0.0.1:80",
|
||||||
|
]
|
||||||
|
|
||||||
|
# 后台api允许跨域
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=origins,
|
||||||
|
allow_credentials=True,
|
||||||
|
allow_methods=["*"],
|
||||||
|
allow_headers=["*"],
|
||||||
|
)
|
@@ -1,7 +1,7 @@
|
|||||||
from fastapi import Depends
|
from fastapi import Depends
|
||||||
from module_admin.entity.vo.user_vo import CurrentUserModel
|
from module_admin.entity.vo.user_vo import CurrentUserModel
|
||||||
from module_admin.service.login_service import LoginService
|
from module_admin.service.login_service import LoginService
|
||||||
from utils.response_util import PermissionException
|
from exceptions.exception import PermissionException
|
||||||
|
|
||||||
|
|
||||||
class CheckUserInterfaceAuth:
|
class CheckUserInterfaceAuth:
|
||||||
|
@@ -2,10 +2,10 @@ from fastapi import APIRouter
|
|||||||
from module_admin.service.login_service import *
|
from module_admin.service.login_service import *
|
||||||
from module_admin.entity.vo.login_vo import *
|
from module_admin.entity.vo.login_vo import *
|
||||||
from module_admin.dao.login_dao import *
|
from module_admin.dao.login_dao import *
|
||||||
from config.env import JwtConfig, RedisInitKeyConfig
|
|
||||||
from utils.response_util import *
|
|
||||||
from utils.log_util import *
|
|
||||||
from module_admin.annotation.log_annotation import log_decorator
|
from module_admin.annotation.log_annotation import log_decorator
|
||||||
|
from config.env import JwtConfig, RedisInitKeyConfig
|
||||||
|
from utils.response_util import ResponseUtil
|
||||||
|
from utils.log_util import *
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
|
|
||||||
@@ -88,13 +88,13 @@ async def get_sms_code(request: Request, user: ResetUserModel, query_db: Session
|
|||||||
sms_result = await get_sms_code_services(request, query_db, user)
|
sms_result = await get_sms_code_services(request, query_db, user)
|
||||||
if sms_result.is_success:
|
if sms_result.is_success:
|
||||||
logger.info('获取成功')
|
logger.info('获取成功')
|
||||||
return response_200(data=sms_result, message='获取成功')
|
return ResponseUtil.success(data=sms_result)
|
||||||
else:
|
else:
|
||||||
logger.warning(sms_result.message)
|
logger.warning(sms_result.message)
|
||||||
return response_400(data='', message=sms_result.message)
|
return ResponseUtil.failure(msg=sms_result.message)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(e)
|
logger.exception(e)
|
||||||
return response_500(data="", message=str(e))
|
return ResponseUtil.error(msg=str(e))
|
||||||
|
|
||||||
|
|
||||||
@loginController.post("/forgetPwd", response_model=CrudResponseModel)
|
@loginController.post("/forgetPwd", response_model=CrudResponseModel)
|
||||||
@@ -103,13 +103,13 @@ async def forget_user_pwd(request: Request, forget_user: ResetUserModel, query_d
|
|||||||
forget_user_result = await forget_user_services(request, query_db, forget_user)
|
forget_user_result = await forget_user_services(request, query_db, forget_user)
|
||||||
if forget_user_result.is_success:
|
if forget_user_result.is_success:
|
||||||
logger.info(forget_user_result.message)
|
logger.info(forget_user_result.message)
|
||||||
return response_200(data=forget_user_result, message=forget_user_result.message)
|
return ResponseUtil.success(data=forget_user_result, msg=forget_user_result.message)
|
||||||
else:
|
else:
|
||||||
logger.warning(forget_user_result.message)
|
logger.warning(forget_user_result.message)
|
||||||
return response_400(data="", message=forget_user_result.message)
|
return ResponseUtil.failure(msg=forget_user_result.message)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(e)
|
logger.exception(e)
|
||||||
return response_500(data="", message=str(e))
|
return ResponseUtil.error(msg=str(e))
|
||||||
|
|
||||||
|
|
||||||
@loginController.post("/logout")
|
@loginController.post("/logout")
|
||||||
|
@@ -9,12 +9,13 @@ from module_admin.service.user_service import *
|
|||||||
from module_admin.entity.vo.login_vo import *
|
from module_admin.entity.vo.login_vo import *
|
||||||
from module_admin.entity.vo.common_vo import CrudResponseModel
|
from module_admin.entity.vo.common_vo import CrudResponseModel
|
||||||
from module_admin.dao.login_dao import *
|
from module_admin.dao.login_dao import *
|
||||||
|
from exceptions.exception import LoginException, AuthException
|
||||||
from config.env import AppConfig, JwtConfig, RedisInitKeyConfig
|
from config.env import AppConfig, JwtConfig, RedisInitKeyConfig
|
||||||
|
from config.get_db import get_db
|
||||||
from utils.common_util import CamelCaseUtil
|
from utils.common_util import CamelCaseUtil
|
||||||
from utils.pwd_util import *
|
from utils.pwd_util import *
|
||||||
from utils.response_util import *
|
from utils.response_util import *
|
||||||
from utils.message_util import *
|
from utils.message_util import *
|
||||||
from config.get_db import get_db
|
|
||||||
|
|
||||||
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="login")
|
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="login")
|
||||||
|
|
||||||
|
70
ruoyi-fastapi-backend/server.py
Normal file
70
ruoyi-fastapi-backend/server.py
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
from fastapi import FastAPI
|
||||||
|
from contextlib import asynccontextmanager
|
||||||
|
from module_admin.controller.login_controller import loginController
|
||||||
|
from module_admin.controller.captcha_controller import captchaController
|
||||||
|
from module_admin.controller.user_controller import userController
|
||||||
|
from module_admin.controller.menu_controller import menuController
|
||||||
|
from module_admin.controller.dept_controller import deptController
|
||||||
|
from module_admin.controller.role_controller import roleController
|
||||||
|
from module_admin.controller.post_controler import postController
|
||||||
|
from module_admin.controller.dict_controller import dictController
|
||||||
|
from module_admin.controller.config_controller import configController
|
||||||
|
from module_admin.controller.notice_controller import noticeController
|
||||||
|
from module_admin.controller.log_controller import logController
|
||||||
|
from module_admin.controller.online_controller import onlineController
|
||||||
|
from module_admin.controller.job_controller import jobController
|
||||||
|
from module_admin.controller.server_controller import serverController
|
||||||
|
from module_admin.controller.cache_controller import cacheController
|
||||||
|
from module_admin.controller.common_controller import commonController
|
||||||
|
from config.env import AppConfig
|
||||||
|
from config.get_redis import RedisUtil
|
||||||
|
from config.get_db import init_create_table
|
||||||
|
from config.get_scheduler import SchedulerUtil
|
||||||
|
from utils.log_util import logger
|
||||||
|
from utils.common_util import worship
|
||||||
|
|
||||||
|
|
||||||
|
@asynccontextmanager
|
||||||
|
async def lifespan(app: FastAPI):
|
||||||
|
logger.info(f"{AppConfig.app_name}开始启动")
|
||||||
|
worship()
|
||||||
|
await init_create_table()
|
||||||
|
app.state.redis = await RedisUtil.create_redis_pool()
|
||||||
|
await RedisUtil.init_sys_dict(app.state.redis)
|
||||||
|
await RedisUtil.init_sys_config(app.state.redis)
|
||||||
|
await SchedulerUtil.init_system_scheduler()
|
||||||
|
logger.info(f"{AppConfig.app_name}启动成功")
|
||||||
|
yield
|
||||||
|
await RedisUtil.close_redis_pool(app)
|
||||||
|
await SchedulerUtil.close_system_scheduler()
|
||||||
|
|
||||||
|
|
||||||
|
app = FastAPI(
|
||||||
|
title=AppConfig.app_name,
|
||||||
|
description=f'{AppConfig.app_name}接口文档',
|
||||||
|
version=AppConfig.app_version,
|
||||||
|
lifespan=lifespan
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
controller_list = [
|
||||||
|
{'router': loginController, 'tags': ['登录模块']},
|
||||||
|
{'router': captchaController, 'tags': ['验证码模块']},
|
||||||
|
{'router': userController, 'tags': ['系统管理-用户管理']},
|
||||||
|
{'router': roleController, 'tags': ['系统管理-角色管理']},
|
||||||
|
{'router': menuController, 'tags': ['系统管理-菜单管理']},
|
||||||
|
{'router': deptController, 'tags': ['系统管理-部门管理']},
|
||||||
|
{'router': postController, 'tags': ['系统管理-岗位管理']},
|
||||||
|
{'router': dictController, 'tags': ['系统管理-字典管理']},
|
||||||
|
{'router': configController, 'tags': ['系统管理-参数管理']},
|
||||||
|
{'router': noticeController, 'tags': ['系统管理-通知公告管理']},
|
||||||
|
{'router': logController, 'tags': ['系统管理-日志管理']},
|
||||||
|
{'router': onlineController, 'tags': ['系统监控-在线用户']},
|
||||||
|
{'router': jobController, 'tags': ['系统监控-定时任务']},
|
||||||
|
{'router': serverController, 'tags': ['系统监控-菜单管理']},
|
||||||
|
{'router': cacheController, 'tags': ['系统监控-缓存监控']},
|
||||||
|
{'router': commonController, 'tags': ['通用模块']}
|
||||||
|
]
|
||||||
|
|
||||||
|
for controller in controller_list:
|
||||||
|
app.include_router(router=controller.get('router'), tags=controller.get('tags'))
|
7
ruoyi-fastapi-backend/sub_applications/staticfiles.py
Normal file
7
ruoyi-fastapi-backend/sub_applications/staticfiles.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
from server import app
|
||||||
|
from config.env import UploadConfig
|
||||||
|
|
||||||
|
|
||||||
|
# 挂载静态文件路径
|
||||||
|
app.mount(f"{UploadConfig.UPLOAD_PREFIX}", StaticFiles(directory=f"{UploadConfig.UPLOAD_PATH}"), name="profile")
|
@@ -187,115 +187,3 @@ class ResponseUtil:
|
|||||||
status_code=status.HTTP_200_OK,
|
status_code=status.HTTP_200_OK,
|
||||||
content=data
|
content=data
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def response_200(*, data: Any = None, message="获取成功") -> Response:
|
|
||||||
return JSONResponse(
|
|
||||||
status_code=status.HTTP_200_OK,
|
|
||||||
content=jsonable_encoder(
|
|
||||||
{
|
|
||||||
'code': 200,
|
|
||||||
'message': message,
|
|
||||||
'data': data,
|
|
||||||
'success': 'true',
|
|
||||||
'time': datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def response_400(*, data: Any = None, message: str = "获取失败") -> Response:
|
|
||||||
return JSONResponse(
|
|
||||||
status_code=status.HTTP_400_BAD_REQUEST,
|
|
||||||
content=jsonable_encoder(
|
|
||||||
{
|
|
||||||
'code': 400,
|
|
||||||
'message': message,
|
|
||||||
'data': data,
|
|
||||||
'success': 'false',
|
|
||||||
'time': datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def response_401(*, data: Any = None, message: str = "获取失败") -> Response:
|
|
||||||
return JSONResponse(
|
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
||||||
content=jsonable_encoder(
|
|
||||||
{
|
|
||||||
'code': 401,
|
|
||||||
'message': message,
|
|
||||||
'data': data,
|
|
||||||
'success': 'false',
|
|
||||||
'time': datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def response_403(*, data: Any = None, message: str = "获取失败") -> Response:
|
|
||||||
return JSONResponse(
|
|
||||||
status_code=status.HTTP_403_FORBIDDEN,
|
|
||||||
content=jsonable_encoder(
|
|
||||||
{
|
|
||||||
'code': 403,
|
|
||||||
'message': message,
|
|
||||||
'data': data,
|
|
||||||
'success': 'false',
|
|
||||||
'time': datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def response_500(*, data: Any = None, message: str = "接口异常") -> Response:
|
|
||||||
return JSONResponse(
|
|
||||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
|
||||||
content=jsonable_encoder(
|
|
||||||
{
|
|
||||||
'code': 500,
|
|
||||||
'message': message,
|
|
||||||
'data': data,
|
|
||||||
'success': 'false',
|
|
||||||
'time': datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def streaming_response_200(*, data: Any = None):
|
|
||||||
return StreamingResponse(
|
|
||||||
status_code=status.HTTP_200_OK,
|
|
||||||
content=data,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class AuthException(Exception):
|
|
||||||
"""
|
|
||||||
自定义令牌异常AuthException
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, data: str = None, message: str = None):
|
|
||||||
self.data = data
|
|
||||||
self.message = message
|
|
||||||
|
|
||||||
|
|
||||||
class PermissionException(Exception):
|
|
||||||
"""
|
|
||||||
自定义权限异常PermissionException
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, data: str = None, message: str = None):
|
|
||||||
self.data = data
|
|
||||||
self.message = message
|
|
||||||
|
|
||||||
|
|
||||||
class LoginException(Exception):
|
|
||||||
"""
|
|
||||||
自定义登录异常LoginException
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, data: str = None, message: str = None):
|
|
||||||
self.data = data
|
|
||||||
self.message = message
|
|
||||||
|
Reference in New Issue
Block a user