基本功能完成,下一步开始美化UI

This commit is contained in:
2025-12-19 16:02:38 +08:00
parent 465d4d7b4a
commit 6ac216d184
46 changed files with 2576 additions and 618 deletions

View File

@@ -8,6 +8,7 @@ export interface ExamTask {
startAt: string;
endAt: string;
createdAt: string;
selectionConfig?: string; // JSON string
}
export interface ExamTaskUser {
@@ -178,7 +179,7 @@ export class ExamTaskModel {
}
static async findById(id: string): Promise<ExamTask | null> {
const sql = `SELECT id, name, subject_id as subjectId, start_at as startAt, end_at as endAt, created_at as createdAt FROM exam_tasks WHERE id = ?`;
const sql = `SELECT id, name, subject_id as subjectId, start_at as startAt, end_at as endAt, created_at as createdAt, selection_config as selectionConfig FROM exam_tasks WHERE id = ?`;
const row = await get(sql, [id]);
return row || null;
}
@@ -189,6 +190,7 @@ export class ExamTaskModel {
startAt: string;
endAt: string;
userIds: string[];
selectionConfig?: string;
}): Promise<ExamTask> {
if (!data.name.trim()) throw new Error('任务名称不能为空');
if (!data.userIds.length) throw new Error('至少选择一位用户');
@@ -198,8 +200,8 @@ export class ExamTaskModel {
const id = uuidv4();
const sqlTask = `
INSERT INTO exam_tasks (id, name, subject_id, start_at, end_at)
VALUES (?, ?, ?, ?, ?)
INSERT INTO exam_tasks (id, name, subject_id, start_at, end_at, selection_config)
VALUES (?, ?, ?, ?, ?, ?)
`;
const sqlTaskUser = `
@@ -207,7 +209,7 @@ export class ExamTaskModel {
VALUES (?, ?, ?)
`;
await run(sqlTask, [id, data.name.trim(), data.subjectId, data.startAt, data.endAt]);
await run(sqlTask, [id, data.name.trim(), data.subjectId, data.startAt, data.endAt, data.selectionConfig || null]);
for (const userId of data.userIds) {
await run(sqlTaskUser, [uuidv4(), id, userId]);
@@ -222,6 +224,7 @@ export class ExamTaskModel {
startAt: string;
endAt: string;
userIds: string[];
selectionConfig?: string;
}): Promise<ExamTask> {
const existing = await this.findById(id);
if (!existing) throw new Error('任务不存在');
@@ -232,11 +235,12 @@ export class ExamTaskModel {
const subject = await import('./examSubject').then(({ ExamSubjectModel }) => ExamSubjectModel.findById(data.subjectId));
if (!subject) throw new Error('科目不存在');
await run(`UPDATE exam_tasks SET name = ?, subject_id = ?, start_at = ?, end_at = ? WHERE id = ?`, [
await run(`UPDATE exam_tasks SET name = ?, subject_id = ?, start_at = ?, end_at = ?, selection_config = ? WHERE id = ?`, [
data.name.trim(),
data.subjectId,
data.startAt,
data.endAt,
data.selectionConfig || null,
id
]);