1. 新增我的考试页面,包含学科筛选Tab和分页考试列表 2. 新增学科图标工具类,替换我的报告页重复的学科图标逻辑 3. 在我的页面菜单中添加我的考试入口 4. 新增exam模块的API接口和数据模型 5. 优化我的报告页面卡片样式,统一与考试卡片的布局
52 lines
1.7 KiB
Dart
52 lines
1.7 KiB
Dart
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<List<ExamSubjectTab>> getSubjects() async {
|
|
final data = await DioClient.instance
|
|
.get('/api/v1/Evaluation/GetSubjects');
|
|
final list = data is List
|
|
? data.whereType<Map<String, dynamic>>().toList()
|
|
: (data is Map<String, dynamic>
|
|
? (data['data'] as List<dynamic>? ?? const [])
|
|
: const [])
|
|
.whereType<Map<String, dynamic>>()
|
|
.toList();
|
|
return list.map(ExamSubjectTab.fromJson).toList();
|
|
}
|
|
|
|
/// 我的考试分页列表
|
|
/// GET /api/v1/Evaluation/Search
|
|
/// 参数:baseSubjectId(可 null=全部)/ pageIndex / pageSize
|
|
Future<ExamResponse> 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<String, dynamic>);
|
|
}
|
|
}
|