完成websocket对话演示和main方法的功能抽离
This commit is contained in:
@@ -502,6 +502,11 @@ func GetUserState(ctx context.Context, userId, platform string) (state *UserStat
|
||||
|
||||
state = &UserState{Stage: 5} // 默认状态5(未选择方向)
|
||||
if result.IsEmpty() {
|
||||
// Redis为空,初始化默认状态
|
||||
if initErr := SetUserStage(ctx, userId, platform, 5); initErr != nil {
|
||||
err = initErr
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,15 @@ type HistoryMessage struct {
|
||||
|
||||
// SendStreamMessage 发送到 Redis Stream 的消息结构
|
||||
type SendStreamMessage struct {
|
||||
UserId string `json:"user_id"` // 用户ID
|
||||
Content string `json:"content"` // 消息内容
|
||||
Timestamp int64 `json:"timestamp"` // 时间戳(秒)
|
||||
MessageId string `json:"message_id"` // 消息唯一ID
|
||||
Platform string `json:"platform,omitempty"` // 平台标识
|
||||
AccountId string `json:"account_id,omitempty"` // 账号ID
|
||||
TenantId string `json:"tenant_id,omitempty"` // 租户ID(数据隔离)
|
||||
History []HistoryMessage `json:"history,omitempty"` // 历史对话(归档后恢复时携带)
|
||||
UserId string `json:"user_id"` // 用户ID
|
||||
Content string `json:"content"` // 消息内容
|
||||
Timestamp int64 `json:"timestamp"` // 时间戳(秒)
|
||||
MessageId string `json:"message_id"` // 消息唯一ID
|
||||
Platform string `json:"platform,omitempty"` // 平台标识
|
||||
AccountId string `json:"account_id,omitempty"` // 账号ID
|
||||
TenantId string `json:"tenant_id,omitempty"` // 租户ID(数据隔离)
|
||||
ReplyQueue string `json:"reply_queue,omitempty"` // 响应队列名称(支持多实例独立队列)
|
||||
History []HistoryMessage `json:"history,omitempty"` // 历史对话(归档后恢复时携带)
|
||||
}
|
||||
|
||||
// BatchStreamMessage 批量消息结构
|
||||
|
||||
Reference in New Issue
Block a user