baodan/api/insurance/models/poster_template_model.py
wsb1224 751302205a 文件 问题 严重度
1	poster/routes.py:156	下载路径硬编码,与实际存储路径不一致 → 下载 404	P0
2	poster/service.py:41	get_reviewed_products() N+1 查询	P1
3	poster/service.py:169,226	json.loads 无异常处理 → 数据损坏时崩溃	P1
4	3 个 model 文件	to_dict() 中 json.loads 无防御 → 序列化崩溃	P1
5	poster/tasks.py	~120 行死代码(线程版海报生成)	P2
6	generation/celery_tasks.py	parse_poster_task + _execute_poster_parse 死代码(~70 行)	P2
7	generation/task_service.py	对应移除 ("poster", "parse") 映射	P2
8	utils/security.py	SSRF TOCTOU:DNS 检查与请求之间的时间窗口可被 DNS rebinding 利用 → 新增 _SafeHTTPTransport 在连接时重新验证 IP	P1 安全
9	poster/image_generator.py	anchor="mm" 在旧 Pillow 默认字体上崩溃;改用 hasattr 检测	P1
前端(3 项)
#	文件	问题	严重度
10	poster-api.ts:54	downloadPoster() 返回 AxiosResponse 而非 Blob → 海报永远无法下载	P0
11	PosterStepUpload.vue	解析轮询无超时 → 无限轮询	P1
12	PosterStepPreview.vue	生成轮询无超时 → 无限轮询	P1
修改的文件总计
后端 7 个:security.py, image_generator.py, service.py, routes.py, tasks.py, celery_tasks.py, task_service.py, poster_case_upload.py, poster_record.py, poster_template_model.py

前端 3 个:poster-api.ts, PosterStepUpload.vue, PosterStepPreview.vue

未修复(确认无需修复)
manual_parser.py — 之前误判为死代码,实际被 Celery 产品小册子解析任务使用,保留不动
llm_client.py 中的 httpx 调用 — URL 来自管理员配置的系统设置,不是用户输入,SSRF 风险极低;加检查反而会阻断合法的私网 LLM 端点
2026-07-29 22:41:27 +08:00

41 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""海报模板模型AI 生图方案)。"""
from sqlalchemy import Column, String, Text, SmallInteger, BigInteger, TIMESTAMP, func
from insurance.db.compat import db
class PosterTemplate(db.Model):
"""海报模板表AI 生图方案)。"""
__tablename__ = "poster_templates"
id = Column(BigInteger, primary_key=True, autoincrement=True)
name = Column(String(100), nullable=False, comment="模板名称")
scenario_tag = Column(String(50), nullable=True, comment="场景标签")
style_description = Column(Text, nullable=False, comment="AI 生图风格描述 prompt 片段")
color_scheme = Column(Text, nullable=True, comment="配色方案 JSON")
reference_image = Column(String(500), nullable=True, comment="参考图地址")
preview_image = Column(String(500), nullable=True, comment="预览图地址")
status = Column(SmallInteger, default=1, comment="1=启用, 0=停用")
created_at = Column(TIMESTAMP, server_default=func.now())
updated_at = Column(TIMESTAMP, server_default=func.now(), onupdate=func.now())
def to_dict(self):
import json
color_scheme = None
if self.color_scheme:
try:
color_scheme = json.loads(self.color_scheme)
except (json.JSONDecodeError, TypeError):
color_scheme = None
return {
"id": self.id,
"name": self.name,
"scenarioTag": self.scenario_tag,
"styleDescription": self.style_description,
"colorScheme": color_scheme,
"referenceImage": self.reference_image,
"previewImage": self.preview_image,
"status": self.status,
"createdAt": self.created_at.isoformat() if self.created_at else None,
"updatedAt": self.updated_at.isoformat() if self.updated_at else None,
}