mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2026-03-13 09:31:31 +08:00
Update the length style of the model columns (#883)
* Update the length style of the model columns * Fix opera log table username column length * Fix login log table username column length
This commit is contained in:
@@ -19,14 +19,14 @@ class DataRule(Base):
|
||||
__tablename__ = 'sys_data_rule'
|
||||
|
||||
id: Mapped[id_key] = mapped_column(init=False)
|
||||
name: Mapped[str] = mapped_column(sa.String(500), unique=True, comment='名称')
|
||||
model: Mapped[str] = mapped_column(sa.String(50), comment='SQLA 模型名,对应 DATA_PERMISSION_MODELS 键名')
|
||||
column: Mapped[str] = mapped_column(sa.String(20), comment='模型字段名')
|
||||
name: Mapped[str] = mapped_column(sa.String(512), unique=True, comment='名称')
|
||||
model: Mapped[str] = mapped_column(sa.String(64), comment='SQLA 模型名,对应 DATA_PERMISSION_MODELS 键名')
|
||||
column: Mapped[str] = mapped_column(sa.String(32), comment='模型字段名')
|
||||
operator: Mapped[int] = mapped_column(comment='运算符(0:and、1:or)')
|
||||
expression: Mapped[int] = mapped_column(
|
||||
comment='表达式(0:==、1:!=、2:>、3:>=、4:<、5:<=、6:in、7:not_in)',
|
||||
)
|
||||
value: Mapped[str] = mapped_column(sa.String(255), comment='规则值')
|
||||
value: Mapped[str] = mapped_column(sa.String(256), comment='规则值')
|
||||
|
||||
# 数据范围规则多对多
|
||||
scopes: Mapped[list[DataScope]] = relationship(init=False, secondary=sys_data_scope_rule, back_populates='rules')
|
||||
|
||||
@@ -19,7 +19,7 @@ class DataScope(Base):
|
||||
__tablename__ = 'sys_data_scope'
|
||||
|
||||
id: Mapped[id_key] = mapped_column(init=False)
|
||||
name: Mapped[str] = mapped_column(sa.String(50), unique=True, comment='名称')
|
||||
name: Mapped[str] = mapped_column(sa.String(64), unique=True, comment='名称')
|
||||
status: Mapped[int] = mapped_column(default=1, comment='状态(0停用 1正常)')
|
||||
|
||||
# 数据范围规则多对多
|
||||
|
||||
@@ -18,11 +18,11 @@ class Dept(Base):
|
||||
__tablename__ = 'sys_dept'
|
||||
|
||||
id: Mapped[id_key] = mapped_column(init=False)
|
||||
name: Mapped[str] = mapped_column(sa.String(50), comment='部门名称')
|
||||
name: Mapped[str] = mapped_column(sa.String(64), comment='部门名称')
|
||||
sort: Mapped[int] = mapped_column(default=0, comment='排序')
|
||||
leader: Mapped[str | None] = mapped_column(sa.String(20), default=None, comment='负责人')
|
||||
leader: Mapped[str | None] = mapped_column(sa.String(32), default=None, comment='负责人')
|
||||
phone: Mapped[str | None] = mapped_column(sa.String(11), default=None, comment='手机')
|
||||
email: Mapped[str | None] = mapped_column(sa.String(50), default=None, comment='邮箱')
|
||||
email: Mapped[str | None] = mapped_column(sa.String(64), default=None, comment='邮箱')
|
||||
status: Mapped[int] = mapped_column(default=1, comment='部门状态(0停用 1正常)')
|
||||
del_flag: Mapped[bool] = mapped_column(default=False, comment='删除标志(0删除 1存在)')
|
||||
|
||||
|
||||
@@ -14,17 +14,17 @@ class LoginLog(DataClassBase):
|
||||
__tablename__ = 'sys_login_log'
|
||||
|
||||
id: Mapped[id_key] = mapped_column(init=False)
|
||||
user_uuid: Mapped[str] = mapped_column(sa.String(50), comment='用户UUID')
|
||||
username: Mapped[str] = mapped_column(sa.String(20), comment='用户名')
|
||||
user_uuid: Mapped[str] = mapped_column(sa.String(64), comment='用户UUID')
|
||||
username: Mapped[str] = mapped_column(sa.String(64), comment='用户名')
|
||||
status: Mapped[int] = mapped_column(insert_default=0, comment='登录状态(0失败 1成功)')
|
||||
ip: Mapped[str] = mapped_column(sa.String(50), comment='登录IP地址')
|
||||
country: Mapped[str | None] = mapped_column(sa.String(50), comment='国家')
|
||||
region: Mapped[str | None] = mapped_column(sa.String(50), comment='地区')
|
||||
city: Mapped[str | None] = mapped_column(sa.String(50), comment='城市')
|
||||
user_agent: Mapped[str] = mapped_column(sa.String(255), comment='请求头')
|
||||
os: Mapped[str | None] = mapped_column(sa.String(50), comment='操作系统')
|
||||
browser: Mapped[str | None] = mapped_column(sa.String(50), comment='浏览器')
|
||||
device: Mapped[str | None] = mapped_column(sa.String(50), comment='设备')
|
||||
ip: Mapped[str] = mapped_column(sa.String(64), comment='登录IP地址')
|
||||
country: Mapped[str | None] = mapped_column(sa.String(64), comment='国家')
|
||||
region: Mapped[str | None] = mapped_column(sa.String(64), comment='地区')
|
||||
city: Mapped[str | None] = mapped_column(sa.String(64), comment='城市')
|
||||
user_agent: Mapped[str] = mapped_column(sa.String(256), comment='请求头')
|
||||
os: Mapped[str | None] = mapped_column(sa.String(64), comment='操作系统')
|
||||
browser: Mapped[str | None] = mapped_column(sa.String(64), comment='浏览器')
|
||||
device: Mapped[str | None] = mapped_column(sa.String(64), comment='设备')
|
||||
msg: Mapped[str] = mapped_column(UniversalText, comment='提示消息')
|
||||
login_time: Mapped[datetime] = mapped_column(TimeZone, comment='登录时间')
|
||||
created_time: Mapped[datetime] = mapped_column(
|
||||
|
||||
@@ -19,14 +19,14 @@ class Menu(Base):
|
||||
__tablename__ = 'sys_menu'
|
||||
|
||||
id: Mapped[id_key] = mapped_column(init=False)
|
||||
title: Mapped[str] = mapped_column(sa.String(50), comment='菜单标题')
|
||||
name: Mapped[str] = mapped_column(sa.String(50), comment='菜单名称')
|
||||
title: Mapped[str] = mapped_column(sa.String(64), comment='菜单标题')
|
||||
name: Mapped[str] = mapped_column(sa.String(64), comment='菜单名称')
|
||||
path: Mapped[str | None] = mapped_column(sa.String(200), comment='路由地址')
|
||||
sort: Mapped[int] = mapped_column(default=0, comment='排序')
|
||||
icon: Mapped[str | None] = mapped_column(sa.String(100), default=None, comment='菜单图标')
|
||||
icon: Mapped[str | None] = mapped_column(sa.String(128), default=None, comment='菜单图标')
|
||||
type: Mapped[int] = mapped_column(default=0, comment='菜单类型(0目录 1菜单 2按钮 3内嵌 4外链)')
|
||||
component: Mapped[str | None] = mapped_column(sa.String(255), default=None, comment='组件路径')
|
||||
perms: Mapped[str | None] = mapped_column(sa.String(100), default=None, comment='权限标识')
|
||||
component: Mapped[str | None] = mapped_column(sa.String(256), default=None, comment='组件路径')
|
||||
perms: Mapped[str | None] = mapped_column(sa.String(128), default=None, comment='权限标识')
|
||||
status: Mapped[int] = mapped_column(default=1, comment='菜单状态(0停用 1正常)')
|
||||
display: Mapped[int] = mapped_column(default=1, comment='是否显示(0否 1是)')
|
||||
cache: Mapped[int] = mapped_column(default=1, comment='是否缓存(0否 1是)')
|
||||
|
||||
@@ -15,21 +15,21 @@ class OperaLog(DataClassBase):
|
||||
|
||||
id: Mapped[id_key] = mapped_column(init=False)
|
||||
trace_id: Mapped[str] = mapped_column(sa.String(32), comment='请求跟踪 ID')
|
||||
username: Mapped[str | None] = mapped_column(sa.String(20), comment='用户名')
|
||||
method: Mapped[str] = mapped_column(sa.String(20), comment='请求类型')
|
||||
title: Mapped[str] = mapped_column(sa.String(255), comment='操作模块')
|
||||
path: Mapped[str] = mapped_column(sa.String(500), comment='请求路径')
|
||||
ip: Mapped[str] = mapped_column(sa.String(50), comment='IP地址')
|
||||
country: Mapped[str | None] = mapped_column(sa.String(50), comment='国家')
|
||||
region: Mapped[str | None] = mapped_column(sa.String(50), comment='地区')
|
||||
city: Mapped[str | None] = mapped_column(sa.String(50), comment='城市')
|
||||
user_agent: Mapped[str] = mapped_column(sa.String(255), comment='请求头')
|
||||
os: Mapped[str | None] = mapped_column(sa.String(50), comment='操作系统')
|
||||
browser: Mapped[str | None] = mapped_column(sa.String(50), comment='浏览器')
|
||||
device: Mapped[str | None] = mapped_column(sa.String(50), comment='设备')
|
||||
username: Mapped[str | None] = mapped_column(sa.String(64), comment='用户名')
|
||||
method: Mapped[str] = mapped_column(sa.String(32), comment='请求类型')
|
||||
title: Mapped[str] = mapped_column(sa.String(256), comment='操作模块')
|
||||
path: Mapped[str] = mapped_column(sa.String(512), comment='请求路径')
|
||||
ip: Mapped[str] = mapped_column(sa.String(64), comment='IP地址')
|
||||
country: Mapped[str | None] = mapped_column(sa.String(64), comment='国家')
|
||||
region: Mapped[str | None] = mapped_column(sa.String(64), comment='地区')
|
||||
city: Mapped[str | None] = mapped_column(sa.String(64), comment='城市')
|
||||
user_agent: Mapped[str] = mapped_column(sa.String(512), comment='请求头')
|
||||
os: Mapped[str | None] = mapped_column(sa.String(64), comment='操作系统')
|
||||
browser: Mapped[str | None] = mapped_column(sa.String(64), comment='浏览器')
|
||||
device: Mapped[str | None] = mapped_column(sa.String(64), comment='设备')
|
||||
args: Mapped[str | None] = mapped_column(sa.JSON(), comment='请求参数')
|
||||
status: Mapped[int] = mapped_column(comment='操作状态(0异常 1正常)')
|
||||
code: Mapped[str] = mapped_column(sa.String(20), insert_default='200', comment='操作状态码')
|
||||
code: Mapped[str] = mapped_column(sa.String(32), insert_default='200', comment='操作状态码')
|
||||
msg: Mapped[str | None] = mapped_column(UniversalText, comment='提示消息')
|
||||
cost_time: Mapped[float] = mapped_column(insert_default=0.0, comment='请求耗时(ms)')
|
||||
opera_time: Mapped[datetime] = mapped_column(TimeZone, comment='操作时间')
|
||||
|
||||
@@ -19,7 +19,7 @@ class Role(Base):
|
||||
__tablename__ = 'sys_role'
|
||||
|
||||
id: Mapped[id_key] = mapped_column(init=False)
|
||||
name: Mapped[str] = mapped_column(sa.String(20), unique=True, comment='角色名称')
|
||||
name: Mapped[str] = mapped_column(sa.String(32), unique=True, comment='角色名称')
|
||||
status: Mapped[int] = mapped_column(default=1, comment='角色状态(0停用 1正常)')
|
||||
is_filter_scopes: Mapped[bool] = mapped_column(default=True, comment='过滤数据权限(0否 1是)')
|
||||
remark: Mapped[str | None] = mapped_column(UniversalText, default=None, comment='备注')
|
||||
|
||||
@@ -22,14 +22,14 @@ class User(Base):
|
||||
__tablename__ = 'sys_user'
|
||||
|
||||
id: Mapped[id_key] = mapped_column(init=False)
|
||||
uuid: Mapped[str] = mapped_column(sa.String(50), init=False, default_factory=uuid4_str, unique=True)
|
||||
username: Mapped[str] = mapped_column(sa.String(20), unique=True, index=True, comment='用户名')
|
||||
nickname: Mapped[str] = mapped_column(sa.String(20), comment='昵称')
|
||||
password: Mapped[str | None] = mapped_column(sa.String(255), comment='密码')
|
||||
uuid: Mapped[str] = mapped_column(sa.String(64), init=False, default_factory=uuid4_str, unique=True)
|
||||
username: Mapped[str] = mapped_column(sa.String(64), unique=True, index=True, comment='用户名')
|
||||
nickname: Mapped[str] = mapped_column(sa.String(64), comment='昵称')
|
||||
password: Mapped[str | None] = mapped_column(sa.String(256), comment='密码')
|
||||
salt: Mapped[bytes | None] = mapped_column(sa.LargeBinary(255), comment='加密盐')
|
||||
email: Mapped[str | None] = mapped_column(sa.String(255), default=None, unique=True, index=True, comment='邮箱')
|
||||
email: Mapped[str | None] = mapped_column(sa.String(256), default=None, unique=True, index=True, comment='邮箱')
|
||||
phone: Mapped[str | None] = mapped_column(sa.String(11), default=None, comment='手机号')
|
||||
avatar: Mapped[str | None] = mapped_column(sa.String(255), default=None, comment='头像')
|
||||
avatar: Mapped[str | None] = mapped_column(sa.String(256), default=None, comment='头像')
|
||||
status: Mapped[int] = mapped_column(default=1, index=True, comment='用户账号状态(0停用 1正常)')
|
||||
is_superuser: Mapped[bool] = mapped_column(default=False, comment='超级权限(0否 1是)')
|
||||
is_staff: Mapped[bool] = mapped_column(default=False, comment='后台管理登陆(0否 1是)')
|
||||
|
||||
@@ -20,7 +20,7 @@ class Task(MappedBase):
|
||||
|
||||
id = sa.Column(sa.Integer, sa.Sequence('task_id_sequence'), primary_key=True, autoincrement=True)
|
||||
task_id = sa.Column(sa.String(155), unique=True)
|
||||
status = sa.Column(sa.String(50), default=states.PENDING)
|
||||
status = sa.Column(sa.String(64), default=states.PENDING)
|
||||
result = sa.Column(PickleType, nullable=True)
|
||||
date_done = sa.Column(
|
||||
sa.DateTime,
|
||||
|
||||
@@ -20,20 +20,20 @@ class TaskScheduler(Base):
|
||||
__tablename__ = 'task_scheduler'
|
||||
|
||||
id: Mapped[id_key] = mapped_column(init=False)
|
||||
name: Mapped[str] = mapped_column(sa.String(50), unique=True, comment='任务名称')
|
||||
task: Mapped[str] = mapped_column(sa.String(255), comment='要运行的 Celery 任务')
|
||||
name: Mapped[str] = mapped_column(sa.String(64), unique=True, comment='任务名称')
|
||||
task: Mapped[str] = mapped_column(sa.String(256), comment='要运行的 Celery 任务')
|
||||
args: Mapped[str | None] = mapped_column(sa.JSON(), comment='任务可接收的位置参数')
|
||||
kwargs: Mapped[str | None] = mapped_column(sa.JSON(), comment='任务可接收的关键字参数')
|
||||
queue: Mapped[str | None] = mapped_column(sa.String(255), comment='CELERY_TASK_QUEUES 中定义的队列')
|
||||
exchange: Mapped[str | None] = mapped_column(sa.String(255), comment='低级别 AMQP 路由的交换机')
|
||||
routing_key: Mapped[str | None] = mapped_column(sa.String(255), comment='低级别 AMQP 路由的路由密钥')
|
||||
queue: Mapped[str | None] = mapped_column(sa.String(256), comment='CELERY_TASK_QUEUES 中定义的队列')
|
||||
exchange: Mapped[str | None] = mapped_column(sa.String(256), comment='低级别 AMQP 路由的交换机')
|
||||
routing_key: Mapped[str | None] = mapped_column(sa.String(256), comment='低级别 AMQP 路由的路由密钥')
|
||||
start_time: Mapped[datetime | None] = mapped_column(TimeZone, comment='任务开始触发的时间')
|
||||
expire_time: Mapped[datetime | None] = mapped_column(TimeZone, comment='任务不再触发的截止时间')
|
||||
expire_seconds: Mapped[int | None] = mapped_column(comment='任务不再触发的秒数时间差')
|
||||
type: Mapped[int] = mapped_column(comment='调度类型(0间隔 1定时)')
|
||||
interval_every: Mapped[int | None] = mapped_column(comment='任务再次运行前的间隔周期数')
|
||||
interval_period: Mapped[str | None] = mapped_column(sa.String(255), comment='任务运行之间的周期类型')
|
||||
crontab: Mapped[str | None] = mapped_column(sa.String(50), default='* * * * *', comment='任务运行的 Crontab 计划')
|
||||
interval_period: Mapped[str | None] = mapped_column(sa.String(256), comment='任务运行之间的周期类型')
|
||||
crontab: Mapped[str | None] = mapped_column(sa.String(64), default='* * * * *', comment='任务运行的 Crontab 计划')
|
||||
one_off: Mapped[bool] = mapped_column(default=False, comment='是否仅运行一次')
|
||||
enabled: Mapped[bool] = mapped_column(default=True, comment='是否启用任务')
|
||||
total_run_count: Mapped[int] = mapped_column(default=0, comment='任务触发的总次数')
|
||||
|
||||
@@ -18,20 +18,20 @@ class GenBusiness(Base):
|
||||
__tablename__ = 'gen_business'
|
||||
|
||||
id: Mapped[id_key] = mapped_column(init=False)
|
||||
app_name: Mapped[str] = mapped_column(sa.String(50), comment='应用名称(英文)')
|
||||
table_name: Mapped[str] = mapped_column(sa.String(255), unique=True, comment='表名称(英文)')
|
||||
doc_comment: Mapped[str] = mapped_column(sa.String(255), comment='文档注释(用于函数/参数文档)')
|
||||
table_comment: Mapped[str | None] = mapped_column(sa.String(255), default=None, comment='表描述')
|
||||
app_name: Mapped[str] = mapped_column(sa.String(64), comment='应用名称(英文)')
|
||||
table_name: Mapped[str] = mapped_column(sa.String(256), unique=True, comment='表名称(英文)')
|
||||
doc_comment: Mapped[str] = mapped_column(sa.String(256), comment='文档注释(用于函数/参数文档)')
|
||||
table_comment: Mapped[str | None] = mapped_column(sa.String(256), default=None, comment='表描述')
|
||||
# relate_model_fk: Mapped[int | None] = mapped_column(default=None, comment='关联表外键')
|
||||
class_name: Mapped[str | None] = mapped_column(sa.String(50), default=None, comment='基础类名(默认为英文表名称)')
|
||||
class_name: Mapped[str | None] = mapped_column(sa.String(64), default=None, comment='基础类名(默认为英文表名称)')
|
||||
schema_name: Mapped[str | None] = mapped_column(
|
||||
sa.String(50), default=None, comment='Schema 名称 (默认为英文表名称)'
|
||||
sa.String(64), default=None, comment='Schema 名称 (默认为英文表名称)'
|
||||
)
|
||||
filename: Mapped[str | None] = mapped_column(sa.String(50), default=None, comment='基础文件名(默认为英文表名称)')
|
||||
filename: Mapped[str | None] = mapped_column(sa.String(64), default=None, comment='基础文件名(默认为英文表名称)')
|
||||
default_datetime_column: Mapped[bool] = mapped_column(default=True, comment='是否存在默认时间列')
|
||||
api_version: Mapped[str] = mapped_column(sa.String(20), default='v1', comment='代码生成 api 版本,默认为 v1')
|
||||
api_version: Mapped[str] = mapped_column(sa.String(32), default='v1', comment='代码生成 api 版本,默认为 v1')
|
||||
gen_path: Mapped[str | None] = mapped_column(
|
||||
sa.String(255), default=None, comment='代码生成路径(默认为 app 根路径)'
|
||||
sa.String(256), default=None, comment='代码生成路径(默认为 app 根路径)'
|
||||
)
|
||||
remark: Mapped[str | None] = mapped_column(UniversalText, default=None, comment='备注')
|
||||
# 代码生成业务模型列一对多
|
||||
|
||||
@@ -18,10 +18,10 @@ class GenColumn(DataClassBase):
|
||||
__tablename__ = 'gen_column'
|
||||
|
||||
id: Mapped[id_key] = mapped_column(init=False)
|
||||
name: Mapped[str] = mapped_column(sa.String(50), comment='列名称')
|
||||
comment: Mapped[str | None] = mapped_column(sa.String(255), default=None, comment='列描述')
|
||||
type: Mapped[str] = mapped_column(sa.String(20), default='String', comment='SQLA 模型列类型')
|
||||
pd_type: Mapped[str] = mapped_column(sa.String(20), default='str', comment='列类型对应的 pydantic 类型')
|
||||
name: Mapped[str] = mapped_column(sa.String(64), comment='列名称')
|
||||
comment: Mapped[str | None] = mapped_column(sa.String(256), default=None, comment='列描述')
|
||||
type: Mapped[str] = mapped_column(sa.String(32), default='String', comment='SQLA 模型列类型')
|
||||
pd_type: Mapped[str] = mapped_column(sa.String(32), default='str', comment='列类型对应的 pydantic 类型')
|
||||
default: Mapped[str | None] = mapped_column(UniversalText, default=None, comment='列默认值')
|
||||
sort: Mapped[int | None] = mapped_column(default=1, comment='列排序')
|
||||
length: Mapped[int] = mapped_column(default=0, comment='列长度')
|
||||
|
||||
@@ -11,9 +11,9 @@ class Config(Base):
|
||||
__tablename__ = 'sys_config'
|
||||
|
||||
id: Mapped[id_key] = mapped_column(init=False)
|
||||
name: Mapped[str] = mapped_column(sa.String(20), comment='名称')
|
||||
type: Mapped[str | None] = mapped_column(sa.String(20), server_default=None, comment='类型')
|
||||
key: Mapped[str] = mapped_column(sa.String(50), unique=True, comment='键名')
|
||||
name: Mapped[str] = mapped_column(sa.String(32), comment='名称')
|
||||
type: Mapped[str | None] = mapped_column(sa.String(32), server_default=None, comment='类型')
|
||||
key: Mapped[str] = mapped_column(sa.String(64), unique=True, comment='键名')
|
||||
value: Mapped[str] = mapped_column(UniversalText, comment='键值')
|
||||
is_frontend: Mapped[bool] = mapped_column(default=False, comment='是否前端')
|
||||
remark: Mapped[str | None] = mapped_column(UniversalText, default=None, comment='备注')
|
||||
|
||||
@@ -11,7 +11,7 @@ class Notice(Base):
|
||||
__tablename__ = 'sys_notice'
|
||||
|
||||
id: Mapped[id_key] = mapped_column(init=False)
|
||||
title: Mapped[str] = mapped_column(sa.String(50), comment='标题')
|
||||
title: Mapped[str] = mapped_column(sa.String(64), comment='标题')
|
||||
type: Mapped[int] = mapped_column(comment='类型(0:通知、1:公告)')
|
||||
status: Mapped[int] = mapped_column(comment='状态(0:隐藏、1:显示)')
|
||||
content: Mapped[str] = mapped_column(UniversalText, comment='内容')
|
||||
|
||||
@@ -18,8 +18,8 @@ class UserSocial(Base):
|
||||
__tablename__ = 'sys_user_social'
|
||||
|
||||
id: Mapped[id_key] = mapped_column(init=False)
|
||||
sid: Mapped[str] = mapped_column(sa.String(255), comment='第三方用户 ID')
|
||||
source: Mapped[str] = mapped_column(sa.String(20), comment='第三方用户来源')
|
||||
sid: Mapped[str] = mapped_column(sa.String(256), comment='第三方用户 ID')
|
||||
source: Mapped[str] = mapped_column(sa.String(32), comment='第三方用户来源')
|
||||
|
||||
# 用户社交信息一对多
|
||||
user_id: Mapped[int] = mapped_column(
|
||||
|
||||
Reference in New Issue
Block a user