diff --git a/model/log.go b/model/log.go index 4a633a6a..dd5a3162 100644 --- a/model/log.go +++ b/model/log.go @@ -27,6 +27,7 @@ type Log struct { UseTime int `json:"use_time" gorm:"default:0"` IsStream bool `json:"is_stream" gorm:"default:false"` ChannelId int `json:"channel" gorm:"index"` + ChannelName string `json:"channel_name" gorm:"->"` TokenId int `json:"token_id" gorm:"default:0;index"` Group string `json:"group" gorm:"index"` Other string `json:"other"` @@ -130,6 +131,10 @@ func GetAllLogs(logType int, startTimestamp int64, endTimestamp int64, modelName } else { tx = LOG_DB.Where("type = ?", logType) } + + tx = tx.Joins("LEFT JOIN channels ON logs.channel_id = channels.id") + tx = tx.Select("logs.*, channels.name as channel_name") + if modelName != "" { tx = tx.Where("model_name like ?", modelName) } @@ -169,6 +174,10 @@ func GetUserLogs(userId int, logType int, startTimestamp int64, endTimestamp int } else { tx = LOG_DB.Where("user_id = ? and type = ?", userId, logType) } + + tx = tx.Joins("LEFT JOIN channels ON logs.channel_id = channels.id") + tx = tx.Select("logs.*, channels.name as channel_name") + if modelName != "" { tx = tx.Where("model_name like ?", modelName) } diff --git a/web/src/components/LogsTable.js b/web/src/components/LogsTable.js index 452585a1..7acc2cc4 100644 --- a/web/src/components/LogsTable.js +++ b/web/src/components/LogsTable.js @@ -157,13 +157,15 @@ const LogsTable = () => { record.type === 0 || record.type === 2 ? (