diff --git a/controller/user.go b/controller/user.go
index 045e0841..09eaccd1 100644
--- a/controller/user.go
+++ b/controller/user.go
@@ -2,6 +2,7 @@ package controller
import (
"encoding/json"
+ "fmt"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"net/http"
@@ -351,6 +352,9 @@ func UpdateUser(c *gin.Context) {
})
return
}
+ if originUser.Quota != updatedUser.Quota {
+ model.RecordLog(originUser.Id, model.LogTypeManage, fmt.Sprintf("管理员将用户额度从 %d 点修改为 %d 点", originUser.Quota, updatedUser.Quota))
+ }
c.JSON(http.StatusOK, gin.H{
"success": true,
"message": "",
diff --git a/model/log.go b/model/log.go
index 493f5613..bc096055 100644
--- a/model/log.go
+++ b/model/log.go
@@ -17,6 +17,8 @@ const (
LogTypeUnknown = iota
LogTypeTopup
LogTypeConsume
+ LogTypeManage
+ LogTypeSystem
)
func RecordLog(userId int, logType int, content string) {
diff --git a/model/user.go b/model/user.go
index 23a97896..60278a07 100644
--- a/model/user.go
+++ b/model/user.go
@@ -2,6 +2,7 @@ package model
import (
"errors"
+ "fmt"
"gorm.io/gorm"
"one-api/common"
"strings"
@@ -73,8 +74,14 @@ func (user *User) Insert() error {
}
user.Quota = common.QuotaForNewUser
user.AccessToken = common.GetUUID()
- err = DB.Create(user).Error
- return err
+ result := DB.Create(user)
+ if result.Error != nil {
+ return result.Error
+ }
+ if common.QuotaForNewUser > 0 {
+ RecordLog(user.Id, LogTypeSystem, fmt.Sprintf("新用户注册赠送 %d 点额度", common.QuotaForNewUser))
+ }
+ return nil
}
func (user *User) Update(updatePassword bool) error {
diff --git a/web/src/components/LogsTable.js b/web/src/components/LogsTable.js
index a27ffbc3..1c623898 100644
--- a/web/src/components/LogsTable.js
+++ b/web/src/components/LogsTable.js
@@ -18,6 +18,10 @@ function renderType(type) {
return ;
case 2:
return ;
+ case 3:
+ return ;
+ case 4:
+ return ;
default:
return ;
}