feat: now able to check all user's log

This commit is contained in:
JustSong
2023-06-10 20:40:07 +08:00
parent 0b4bf30908
commit 64db39320a
2 changed files with 79 additions and 7 deletions

View File

@@ -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
}