diff --git a/WeChatApplet/Controllers/PatriarchController.cs b/WeChatApplet/Controllers/PatriarchController.cs index 42cb810..c460f45 100644 --- a/WeChatApplet/Controllers/PatriarchController.cs +++ b/WeChatApplet/Controllers/PatriarchController.cs @@ -63,7 +63,7 @@ namespace YD_WeChatApplet.Api.Controllers /// /// [HttpGet("StudentReport")] - public async Task StudentReport(string studentNo) + public async Task StudentReport(string? studentNo) { var res = await _patriarchService.StudentReport(studentNo); return res; diff --git a/WeChatApplet/Services/Impl/PatriarchService.cs b/WeChatApplet/Services/Impl/PatriarchService.cs index 888fef4..4792471 100644 --- a/WeChatApplet/Services/Impl/PatriarchService.cs +++ b/WeChatApplet/Services/Impl/PatriarchService.cs @@ -184,15 +184,20 @@ namespace YD_WeChatApplet.Api.Services.Impl /// 学生报告 /// /// - public async Task StudentReport(string studentNo) + public async Task StudentReport(string? studentNo) { var res = new StudentReportDto(); + // 若参数为空,则尝试从登录上下文获取当前用户编号 + if (string.IsNullOrWhiteSpace(studentNo)) + { + studentNo = UserLoginContext.Current.UserNo; + } + + // 最终编号仍为空,则直接返回空结果 if (string.IsNullOrWhiteSpace(studentNo)) return res; - //var studentNo = UserLoginContext.Current.UserNo; - var student = await _sportsContext.Student.Where(x => x.StudentNo == studentNo).FirstOrDefaultAsync(); if (student == null) diff --git a/WeChatApplet/Services/Interface/IPatriarchService.cs b/WeChatApplet/Services/Interface/IPatriarchService.cs index 5013d90..37bdc49 100644 --- a/WeChatApplet/Services/Interface/IPatriarchService.cs +++ b/WeChatApplet/Services/Interface/IPatriarchService.cs @@ -42,7 +42,7 @@ namespace YD_WeChatApplet.Services /// 学生报告 /// /// - Task StudentReport(string studentNo); + Task StudentReport(string? studentNo); /// /// 训练记录