Files
juwan-backend/desc/api/chat.api
T
wwweww 19cc7a778c Refactor: Remove deprecated gRPC service files and implement new API structure
- Deleted old gRPC service definitions in `game_grpc.pb.go` and `public.go`.
- Added new API server implementations for objectstory, player, and shop services.
- Introduced configuration files for new APIs in `etc/*.yaml`.
- Created main entry points for each service in `objectstory.go`, `player.go`, and `shop.go`.
- Removed unused user update handler and user API files.
- Added utility functions for context management and HTTP header parsing.
- Introduced PostgreSQL backup configuration in `backup/postgreSql.yaml`.
2026-02-28 18:35:56 +08:00

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 chat-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)
}