77 lines
2.9 KiB
Go
77 lines
2.9 KiB
Go
// Package model -----------------------------
|
|
// @file : chatRecord.go
|
|
// @author : JJXu
|
|
// @contact : wavingbear@163.com
|
|
// @time : 2024/9/10 下午3:23
|
|
// -------------------------------------------
|
|
package model
|
|
|
|
import (
|
|
"gorm.io/plugin/soft_delete"
|
|
"time"
|
|
)
|
|
|
|
type Model struct {
|
|
ID int64 `gorm:"primarykey;" json:"id" form:"id"`
|
|
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
|
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
|
|
DeletedAt soft_delete.DeletedAt `gorm:"column:deleted_at;type:bigint;default:0" json:"deletedAt"`
|
|
}
|
|
type ChatRecord struct {
|
|
Model
|
|
SessionId string `gorm:"column:session_id;comment:会话ID"`
|
|
Domain string `gorm:"column:domain;comment:域"`
|
|
UserId int64 `gorm:"column:user_id;comment:账号ID"`
|
|
Name string `gorm:"column:name;comment:名称"`
|
|
Avatar string `gorm:"column:avatar;comment:头像"`
|
|
MsgType int32 `gorm:"column:msg_type;comment:消息类型"`
|
|
Content string `gorm:"column:content;type:varchar(2000);comment:消息内容"`
|
|
Medias []*ChatMedia `gorm:"many2many:chat_record_media;"`
|
|
WaiterRead int32 `gorm:"column:waiter_read;default:2;comment:客服是否已读 1=已读 2=未读"` // (被任意客服读取过均为已读)
|
|
LocalStamp int64 `gorm:"column:local_stamp;comment:用户端的消息唯一值,用于用户端的消息校验"`
|
|
}
|
|
|
|
func (c ChatRecord) TableName() string {
|
|
return "chat_record"
|
|
}
|
|
|
|
type ChatMedia struct {
|
|
Model
|
|
//MediaType int32 `gorm:"column:media_type;comment:媒体类型"`
|
|
Url string `gorm:"column:url;comment:url"`
|
|
Md5 string `gorm:"column:md5;comment:md5值"`
|
|
Size string `gorm:"column:size;comment:尺寸"`
|
|
Ext string `gorm:"column:ext;comment:后缀格式"`
|
|
ConvText string `gorm:"column:conv_text;type:varchar(2000);comment:语音转文字内容"`
|
|
Duration int64 `gorm:"column:duration;comment:时长 单位为ms"`
|
|
}
|
|
|
|
func (c ChatRecord) ChatMedia() string {
|
|
return "chat_media"
|
|
}
|
|
|
|
type ChatAutoReplyRuler struct {
|
|
Model
|
|
Title string `gorm:"column:title;comment:标题"`
|
|
Ruler string `gorm:"column:ruler;type:varchar(2000);comment:规则内容"`
|
|
RulerStatus int32 `gorm:"column:ruler_status;comment:规则状态: 1=启用 2=禁用"`
|
|
}
|
|
|
|
func (c ChatRecord) AutoChatRuler() string {
|
|
return "chat_auto_reply_ruler"
|
|
}
|
|
|
|
type ChatUser struct {
|
|
Model
|
|
NickName string `gorm:"column:nick_name;comment:昵称"`
|
|
Account string `gorm:"column:account;comment:账号"`
|
|
Role int32 `gorm:"column:role;default:1;comment:聊天角色 1=用户 2=客服"`
|
|
Origin string `gorm:"column:origin;default:'fiee';comment:数据来源"`
|
|
OriginId int64 `gorm:"column:origin_id;comment:数据来源对应的用户ID"`
|
|
Avatar string `gorm:"column:avatar;comment:头像"`
|
|
}
|
|
|
|
func (c ChatUser) TableName() string {
|
|
return "chat_user"
|
|
}
|