Files
FastapiAdmin/backend/app/api/v1/module_example/demo/model.py
T
zhangtao 1ee6400ac7 feat: 重构代码生成模块并添加示例模块
refactor(menu): 优化菜单删除逻辑,自动删除子菜单
refactor(dept): 优化部门删除逻辑,自动删除子部门
feat(redis): 添加分布式锁功能
feat(validator): 新增DateStr和TimeStr验证类型
refactor(logger): 简化日志配置,移除开发环境同步策略
refactor(console): 重命名并简化控制台输出函数
feat(example): 添加示例模块,包含完整数据类型示例
refactor(gencode): 重构代码生成工具,移除SQL生成
feat(ai): 添加MCP客户端和服务端实现
chore: 更新依赖版本
style: 清理无用代码和文件
2026-01-03 04:28:18 +08:00

36 lines
1.5 KiB
Python

# -*- coding: utf-8 -*-
import enum
from sqlalchemy import JSON, String, Integer, BIGINT, Float, Boolean, Date, Time, DateTime, Enum, Text
from sqlalchemy.orm import Mapped, mapped_column
from datetime import date, time, datetime
from app.core.base_model import ModelMixin, UserMixin
class StatusEnum(enum.Enum):
"""状态枚举"""
ACTIVE = "active"
INACTIVE = "inactive"
class DemoModel(ModelMixin, UserMixin):
"""
示例表 - 涵盖大多数常用数据类型
"""
__tablename__: str = 'gen_demo'
__table_args__: dict[str, str] = ({'comment': '示例表'})
__loader_options__: list[str] = ["created_by", "updated_by"]
# 字符串类型
name: Mapped[str] = mapped_column(String(64), nullable=False, comment='名称')
a: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='整数')
b: Mapped[int | None] = mapped_column(BIGINT, nullable=True, comment='大整数')
c: Mapped[float | None] = mapped_column(Float, nullable=True, comment='浮点数')
d: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False, comment='布尔型')
e: Mapped[date | None] = mapped_column(Date, nullable=True, comment='日期')
f: Mapped[time | None] = mapped_column(Time, nullable=True, comment='时间')
g: Mapped[datetime | None] = mapped_column(DateTime, nullable=True, comment='日期时间')
h: Mapped[str | None] = mapped_column(Text, nullable=True, comment='长文本')
i: Mapped[dict | None] = mapped_column(JSON, nullable=True, comment='元数据(JSON格式)')