liuyu
21 小时以前 93c133349a5ccd7a328371fa113dce69d5611f21
apps/jnpf-web-apps-main/src/api/x/tms/trainArchive.ts
@@ -1,19 +1,19 @@
import type { TrainArchiveDetail } from '#/views/x/tms/trainArchive/types';
import { defHttp } from '#/api/request';
import { mockGetMyTrainArchive } from '#/views/x/tms/trainArchive/mock';
/** 后端未就绪前走 mock;联调后改为 false */
const USE_MOCK = true;
/** 正式路径:/api/tms/train-archive/** */
const prefix = '/api/tms/train-archive';
export function getMyTrainArchive(user?: {
  userId?: string;
  userName?: string;
  userAccount?: string;
  organizeName?: string;
  positionName?: string;
}) {
  if (USE_MOCK) return mockGetMyTrainArchive(user);
  return defHttp.get<TrainArchiveDetail>({ url: `${prefix}/mine` });
async function unwrapData<T>(promise: Promise<any>): Promise<T> {
  const res = await promise;
  if (res && typeof res === 'object' && 'data' in res && ('code' in res || 'msg' in res)) {
    return res.data as T;
  }
  return res as T;
}
/** 当前登录用户的个人培训档案 */
export function getMyTrainArchive() {
  return unwrapData<TrainArchiveDetail>(defHttp.get({ url: `${prefix}/mine` }));
}