mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 12:52:26 +00:00
refactor(myapp): 重命名查询参数类以统一命名风格
- 将 ApplicationQueryParams 改为 ApplicationQueryParam - 同步更新相关导入和函数参数类型注解 - 修改 PaginationQueryParams 为 PaginationQueryParam refactor(demo): 重命名查询参数类以统一命名风格 - 将 DemoQueryParams 改为 DemoQueryParam - 同步更新相关导入和函数参数类型注解 - 修改 PaginationQueryParams 为 PaginationQueryParam refactor(gencode): 优化代码生成模块的模型和服务层结构 - 统一模型名称后缀为 Schema,调整相关引用 - 规范 Pydantic schema 的命名和定义 - 删除无用的 Python DAO 模板文件 - 调整导入路径,统一使用 app 目录下的模块路径 - 改进服务层方法签名,添加返回类型注解 - 使用自定义异常 CustomException 替代旧异常 - 统一成功响应格式为 SuccessResponse - 优化代码生成服务中的数据库操作 DAO 调用参数传递 - 优化代码生成业务表和字段模型的字段定义,添加注释和默认值 - 优化生成代码路径处理逻辑和异常信息提示 - 整合分页查询参数定义,统一分页模型 - 修正多个服务方法的参数类型和返回类型 - 删除无用的导入和多余注释,提升代码整洁度
This commit is contained in:
@@ -4,7 +4,7 @@ from fastapi import APIRouter, Body, Depends, Path, Query
|
||||
from fastapi.responses import JSONResponse, StreamingResponse
|
||||
|
||||
from app.common.response import StreamResponse, SuccessResponse
|
||||
from app.core.base_params import PaginationQueryParams
|
||||
from app.core.base_params import PaginationQueryParam
|
||||
from app.core.dependencies import AuthPermission, get_current_user
|
||||
from app.core.router_class import OperationLogRoute
|
||||
from app.core.base_schema import BatchSetAvailable
|
||||
@@ -12,7 +12,7 @@ from app.core.logger import logger
|
||||
from app.common.request import PaginationService
|
||||
from app.utils.common_util import bytes2file_response
|
||||
from ..auth.schema import AuthSchema
|
||||
from .param import NoticeQueryParams
|
||||
from .param import NoticeQueryParam
|
||||
from .service import NoticeService
|
||||
from .schema import (
|
||||
NoticeCreateSchema,
|
||||
@@ -33,8 +33,8 @@ async def get_obj_detail_controller(
|
||||
|
||||
@NoticeRouter.get("/list", summary="查询公告", description="查询公告")
|
||||
async def get_obj_list_controller(
|
||||
page: PaginationQueryParams = Depends(),
|
||||
search: NoticeQueryParams = Depends(),
|
||||
page: PaginationQueryParam = Depends(),
|
||||
search: NoticeQueryParam = Depends(),
|
||||
auth: AuthSchema = Depends(AuthPermission(permissions=["system:notice:query"]))
|
||||
) -> JSONResponse:
|
||||
result_dict_list = await NoticeService.get_notice_list_service(auth=auth, search=search, order_by=page.order_by)
|
||||
@@ -81,7 +81,7 @@ async def batch_set_available_obj_controller(
|
||||
|
||||
@NoticeRouter.post('/export', summary="导出公告", description="导出公告")
|
||||
async def export_obj_list_controller(
|
||||
search: NoticeQueryParams = Depends(),
|
||||
search: NoticeQueryParam = Depends(),
|
||||
auth: AuthSchema = Depends(AuthPermission(permissions=["system:notice:export"]))
|
||||
) -> StreamingResponse:
|
||||
# 获取全量数据
|
||||
|
||||
@@ -7,7 +7,7 @@ from fastapi import Query
|
||||
from app.core.validator import DateTimeStr
|
||||
|
||||
|
||||
class NoticeQueryParams:
|
||||
class NoticeQueryParam:
|
||||
"""公告通知查询参数"""
|
||||
|
||||
def __init__(
|
||||
|
||||
@@ -8,7 +8,7 @@ from app.core.exceptions import CustomException
|
||||
from app.utils.excel_util import ExcelUtil
|
||||
from ..auth.schema import AuthSchema
|
||||
from .schema import NoticeCreateSchema, NoticeUpdateSchema, NoticeOutSchema
|
||||
from .param import NoticeQueryParams
|
||||
from .param import NoticeQueryParam
|
||||
from .crud import NoticeCRUD
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class NoticeService:
|
||||
return [NoticeOutSchema.model_validate(notice_obj).model_dump() for notice_obj in notice_obj_list]
|
||||
|
||||
@classmethod
|
||||
async def get_notice_list_service(cls, auth: AuthSchema, search: NoticeQueryParams = None, order_by: List[Dict[str, str]] = None) -> List[Dict]:
|
||||
async def get_notice_list_service(cls, auth: AuthSchema, search: NoticeQueryParam = None, order_by: List[Dict[str, str]] = None) -> List[Dict]:
|
||||
if order_by:
|
||||
order_by = eval(order_by)
|
||||
notice_obj_list = await NoticeCRUD(auth).get_list_crud(search=search.__dict__, order_by=order_by)
|
||||
|
||||
Reference in New Issue
Block a user