【实训查询所有信息列表】

This commit is contained in:
weizhihong 2022-11-28 10:23:14 +08:00
parent 2598afe378
commit 9ac0ad8f44
2 changed files with 36 additions and 24 deletions

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.controller.training2;
import club.joylink.rtss.services.training2.Training2PublishService;
import club.joylink.rtss.services.training2.Training2TypeEnum;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.training2.publish.*;
import lombok.extern.slf4j.Slf4j;
@ -47,20 +48,31 @@ public class TrainingV2PublishController {
public DeletePublishedTraining2RspVo deletePublishedTrainings(@RequestBody DeletePublishedTraining2ReqVo req){
return this.publishService.deletePublishedTrainings(req);
}
/**
* 根据mapId查所有的已发布单操实训的基础信息
*/
@GetMapping("/{mapId}/singles")
public List<PublishedTraining2InfoRspVo> findAllSingleTrainingBasicInfo(@PathVariable("mapId") Long mapId){
public List<PublishedTraining2InfoRspVo> findSingleTrainingBasicInfo(@PathVariable("mapId") Long mapId){
return this.publishService.findAllSingleTrainingBasicInfoByMapId(mapId);
}
/**
* 根据mapId查所有的已发布场景实训的基础信息
*/
@GetMapping("/{mapId}/scenes")
public List<PublishedTraining2InfoRspVo> findAllSceneTrainingBasicInfo(@PathVariable("mapId") Long mapId){
public List<PublishedTraining2InfoRspVo> findSceneTrainingBasicInfo(@PathVariable("mapId") Long mapId){
return this.publishService.findAllSceneTrainingBasicInfoByMapId(mapId);
}
/**
* 查所有的已发布场景实训的基础信息
*/
@GetMapping("/list")
public List<PublishedTraining2InfoRspVo> findTrainingList(Long mapId,Training2TypeEnum type){
return this.publishService.findTrainingInfo(mapId, type);
}
/**
* 根据实训id查该已发布实训的所有信息
*/

View File

@ -19,6 +19,7 @@ import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 已发布实训管理业务实现
@ -202,18 +203,7 @@ public class Training2PublishService {
*/
@Transactional(readOnly = true)
public List<PublishedTraining2InfoRspVo> findAllSingleTrainingBasicInfoByMapId(Long mapId) {
List<PublishedTraining2InfoRspVo> rsp = new ArrayList<>();
//
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andMapIdEqualTo(mapId).andTypeEqualTo(Training2TypeEnum.single.value());
List<PublishedTraining2> list = this.publishedDao.selectByExample(example);
if (!CollectionUtils.isEmpty(list)) {
list.forEach(p -> {
rsp.add(Training2Convertor.convertFrom(p));
});
}
//
return rsp;
return findTrainingInfo(mapId, Training2TypeEnum.single);
}
/**
@ -221,18 +211,28 @@ public class Training2PublishService {
*/
@Transactional(readOnly = true)
public List<PublishedTraining2InfoRspVo> findAllSceneTrainingBasicInfoByMapId(Long mapId) {
List<PublishedTraining2InfoRspVo> rsp = new ArrayList<>();
//
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andMapIdEqualTo(mapId).andTypeEqualTo(Training2TypeEnum.scene.value());
List<PublishedTraining2> list = this.publishedDao.selectByExample(example);
if (!CollectionUtils.isEmpty(list)) {
list.forEach(p -> {
rsp.add(Training2Convertor.convertFrom(p));
});
return findTrainingInfo(mapId, Training2TypeEnum.scene);
}
/**
* 根据地图ID和类型查询实训列表
*/
public List<PublishedTraining2InfoRspVo> findTrainingInfo(Long mapId, Training2TypeEnum type) {
PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria criteria = example.createCriteria();
if (mapId != null) {
criteria.andMapIdEqualTo(mapId);
}
if (type != null) {
criteria.andTypeEqualTo(type.value());
}
List<PublishedTraining2> list = this.publishedDao.selectByExample(example);
if (CollectionUtils.isEmpty(list)) {
return List.of();
} else {
return list.stream().map(Training2Convertor::convertFrom).collect(Collectors.toList());
}
//
return rsp;
}
/**