diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSchemeController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSchemeController.java index 58bfdf62..0728e85d 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSchemeController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSchemeController.java @@ -4,8 +4,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import pc.exam.pp.framework.common.pojo.CommonResult; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperScheme; +import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask; import pc.exam.pp.module.exam.service.paper.IEducationPaperSchemeService; import pc.exam.pp.module.exam.service.paper.IEducationPaperService; +import pc.exam.pp.module.exam.service.paper.IEducationPaperTaskService; import java.util.List; @@ -24,8 +26,10 @@ public class EducationPaperSchemeController { @Autowired private IEducationPaperSchemeService educationPaperSchemeService; -@Autowired -private IEducationPaperService educationPaperService; + @Autowired + private IEducationPaperService educationPaperService; + @Autowired + private IEducationPaperTaskService educationPaperTaskService; /** * 查询试卷方案列表 */ @@ -63,10 +67,17 @@ private IEducationPaperService educationPaperService; public CommonResult add(@RequestBody EducationPaperScheme educationPaperScheme) { - List strings = educationPaperService.selectPaperByTaskId(educationPaperScheme.getTaskId()); - if (strings!=null&&strings.size()>0){ - return CommonResult.error(DEMO03_PAPER_TASK_ADD_EXISTS); + + EducationPaperTask educationPaperTask = educationPaperTaskService.selectEducationPaperTaskByTaskId(educationPaperScheme.getTaskId()); + String taskType = educationPaperTask.getTaskType(); + if ( "0".equals(taskType)||"1".equals(taskType)||"3".equals(taskType)) { + List strings = educationPaperService.selectPaperByTaskId(educationPaperScheme.getTaskId()); + if (strings!=null&&strings.size()>0){ + return CommonResult.error(DEMO03_PAPER_TASK_ADD_EXISTS); + } } + + return CommonResult.success(educationPaperSchemeService.insertEducationPaperScheme(educationPaperScheme)); } @@ -86,10 +97,17 @@ private IEducationPaperService educationPaperService; public CommonResult remove(@PathVariable String schemeIds) { EducationPaperScheme educationPaperScheme = educationPaperSchemeService.selectEducationPaperSchemeBySchemeId(schemeIds); - List strings = educationPaperService.selectPaperByTaskId(educationPaperScheme.getTaskId()); - if (strings!=null&&strings.size()>0){ - return CommonResult.error(DEMO03_PAPER_TASK_DEL_EXISTS); + + EducationPaperTask educationPaperTask = educationPaperTaskService.selectEducationPaperTaskByTaskId(educationPaperScheme.getTaskId()); + String taskType = educationPaperTask.getTaskType(); + if ( "0".equals(taskType)||"1".equals(taskType)||"3".equals(taskType)){ + List strings = educationPaperService.selectPaperByTaskId(educationPaperScheme.getTaskId()); + if (strings!=null&&strings.size()>0){ + return CommonResult.error(DEMO03_PAPER_TASK_DEL_EXISTS); + } } + + return CommonResult.success(educationPaperSchemeService.deleteEducationPaperSchemeBySchemeId(schemeIds)); } }