|
@@ -129,19 +129,20 @@ func SaveChatRecordsToDB(chatId int) error {
|
|
|
}
|
|
|
var newRecords []*llm.UserChatRecord
|
|
|
for _, record := range list {
|
|
|
- //if record.Id == 0 {
|
|
|
- sendTime, parseErr := time.Parse(utils.FormatDateTime, record.SendTime)
|
|
|
- if parseErr != nil {
|
|
|
- sendTime = time.Now()
|
|
|
+ if record.Id == 0 {
|
|
|
+ sendTime, parseErr := time.Parse(utils.FormatDateTime, record.SendTime)
|
|
|
+ if parseErr != nil {
|
|
|
+ sendTime = time.Now()
|
|
|
+ }
|
|
|
+ newRecords = append(newRecords, &llm.UserChatRecord{
|
|
|
+ Id: record.Id,
|
|
|
+ ChatId: record.ChatId,
|
|
|
+ ChatUserType: record.ChatUserType,
|
|
|
+ Content: record.Content,
|
|
|
+ SendTime: sendTime,
|
|
|
+ CreatedTime: time.Now(),
|
|
|
+ })
|
|
|
}
|
|
|
- newRecords = append(newRecords, &llm.UserChatRecord{
|
|
|
- ChatId: record.ChatId,
|
|
|
- ChatUserType: record.ChatUserType,
|
|
|
- Content: record.Content,
|
|
|
- SendTime: sendTime,
|
|
|
- CreatedTime: time.Now(),
|
|
|
- })
|
|
|
- //}
|
|
|
}
|
|
|
key := fmt.Sprintf("%s%d", redisChatPrefix, chatId)
|
|
|
holder, _ := uuid.NewRandom()
|