fonchain-fiee/pkg/service/asChat/dto.go
2025-06-12 19:31:40 +08:00

137 lines
4.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Package asChat -----------------------------
// @file : dto.go
// @author : JJXu
// @contact : wavingbear@163.com
// @time : 2024/9/10 下午6:28
// -------------------------------------------
package asChat
import (
"encoding/json"
"fonchain-fiee/api/accountFiee"
"time"
)
type Message struct {
MsgType accountFiee.MsgType `json:"msgType"`
Text string `json:"text"` //文本内容
Media []MessageMedia `json:"media"`
LocalStamp int64 `json:"localStamp"`
}
type MessageMedia struct {
MediaId int64 `json:"mediaId"` //媒体文件id
MediaSize string `json:"mediaSize"` //媒体文件大小
Ext string `json:"ext"` //后缀格式
Url string `json:"url"` //文件地址
ConvText string `json:"convText"` //语音转文字内容,需要调用语音转文字接口后才会有值
Duration int64 `json:"duration"` //时长 单位:毫秒
}
// 客户端发送消息请求使用api发送消息
type NewMessageRequest struct {
Waiter bool `json:"waiter"` //是否是客服发送,客服没有userId
SessionId string `json:"sessionId"`
Message
}
// 服务端接收到消息后使用websocket发送给userId关联的客户端通知客户端有新消息然后调用接口获取消息
type NewMessageNotice struct {
Name string `json:"name"` //名字
UserId int64 `json:"userId"` //用户id
SessionId string `json:"sessionId"`
MessageId int64 `json:"messageId"` //消息id
//NewMsgTotal int64 `json:"newMsgTotal"` //新消息数量
//Active bool `json:"active"` //是否在线
}
// 获取会话列表
type SessionType struct {
NewMessageNotice
RecentMessage []*Message `json:"recentMessage"` //最近消息
}
type MessageListType struct {
ID int64 `json:"ID"`
CreatedAt string `json:"createdAt"`
UserId int64 `json:"userId"`
Name string `json:"name"`
Message Message `json:"message"`
}
func (m *MessageListType) BuildMessage(data *accountFiee.ChatRecordData) {
m.ID = data.ID
m.CreatedAt = data.CreatedAt
m.UserId = data.UserId
m.Name = data.Name
switch data.MsgType {
case accountFiee.MsgType_TextMsgType:
m.Message = Message{
MsgType: accountFiee.MsgType_TextMsgType,
Text: data.Content,
Media: []MessageMedia{},
LocalStamp: data.LocalStamp,
}
case accountFiee.MsgType_ImageMsgType, accountFiee.MsgType_AudioMsgType, accountFiee.MsgType_VideoMsgType:
m.Message.MsgType = data.MsgType
m.Message.Text = data.Content
m.Message.LocalStamp = data.LocalStamp
if data.Medias != nil {
for _, media := range data.Medias {
m.Message.Media = append(m.Message.Media, MessageMedia{
MediaId: media.ID,
MediaSize: media.Size,
Ext: media.Ext,
Url: media.Url,
ConvText: media.ConvText,
Duration: media.Duration,
})
}
}
}
}
func (m *MessageListType) ToJson() string {
jsonBytes, _ := json.Marshal(m)
return string(jsonBytes)
}
type UserMsgStatic struct {
UserId int64 `json:"userId"` //用户id
Name string `json:"name"` //名称
ArtistUid string `json:"artistUid,omitempty"`
SessionId string `json:"sessionId"` //会话id
Total int64 `json:"total"` //新消息数量
//NewMessageTime string `json:"newMessageTime"` //最新消息的创建时间
}
type MessageListRequest struct {
SessionId string `json:"sessionId"` //不传则获取自己的会话消息里列表
CurrentId int64 `json:"currentId"` //组合查询条件1基于某个消息id向前或向后查找。两种组合条件不能同时使用
Direction int `json:"direction"` //组合查询条件1方向 1=向前查找 2=向后查找
Recent bool `json:"recent"` //组合查询条件2查找最新的若干条消息。两种组合条件不能同时使用
InHour time.Duration `json:"inHour"` //组合查询条件2可选查询指定小时内的数据
PageSize int64 `json:"pageSize"` //查找数量
}
type VoiceToTextRequest struct {
MediaId int64 `json:"mediaId"`
}
type ArtistInfoRequest struct {
UserId int64 `json:"userId"`
}
type ArtistInfo struct {
Tnum string `json:"tnum"`
ArtistName string `json:"artistName"`
Age int64 `json:"age"`
Sex string `json:"sex"`
NativePlace string `json:"nativePlace"`
TelNum string `json:"telNum"`
RecentPhoto string `json:"recentPhoto"`
}
type GetChatAutoReplyRulerListRequest struct {
Page int64 `json:"page"`
PageSize int64 `json:"pageSize"`
accountFiee.ChatAutoReplyRulerData
}