Files
FastapiAdmin/backend/app/api/v1/module_system/dict/model.py
T
zhangtao 700d76ad5a feat(model): 添加status字段表示启用状态
- 在myapp模块的ApplicationModel中新增status字段,标识应用是否启用
- 在demo模块的DemoModel中新增status字段,标识示例条目是否启用
- 修改代码生成模块相关模型,替换BaseMixin为CreatorMixin
- 删除代码生成模块中Python模板相关文件与Vue前端代码模板,优化代码结构和清理无用模板文件
2025-09-17 01:33:53 +08:00

45 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
from typing import Optional, List
from sqlalchemy import Boolean, String, Integer, ForeignKey
from sqlalchemy.orm import relationship, Mapped, mapped_column
from app.core.base_model import CreatorMixin
class DictTypeModel(CreatorMixin):
"""
字典类型表
"""
__tablename__ = "system_dict_type"
__table_args__ = ({'comment': '字典类型表'})
dict_name: Mapped[str] = mapped_column(String(100), nullable=False, unique=True, comment='字典名称')
dict_type: Mapped[str] = mapped_column(String(100), nullable=False, unique=True, comment='字典类型')
status: Mapped[bool] = mapped_column(Boolean(), default=True, nullable=False, comment="是否启用(True:启用 False:禁用)")
dict_datas: Mapped[List["DictDataModel"]] = relationship(back_populates="dict_type_rel", lazy="selectin")
class DictDataModel(CreatorMixin):
"""
字典数据表
"""
__tablename__ = 'system_dict_data'
__table_args__ = ({'comment': '字典数据表'})
dict_sort: Mapped[int] = mapped_column(Integer, nullable=False, default=0, comment='字典排序')
dict_label: Mapped[str] = mapped_column(String(100), nullable=False, comment='字典标签')
dict_value: Mapped[str] = mapped_column(String(100), nullable=False, comment='字典键值')
dict_type: Mapped[str] = mapped_column(String(100), nullable=False, comment='字典类型')
status: Mapped[bool] = mapped_column(Boolean(), default=True, nullable=False, comment="是否启用(True:启用 False:禁用)")
css_class: Mapped[Optional[str]] = mapped_column(String(100), nullable=True, comment='样式属性(其他样式扩展)')
list_class: Mapped[Optional[str]] = mapped_column(String(100), nullable=True, comment='表格回显样式')
is_default: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, comment='是否默认(True是 False否)')
dict_type_id: Mapped[Optional[int]] = mapped_column(ForeignKey('system_dict_type.id'), nullable=True, comment='字典类型ID')
# 字典类型关联关系
dict_type_rel: Mapped[Optional["DictTypeModel"]] = relationship(back_populates="dict_datas", lazy="selectin")