Files
RuoYi-Vue3-FastAPI/ruoyi-fastapi-backend/module_generator/templates/python/do.py.jinja2
2025-02-17 17:43:29 +08:00

42 lines
1.4 KiB
Django/Jinja

{% for do_import in doImportList %}
{{ do_import }}
{% endfor %}
{% if table.sub %}
from sqlalchemy.orm import relationship
{% endif %}
from config.database import Base
class {{ ClassName }}(Base):
"""
{{ functionName }}
"""
__tablename__ = '{{ tableName }}'
{% for column in columns %}
{{ column.column_name }} = Column({{ column.column_type | get_sqlalchemy_type }}, {% if column.pk %}primary_key=True, {% endif %}{% if column.increment %}autoincrement=True, {% endif %}{% if column.required %}nullable=True{% else %}nullable=False{% endif %}, comment='{{ column.column_comment }}')
{% endfor %}
{% if table.sub %}
{{ subclassName }}_list = relationship('{{ subClassName }}', back_populates='{{ businessName }}')
{% endif %}
{% if table.sub %}
class {{ subClassName }}(Base):
"""
{{ subTable.function_name }}
"""
__tablename__ = '{{ subTableName }}'
{% for column in subTable.columns %}
{{ column.column_name }} = Column({{ column.column_type | get_sqlalchemy_type }}, {% if column.pk %}primary_key=True, {% endif %}{% if column.increment %}autoincrement=True, {% endif %}{% if column.required %}nullable=True{% else %}nullable=False{% endif %}, comment='{{ column.column_comment }}')
{% endfor %}
{% if table.sub %}
{{ businessName }} = relationship('{{ ClassName }}', back_populates='{{ subclassName }}_list')
{% endif %}
{% endif %}