fix: 域能系统全量检查 — 修复 5 个逻辑/交互 Gap
- 修复 Admin 改名路径未扣域能(非审核路径补充 HasCompletedTask + DeductOnRename) - 赋能按钮改为 Modal 弹窗(轻赋/重赋选择 + 每日上限提示) - EnergyInfo API 增加 daily_energize_exp/daily_exp_cap_reached 返回值 - "我的域能" TAB 增加经验值和等级展示 - Energize 事务修复:导出 EnergyStore + WithTx 方法确保 DB 操作原子性 - Studio 写文章页新增 LV0 锁止横幅 + 禁用提交按钮
This commit is contained in:
@ -69,6 +69,29 @@ func (sc *SettingsController) UpdateProfile(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 管理员及以上直接更新
|
||||
// 先获取当前用户信息,判断是否改名
|
||||
currentUser, err := sc.authService.GetProfile(userID)
|
||||
if err != nil {
|
||||
common.Error(c, http.StatusInternalServerError, "操作失败")
|
||||
return
|
||||
}
|
||||
|
||||
// 改名:首次免费,非首次扣 6 域能
|
||||
if req.Username != "" && req.Username != currentUser.Username && sc.energySvc != nil {
|
||||
hasCompleted, _ := sc.levelSvc.HasCompletedTask(userID, "username")
|
||||
if hasCompleted {
|
||||
if err := sc.energySvc.DeductOnRename(userID); err != nil {
|
||||
switch err {
|
||||
case common.ErrInsufficientEnergy:
|
||||
common.Error(c, http.StatusBadRequest, "域能不足,无法改名。可通过每日签到或创作被赋能获取")
|
||||
default:
|
||||
common.Error(c, http.StatusInternalServerError, "操作失败")
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := sc.authService.UpdateProfile(userID, req.Username, req.Bio); err != nil {
|
||||
handleSettingsError(c, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user