refactor: P3a 模型层迁入 src/modules/(22 模型)

- 19 个模块目录(system/association/cms/dictionary/configuration/log 等)
- 一对一 16 个 + 合并 3 组(dict+dict_item、config+config_item、login_log+operation_log)
- 重写模型 import:base_db/base_model→src.common、db→src.core.database、
  case_converter/rich_text/request→src.common.utils
- application/models/ 全部替换为 shim(指向 src.modules)
- src/models_registry.py 改为从 src.modules 全量导入

【修复】codemod 两处 bug:shim 与 registry 的 import 路径含斜杠(已改点分);
strip_license 误剥无许可头文件的 docstring 开头(log/models.py 已补回)

【验收】22 表全量识别;应用启动;pytest 5 passed

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
DjangoAdmin Dev
2026-08-07 13:48:30 +08:00
co-authored by Claude
parent 658ee6d596
commit 6de4f3bef2
64 changed files with 3126 additions and 3399 deletions
+4 -105
View File
@@ -1,109 +1,8 @@
"""
文件模板模型模块
兼容 shim(绞杀者迁移期间保留)
=============================================================
提供文件模板管理的数据模型定义,用于管理文件模板信息。
模型已迁移至 src.modules.file_template.models。
本文件仅作兼容转发,最终在 P7(切尾)阶段删除。
"""
from application.models.base_db import BaseDB
from application.models.base_model import BaseModel
from config import DB_PREFIX
from extensions import db
from utils.case_converter import convert_camel_to_snake
# ============================================================
# 文件模板模型
# ============================================================
class FileTemplate(BaseModel, BaseDB):
"""
文件模板模型
用于存储文件模板信息,如:导入导出模板、报表模板等。
Attributes:
id: 主键ID(继承自 BaseModel)
name: 模板名称(String(100),可选)
code: 模板编码(String(50),可选,唯一标识)
file_name: 文件名称(String(255),可选)
file_path: 文件路径(String(255),可选)
note: 文件模板备注(String(255),可选)
sort: 文件模板顺序(Integer,必填,默认0)
"""
# ============================================================
# 表配置
# ============================================================
# 设置表名
__tablename__ = DB_PREFIX + "file_template"
# ============================================================
# 字段定义
# ============================================================
# 模板名称
name = db.Column(
db.String(100),
nullable=True,
comment="模板名称"
)
# 模板编码
code = db.Column(
db.String(50),
nullable=True,
comment="模板编码"
)
# 文件名称
file_name = db.Column(
db.String(255),
nullable=True,
comment="文件名称"
)
# 文件路径
file_path = db.Column(
db.String(255),
nullable=True,
comment="文件路径"
)
# 文件模板备注
note = db.Column(
db.String(255),
nullable=True,
comment="文件模板备注"
)
# 文件模板顺序
sort = db.Column(
db.Integer,
nullable=False,
default=0,
comment="文件模板顺序"
)
# ============================================================
# 魔法方法
# ============================================================
def __repr__(self):
"""
返回模型的字符串表示
Returns:
str: 格式为 "文件模板:{name}" 的字符串
"""
return '文件模板:{}'.format(self.name or self.code)
def __str__(self):
"""
返回模型的字符串表示
Returns:
str: 格式为 "文件模板:{name}" 的字符串
"""
return self.__repr__()
from src.modules.file_template.models import * # noqa: F401,F403