modify scoreList

This commit is contained in:
ray.ma 2025-04-24 17:22:37 +08:00
parent 6dac497391
commit cbb93384a5
2 changed files with 7 additions and 6 deletions

View File

@ -86,10 +86,7 @@ public class ScoreController extends CommonController{
// 学生各科成绩查询: 指定学年学期的学生各科成绩查询 // 学生各科成绩查询: 指定学年学期的学生各科成绩查询
@LoginCheck(required = true) @LoginCheck(required = true)
@GetMapping("/subjects") @GetMapping("/subjects")
public Result<List<ScoreInfo>> subjectList(@RequestParam Long accountId, @RequestParam Integer year, @RequestParam Integer term) { public Result<List<ScoreInfo>> subjectList(@RequestParam(required = false) Long accountId, @RequestParam(required = false) Integer year, @RequestParam(required = false) Integer term) {
if (year == null || term == null) {
return Result.fail(BaseErrorCode.PARAM_INVALID);
}
if (accountId == null) { if (accountId == null) {
accountId = getUserId(); accountId = getUserId();
} }

View File

@ -97,8 +97,12 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreMapper, Stu
public List<ScoreInfo> studentScoreList(Long accountId, Integer year, Integer term) { public List<ScoreInfo> studentScoreList(Long accountId, Integer year, Integer term) {
LambdaQueryWrapper<StudentScoreEntity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StudentScoreEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StudentScoreEntity::getAccountId, accountId); queryWrapper.eq(StudentScoreEntity::getAccountId, accountId);
if (year != null) {
queryWrapper.eq(StudentScoreEntity::getYear, year); queryWrapper.eq(StudentScoreEntity::getYear, year);
}
if (term != null) {
queryWrapper.eq(StudentScoreEntity::getTerm, term); queryWrapper.eq(StudentScoreEntity::getTerm, term);
}
List<StudentScoreEntity> scoreList = list(queryWrapper); List<StudentScoreEntity> scoreList = list(queryWrapper);
if (CollectionUtils.isEmpty(scoreList)) { if (CollectionUtils.isEmpty(scoreList)) {
return new ArrayList<>(); return new ArrayList<>();