42 lines
1.8 KiB
Go
42 lines
1.8 KiB
Go
package app
|
|
|
|
import (
|
|
"git.echol.cn/loser/st/server/global"
|
|
"gorm.io/datatypes"
|
|
"time"
|
|
)
|
|
|
|
// AIChat 对话表
|
|
type AIChat struct {
|
|
global.GVA_MODEL
|
|
Title string `json:"title" gorm:"type:varchar(500);default:新对话;comment:对话标题"`
|
|
UserID uint `json:"userId" gorm:"not null;index;comment:所属用户ID"`
|
|
User *AppUser `json:"user" gorm:"foreignKey:UserID"`
|
|
CharacterID *uint `json:"characterId" gorm:"index;comment:关联角色ID"`
|
|
Character *AICharacter `json:"character" gorm:"foreignKey:CharacterID"`
|
|
ChatType string `json:"chatType" gorm:"type:varchar(50);default:single;comment:对话类型"`
|
|
Settings datatypes.JSON `json:"settings" gorm:"type:jsonb;comment:对话设置"`
|
|
LastMessageAt *time.Time `json:"lastMessageAt" gorm:"index;comment:最后一条消息时间"`
|
|
MessageCount int `json:"messageCount" gorm:"default:0;comment:消息数量"`
|
|
IsPinned bool `json:"isPinned" gorm:"default:false;comment:是否固定"`
|
|
}
|
|
|
|
func (AIChat) TableName() string {
|
|
return "ai_chats"
|
|
}
|
|
|
|
// AIChatMember 群聊成员表
|
|
type AIChatMember struct {
|
|
global.GVA_MODEL
|
|
ChatID uint `json:"chatId" gorm:"not null;index:idx_chat_character,unique;comment:对话ID"`
|
|
Chat *AIChat `json:"chat" gorm:"foreignKey:ChatID"`
|
|
CharacterID uint `json:"characterId" gorm:"not null;index:idx_chat_character,unique;comment:角色ID"`
|
|
Character *AICharacter `json:"character" gorm:"foreignKey:CharacterID"`
|
|
DisplayOrder int `json:"displayOrder" gorm:"default:0;comment:显示顺序"`
|
|
Settings datatypes.JSON `json:"settings" gorm:"type:jsonb;comment:成员设置"`
|
|
}
|
|
|
|
func (AIChatMember) TableName() string {
|
|
return "ai_chat_members"
|
|
}
|