后端: Go(Gin+GORM+MySQL+Redis) - 17张业务表(yz_pw_前缀), 自动迁移 - JWT认证(3小时) + 盐+MD5密码 + 图形验证码 - 班级CRUD/加入(8人姓名验证/邀请码)/审核/30天自动清理 - 系统配置(16项)/菜单管理(动态路由)/数据统计 - 文件MD5去重/数据隔离/账号封禁/敏感词DFA检测 前端: Vue3+Vite+Element Plus+Less+ECharts+FontAwesome - 动态路由(数据库菜单驱动) - 蓝白配色, H5响应式 - 登录/注册/忘记密码/个人中心 - 班级创建向导/详情/加入/列表 - 管理后台: 审核/配置/菜单/统计/用户/敏感词 数据库: MySQL 10.31.100.3:3306/photowall 管理员: hero920103 / 920103
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package handler
|
|
|
|
import (
|
|
"photowall/internal/service"
|
|
"photowall/pkg/response"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type ConfigHandler struct {
|
|
cfg *service.ConfigService
|
|
}
|
|
|
|
func NewConfigHandler(cfg *service.ConfigService) *ConfigHandler {
|
|
return &ConfigHandler{cfg: cfg}
|
|
}
|
|
|
|
// GetAll GET /api/admin/config 获取所有系统配置
|
|
func (h *ConfigHandler) GetAll(c *gin.Context) {
|
|
list, err := h.cfg.GetAll()
|
|
if err != nil {
|
|
response.Internal(c, "获取配置失败")
|
|
return
|
|
}
|
|
// 按分类分组返回
|
|
result := gin.H{
|
|
"basic": []gin.H{},
|
|
"geetest": []gin.H{},
|
|
"sms": []gin.H{},
|
|
"wechat": []gin.H{},
|
|
"storage": []gin.H{},
|
|
}
|
|
for _, item := range list {
|
|
result[item.Category] = append(result[item.Category].([]gin.H), gin.H{
|
|
"key": item.Key,
|
|
"value": item.Value,
|
|
"label": item.Label,
|
|
"description": item.Description,
|
|
"placeholder": item.Placeholder,
|
|
"doc_link": item.DocLink,
|
|
})
|
|
}
|
|
response.OK(c, result)
|
|
}
|
|
|
|
// Update PUT /api/admin/config 批量更新配置
|
|
func (h *ConfigHandler) Update(c *gin.Context) {
|
|
var req service.UpdateConfigReq
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
response.BadRequest(c, "参数错误:"+err.Error())
|
|
return
|
|
}
|
|
if err := h.cfg.Update(&req); err != nil {
|
|
response.Internal(c, "更新配置失败")
|
|
return
|
|
}
|
|
response.OK(c, gin.H{"message": "配置更新成功,部分配置需重启服务生效"})
|
|
}
|