mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-22 13:05:18 +00:00
refactor(backend): 重构数据库模型和初始化逻辑 fix(frontend): 修复权限指令在多个组件中的使用问题 perf(backend): 优化数据库连接和初始化性能 docs: 更新低代码生成器的README文档 style: 清理无用代码和注释 chore: 移除不再需要的依赖项 test: 更新用户权限相关测试用例 ci: 更新CI配置以支持新的权限检查 build: 更新依赖项版本
39 lines
1.4 KiB
Django/Jinja
39 lines
1.4 KiB
Django/Jinja
# -*- coding: utf-8 -*-
|
|
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
from fastapi import Query
|
|
|
|
from app.core.validator import DateTimeStr
|
|
|
|
class {{ tableName|snake_to_pascal_case }}QueryParam:
|
|
"""{{ functionName }}查询参数"""
|
|
|
|
def __init__(
|
|
self,
|
|
{% for column in columns %}
|
|
{% if column.queryType == 'LIKE' %}
|
|
{{ column.columnName }}: Optional[{{ column.pythonType }}] = Query(None, description="{{ column.columnComment }}"),
|
|
{% endif %}
|
|
{% endfor %}
|
|
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"),
|
|
creator: Optional[int] = Query(None, description="创建人"),
|
|
) -> None:
|
|
super().__init__()
|
|
|
|
# 模糊查询字段
|
|
{% for column in columns %}
|
|
{% if column.queryType == 'LIKE' %}
|
|
self.{{ column.columnName }} = ("like", {{ column.columnName }})
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
# 精确查询字段
|
|
self.creator_id = creator
|
|
|
|
# 时间范围查询
|
|
if start_time and end_time:
|
|
start_datetime = datetime.strptime(start_time, '%Y-%m-%d %H:%M:%S')
|
|
end_datetime = datetime.strptime(end_time, '%Y-%m-%d %H:%M:%S')
|
|
self.created_at = ("between", (start_datetime, end_datetime)) |