213 lines
5.8 KiB
Python
213 lines
5.8 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
合同管理 Schema 定义
|
|
"""
|
|
from datetime import datetime
|
|
from typing import Any, Dict, Optional
|
|
|
|
from pydantic import BaseModel, Field, ConfigDict
|
|
|
|
from app.base_schema import CSTDatetime
|
|
|
|
|
|
# ============ 合同模板 Schema ============
|
|
|
|
class ContractTemplateCreate(BaseModel):
|
|
"""创建合同模板"""
|
|
name: str = Field(..., max_length=100, description="模板名称")
|
|
code: str = Field(..., max_length=100, description="模板编码")
|
|
category: str = Field(default="", max_length=50, description="分类")
|
|
description: str = Field(default="", description="描述")
|
|
template_config: Dict[str, Any] = Field(default_factory=dict, description="模板配置")
|
|
|
|
|
|
class ContractTemplateUpdate(BaseModel):
|
|
"""更新合同模板"""
|
|
name: Optional[str] = Field(None, max_length=100, description="模板名称")
|
|
category: Optional[str] = Field(None, max_length=50, description="分类")
|
|
description: Optional[str] = Field(None, description="描述")
|
|
template_config: Optional[Dict[str, Any]] = Field(None, description="模板配置")
|
|
thumbnail: Optional[str] = Field(None, description="缩略图")
|
|
|
|
|
|
class ContractTemplateOut(BaseModel):
|
|
"""合同模板输出"""
|
|
id: str
|
|
name: str
|
|
code: str
|
|
category: str
|
|
description: str
|
|
status: str
|
|
version: int
|
|
template_config: Dict[str, Any]
|
|
thumbnail: str
|
|
sys_create_datetime: CSTDatetime
|
|
sys_update_datetime: CSTDatetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class ContractTemplateListItem(BaseModel):
|
|
"""合同模板列表项"""
|
|
id: str
|
|
name: str
|
|
code: str
|
|
category: str
|
|
description: str
|
|
status: str
|
|
version: int
|
|
thumbnail: str
|
|
sys_create_datetime: CSTDatetime
|
|
sys_update_datetime: CSTDatetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
# ============ 合同实例 Schema ============
|
|
|
|
class ContractInstanceCreate(BaseModel):
|
|
"""创建合同实例"""
|
|
template_id: str = Field(..., description="模板ID")
|
|
title: str = Field(..., max_length=200, description="合同标题")
|
|
contract_no: Optional[str] = Field(None, max_length=50, description="合同编号(可选,不填则自动生成)")
|
|
variable_data: Dict[str, Any] = Field(default_factory=dict, description="变量数据")
|
|
|
|
|
|
class ContractInstanceUpdate(BaseModel):
|
|
"""更新合同实例"""
|
|
title: Optional[str] = Field(None, max_length=200, description="合同标题")
|
|
variable_data: Optional[Dict[str, Any]] = Field(None, description="变量数据")
|
|
signature_data: Optional[Dict[str, Any]] = Field(None, description="签署数据")
|
|
|
|
|
|
class ContractInstanceOut(BaseModel):
|
|
"""合同实例输出"""
|
|
id: str
|
|
contract_no: str
|
|
title: str
|
|
status: str
|
|
template_id: str
|
|
contract_config: Dict[str, Any]
|
|
variable_data: Dict[str, Any]
|
|
signature_data: Dict[str, Any]
|
|
created_at: Optional[CSTDatetime] = None
|
|
completed_at: Optional[CSTDatetime] = None
|
|
expired_at: Optional[CSTDatetime] = None
|
|
pdf_file: str
|
|
|
|
# 关联字段
|
|
template_name: str = ""
|
|
template_code: str = ""
|
|
creator_id: str = ""
|
|
creator_name: str = ""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class ContractInstanceListItem(BaseModel):
|
|
"""合同实例列表项"""
|
|
id: str
|
|
contract_no: str
|
|
title: str
|
|
status: str
|
|
created_at: Optional[CSTDatetime] = None
|
|
completed_at: Optional[CSTDatetime] = None
|
|
|
|
# 关联字段
|
|
template_name: str = ""
|
|
creator_name: str = ""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
# ============ 签署记录 Schema ============
|
|
|
|
class ContractSignatureCreate(BaseModel):
|
|
"""创建签署记录"""
|
|
element_id: str = Field(..., description="元素ID")
|
|
signature_image: str = Field(..., description="签名图片(base64)")
|
|
signer_name: str = Field(default="", description="签署人姓名")
|
|
|
|
|
|
class ContractSignatureOut(BaseModel):
|
|
"""签署记录输出"""
|
|
id: str
|
|
element_id: str
|
|
party_type: str
|
|
party_label: str
|
|
sign_type: str
|
|
signer_id: Optional[str] = None
|
|
signer_name: str
|
|
signature_image: str
|
|
status: str
|
|
signed_at: Optional[CSTDatetime] = None
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
# ============ 操作日志 Schema ============
|
|
|
|
class ContractLogOut(BaseModel):
|
|
"""操作日志输出"""
|
|
id: str
|
|
action: str
|
|
operator_id: str
|
|
comment: str
|
|
sys_create_datetime: CSTDatetime
|
|
|
|
# 关联字段
|
|
operator_name: str = ""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
# ============ 手机签署 Schema ============
|
|
|
|
class MobileSignTokenCreate(BaseModel):
|
|
"""创建手机签署令牌"""
|
|
party_type: str = Field(default="party_a", description="签署方类型")
|
|
signer_name: str = Field(default="", description="签署人姓名")
|
|
expire_minutes: int = Field(default=30, description="有效期(分钟)")
|
|
|
|
|
|
class MobileSignTokenOut(BaseModel):
|
|
"""手机签署令牌输出"""
|
|
token: str
|
|
sign_url: str
|
|
expired_at: CSTDatetime
|
|
qrcode_data: str # 二维码内容
|
|
|
|
|
|
class MobileContractInfo(BaseModel):
|
|
"""移动端合同信息(简化版)"""
|
|
id: str
|
|
contract_no: str
|
|
title: str
|
|
status: str
|
|
contract_config: Dict[str, Any]
|
|
variable_data: Dict[str, Any]
|
|
signature_data: Dict[str, Any]
|
|
party_type: str = ""
|
|
signer_name: str = ""
|
|
template_name: str = ""
|
|
|
|
|
|
class MobileSignRequest(BaseModel):
|
|
"""移动端签署请求"""
|
|
element_id: str = Field(..., description="元素ID")
|
|
signature_image: str = Field(..., description="签名图片(base64)")
|
|
signer_name: str = Field(default="", description="签署人姓名")
|
|
|
|
|
|
# ============ 通用响应 ============
|
|
|
|
class MessageResponse(BaseModel):
|
|
"""消息响应"""
|
|
message: str
|
|
|
|
|
|
class CountResponse(BaseModel):
|
|
"""计数响应"""
|
|
count: int
|