Commit 8580d76d by CaIon

馃敡 refactor: Update formatUserLogs function to accept start index

Modified the formatUserLogs function to include a startIdx parameter, allowing for more flexible log ID assignment. Updated calls to this function in GetLogByTokenId and GetUserLogs to pass the appropriate starting index.
parent a30561d8
......@@ -50,7 +50,7 @@ const (
LogTypeRefund = 6
)
func formatUserLogs(logs []*Log) {
func formatUserLogs(logs []*Log, startIdx int) {
for i := range logs {
logs[i].ChannelName = ""
var otherMap map[string]interface{}
......@@ -61,13 +61,13 @@ func formatUserLogs(logs []*Log) {
delete(otherMap, "reject_reason")
}
logs[i].Other = common.MapToJsonStr(otherMap)
logs[i].Id = logs[i].Id % 1024
logs[i].Id = startIdx + i + 1
}
}
func GetLogByTokenId(tokenId int) (logs []*Log, err error) {
err = LOG_DB.Model(&Log{}).Where("token_id = ?", tokenId).Order("id desc").Limit(common.MaxRecentItems).Find(&logs).Error
formatUserLogs(logs)
formatUserLogs(logs, 0)
return logs, err
}
......@@ -310,7 +310,7 @@ func GetUserLogs(userId int, logType int, startTimestamp int64, endTimestamp int
return nil, 0, errors.New("鏌ヨ鏃ュ織澶辫触")
}
formatUserLogs(logs)
formatUserLogs(logs, startIdx)
return logs, total, err
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment