| | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | public Result studentPage(ExamQuery query) { |
| | | IPage<ExamVO> page = PageUtil.getPage(query, ExamVO.class); |
| | | baseMapper.studentPage(page, query, webContext.getCurrentUser().getId()); |
| | | for (ExamVO record : page.getRecords()) { |
| | | ExamSubmitTemp one = new LambdaQueryChainWrapper<>(examSubmitTempMapper) |
| | | .eq(ExamSubmitTemp::getExamId, record.getId()) |
| | | .eq(ExamSubmitTemp::getUserId, webContext.getCurrentUser().getId()) |
| | | .one(); |
| | | record.setIsContinue(Objects.isNull(one) || ExamSubmitTempStatusEnum.temp.equals(one.getExamSubmit())); |
| | | } |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result all() { |
| | | List<Exam> entities = baseMapper.selectList(null); |
| | | public Result all(ExamQuery query) { |
| | | List<Exam> entities; |
| | | // 判断如果examName为空或空字符串,则查询所有 |
| | | if (query.getExamName() == null || query.getExamName().isEmpty()) { |
| | | entities = baseMapper.selectList(null); |
| | | }else { |
| | | entities = baseMapper.selectList(new LambdaQueryWrapper<>(Exam.class).like(Exam::getExamName,query.getExamName())); |
| | | } |
| | | List<ExamVO> vos = entities.stream() |
| | | .map(entity -> ExamVO.getVoByEntity(entity, null)) |
| | | .map(entity -> { |
| | | ExamVO vo = new ExamVO(); |
| | | vo = ExamVO.getVoByEntity(entity, vo); |
| | | vo.setStatus(entity.getStatus().getDesc()); |
| | | return vo; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | return Result.ok().data(vos); |
| | | } |