|
@@ -16,13 +16,7 @@ type UserLlmChat struct {
|
|
|
UpdateTime time.Time `gorm:"autoUpdateTime;comment:更新时间"`
|
|
|
}
|
|
|
|
|
|
-type UserLlmChatListItem struct {
|
|
|
- Id int `gorm:"primaryKey;autoIncrement;comment:会话主键"`
|
|
|
- UserId int `gorm:"comment:用户id"`
|
|
|
- ChatTitle string `gorm:"comment:会话标题"`
|
|
|
- CreatedTime time.Time `gorm:"comment:创建时间"`
|
|
|
- RecordCount int `gorm:"comment:会话记录数"`
|
|
|
-}
|
|
|
+
|
|
|
type UserLlmChatListViewItem struct {
|
|
|
Id int `gorm:"primaryKey;autoIncrement;comment:会话主键"`
|
|
|
UserId int `gorm:"comment:用户id"`
|
|
@@ -31,13 +25,12 @@ type UserLlmChatListViewItem struct {
|
|
|
RecordCount int `gorm:"comment:会话记录数"`
|
|
|
}
|
|
|
|
|
|
-func CovertItemToView(item UserLlmChatListItem) UserLlmChatListViewItem {
|
|
|
+func CovertItemToView(item UserLlmChat) UserLlmChatListViewItem {
|
|
|
return UserLlmChatListViewItem{
|
|
|
Id: item.Id,
|
|
|
UserId: item.UserId,
|
|
|
ChatTitle: item.ChatTitle,
|
|
|
CreatedTime: item.CreatedTime.Format(utils.FormatDateTime),
|
|
|
- RecordCount: item.RecordCount,
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -72,10 +65,9 @@ func (u *UserLlmChat) DeleteChatSession() (err error) {
|
|
|
err = o.Select("is_deleted").Updates(u).Error
|
|
|
return
|
|
|
}
|
|
|
-func GetUserChatList(userId int, monDay, toDay string) (chatList []UserLlmChatListItem, err error) {
|
|
|
+func GetUserChatList(userId int, monDay, toDay string) (chatList []UserLlmChat, err error) {
|
|
|
o := global.DbMap[utils.DbNameAI]
|
|
|
- sql := `select ulc.id AS id ,ulc.user_id as user_id,ulc.chat_title as chat_title,ulc.created_time,COUNT(ucr.id) AS record_count from user_llm_chat ulc left join user_chat_record ucr
|
|
|
- ON ucr.chat_id = ulc.id where ulc.user_id=? and ` + utils.GenerateQuerySql(utils.ToDate, &utils.QueryParam{Column: "ulc.created_time"}) + ` BETWEEN ? and ? AND is_deleted=0 GROUP BY ulc.id order by ulc.created_time desc`
|
|
|
+ sql := `select ulc.id AS id ,ulc.user_id as user_id,ulc.chat_title as chat_title,ulc.created_time from user_llm_chat ulc where ulc.user_id=? and ` + utils.GenerateQuerySql(utils.ToDate, &utils.QueryParam{Column: "ulc.created_time"}) + ` BETWEEN ? and ? AND is_deleted=0 GROUP BY ulc.id order by ulc.created_time desc`
|
|
|
err = o.Raw(sql, userId, monDay, toDay).Find(&chatList).Error
|
|
|
return
|
|
|
}
|