diff --git a/WeChatApplet/Services/Impl/PatriarchService.cs b/WeChatApplet/Services/Impl/PatriarchService.cs
index a72dee9..fadfb47 100644
--- a/WeChatApplet/Services/Impl/PatriarchService.cs
+++ b/WeChatApplet/Services/Impl/PatriarchService.cs
@@ -186,7 +186,10 @@ namespace YD_WeChatApplet.Api.Services.Impl
///
public async Task StudentReport(string? studentNo)
{
- var res = new StudentReportDto();
+ var res = new StudentReportDto
+ {
+ CategoryScoreList = new List()
+ };
// 若参数为空,则尝试从登录上下文获取当前用户编号
if (string.IsNullOrWhiteSpace(studentNo))
@@ -272,8 +275,6 @@ namespace YD_WeChatApplet.Api.Services.Impl
ScoreTime = x.ScoreTime
}).ToListAsync();
- res.CategoryScoreList = new List();
-
foreach (var item in categorys)
{
// ✅ 当前学生数据
@@ -327,11 +328,11 @@ namespace YD_WeChatApplet.Api.Services.Impl
res.CategoryScoreList.Add(new CategoryScoreDto()
{
- CategoryValue = item.CategoryValue,
+ CategoryValue = item.Id,
Name = item.CategoryName,
Rank = lastResult?.Rank,
- GradeId = lastResult.GradeId,
+ GradeId = lastResult?.GradeId,
PrevScore = prevResult?.Score ?? 0,
LastScore = lastResult?.Score ?? 0,
@@ -340,7 +341,7 @@ namespace YD_WeChatApplet.Api.Services.Impl
//ClassAvgScore = (float)classAvgScore,
SchoolAvgScore = (float)schoolAvgScore,
- ScoreTrendChart = trendChart,
+ ScoreTrendChart = trendChart ?? new ScoreTrendChartDataDto { AxisX = new List(), AxisY = new List() },
ImgUrl = $"{AppSettings.ALiYunOSS.CategoryImgUrl}{item.CategoryEnum}.png"
});
diff --git a/YD_WeChatApplet.Commons/Dto/Patriarch/StudentReportDto.cs b/YD_WeChatApplet.Commons/Dto/Patriarch/StudentReportDto.cs
index ddbc198..7b1ca56 100644
--- a/YD_WeChatApplet.Commons/Dto/Patriarch/StudentReportDto.cs
+++ b/YD_WeChatApplet.Commons/Dto/Patriarch/StudentReportDto.cs
@@ -14,7 +14,7 @@ namespace YD_WeChatApplet.Commons.Dto.Patriarch
///
/// 各项目得分
///
- public List CategoryScoreList { get; set; }
+ public List CategoryScoreList { get; set; } = new List();
}
///
@@ -30,7 +30,7 @@ namespace YD_WeChatApplet.Commons.Dto.Patriarch
///
/// 项目名称
///
- public string Name { get; set; }
+ public string Name { get; set; } = string.Empty;
///
/// 上一次得分
@@ -60,12 +60,12 @@ namespace YD_WeChatApplet.Commons.Dto.Patriarch
///
/// 图片地址
///
- public string ImgUrl { get; set; }
+ public string ImgUrl { get; set; } = string.Empty;
///
/// 等级
///
- public string Rank { get; set; }
+ public string Rank { get; set; } = string.Empty;
///
///年级Id
@@ -75,7 +75,7 @@ namespace YD_WeChatApplet.Commons.Dto.Patriarch
///
/// 成绩趋势图
///
- public ScoreTrendChartDataDto ScoreTrendChart { get; set; }
+ public ScoreTrendChartDataDto ScoreTrendChart { get; set; } = new ScoreTrendChartDataDto();
}
public class ScoreTrendChartDataDto
@@ -83,11 +83,11 @@ namespace YD_WeChatApplet.Commons.Dto.Patriarch
///
/// X轴
///
- public List AxisX { get; set; }
+ public List AxisX { get; set; } = new List();
///
/// Y轴
///
- public List AxisY { get; set; }
+ public List AxisY { get; set; } = new List();
}
}