feat(reset): 以构造器模式重构
- 加了大文件传输自定义分片协议 BREAKING CHANGES: 0.1.0(latest)
This commit is contained in:
92
api/chat-api.ts
Normal file
92
api/chat-api.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
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<CreateChatSessionResponse> {
|
||||
// 实际请求逻辑由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<GetChatSessionsResponse> {
|
||||
// 实际请求逻辑由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<GetChatMessagesResponse> {
|
||||
// 实际请求逻辑由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<SendMessageResponse> {
|
||||
// 实际请求逻辑由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<SearchChatMessagesResponse> {
|
||||
// 实际请求逻辑由Request装饰器处理
|
||||
throw new Error('Decorated by @Request and should never be executed.');
|
||||
}
|
||||
}
|
||||
|
||||
// 创建单例实例
|
||||
export const chatApi = new ChatApiService();
|
||||
Reference in New Issue
Block a user