mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-23 05:10:57 +00:00
feat: 为API路由添加response_model定义并优化代码
refactor: 重构DeptModel移除UserMixin继承 fix: 修复token过期时间单位错误 style: 优化日志字段拼接方式 docs: 更新AI助手示例提示文本 perf: 优化CRUDBase更新操作避免循环依赖 chore: 更新FastAPI默认响应状态码文档 feat(monitor): 为监控模块添加response_model定义 feat(system): 为系统模块添加response_model定义
This commit is contained in:
@@ -10,13 +10,18 @@ from app.core.dependencies import AuthPermission
|
||||
from app.core.logger import log
|
||||
from app.core.router_class import OperationLogRoute
|
||||
|
||||
from .schema import DeptCreateSchema, DeptQueryParam, DeptUpdateSchema
|
||||
from .schema import DeptCreateSchema, DeptOutSchema, DeptQueryParam, DeptUpdateSchema
|
||||
from .service import DeptService
|
||||
|
||||
DeptRouter = APIRouter(route_class=OperationLogRoute, prefix="/dept", tags=["部门管理"])
|
||||
|
||||
|
||||
@DeptRouter.get("/tree", summary="查询部门树", description="查询部门树")
|
||||
@DeptRouter.get(
|
||||
"/tree",
|
||||
summary="查询部门树",
|
||||
description="查询部门树",
|
||||
response_model=list[DeptOutSchema],
|
||||
)
|
||||
async def get_dept_tree_controller(
|
||||
search: Annotated[DeptQueryParam, Depends()],
|
||||
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:dept:query"]))],
|
||||
@@ -42,7 +47,12 @@ async def get_dept_tree_controller(
|
||||
return SuccessResponse(data=result_dict_list, msg="查询部门树成功")
|
||||
|
||||
|
||||
@DeptRouter.get("/detail/{id}", summary="查询部门详情", description="查询部门详情")
|
||||
@DeptRouter.get(
|
||||
"/detail/{id}",
|
||||
summary="查询部门详情",
|
||||
description="查询部门详情",
|
||||
response_model=DeptOutSchema,
|
||||
)
|
||||
async def get_obj_detail_controller(
|
||||
id: Annotated[int, Path(description="部门ID")],
|
||||
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:dept:detail"]))],
|
||||
@@ -65,7 +75,12 @@ async def get_obj_detail_controller(
|
||||
return SuccessResponse(data=result_dict, msg="查询部门详情成功")
|
||||
|
||||
|
||||
@DeptRouter.post("/create", summary="创建部门", description="创建部门")
|
||||
@DeptRouter.post(
|
||||
"/create",
|
||||
summary="创建部门",
|
||||
description="创建部门",
|
||||
response_model=DeptOutSchema,
|
||||
)
|
||||
async def create_obj_controller(
|
||||
data: DeptCreateSchema,
|
||||
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:dept:create"]))],
|
||||
@@ -88,7 +103,12 @@ async def create_obj_controller(
|
||||
return SuccessResponse(data=result_dict, msg="创建部门成功")
|
||||
|
||||
|
||||
@DeptRouter.put("/update/{id}", summary="修改部门", description="修改部门")
|
||||
@DeptRouter.put(
|
||||
"/update/{id}",
|
||||
summary="修改部门",
|
||||
description="修改部门",
|
||||
response_model=DeptOutSchema,
|
||||
)
|
||||
async def update_obj_controller(
|
||||
data: DeptUpdateSchema,
|
||||
id: Annotated[int, Path(description="部门ID")],
|
||||
@@ -113,7 +133,11 @@ async def update_obj_controller(
|
||||
return SuccessResponse(data=result_dict, msg="修改部门成功")
|
||||
|
||||
|
||||
@DeptRouter.delete("/delete", summary="删除部门", description="删除部门")
|
||||
@DeptRouter.delete(
|
||||
"/delete",
|
||||
summary="删除部门",
|
||||
description="删除部门",
|
||||
)
|
||||
async def delete_obj_controller(
|
||||
ids: Annotated[list[int], Body(description="ID列表")],
|
||||
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:dept:delete"]))],
|
||||
|
||||
Reference in New Issue
Block a user