refactor: 统一将creator_id重命名为created_id并优化模型关系

feat: 新增系统租户和用户初始化数据

style: 优化代码注释和格式

fix: 修复数据权限检查逻辑中的created_id字段判断

perf: 移除不必要的模型关系以提升性能

docs: 更新初始化数据的描述信息

chore: 清理废弃文件和冗余代码
This commit is contained in:
zhangtao
2025-11-24 01:02:27 +08:00
parent 9a39a64faf
commit c0d32a7eec
59 changed files with 581 additions and 867 deletions
@@ -1,16 +1,10 @@
# -*- coding: utf-8 -*-
from typing import TYPE_CHECKING
from sqlalchemy import String
from sqlalchemy.orm import Mapped, mapped_column, relationship
from sqlalchemy.orm import Mapped, mapped_column
from app.core.base_model import ModelMixin, UserMixin, TenantMixin, CustomerMixin
if TYPE_CHECKING:
from app.api.v1.module_system.user.model import UserModel
from app.api.v1.module_system.tenant.model import TenantModel
from app.api.v1.module_system.customer.model import CustomerModel
class DemoModel(ModelMixin, UserMixin, TenantMixin, CustomerMixin):
"""
@@ -27,21 +21,3 @@ class DemoModel(ModelMixin, UserMixin, TenantMixin, CustomerMixin):
__loader_options__: list[str] = ["created_by", "updated_by", "tenant", "customer"]
name: Mapped[str | None] = mapped_column(String(64), nullable=True, default='', comment='名称')
# 关联关系 (覆盖Mixin中的property)
created_by: Mapped["UserModel | None"] = relationship(
foreign_keys="DemoModel.created_id",
lazy="selectin"
)
updated_by: Mapped["UserModel | None"] = relationship(
foreign_keys="DemoModel.updated_id",
lazy="selectin"
)
tenant: Mapped["TenantModel"] = relationship(
foreign_keys="DemoModel.tenant_id",
lazy="selectin"
)
customer: Mapped["CustomerModel | None"] = relationship(
foreign_keys="DemoModel.customer_id",
lazy="selectin"
)
@@ -22,7 +22,7 @@ class DemoQueryParam:
self.name = ("like", name)
# 精确查询字段
self.creator_id = creator
self.created_id = creator
self.status = status
# 时间范围查询