mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-22 13:05:18 +00:00
- 修正 CRUD 基类初始化时 model 参数传递方式,改为实例化对象 - 修改部分查询中条件字段名的错误,table_id 改为 id - 修正数据库方言下查询语句缺少 SELECT 关键字的问题 - 优化查询参数绑定,避免直接传递包含分页参数的字典 - 修正生成表结构后返回数据中的主键字段 id 替代 table_id - 优化删除逻辑中获取列 ID 的字段名称错误 - 重写建表功能相关代码,添加异常捕获和事务回滚 - 取消子表字段 Schema 的非空强制,改为可选类型 - 修正前端接口请求路径及参数命名,使其更加直观和规范 - 修改模板加载路径为绝对路径,确保多环境下模板加载正确 - 修复模板工具中子表相关属性为空时的类型检查错误 - 调整模板文件及路径后缀名,统一从 .jinja2 改为 .j2 - 修正生成文件路径映射以符合新模板路径和文件名规范 - 删除冗余和废弃的 Python 控制器及 CRUD 模板文件 - 修正 SQL 菜单模板中模块名路径格式错误 - 更新前端 Vue API 调用函数参数与接口路径一致性
63 lines
2.4 KiB
Python
63 lines
2.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
from fastapi import Query
|
|
|
|
from app.core.validator import DateTimeStr
|
|
from app.core.base_params import PaginationQueryParam
|
|
from .schema import GenTableBaseSchema, GenTableColumnBaseSchema
|
|
|
|
|
|
class GenTableQueryParam(PaginationQueryParam, GenTableBaseSchema):
|
|
"""数据库表查询参数"""
|
|
|
|
def __init__(
|
|
self,
|
|
name: Optional[str] = Query(None, description="名称"),
|
|
status: Optional[bool] = Query(None, description="是否启用"),
|
|
creator: Optional[int] = Query(None, description="创建人"),
|
|
start_time: Optional[DateTimeStr] = Query(None, description="开始时间", example="2023-01-01 00:00:00"),
|
|
end_time: Optional[DateTimeStr] = Query(None, description="结束时间", example="2023-12-31 23:59:59"),
|
|
) -> None:
|
|
super().__init__()
|
|
|
|
# 模糊查询字段
|
|
self.name = ("like", name)
|
|
|
|
# 精确查询字段
|
|
self.creator_id = creator
|
|
self.status = status
|
|
|
|
# 时间范围查询
|
|
if start_time and end_time:
|
|
start_datetime = datetime.strptime(str(start_time), '%Y-%m-%d %H:%M:%S')
|
|
end_datetime = datetime.strptime(str(end_time), '%Y-%m-%d %H:%M:%S')
|
|
self.created_at = ("between", (start_datetime, end_datetime))
|
|
|
|
|
|
class GenTableColumnQueryParam(PaginationQueryParam, GenTableColumnBaseSchema):
|
|
"""数据库表字段查询参数"""
|
|
|
|
def __init__(
|
|
self,
|
|
name: Optional[str] = Query(None, description="名称"),
|
|
status: Optional[bool] = Query(None, description="是否启用"),
|
|
creator: Optional[int] = Query(None, description="创建人"),
|
|
start_time: Optional[DateTimeStr] = Query(None, description="开始时间", example="2023-01-01 00:00:00"),
|
|
end_time: Optional[DateTimeStr] = Query(None, description="结束时间", example="2023-12-31 23:59:59"),
|
|
) -> None:
|
|
super().__init__()
|
|
|
|
# 模糊查询字段
|
|
self.name = ("like", name)
|
|
|
|
# 精确查询字段
|
|
self.creator_id = creator
|
|
self.status = status
|
|
|
|
# 时间范围查询
|
|
if start_time and end_time:
|
|
start_datetime = datetime.strptime(str(start_time), '%Y-%m-%d %H:%M:%S')
|
|
end_datetime = datetime.strptime(str(end_time), '%Y-%m-%d %H:%M:%S')
|
|
self.created_at = ("between", (start_datetime, end_datetime)) |