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:
@@ -6,6 +6,9 @@ from ..database import Base
|
||||
from .user import User
|
||||
from .category import Category, SubType, Color
|
||||
from .design import Design
|
||||
from .design_image import DesignImage
|
||||
from .system_config import SystemConfig
|
||||
from .prompt_template import PromptTemplate, PromptMapping
|
||||
|
||||
__all__ = [
|
||||
"Base",
|
||||
@@ -13,5 +16,9 @@ __all__ = [
|
||||
"Category",
|
||||
"SubType",
|
||||
"Color",
|
||||
"Design"
|
||||
"Design",
|
||||
"DesignImage",
|
||||
"SystemConfig",
|
||||
"PromptTemplate",
|
||||
"PromptMapping",
|
||||
]
|
||||
|
||||
@@ -34,6 +34,7 @@ class Design(Base):
|
||||
category = relationship("Category", back_populates="designs")
|
||||
sub_type = relationship("SubType", back_populates="designs")
|
||||
color = relationship("Color", back_populates="designs")
|
||||
images = relationship("DesignImage", back_populates="design", cascade="all, delete-orphan", order_by="DesignImage.sort_order")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Design(id={self.id}, status='{self.status}')>"
|
||||
|
||||
29
backend/app/models/design_image.py
Normal file
29
backend/app/models/design_image.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""
|
||||
设计图片模型
|
||||
存储每个设计的多视角图片
|
||||
"""
|
||||
from sqlalchemy import Column, BigInteger, Integer, String, Text, DateTime, ForeignKey
|
||||
from sqlalchemy.sql import func
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from ..database import Base
|
||||
|
||||
|
||||
class DesignImage(Base):
|
||||
"""设计图片表 - 存储多视角设计图"""
|
||||
__tablename__ = "design_images"
|
||||
|
||||
id = Column(BigInteger, primary_key=True, autoincrement=True, comment="图片ID")
|
||||
design_id = Column(BigInteger, ForeignKey("designs.id", ondelete="CASCADE"), nullable=False, comment="关联设计ID")
|
||||
view_name = Column(String(20), nullable=False, comment="视角名称: 效果图/正面图/侧面图/背面图")
|
||||
image_url = Column(String(255), nullable=True, comment="图片URL路径")
|
||||
model_used = Column(String(50), nullable=True, comment="使用的AI模型: flux-dev/seedream-4.5")
|
||||
prompt_used = Column(Text, nullable=True, comment="实际使用的英文prompt")
|
||||
sort_order = Column(Integer, default=0, comment="排序")
|
||||
created_at = Column(DateTime, server_default=func.now(), comment="创建时间")
|
||||
|
||||
# 关联关系
|
||||
design = relationship("Design", back_populates="images")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<DesignImage(id={self.id}, view='{self.view_name}')>"
|
||||
37
backend/app/models/prompt_template.py
Normal file
37
backend/app/models/prompt_template.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""
|
||||
提示词模板模型
|
||||
存储可后台配置的提示词模板和映射数据
|
||||
"""
|
||||
from sqlalchemy import Column, BigInteger, Integer, String, Text, DateTime
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
from ..database import Base
|
||||
|
||||
|
||||
class PromptTemplate(Base):
|
||||
"""提示词模板表"""
|
||||
__tablename__ = "prompt_templates"
|
||||
|
||||
id = Column(BigInteger, primary_key=True, autoincrement=True, comment="模板ID")
|
||||
template_key = Column(String(100), unique=True, nullable=False, comment="模板键: main_template / quality_suffix")
|
||||
template_value = Column(Text, nullable=False, comment="模板内容,支持{变量}占位符")
|
||||
description = Column(String(255), nullable=True, comment="模板说明")
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<PromptTemplate(key='{self.template_key}')>"
|
||||
|
||||
|
||||
class PromptMapping(Base):
|
||||
"""提示词映射表 - 中文参数到英文描述的映射"""
|
||||
__tablename__ = "prompt_mappings"
|
||||
|
||||
id = Column(BigInteger, primary_key=True, autoincrement=True, comment="映射ID")
|
||||
mapping_type = Column(String(50), nullable=False, comment="映射类型: category/color/carving/style/motif/finish/scene/view/sub_type")
|
||||
cn_key = Column(String(100), nullable=False, comment="中文键")
|
||||
en_value = Column(Text, nullable=False, comment="英文描述")
|
||||
sort_order = Column(Integer, default=0, comment="排序")
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<PromptMapping(type='{self.mapping_type}', key='{self.cn_key}')>"
|
||||
24
backend/app/models/system_config.py
Normal file
24
backend/app/models/system_config.py
Normal file
@@ -0,0 +1,24 @@
|
||||
"""
|
||||
系统配置模型
|
||||
存储可通过后台管理的系统配置项
|
||||
"""
|
||||
from sqlalchemy import Column, BigInteger, String, Text, DateTime
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
from ..database import Base
|
||||
|
||||
|
||||
class SystemConfig(Base):
|
||||
"""系统配置表"""
|
||||
__tablename__ = "system_configs"
|
||||
|
||||
id = Column(BigInteger, primary_key=True, autoincrement=True, comment="配置ID")
|
||||
config_key = Column(String(100), unique=True, nullable=False, comment="配置键")
|
||||
config_value = Column(Text, nullable=True, comment="配置值")
|
||||
description = Column(String(255), nullable=True, comment="配置说明")
|
||||
config_group = Column(String(50), nullable=False, default="general", comment="配置分组: ai/general")
|
||||
is_secret = Column(String(1), nullable=False, default="N", comment="是否敏感信息(Y/N)")
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<SystemConfig(key='{self.config_key}')>"
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
用户模型
|
||||
"""
|
||||
from sqlalchemy import Column, BigInteger, String, DateTime
|
||||
from sqlalchemy import Column, BigInteger, String, DateTime, Boolean
|
||||
from sqlalchemy.sql import func
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
@@ -18,6 +18,7 @@ class User(Base):
|
||||
hashed_password = Column(String(255), nullable=False, comment="加密密码")
|
||||
nickname = Column(String(50), nullable=True, comment="昵称")
|
||||
avatar = Column(String(255), nullable=True, comment="头像URL")
|
||||
is_admin = Column(Boolean, default=False, nullable=False, comment="是否管理员")
|
||||
created_at = Column(DateTime, server_default=func.now(), comment="创建时间")
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user