docs(readme): 编写项目README文档,描述功能与架构

- 完整撰写玉宗珠宝设计大师项目README,介绍项目概况及核心功能
- 说明用户认证系统实现及优势,包含JWT鉴权和密码加密细节
- 详细描述品类管理系统,支持多流程类型和多种玉石品类
- 说明设计图生成方案及技术,包含Pillow生成示例及字体支持
- 介绍设计管理功能,支持分页浏览、预览、下载和删除设计
- 个人信息管理模块说明,涵盖昵称、手机号、密码的安全修改
- 绘制业务流程图和关键数据流图,清晰展现系统架构与数据流
- 提供详细API调用链路及参数说明,涵盖用户、品类、设计接口
- 列明技术栈及版本,包含前后端框架、ORM、认证、加密等工具
- 展示目录结构,标明后端与前端项目布局
- 规划本地开发环境与启动步骤,包括数据库初始化及运行命令
- 说明服务器部署流程和Nginx配置方案
- 详细数据库表结构说明及环境变量配置指导
- 汇总常用开发及测试命令,方便开发调试与部署管理
This commit is contained in:
changyoutongxue
2026-03-27 13:10:17 +08:00
commit e3ff55b4db
69 changed files with 8551 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
"""
数据库模型
导出所有模型,确保 Base.metadata 包含所有表
"""
from ..database import Base
from .user import User
from .category import Category, SubType, Color
from .design import Design
__all__ = [
"Base",
"User",
"Category",
"SubType",
"Color",
"Design"
]

View File

@@ -0,0 +1,64 @@
"""
品类相关模型
包含:品类、子类型、颜色
"""
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import relationship
from ..database import Base
class Category(Base):
"""品类表"""
__tablename__ = "categories"
id = Column(Integer, primary_key=True, autoincrement=True, comment="品类ID")
name = Column(String(50), nullable=False, comment="品类名称")
icon = Column(String(255), nullable=True, comment="品类图标")
sort_order = Column(Integer, default=0, comment="排序")
flow_type = Column(String(20), nullable=False, comment="流程类型full/size_color/simple")
# 关联关系
sub_types = relationship("SubType", back_populates="category")
colors = relationship("Color", back_populates="category")
designs = relationship("Design", back_populates="category")
def __repr__(self):
return f"<Category(id={self.id}, name='{self.name}')>"
class SubType(Base):
"""子类型表"""
__tablename__ = "sub_types"
id = Column(Integer, primary_key=True, autoincrement=True, comment="子类型ID")
category_id = Column(Integer, ForeignKey("categories.id"), nullable=False, comment="所属品类")
name = Column(String(50), nullable=False, comment="名称")
description = Column(String(255), nullable=True, comment="描述")
preview_image = Column(String(255), nullable=True, comment="预览图")
sort_order = Column(Integer, default=0, comment="排序")
# 关联关系
category = relationship("Category", back_populates="sub_types")
designs = relationship("Design", back_populates="sub_type")
def __repr__(self):
return f"<SubType(id={self.id}, name='{self.name}')>"
class Color(Base):
"""颜色表"""
__tablename__ = "colors"
id = Column(Integer, primary_key=True, autoincrement=True, comment="颜色ID")
category_id = Column(Integer, ForeignKey("categories.id"), nullable=False, comment="适用品类")
name = Column(String(50), nullable=False, comment="颜色名称")
hex_code = Column(String(7), nullable=False, comment="色值")
sort_order = Column(Integer, default=0, comment="排序")
# 关联关系
category = relationship("Category", back_populates="colors")
designs = relationship("Design", back_populates="color")
def __repr__(self):
return f"<Color(id={self.id}, name='{self.name}', hex_code='{self.hex_code}')>"

View File

@@ -0,0 +1,39 @@
"""
设计作品模型
"""
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 Design(Base):
"""设计作品表"""
__tablename__ = "designs"
id = Column(BigInteger, primary_key=True, autoincrement=True, comment="设计ID")
user_id = Column(BigInteger, ForeignKey("users.id"), nullable=False, comment="用户ID")
category_id = Column(Integer, ForeignKey("categories.id"), nullable=False, comment="品类ID")
sub_type_id = Column(Integer, ForeignKey("sub_types.id"), nullable=True, comment="子类型ID")
color_id = Column(Integer, ForeignKey("colors.id"), nullable=True, comment="颜色ID")
prompt = Column(Text, nullable=False, comment="设计需求")
carving_technique = Column(String(50), nullable=True, comment="雕刻工艺")
design_style = Column(String(50), nullable=True, comment="设计风格")
motif = Column(String(100), nullable=True, comment="题材纹样")
size_spec = Column(String(100), nullable=True, comment="尺寸规格")
surface_finish = Column(String(50), nullable=True, comment="表面处理")
usage_scene = Column(String(50), nullable=True, comment="用途场景")
image_url = Column(String(255), nullable=True, comment="设计图URL")
status = Column(String(20), default="generating", comment="状态")
created_at = Column(DateTime, server_default=func.now(), comment="创建时间")
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")
# 关联关系
user = relationship("User", back_populates="designs")
category = relationship("Category", back_populates="designs")
sub_type = relationship("SubType", back_populates="designs")
color = relationship("Color", back_populates="designs")
def __repr__(self):
return f"<Design(id={self.id}, status='{self.status}')>"

View File

@@ -0,0 +1,28 @@
"""
用户模型
"""
from sqlalchemy import Column, BigInteger, String, DateTime
from sqlalchemy.sql import func
from sqlalchemy.orm import relationship
from ..database import Base
class User(Base):
"""用户表"""
__tablename__ = "users"
id = Column(BigInteger, primary_key=True, autoincrement=True, comment="用户ID")
username = Column(String(50), unique=True, nullable=False, comment="用户名")
phone = Column(String(20), unique=True, nullable=True, comment="手机号")
hashed_password = Column(String(255), nullable=False, comment="加密密码")
nickname = Column(String(50), nullable=True, comment="昵称")
avatar = Column(String(255), nullable=True, comment="头像URL")
created_at = Column(DateTime, server_default=func.now(), comment="创建时间")
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")
# 关联关系
designs = relationship("Design", back_populates="user")
def __repr__(self):
return f"<User(id={self.id}, username='{self.username}')>"