deason 6 lat temu
rodzic
commit
4990d180d1

+ 13 - 6
examcloud-core-print-provider/src/main/java/cn/com/qmth/examcloud/core/print/api/controller/CoursePaperController.java

@@ -43,17 +43,24 @@ public class CoursePaperController extends ControllerSupport {
         return coursePaperService.getCoursePaperList(query);
     }
 
-    @PostMapping("/allot")
+    @PostMapping("/save")
+    @ApiOperation(value = "保存课程试卷")
+    public Result saveCoursePaper(@RequestBody CoursePaperForm form) {
+        //coursePaperService.saveCoursePaper(form);
+        return success();
+    }
+
+    @PostMapping("/allot/{courseStatisticId}/{coursePaperId}")
     @ApiOperation(value = "(单个)分配待指定试卷")
-    public Result allotCoursePaper(@RequestBody CoursePaperForm form) {
-        coursePaperService.allotCoursePaper(form);
+    public Result allotCoursePaper(@PathVariable Long courseStatisticId, @PathVariable Long coursePaperId) {
+        coursePaperService.allotCoursePaper(courseStatisticId, coursePaperId);
         return success();
     }
 
-    @PostMapping("/allot/{orgId}/{examId}")
+    @PostMapping("/allot/all/{orgId}/{examId}")
     @ApiOperation(value = "(整体)分配待指定试卷")
-    public Result allotCoursePaper(@PathVariable Long orgId, @PathVariable Long examId) {
-        coursePaperService.allotCoursePapers(orgId, examId);
+    public Result allotAllCoursePaper(@PathVariable Long orgId, @PathVariable Long examId) {
+        coursePaperService.allotAllCoursePaper(orgId, examId);
         return success();
     }
 

+ 5 - 3
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/CoursePaperService.java

@@ -7,7 +7,6 @@
 
 package cn.com.qmth.examcloud.core.print.service;
 
-import cn.com.qmth.examcloud.core.print.service.bean.coursepaper.CoursePaperForm;
 import cn.com.qmth.examcloud.core.print.service.bean.coursepaper.CoursePaperInfo;
 import cn.com.qmth.examcloud.core.print.service.bean.coursepaper.CoursePaperQuery;
 import cn.com.qmth.examcloud.core.print.service.bean.coursepaper.CoursePaperTotalInfo;
@@ -43,13 +42,16 @@ public interface CoursePaperService {
 
     /**
      * (单个)分配待指定试卷
+     *
+     * @param courseStatisticId 课程统计ID
+     * @param coursePaperId     课程试卷ID
      */
-    void allotCoursePaper(CoursePaperForm form);
+    void allotCoursePaper(Long courseStatisticId, Long coursePaperId);
 
     /**
      * (整体)分配待指定试卷
      */
-    void allotCoursePapers(Long orgId, Long examId);
+    void allotAllCoursePaper(Long orgId, Long examId);
 
     /**
      * 获取某学校考试的试卷数量情况

+ 12 - 12
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/coursepaper/CoursePaperForm.java

@@ -27,14 +27,14 @@ public class CoursePaperForm implements JsonSerializable {
      * 课程ID
      */
     private Long courseId;
-    /**
-     * 试卷类型
-     */
-    private String paperType;
     /**
      * 试卷ID
      */
     private String paperId;
+    /**
+     * 试卷名称
+     */
+    private String paperName;
 
     public Long getOrgId() {
         return orgId;
@@ -60,14 +60,6 @@ public class CoursePaperForm implements JsonSerializable {
         this.courseId = courseId;
     }
 
-    public String getPaperType() {
-        return paperType;
-    }
-
-    public void setPaperType(String paperType) {
-        this.paperType = paperType;
-    }
-
     public String getPaperId() {
         return paperId;
     }
@@ -76,4 +68,12 @@ public class CoursePaperForm implements JsonSerializable {
         this.paperId = paperId;
     }
 
+    public String getPaperName() {
+        return paperName;
+    }
+
+    public void setPaperName(String paperName) {
+        this.paperName = paperName;
+    }
+
 }

+ 30 - 7
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/impl/CoursePaperServiceImpl.java

@@ -11,15 +11,21 @@ import cn.com.qmth.examcloud.core.print.common.jpa.SearchBuilder;
 import cn.com.qmth.examcloud.core.print.common.jpa.SpecUtils;
 import cn.com.qmth.examcloud.core.print.common.utils.Check;
 import cn.com.qmth.examcloud.core.print.entity.CoursePaper;
+import cn.com.qmth.examcloud.core.print.entity.CourseStatistic;
 import cn.com.qmth.examcloud.core.print.repository.CoursePaperRepository;
+import cn.com.qmth.examcloud.core.print.repository.CourseStatisticRepository;
 import cn.com.qmth.examcloud.core.print.service.CoursePaperService;
-import cn.com.qmth.examcloud.core.print.service.bean.coursepaper.*;
+import cn.com.qmth.examcloud.core.print.service.bean.coursepaper.CoursePaperConvert;
+import cn.com.qmth.examcloud.core.print.service.bean.coursepaper.CoursePaperInfo;
+import cn.com.qmth.examcloud.core.print.service.bean.coursepaper.CoursePaperQuery;
+import cn.com.qmth.examcloud.core.print.service.bean.coursepaper.CoursePaperTotalInfo;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.io.File;
 import java.util.List;
@@ -33,6 +39,8 @@ public class CoursePaperServiceImpl implements CoursePaperService {
     private static final Logger log = LoggerFactory.getLogger(CoursePaperServiceImpl.class);
     @Autowired
     private CoursePaperRepository coursePaperRepository;
+    @Autowired
+    private CourseStatisticRepository courseStatisticRepository;
 
     @Override
     public List<CoursePaperInfo> getCoursePaperList(CoursePaperQuery query) {
@@ -63,36 +71,51 @@ public class CoursePaperServiceImpl implements CoursePaperService {
 
     @Override
     public File downloadPaperStructure(Long examId, Long paperId) {
+        //todo
         return null;
     }
 
     @Override
     public void checkPaperStructure(Long examId, Long paperId) {
-
+        //todo
     }
 
-    @Override
-    public void allotCoursePaper(CoursePaperForm form) {
-
+    @Transactional
+    public void allotCoursePaper(Long courseStatisticId, Long coursePaperId) {
+        Check.isEmpty(courseStatisticId, "课程统计ID不能为空!");
+        Check.isEmpty(coursePaperId, "课程试卷ID不能为空!");
+        CourseStatistic statistic = courseStatisticRepository.findOne(courseStatisticId);
+        if (statistic == null) {
+            return;
+        }
+        CoursePaper coursePaper = coursePaperRepository.findOne(coursePaperId);
+        if (coursePaper == null) {
+            return;
+        }
+        statistic.setCoursePaper(coursePaper);
+        courseStatisticRepository.save(statistic);
     }
 
     @Override
-    public void allotCoursePapers(Long orgId, Long examId) {
-
+    public void allotAllCoursePaper(Long orgId, Long examId) {
+        //todo
     }
 
     @Override
     public CoursePaperTotalInfo getPaperTotalByOrgIdAndExamId(Long orgId, Long examId) {
+        //todo
         return null;
     }
 
     @Override
     public File exportAllByOrgIdAndExamId(Long orgId, Long examId) {
+        //todo
         return null;
     }
 
     @Override
     public File exportBatchByIds(Long[] ids) {
+        //todo
         return null;
     }
 

+ 2 - 1
examcloud-core-print-starter/src/main/resources/security-exclusions.conf

@@ -35,7 +35,8 @@
 [${$rmp.ctrl.print}/course/statistic][/all/init][GET]
 
 [${$rmp.ctrl.print}/course/paper][/list][POST]
-[${$rmp.ctrl.print}/course/paper][/allot][POST]
+[${$rmp.ctrl.print}/course/paper][/save][POST]
+[${$rmp.ctrl.print}/course/paper][/allot/{courseStatisticId}/{coursePaperId}][POST]
 [${$rmp.ctrl.print}/course/paper][/allot/{orgId}/{examId}][POST]
 [${$rmp.ctrl.print}/course/paper][/total/{orgId}/{examId}][POST]
 [${$rmp.ctrl.print}/course/paper][/export/all/{orgId}/{examId}][GET]

+ 8 - 0
examcloud-core-print-starter/src/test/java/cn/com/qmth/examcloud/core/print/test/CoursePaperServiceTest.java

@@ -24,4 +24,12 @@ public class CoursePaperServiceTest extends BaseTest {
         coursePaperService.syncCourseNameByCourseId(262L, "测试课程");
     }
 
+    @Test
+    public void allotCoursePaperTest() throws Exception {
+        Long courseStatisticId = 1L;
+        Long coursePaperId = 1L;
+        coursePaperService.allotCoursePaper(courseStatisticId, coursePaperId);
+    }
+
+
 }