mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-22 05:02:57 +00:00
refactor(api): 统一更新接口使用路径参数传递ID
refactor(backend): 重构CRUD基类查询方法去除重复结果 feat(application): 新增应用系统模块基础结构 fix(backend): 修复多处日志记录ID变量名错误 style(backend): 清理无用代码和注释 fix(frontend): 修复用户导入功能参数错误 docs(backend): 更新环境配置示例注释 perf(backend): 优化导出功能数据处理逻辑 test(frontend): 添加任务日志功能开发中提示 chore: 更新角色菜单权限数据
This commit is contained in:
@@ -28,7 +28,7 @@ async def get_obj_detail_controller(
|
||||
id: int = Path(..., description="示例ID"),
|
||||
auth: AuthSchema = Depends(AuthPermission(permissions=["demo:example:query"]))
|
||||
) -> JSONResponse:
|
||||
result_dict = await DemoService.get_example_detail_service(id=id, auth=auth)
|
||||
result_dict = await DemoService.get_demo_detail_service(id=id, auth=auth)
|
||||
logger.info(f"获取示例详情成功 {id}")
|
||||
return SuccessResponse(data=result_dict, msg="获取示例详情成功")
|
||||
|
||||
@@ -38,7 +38,7 @@ async def get_obj_list_controller(
|
||||
search: DemoQueryParams = Depends(),
|
||||
auth: AuthSchema = Depends(AuthPermission(permissions=["demo:example:query"]))
|
||||
) -> JSONResponse:
|
||||
result_dict_list = await DemoService.get_example_list_service(auth=auth, search=search, order_by=page.order_by)
|
||||
result_dict_list = await DemoService.get_demo_list_service(auth=auth, search=search, order_by=page.order_by)
|
||||
result_dict = await PaginationService.get_page_obj(data_list= result_dict_list, page_no= page.page_no, page_size = page.page_size)
|
||||
logger.info(f"查询示例列表成功")
|
||||
return SuccessResponse(data=result_dict, msg="查询公告列表成功")
|
||||
@@ -48,16 +48,17 @@ async def create_obj_controller(
|
||||
data: DemoCreateSchema,
|
||||
auth: AuthSchema = Depends(AuthPermission(permissions=["demo:example:create"]))
|
||||
) -> JSONResponse:
|
||||
result_dict = await DemoService.create_example_service(auth=auth, data=data)
|
||||
result_dict = await DemoService.create_demo_service(auth=auth, data=data)
|
||||
logger.info(f"创建示例成功: {result_dict}")
|
||||
return SuccessResponse(data=result_dict, msg="创建示例成功")
|
||||
|
||||
@DemoRouter.put("/update", summary="修改示例", description="修改示例")
|
||||
@DemoRouter.put("/update/{id}", summary="修改示例", description="修改示例")
|
||||
async def update_obj_controller(
|
||||
data: DemoUpdateSchema,
|
||||
id: int = Path(..., description="示例ID"),
|
||||
auth: AuthSchema = Depends(AuthPermission(permissions=["demo:example:update"]))
|
||||
) -> JSONResponse:
|
||||
result_dict = await DemoService.update_example_service(auth=auth, data=data)
|
||||
result_dict = await DemoService.update_demo_service(auth=auth, id=id, data=data)
|
||||
logger.info(f"修改示例成功: {result_dict}")
|
||||
return SuccessResponse(data=result_dict, msg="修改示例成功")
|
||||
|
||||
@@ -66,7 +67,7 @@ async def delete_obj_controller(
|
||||
ids: list[int] = Body(..., description="ID列表"),
|
||||
auth: AuthSchema = Depends(AuthPermission(permissions=["demo:example:delete"]))
|
||||
) -> JSONResponse:
|
||||
await DemoService.delete_example_service(auth=auth, ids=ids)
|
||||
await DemoService.delete_demo_service(auth=auth, ids=ids)
|
||||
logger.info(f"删除示例成功: {ids}")
|
||||
return SuccessResponse(msg="删除示例成功")
|
||||
|
||||
@@ -75,7 +76,7 @@ async def batch_set_available_obj_controller(
|
||||
data: BatchSetAvailable,
|
||||
auth: AuthSchema = Depends(AuthPermission(permissions=["demo:example:patch"]))
|
||||
) -> JSONResponse:
|
||||
await DemoService.set_example_available_service(auth=auth, data=data)
|
||||
await DemoService.set_demo_available_service(auth=auth, data=data)
|
||||
logger.info(f"批量修改示例状态成功: {data.ids}")
|
||||
return SuccessResponse(msg="批量修改示例状态成功")
|
||||
|
||||
@@ -85,7 +86,7 @@ async def export_obj_list_controller(
|
||||
auth: AuthSchema = Depends(AuthPermission(permissions=["demo:example:export"]))
|
||||
) -> StreamingResponse:
|
||||
# 获取全量数据
|
||||
result_dict_list = await DemoService.get_example_list_service(search=search, auth=auth)
|
||||
result_dict_list = await DemoService.get_demo_list_service(search=search, auth=auth)
|
||||
export_result = await DemoService.batch_export_service(obj_list=result_dict_list)
|
||||
logger.info('导出示例成功')
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class DemoCreateSchema(BaseModel):
|
||||
|
||||
class DemoUpdateSchema(DemoCreateSchema):
|
||||
"""更新模型"""
|
||||
id: int = Field(..., gt=0, description="示例ID")
|
||||
...
|
||||
|
||||
|
||||
class DemoOutSchema(DemoCreateSchema, BaseSchema):
|
||||
|
||||
@@ -44,15 +44,15 @@ class DemoService:
|
||||
return DemoOutSchema.model_validate(obj).model_dump()
|
||||
|
||||
@classmethod
|
||||
async def update_demo_service(cls, auth: AuthSchema, data: DemoUpdateSchema) -> Dict:
|
||||
async def update_demo_service(cls, auth: AuthSchema, id:int, data: DemoUpdateSchema) -> Dict:
|
||||
"""更新"""
|
||||
obj = await DemoCRUD(auth).get_by_id_crud(id=data.id)
|
||||
obj = await DemoCRUD(auth).get_by_id_crud(id=id)
|
||||
if not obj:
|
||||
raise CustomException(msg='更新失败,该数据不存在')
|
||||
exist_obj = await DemoCRUD(auth).get(name=data.name)
|
||||
if exist_obj and exist_obj.id != data.id:
|
||||
raise CustomException(msg='更新失败,名称重复')
|
||||
obj = await DemoCRUD(auth).update_crud(id=data.id, data=data)
|
||||
obj = await DemoCRUD(auth).update_crud(id=id, data=data)
|
||||
return DemoOutSchema.model_validate(obj).model_dump()
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user