改造后台权限和APP权限
This commit is contained in:
@@ -955,6 +955,8 @@ export interface PriceTrackDashboardVo {
|
||||
export interface PriceTrackHistoryItem {
|
||||
resultId?: number;
|
||||
taskId?: number;
|
||||
loopRunId?: number;
|
||||
roundIndex?: number;
|
||||
shopName?: string;
|
||||
shopId?: number | string | null;
|
||||
platform?: string;
|
||||
@@ -998,6 +1000,8 @@ export interface PriceTrackTaskSummary {
|
||||
id?: number;
|
||||
taskNo?: string;
|
||||
status?: string;
|
||||
loopRunId?: number;
|
||||
roundIndex?: number;
|
||||
errorMessage?: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
@@ -1146,6 +1150,45 @@ export interface PriceTrackCreateTaskRequest {
|
||||
items: PriceTrackShopQueueItem[];
|
||||
asinFiles: string[];
|
||||
countryCodes: string[];
|
||||
loopRunId?: number;
|
||||
roundIndex?: number;
|
||||
shopIndex?: number;
|
||||
}
|
||||
|
||||
export type PriceTrackExecutionMode = "FINITE" | "INFINITE";
|
||||
|
||||
export interface PriceTrackLoopRunCreateRequest {
|
||||
userId: number;
|
||||
statusMode: boolean;
|
||||
asinMode: boolean;
|
||||
items: PriceTrackShopQueueItem[];
|
||||
asinFiles: string[];
|
||||
countryCodes: string[];
|
||||
executionMode: PriceTrackExecutionMode;
|
||||
targetRounds?: number;
|
||||
}
|
||||
|
||||
export interface PriceTrackLoopRunVo {
|
||||
id: number;
|
||||
status?: string;
|
||||
executionMode?: PriceTrackExecutionMode;
|
||||
targetRounds?: number;
|
||||
currentRound?: number;
|
||||
currentShopIndex?: number;
|
||||
totalShopCount?: number;
|
||||
activeTaskId?: number;
|
||||
activeTaskStatus?: string;
|
||||
stopRequested?: boolean;
|
||||
errorMessage?: string;
|
||||
statusMode?: boolean;
|
||||
asinMode?: boolean;
|
||||
asinFiles?: string[];
|
||||
countryCodes?: string[];
|
||||
}
|
||||
|
||||
export interface PriceTrackLoopRunDispatchVo {
|
||||
loopRun?: PriceTrackLoopRunVo;
|
||||
childTaskRequest?: PriceTrackCreateTaskRequest;
|
||||
}
|
||||
|
||||
export function createPriceTrackTask(
|
||||
@@ -1176,6 +1219,52 @@ export function getPriceTrackTasksBatch(taskIds: number[]) {
|
||||
);
|
||||
}
|
||||
|
||||
export function createPriceTrackLoopRun(
|
||||
request: Omit<PriceTrackLoopRunCreateRequest, "userId"> | PriceTrackLoopRunCreateRequest,
|
||||
) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<PriceTrackLoopRunVo>, PriceTrackLoopRunCreateRequest>(
|
||||
`${JAVA_API_PREFIX}/price-track/loop-runs`,
|
||||
{ ...request, userId: getCurrentUserId() },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function getPriceTrackLoopRun(loopRunId: number) {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<PriceTrackLoopRunVo>>(
|
||||
`${JAVA_API_PREFIX}/price-track/loop-runs/${loopRunId}?user_id=${encodeURIComponent(String(getCurrentUserId()))}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function dispatchNextPriceTrackLoopRun(loopRunId: number) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<PriceTrackLoopRunDispatchVo>, undefined>(
|
||||
`${JAVA_API_PREFIX}/price-track/loop-runs/${loopRunId}/dispatch-next?user_id=${encodeURIComponent(String(getCurrentUserId()))}`,
|
||||
undefined,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function completePriceTrackLoopChild(loopRunId: number, childTaskId: number) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<PriceTrackLoopRunVo>, { childTaskId: number }>(
|
||||
`${JAVA_API_PREFIX}/price-track/loop-runs/${loopRunId}/child-finished?user_id=${encodeURIComponent(String(getCurrentUserId()))}`,
|
||||
{ childTaskId },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function stopPriceTrackLoopRun(loopRunId: number) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<PriceTrackLoopRunVo>, undefined>(
|
||||
`${JAVA_API_PREFIX}/price-track/loop-runs/${loopRunId}/stop?user_id=${encodeURIComponent(String(getCurrentUserId()))}`,
|
||||
undefined,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function getPriceTrackTaskProgressBatch(taskIds: number[]) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<PriceTrackTaskBatchVo>, { taskIds: number[] }>(
|
||||
|
||||
63
frontend-vue/src/shared/api/permission.ts
Normal file
63
frontend-vue/src/shared/api/permission.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { requestGetJson } from '@/shared/api/http'
|
||||
|
||||
export interface PermissionMenuItem {
|
||||
id: number | string
|
||||
name?: string
|
||||
column_key?: string
|
||||
route_path?: string
|
||||
menu_type?: string
|
||||
sort_order?: number
|
||||
created_at?: string
|
||||
}
|
||||
|
||||
interface PermissionMenuResponse {
|
||||
success: boolean
|
||||
items?: PermissionMenuItem[]
|
||||
error?: string
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
function getAppPermissionCacheKey(uid: number) {
|
||||
return `app_column_permissions:${String(uid)}`
|
||||
}
|
||||
|
||||
export async function getCurrentUserAppColumnKeys() {
|
||||
const uid = getCurrentUserId()
|
||||
const cacheKey = getAppPermissionCacheKey(uid)
|
||||
|
||||
try {
|
||||
const cachedItems = JSON.parse(window.localStorage.getItem(cacheKey) || 'null') as PermissionMenuItem[] | null
|
||||
if (Array.isArray(cachedItems)) {
|
||||
return cachedItems
|
||||
.map((item) => String(item.column_key || '').trim().toLowerCase())
|
||||
.filter(Boolean)
|
||||
}
|
||||
} catch (_error) {}
|
||||
|
||||
const res = await requestGetJson<PermissionMenuResponse>(
|
||||
`/api/admin/user/${encodeURIComponent(String(uid))}/column-permissions`,
|
||||
{
|
||||
params: { menu_type: 'app' },
|
||||
},
|
||||
)
|
||||
|
||||
if (!res.success) {
|
||||
throw new Error(res.error || '获取菜单权限失败')
|
||||
}
|
||||
|
||||
try {
|
||||
window.localStorage.setItem(cacheKey, JSON.stringify(res.items || []))
|
||||
} catch (_error) {}
|
||||
|
||||
return (res.items || [])
|
||||
.map((item) => String(item.column_key || '').trim().toLowerCase())
|
||||
.filter(Boolean)
|
||||
}
|
||||
Reference in New Issue
Block a user