Files
group_fqcd_jr/app/model/promotion_material.py

143 lines
7.0 KiB
Python

"""产品推介材料自动生成独立持久化模型。"""
from datetime import datetime
from typing import Any
from sqlalchemy import JSON, BigInteger, DateTime, Integer, String, Text, UniqueConstraint
from sqlalchemy.orm import Mapped, mapped_column
from app.model.base import Base
class PromotionMaterialTask(Base):
__tablename__ = "promotion_material_task"
__table_args__ = (
UniqueConstraint("task_no", name="uk_promotion_task_no"),
)
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
task_no: Mapped[str] = mapped_column(String(32), nullable=False)
product_code: Mapped[str | None] = mapped_column(String(32))
product_name: Mapped[str] = mapped_column(String(128), nullable=False)
material_title: Mapped[str] = mapped_column(String(200), nullable=False)
style_code: Mapped[str] = mapped_column(String(32), nullable=False)
output_formats: Mapped[list[str]] = mapped_column(JSON, nullable=False)
template_version: Mapped[str | None] = mapped_column(String(64))
status: Mapped[str] = mapped_column(String(32), nullable=False, default="draft")
created_by: Mapped[int] = mapped_column(BigInteger, nullable=False)
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
class PromotionInputSnapshot(Base):
__tablename__ = "promotion_input_snapshot"
__table_args__ = (
UniqueConstraint("task_no", "version_no", name="uk_promotion_input_version"),
)
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
task_no: Mapped[str] = mapped_column(String(32), nullable=False)
version_no: Mapped[int] = mapped_column(Integer, nullable=False)
product_info: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False)
manager_info: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False)
team_info: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False)
strategy_info: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False)
fee_structure: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False)
performance_info: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False)
risk_disclosure: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False)
source_notes: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False)
created_by: Mapped[int] = mapped_column(BigInteger, nullable=False)
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
class PromotionAttachment(Base):
__tablename__ = "promotion_attachment"
__table_args__ = (
UniqueConstraint("task_no", "file_hash", name="uk_promotion_attachment_hash"),
)
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
task_no: Mapped[str] = mapped_column(String(32), nullable=False)
attachment_type: Mapped[str] = mapped_column(String(32), nullable=False)
filename: Mapped[str] = mapped_column(String(255), nullable=False)
media_type: Mapped[str] = mapped_column(String(128), nullable=False)
file_hash: Mapped[str] = mapped_column(String(128), nullable=False)
size_bytes: Mapped[int] = mapped_column(BigInteger, nullable=False)
file_path: Mapped[str] = mapped_column(String(500), nullable=False)
parsed_metadata: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False)
uploaded_by: Mapped[int] = mapped_column(BigInteger, nullable=False)
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
class PromotionMaterialVersion(Base):
__tablename__ = "promotion_material_version"
__table_args__ = (
UniqueConstraint("task_no", "version_no", name="uk_promotion_material_version"),
)
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
task_no: Mapped[str] = mapped_column(String(32), nullable=False)
input_snapshot_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
version_no: Mapped[int] = mapped_column(Integer, nullable=False)
style_code: Mapped[str] = mapped_column(String(32), nullable=False)
template_version: Mapped[str | None] = mapped_column(String(64))
prompt_version: Mapped[str] = mapped_column(String(64), nullable=False)
draft_json: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False)
pptx_path: Mapped[str | None] = mapped_column(String(500))
pdf_path: Mapped[str | None] = mapped_column(String(500))
poster_path: Mapped[str | None] = mapped_column(String(500))
chart_paths: Mapped[list[str]] = mapped_column(JSON, nullable=False)
status: Mapped[str] = mapped_column(String(32), nullable=False)
error_message: Mapped[str | None] = mapped_column(String(500))
generated_by: Mapped[int] = mapped_column(BigInteger, nullable=False)
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
class PromotionComplianceCheck(Base):
__tablename__ = "promotion_compliance_check"
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
task_no: Mapped[str] = mapped_column(String(32), nullable=False)
material_version_id: Mapped[int | None] = mapped_column(BigInteger)
rule_code: Mapped[str] = mapped_column(String(64), nullable=False)
rule_name: Mapped[str] = mapped_column(String(128), nullable=False)
scope: Mapped[str] = mapped_column(String(32), nullable=False)
severity: Mapped[str] = mapped_column(String(16), nullable=False)
hit_text: Mapped[str | None] = mapped_column(Text)
suggestion: Mapped[str] = mapped_column(String(500), nullable=False)
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
class PromotionReviewRecord(Base):
__tablename__ = "promotion_review_record"
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
task_no: Mapped[str] = mapped_column(String(32), nullable=False)
material_version_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
reviewer_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
decision: Mapped[str] = mapped_column(String(32), nullable=False)
comment: Mapped[str | None] = mapped_column(String(1000))
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
class PromotionDeliveryRecord(Base):
__tablename__ = "promotion_delivery_record"
__table_args__ = (
UniqueConstraint(
"material_version_id",
"advisor_id",
name="uk_promotion_delivery_version_advisor",
),
)
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
task_no: Mapped[str] = mapped_column(String(32), nullable=False)
material_version_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
advisor_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
delivery_channel: Mapped[str] = mapped_column(String(32), nullable=False)
status: Mapped[str] = mapped_column(String(16), nullable=False)
failure_reason: Mapped[str | None] = mapped_column(String(500))
created_by: Mapped[int] = mapped_column(BigInteger, nullable=False)
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
sent_at: Mapped[datetime | None] = mapped_column(DateTime)