77 lines
2.0 KiB
Plaintext
77 lines
2.0 KiB
Plaintext
syntax = "v1"
|
|
import "common.api"
|
|
|
|
type (
|
|
SessionIdReq {
|
|
Id int64 `path:"id"`
|
|
}
|
|
|
|
ChatSession {
|
|
Id int64 `json:"id"`
|
|
Type string `json:"type"` // order, consultation
|
|
OrderId string `json:"orderId,optional"`
|
|
Participants []SimpleUser `json:"participants"`
|
|
LastMessage string `json:"lastMessage"`
|
|
UnreadCount int `json:"unreadCount"`
|
|
}
|
|
|
|
ChatSessionListResp {
|
|
Items []ChatSession `json:"items"`
|
|
Meta PageMeta `json:"meta"`
|
|
}
|
|
|
|
ChatMessage {
|
|
Id int64 `json:"id"`
|
|
SessionId string `json:"sessionId"`
|
|
SenderId string `json:"senderId"`
|
|
Type string `json:"type"` // text, image, system
|
|
Content string `json:"content"`
|
|
CreatedAt string `json:"createdAt"`
|
|
}
|
|
|
|
ChatMessageListResp {
|
|
Items []ChatMessage `json:"items"`
|
|
Meta PageMeta `json:"meta"`
|
|
}
|
|
|
|
SendMessageReq {
|
|
SessionIdReq
|
|
Type string `json:"type"`
|
|
Content string `json:"content"`
|
|
}
|
|
|
|
ListMessageReq {
|
|
SessionIdReq
|
|
PageReq
|
|
}
|
|
)
|
|
|
|
@server(
|
|
prefix: api/v1/chat
|
|
group: chat
|
|
)
|
|
service juwan-api {
|
|
@doc "获取会话列表"
|
|
@handler ListSessions
|
|
get /sessions (PageReq) returns (ChatSessionListResp)
|
|
|
|
@doc "获取会话详情"
|
|
@handler GetSession
|
|
get /sessions/:id (SessionIdReq) returns (ChatSession)
|
|
|
|
@doc "获取消息历史"
|
|
@handler ListMessages
|
|
get /sessions/:id/messages (ListMessageReq) returns (ChatMessageListResp)
|
|
|
|
@doc "发送消息"
|
|
@handler SendMessage
|
|
post /sessions/:id/messages (SendMessageReq) returns (ChatMessage)
|
|
|
|
@doc "创建/获取订单会话"
|
|
@handler EnsureOrderSession
|
|
post /sessions/order (EmptyResp) returns (ChatSession)
|
|
|
|
@doc "创建咨询会话"
|
|
@handler CreateConsultation
|
|
post /sessions/consultation (EmptyResp) returns (ChatSession)
|
|
} |