refactor: P2 core+common 建设(应用工厂/扩展/工具层迁入 src/)
【结构】 - src/core/:database/response/jwt/password/security/redis_client/mail/scheduler - src/common/:base_model/base_db/forms(base_form+fields)/constants/utils - src/models_registry.py:模型聚合器(Flask-Migrate 全量表识别) 【绞杀者 shim】extensions/、utils/、application/constants|forms|models 打兼容转发 【兼容修复】应用工厂抽取至 application/factory.py(P2 前置,P1 已完成) 【基线修复】application/models(25) + middleware(7) 原被嵌套 .gitignore(*) 误排除出版本库,已补入(base_model/base_db 现为 shim,原版在 src/common/) 【登记既有缺陷】 1. flask db CLI 因 .env FLASK_VERSION 与 --version 冲突报错 → Makefile 已加 FLASK_SKIP_DOTENV=1 2. 本机 Redis 未设密码但 REDIS_AUTH=True,/captcha 报 AUTH 错误(环境问题) 【验收】22 模型表全量识别;src/ flake8 零告警;pytest 5 passed;应用启动; /login 表单校验、/user/page 鉴权拦截冒烟正常 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
92130ef070
commit
658ee6d596
@@ -0,0 +1,109 @@
|
||||
"""
|
||||
文件模板模型模块
|
||||
=============================================================
|
||||
|
||||
提供文件模板管理的数据模型定义,用于管理文件模板信息。
|
||||
"""
|
||||
|
||||
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__()
|
||||
Reference in New Issue
Block a user