diff --git a/backend/app/api/v1/module_generator/gencode/templates/ts/api.ts.j2 b/backend/app/api/v1/module_generator/gencode/templates/ts/api.ts.j2 index 54f3cffa..06ce9411 100644 --- a/backend/app/api/v1/module_generator/gencode/templates/ts/api.ts.j2 +++ b/backend/app/api/v1/module_generator/gencode/templates/ts/api.ts.j2 @@ -107,12 +107,12 @@ export interface {{ class_name }}PageQuery extends PageQuery { end_time?: string; } -// 列表查询结果 +// 列表展示项 export interface {{ class_name }}Table { index?: number; {% for column in columns %} - {{ column.python_field }}?: {{ - 'boolean' if ('status' in (column.python_field|lower)) or (column.html_type == 'radio') + {{ column.column_name }}?: {{ + 'boolean' if ('status' in (column.column_name|lower)) or (column.html_type == 'radio') else 'number' if column.is_pk == 1 else 'string' }}; @@ -123,9 +123,9 @@ export interface {{ class_name }}Table { // 新增/修改/详情表单参数 export interface {{ class_name }}Form { {% for column in columns %} - {% if (column.is_insert == 1 or column.is_edit == 1) and column.python_field not in ['creatorId', 'createdAt', 'updatedAt'] %} - {{ column.python_field }}?: {{ - 'boolean' if ('status' in (column.python_field|lower)) or (column.html_type == 'radio') + {% if (column.is_insert == 1 or column.is_edit == 1) and column.column_name not in ['creator_id', 'created_at', 'updated_at'] %} + {{ column.column_name }}?: {{ + 'boolean' if ('status' in (column.column_name|lower)) or (column.html_type == 'radio') else 'number' if column.is_pk == 1 else 'string' }}; diff --git a/backend/app/core/base_crud.py b/backend/app/core/base_crud.py index 9969ca01..313474f7 100644 --- a/backend/app/core/base_crud.py +++ b/backend/app/core/base_crud.py @@ -179,15 +179,13 @@ async def page(self, offset: int, limit: int, order_by: List[Dict[str, str]], se result: Result = await self.db.execute(sql.offset(offset).limit(limit)) objs = result.scalars().all() - data = PageResultSchema( - items=[out_schema.model_validate(obj).model_dump() for obj in objs], - total=total, - page_no=offset // limit + 1 if limit else 1, - page_size=limit, - has_next=offset + limit < total, - ).model_dump() - - return data + return { + "page_no": offset // limit + 1 if limit else 1, + "page_size": limit if limit else 10, + "total": total, + "has_next": offset + limit < total, + "items": [out_schema.model_validate(obj).model_dump() for obj in objs] + } except Exception as e: raise CustomException(msg=f"分页查询失败: {str(e)}")