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多视角生图与后台管理详细功能与流程说明
This commit is contained in:
2026-03-27 15:29:50 +08:00
parent e3ff55b4db
commit 032c43525a
41 changed files with 3756 additions and 81 deletions

View File

@@ -4,7 +4,7 @@ Pydantic Schemas
"""
from .user import UserCreate, UserLogin, UserResponse, Token, UserUpdate, PasswordChange
from .category import CategoryResponse, SubTypeResponse, ColorResponse
from .design import DesignCreate, DesignResponse, DesignListResponse
from .design import DesignCreate, DesignResponse, DesignListResponse, DesignImageResponse
__all__ = [
# User schemas
@@ -22,4 +22,5 @@ __all__ = [
"DesignCreate",
"DesignResponse",
"DesignListResponse",
"DesignImageResponse",
]

View File

@@ -0,0 +1,173 @@
"""
管理后台相关 Pydantic Schemas
"""
from pydantic import BaseModel, Field
from datetime import datetime
from typing import Optional, List
# ============ 系统配置 ============
class SystemConfigItem(BaseModel):
"""单个配置项"""
config_key: str
config_value: Optional[str] = None
description: Optional[str] = None
config_group: str = "general"
is_secret: str = "N"
updated_at: Optional[datetime] = None
class Config:
from_attributes = True
class SystemConfigUpdate(BaseModel):
"""批量更新配置"""
configs: dict = Field(..., description="键值对: {config_key: config_value}")
class SystemConfigResponse(BaseModel):
"""配置列表响应"""
items: List[SystemConfigItem]
# ============ 用户管理 ============
class AdminUserResponse(BaseModel):
"""管理端用户信息"""
id: int
username: str
nickname: Optional[str] = None
phone: Optional[str] = None
is_admin: bool = False
created_at: datetime
design_count: int = 0
class Config:
from_attributes = True
class AdminUserListResponse(BaseModel):
"""用户列表响应"""
items: List[AdminUserResponse]
total: int
page: int
page_size: int
class AdminSetAdmin(BaseModel):
"""设置管理员"""
is_admin: bool
# ============ 品类管理 ============
class CategoryCreate(BaseModel):
"""创建品类"""
name: str = Field(..., max_length=50)
icon: Optional[str] = Field(None, max_length=255)
sort_order: int = 0
flow_type: str = Field("full", max_length=20)
class CategoryUpdate(BaseModel):
"""更新品类"""
name: Optional[str] = Field(None, max_length=50)
icon: Optional[str] = Field(None, max_length=255)
sort_order: Optional[int] = None
flow_type: Optional[str] = Field(None, max_length=20)
class SubTypeCreate(BaseModel):
"""创建子类型"""
category_id: int
name: str = Field(..., max_length=50)
description: Optional[str] = Field(None, max_length=255)
preview_image: Optional[str] = Field(None, max_length=255)
sort_order: int = 0
class SubTypeUpdate(BaseModel):
"""更新子类型"""
name: Optional[str] = Field(None, max_length=50)
description: Optional[str] = Field(None, max_length=255)
preview_image: Optional[str] = Field(None, max_length=255)
sort_order: Optional[int] = None
class ColorCreate(BaseModel):
"""创建颜色"""
category_id: int
name: str = Field(..., max_length=50)
hex_code: Optional[str] = Field(None, max_length=10)
sort_order: int = 0
class ColorUpdate(BaseModel):
"""更新颜色"""
name: Optional[str] = Field(None, max_length=50)
hex_code: Optional[str] = Field(None, max_length=10)
sort_order: Optional[int] = None
# ============ 设计管理 ============
class AdminDesignListResponse(BaseModel):
"""管理端设计列表"""
items: list
total: int
page: int
page_size: int
# ============ 提示词管理 ============
class PromptTemplateItem(BaseModel):
"""提示词模板"""
id: Optional[int] = None
template_key: str
template_value: str
description: Optional[str] = None
updated_at: Optional[datetime] = None
class Config:
from_attributes = True
class PromptTemplateUpdate(BaseModel):
"""更新提示词模板"""
template_value: str
description: Optional[str] = None
class PromptMappingItem(BaseModel):
"""提示词映射"""
id: Optional[int] = None
mapping_type: str
cn_key: str
en_value: str
sort_order: int = 0
updated_at: Optional[datetime] = None
class Config:
from_attributes = True
class PromptMappingCreate(BaseModel):
"""创建提示词映射"""
mapping_type: str
cn_key: str
en_value: str
sort_order: int = 0
class PromptMappingUpdate(BaseModel):
"""更新提示词映射"""
cn_key: Optional[str] = None
en_value: Optional[str] = None
sort_order: Optional[int] = None
# ============ 仪表盘 ============
class DashboardStats(BaseModel):
"""仪表盘统计"""
total_users: int
total_designs: int
total_categories: int
today_designs: int
today_users: int

View File

@@ -8,6 +8,20 @@ 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")
@@ -37,6 +51,7 @@ class DesignResponse(BaseModel):
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

View File

@@ -26,6 +26,7 @@ class UserResponse(BaseModel):
nickname: Optional[str] = None
phone: Optional[str] = None
avatar: Optional[str] = None
is_admin: bool = False
created_at: datetime
class Config: