feat(user): 支持后台调整等级并限制极品专区可见性

This commit is contained in:
yml2213
2026-11-05 12:02:48 +08:00
parent 09f244a93d
commit 0d558bdce0
35 changed files with 934 additions and 131 deletions
@@ -144,6 +144,29 @@ func (h *Handler) AdjustGrowthPoints(c *gin.Context) {
response.OK(c, item)
}
func (h *Handler) AdjustGrowthLevel(c *gin.Context) {
adminID, ok := currentAdminID(c)
if !ok {
response.Unauthorized(c, "缺少管理员上下文")
return
}
userID, ok := parseID(c)
if !ok {
return
}
var req GrowthLevelAdjustRequest
if err := c.ShouldBindJSON(&req); err != nil {
response.BadRequest(c, "成长等级调整参数不正确")
return
}
item, err := h.service.AdjustGrowthLevel(c.Request.Context(), adminID, userID, req, auditMeta(c))
if err != nil {
writeAdminUserError(c, err)
return
}
response.OK(c, item)
}
func (h *Handler) RevokeRealname(c *gin.Context) {
adminID, ok := currentAdminID(c)
if !ok {
@@ -265,6 +288,12 @@ func writeAdminUserError(c *gin.Context, err error) {
response.BadRequest(c, "请填写 2-200 字的积分调整原因")
case errors.Is(err, ErrGrowthPointsUnchanged):
response.Error(c, http.StatusConflict, "growth_points_unchanged", "目标积分与当前积分相同")
case errors.Is(err, ErrInvalidGrowthLevel):
response.BadRequest(c, "目标成长等级不正确")
case errors.Is(err, ErrInvalidGrowthLevelReason):
response.BadRequest(c, "请填写 2-200 字的等级调整原因")
case errors.Is(err, ErrGrowthLevelUnchanged):
response.Error(c, http.StatusConflict, "growth_level_unchanged", "目标等级与当前手动等级相同")
case IsNotFound(err):
response.Error(c, http.StatusNotFound, "not_found", "用户不存在")
default: