feat: restore source parity and harden agent runtime
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
合同管理数据模型
|
||||
"""
|
||||
from sqlalchemy import Column, String, Text, Integer, DateTime, Boolean, JSON
|
||||
|
||||
from app.base_model import BaseModel
|
||||
|
||||
|
||||
class ContractTemplate(BaseModel):
|
||||
"""合同模板"""
|
||||
__tablename__ = "contract_template"
|
||||
|
||||
name = Column(String(100), nullable=False, comment="模板名称")
|
||||
code = Column(String(100), unique=True, nullable=False, comment="模板编码")
|
||||
category = Column(String(50), default="", comment="分类")
|
||||
description = Column(Text, default="", comment="描述")
|
||||
status = Column(String(20), default="draft", index=True, comment="状态: draft/published/disabled")
|
||||
version = Column(Integer, default=1, comment="版本号")
|
||||
|
||||
# 模板配置(JSON格式存储页面设置、元素、变量等)
|
||||
template_config = Column(JSON, default=dict, comment="模板配置")
|
||||
|
||||
# 缩略图
|
||||
thumbnail = Column(Text, default="", comment="缩略图(base64)")
|
||||
|
||||
|
||||
class ContractInstance(BaseModel):
|
||||
"""合同实例(基于模板创建的合同)"""
|
||||
__tablename__ = "contract_instance"
|
||||
|
||||
# 关联模板(逻辑外键)
|
||||
template_id = Column(String(21), nullable=False, index=True, comment="合同模板ID")
|
||||
|
||||
# 合同信息
|
||||
contract_no = Column(String(50), unique=True, nullable=False, comment="合同编号")
|
||||
title = Column(String(200), nullable=False, comment="合同标题")
|
||||
status = Column(String(20), default="draft", index=True, comment="状态: draft/pending/signing/completed/expired/canceled")
|
||||
|
||||
# 创建人(逻辑外键)
|
||||
creator_id = Column(String(21), nullable=False, index=True, comment="创建人ID")
|
||||
|
||||
# 合同配置(继承自模板,可修改)
|
||||
contract_config = Column(JSON, default=dict, comment="合同配置")
|
||||
|
||||
# 变量数据
|
||||
variable_data = Column(JSON, default=dict, comment="变量数据")
|
||||
|
||||
# 签署数据
|
||||
signature_data = Column(JSON, default=dict, comment="签署数据")
|
||||
|
||||
# 时间记录
|
||||
created_at = Column(DateTime, nullable=True, comment="创建时间")
|
||||
completed_at = Column(DateTime, nullable=True, comment="完成时间")
|
||||
expired_at = Column(DateTime, nullable=True, comment="过期时间")
|
||||
|
||||
# PDF 文件
|
||||
pdf_file = Column(Text, default="", comment="PDF文件路径")
|
||||
|
||||
|
||||
class ContractSignature(BaseModel):
|
||||
"""合同签署记录"""
|
||||
__tablename__ = "contract_signature"
|
||||
|
||||
# 关联合同(逻辑外键)
|
||||
contract_id = Column(String(21), nullable=False, index=True, comment="合同实例ID")
|
||||
|
||||
# 签署区信息
|
||||
element_id = Column(String(50), nullable=False, comment="元素ID")
|
||||
party_type = Column(String(20), default="party_a", comment="签署方类型: party_a/party_b/party_c/witness")
|
||||
party_label = Column(String(50), default="", comment="签署方标签")
|
||||
sign_type = Column(String(20), default="signature", comment="签署类型: signature/seal")
|
||||
|
||||
# 签署人(逻辑外键)
|
||||
signer_id = Column(String(21), nullable=True, comment="签署人ID")
|
||||
signer_name = Column(String(50), default="", comment="签署人姓名")
|
||||
|
||||
# 签署数据
|
||||
signature_image = Column(Text, default="", comment="签名/印章图片(base64)")
|
||||
status = Column(String(20), default="pending", comment="状态: pending/signed/rejected")
|
||||
signed_at = Column(DateTime, nullable=True, comment="签署时间")
|
||||
|
||||
# IP 和设备信息
|
||||
sign_ip = Column(String(50), default="", comment="签署IP")
|
||||
sign_device = Column(String(200), default="", comment="签署设备")
|
||||
|
||||
|
||||
class ContractSignToken(BaseModel):
|
||||
"""合同签署令牌(用于手机扫码签署)"""
|
||||
__tablename__ = "contract_sign_token"
|
||||
|
||||
# 关联合同(逻辑外键)
|
||||
contract_id = Column(String(21), nullable=False, index=True, comment="合同实例ID")
|
||||
|
||||
# 令牌
|
||||
token = Column(String(64), unique=True, nullable=False, comment="签署令牌")
|
||||
|
||||
# 签署方信息
|
||||
party_type = Column(String(20), default="party_a", comment="签署方类型")
|
||||
signer_name = Column(String(50), default="", comment="签署人姓名")
|
||||
|
||||
# 有效期
|
||||
expired_at = Column(DateTime, nullable=False, comment="过期时间")
|
||||
|
||||
# 是否已使用
|
||||
is_used = Column(Boolean, default=False, comment="是否已使用")
|
||||
used_at = Column(DateTime, nullable=True, comment="使用时间")
|
||||
|
||||
|
||||
class ContractLog(BaseModel):
|
||||
"""合同操作日志"""
|
||||
__tablename__ = "contract_log"
|
||||
|
||||
# 关联合同(逻辑外键)
|
||||
contract_id = Column(String(21), nullable=False, index=True, comment="合同实例ID")
|
||||
|
||||
# 操作信息
|
||||
action = Column(String(20), nullable=False, comment="操作类型: create/update/submit/sign/reject/cancel/complete/export/view")
|
||||
|
||||
# 操作人(逻辑外键)
|
||||
operator_id = Column(String(21), nullable=False, comment="操作人ID")
|
||||
|
||||
# 操作详情
|
||||
comment = Column(Text, default="", comment="备注")
|
||||
extra_data = Column(JSON, default=dict, comment="额外数据")
|
||||
|
||||
# IP 信息
|
||||
ip_address = Column(String(50), default="", comment="IP地址")
|
||||
Reference in New Issue
Block a user