| | |
| | | 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` })); |
| | | } |