From 8534025c45b4736975730678b9ccf23570a75f95 Mon Sep 17 00:00:00 2001
From: liuyu <yu.liu@cqgbkj.com>
Date: 星期二, 22 九月 2026 09:25:48 +0800
Subject: [PATCH] feat(tms): 新增试卷、培训任务、个人任务页面
---
apps/jnpf-web-apps-main/src/api/x/tms/selfTest.ts | 49 +++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/apps/jnpf-web-apps-main/src/api/x/tms/selfTest.ts b/apps/jnpf-web-apps-main/src/api/x/tms/selfTest.ts
index 0667daf..38a18e1 100644
--- a/apps/jnpf-web-apps-main/src/api/x/tms/selfTest.ts
+++ b/apps/jnpf-web-apps-main/src/api/x/tms/selfTest.ts
@@ -1,19 +1,56 @@
import type { QuestionBankOption } from '#/views/x/tms/question/types';
-import type { SelfTestPaper, SelfTestStartPayload } from '#/views/x/tms/selfTest/types';
+import type {
+ SelfTestPaper,
+ SelfTestStartPayload,
+ SelfTestSubmitPayload,
+ SelfTestSubmitResult,
+ SelfTestRecordItem,
+} from '#/views/x/tms/selfTest/types';
import { defHttp } from '#/api/request';
import { getQuestionBanks } from '#/api/x/tms/question';
-import { mockStartSelfTest } from '#/views/x/tms/selfTest/mock';
-/** 鍚庣鏈氨缁墠璧� mock锛涜仈璋冨悗鏀逛负 false */
-const USE_MOCK = true;
+/** 姝e紡璺緞锛�/api/tms/self-test/** */
const prefix = '/api/tms/self-test';
+
+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 getSelfTestBanks() {
return getQuestionBanks() as Promise<QuestionBankOption[]>;
}
export function startSelfTest(data: SelfTestStartPayload) {
- if (USE_MOCK) return mockStartSelfTest(data);
- return defHttp.post<SelfTestPaper>({ url: `${prefix}/start`, data });
+ return unwrapData<SelfTestPaper>(defHttp.post({ url: `${prefix}/start`, data }));
+}
+
+/** 鏆傚瓨浣滅瓟锛堜笉浜ゅ嵎锛屼究浜庣户缁�冭瘯锛� */
+export function saveSelfTest(paperId: string, data: SelfTestSubmitPayload) {
+ return unwrapData<string>(defHttp.post({ url: `${prefix}/${paperId}/save`, data }));
+}
+
+export function submitSelfTest(paperId: string, data: SelfTestSubmitPayload) {
+ return unwrapData<SelfTestSubmitResult>(defHttp.post({ url: `${prefix}/${paperId}/submit`, data }));
+}
+
+export function getSelfTestList(params?: {
+ currentPage?: number;
+ pageSize?: number;
+ bankId?: string;
+ testStatus?: string;
+ startTimeBegin?: string;
+ startTimeEnd?: string;
+}) {
+ return unwrapData<{ list: SelfTestRecordItem[]; pagination: Record<string, any> }>(
+ defHttp.get({ url: `${prefix}/list`, params }),
+ );
+}
+
+export function getSelfTestInfo(id: string) {
+ return unwrapData<SelfTestPaper>(defHttp.get({ url: `${prefix}/${id}` }));
}
--
Gitblit v1.8.0