大赛管理功能
This commit is contained in:
parent
6c1bb1d77f
commit
7e227fb96b
|
@ -1 +1 @@
|
|||
Subproject commit c11e2cdff56d76f466ab41356c078d55563a4140
|
||||
Subproject commit 71cf9d49fb9dbe951b43a482b7649b5f7bf58a3b
|
|
@ -10,7 +10,7 @@ import club.joylink.rtss.vo.race.RacePaper.RacePaperDetailVO;
|
|||
import club.joylink.rtss.vo.race.RacePaper.RacePaperModuleVO;
|
||||
import club.joylink.rtss.vo.race.RacePaper.RacePaperVO;
|
||||
import club.joylink.rtss.vo.race.RacePaperQueryVO;
|
||||
import club.joylink.rtss.vo.race.RaceTask.RacePaperModuleTask;
|
||||
import club.joylink.rtss.vo.race.RaceTask.RacePaperSingleModuleGroupTask;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -78,7 +78,9 @@ public class RacePaperController {
|
|||
}
|
||||
|
||||
@GetMapping("/{paperId}/module/{moduleId}/task")
|
||||
public RacePaperModuleTask paperModuleTask(@PathVariable("paperId") Long id, @PathVariable("moduleId") Integer moduleId) {
|
||||
return this.racePaperService.paperModuleTask(id, moduleId);
|
||||
public RacePaperSingleModuleGroupTask paperModuleTask(@PathVariable("paperId") Long id, @PathVariable("moduleId") Integer moduleId) {
|
||||
return this.racePaperService.singlePaperModuleTask(id, moduleId);
|
||||
|
||||
// return this.racePaperService.paperModuleTask(id, moduleId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package club.joylink.rtss.services.race;
|
|||
import club.joylink.rtss.dao.racetr.RacetrPaperDAO;
|
||||
import club.joylink.rtss.entity.racetr.RacetrPaper;
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
import club.joylink.rtss.vo.AccountVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.common.ModifyInfo.ModifyInfoVO;
|
||||
|
@ -17,14 +16,15 @@ import club.joylink.rtss.vo.race.RacePaperQueryVO;
|
|||
import club.joylink.rtss.vo.race.RaceSeasonOuterClass.RaceSeason.Group;
|
||||
import club.joylink.rtss.vo.race.RaceTask.RacePaperModuleTask;
|
||||
import club.joylink.rtss.vo.race.RaceTask.RacePaperModuleTask.PaperModuleGroup;
|
||||
import club.joylink.rtss.vo.race.RaceTask.RacePaperSingleModuleGroupTask;
|
||||
import club.joylink.rtss.vo.race.RaceTask.RaceTaskChildVO;
|
||||
import club.joylink.rtss.vo.race.RaceTask.RaceTaskChildVO.ChildNodeType;
|
||||
import club.joylink.rtss.vo.race.RaceTaskDetailDTO;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -86,7 +86,7 @@ public class RacePaperService {
|
|||
return PageVO.convert(page, voList);
|
||||
}
|
||||
|
||||
private RacePaperVO convertVO(RacePaperPageVO rp) {
|
||||
private RacePaperVO convertGroupDTO(RacePaperPageVO rp) {
|
||||
RacePaperVO.Builder builder = RacePaperVO.newBuilder();
|
||||
|
||||
ModifyInfoVO modifyInfoVO = RaceServiceUtil.createModifyInfo(rp.getCreatorId(), rp.getCreatorName(), rp.getUpdaterId(), rp.getUpdaterName(), rp.getCreateTime(), rp.getUpdateTime());
|
||||
|
@ -110,7 +110,7 @@ public class RacePaperService {
|
|||
}
|
||||
List<RacePaperVO> voList = Lists.newArrayListWithCapacity(rpList.size());
|
||||
for (RacePaperPageVO rp : rpList) {
|
||||
voList.add(this.convertVO(rp));
|
||||
voList.add(this.convertGroupDTO(rp));
|
||||
}
|
||||
return voList;
|
||||
}
|
||||
|
@ -178,6 +178,43 @@ public class RacePaperService {
|
|||
this.paperDAO.insert(paper);
|
||||
}
|
||||
|
||||
public RacePaperSingleModuleGroupTask singlePaperModuleTask(Long paperId, Integer moduleId) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(moduleId), "请选择对应的模型");
|
||||
RacePaperDetailVO detailVO = this.detail(paperId);
|
||||
RacePaperModuleVO moduleVO = detailVO.getModuleVo();
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!CollectionUtils.isEmpty(moduleVO.getModulesList()), "此试卷没有模块数据");
|
||||
PaperModule pm = moduleVO.getModulesList().stream().filter(d -> d.getCustomModuleId() == moduleId).findFirst().orElse(null);
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(pm), "没有找到对应的模块");
|
||||
|
||||
List<Long> allGroupTaskIds = this.collectAllTaskIds(pm.getGroupList());
|
||||
Map<Long, List<RaceTaskDetailDTO>> taskMapList = this.taskService.recursiveFindTask(allGroupTaskIds);
|
||||
|
||||
List<RaceTaskChildVO> childVOS = this.singleTreeConvertModuleGroup(pm.getGroupList(), taskMapList);
|
||||
RacePaperSingleModuleGroupTask.Builder modultTask = RacePaperSingleModuleGroupTask.newBuilder();
|
||||
modultTask.setCustomModuleId(moduleId);
|
||||
modultTask.addAllChild(childVOS);
|
||||
return modultTask.build();
|
||||
}
|
||||
|
||||
private List<RaceTaskChildVO> singleTreeConvertModuleGroup(List<RacePaperModuleVO.Group> groupList, Map<Long, List<RaceTaskDetailDTO>> allTaskMapList) {
|
||||
List<RaceTaskChildVO> groups = new ArrayList<>();
|
||||
for (RacePaperModuleVO.Group group : groupList) {
|
||||
RaceTaskChildVO.Builder childVOB = RaceTaskChildVO.newBuilder();
|
||||
childVOB.setName(group.getName());
|
||||
childVOB.setNodeType(ChildNodeType.MODULE_GROUP);
|
||||
for (Long taskId : group.getTaskIdsList()) {
|
||||
RaceTaskChildVO taskVO = this.findTask(taskId, allTaskMapList);
|
||||
childVOB.addChildren(taskVO);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(group.getGroupList())) {
|
||||
List<RaceTaskChildVO> childGroup = this.singleTreeConvertModuleGroup(group.getGroupList(), allTaskMapList);
|
||||
childVOB.addAllChildren(childGroup);
|
||||
}
|
||||
groups.add(childVOB.build());
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
public RacePaperModuleTask paperModuleTask(Long paperId, Integer moduleId) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(moduleId), "请选择对应的模型");
|
||||
RacePaperDetailVO detailVO = this.detail(paperId);
|
||||
|
@ -190,12 +227,12 @@ public class RacePaperService {
|
|||
Map<Long, List<RaceTaskDetailDTO>> taskMapList = this.taskService.recursiveFindTask(allGroupTaskIds);
|
||||
RacePaperModuleTask.Builder modultTask = RacePaperModuleTask.newBuilder();
|
||||
modultTask.setCustomModuleId(pm.getCustomModuleId());
|
||||
List<PaperModuleGroup> convertGroupList = this.convert(pm.getGroupList(), taskMapList);
|
||||
List<PaperModuleGroup> convertGroupList = this.convertModuleGroup(pm.getGroupList(), taskMapList);
|
||||
modultTask.addAllModuleGroup(convertGroupList);
|
||||
return modultTask.build();
|
||||
}
|
||||
|
||||
private List<PaperModuleGroup> convert(List<RacePaperModuleVO.Group> groupList, Map<Long, List<RaceTaskDetailDTO>> allTaskMapList) {
|
||||
private List<PaperModuleGroup> convertModuleGroup(List<RacePaperModuleVO.Group> groupList, Map<Long, List<RaceTaskDetailDTO>> allTaskMapList) {
|
||||
List<PaperModuleGroup> groups = new ArrayList<>();
|
||||
for (RacePaperModuleVO.Group group : groupList) {
|
||||
PaperModuleGroup.Builder groupBuilder = PaperModuleGroup.newBuilder();
|
||||
|
@ -205,7 +242,7 @@ public class RacePaperService {
|
|||
groupBuilder.addTreeData(taskVO);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(group.getGroupList())) {
|
||||
List<PaperModuleGroup> childGroup = this.convert(group.getGroupList(), allTaskMapList);
|
||||
List<PaperModuleGroup> childGroup = this.convertModuleGroup(group.getGroupList(), allTaskMapList);
|
||||
groupBuilder.addAllModuleGroup(childGroup);
|
||||
}
|
||||
groups.add(groupBuilder.build());
|
||||
|
@ -217,30 +254,34 @@ public class RacePaperService {
|
|||
List<RaceTaskDetailDTO> dtoList = allTaskMapList.get(RaceTaskService.TASK_ROOT_ID);
|
||||
RaceTaskDetailDTO taskDto = dtoList.stream().filter(d -> Objects.equals(d.getId(), taskId)).findFirst().orElse(null);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(taskDto), String.format("对应的任务没有找到[%s]", taskDto));
|
||||
RaceTaskChildVO.Builder vo = this.convertVO(taskDto);
|
||||
this.childTask(vo, allTaskMapList);
|
||||
RaceTaskChildVO.Builder vo = this.convertGroupDTO(taskDto, ChildNodeType.TASK);
|
||||
this.findChildTask(vo, allTaskMapList);
|
||||
return vo.build();
|
||||
}
|
||||
|
||||
private void childTask(RaceTaskChildVO.Builder vob, Map<Long, List<RaceTaskDetailDTO>> allTaskMapList) {
|
||||
private void findChildTask(RaceTaskChildVO.Builder vob, Map<Long, List<RaceTaskDetailDTO>> allTaskMapList) {
|
||||
List<RaceTaskDetailDTO> childDto = allTaskMapList.get(vob.getId());
|
||||
if (!CollectionUtils.isEmpty(childDto)) {
|
||||
for (RaceTaskDetailDTO ch : childDto) {
|
||||
RaceTaskChildVO.Builder chvo = this.convertVO(ch);
|
||||
RaceTaskChildVO.Builder chvo = this.convertGroupDTO(ch, ChildNodeType.TASK);
|
||||
vob.addChildren(chvo);
|
||||
this.childTask(chvo, allTaskMapList);
|
||||
this.findChildTask(chvo, allTaskMapList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private RaceTaskChildVO.Builder convertVO(RaceTaskDetailDTO dto) {
|
||||
private RaceTaskChildVO.Builder convertGroupDTO(RaceTaskDetailDTO dto, ChildNodeType nodeType) {
|
||||
RaceTaskChildVO.Builder cb = RaceTaskChildVO.newBuilder();
|
||||
cb.setId(dto.getId());
|
||||
if (ChildNodeType.TASK == nodeType) {
|
||||
cb.setId(dto.getId());
|
||||
cb.setDesc(dto.getDesc());
|
||||
cb.setContent(dto.getContent());
|
||||
cb.setStandards(dto.getStandards());
|
||||
cb.setParentId(dto.getParentId());
|
||||
}
|
||||
cb.setNodeType(nodeType);
|
||||
cb.setName(dto.getName());
|
||||
cb.setDesc(dto.getDesc());
|
||||
cb.setContent(dto.getContent());
|
||||
cb.setStandards(dto.getStandards());
|
||||
|
||||
return cb;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,14 +1,12 @@
|
|||
package club.joylink.rtss.services.race;
|
||||
|
||||
import static com.github.pagehelper.util.ExecutorUtil.pageQuery;
|
||||
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.race.RacePaper.RacePaperCreateVO;
|
||||
import club.joylink.rtss.vo.race.RacePaper.RacePaperVO;
|
||||
import club.joylink.rtss.vo.race.RacePaperQueryVO;
|
||||
import club.joylink.rtss.vo.race.RaceSeasonOuterClass.RaceSeason.Group;
|
||||
import club.joylink.rtss.vo.race.RaceTask.RacePaperModuleTask;
|
||||
import club.joylink.rtss.vo.race.RaceTask.RacePaperSingleModuleGroupTask;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
@ -46,7 +44,8 @@ public class PaperServiceTest {
|
|||
|
||||
@Test
|
||||
public void paperModuleTaskTest() {
|
||||
RacePaperModuleTask moduleTask = this.paperService.paperModuleTask(13L, 2);
|
||||
// RacePaperModuleTask moduleTask = this.paperService.paperModuleTask(13L, 2);
|
||||
RacePaperSingleModuleGroupTask moduleTask = this.paperService.singlePaperModuleTask(13L, 2);
|
||||
System.out.println(JsonUtils.writeValueAsString(moduleTask));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue