mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-26 22:31:21 +00:00
refactor(字段命名): 统一将created_at和updated_at重命名为created_time和updated_time
重构字段命名以保持一致性,将时间相关字段从created_at/updated_at统一改为created_time/updated_time 同时调整相关查询参数、服务层映射和模板文件中的字段命名 优化权限过滤逻辑,提取为独立的Permission类
This commit is contained in:
@@ -13,7 +13,7 @@ class DemoQueryParam:
|
||||
self,
|
||||
name: Optional[str] = Query(None, description="名称"),
|
||||
status: Optional[bool] = Query(None, description="是否启用"),
|
||||
creator: Optional[int] = Query(None, description="创建人"),
|
||||
created_id: Optional[int] = Query(None, description="创建人"),
|
||||
start_time: Optional[DateTimeStr] = Query(None, description="开始时间", example="2025-01-01 00:00:00"),
|
||||
end_time: Optional[DateTimeStr] = Query(None, description="结束时间", example="2025-12-31 23:59:59"),
|
||||
) -> None:
|
||||
@@ -22,11 +22,11 @@ class DemoQueryParam:
|
||||
self.name = ("like", name)
|
||||
|
||||
# 精确查询字段
|
||||
self.created_id = creator
|
||||
self.created_id = created_id
|
||||
self.status = status
|
||||
|
||||
# 时间范围查询
|
||||
if start_time and end_time:
|
||||
self.created_at = ("between", (start_time, end_time))
|
||||
self.created_time = ("between", (start_time, end_time))
|
||||
|
||||
|
||||
|
||||
@@ -179,9 +179,9 @@ class DemoService:
|
||||
'name': '名称',
|
||||
'status': '状态',
|
||||
'description': '备注',
|
||||
'created_at': '创建时间',
|
||||
'updated_at': '更新时间',
|
||||
'creator': '创建者',
|
||||
'created_time': '创建时间',
|
||||
'updated_time': '更新时间',
|
||||
'created_id': '创建者',
|
||||
}
|
||||
|
||||
# 复制数据并转换状态
|
||||
@@ -190,11 +190,11 @@ class DemoService:
|
||||
# 处理状态
|
||||
item['status'] = '正常' if item.get('status') else '停用'
|
||||
# 处理创建者
|
||||
creator_info = item.get('creator')
|
||||
creator_info = item.get('created_id')
|
||||
if isinstance(creator_info, dict):
|
||||
item['creator'] = creator_info.get('name', '未知')
|
||||
item['created_id'] = creator_info.get('name', '未知')
|
||||
else:
|
||||
item['creator'] = '未知'
|
||||
item['created_id'] = '未知'
|
||||
|
||||
return ExcelUtil.export_list2excel(list_data=data, mapping_dict=mapping_dict)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user