Files
fastapi-best-architecture/backend/app/admin/model/sys_dict_data.py
T
Wu Clan f9ec9d5d56 Add code generator app (#318)
* Add code generator app

* Define the generator interfaces

* Update the name of the template files

* update lock hash

* update route and schemas

* update gen code structure

* add some gen codes

* upgrade SQLAlchemy to release

* update template util

* Fix lint error

* Add template rendering code

* Add gen model code

* Fix gen model table

* Update business model column naming

* Update any route

* Fix api ninja args

* Update gen business model

* Fix interface services logic

* Fix template render

* Add more code template

* Add model auto gen template

* Fix model type map style

* Update schema and model templates

* Update gen_model schema

* Fix model template if

* Update have_datetime_column field from gen_model to gen_business table

* Update the name of the zip

* Update model template vars

* Add download generate code

* Add preview code encoding

* Update service code template

* fix lint

* Update github auth tag

* Update requirements

* Add code generation write

* Update generate interface and zip conf

* Optimize templates details

* Update model relation column conf

* Add import tables module

* Add get all databases interface

* Fix get tables interface

* Bump pydantic to 2.8.1

* Upgrading lint dependencies

* Add import business and model implement

* Split import database execution code

* Update text SQL execution to prevent SQL injection

* Optimize schema name generation

* clean code

* Update create tables sql scripts

* Update import sql query conditions

* Add todo comments

* Mark business creation interface

* Update features in README
2024-07-10 12:12:29 +08:00

24 lines
1.0 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from sqlalchemy import ForeignKey, String
from sqlalchemy.dialects.mysql import LONGTEXT
from sqlalchemy.orm import Mapped, mapped_column, relationship
from backend.common.model import Base, id_key
class DictData(Base):
"""字典数据"""
__tablename__ = 'sys_dict_data'
id: Mapped[id_key] = mapped_column(init=False)
label: Mapped[str] = mapped_column(String(32), unique=True, comment='字典标签')
value: Mapped[str] = mapped_column(String(32), unique=True, comment='字典值')
sort: Mapped[int] = mapped_column(default=0, comment='排序')
status: Mapped[int] = mapped_column(default=1, comment='状态(0停用 1正常)')
remark: Mapped[str | None] = mapped_column(LONGTEXT, default=None, comment='备注')
# 字典类型一对多
type_id: Mapped[int] = mapped_column(ForeignKey('sys_dict_type.id'), default=0, comment='字典类型关联ID')
type: Mapped['DictType'] = relationship(init=False, back_populates='datas') # noqa: F821