mirror of
https://github.com/linux-do/new-api.git
synced 2025-10-15 20:03:41 +08:00
chore: add more log types
This commit is contained in:
@@ -17,6 +17,8 @@ const (
|
||||
LogTypeUnknown = iota
|
||||
LogTypeTopup
|
||||
LogTypeConsume
|
||||
LogTypeManage
|
||||
LogTypeSystem
|
||||
)
|
||||
|
||||
func RecordLog(userId int, logType int, content string) {
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user