You've already forked DataMate
refactor(annotation): 统一查询参数命名规范
- 将分页查询参数 pageSize 替换为 size - 更新所有相关函数中的参数引用 - 修改日志输出中的参数名称显示 - 保持原有的分页逻辑不变
This commit is contained in:
@@ -131,7 +131,7 @@ async def create_mapping(
|
|||||||
@router.get("", response_model=StandardResponse[PaginatedData[DatasetMappingResponse]])
|
@router.get("", response_model=StandardResponse[PaginatedData[DatasetMappingResponse]])
|
||||||
async def list_mappings(
|
async def list_mappings(
|
||||||
page: int = Query(1, ge=1, description="页码(从1开始)"),
|
page: int = Query(1, ge=1, description="页码(从1开始)"),
|
||||||
page_size: int = Query(20, ge=1, le=100, description="每页记录数", alias="pageSize"),
|
size: int = Query(20, ge=1, le=100, description="每页记录数"),
|
||||||
include_template: bool = Query(False, description="是否包含模板详情", alias="includeTemplate"),
|
include_template: bool = Query(False, description="是否包含模板详情", alias="includeTemplate"),
|
||||||
db: AsyncSession = Depends(get_db)
|
db: AsyncSession = Depends(get_db)
|
||||||
):
|
):
|
||||||
@@ -143,32 +143,32 @@ async def list_mappings(
|
|||||||
|
|
||||||
参数:
|
参数:
|
||||||
- page: 页码(从1开始)
|
- page: 页码(从1开始)
|
||||||
- pageSize: 每页记录数
|
- size: 每页记录数
|
||||||
- includeTemplate: 是否包含模板详情(默认false)
|
- includeTemplate: 是否包含模板详情(默认false)
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
service = DatasetMappingService(db)
|
service = DatasetMappingService(db)
|
||||||
|
|
||||||
# 计算 skip
|
# 计算 skip
|
||||||
skip = (page - 1) * page_size
|
skip = (page - 1) * size
|
||||||
|
|
||||||
logger.info(f"List mappings: page={page}, page_size={page_size}, include_template={include_template}")
|
logger.info(f"List mappings: page={page}, size={size}, include_template={include_template}")
|
||||||
|
|
||||||
# 获取数据和总数
|
# 获取数据和总数
|
||||||
mappings, total = await service.get_all_mappings_with_count(
|
mappings, total = await service.get_all_mappings_with_count(
|
||||||
skip=skip,
|
skip=skip,
|
||||||
limit=page_size,
|
limit=size,
|
||||||
include_deleted=False,
|
include_deleted=False,
|
||||||
include_template=include_template
|
include_template=include_template
|
||||||
)
|
)
|
||||||
|
|
||||||
# 计算总页数
|
# 计算总页数
|
||||||
total_pages = math.ceil(total / page_size) if total > 0 else 0
|
total_pages = math.ceil(total / size) if total > 0 else 0
|
||||||
|
|
||||||
# 构造分页响应
|
# 构造分页响应
|
||||||
paginated_data = PaginatedData(
|
paginated_data = PaginatedData(
|
||||||
page=page,
|
page=page,
|
||||||
size=page_size,
|
size=size,
|
||||||
total_elements=total,
|
total_elements=total,
|
||||||
total_pages=total_pages,
|
total_pages=total_pages,
|
||||||
content=mappings
|
content=mappings
|
||||||
@@ -232,7 +232,7 @@ async def get_mapping(
|
|||||||
async def get_mappings_by_source(
|
async def get_mappings_by_source(
|
||||||
dataset_id: str,
|
dataset_id: str,
|
||||||
page: int = Query(1, ge=1, description="页码(从1开始)"),
|
page: int = Query(1, ge=1, description="页码(从1开始)"),
|
||||||
page_size: int = Query(20, ge=1, le=100, description="每页记录数", alias="pageSize"),
|
size: int = Query(20, ge=1, le=100, description="每页记录数"),
|
||||||
include_template: bool = Query(True, description="是否包含模板详情", alias="includeTemplate"),
|
include_template: bool = Query(True, description="是否包含模板详情", alias="includeTemplate"),
|
||||||
db: AsyncSession = Depends(get_db)
|
db: AsyncSession = Depends(get_db)
|
||||||
):
|
):
|
||||||
@@ -245,32 +245,32 @@ async def get_mappings_by_source(
|
|||||||
参数:
|
参数:
|
||||||
- dataset_id: 数据集ID
|
- dataset_id: 数据集ID
|
||||||
- page: 页码(从1开始)
|
- page: 页码(从1开始)
|
||||||
- pageSize: 每页记录数
|
- size: 每页记录数
|
||||||
- includeTemplate: 是否包含模板详情(默认true)
|
- includeTemplate: 是否包含模板详情(默认true)
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
service = DatasetMappingService(db)
|
service = DatasetMappingService(db)
|
||||||
|
|
||||||
# 计算 skip
|
# 计算 skip
|
||||||
skip = (page - 1) * page_size
|
skip = (page - 1) * size
|
||||||
|
|
||||||
logger.info(f"Get mappings by source dataset id: {dataset_id}, page={page}, page_size={page_size}, include_template={include_template}")
|
logger.info(f"Get mappings by source dataset id: {dataset_id}, page={page}, size={size}, include_template={include_template}")
|
||||||
|
|
||||||
# 获取数据和总数(包含模板信息)
|
# 获取数据和总数(包含模板信息)
|
||||||
mappings, total = await service.get_mappings_by_source_with_count(
|
mappings, total = await service.get_mappings_by_source_with_count(
|
||||||
dataset_id=dataset_id,
|
dataset_id=dataset_id,
|
||||||
skip=skip,
|
skip=skip,
|
||||||
limit=page_size,
|
limit=size,
|
||||||
include_template=include_template
|
include_template=include_template
|
||||||
)
|
)
|
||||||
|
|
||||||
# 计算总页数
|
# 计算总页数
|
||||||
total_pages = math.ceil(total / page_size) if total > 0 else 0
|
total_pages = math.ceil(total / size) if total > 0 else 0
|
||||||
|
|
||||||
# 构造分页响应
|
# 构造分页响应
|
||||||
paginated_data = PaginatedData(
|
paginated_data = PaginatedData(
|
||||||
page=page,
|
page=page,
|
||||||
size=page_size,
|
size=size,
|
||||||
total_elements=total,
|
total_elements=total,
|
||||||
total_pages=total_pages,
|
total_pages=total_pages,
|
||||||
content=mappings
|
content=mappings
|
||||||
|
|||||||
Reference in New Issue
Block a user