import 'package:new_learn/core/api/exam/model.dart'; import 'package:new_learn/core/network/dio_client.dart'; /// ============================================================ /// 【exam 模块接口】我的考试 —— 对标 Vue3 端 api/exam/index.ts /// /// getSubjects —— 获取考试学科筛选 Tab 列表 /// search —— 我的考试分页列表 /// /// 注意:考试报告详情(getReport)等考试做题相关接口, /// 后续扩展时再按模块拆分补进来。 /// ============================================================ class ExamApi { ExamApi._(); static final ExamApi instance = ExamApi._(); /// 考试学科筛选 Tab 列表 /// GET /api/v1/Evaluation/GetSubjects Future> getSubjects() async { final data = await DioClient.instance .get('/api/v1/Evaluation/GetSubjects'); final list = data is List ? data.whereType>().toList() : (data is Map ? (data['data'] as List? ?? const []) : const []) .whereType>() .toList(); return list.map(ExamSubjectTab.fromJson).toList(); } /// 我的考试分页列表 /// GET /api/v1/Evaluation/Search /// 参数:baseSubjectId(可 null=全部)/ pageIndex / pageSize Future search({ int? baseSubjectId, required int pageIndex, int pageSize = 10, }) async { final data = await DioClient.instance.get( '/api/v1/Evaluation/Search', query: { if (baseSubjectId != null) 'baseSubjectId': baseSubjectId, 'pageIndex': pageIndex, 'pageSize': pageSize, }, ); return ExamResponse.fromJson(data as Map); } }