新增文本题库导入功能,题目新增“解析”字段
This commit is contained in:
@@ -187,6 +187,55 @@ export class AdminController {
|
||||
}
|
||||
}
|
||||
|
||||
static async getAllTaskStats(req: Request, res: Response) {
|
||||
try {
|
||||
const page = toPositiveInt(req.query.page, 1);
|
||||
const limit = toPositiveInt(req.query.limit, 5);
|
||||
|
||||
const statusRaw = typeof req.query.status === 'string' ? req.query.status : undefined;
|
||||
const status =
|
||||
statusRaw === 'completed' || statusRaw === 'ongoing' || statusRaw === 'notStarted'
|
||||
? statusRaw
|
||||
: undefined;
|
||||
|
||||
const endAtStart = typeof req.query.endAtStart === 'string' ? req.query.endAtStart : undefined;
|
||||
const endAtEnd = typeof req.query.endAtEnd === 'string' ? req.query.endAtEnd : undefined;
|
||||
|
||||
if (endAtStart && !Number.isFinite(Date.parse(endAtStart))) {
|
||||
return res.status(400).json({ success: false, message: 'endAtStart 参数无效' });
|
||||
}
|
||||
if (endAtEnd && !Number.isFinite(Date.parse(endAtEnd))) {
|
||||
return res.status(400).json({ success: false, message: 'endAtEnd 参数无效' });
|
||||
}
|
||||
|
||||
const { ExamTaskModel } = await import('../models/examTask');
|
||||
const result = await ExamTaskModel.getAllTasksWithStatsPaged({
|
||||
page,
|
||||
limit,
|
||||
status,
|
||||
endAtStart,
|
||||
endAtEnd,
|
||||
});
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
data: result.data,
|
||||
pagination: {
|
||||
page,
|
||||
limit,
|
||||
total: result.total,
|
||||
pages: Math.ceil(result.total / limit),
|
||||
},
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error('获取任务统计失败:', error);
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: error.message || '获取任务统计失败',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static async getDashboardOverview(req: Request, res: Response) {
|
||||
try {
|
||||
const { QuizModel } = await import('../models');
|
||||
|
||||
Reference in New Issue
Block a user