refactor(backend): 重构控制器和信息服务方法命名

- 更新了多个控制器文件中的函数命名,增加了 _controller 后缀
- 更新了多个服务文件中的函数命名,增加了 _service 后缀
- 统一了命名格式,提高了代码的可读性和可维护性
This commit is contained in:
zhangtao
2025-04-15 03:03:45 +08:00
parent 6e0e1303e1
commit da957dca55
45 changed files with 606 additions and 641 deletions
@@ -23,63 +23,62 @@ router = APIRouter(route_class=OperationLogRoute)
@router.get("/list", summary="查询部门", description="查询部门")
async def get_obj_list(
page: PaginationQueryParams = Depends(),
search: DeptQueryParams = Depends(),
auth: AuthSchema = Depends(AuthPermission(permissions=["system:dept:query"])),
async def get_obj_list_controller(
page: PaginationQueryParams = Depends(),
search: DeptQueryParams = Depends(),
auth: AuthSchema = Depends(AuthPermission(permissions=["system:dept:query"]))
) -> JSONResponse:
result_dict_list = await DeptService.get_dept_list_services(search=search, auth=auth, 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)
result_dict_list = await DeptService.get_dept_list_service(search=search, auth=auth, 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"{auth.user.name} 查询部门成功")
return SuccessResponse(data=result_dict, msg="查询部门成功")
@router.get("/detail", summary="查询部门详情", description="查询部门详情")
async def get_obj_detail(
id: int = Query(..., description="部门ID"),
auth: AuthSchema = Depends(AuthPermission(permissions=["system:dept:query"])),
async def get_obj_detail_controller(
id: int = Query(..., description="部门ID"),
auth: AuthSchema = Depends(AuthPermission(permissions=["system:dept:query"]))
) -> JSONResponse:
result_dict = await DeptService.get_dept_detail_services(id=id, auth=auth)
result_dict = await DeptService.get_dept_detail_service(id=id, auth=auth)
logger.info(f"{auth.user.name} 查询部门详情成功 {id}")
return SuccessResponse(data=result_dict, msg="查询部门详情成功")
@router.post("/create", summary="创建部门", description="创建部门")
async def create_obj(
data: DeptCreateSchema,
auth: AuthSchema = Depends(AuthPermission(permissions=["system:dept:create"])),
async def create_obj_controller(
data: DeptCreateSchema,
auth: AuthSchema = Depends(AuthPermission(permissions=["system:dept:create"]))
) -> JSONResponse:
result_dict = await DeptService.create_dept_services(data=data, auth=auth)
result_dict = await DeptService.create_dept_service(data=data, auth=auth)
logger.info(f"{auth.user.name} 创建部门成功: {result_dict}")
return SuccessResponse(data=result_dict, msg="创建部门成功")
@router.put("/update", summary="修改部门", description="修改部门")
async def update_obj(
data: DeptUpdateSchema,
auth: AuthSchema = Depends(AuthPermission(permissions=["system:dept:update"])),
async def update_obj_controller(
data: DeptUpdateSchema,
auth: AuthSchema = Depends(AuthPermission(permissions=["system:dept:update"]))
) -> JSONResponse:
result_dict = await DeptService.update_dept_services(data=data, auth=auth)
result_dict = await DeptService.update_dept_service(data=data, auth=auth)
logger.info(f"{auth.user.name} 修改部门成功: {result_dict}")
return SuccessResponse(data=result_dict, msg="修改部门成功")
@router.delete("/delete", summary="删除部门", description="删除部门")
async def delete_obj(
id: int = Query(..., description="部门ID"),
auth: AuthSchema = Depends(AuthPermission(permissions=["system:dept:delete"])),
async def delete_obj_controller(
id: int = Query(..., description="部门ID"),
auth: AuthSchema = Depends(AuthPermission(permissions=["system:dept:delete"]))
) -> JSONResponse:
await DeptService.delete_dept_services(id=id, auth=auth)
await DeptService.delete_dept_service(id=id, auth=auth)
logger.info(f"{auth.user.name} 删除部门成功: {id}")
return SuccessResponse(msg="删除部门成功")
@router.patch("/available/setting", summary="批量修改部门状态", description="批量修改部门状态")
async def batch_set_available_obj(
data: BatchSetAvailable,
auth: AuthSchema = Depends(AuthPermission(permissions=["system:dept:patch"])),
async def batch_set_available_obj_controller(
data: BatchSetAvailable,
auth: AuthSchema = Depends(AuthPermission(permissions=["system:dept:patch"]))
) -> JSONResponse:
await DeptService.batch_set_available_services(data=data , auth=auth)
await DeptService.batch_set_available_service(data=data, auth=auth)
logger.info(f"{auth.user.name} 批量修改部门状态成功: {data.ids}")
return SuccessResponse(msg="批量修改部门状态成功")