chore: 批量优化项目代码,修复多处细节问题

本次提交包含多项优化和修复:
1. 修复CRUD初始化参数传递、搜索参数处理逻辑
2. 更新环境配置中的大模型相关参数
3. 重构部分服务方法命名,统一代码风格
4. 新增多个枚举类型,补充模型关联关系和加载选项
5. 优化查询参数类实现,完善字段校验逻辑
6. 调整Pydantic模型字段注释和类型定义
7. 简化并移除冗余的CRUD方法实现
8. 新增超级管理员权限装饰器
9. 修复邮件日志模型的租户关联和字段定义
This commit is contained in:
zhangtao
2026-06-20 23:37:58 +08:00
parent bbe77930a8
commit 4e2b668d7b
96 changed files with 2914 additions and 1936 deletions
@@ -88,7 +88,7 @@ class GenTableCRUD(CRUDBase[GenTableModel, GenTableSchema, GenTableSchema]):
- Sequence[GenTableModel]: 业务表列表信息。
"""
return await self.list(
search=search.__dict__,
search=vars(search) if search else None,
order_by=[{"created_time": "desc"}],
preload=preload,
)
@@ -1,4 +1,4 @@
from sqlalchemy import Boolean, ForeignKey, Integer, String
from sqlalchemy import Boolean, ForeignKey, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column, relationship, validates
from sqlalchemy.sql import expression
@@ -14,7 +14,7 @@ class GenTableModel(ModelMixin, TenantMixin, UserMixin):
__tablename__: str = "gen_table"
__table_args__: dict[str, str] = {"comment": "代码生成表"}
__loader_options__: list[str] = ["columns", "created_by", "updated_by", "deleted_by"]
__loader_options__: list[str] = ["columns", "created_by", "updated_by", "deleted_by", "tenant_by"]
table_name: Mapped[str] = mapped_column(String(200), nullable=False, default="", comment="表名称")
table_comment: Mapped[str | None] = mapped_column(String(500), nullable=True, comment="表描述")
@@ -50,7 +50,7 @@ class GenTableColumnModel(ModelMixin, TenantMixin, UserMixin):
__tablename__: str = "gen_table_column"
__table_args__: dict[str, str] = {"comment": "代码生成表字段"}
__loader_options__: list[str] = ["created_by", "updated_by", "deleted_by"]
__loader_options__: list[str] = ["created_by", "updated_by", "deleted_by", "tenant_by"]
column_name: Mapped[str] = mapped_column(String(200), nullable=False, comment="列名称")
column_comment: Mapped[str | None] = mapped_column(String(500), nullable=True, comment="列描述")
@@ -5,7 +5,8 @@ from fastapi import Query
from pydantic import BaseModel, ConfigDict, Field, field_validator
from app.common.enums import QueueEnum
from app.core.base_schema import BaseSchema
from app.core.base_params import BaseQueryParam, TenantByQueryParam, UserByQueryParam
from app.core.base_schema import BaseSchema, TenantBySchema, UserBySchema
class GenDBTableSchema(BaseModel):
@@ -254,7 +255,7 @@ class GenTableSchema(BaseModel):
return s if s else None
class GenTableOutSchema(GenTableSchema, BaseSchema):
class GenTableOutSchema(GenTableSchema, BaseSchema, UserBySchema, TenantBySchema):
"""业务表输出模型(面向控制器/前端)。"""
model_config = ConfigDict(from_attributes=True)
@@ -300,7 +301,7 @@ class GenSyncPreviewSchema(BaseModel):
@dataclass
class GenTableQueryParam:
class GenTableQueryParam(BaseQueryParam, UserByQueryParam, TenantByQueryParam):
"""代码生成业务表查询参数
- 支持按`table_name`、`table_comment`进行模糊检索(由CRUD层实现like)。
- 空值将被忽略,不参与过滤。
@@ -310,20 +311,10 @@ class GenTableQueryParam:
self,
table_name: str | None = Query(None, description="表名称"),
table_comment: str | None = Query(None, description="表注释"),
*args,
**kwargs,
) -> None:
super().__init__(*args, **kwargs)
# 模糊查询字段
self.table_name = (QueueEnum.like.value, table_name)
self.table_comment = (QueueEnum.like.value, table_comment)
class GenTableColumnQueryParam:
"""代码生成业务表字段查询参数
- `column_name`按like规则模糊查询(透传到CRUD层)
"""
def __init__(
self,
column_name: str | None = Query(None, description="列名称"),
) -> None:
# 模糊查询字段:约定("like", 值)格式,便于CRUD解析
self.column_name = (QueueEnum.like.value, column_name)
self.table_name = (QueueEnum.like.value, table_name) if table_name else None
self.table_comment = (QueueEnum.like.value, table_comment) if table_comment else None
@@ -284,7 +284,7 @@ class GenTableService:
offset=offset,
limit=page_size,
order_by=order,
search=search.__dict__,
search=vars(search) if search else None,
out_schema=GenTableOutSchema,
)