Files
YuShiSheJiShi/backend/app/schemas/design.py
032c43525a feat(ai): 支持双模型多视角AI设计生图与后台管理系统
- 实现AI多视角设计图生成功能,支持6个可选设计参数配置
- 集成SiliconFlow FLUX.1与火山引擎Seedream 4.5双模型切换
- 构建专业中文转英文prompt系统,提升AI生成质量
- 前端设计预览支持多视角切换与视角指示器展示
- 增加多视角设计图片DesignImage模型关联及存储
- 后端设计服务异步调用AI接口,失败时降级生成mock图
- 新增管理员后台管理路由及完整的权限校验机制
- 实现后台模块:仪表盘、系统配置、用户/品类/设计管理
- 配置数据库系统配置表,支持动态AI配置及热更新
- 增加用户管理员标识字段,管理后台登录鉴权支持
- 更新API接口支持多视角设计参数及后台管理接口
- 优化设计删除逻辑,删除多视角相关图片文件
- 前端新增管理后台页面与路由,布局样式独立分离
- 更新环境变量增加AI模型相关Key与参数配置说明
- 引入httpx异步HTTP客户端用于AI接口调用及图片下载
- README文档完善AI多视角生图与后台管理详细功能与流程说明
2026-03-27 15:29:50 +08:00

69 lines
2.2 KiB
Python

"""
设计作品相关 Pydantic Schemas
"""
from pydantic import BaseModel, Field
from datetime import datetime
from typing import Optional, List
from .category import CategoryResponse, SubTypeResponse, ColorResponse
class DesignImageResponse(BaseModel):
"""设计图片响应(单张视角图)"""
id: int
view_name: str
image_url: Optional[str] = None
model_used: Optional[str] = None
prompt_used: Optional[str] = None
sort_order: int = 0
class Config:
from_attributes = True
protected_namespaces = ()
class DesignCreate(BaseModel):
"""创建设计请求"""
category_id: int = Field(..., description="品类ID")
sub_type_id: Optional[int] = Field(None, description="子类型ID")
color_id: Optional[int] = Field(None, description="颜色ID")
prompt: str = Field(..., min_length=1, max_length=2000, description="设计需求")
carving_technique: Optional[str] = Field(None, max_length=50, description="雕刻工艺")
design_style: Optional[str] = Field(None, max_length=50, description="设计风格")
motif: Optional[str] = Field(None, max_length=100, description="题材纹样")
size_spec: Optional[str] = Field(None, max_length=100, description="尺寸规格")
surface_finish: Optional[str] = Field(None, max_length=50, description="表面处理")
usage_scene: Optional[str] = Field(None, max_length=50, description="用途场景")
class DesignResponse(BaseModel):
"""设计作品响应"""
id: int
user_id: int
category: CategoryResponse
sub_type: Optional[SubTypeResponse] = None
color: Optional[ColorResponse] = None
prompt: str
carving_technique: Optional[str] = None
design_style: Optional[str] = None
motif: Optional[str] = None
size_spec: Optional[str] = None
surface_finish: Optional[str] = None
usage_scene: Optional[str] = None
image_url: Optional[str] = None
images: List[DesignImageResponse] = []
status: str
created_at: datetime
updated_at: datetime
class Config:
from_attributes = True
class DesignListResponse(BaseModel):
"""设计作品列表响应"""
items: List[DesignResponse]
total: int
page: int
page_size: int