refactor(api): remove unused network endpoints

This commit is contained in:
2026-07-07 16:29:21 +08:00
parent ab9b227969
commit b5bf81de59
47 changed files with 1 additions and 971 deletions
-27
View File
@@ -3,7 +3,6 @@
import { ExceptionHandler } from "@/core/errors";
import { ApiError, AuthApi, authApi, ErrorCode } from "@/data/services/api";
import {
AppleLoginRequest,
FacebookLoginRequest,
FbIdLoginRequest,
GoogleLoginRequest,
@@ -16,7 +15,6 @@ import {
RefreshTokenRequest,
RefreshTokenResponse,
RegisterRequest,
SendCodeRequest,
} from "@/data/dto/auth";
import { User } from "@/data/dto/user";
import {
@@ -94,13 +92,6 @@ export class AuthRepository implements IAuthRepository {
});
}
/** 发送邮箱验证码。 */
async sendCode(email: string): Promise<Result<void>> {
return Result.wrap(async () => {
await this.api.sendCode(SendCodeRequest.from({ email }));
});
}
/**
* 退出真实用户登录并恢复游客态。
*
@@ -231,24 +222,6 @@ export class AuthRepository implements IAuthRepository {
);
}
/**
* Apple 登录。
* 注:Dart 端另有一个 `uploadFacebookAvatar` 方法,但当前 TS 端 `AuthApi`
* 尚未实现该端点,故仓库暂不暴露。等 `AuthApi` 补齐后再加。
*/
async appleLogin(identityToken: string): Promise<Result<LoginResponse>> {
return this._socialLogin(LoginStatus.Apple, () =>
this.api.appleLogin(
AppleLoginRequest.from(
withTestAccountFlag({
identityToken,
platform: getAuthPlatform(),
}),
),
),
);
}
/**
* 刷新 token:先读本地的 refresh token,空则直接返回错误;
* 调用 API 成功后写回新的 login token + refresh token。
@@ -38,9 +38,6 @@ export interface IAuthRepository {
guestId?: string;
}): Promise<Result<LoginResponse>>;
/** 发送邮箱验证码。 */
sendCode(email: string): Promise<Result<void>>;
/** 退出真实用户登录并恢复游客态。 */
logout(): Promise<Result<void>>;
@@ -65,9 +62,6 @@ export interface IAuthRepository {
avatarUrl?: string;
}): Promise<Result<LoginResponse>>;
/** Apple 登录。 */
appleLogin(identityToken: string): Promise<Result<LoginResponse>>;
/** 刷新 token:先读本地的 refresh token,空则返回错误。 */
refreshToken(): Promise<Result<RefreshTokenResponse>>;
@@ -7,9 +7,7 @@ import type {
CreatePaymentOrderResponse,
PayChannel,
PaymentOrderStatusResponse,
PaymentPlan,
PaymentPlansResponse,
PaymentVipStatusResponse,
} from "@/data/dto/payment";
import type { Result } from "@/utils/result";
@@ -23,12 +21,6 @@ export interface IPaymentRepository {
/** 清除本地缓存套餐列表。 */
clearCachedPlans(): Promise<Result<void>>;
/** 获取会员套餐列表。 */
getVipPlans(): Promise<Result<PaymentPlan[]>>;
/** 获取积分套餐列表。 */
getCreditPlans(): Promise<Result<PaymentPlan[]>>;
/** 创建支付订单。 */
createOrder(
planId: string,
@@ -38,7 +30,4 @@ export interface IPaymentRepository {
/** 查询支付订单状态。 */
getOrderStatus(orderId: string): Promise<Result<PaymentOrderStatusResponse>>;
/** 查询当前用户 VIP 状态。 */
getVipStatus(): Promise<Result<PaymentVipStatusResponse>>;
}
@@ -6,33 +6,14 @@
import type { Result } from "@/utils";
import type {
CreditsData,
CreditsHistoryData,
UpdateProfileRequest,
User,
UserEntitlements,
UserStatsResponse,
} from "@/data/dto/user";
export interface IUserRepository {
/** 获取用户统计信息。 */
getUserStats(): Promise<Result<UserStatsResponse>>;
/** 获取当前登录用户信息。 */
getCurrentUser(): Promise<Result<User>>;
/** 更新个人资料。 */
updateProfile(request: UpdateProfileRequest): Promise<Result<User>>;
/** 查询积分余额。 */
getCredits(): Promise<Result<CreditsData>>;
/** 查询积分操作历史,分页参数默认 limit=50, offset=0。 */
getCreditsHistory(
limit?: number,
offset?: number,
): Promise<Result<CreditsHistoryData>>;
/** 获取当前用户权益快照。 */
getEntitlements(): Promise<Result<UserEntitlements>>;
}
@@ -10,9 +10,7 @@ import {
CreatePaymentOrderResponse,
PayChannel,
PaymentOrderStatusResponse,
PaymentPlan,
PaymentPlansResponse,
PaymentVipStatusResponse,
} from "@/data/dto/payment";
import { PaymentApi, paymentApi } from "@/data/services/api";
import { PaymentPlansStorage } from "@/data/storage/payment";
@@ -49,22 +47,6 @@ export class PaymentRepository implements IPaymentRepository {
});
}
/** 获取会员套餐列表。 */
async getVipPlans(): Promise<Result<PaymentPlan[]>> {
return Result.wrap(async () => {
const response = await this.api.getPlans();
return response.plans.filter(isVipPaymentPlan);
});
}
/** 获取积分套餐列表。 */
async getCreditPlans(): Promise<Result<PaymentPlan[]>> {
return Result.wrap(async () => {
const response = await this.api.getPlans();
return response.plans.filter(isCreditPaymentPlan);
});
}
/** 创建支付订单。 */
async createOrder(
planId: string,
@@ -86,21 +68,9 @@ export class PaymentRepository implements IPaymentRepository {
return Result.wrap(() => this.api.getOrderStatus(orderId));
}
/** 查询当前用户 VIP 状态。 */
async getVipStatus(): Promise<Result<PaymentVipStatusResponse>> {
return Result.wrap(() => this.api.getVipStatus());
}
}
/** 全局懒单例。 */
export const getPaymentRepository = createLazySingleton<IPaymentRepository>(
() => new PaymentRepository(paymentApi),
);
export function isVipPaymentPlan(plan: PaymentPlan): boolean {
return plan.vipDays !== null;
}
export function isCreditPaymentPlan(plan: PaymentPlan): boolean {
return plan.dolAmount !== null;
}
-27
View File
@@ -1,12 +1,8 @@
"use client";
import { UserApi, userApi } from "@/data/services/api";
import {
CreditsData,
CreditsHistoryData,
UpdateProfileRequest,
User,
UserEntitlements,
UserStatsResponse,
} from "@/data/dto/user";
import { Result } from "@/utils";
import type { IUserRepository } from "@/data/repositories/interfaces";
@@ -15,34 +11,11 @@ import { createLazySingleton } from "./lazy_singleton";
export class UserRepository implements IUserRepository {
constructor(private readonly api: UserApi) {}
/** 获取用户统计信息。 */
async getUserStats(): Promise<Result<UserStatsResponse>> {
return Result.wrap(() => this.api.getUserStats());
}
/** 获取当前登录用户信息。 */
async getCurrentUser(): Promise<Result<User>> {
return Result.wrap(() => this.api.getCurrentUser());
}
/** 更新个人资料。 */
async updateProfile(request: UpdateProfileRequest): Promise<Result<User>> {
return Result.wrap(() => this.api.updateProfile(request));
}
/** 查询积分余额。 */
async getCredits(): Promise<Result<CreditsData>> {
return Result.wrap(() => this.api.getCredits());
}
/** 查询积分操作历史,分页参数默认 limit=50, offset=0。 */
async getCreditsHistory(
limit = 50,
offset = 0,
): Promise<Result<CreditsHistoryData>> {
return Result.wrap(() => this.api.getCreditsHistory(limit, offset));
}
/** 获取当前用户权益快照。 */
async getEntitlements(): Promise<Result<UserEntitlements>> {
return Result.wrap(() => this.api.getEntitlements());