feat(reset): 以构造器模式重构
- 加了大文件传输自定义分片协议 BREAKING CHANGES: 0.1.0(latest)
This commit is contained in:
77
api/model-api.ts
Normal file
77
api/model-api.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import { GET, POST, ApiClientBound, Request } from '../decorators';
|
||||
import { API_ENDPOINTS } from './common';
|
||||
import type {
|
||||
GetModelsRequest,
|
||||
GetModelsResponse,
|
||||
GetModelCommentsRequest,
|
||||
GetModelCommentsResponse,
|
||||
CreateModelCommentRequest,
|
||||
CreateModelCommentResponse,
|
||||
LikeModelRequest,
|
||||
LikeModelResponse,
|
||||
} from '../types/model/api';
|
||||
import type { AxiosHttpClient } from '../client';
|
||||
|
||||
/**
|
||||
* 模型相关API服务类
|
||||
*/
|
||||
@ApiClientBound
|
||||
export class ModelApiService {
|
||||
// 语法要求
|
||||
declare client: AxiosHttpClient;
|
||||
|
||||
/**
|
||||
* 获取模型列表
|
||||
* @param request 获取模型列表请求参数
|
||||
* @returns 获取模型列表响应
|
||||
* @throws ApiError 当请求失败时抛出
|
||||
*/
|
||||
@GET(API_ENDPOINTS.MODELS)
|
||||
@Request
|
||||
async getModels(_request: GetModelsRequest): Promise<GetModelsResponse> {
|
||||
throw new Error('Decorated by @Request and should never be executed.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模型评论列表
|
||||
* @param request 获取模型评论列表请求参数
|
||||
* @returns 获取模型评论列表响应
|
||||
* @throws ApiError 当请求失败时抛出
|
||||
*/
|
||||
@GET(API_ENDPOINTS.MODEL_ONE_COMMENTS)
|
||||
@Request
|
||||
async getModelComments(_request: GetModelCommentsRequest): Promise<GetModelCommentsResponse> {
|
||||
// 实际请求逻辑由Request装饰器处理
|
||||
throw new Error('Decorated by @Request and should never be executed.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 发表模型评论
|
||||
* @param request 发表模型评论请求参数
|
||||
* @returns 发表模型评论响应
|
||||
* @throws ApiError 当请求失败时抛出
|
||||
*/
|
||||
@POST(API_ENDPOINTS.MODEL_ONE_COMMENTS)
|
||||
@Request
|
||||
async createModelComment(_request: CreateModelCommentRequest): Promise<CreateModelCommentResponse> {
|
||||
// 实际请求逻辑由Request装饰器处理
|
||||
throw new Error('Decorated by @Request and should never be executed.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 点赞模型
|
||||
* @param request 包含modelId的请求参数
|
||||
* @returns 点赞响应
|
||||
* @throws ApiError 当请求失败时抛出
|
||||
*/
|
||||
@POST(API_ENDPOINTS.MODEL_ONE_LIKES)
|
||||
@Request
|
||||
async likeModel(_request: LikeModelRequest): Promise<LikeModelResponse> {
|
||||
// 实际请求逻辑由Request装饰器处理
|
||||
throw new Error('Decorated by @Request and should never be executed.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 创建单例实例
|
||||
export const modelApi = new ModelApiService();
|
||||
Reference in New Issue
Block a user