Files
FastapiAdmin/backend/templates/python/model.py.j2
T
zhangtao 086bce3972 feat(tenant): 添加租户编码字段及相关功能
- 在后端模型、schema和前端接口中添加code字段
- 在前端表格和表单中显示和编辑code字段
- 修改租户名称长度限制从50到64字符
- 添加编码字段的验证逻辑
- 更新WangEditor组件返回纯文本格式
2025-11-13 23:47:52 +08:00

33 lines
1.2 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 typing import Optional
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 %}