Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}};
Expand All @@ -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'
}};
Expand Down
16 changes: 7 additions & 9 deletions backend/app/core/base_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}")

Expand Down