import { GET, POST, ApiClientBound, Request } from '../decorators'; import { API_ENDPOINTS } from './common'; import type { CreatePostRequest, CreatePostResponse, GetPostsRequest, GetPostsResponse, LikePostRequest, LikePostResponse, BookmarkPostRequest, BookmarkPostResponse, CreateCommentRequest, CreateCommentResponse, GetCommentsRequest, GetCommentsResponse, GetHotPostsRequest, GetHotPostsResponse } from '../types'; import type { AxiosHttpClient } from '../client'; /** * 帖子相关API服务类 */ @ApiClientBound export class PostApiService { // 语法要求 declare client: AxiosHttpClient; /** * 创建新帖子 * @param request 创建帖子请求参数 * @returns 创建帖子响应 * @throws ApiError 当请求失败时抛出 */ @POST(API_ENDPOINTS.POSTS) @Request async createPost(_request: CreatePostRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 获取帖子列表 * @param request 获取帖子列表请求参数 * @returns 获取帖子列表响应 * @throws ApiError 当请求失败时抛出 */ @GET(API_ENDPOINTS.POSTS) @Request async getPosts(_request: GetPostsRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 点赞帖子 * @param request 点赞帖子请求参数 * @returns 点赞帖子响应 * @throws ApiError 当请求失败时抛出 */ @POST(API_ENDPOINTS.POST_ONE_LIKES) @Request async likePost(_request: LikePostRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 收藏帖子 * @param request 收藏帖子请求参数 * @returns 收藏帖子响应 * @throws ApiError 当请求失败时抛出 */ @POST(API_ENDPOINTS.POST_ONE_STARS) @Request async bookmarkPost(_request: BookmarkPostRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 创建评论 * @param request 创建评论请求参数 * @returns 创建评论响应 * @throws ApiError 当请求失败时抛出 */ @POST(API_ENDPOINTS.POST_ONE_COMMENTS) @Request async createComment(_request: CreateCommentRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 获取评论列表 * @param request 获取评论列表请求参数 * @returns 获取评论列表响应 * @throws ApiError 当请求失败时抛出 */ @GET(API_ENDPOINTS.POST_ONE_COMMENTS) @Request async getComments(_request: GetCommentsRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 获取热门帖子 * @param request 获取热门帖子请求参数 * @returns 获取热门帖子响应 * @throws ApiError 当请求失败时抛出 */ @GET(API_ENDPOINTS.POSTS) @Request async getHotPosts(_request: GetHotPostsRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } } // 创建单例实例 export const postApi = new PostApiService();