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 -113
View File
@@ -1,117 +1,8 @@
"""
参数模型模块
兼容 shim(绞杀者迁移期间保留)
=============================================================
提供系统参数管理的数据模型定义,用于管理系统参数和业务参数。
模型已迁移至 src.modules.param.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 Param(BaseModel, BaseDB):
"""
参数模型
用于存储系统参数和业务参数信息,如:系统配置参数、业务规则参数等。
继承自 BaseModel(通用字段)和 BaseDB(数据库操作方法)。
Attributes:
id: 主键ID(继承自 BaseModel)
name: 参数名称(String(100),必填)
code: 参数编码(String(100),必填,唯一标识)
value: 参数值(String(255),必填)
type: 参数类型(Integer,0-系统 1-业务,必填)
status: 参数状态(Integer,1-正常 2-禁用,必填)
sort: 参数排序(Integer,默认0,数值越小越靠前)
note: 参数备注(String(255),可选)
"""
# ============================================================
# 表配置
# ============================================================
# 设置表名
__tablename__ = DB_PREFIX + "param"
# ============================================================
# 字段定义
# ============================================================
# 参数名称
name = db.Column(
db.String(100),
nullable=False,
comment="参数名称"
)
# 参数编码
code = db.Column(
db.String(100),
nullable=False,
comment="参数编码"
)
# 参数值
value = db.Column(
db.String(255),
nullable=False,
comment="参数值"
)
# 参数类型:0-系统 1-业务
type = db.Column(
db.Integer,
nullable=False,
comment="参数类型:0-系统 1-业务"
)
# 参数状态:1-正常 2-禁用
status = db.Column(
db.Integer,
nullable=False,
comment="参数状态:1-正常 2-禁用"
)
# 参数排序
sort = db.Column(
db.Integer,
nullable=False,
comment="参数排序"
)
# 参数备注
note = db.Column(
db.String(255),
nullable=True,
comment="参数备注"
)
# ============================================================
# 魔法方法
# ============================================================
def __repr__(self):
"""
返回模型的字符串表示
Returns:
str: 格式为 "参数:{name}" 的字符串
"""
return '参数:{}'.format(self.name)
def __str__(self):
"""
返回模型的字符串表示
Returns:
str: 格式为 "参数:{name}" 的字符串
"""
return self.__repr__()
from src.modules.param.models import * # noqa: F401,F403