feat: restore source parity and harden agent runtime
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
文档生成数据模型
|
||||
"""
|
||||
from sqlalchemy import Column, String, Text, Integer, Boolean, BigInteger, Index, JSON
|
||||
|
||||
from app.base_model import BaseModel
|
||||
|
||||
|
||||
class DocumentTemplate(BaseModel):
|
||||
"""文档模板配置"""
|
||||
__tablename__ = "document_template"
|
||||
|
||||
# 所属应用(逻辑外键关联 core_application)
|
||||
application_id = Column(String(21), nullable=True, index=True, comment="所属应用ID")
|
||||
|
||||
# 基础信息
|
||||
name = Column(String(100), nullable=False, comment="模板名称")
|
||||
code = Column(String(100), unique=True, nullable=False, comment="模板编码")
|
||||
category = Column(String(50), default="other", comment="分类: leave/expense/purchase/contract/certificate/other")
|
||||
description = Column(Text, default="", comment="描述")
|
||||
|
||||
# 关联配置
|
||||
form_code = Column(String(100), nullable=True, index=True, comment="关联表单编码")
|
||||
workflow_code = Column(String(100), nullable=True, index=True, comment="关联流程编码")
|
||||
|
||||
# 模板内容
|
||||
template_type = Column(String(20), default="designer", comment="模板类型: designer/html")
|
||||
template_content = Column(Text, nullable=True, comment="模板内容(JSON或HTML)")
|
||||
template_css = Column(Text, nullable=True, comment="自定义CSS")
|
||||
|
||||
# 页面设置
|
||||
page_size = Column(String(20), default="A4", comment="页面大小: A4/A3/Letter/Legal")
|
||||
page_orientation = Column(String(20), default="portrait", comment="页面方向: portrait/landscape")
|
||||
page_margin = Column(JSON, default=lambda: {"top": 20, "right": 20, "bottom": 20, "left": 20}, comment="页边距(mm)")
|
||||
|
||||
# 水印配置
|
||||
watermark_enabled = Column(Boolean, default=False, comment="是否启用水印")
|
||||
watermark_text = Column(String(100), nullable=True, comment="水印文字")
|
||||
watermark_type = Column(String(20), default="text", comment="水印类型: text/image")
|
||||
watermark_image_id = Column(String(36), nullable=True, comment="水印图片文件ID")
|
||||
watermark_opacity = Column(Integer, default=30, comment="水印透明度(0-100)")
|
||||
watermark_angle = Column(Integer, default=-45, comment="水印角度")
|
||||
|
||||
# 签章配置
|
||||
seal_enabled = Column(Boolean, default=False, comment="是否启用签章")
|
||||
seal_positions = Column(JSON, nullable=True, comment="签章位置配置")
|
||||
|
||||
# 页眉页脚
|
||||
header_enabled = Column(Boolean, default=False, comment="是否启用页眉")
|
||||
header_template = Column(Text, nullable=True, comment="页眉模板")
|
||||
footer_enabled = Column(Boolean, default=False, comment="是否启用页脚")
|
||||
footer_template = Column(Text, nullable=True, comment="页脚模板")
|
||||
show_page_number = Column(Boolean, default=True, comment="是否显示页码")
|
||||
|
||||
# 计算规则配置
|
||||
calculation_rules = Column(JSON, nullable=True, comment="计算规则配置")
|
||||
|
||||
# 状态
|
||||
status = Column(String(20), default="draft", index=True, comment="状态: draft/published")
|
||||
is_builtin = Column(Boolean, default=False, comment="是否内置模板")
|
||||
version = Column(Integer, default=1, comment="版本号")
|
||||
|
||||
__table_args__ = (
|
||||
Index("ix_document_template_code", "code"),
|
||||
Index("ix_document_template_form_code", "form_code"),
|
||||
Index("ix_document_template_workflow_code", "workflow_code"),
|
||||
)
|
||||
|
||||
|
||||
class GeneratedDocument(BaseModel):
|
||||
"""生成的文档记录"""
|
||||
__tablename__ = "generated_document"
|
||||
|
||||
# 关联模板
|
||||
template_id = Column(String(36), nullable=False, index=True, comment="模板ID")
|
||||
template_code = Column(String(100), nullable=True, comment="模板编码")
|
||||
template_name = Column(String(100), nullable=True, comment="模板名称")
|
||||
|
||||
# 关联表单数据
|
||||
form_code = Column(String(100), nullable=True, index=True, comment="表单编码")
|
||||
form_data_id = Column(String(36), nullable=True, index=True, comment="表单数据ID")
|
||||
|
||||
# 关联流程实例
|
||||
workflow_code = Column(String(100), nullable=True, comment="流程编码")
|
||||
instance_id = Column(String(36), nullable=True, index=True, comment="流程实例ID")
|
||||
|
||||
# 文档信息
|
||||
document_name = Column(String(200), nullable=False, comment="文档名称")
|
||||
document_no = Column(String(100), nullable=True, comment="文档编号")
|
||||
|
||||
# 文件信息
|
||||
file_id = Column(String(36), nullable=False, comment="文件ID(关联file_manager)")
|
||||
file_size = Column(BigInteger, default=0, comment="文件大小(字节)")
|
||||
page_count = Column(Integer, default=1, comment="页数")
|
||||
|
||||
# 生成信息
|
||||
generate_type = Column(String(20), default="manual", comment="生成方式: auto/manual")
|
||||
generator_id = Column(String(36), nullable=True, comment="生成人ID")
|
||||
generator_name = Column(String(100), nullable=True, comment="生成人姓名")
|
||||
|
||||
# 状态
|
||||
status = Column(String(20), default="generated", comment="状态: generated/sealed/downloaded/printed")
|
||||
download_count = Column(Integer, default=0, comment="下载次数")
|
||||
|
||||
# 签章信息
|
||||
sealed = Column(Boolean, default=False, comment="是否已盖章")
|
||||
seal_info = Column(JSON, nullable=True, comment="签章信息")
|
||||
|
||||
__table_args__ = (
|
||||
Index("ix_generated_document_template_id", "template_id"),
|
||||
Index("ix_generated_document_form_data_id", "form_data_id"),
|
||||
Index("ix_generated_document_instance_id", "instance_id"),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user