|
|
@@ -918,6 +918,11 @@ func ManageUser(c *gin.Context) {
|
|
|
user.Role = common.RoleCommonUser
|
|
|
case "add_quota":
|
|
|
adminName := c.GetString("username")
|
|
|
+ adminId := c.GetInt("id")
|
|
|
+ adminInfo := map[string]interface{}{
|
|
|
+ "admin_id": adminId,
|
|
|
+ "admin_username": adminName,
|
|
|
+ }
|
|
|
switch req.Mode {
|
|
|
case "add":
|
|
|
if req.Value <= 0 {
|
|
|
@@ -928,8 +933,8 @@ func ManageUser(c *gin.Context) {
|
|
|
common.ApiError(c, err)
|
|
|
return
|
|
|
}
|
|
|
- model.RecordLog(user.Id, model.LogTypeManage,
|
|
|
- fmt.Sprintf("管理员(%s)增加用户额度 %s", adminName, logger.LogQuota(req.Value)))
|
|
|
+ model.RecordLogWithAdminInfo(user.Id, model.LogTypeManage,
|
|
|
+ fmt.Sprintf("管理员增加用户额度 %s", logger.LogQuota(req.Value)), adminInfo)
|
|
|
case "subtract":
|
|
|
if req.Value <= 0 {
|
|
|
common.ApiErrorI18n(c, i18n.MsgUserQuotaChangeZero)
|
|
|
@@ -939,16 +944,16 @@ func ManageUser(c *gin.Context) {
|
|
|
common.ApiError(c, err)
|
|
|
return
|
|
|
}
|
|
|
- model.RecordLog(user.Id, model.LogTypeManage,
|
|
|
- fmt.Sprintf("管理员(%s)减少用户额度 %s", adminName, logger.LogQuota(req.Value)))
|
|
|
+ model.RecordLogWithAdminInfo(user.Id, model.LogTypeManage,
|
|
|
+ fmt.Sprintf("管理员减少用户额度 %s", logger.LogQuota(req.Value)), adminInfo)
|
|
|
case "override":
|
|
|
oldQuota := user.Quota
|
|
|
if err := model.DB.Model(&model.User{}).Where("id = ?", user.Id).Update("quota", req.Value).Error; err != nil {
|
|
|
common.ApiError(c, err)
|
|
|
return
|
|
|
}
|
|
|
- model.RecordLog(user.Id, model.LogTypeManage,
|
|
|
- fmt.Sprintf("管理员(%s)覆盖用户额度从 %s 为 %s", adminName, logger.LogQuota(oldQuota), logger.LogQuota(req.Value)))
|
|
|
+ model.RecordLogWithAdminInfo(user.Id, model.LogTypeManage,
|
|
|
+ fmt.Sprintf("管理员覆盖用户额度从 %s 为 %s", logger.LogQuota(oldQuota), logger.LogQuota(req.Value)), adminInfo)
|
|
|
default:
|
|
|
common.ApiErrorI18n(c, i18n.MsgInvalidParams)
|
|
|
return
|