2025-09-19 04:08:42 +00:00
|
|
|
package entity
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"narasi-ahli-be/app/database/entity/users"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ChatMessages struct {
|
2025-09-22 13:05:40 +00:00
|
|
|
ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
|
|
|
|
|
ChatSessionID uint `json:"chat_session_id" gorm:"type:int4;not null;index"`
|
|
|
|
|
SenderID uint `json:"sender_id" gorm:"type:int4;not null;index"`
|
|
|
|
|
Message string `json:"message" gorm:"type:text;not null"`
|
|
|
|
|
MessageType string `json:"message_type" gorm:"type:varchar(20);not null;default:'text';check:message_type IN ('text', 'image', 'file', 'user', 'assistant')"` // 'text', 'image', 'file', 'user', 'assistant'
|
|
|
|
|
IsEdited bool `json:"is_edited" gorm:"default:false"`
|
|
|
|
|
EditedAt *time.Time `json:"edited_at"`
|
|
|
|
|
IsDeleted bool `json:"is_deleted" gorm:"default:false"`
|
|
|
|
|
DeletedAt *time.Time `json:"deleted_at"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"`
|
|
|
|
|
|
|
|
|
|
// Relationships
|
|
|
|
|
ChatSession *ChatSessions `json:"chat_session" gorm:"foreignKey:ChatSessionID;references:ID"`
|
|
|
|
|
Sender *users.Users `json:"sender" gorm:"foreignKey:SenderID;references:ID"`
|
2025-09-19 04:08:42 +00:00
|
|
|
}
|