import { GET, POST, ApiClientBound, Request } from '../decorators'; import { API_ENDPOINTS } from './common'; import type { GetMyProfileResponse, GetUserProfileRequest, GetUserProfileResponse, UserProfileUpdateRequest, UserProfileUpdateResponse, LoginRequest, LoginResponse, RegisterRequest, RegisterResponse, ChangePasswordRequest, ChangePasswordResponse, UserSearchRequest, UserSearchResponse, GetHotAuthorsRequest, GetHotAuthorsResponse, GetAuthorRankingRequest, GetAuthorRankingResponse } from '../types'; import type { AxiosHttpClient } from '../client'; /** * 用户相关API服务类 */ @ApiClientBound export class UserApiService { // 语法要求 declare client: AxiosHttpClient; /** * 获取我的个人资料 * @returns 个人资料信息 * @throws ApiError 当请求失败时抛出 */ @GET(API_ENDPOINTS.ME_PROFILE) @Request async getMyProfile(): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 获取他人个人资料 * @param request 包含userId的请求参数 * @returns 他人个人资料信息 * @throws ApiError 当请求失败时抛出 */ @GET(API_ENDPOINTS.SOMEBODY_PROFILE) @Request async getUserProfile(_request: GetUserProfileRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 用户登录 * @param request 登录请求参数 * @returns 登录响应 * @throws ApiError 当请求失败时抛出 */ @POST(API_ENDPOINTS.AUTH_LOGIN) @Request async login(_request: LoginRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 用户注册 * @param request 注册请求参数 * @returns 注册响应 * @throws ApiError 当请求失败时抛出 */ @POST(API_ENDPOINTS.AUTH_REGISTER) @Request async register(_request: RegisterRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 修改密码 * @param request 修改密码请求参数 * @returns 修改密码响应 * @throws ApiError 当请求失败时抛出 */ @POST(API_ENDPOINTS.AUTH_CHANGE_PASSWORD) @Request async changePassword(_request: ChangePasswordRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 更新个人资料 * @param request 更新请求参数 * @returns 更新响应 * @throws ApiError 当请求失败时抛出 */ @POST(API_ENDPOINTS.USER_PROFILE_UPDATE) @Request async updateProfile(_request: UserProfileUpdateRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 搜索用户 * @param request 搜索请求参数 * @returns 搜索响应 * @throws ApiError 当请求失败时抛出 */ @GET(API_ENDPOINTS.USER_SEARCH) @Request async searchUsers(_request: UserSearchRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 获取热门作者 * @param request 请求参数 * @returns 热门作者列表 * @throws ApiError 当请求失败时抛出 */ @GET(API_ENDPOINTS.USER_HOT_AUTHORS) @Request async getHotAuthors(_request: GetHotAuthorsRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } /** * 获取作者榜单 * @param request 请求参数 * @returns 作者榜单列表 * @throws ApiError 当请求失败时抛出 */ @GET(API_ENDPOINTS.USER_RANKING) @Request async getAuthorRanking(_request: GetAuthorRankingRequest): Promise { // 实际请求逻辑由Request装饰器处理 throw new Error('Decorated by @Request and should never be executed.'); } } // 创建单例实例 export const userApi = new UserApiService();