import { GET, POST, ApiClientBound, Request } from '../decorators'; import { API_ENDPOINTS } from './common'; import type { CreateChatSessionRequest, CreateChatSessionResponse, SendMessageRequest, SendMessageResponse, GetChatSessionsRequest, GetChatSessionsResponse, GetChatMessagesRequest, GetChatMessagesResponse, SearchChatMessagesRequest, SearchChatMessagesResponse } from '../types'; import type { AxiosHttpClient } from '../client'; /** * 聊天相关API服务类 */ @ApiClientBound export class ChatApiService { // 语法要求 declare client: AxiosHttpClient; /** * 创建聊天会话 * @param request 创建聊天会话请求参数 * @returns 创建聊天会话响应 * @throws ApiError 当请求失败时抛出 */ @POST(API_ENDPOINTS.CHATS) @Request async createChatSession(_request: CreateChatSessionRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 获取聊天会话列表 * @param request 获取聊天会话列表请求参数 * @returns 获取聊天会话列表响应 * @throws ApiError 当请求失败时抛出 */ @GET(API_ENDPOINTS.CHATS) @Request async getChatSessions(_request: GetChatSessionsRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 获取聊天消息列表 * @param request 获取聊天消息请求参数 * @returns 获取聊天消息响应 * @throws ApiError 当请求失败时抛出 */ @GET(API_ENDPOINTS.CHAT_ONE_MESSAGES) @Request async getChatMessages(_request: GetChatMessagesRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 发送消息 * @param request 发送消息请求参数 * @returns 发送消息响应 * @throws ApiError 当请求失败时抛出 */ @POST(API_ENDPOINTS.CHAT_ONE_MESSAGES) @Request async sendMessage(_request: SendMessageRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 搜索聊天消息或会话 * @param request 搜索聊天消息请求参数 * @returns 搜索聊天消息响应 * @throws ApiError 当请求失败时抛出 */ @GET(API_ENDPOINTS.CHATS) @Request async searchChatMessages(_request: SearchChatMessagesRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } } // 创建单例实例 export const chatApi = new ChatApiService();