mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 04:46:26 +00:00
- 将前端API路径从`system`和`monitor`重命名为`module_system`和`module_monitor` - 移除MongoDB相关配置和依赖 - 统一数据库类型命名为`mysql`和`postgres` - 修复代码生成模板中的字段命名问题 - 更新依赖项并移除不必要的包 - 优化数据库连接配置 - 添加新的文档和Redoc视图组件 - 修复SQL脚本中的字段注释
32 lines
1.1 KiB
Django/Jinja
32 lines
1.1 KiB
Django/Jinja
# -*- coding: utf-8 -*-
|
|
|
|
{% for model_import in model_import_list %}
|
|
{{ model_import }}
|
|
{% endfor %}
|
|
{% if table.sub %}
|
|
from sqlalchemy.orm import relationship
|
|
{% endif %}
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.core.base_model import CreatorMixin
|
|
|
|
|
|
class {{ class_name }}Model(CreatorMixin):
|
|
"""
|
|
{{ function_name }}表
|
|
"""
|
|
|
|
__tablename__ = '{{ table_name }}'
|
|
__table_args__ = {'comment': '{{ function_name }}'}
|
|
__loader_options__ = ["creator"]
|
|
|
|
{% for column in columns %}
|
|
{% if column.column_name not in ['id', 'creator_id', 'description', 'created_at', 'updated_at'] %}
|
|
{{ column.column_name }}: Mapped[Optional[{{ column.python_type }}]] = mapped_column({{ column.column_type|get_sqlalchemy_type }}, {% if column.pk %}primary_key=True, {% endif %}{% if column.increment %}autoincrement=True, {% endif %}{% if column.required or column.pk %}nullable=False{% else %}nullable=True{% endif %}, comment='{{ column.column_comment }}')
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% if table.sub %}
|
|
{{ sub_class_name }}_list = relationship('{{ sub_class_name }}', back_populates='{{ business_name }}')
|
|
{% endif %}
|