更新后端新增内容
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
import { requestDeleteJson, requestGetJson, requestPostJson } from '@/shared/api/http'
|
||||
|
||||
function getCurrentUserId() {
|
||||
const raw = typeof window === 'undefined' ? '' : window.localStorage.getItem('uid') || ''
|
||||
const value = Number(raw)
|
||||
if (!Number.isFinite(value) || value <= 0) {
|
||||
throw new Error('未获取到用户ID')
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
export interface BrandExpandFolderItem {
|
||||
absolutePath: string
|
||||
relativePath: string
|
||||
@@ -47,11 +56,11 @@ export interface BrandTaskMutationResponse {
|
||||
const API_PREFIX = ''
|
||||
|
||||
export function getBrandTaskEventsUrl(taskId: string | number) {
|
||||
return `${API_PREFIX}/api/brand/tasks/${taskId}/events`
|
||||
return `${API_PREFIX}/api/brand/tasks/${taskId}/events?user_id=${encodeURIComponent(String(getCurrentUserId()))}`
|
||||
}
|
||||
|
||||
export function getBrandTaskDownloadUrl(taskId: string | number) {
|
||||
return `${API_PREFIX}/api/brand/download/${taskId}`
|
||||
return `${API_PREFIX}/api/brand/tasks/${taskId}/download?user_id=${encodeURIComponent(String(getCurrentUserId()))}`
|
||||
}
|
||||
|
||||
export function getBrandTemplateXlsxUrl() {
|
||||
@@ -75,23 +84,23 @@ export function runBrandNow(paths: string[], strategy: string) {
|
||||
}
|
||||
|
||||
export function createBrandTask(paths: string[], strategy: string) {
|
||||
return requestPostJson<BrandTaskMutationResponse>(`${API_PREFIX}/api/brand/tasks`, { paths, strategy })
|
||||
return requestPostJson<BrandTaskMutationResponse>(`${API_PREFIX}/api/brand/tasks?userId=${encodeURIComponent(String(getCurrentUserId()))}`, { paths, strategy })
|
||||
}
|
||||
|
||||
export function getBrandTasks() {
|
||||
return requestGetJson<BrandTaskListResponse>(`${API_PREFIX}/api/brand/tasks`)
|
||||
return requestGetJson<BrandTaskListResponse>(`${API_PREFIX}/api/brand/tasks?userId=${encodeURIComponent(String(getCurrentUserId()))}`)
|
||||
}
|
||||
|
||||
export function getBrandTask(taskId: string | number) {
|
||||
return requestGetJson<BrandTaskDetailResponse>(`${API_PREFIX}/api/brand/tasks/${taskId}`)
|
||||
return requestGetJson<BrandTaskDetailResponse>(`${API_PREFIX}/api/brand/tasks/${taskId}?userId=${encodeURIComponent(String(getCurrentUserId()))}`)
|
||||
}
|
||||
|
||||
export function cancelBrandTask(taskId: string | number) {
|
||||
return requestPostJson<BrandTaskMutationResponse>(`${API_PREFIX}/api/brand/tasks/${taskId}/cancel`)
|
||||
return requestPostJson<BrandTaskMutationResponse>(`${API_PREFIX}/api/brand/tasks/${taskId}/cancel?userId=${encodeURIComponent(String(getCurrentUserId()))}`)
|
||||
}
|
||||
|
||||
export function deleteBrandTask(taskId: string | number) {
|
||||
return requestDeleteJson<BrandTaskMutationResponse>(`${API_PREFIX}/api/brand/tasks/${taskId}`)
|
||||
return requestDeleteJson<BrandTaskMutationResponse>(`${API_PREFIX}/api/brand/tasks/${taskId}?userId=${encodeURIComponent(String(getCurrentUserId()))}`)
|
||||
}
|
||||
|
||||
export function createBrandTaskEvents(taskId: string | number) {
|
||||
|
||||
@@ -2,6 +2,15 @@ import { del, get, http, post, type JavaApiResponse, unwrapJavaResponse } from '
|
||||
|
||||
const JAVA_API_PREFIX = '/newApi/api'
|
||||
|
||||
function getCurrentUserId() {
|
||||
const raw = typeof window === 'undefined' ? '' : window.localStorage.getItem('uid') || ''
|
||||
const value = Number(raw)
|
||||
if (!Number.isFinite(value) || value <= 0) {
|
||||
throw new Error('未获取到用户ID')
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
export interface UploadedFileRef {
|
||||
fileKey: string
|
||||
originalFilename?: string
|
||||
@@ -43,6 +52,7 @@ export interface DedupeRunRequest {
|
||||
keepUnderscoreIds: boolean
|
||||
keepIntegerMainIdsWhenNoSubIds: boolean
|
||||
archiveName?: string
|
||||
user_id: number
|
||||
}
|
||||
|
||||
export interface SplitArchiveEntry {
|
||||
@@ -80,6 +90,7 @@ export interface SplitRunRequest {
|
||||
rowsPerFile?: number
|
||||
parts?: number
|
||||
archiveName?: string
|
||||
user_id: number
|
||||
}
|
||||
|
||||
export interface ConvertResultItem {
|
||||
@@ -106,6 +117,45 @@ export interface ConvertRunRequest {
|
||||
files: UploadedFileRef[]
|
||||
templateId: string
|
||||
archiveName?: string
|
||||
user_id: number
|
||||
}
|
||||
|
||||
export interface DeleteBrandPreviewRow {
|
||||
rowIndex: number
|
||||
country: string
|
||||
asin: string
|
||||
status: string
|
||||
}
|
||||
|
||||
export interface DeleteBrandResultItem {
|
||||
resultId?: number
|
||||
sourceFilename: string
|
||||
shopName?: string
|
||||
matched: boolean
|
||||
shopId?: string
|
||||
platform?: string
|
||||
openStoreUrl?: string
|
||||
totalRows?: number
|
||||
truncated?: boolean
|
||||
previewRows?: DeleteBrandPreviewRow[]
|
||||
success: boolean
|
||||
error?: string
|
||||
}
|
||||
|
||||
export interface DeleteBrandRunVo {
|
||||
total: number
|
||||
successCount: number
|
||||
failedCount: number
|
||||
items: DeleteBrandResultItem[]
|
||||
}
|
||||
|
||||
export interface DeleteBrandHistoryVo {
|
||||
items: DeleteBrandResultItem[]
|
||||
}
|
||||
|
||||
export interface DeleteBrandRunRequest {
|
||||
files: UploadedFileRef[]
|
||||
user_id: number
|
||||
}
|
||||
|
||||
export interface ConvertTemplateVo {
|
||||
@@ -133,28 +183,42 @@ export function getExcelInfo(fileKey: string) {
|
||||
}))
|
||||
}
|
||||
|
||||
export function runDedupe(request: DedupeRunRequest) {
|
||||
return unwrapJavaResponse(post<JavaApiResponse<DedupeRunVo>, DedupeRunRequest>(`${JAVA_API_PREFIX}/dedupe/run`, request))
|
||||
export function runDedupe(request: Omit<DedupeRunRequest, 'user_id'> | DedupeRunRequest) {
|
||||
return unwrapJavaResponse(post<JavaApiResponse<DedupeRunVo>, DedupeRunRequest>(`${JAVA_API_PREFIX}/dedupe/run`, {
|
||||
...request,
|
||||
user_id: getCurrentUserId(),
|
||||
}))
|
||||
}
|
||||
|
||||
export function getDedupeHistory() {
|
||||
return unwrapJavaResponse(get<JavaApiResponse<DedupeHistoryVo>>(`${JAVA_API_PREFIX}/dedupe/history`))
|
||||
return unwrapJavaResponse(get<JavaApiResponse<DedupeHistoryVo>>(`${JAVA_API_PREFIX}/dedupe/history`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}))
|
||||
}
|
||||
|
||||
export function deleteDedupeHistory(resultId: number) {
|
||||
return unwrapJavaResponse(del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/dedupe/history/${resultId}`))
|
||||
return unwrapJavaResponse(del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/dedupe/history/${resultId}`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}))
|
||||
}
|
||||
|
||||
export function runSplit(request: SplitRunRequest) {
|
||||
return unwrapJavaResponse(post<JavaApiResponse<SplitRunVo>, SplitRunRequest>(`${JAVA_API_PREFIX}/split/run`, request))
|
||||
export function runSplit(request: Omit<SplitRunRequest, 'user_id'> | SplitRunRequest) {
|
||||
return unwrapJavaResponse(post<JavaApiResponse<SplitRunVo>, SplitRunRequest>(`${JAVA_API_PREFIX}/split/run`, {
|
||||
...request,
|
||||
user_id: getCurrentUserId(),
|
||||
}))
|
||||
}
|
||||
|
||||
export function getSplitHistory() {
|
||||
return unwrapJavaResponse(get<JavaApiResponse<SplitHistoryVo>>(`${JAVA_API_PREFIX}/split/history`))
|
||||
return unwrapJavaResponse(get<JavaApiResponse<SplitHistoryVo>>(`${JAVA_API_PREFIX}/split/history`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}))
|
||||
}
|
||||
|
||||
export function deleteSplitHistory(resultId: number) {
|
||||
return unwrapJavaResponse(del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/split/history/${resultId}`))
|
||||
return unwrapJavaResponse(del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/split/history/${resultId}`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}))
|
||||
}
|
||||
|
||||
export function getConvertTemplates() {
|
||||
@@ -175,20 +239,48 @@ export function deleteConvertTemplate(templateCode: string) {
|
||||
return unwrapJavaResponse(del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/convert/templates/${templateCode}`))
|
||||
}
|
||||
|
||||
export function runConvert(request: ConvertRunRequest) {
|
||||
return unwrapJavaResponse(post<JavaApiResponse<ConvertRunVo>, ConvertRunRequest>(`${JAVA_API_PREFIX}/convert/run`, request))
|
||||
export function runConvert(request: Omit<ConvertRunRequest, 'user_id'> | ConvertRunRequest) {
|
||||
return unwrapJavaResponse(post<JavaApiResponse<ConvertRunVo>, ConvertRunRequest>(`${JAVA_API_PREFIX}/convert/run`, {
|
||||
...request,
|
||||
user_id: getCurrentUserId(),
|
||||
}))
|
||||
}
|
||||
|
||||
export function getConvertHistory() {
|
||||
return unwrapJavaResponse(get<JavaApiResponse<ConvertHistoryVo>>(`${JAVA_API_PREFIX}/convert/history`))
|
||||
return unwrapJavaResponse(get<JavaApiResponse<ConvertHistoryVo>>(`${JAVA_API_PREFIX}/convert/history`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}))
|
||||
}
|
||||
|
||||
export function deleteConvertHistory(resultId: number) {
|
||||
return unwrapJavaResponse(del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/convert/history/${resultId}`))
|
||||
return unwrapJavaResponse(del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/convert/history/${resultId}`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}))
|
||||
}
|
||||
|
||||
export function runDeleteBrand(request: Omit<DeleteBrandRunRequest, 'user_id'> | DeleteBrandRunRequest) {
|
||||
return unwrapJavaResponse(post<JavaApiResponse<DeleteBrandRunVo>, DeleteBrandRunRequest>(`${JAVA_API_PREFIX}/delete-brand/run`, {
|
||||
...request,
|
||||
user_id: getCurrentUserId(),
|
||||
}))
|
||||
}
|
||||
|
||||
export function getDeleteBrandHistory() {
|
||||
return unwrapJavaResponse(get<JavaApiResponse<DeleteBrandHistoryVo>>(`${JAVA_API_PREFIX}/delete-brand/history`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}))
|
||||
}
|
||||
|
||||
export function deleteDeleteBrandHistory(resultId: number) {
|
||||
return unwrapJavaResponse(del<JavaApiResponse<null>>(`${JAVA_API_PREFIX}/delete-brand/history/${resultId}`, {
|
||||
params: { user_id: getCurrentUserId() },
|
||||
}))
|
||||
}
|
||||
|
||||
export function getJavaDownloadUrl(path: string) {
|
||||
return path.startsWith('http://') || path.startsWith('https://') ? path : `${JAVA_API_PREFIX}${path}`
|
||||
const raw = path.startsWith('http://') || path.startsWith('https://') ? path : `${JAVA_API_PREFIX}${path}`
|
||||
const separator = raw.includes('?') ? '&' : '?'
|
||||
return `${raw}${separator}user_id=${encodeURIComponent(String(getCurrentUserId()))}`
|
||||
}
|
||||
|
||||
export { JAVA_API_PREFIX, http }
|
||||
|
||||
Reference in New Issue
Block a user