67 lines
2.0 KiB
TypeScript
67 lines
2.0 KiB
TypeScript
|
|
/**
|
||
|
|
* 操作日志 API
|
||
|
|
*/
|
||
|
|
import { get } from '@/utils/request';
|
||
|
|
import { USE_MOCK, MOCK_DELAY } from '@/config/mock';
|
||
|
|
import { buildMockOperationLogPage } from '@/config/mock/operationLogs';
|
||
|
|
import { buildMockEventOperationLogPage } from '@/config/mock/eventOperationLogs';
|
||
|
|
import type {
|
||
|
|
OperationLogQueryParams,
|
||
|
|
SysOperationLogVO,
|
||
|
|
TournamentAdminOperationPageVO,
|
||
|
|
PageData,
|
||
|
|
ApiResult,
|
||
|
|
} from './types';
|
||
|
|
|
||
|
|
export type {
|
||
|
|
SysOperationLogVO,
|
||
|
|
TournamentAdminOperationPageVO,
|
||
|
|
OperationLogQueryParams,
|
||
|
|
PageData,
|
||
|
|
ApiResult,
|
||
|
|
} from './types';
|
||
|
|
|
||
|
|
const delay = (ms: number) => new Promise<void>((r) => setTimeout(r, ms));
|
||
|
|
|
||
|
|
function pickFilters(params: OperationLogQueryParams): OperationLogQueryParams {
|
||
|
|
const { page: _page, limit: _limit, ...filters } = params;
|
||
|
|
return filters;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** GET /admin/sys/operation/page — 系统操作日志分页 */
|
||
|
|
export async function getOperationLogList(
|
||
|
|
params: OperationLogQueryParams,
|
||
|
|
): Promise<ApiResult<PageData<SysOperationLogVO>>> {
|
||
|
|
if (USE_MOCK) {
|
||
|
|
await delay(MOCK_DELAY);
|
||
|
|
const page = Number(params.page) || 1;
|
||
|
|
const limit = Number(params.limit) || 10;
|
||
|
|
return {
|
||
|
|
code: 200,
|
||
|
|
msg: 'success',
|
||
|
|
data: buildMockOperationLogPage(page, limit, pickFilters(params)),
|
||
|
|
};
|
||
|
|
}
|
||
|
|
return get('/admin/sys/operation/page', params as Record<string, any>);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** GET /admin/tournament/operation/page — 赛事操作日志分页 */
|
||
|
|
export async function getOperationLogs(
|
||
|
|
params: OperationLogQueryParams,
|
||
|
|
): Promise<ApiResult<PageData<TournamentAdminOperationPageVO>>> {
|
||
|
|
if (USE_MOCK) {
|
||
|
|
await delay(MOCK_DELAY);
|
||
|
|
const page = Number(params.page) || 1;
|
||
|
|
const limit = Number(params.limit) || 10;
|
||
|
|
return {
|
||
|
|
code: 200,
|
||
|
|
msg: 'success',
|
||
|
|
data: buildMockEventOperationLogPage(page, limit, pickFilters(params)),
|
||
|
|
};
|
||
|
|
}
|
||
|
|
return get('/admin/tournament/operation/page', params as Record<string, any>);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** @deprecated 使用 getOperationLogList */
|
||
|
|
export const getOperationLogPage = getOperationLogList;
|