feat: 新增诊断报告全流程功能,适配登录后报告跳转逻辑

实现了入门测/出门测报告的完整链路:
1. 新增UserInfo模型的出门测报告标记字段与相关接口
2. 新增全局报告路由拦截器,自动在登录后/应用回前台时检查报告状态
3. 新增报告相关API、页面与路由配置,包含欢迎页、H5壳子、AI计算页
4. 适配登录成功后的报告跳转逻辑,更新用户状态管理方法
This commit is contained in:
崔宝新
2026-09-09 16:49:51 +08:00
parent c0c673e2d2
commit 5e4cfe9ac6
13 changed files with 1441 additions and 18 deletions
+46
View File
@@ -0,0 +1,46 @@
import 'package:new_learn/core/api/report/model.dart';
import 'package:new_learn/core/network/dio_client.dart';
/// ============================================================
/// 【report 模块接口】入门测/出门测诊断报告 —— 对标 Vue3 端 api/report/index.ts
///
/// 注意:这个模块是"诊断报告包"那条链路的接口(studentInfo / reportComputation 页用),
/// 与 core/api/my_report(历史报告列表)不是同一个业务模块。
///
/// getCurrentReport() → 入门测报告(placementTest)
/// getCurrentAfterReport() → 出门测报告(exitTest)
/// getCurrentReportKnow() → 当前用户未掌握知识点(reportComputation AI 动画页用)
/// ============================================================
class ReportApi {
ReportApi._();
static final ReportApi instance = ReportApi._();
/// 获取当前用户入门测试报告 → GET /api/v1/UserReport/GetCurrentReport
Future<UserReportType> getCurrentReport() async {
final data = await DioClient.instance.get(
'/api/v1/UserReport/GetCurrentReport',
);
return UserReportType.fromJson(data as Map<String, dynamic>);
}
/// 获取当前用户出门测试报告 → GET /api/v1/UserReport/GetCurrentAfterReport
Future<UserReportType> getCurrentAfterReport() async {
final data = await DioClient.instance.get(
'/api/v1/UserReport/GetCurrentAfterReport',
);
return UserReportType.fromJson(data as Map<String, dynamic>);
}
/// 获取当前用户未掌握的知识点 → GET /api/v1/UserReport/GetCurrentReportKnow
Future<List<UserReportKnowType>> getCurrentReportKnow() async {
final data = await DioClient.instance.get(
'/api/v1/UserReport/GetCurrentReportKnow',
);
final list = data is List ? data : (data['data'] as List<dynamic>? ?? const []);
return list
.whereType<Map<String, dynamic>>()
.map(UserReportKnowType.fromJson)
.toList();
}
}
+80
View File
@@ -0,0 +1,80 @@
/// ============================================================
/// 【report 模块模型】入门测/出门测报告 —— 对标 Vue3 端 api/report/type.ts
///
/// 注意:这个模块是"诊断报告包"(报告状态流转那条链路用的),
/// 与 core/api/my_report(历史报告列表)不是同一个业务模块。
///
/// SubjectReportType → 单科目报告(科目名/图标/知识点数/报告URL)
/// UserReportType → 当前用户诊断报告整体(用户名/能力等级/科目列表)
/// UserReportKnowType → 当前用户未掌握的知识点(reportComputation 页用)
///
/// 序列化:手动 fromJson,与项目其他模块风格一致,不依赖 build_runner。
/// ============================================================
library;
/// 单科目报告信息
class SubjectReportType {
const SubjectReportType({
this.subjectName = '',
this.url = '',
this.icon = '',
this.knowledgePoint = 0,
});
final String subjectName;
final String url;
final String icon;
final int knowledgePoint;
factory SubjectReportType.fromJson(Map<String, dynamic> json) {
return SubjectReportType(
subjectName: (json['subjectName'] as String?) ?? '',
url: (json['url'] as String?) ?? '',
icon: (json['icon'] as String?) ?? '',
knowledgePoint: (json['knowledgePoint'] as num?)?.toInt() ?? 0,
);
}
}
/// 当前用户诊断报告整体
class UserReportType {
const UserReportType({
this.userName = '',
this.userLevel = '',
this.subjectReports = const [],
});
final String userName;
final String userLevel;
final List<SubjectReportType> subjectReports;
factory UserReportType.fromJson(Map<String, dynamic> json) {
final payload = (json['data'] as Map<String, dynamic>?) ?? json;
return UserReportType(
userName: (payload['userName'] as String?) ?? '',
userLevel: (payload['userLevel'] as String?) ?? '',
subjectReports: (payload['subjectReports'] as List<dynamic>? ?? const [])
.whereType<Map<String, dynamic>>()
.map(SubjectReportType.fromJson)
.toList(),
);
}
}
/// 当前用户未掌握的知识点(reportComputation AI加载动画页用)
class UserReportKnowType {
const UserReportKnowType({
this.subjectName = '',
this.knowCount = 0,
});
final String subjectName;
final int knowCount;
factory UserReportKnowType.fromJson(Map<String, dynamic> json) {
return UserReportKnowType(
subjectName: (json['subjectName'] as String?) ?? '',
knowCount: (json['knowCount'] as num?)?.toInt() ?? 0,
);
}
}