【毕业季】本科毕设《Magic Camera》需求清单

记录本科毕设的需求、进度
数据库
- 数据库设计
- prompt_option: prompt 选项表
- resource: 资源表
- role: 角色表
- role_resource_rel: 角色-资源关联表
- sys_param: 系统参数表
- user_basic: 用户表
- api_log: API 日志表
- 资源初始化
后端服务
- API
- 登录/注册/登出
- PhotoMaker
- 权限模块
- 角色管理:增删改查
- 用户管理:增删改查
- 资源树管理:增删改查
- Prompt 管理:增删改查
- 系统参数管理:增删改查
- API 日志模块:增查
- 中间件
- JWT 认证
- 业务限流器
- 缓存限流次数
- API 日志记录
- 字段脱敏
- 优化
- 对 DB 封装一层 Redis 缓存
前端页面
- 身份认证功能:登录/注册/登出
- 首页业务页面:魔力照相机
- 系统管理页面
- 角色管理页面
- 资源管理页面
- 用户管理页面
- Prompt 管理页面
- 系统参数管理页面
- 监控视图页面
- 服务器监控面板
- Go 进程监控面板
- Redis 监控面板
- MySQL 监控面板
- WEB API 监控面板
- API 日志查询页面
测试
- 登录/注册/登出
- 业务模块
- 后台管理模块
- 权限模块
- 用户模块
- 角色模块
- Prompt 模块
- 系统参数模块
- 监控模块
- 服务器监控面板
- Go 进程监控面板
- Redis 监控面板
- MySQL 监控面板
- WEB API 监控面板
- 日志模块
运维相关
- 流水线发布(前端)
- 流水线发布(后端)
- Nginx 部署
- MySQL 部署
- Redis 部署
- 监控组件部署
- Prometheus 部署
- node_exporter 部署
- mysqld_exporter 部署
- redis_exporter 部署
- Grafana 部署
- 服务器 Dashboard
- Go 进程 Dashboard
- Redis Dashboard
- MySQL Dashboard
- WEB API Dashboard
- SSL/TLS 证书
- 日志
- Prompt 设置
数据库设计
单体服务,采用 mysql 作为底层数据库,使用 redis 做缓存数据库。
权限模块
通过 RBAC 模型的方式,基于角色控制资源权限,表字段设计如下:
用户表
字段名 | 类型 | NULL | Key | Default | Extra |
---|---|---|---|---|---|
id | bigint unsigned | NO | PRI | null | auto_increment |
created_at | datetime | YES | null | ||
updated_at | datetime | YES | null | ||
deleted_at | datetime | YES | null | ||
username | varchar(50) | NO | UNI | null | |
password_hash | varchar(255) | NO | null | ||
role_id | bigint unsigned | NO | MUL | 0 | |
last_login | datetime | YES | null | ||
is_enable | tinyint(1) | YES | null | ||
biz_count | bigint unsigned | YES | 0 |
建表语句:
|
|
资源表
字段名 | 类型 | Null | Key | Default | Extra |
---|---|---|---|---|---|
id | bigint unsigned | NO | PRI | null | auto_increment |
created_at | datetime | YES | null | ||
updated_at | datetime | YES | null | ||
deleted_at | datetime | YES | null | ||
name | varchar(255) | NO | |||
code | varchar(255) | NO | |||
type | varchar(255) | NO | |||
parent_id | bigint unsigned | NO | 0 | ||
order | int | NO | 0 | ||
icon | varchar(512) | NO | |||
component | varchar(512) | NO | |||
path | varchar(512) | NO | |||
is_show | tinyint(1) | NO | 0 | ||
is_enable | tinyint(1) | NO | 0 |
建表语句:
|
|
角色-资源关联表
字段名 | 类型 | Null | Key | Default | Extra |
---|---|---|---|---|---|
id | bigint unsigned | NO | PRI | null | auto_increment |
created_at | datetime | YES | null | ||
updated_at | datetime | YES | null | ||
deleted_at | datetime | YES | null | ||
role_id | bigint unsigned | NO | MUL | 0 | |
resource_id | bigint unsigned | NO | MUL | 0 |
建表语句:
|
|
角色表
字段名 | 类型 | Null | Key | Default | Extra |
---|---|---|---|---|---|
id | bigint unsigned | NO | PRI | null | auto_increment |
created_at | datetime | YES | null | ||
updated_at | datetime | YES | null | ||
deleted_at | datetime | YES | null | ||
code | varchar(255) | NO | UNI | ||
name | varchar(255) | NO | UNI | ||
is_enable | tinyint(1) | NO | 0 |
建表语句:
|
|
业务模块
需要给用户提供一个下拉选项,并且对应 prompt 中英文。
造型选项表
Field | Type | Null | Key | Default | Extra |
---|---|---|---|---|---|
id | bigint unsigned | NO | PRI | null | auto_increment |
created_at | datetime | YES | null | ||
updated_at | datetime | YES | null | ||
deleted_at | datetime | YES | null | ||
name | varchar(255) | NO | UNI | ||
prompt | text | YES | null | ||
negative_prompt | text | YES | null | ||
desc | varchar(255) | NO |
建表语句:
|
|
系统模块
系统参数表
字段名 | 字段类型 | Null | Key | Default | Extra |
---|---|---|---|---|---|
id | bigint unsigned | NO | PRI | null | auto_increment |
created_at | datetime | YES | null | ||
updated_at | datetime | YES | null | ||
deleted_at | datetime | YES | null | ||
key | varchar(255) | NO | UNI | null | |
value | text | YES | null | ||
desc | varchar(255) | NO |
建表语句:
|
|
日志模块
字段名 | 字段类型 | Null | Key | Default | Extra |
---|---|---|---|---|---|
id | bigint unsigned | NO | PRI | null | auto_increment |
created_at | datetime | YES | null | ||
method | varchar(64) | NO | null | ||
api_path | text | NO | null | ||
req_header | mediumtext | YES | null | ||
req_body | mediumtext | YES | null | ||
status | varchar(64) | NO | null | ||
operator | varchar(255) | NO | null | ||
remote_ip | varchar(255) | YES | null | ||
remote_city | varchar(255) | YES | null | ||
response | longtext | YES | null | ||
cost_time | bigint unsigned | NO | null |
建表语句:
|
|
数据初始化
|
|
AI 模型需求
PhotoMaker
使用 PhotoMaker 作为 AI Work,底层用到了 Stable Diffusion 和 LoRA 微调。
AI 部署
模型算法部署在了 Replicate 上,通过 http 接口的方式暴露给后端使用。
接口列表
1. “分页查询 API 日志”
- route definition
- Url: /api/v1/api-log
- Method: GET
- Request:
GetApiLogReq
- Response:
GetApiLogResp
- request definition
|
|
- response definition
|
|
2. “用户登录”
- route definition
- Url: /api/v1/user/login
- Method: POST
- Request:
UserLoginReq
- Response:
UserLoginResp
- request definition
|
|
- response definition
|
|
3. “用户注册”
- route definition
- Url: /api/v1/user/register
- Method: POST
- Request:
UserRegisterReq
- Response:
UserRegisterResp
- request definition
|
|
- response definition
|
|
4. “用户登出”
- route definition
- Url: /api/v1/user/logout
- Method: POST
- Request:
-
- Response:
-
request definition
response definition
5. “获取四位验证码”
- route definition
- Url: /api/v1/captcha
- Method: GET
- Request:
-
- Response:
GetCaptchaResp
request definition
response definition
|
|
6. “获取 tmp 目录下文件”
- route definition
- Url: /api/v1/file/:dir/:filename
- Method: GET
- Request:
GetFileReq
- Response:
-
- request definition
|
|
- response definition
7. “探活 ping”
- route definition
- Url: /ping
- Method: GET
- Request:
-
- Response:
-
request definition
response definition
8. “生成照片”
- route definition
- Url: /api/v1/generate/photo
- Method: POST
- Request:
GeneratePhotoReq
- Response:
GeneratePhotoResp
- request definition
|
|
- response definition
|
|
9. “获取角色权限树”
- route definition
- Url: /api/v1/role/permissions/tree
- Method: GET
- Request:
-
- Response:
GetResourceTreeResp
request definition
response definition
|
|
10. “分页查询 Prompt Option”
- route definition
- Url: /api/v1/prompt-option
- Method: GET
- Request:
GetPromptOptionReq
- Response:
GetPromptOptionResp
- request definition
|
|
- response definition
|
|
11. “新增 Prompt Option”
- route definition
- Url: /api/v1/prompt-option
- Method: POST
- Request:
AddPromptOptionReq
- Response:
AddPromptOptionResp
- request definition
|
|
- response definition
|
|
12. “修改 Prompt Option”
- route definition
- Url: /api/v1/prompt-option/:id
- Method: PUT
- Request:
UpdatePromptOptionReq
- Response:
-
- request definition
|
|
- response definition
13. “删除 Prompt Option”
- route definition
- Url: /api/v1/prompt-option/:id
- Method: DELETE
- Request:
DeletePromptOptionReq
- Response:
-
- request definition
|
|
- response definition
14. “获取全部 Prompt Option”
- route definition
- Url: /api/v1/prompt-option/all
- Method: GET
- Request:
GetPromptOptionReq
- Response:
GetPromptOptionResp
- request definition
|
|
- response definition
|
|
15. “新增资源”
- route definition
- Url: /api/v1/resource
- Method: POST
- Request:
AddResourceReq
- Response:
AddResourceResp
- request definition
|
|
- response definition
|
|
16. “修改资源”
- route definition
- Url: /api/v1/resource/:id
- Method: PUT
- Request:
SaveResourceReq
- Response:
SaveResourceResp
- request definition
|
|
- response definition
|
|
17. “删除资源”
- route definition
- Url: /api/v1/resource/:id
- Method: DELETE
- Request:
DeleteResourceReq
- Response:
DeleteResourceResp
- request definition
|
|
- response definition
|
|
18. “获取菜单资源树”
- route definition
- Url: /api/v1/resource/menu/tree
- Method: GET
- Request:
-
- Response:
GetResourceTreeResp
request definition
response definition
|
|
19. “给用户分配角色”
- route definition
- Url: /api/v1/assign/roles
- Method: PUT
- Request:
AssignRolesReq
- Response:
-
- request definition
|
|
- response definition
20. “新增角色”
- route definition
- Url: /api/v1/role
- Method: POST
- Request:
AddRoleReq
- Response:
AddRoleResp
- request definition
|
|
- response definition
|
|
21. “更新角色”
- route definition
- Url: /api/v1/role/:id
- Method: PUT
- Request:
UpdateRoleReq
- Response:
-
- request definition
|
|
- response definition
22. “删除角色”
- route definition
- Url: /api/v1/role/:id
- Method: DELETE
- Request:
DeleteRoleReq
- Response:
-
- request definition
|
|
- response definition
23. “查询角色”
- route definition
- Url: /api/v1/role/all
- Method: GET
- Request:
GetRoleAllReq
- Response:
GetRoleAllResp
- request definition
|
|
- response definition
|
|
24. “分页查询角色”
- route definition
- Url: /api/v1/role/page
- Method: GET
- Request:
GetRolePageReq
- Response:
GetRolePageResp
- request definition
|
|
- response definition
|
|
25. “分页查询系统参数”
- route definition
- Url: /api/v1/sys-param
- Method: GET
- Request:
GetSysParamReq
- Response:
GetSysParamResp
- request definition
|
|
- response definition
|
|
26. “新增系统参数”
- route definition
- Url: /api/v1/sys-param
- Method: POST
- Request:
AddSysParamReq
- Response:
AddSysParamResp
- request definition
|
|
- response definition
|
|
27. “修改系统参数”
- route definition
- Url: /api/v1/sys-param/:id
- Method: PUT
- Request:
UpdateSysParamReq
- Response:
-
- request definition
|
|
- response definition
28. “删除系统参数”
- route definition
- Url: /api/v1/sys-param/:id
- Method: DELETE
- Request:
DeleteSysParamReq
- Response:
-
- request definition
|
|
- response definition
29. “获取单个系统参数”
- route definition
- Url: /api/v1/sys-param/single
- Method: GET
- Request:
GetSysParamReq
- Response:
SysParam
- request definition
|
|
- response definition
|
|
30. “分页查询用户”
- route definition
- Url: /api/v1/user
- Method: GET
- Request:
GetUserPageReq
- Response:
GetUserPageResp
- request definition
|
|
- response definition
|
|
31. “更新角色”
- route definition
- Url: /api/v1/user/:id
- Method: PUT
- Request:
UpdateUserReq
- Response:
-
- request definition
|
|
- response definition
32. “获取全部角色”
- route definition
- Url: /api/v1/user/all
- Method: GET
- Request:
-
- Response:
GetUserPageResp
request definition
response definition
|
|
33. “获取用户详情”
- route definition
- Url: /api/v1/user/detail
- Method: GET
- Request:
-
- Response:
GetUserDetailResp
request definition
response definition
|
|
34. “用户修改密码”
- route definition
- Url: /api/v1/user/password/change
- Method: POST
- Request:
ChangeUserPasswordReq
- Response:
-
- request definition
|
|
- response definition
35. “重置密码”
- route definition
- Url: /api/v1/user/password/reset/:id
- Method: PUT
- Request:
ResetUserPasswordReq
- Response:
-
- request definition
|
|
- response definition
运维需求
MySQL 服务部署
使用 docker 部署,具体见 docker compose 文件
Redis 服务部署
使用 docker 部署,具体见 docker compose 文件
Nginx 服务部署
使用 docker 部署,具体见 docker compose 文件
/usr/local/nginx/nginx.conf
文件
|
|
/usr/local/nginx/conf.d/default.conf
文件
|
|
Docker Compose
新建 docker-compose.yaml 文件,写入下列内容:
|
|
执行命令:
|
|
前端部署
通过自写脚本,完成自动化发布流程:
- 打包
src
- 压缩
dist
目录成dist.tar.gz
- 把压缩包上传到服务器
- 服务器解压缩目录到
/usr/local/nginx/html
- 删除
dist.tar.gz
文件
|
|
后端部署
通过 ansible 进行自动化部署
inventory
文件:
|
|
ansible.yaml
文件:
|
|
Makefile
文件:
|
|
Prometheus 部署
- 下载 Prometheus 文件,并且放置到各个文件夹下
|
|
- 创建 Prometheus 服务
新建文件/etc/systemd/system/prometheus.service
|
|
- 启动服务
|
|
出现下列 active
信息即可,Prometheus
服务运行在:9090
端口
|
|
- Prometheus 配置文件:
/etc/prometheus/prometheus.yml
|
|
部署 Node Exporter
- 下载 node_exporter 文件,并且放置到各个文件夹下
|
|
- 创建 node_exporter 服务
新建文件/etc/systemd/system/node_exporter.service
|
|
- 启动服务
|
|
出现下列 active
信息即可,node_exporter
服务运行在:9100
端口
|
|
部署 MySQLd Exporter
- 下载 mysqld_exporter 文件,并且放置到各个文件夹下
|
|
- mysqld_exporter 配置文件:
/etc/prometheus/mysqld_exporter/my.cnf
|
|
- 创建 mysqld_exporter 服务
新建文件/etc/systemd/system/mysqld_exporter.service
|
|
- 启动服务
|
|
出现下列 active
信息即可,mysqld_exporter
服务运行在:9104
端口
|
|
部署 Redis Exporter
- 下载 redis_exporter 文件,并且放置到各个文件夹下
|
|
- 创建 redis_exporter 服务
新建文件/etc/systemd/system/redis_exporter.service
|
|
- 启动服务
|
|
出现下列 active
信息即可,redis_exporter
服务运行在:9121
端口
|
|
部署 Grafana
|
|
检测服务,服务运行在 :3000
端口:
|
|
遇到的问题
图片上传前后端交互
前端代码
|
|
后端代码
处理图片上传:
|
|
文件(图片)服务器
|
|
数据库软删除与唯一索引冲突
暂无解决方案
前端 json 展示
使用 vue-json-viewer 包
|
|