From d15e14b117584294f94f0a9ee19f0c3d24c35db1 Mon Sep 17 00:00:00 2001 From: feitianbubu Date: Mon, 13 Apr 2026 15:47:15 +0800 Subject: [PATCH] feat: include admin username in quota adjustment logs --- controller/user.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/controller/user.go b/controller/user.go index 7921e337..a12d5c66 100644 --- a/controller/user.go +++ b/controller/user.go @@ -912,6 +912,7 @@ func ManageUser(c *gin.Context) { } user.Role = common.RoleCommonUser case "add_quota": + adminName := c.GetString("username") switch req.Mode { case "add": if req.Value <= 0 { @@ -923,7 +924,7 @@ func ManageUser(c *gin.Context) { return } model.RecordLog(user.Id, model.LogTypeManage, - fmt.Sprintf("管理员增加用户额度 %s", logger.LogQuota(req.Value))) + fmt.Sprintf("管理员(%s)增加用户额度 %s", adminName, logger.LogQuota(req.Value))) case "subtract": if req.Value <= 0 { common.ApiErrorI18n(c, i18n.MsgUserQuotaChangeZero) @@ -934,7 +935,7 @@ func ManageUser(c *gin.Context) { return } model.RecordLog(user.Id, model.LogTypeManage, - fmt.Sprintf("管理员减少用户额度 %s", logger.LogQuota(req.Value))) + fmt.Sprintf("管理员(%s)减少用户额度 %s", adminName, logger.LogQuota(req.Value))) case "override": oldQuota := user.Quota if err := model.DB.Model(&model.User{}).Where("id = ?", user.Id).Update("quota", req.Value).Error; err != nil { @@ -942,7 +943,7 @@ func ManageUser(c *gin.Context) { return } model.RecordLog(user.Id, model.LogTypeManage, - fmt.Sprintf("管理员覆盖用户额度从 %s 为 %s", logger.LogQuota(oldQuota), logger.LogQuota(req.Value))) + fmt.Sprintf("管理员(%s)覆盖用户额度从 %s 为 %s", adminName, logger.LogQuota(oldQuota), logger.LogQuota(req.Value))) default: common.ApiErrorI18n(c, i18n.MsgInvalidParams) return