项目初始化

This commit is contained in:
2025-09-29 16:49:43 +08:00
commit f7131cf425
14 changed files with 240 additions and 0 deletions

34
common/reponse_code.py Normal file
View File

@@ -0,0 +1,34 @@
from fastapi.responses import JSONResponse, Response
from fastapi import status
def response_code_view(code: int,msg: str) -> Response:
return JSONResponse(
status_code=code,
content={
'code': code,
'msg': msg
}
)
def response_success(msg: str = "查询成功", data: object = None):
return JSONResponse(
status_code=status.HTTP_200_OK,
content={
'code': 200,
'msg': msg,
'data': data,
}
)
def response_error(msg:str):
return JSONResponse(
status_code=status.HTTP_200_OK,
content={
'code': 500,
'msg': msg,
'data': None,
}
)