refactor(tenant): 移除租户工具模块并优化相关代码

重构租户模块,删除不再使用的工具类文件,包括查询、写入、缓存键等功能
优化模型字段格式和CRUD方法顺序,调整前端暗黑模式颜色变量
简化租户服务逻辑,移除平台租户管理校验,改进初始管理员创建流程
This commit is contained in:
zhangtao
2026-04-08 00:06:20 +08:00
parent 9f3846adca
commit 329dd791d2
16 changed files with 35 additions and 398 deletions
@@ -792,7 +792,6 @@ class GenTableService:
order=9999,
permission=f"{permission_prefix}:query",
icon="menu",
# route_name 使用模块名(对齐 module_example/demo/example/demo
route_name=CamelCaseUtil.snake_to_camel(_mn),
route_path=_route_path,
component_path=_component_path,
@@ -918,6 +917,9 @@ class GenTableService:
await _write_templates(render_info[0], render_info[2], gen_table_schema)
if gen_table_schema.sub and gen_table_schema.sub_table:
# 子表与主表同分系统,使用自己的模块名,实现同级目录
gen_table_schema.sub_table.package_name = gen_table_schema.package_name
# 确保子表使用自己的模块名,与主表同级目录
sub_ctx = Jinja2TemplateUtil.prepare_sub_render_context(
gen_table_schema, gen_table_schema.sub_table
)
@@ -1072,7 +1074,7 @@ class GenTableService:
column.id
])
# 主子表:若子表也已导入生成器,则一并同步子表配置(更接近 RuoYi 体验)
# 主子表:若子表也已导入生成器,则一并同步子表配置
sn = (table.sub_table_name or "").strip()
fk = (table.sub_table_fk_name or "").strip()
if _sync_sub and sn and fk:
@@ -1140,7 +1142,7 @@ class GenTableService:
gen_table.sub = True
gen_table.sub_table = sub_cfg
gen_table.master_sub_hint = (
"主子表已启用:子表字段来自「已导入的子表配置」(更接近 RuoYi 的方式)。"
"主子表已启用:子表字段来自「已导入的子表配置」(更可控、可复用)。"
"如需调整子表字段,请在列表中打开该子表进行配置。"
)
return
@@ -1203,7 +1205,7 @@ class GenTableService:
gen_table.sub_table = sub
gen_table.master_sub_hint = (
"主子表已启用:当前子表仅从数据库结构读取(只读)。"
f"要像 RuoYi 那样可配置子表字段,请先在「导入」中把子表「{sub_name_raw}」也导入生成器。"
f"可配置子表字段,请先在「导入」中把子表「{sub_name_raw}」也导入生成器。"
)
@classmethod
@@ -32,7 +32,7 @@ class {{ class_name }}Model(ModelMixin, UserMixin):
{% if column.column_name not in ['id', 'uuid', 'status', 'description', 'created_time', 'updated_time', 'created_id', 'updated_id'] %}
{% set sqlalchemy_type = column|get_sqlalchemy_type %}
{% if column.column_name == sub_table_fk_name %}
{{ column.column_name }}: Mapped[{{ column.python_type }} | None] = mapped_column(ForeignKey('{{ parent_table_name }}.{{ parent_pk_column_name }}', ondelete='CASCADE'), {{ sqlalchemy_type }}, {% if column.is_pk %}primary_key=True, {% endif %}{% if column.is_increment %}autoincrement=True, {% endif %}{% if (not column.is_nullable) or column.is_pk %}nullable=False{% else %}nullable=True{% endif %}, comment='{{ column.column_comment }}')
{{ column.column_name }}: Mapped[{{ column.python_type }} | None] = mapped_column({{ sqlalchemy_type }}, ForeignKey('{{ parent_table_name }}.{{ parent_pk_column_name }}', ondelete='CASCADE'), {% if column.is_pk %}primary_key=True, {% endif %}{% if column.is_increment %}autoincrement=True, {% endif %}{% if (not column.is_nullable) or column.is_pk %}nullable=False{% else %}nullable=True{% endif %}, comment='{{ column.column_comment }}')
{% else %}
{{ column.column_name }}: Mapped[{{ column.python_type }} | None] = mapped_column({{ sqlalchemy_type }}, {% if column.is_pk %}primary_key=True, {% endif %}{% if column.is_increment %}autoincrement=True, {% endif %}{% if (not column.is_nullable) or column.is_pk %}nullable=False{% else %}nullable=True{% endif %}, comment='{{ column.column_comment }}')
{% endif %}