feat: parse and merge undergraduate exam schedules

This commit is contained in:
Codex
2026-10-14 23:35:30 +08:00
parent 17e4903399
commit ebe70e3eb2
4 changed files with 384 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
import 'dart:convert';
import 'package:html/parser.dart' as html;
import '../domain/exam_schedule.dart';
import '../features/school/school_exam_adapter.dart';
import '../features/school/undergraduate/exam_adapter.dart';
class ExamFileImport {
static ExamSchedule parse(String content) {
if (utf8.encode(content).length > 2 * 1024 * 1024)
throw const FormatException('文件不能超过2MB');
final doc = html.parse(content.replaceFirst('\uFEFF', ''));
if (doc.querySelector('#stdExamTableForm') != null)
return UndergraduateExamAdapter.extract(content);
if (doc.querySelector('#sample-table-1') != null)
return SchoolExamAdapter.extract(content);
throw const FormatException('未识别到学校排考页面');
}
}