task-20: 拆分 shop-data-crawl / query-asin 模块 API 至 types/modules/query-asin.ts,java-modules.ts re-export
This commit is contained in:
@@ -19,12 +19,17 @@ export * from "./types/modules/appearance-patent.ts";
|
||||
export * from "./types/modules/delete-brand.ts";
|
||||
export * from "./types/modules/price-track.ts";
|
||||
export * from "./types/modules/shop-match.ts";
|
||||
export * from "./types/modules/query-asin.ts";
|
||||
import type {
|
||||
ProductRiskCandidateVo,
|
||||
ProductRiskDashboardVo,
|
||||
ProductRiskMatchShopsVo,
|
||||
ProductRiskShopQueueItem,
|
||||
} from "./types/modules/shop-match.ts";
|
||||
import type {
|
||||
QueryAsinCandidateVo,
|
||||
QueryAsinDashboardVo,
|
||||
} from "./types/modules/query-asin.ts";
|
||||
|
||||
const JAVA_API_PREFIX = "/newApi/api";
|
||||
|
||||
@@ -418,363 +423,6 @@ export function deletePatrolDeleteHistory(resultId: number) {
|
||||
);
|
||||
}
|
||||
|
||||
export type QueryAsinCandidateVo = ProductRiskCandidateVo;
|
||||
export type QueryAsinDashboardVo = ProductRiskDashboardVo;
|
||||
export type QueryAsinShopQueueItem = ProductRiskShopQueueItem;
|
||||
|
||||
export interface QueryAsinCountryAsins {
|
||||
country: string;
|
||||
asins: string[];
|
||||
}
|
||||
|
||||
export interface QueryAsinStatusItem {
|
||||
asin?: string;
|
||||
status?: string;
|
||||
}
|
||||
|
||||
export interface QueryAsinCountryResult {
|
||||
country: string;
|
||||
items: QueryAsinStatusItem[];
|
||||
}
|
||||
|
||||
export interface QueryAsinTaskItem {
|
||||
shopName?: string;
|
||||
matched?: boolean;
|
||||
shopId?: string;
|
||||
platform?: string;
|
||||
companyName?: string;
|
||||
matchStatus?: string;
|
||||
matchMessage?: string;
|
||||
queryAsins: QueryAsinCountryAsins[];
|
||||
}
|
||||
|
||||
export interface QueryAsinHistoryItem {
|
||||
resultId?: number;
|
||||
taskId?: number;
|
||||
shopName?: string;
|
||||
shopId?: string;
|
||||
platform?: string;
|
||||
companyName?: string;
|
||||
matched?: boolean;
|
||||
matchStatus?: string;
|
||||
matchMessage?: string;
|
||||
taskStatus?: string;
|
||||
success?: boolean;
|
||||
error?: string;
|
||||
createdAt?: string;
|
||||
finishedAt?: string;
|
||||
outputFilename?: string;
|
||||
downloadUrl?: string;
|
||||
fileJobId?: number;
|
||||
fileStatus?: string;
|
||||
fileError?: string;
|
||||
fileReady?: boolean;
|
||||
queryAsins: QueryAsinCountryAsins[];
|
||||
countryResults?: QueryAsinCountryResult[];
|
||||
}
|
||||
|
||||
export interface QueryAsinHistoryVo {
|
||||
items: QueryAsinHistoryItem[];
|
||||
}
|
||||
|
||||
export interface QueryAsinTaskBatchVo {
|
||||
items: QueryAsinHistoryItem[];
|
||||
missingTaskIds: number[];
|
||||
}
|
||||
|
||||
export interface QueryAsinCreateTaskVo {
|
||||
taskId: number;
|
||||
items: QueryAsinHistoryItem[];
|
||||
}
|
||||
|
||||
export function listQueryAsinCandidates() {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<QueryAsinCandidateVo[]>>(`${JAVA_API_PREFIX}/query-asin/candidates`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function addQueryAsinCandidate(shopName: string) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<QueryAsinCandidateVo>, { user_id: number; shop_name: string }>(
|
||||
`${JAVA_API_PREFIX}/query-asin/candidates`,
|
||||
{ user_id: getCurrentUserId(), shop_name: shopName },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteQueryAsinCandidate(id: number) {
|
||||
return unwrapJavaResponse(
|
||||
del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/query-asin/candidates/${id}`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function matchQueryAsinShops(shopNames: string[]) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<ProductRiskMatchShopsVo>, { user_id: number; shop_names: string[] }>(
|
||||
`${JAVA_API_PREFIX}/query-asin/match-shops`,
|
||||
{ user_id: getCurrentUserId(), shop_names: shopNames },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function getQueryAsinDashboard() {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<QueryAsinDashboardVo>>(`${JAVA_API_PREFIX}/query-asin/dashboard`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function getQueryAsinHistory() {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<QueryAsinHistoryVo>>(`${JAVA_API_PREFIX}/query-asin/history`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function getQueryAsinTaskProgressBatch(taskIds: number[]) {
|
||||
return postTaskProgressBatch<QueryAsinTaskBatchVo>(
|
||||
`${JAVA_API_PREFIX}/query-asin/tasks/progress/batch`,
|
||||
taskIds,
|
||||
);
|
||||
}
|
||||
|
||||
export function createQueryAsinTask(items: QueryAsinTaskItem[]) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<QueryAsinCreateTaskVo>, { user_id: number; items: QueryAsinTaskItem[] }>(
|
||||
`${JAVA_API_PREFIX}/query-asin/tasks`,
|
||||
{ user_id: getCurrentUserId(), items },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function submitQueryAsinTaskResult(
|
||||
taskId: number,
|
||||
payload: {
|
||||
shops: Array<{
|
||||
shopName: string;
|
||||
error?: string;
|
||||
countryResults?: QueryAsinCountryResult[];
|
||||
shopDone?: boolean;
|
||||
submissionId?: string;
|
||||
}>;
|
||||
},
|
||||
) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<null>, typeof payload>(`${JAVA_API_PREFIX}/query-asin/tasks/${taskId}/result`, payload),
|
||||
);
|
||||
}
|
||||
|
||||
export function getQueryAsinResultDownloadUrl(resultId: number) {
|
||||
return getJavaDownloadUrl(`/query-asin/results/${resultId}/download`);
|
||||
}
|
||||
|
||||
export function deleteQueryAsinTask(taskId: number) {
|
||||
return unwrapJavaResponse(
|
||||
del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/query-asin/tasks/${taskId}`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteQueryAsinHistory(resultId: number) {
|
||||
return unwrapJavaResponse(
|
||||
del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/query-asin/history/${resultId}`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// ========== 店铺数据抓取 ==========
|
||||
|
||||
export interface ShopDataCrawlCandidateVo {
|
||||
id: number;
|
||||
shop_name: string;
|
||||
created_at?: string;
|
||||
}
|
||||
|
||||
export interface ShopDataCrawlCountryPreferenceVo {
|
||||
country_codes: string[];
|
||||
}
|
||||
|
||||
export interface ShopDataCrawlShopItem {
|
||||
shopName: string;
|
||||
matched: boolean;
|
||||
shopId?: string;
|
||||
platform?: string;
|
||||
companyName?: string;
|
||||
openStoreUrl?: string;
|
||||
matchedUserId?: number;
|
||||
matchStatus?: string;
|
||||
matchMessage?: string;
|
||||
}
|
||||
|
||||
export interface ShopDataCrawlMatchVo {
|
||||
items: ShopDataCrawlShopItem[];
|
||||
}
|
||||
|
||||
export interface ShopDataCrawlDashboardVo {
|
||||
candidateCount: number;
|
||||
processedTaskCount: number;
|
||||
successTaskCount: number;
|
||||
failedTaskCount: number;
|
||||
}
|
||||
|
||||
export interface ShopDataCrawlHistoryItem extends ShopDataCrawlShopItem {
|
||||
resultId?: number;
|
||||
taskId?: number;
|
||||
taskStatus?: string;
|
||||
success?: boolean;
|
||||
error?: string;
|
||||
fileReady?: boolean;
|
||||
fileStatus?: string;
|
||||
downloadUrl?: string;
|
||||
outputFilename?: string;
|
||||
createdAt?: string;
|
||||
finishedAt?: string;
|
||||
}
|
||||
|
||||
export interface ShopDataCrawlHistoryVo {
|
||||
items: ShopDataCrawlHistoryItem[];
|
||||
}
|
||||
|
||||
export interface ShopDataCrawlTaskSummary {
|
||||
id?: number;
|
||||
status?: string;
|
||||
errorMessage?: string;
|
||||
createdAt?: string;
|
||||
finishedAt?: string;
|
||||
countryCodes?: string[];
|
||||
}
|
||||
|
||||
export interface ShopDataCrawlTaskDetailVo {
|
||||
task?: ShopDataCrawlTaskSummary;
|
||||
items?: ShopDataCrawlHistoryItem[];
|
||||
}
|
||||
|
||||
export interface ShopDataCrawlTaskBatchVo {
|
||||
items: Array<ShopDataCrawlTaskDetailVo | ShopDataCrawlHistoryItem>;
|
||||
missingTaskIds?: number[];
|
||||
}
|
||||
|
||||
export interface ShopDataCrawlCreateTaskVo {
|
||||
taskId: number;
|
||||
items: ShopDataCrawlHistoryItem[];
|
||||
}
|
||||
|
||||
export function listShopDataCrawlCandidates() {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<ShopDataCrawlCandidateVo[]>>(`${JAVA_API_PREFIX}/shop-data-crawl/candidates`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function addShopDataCrawlCandidate(shopName: string) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<ShopDataCrawlCandidateVo>, { user_id: number; shop_name: string }>(
|
||||
`${JAVA_API_PREFIX}/shop-data-crawl/candidates`,
|
||||
{ user_id: getCurrentUserId(), shop_name: shopName },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteShopDataCrawlCandidate(id: number) {
|
||||
return unwrapJavaResponse(
|
||||
del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/shop-data-crawl/candidates/${id}`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function getShopDataCrawlCountryPreference() {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<ShopDataCrawlCountryPreferenceVo>>(
|
||||
`${JAVA_API_PREFIX}/shop-data-crawl/country-preference`,
|
||||
{ params: { user_id: getCurrentUserId() } },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function putShopDataCrawlCountryPreference(countryCodes: string[]) {
|
||||
return unwrapJavaResponse(
|
||||
put<JavaApiResponse<ShopDataCrawlCountryPreferenceVo>, { user_id: number; country_codes: string[] }>(
|
||||
`${JAVA_API_PREFIX}/shop-data-crawl/country-preference`,
|
||||
{ user_id: getCurrentUserId(), country_codes: countryCodes },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function matchShopDataCrawlShops(shopNames: string[]) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<ShopDataCrawlMatchVo>, { user_id: number; shop_names: string[] }>(
|
||||
`${JAVA_API_PREFIX}/shop-data-crawl/match-shops`,
|
||||
{ user_id: getCurrentUserId(), shop_names: shopNames },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function getShopDataCrawlDashboard() {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<ShopDataCrawlDashboardVo>>(`${JAVA_API_PREFIX}/shop-data-crawl/dashboard`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function getShopDataCrawlHistory() {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<ShopDataCrawlHistoryVo>>(`${JAVA_API_PREFIX}/shop-data-crawl/history`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function createShopDataCrawlTask(items: ShopDataCrawlShopItem[], countryCodes: string[]) {
|
||||
return unwrapJavaResponse(
|
||||
post<
|
||||
JavaApiResponse<ShopDataCrawlCreateTaskVo>,
|
||||
{ user_id: number; items: ShopDataCrawlShopItem[]; country_codes: string[] }
|
||||
>(`${JAVA_API_PREFIX}/shop-data-crawl/tasks`, {
|
||||
user_id: getCurrentUserId(),
|
||||
items,
|
||||
country_codes: countryCodes,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function getShopDataCrawlTaskProgressBatch(taskIds: number[]) {
|
||||
return postTaskProgressBatch<ShopDataCrawlTaskBatchVo>(
|
||||
`${JAVA_API_PREFIX}/shop-data-crawl/tasks/progress/batch`,
|
||||
taskIds,
|
||||
);
|
||||
}
|
||||
|
||||
export function getShopDataCrawlResultDownloadUrl(resultId: number) {
|
||||
return getJavaDownloadUrl(`/shop-data-crawl/results/${resultId}/download`);
|
||||
}
|
||||
|
||||
export function deleteShopDataCrawlTask(taskId: number) {
|
||||
return unwrapJavaResponse(
|
||||
del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/shop-data-crawl/tasks/${taskId}`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteShopDataCrawlHistory(resultId: number) {
|
||||
return unwrapJavaResponse(
|
||||
del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/shop-data-crawl/history/${resultId}`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// ========== 取款 ==========
|
||||
|
||||
export type WithdrawCandidateVo = QueryAsinCandidateVo;
|
||||
|
||||
Reference in New Issue
Block a user