90 lines
2.4 KiB
TypeScript
90 lines
2.4 KiB
TypeScript
/**
|
||
* 用户详情服务
|
||
* 负责用户详情页面的 API 调用
|
||
*/
|
||
|
||
import apiClient from '@/infrastructure/api/client';
|
||
import { API_ENDPOINTS } from '@/infrastructure/api/endpoints';
|
||
import type {
|
||
UserFullDetail,
|
||
ReferralTreeData,
|
||
PlantingLedgerResponse,
|
||
WalletLedgerResponse,
|
||
AuthorizationDetailResponse,
|
||
LedgerQueryParams,
|
||
WalletLedgerQueryParams,
|
||
} from '@/types/userDetail.types';
|
||
|
||
/**
|
||
* 用户详情服务
|
||
*/
|
||
export const userDetailService = {
|
||
/**
|
||
* 获取用户完整信息
|
||
*/
|
||
async getFullDetail(accountSequence: string): Promise<UserFullDetail> {
|
||
return apiClient.get(API_ENDPOINTS.USER_DETAIL.FULL_DETAIL(accountSequence));
|
||
},
|
||
|
||
/**
|
||
* 获取推荐关系树
|
||
* @param accountSequence 用户账户序号
|
||
* @param direction 方向:up-向上查推荐人链,down-向下查直推用户,both-双向
|
||
* @param depth 深度,默认1级
|
||
*/
|
||
async getReferralTree(
|
||
accountSequence: string,
|
||
direction: 'up' | 'down' | 'both' = 'both',
|
||
depth: number = 1
|
||
): Promise<ReferralTreeData> {
|
||
return apiClient.get(API_ENDPOINTS.USER_DETAIL.REFERRAL_TREE(accountSequence), {
|
||
params: { direction, depth },
|
||
});
|
||
},
|
||
|
||
/**
|
||
* 获取认种分类账
|
||
*/
|
||
async getPlantingLedger(
|
||
accountSequence: string,
|
||
params: LedgerQueryParams = {}
|
||
): Promise<PlantingLedgerResponse> {
|
||
return apiClient.get(API_ENDPOINTS.USER_DETAIL.PLANTING_LEDGER(accountSequence), {
|
||
params: {
|
||
page: params.page || 1,
|
||
pageSize: params.pageSize || 20,
|
||
startDate: params.startDate,
|
||
endDate: params.endDate,
|
||
},
|
||
});
|
||
},
|
||
|
||
/**
|
||
* 获取钱包分类账
|
||
*/
|
||
async getWalletLedger(
|
||
accountSequence: string,
|
||
params: WalletLedgerQueryParams = {}
|
||
): Promise<WalletLedgerResponse> {
|
||
return apiClient.get(API_ENDPOINTS.USER_DETAIL.WALLET_LEDGER(accountSequence), {
|
||
params: {
|
||
page: params.page || 1,
|
||
pageSize: params.pageSize || 20,
|
||
assetType: params.assetType,
|
||
entryType: params.entryType,
|
||
startDate: params.startDate,
|
||
endDate: params.endDate,
|
||
},
|
||
});
|
||
},
|
||
|
||
/**
|
||
* 获取授权信息
|
||
*/
|
||
async getAuthorizationDetail(accountSequence: string): Promise<AuthorizationDetailResponse> {
|
||
return apiClient.get(API_ENDPOINTS.USER_DETAIL.AUTHORIZATION_DETAIL(accountSequence));
|
||
},
|
||
};
|
||
|
||
export default userDetailService;
|