mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-15 15:30:26 +00:00
feat: now able to check all user's log
This commit is contained in:
@@ -35,7 +35,13 @@ func RecordLog(userId int, logType int, content string) {
|
||||
}
|
||||
|
||||
func GetAllLogs(logType int, startIdx int, num int) (logs []*Log, err error) {
|
||||
err = DB.Where("type = ?", logType).Order("id desc").Limit(num).Offset(startIdx).Find(&logs).Error
|
||||
var tx *gorm.DB
|
||||
if logType == LogTypeUnknown {
|
||||
tx = DB
|
||||
} else {
|
||||
tx = DB.Where("type = ?", logType)
|
||||
}
|
||||
err = tx.Order("id desc").Limit(num).Offset(startIdx).Find(&logs).Error
|
||||
return logs, err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user