| | |
| | | |
| | | 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; |
| | |
| | | * @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); |
| | | } |