Jelajahi Sumber

Merge with branch dev-no-jpa.

deason 5 tahun lalu
induk
melakukan
cd228bce89
25 mengubah file dengan 761 tambahan dan 913 penghapusan
  1. 73 59
      examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/core/questions/api/CoursePropertyController.java
  2. 65 82
      examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/core/questions/api/PropertyController.java
  3. 28 0
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/Constants.java
  4. 10 0
      examcloud-core-questions-dao/pom.xml
  5. 10 47
      examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/CoursePropertyRepo.java
  6. 5 42
      examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/PropertyRepo.java
  7. 34 54
      examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/CourseProperty.java
  8. 0 135
      examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/CoursePropertyNumber.java
  9. 2 1
      examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/PaperDetailUnitStruct.java
  10. 3 3
      examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/PaperStruct.java
  11. 29 39
      examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/Property.java
  12. 3 7
      examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/base/IdEntity.java
  13. 33 32
      examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/dto/CoursePropertyDto.java
  14. 14 14
      examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/dto/CoursePropertyNumberDto.java
  15. 5 3
      examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/dto/PropertyConvert.java
  16. 44 29
      examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/dto/PropertyDto.java
  17. 13 53
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/CoursePropertyService.java
  18. 32 23
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ImportPaperService.java
  19. 13 46
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PropertyService.java
  20. 27 28
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/PropertyAssembler.java
  21. 103 91
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/CoursePropertyServiceImpl.java
  22. 4 4
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExportPaperServiceImpl.java
  23. 181 108
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PropertyServiceImpl.java
  24. 30 10
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/QuesServiceImpl.java
  25. 0 3
      examcloud-core-questions-starter/src/main/java/cn/com/qmth/examcloud/core/questions/starter/QuestionPoolApplication.java

+ 73 - 59
examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/core/questions/api/CoursePropertyController.java

@@ -1,6 +1,8 @@
 package cn.com.qmth.examcloud.core.questions.api;
 
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
+import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.core.questions.base.Constants;
 import cn.com.qmth.examcloud.core.questions.dao.entity.CourseProperty;
 import cn.com.qmth.examcloud.core.questions.dao.entity.dto.CoursePropertyDto;
 import cn.com.qmth.examcloud.core.questions.service.CoursePropertyService;
@@ -22,38 +24,42 @@ import java.util.stream.Stream;
 
 /**
  * @author weiwenhai
- * @describle 课程属性  coursePropertyController
+ * @describle 课程属性
  * @date 2017.11.2
  */
 @Controller
 @RequestMapping("${api_cqb}/")
 public class CoursePropertyController extends ControllerSupport {
-
     @Autowired
     private CoursePropertyService coursePropertyService;
 
-    @ApiOperation(value = "根据orgId查询所有课程属性", notes = "不带分页")
+    @ApiOperation(value = "根据orgId查询所有课程属性")
     @GetMapping(value = "/courseProperty/all")
     public ResponseEntity<Object> findAllByOrg() {
         User user = getAccessUser();
-        if (user != null) {
-            List<CourseProperty> courseProperties = coursePropertyService.findAllByOrgId(user.getRootOrgId());
-            return new ResponseEntity<>(courseProperties, HttpStatus.OK);
+        if (user == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+
+        List<CourseProperty> courseProperties = coursePropertyService.findAllByOrgId(user.getRootOrgId());
+        return new ResponseEntity<>(courseProperties, HttpStatus.OK);
     }
 
-    @ApiOperation(value = "根据orgId查询所有课程属性", notes = "带分页")
+    @ApiOperation(value = "根据orgId查询所有课程属性(分页)")
     @GetMapping(value = "/courseProperty/all/{curPage}/{pageSize}")
     public ResponseEntity<Object> findAllByOrgId(@ModelAttribute CoursePropertyDto coursePropertyDto,
                                                  @PathVariable Integer curPage,
                                                  @PathVariable Integer pageSize) {
         User user = getAccessUser();
         if (user == null) {
-            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
+
         coursePropertyDto.setOrgId(user.getRootOrgId());
-        Page<CourseProperty> coursePropertiesPage = coursePropertyService.findAllByOrg(coursePropertyDto, new PageRequest(curPage - 1, pageSize, new Sort(Direction.DESC, "id")));
+
+        PageRequest pageRequest = PageRequest.of(curPage - 1, pageSize, new Sort(Direction.DESC, "updateTime"));
+        Page<CourseProperty> coursePropertiesPage = coursePropertyService.findList(coursePropertyDto, pageRequest);
+
         return new ResponseEntity<>(coursePropertiesPage, HttpStatus.OK);
     }
 
@@ -61,94 +67,102 @@ public class CoursePropertyController extends ControllerSupport {
     @PostMapping(value = "/courseProperty/save")
     public ResponseEntity<Object> saveCourseProperty(@RequestBody CoursePropertyDto coursePropertyDto) {
         User user = getAccessUser();
-        if (user != null) {
-            try {
-                coursePropertyDto.setOrgId(user.getRootOrgId());
-                coursePropertyService.saveCourseProperty(coursePropertyDto);
-            } catch (Exception e) {
-                return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
-            }
-            return new ResponseEntity<>(HttpStatus.OK);
+        if (user == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+
+        coursePropertyDto.setOrgId(user.getRootOrgId());
+        coursePropertyService.saveCourseProperty(coursePropertyDto);
+
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
-    @ApiOperation(value = "启用", notes = "启用")
+    @ApiOperation(value = "启用")
     @PutMapping(value = "/courseProperty/open/{id}")
-    public ResponseEntity<Object> openCourseProperty(@PathVariable Long id) {
+    public ResponseEntity<Object> openCourseProperty(@PathVariable String id) {
         User user = getAccessUser();
-        if (user != null) {
-            coursePropertyService.openCourseProperty(id);
-            return new ResponseEntity<>(HttpStatus.OK);
+        if (user == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+
+        coursePropertyService.updateCoursePropertyStatus(id, true);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
-    @ApiOperation(value = "批量启用", notes = "启用")
+    @ApiOperation(value = "批量启用")
     @PutMapping(value = "/courseProperty/opens/{ids}")
     public ResponseEntity<Object> opensCourseProperty(@PathVariable String ids) {
         User user = getAccessUser();
-        if (user != null) {
-            List<String> idList = Stream.of(ids.split(",")).collect(Collectors.toList());
-            coursePropertyService.opensCourseProperty(idList);
-            return new ResponseEntity<>(HttpStatus.OK);
+        if (user == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+
+        List<String> idList = Stream.of(ids.split(",")).collect(Collectors.toList());
+        coursePropertyService.updateCoursePropertyStatus(idList, true);
+
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
-    @ApiOperation(value = "禁用", notes = "禁用")
+    @ApiOperation(value = "禁用")
     @PutMapping(value = "/courseProperty/close/{id}")
-    public ResponseEntity<Object> closeCourseProperty(@PathVariable Long id) {
+    public ResponseEntity<Object> closeCourseProperty(@PathVariable String id) {
         User user = getAccessUser();
-        if (user != null) {
-            coursePropertyService.closeCourseProperty(id);
-            return new ResponseEntity<>(HttpStatus.OK);
+        if (user == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+
+        coursePropertyService.updateCoursePropertyStatus(id, false);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
-    @ApiOperation(value = "批量禁用", notes = "禁用")
+    @ApiOperation(value = "批量禁用")
     @PutMapping(value = "/courseProperty/closes/{ids}")
     public ResponseEntity<Object> closesCourseProperty(@PathVariable String ids) {
         User user = getAccessUser();
-        if (user != null) {
-            List<String> idList = Stream.of(ids.split(",")).collect(Collectors.toList());
-            coursePropertyService.closesCourseProperty(idList);
-            return new ResponseEntity<>(HttpStatus.OK);
+        if (user == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+
+        List<String> idList = Stream.of(ids.split(",")).collect(Collectors.toList());
+        coursePropertyService.updateCoursePropertyStatus(idList, false);
+
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
-    @ApiOperation(value = "根据courseId查询所有课程属性", notes = "不带分页")
+    @ApiOperation(value = "根据courseId查询所有课程属性")
     @GetMapping(value = "/courseProperty/all/{courseId}")
     public ResponseEntity<Object> findAllByCourseId(@PathVariable Long courseId) {
         User user = getAccessUser();
-        if (user != null) {
-            List<CourseProperty> courseProperties = coursePropertyService.findAllByCourseId(courseId);
-            return new ResponseEntity<>(courseProperties, HttpStatus.OK);
+        if (user == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+
+        List<CourseProperty> courseProperties = coursePropertyService.findAllByCourseId(courseId);
+        return new ResponseEntity<>(courseProperties, HttpStatus.OK);
     }
 
-    @ApiOperation(value = "根据courseCode查询所有课程属性", notes = "不带分页")
+    @ApiOperation(value = "根据courseCode查询所有课程属性")
     @GetMapping(value = "/courseProperty/code/{courseCode}")
     public ResponseEntity<Object> findAllByCourseCode(@PathVariable String courseCode) {
         User user = getAccessUser();
-        if (user != null) {
-            List<CourseProperty> courseProperties = coursePropertyService.findAllByCourseCode(courseCode);
-            return new ResponseEntity<>(courseProperties, HttpStatus.OK);
+        if (user == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+
+        List<CourseProperty> courseProperties = coursePropertyService.findAllByCourseCode(courseCode);
+        return new ResponseEntity<>(courseProperties, HttpStatus.OK);
     }
 
-    @ApiOperation(value = "根据courseCode查询所有开启的课程属性", notes = "不带分页")
+    @ApiOperation(value = "根据courseCode查询所有开启的课程属性")
     @GetMapping(value = "/courseProperty/enable/{courseCode}")
     public ResponseEntity<Object> findAllEnable(@PathVariable String courseCode) {
         User user = getAccessUser();
-        if (user != null) {
-            List<CourseProperty> courseProperties = coursePropertyService.findAllEnable(courseCode, true);
-            return new ResponseEntity<>(courseProperties, HttpStatus.OK);
+        if (user == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+
+        List<CourseProperty> courseProperties = coursePropertyService.findByEnable(courseCode, true);
+        return new ResponseEntity<>(courseProperties, HttpStatus.OK);
     }
-}
+
+}

+ 65 - 82
examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/core/questions/api/PropertyController.java

@@ -1,6 +1,8 @@
 package cn.com.qmth.examcloud.core.questions.api;
 
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
+import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.core.questions.base.Constants;
 import cn.com.qmth.examcloud.core.questions.dao.entity.Property;
 import cn.com.qmth.examcloud.core.questions.dao.entity.dto.PropertyDto;
 import cn.com.qmth.examcloud.core.questions.service.PropertyService;
@@ -16,134 +18,115 @@ import java.util.List;
 
 /**
  * @author weiwenhai
- * @describle 属性 PropertyController
+ * @describle 属性
  * @date 2017.11.8
  */
 @Controller
 @RequestMapping("${api_cqb}/")
 public class PropertyController extends ControllerSupport {
-
     @Autowired
     private PropertyService propertyService;
 
-    @ApiOperation(value = "新增属性", notes = "新增属性")
-    @PostMapping(value = "/property/save")
-    public ResponseEntity<Object> saveProperty(@RequestBody Property property) {
-        User user = getAccessUser();
-        if (user != null) {
-            try {
-                propertyService.saveProperty(property, user);
-                return new ResponseEntity<>(HttpStatus.OK);
-            } catch (Exception e) {
-                log.error(e.getMessage(), e);
-                return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
-            }
-        }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
-    }
-
-    @ApiOperation(value = "查询所有属性dto", notes = "树形结构")
+    @ApiOperation(value = "查询所有属性(树结构)")
     @GetMapping(value = "/property/all/{coursePropertyId}")
     public ResponseEntity<Object> findAllProperty(@PathVariable String coursePropertyId) {
         User user = getAccessUser();
         if (user == null) {
-            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        List<PropertyDto> propertyDtos = propertyService.propertyDtos(Long.parseLong(coursePropertyId), user);
-        return new ResponseEntity<>(propertyDtos, HttpStatus.OK);
+
+        List<PropertyDto> properties = propertyService.findParentPropertyDtoList(coursePropertyId, user.getRootOrgId());
+        return new ResponseEntity<>(properties, HttpStatus.OK);
     }
 
-    @ApiOperation(value = "更新属性", notes = "更新属性")
-    @PutMapping(value = "/property/save")
-    public ResponseEntity<Object> updateProperty(@RequestBody Property property) {
+    @ApiOperation(value = "新增或更新属性")
+    @RequestMapping(value = "/property/save", method = {RequestMethod.POST, RequestMethod.PUT})
+    public ResponseEntity<Object> saveProperty(@RequestBody PropertyDto property) {
         User user = getAccessUser();
-        if (user != null) {
-            try {
-                propertyService.saveProperty(property, user);
-                return new ResponseEntity<>(HttpStatus.OK);
-            } catch (Exception e) {
-                log.error(e.getMessage(), e);
-                return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
-            }
+        if (user == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+
+        property.setOrgId(user.getRootOrgId());
+        propertyService.saveProperty(property);
+
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
-    @ApiOperation(value = "删除属性", notes = "删除属性")
+    @ApiOperation(value = "删除属性")
     @DeleteMapping(value = "/property/delete/{propertyId}/{coursePropertyId}")
-    public ResponseEntity<Object> deleteProperty(@PathVariable Long propertyId, @PathVariable Long coursePropertyId) {
+    public ResponseEntity<Object> deleteProperty(@PathVariable String propertyId, @PathVariable String coursePropertyId) {
         User user = getAccessUser();
-        if (user != null) {
-            propertyService.deleteProperty(propertyId, coursePropertyId, user);
-            return new ResponseEntity<>(HttpStatus.OK);
+        if (user == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+
+        propertyService.deleteProperty(propertyId, coursePropertyId, user.getRootOrgId());
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
-    @ApiOperation(value = "查询所有属性", notes = "查询所有属性")
+    @ApiOperation(value = "查询所有属性")
     @GetMapping(value = "/property/{coursePropertyId}")
     public ResponseEntity<Object> findAll(@PathVariable String coursePropertyId) {
         User user = getAccessUser();
-        if (user != null) {
-            List<Property> properties = propertyService.findAll(Long.parseLong(coursePropertyId), user);
-            return new ResponseEntity<>(properties, HttpStatus.OK);
+        if (user == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+
+        List<Property> properties = propertyService.findProperties(coursePropertyId, user.getRootOrgId());
+        return new ResponseEntity<>(properties, HttpStatus.OK);
     }
 
-    @ApiOperation(value = "根据一级查询二级所有属性", notes = "查询所有属性")
+    @ApiOperation(value = "根据一级查询二级所有属性")
     @GetMapping(value = "/property/second/{propertyId}")
-    public ResponseEntity<Object> findSons(@PathVariable Long propertyId) {
+    public ResponseEntity<Object> findSons(@PathVariable String propertyId) {
         User user = getAccessUser();
-        if (user != null) {
-            List<Property> properties = propertyService.findPropertySons(propertyId);
-            return new ResponseEntity<>(properties, HttpStatus.OK);
+        if (user == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+
+        List<Property> properties = propertyService.findSonProperties(propertyId);
+        return new ResponseEntity<>(properties, HttpStatus.OK);
     }
 
-    @ApiOperation(value = "根据课程属性id所有一级属性", notes = "查询所有属性")
+    @ApiOperation(value = "根据课程属性id所有一级属性")
     @GetMapping(value = "/property/first/{coursePropertyId}")
-    public ResponseEntity<Object> findParents(@PathVariable Long coursePropertyId) {
+    public ResponseEntity<Object> findParents(@PathVariable String coursePropertyId) {
         User user = getAccessUser();
-        if (user != null) {
-            List<Property> properties = propertyService.findPropertyParents(coursePropertyId, user.getRootOrgId());
-            return new ResponseEntity<>(properties, HttpStatus.OK);
+        if (user == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+
+        List<Property> properties = propertyService.findParentProperties(coursePropertyId, user.getRootOrgId());
+        return new ResponseEntity<>(properties, HttpStatus.OK);
     }
 
-    @ApiOperation(value = "上移", notes = "上移")
+    @ApiOperation(value = "上移")
     @PutMapping(value = "/property/moveUp")
-    public ResponseEntity<Object> moveUp(@RequestBody Property property) {
+    public ResponseEntity<Object> moveUp(@RequestBody PropertyDto property) {
         User user = getAccessUser();
-        if (user != null) {
-            try {
-                property.setOrgId(user.getRootOrgId());
-                propertyService.moveUp(property);
-                return new ResponseEntity<>(HttpStatus.OK);
-            } catch (Exception e) {
-                log.error(e.getMessage(), e);
-                return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
-            }
+        if (user == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+
+        property.setOrgId(user.getRootOrgId());
+        propertyService.moveUp(property);
+
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
-    @ApiOperation(value = "下移", notes = "下移")
+    @ApiOperation(value = "下移")
     @PutMapping(value = "/property/moveDown")
-    public ResponseEntity<Object> moveDown(@RequestBody Property property) {
+    public ResponseEntity<Object> moveDown(@RequestBody PropertyDto property) {
         User user = getAccessUser();
-        if (user != null) {
-            try {
-                property.setOrgId(user.getRootOrgId());
-                propertyService.moveDown(property);
-                return new ResponseEntity<>(HttpStatus.OK);
-            } catch (Exception e) {
-                log.error(e.getMessage(), e);
-                return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
-            }
+        if (user == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "请先登录!");
         }
-        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+
+        property.setOrgId(user.getRootOrgId());
+        propertyService.moveDown(property);
+
+        return new ResponseEntity<>(HttpStatus.OK);
     }
-}
+
+}

+ 28 - 0
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/Constants.java

@@ -0,0 +1,28 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-10-17 15:18:02.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.questions.base;
+
+/**
+ * 系统常量
+ *
+ * @author: fengdesheng
+ * @since: 2018/10/17
+ */
+public interface Constants {
+
+    /**
+     * 系统错误
+     */
+    String SYS_CODE_500 = "000500";
+
+    /**
+     * 参数错误
+     */
+    String SYS_CODE_400 = "000400";
+
+}

+ 10 - 0
examcloud-core-questions-dao/pom.xml

@@ -16,6 +16,16 @@
             <groupId>cn.com.qmth.examcloud.core.questions</groupId>
             <artifactId>examcloud-core-questions-base</artifactId>
             <version>${examcloud.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-data-jpa</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>mysql</groupId>
+                    <artifactId>mysql-connector-java</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
     </dependencies>
 

+ 10 - 47
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/CoursePropertyRepo.java

@@ -1,73 +1,36 @@
 package cn.com.qmth.examcloud.core.questions.dao;
 
 import cn.com.qmth.examcloud.core.questions.dao.entity.CourseProperty;
-import org.apache.commons.compress.utils.Lists;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageImpl;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.domain.Specification;
-import org.springframework.stereotype.Component;
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
 
 import java.util.List;
-import java.util.Optional;
 
 /**
  * @author weiwenhai
  * @describle 课程属性repo
  * @date 2017.11.2
  */
-@Component
-//public interface CoursePropertyRepo extends JpaRepository<CourseProperty, Long>, QueryByExampleExecutor<CourseProperty>, JpaSpecificationExecutor<CourseProperty> {
-public class CoursePropertyRepo {
+public interface CoursePropertyRepo extends MongoRepository<CourseProperty, String>, QueryByExampleExecutor<CourseProperty> {
 
     //查询所有课程属性
-    public List<CourseProperty> findByOrgId(Long orgId) {
-        return Lists.newArrayList();
-    }
+    List<CourseProperty> findByOrgId(Long orgId);
 
     //根据属性名查询
-    public CourseProperty findByNameAndOrgId(String name, Long orgId) {
-        return null;
-    }
+    CourseProperty findByOrgIdAndName(Long orgId, String name);
 
     //根据课程id查询
-    public List<CourseProperty> findByCourseId(Long courseId) {
-        return Lists.newArrayList();
-    }
+    List<CourseProperty> findByCourseId(Long courseId);
 
-    public List<CourseProperty> findByCourseCode(String code) {
-        return Lists.newArrayList();
-    }
+    List<CourseProperty> findByCourseCode(String courseCode);
 
     //根据课程代码查询已开启的课程属性
-    public List<CourseProperty> findByCourseCodeAndEnable(String code, Boolean enable) {
-        return Lists.newArrayList();
-    }
+    List<CourseProperty> findByCourseCodeAndEnable(String courseCode, Boolean enable);
 
     //根据课程id查询已经开启的课程属性
-    public List<CourseProperty> findByCourseIdAndEnable(Long courseId, Boolean enable) {
-        return Lists.newArrayList();
-    }
+    List<CourseProperty> findByCourseIdAndEnable(Long courseId, Boolean enable);
 
     //根据id集合查询
-    public List<CourseProperty> findByIdIn(List<Long> ids) {
-        return Lists.newArrayList();
-    }
-
-    public void save(CourseProperty courseProperty) {
-
-    }
-
-    public Page<CourseProperty> findAll(Specification<CourseProperty> specification, Pageable pageable) {
-        return new PageImpl<>(Lists.newArrayList(), pageable, 0l);
-    }
-
-    public Optional<CourseProperty> findById(Long id) {
-        return null;
-    }
-
-    public void saveAll(List<CourseProperty> courseProperties) {
-
-    }
+    List<CourseProperty> findByIdIn(List<String> ids);
 
 }

+ 5 - 42
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/PropertyRepo.java

@@ -1,62 +1,25 @@
 package cn.com.qmth.examcloud.core.questions.dao;
 
 import cn.com.qmth.examcloud.core.questions.dao.entity.Property;
-import org.apache.commons.compress.utils.Lists;
-import org.springframework.data.domain.Example;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.mongodb.repository.MongoRepository;
 import org.springframework.data.repository.query.QueryByExampleExecutor;
-import org.springframework.stereotype.Component;
 
 import java.util.List;
-import java.util.Optional;
 
 /**
  * @author weiwenhai
  * @describle 课程属性repo
  * @date 2017.11.6
  */
-@Component
-//public interface PropertyRepo extends JpaRepository<Property, Long>, QueryByExampleExecutor<Property>, JpaSpecificationExecutor<Property> {
-public class PropertyRepo {
+public interface PropertyRepo extends MongoRepository<Property, String>, QueryByExampleExecutor<Property> {
 
     //查询所有节点
-    public List<Property> findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(Long orgId, Long coursePropertyId, Long parentId) {
-        return Lists.newArrayList();
-    }
+    List<Property> findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(Long orgId, String coursePropertyId, String parentId);
 
     //查询子节点
-    public List<Property> findByParentIdOrderByNumber(Long parentId) {
-        return Lists.newArrayList();
-    }
+    List<Property> findByParentIdOrderByNumber(String parentId);
 
     //根据课程属性id,一级id,属性名称查询
-    public Property findByOrgIdAndCoursePropertyIdAndParentIdAndName(Long orgId, Long coursePropertyId, Long parentId, String name) {
-        return null;
-    }
-
-    public List<Property> findAll(Example<Property> of) {
-        return Lists.newArrayList();
-    }
-
-    public Property save(Property property) {
-        return null;
-    }
-
-    public void saveAll(List<Property> properties) {
-
-    }
-
-    public Optional<Property> findById(Long id) {
-        return null;
-    }
-
-    public void delete(Property property) {
-
-    }
-
-    public void deleteById(Long propertyId) {
-
-    }
+    Property findByOrgIdAndCoursePropertyIdAndParentIdAndName(Long orgId, String coursePropertyId, String parentId, String name);
 
 }

+ 34 - 54
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/CourseProperty.java

@@ -1,84 +1,72 @@
 package cn.com.qmth.examcloud.core.questions.dao.entity;
 
-import cn.com.qmth.examcloud.core.questions.dao.entity.base.IdEntity;
-import cn.com.qmth.examcloud.core.questions.dao.entity.dto.CoursePropertyDto;
+import cn.com.qmth.examcloud.core.questions.dao.entity.base.IdBase;
 
-import javax.persistence.Entity;
-import javax.persistence.Table;
 import javax.validation.constraints.NotNull;
+import java.util.Date;
 
 /**
  * @author weiwenhai
  * @describle 课程属性
  * @date 2017.11.2
  */
-//@Entity
-//@Table(name = "ecs_ques_course_property")
-public class CourseProperty extends IdEntity {
+public class CourseProperty extends IdBase {
     @NotNull
-    private String name;
+    private Long orgId;
 
     @NotNull
     private Long courseId;
 
-    @NotNull
-    private Long orgId;
-
     private String courseCode;
 
+    private String courseName;
+
+    @NotNull
+    private String name;
+
     private Boolean enable;
 
-    private String courseName;
+    private Date updateTime;//更新时间
 
-    public CourseProperty() {
 
+    public Long getOrgId() {
+        return orgId;
     }
 
-    public CourseProperty(CoursePropertyDto coursePropertyDto) {
-        this.id = coursePropertyDto.getId();
-        this.name = coursePropertyDto.getName();
-        this.courseId = coursePropertyDto.getCourseId();
-        this.orgId = coursePropertyDto.getOrgId();
-        this.courseCode = coursePropertyDto.getCourseCode();
-        if (coursePropertyDto.getEnable() != null && coursePropertyDto.getEnable().equals("0")) {
-            this.enable = false;
-        } else if (coursePropertyDto.getEnable() != null && coursePropertyDto.getEnable().equals("1")) {
-            this.enable = true;
-        } else {
-            this.enable = null;
-        }
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
     }
 
-    public Long getId() {
-        return id;
+    public Long getCourseId() {
+        return courseId;
     }
 
-    public void setId(Long id) {
-        this.id = id;
+    public void setCourseId(Long courseId) {
+        this.courseId = courseId;
     }
 
-    public String getName() {
-        return name;
+    public String getCourseCode() {
+        return courseCode;
     }
 
-    public void setName(String name) {
-        this.name = name;
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
     }
 
-    public Long getCourseId() {
-        return courseId;
+    public String getCourseName() {
+        return courseName;
     }
 
-    public void setCourseId(Long courseId) {
-        this.courseId = courseId;
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
     }
 
-    public Long getOrgId() {
-        return orgId;
+    public String getName() {
+        return name;
     }
 
-    public void setOrgId(Long orgId) {
-        this.orgId = orgId;
+    public void setName(String name) {
+        this.name = name;
     }
 
     public Boolean getEnable() {
@@ -89,20 +77,12 @@ public class CourseProperty extends IdEntity {
         this.enable = enable;
     }
 
-    public String getCourseCode() {
-        return courseCode;
-    }
-
-    public void setCourseCode(String courseCode) {
-        this.courseCode = courseCode;
+    public Date getUpdateTime() {
+        return updateTime;
     }
 
-    public String getCourseName() {
-        return courseName;
-    }
-
-    public void setCourseName(String courseName) {
-        this.courseName = courseName;
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
     }
 
 }

+ 0 - 135
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/CoursePropertyNumber.java

@@ -1,135 +0,0 @@
-package cn.com.qmth.examcloud.core.questions.dao.entity;
-
-public class CoursePropertyNumber {
-
-    private Long id;
-
-    private Long propertyId;
-
-    private Long propertyParentId;
-
-    private String propertyName;
-
-    private Integer number;
-
-    private Double score; //每题分数
-
-    private Integer publicSimple; //公开简单
-
-    private Integer publicMedium; //公开中等
-
-    private Integer publicDifficulty; //公开困难
-
-    private Integer noPublicSimple; //非公开简单
-
-    private Integer noPublicMedium; //非公开中等
-
-    private Integer noPublicDifficulty; //非公开困难
-
-    private Boolean disable; //是否显示
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public Long getPropertyId() {
-        return propertyId;
-    }
-
-    public void setPropertyId(Long propertyId) {
-        this.propertyId = propertyId;
-    }
-
-    public Long getPropertyParentId() {
-        return propertyParentId;
-    }
-
-    public void setPropertyParentId(Long propertyParentId) {
-        this.propertyParentId = propertyParentId;
-    }
-
-    public String getPropertyName() {
-        return propertyName;
-    }
-
-    public void setPropertyName(String propertyName) {
-        this.propertyName = propertyName;
-    }
-
-    public Integer getNumber() {
-        return number;
-    }
-
-    public void setNumber(Integer number) {
-        this.number = number;
-    }
-
-    public Integer getPublicSimple() {
-        return publicSimple;
-    }
-
-    public void setPublicSimple(Integer publicSimple) {
-        this.publicSimple = publicSimple;
-    }
-
-    public Integer getPublicMedium() {
-        return publicMedium;
-    }
-
-    public void setPublicMedium(Integer publicMedium) {
-        this.publicMedium = publicMedium;
-    }
-
-    public Integer getPublicDifficulty() {
-        return publicDifficulty;
-    }
-
-    public void setPublicDifficulty(Integer publicDifficulty) {
-        this.publicDifficulty = publicDifficulty;
-    }
-
-    public Integer getNoPublicSimple() {
-        return noPublicSimple;
-    }
-
-    public void setNoPublicSimple(Integer noPublicSimple) {
-        this.noPublicSimple = noPublicSimple;
-    }
-
-    public Integer getNoPublicMedium() {
-        return noPublicMedium;
-    }
-
-    public void setNoPublicMedium(Integer noPublicMedium) {
-        this.noPublicMedium = noPublicMedium;
-    }
-
-    public Integer getNoPublicDifficulty() {
-        return noPublicDifficulty;
-    }
-
-    public void setNoPublicDifficulty(Integer noPublicDifficulty) {
-        this.noPublicDifficulty = noPublicDifficulty;
-    }
-
-    public Boolean getDisable() {
-        return disable;
-    }
-
-    public void setDisable(Boolean disable) {
-        this.disable = disable;
-    }
-
-    public Double getScore() {
-        return score;
-    }
-
-    public void setScore(Double score) {
-        this.score = score;
-    }
-
-}

+ 2 - 1
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/PaperDetailUnitStruct.java

@@ -42,9 +42,10 @@ public class PaperDetailUnitStruct extends IdBase {
 
     private String buildPropertyId(CoursePropertyNumberDto coursePropertyNumberDto) {
         //有一级属性和二姐属性
-        if (coursePropertyNumberDto.getPropertyParentId() != 0) {
+        if (!Property.ROOT_PARENT_ID.equals(coursePropertyNumberDto.getPropertyParentId())) {
             return coursePropertyNumberDto.getPropertyParentId() + "-" + coursePropertyNumberDto.getPropertyId();
         }
+
         return String.valueOf(coursePropertyNumberDto.getPropertyId());
     }
 

+ 3 - 3
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/PaperStruct.java

@@ -51,7 +51,7 @@ public class PaperStruct extends IdBase {
      */
     private GenPaperType genPaperType;
 
-    private Long coursePropertyId; //课程属性id
+    private String coursePropertyId; //课程属性id
 
     private Double difficulty; //难度
 
@@ -167,11 +167,11 @@ public class PaperStruct extends IdBase {
         this.type = type;
     }
 
-    public Long getCoursePropertyId() {
+    public String getCoursePropertyId() {
         return coursePropertyId;
     }
 
-    public void setCoursePropertyId(Long coursePropertyId) {
+    public void setCoursePropertyId(String coursePropertyId) {
         this.coursePropertyId = coursePropertyId;
     }
 

+ 29 - 39
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/Property.java

@@ -1,9 +1,7 @@
 package cn.com.qmth.examcloud.core.questions.dao.entity;
 
-import cn.com.qmth.examcloud.core.questions.dao.entity.base.IdEntity;
+import cn.com.qmth.examcloud.core.questions.dao.entity.base.IdBase;
 
-import javax.persistence.Entity;
-import javax.persistence.Table;
 import javax.validation.constraints.NotNull;
 
 /**
@@ -11,64 +9,64 @@ import javax.validation.constraints.NotNull;
  * @describle 属性
  * @date 2017.11.6
  */
-//@Entity
-//@Table(name = "ecs_ques_property")
-public class Property extends IdEntity {
-    @NotNull
-    private String name;
+public class Property extends IdBase {
+    public static final String ROOT_PARENT_ID = "0";
 
     @NotNull
-    private Long parentId;
+    private Long orgId;
 
     @NotNull
-    private Integer number;//序号
+    private String coursePropertyId;
 
     @NotNull
-    private Long coursePropertyId;
+    private String parentId;
 
-    private String remark;
+    @NotNull
+    private String name;
 
     @NotNull
-    private Long orgId;
+    private Integer number;//序号
+
+    private String remark;
 
-    public Long getId() {
-        return id;
+    public Long getOrgId() {
+        return orgId;
     }
 
-    public void setId(Long id) {
-        this.id = id;
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
     }
 
-    public String getName() {
-        return name;
+    public String getCoursePropertyId() {
+        return coursePropertyId;
     }
 
-    public void setName(String name) {
-        this.name = name;
+    public void setCoursePropertyId(String coursePropertyId) {
+        this.coursePropertyId = coursePropertyId;
     }
 
-    public Long getParentId() {
+    public String getParentId() {
         return parentId;
     }
 
-    public void setParentId(Long parentId) {
+    public void setParentId(String parentId) {
         this.parentId = parentId;
     }
 
-    public Integer getNumber() {
-        return number;
+    public String getName() {
+        return name;
     }
 
-    public void setNumber(Integer number) {
-        this.number = number;
+    public void setName(String name) {
+        this.name = name;
     }
 
-    public Long getCoursePropertyId() {
-        return coursePropertyId;
+    public Integer getNumber() {
+        return number;
     }
 
-    public void setCoursePropertyId(Long coursePropertyId) {
-        this.coursePropertyId = coursePropertyId;
+    public void setNumber(Integer number) {
+        this.number = number;
     }
 
     public String getRemark() {
@@ -79,12 +77,4 @@ public class Property extends IdEntity {
         this.remark = remark;
     }
 
-    public Long getOrgId() {
-        return orgId;
-    }
-
-    public void setOrgId(Long orgId) {
-        this.orgId = orgId;
-    }
-
 }

+ 3 - 7
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/base/IdEntity.java

@@ -7,10 +7,6 @@
 
 package cn.com.qmth.examcloud.core.questions.dao.entity.base;
 
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.MappedSuperclass;
 import java.io.Serializable;
 
 /**
@@ -19,12 +15,12 @@ import java.io.Serializable;
  * @author: fengdesheng
  * @since: 2019/5/5
  */
-@MappedSuperclass
+//@MappedSuperclass
 public abstract class IdEntity implements Serializable {
     private static final long serialVersionUID = 1L;
 
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //@Id
+    //@GeneratedValue(strategy = GenerationType.IDENTITY)
     protected Long id;
 
     public Long getId() {

+ 33 - 32
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/dto/CoursePropertyDto.java

@@ -1,38 +1,31 @@
 package cn.com.qmth.examcloud.core.questions.dao.entity.dto;
 
+import java.io.Serializable;
+
 /**
  * @author weiwenhai
  * @describle 课程属性Dto
  * @date 2017.11.2
  */
-public class CoursePropertyDto {
-
-    private Long id;
-
-    private String name;
-
-    private Long courseId;
-
+public class CoursePropertyDto implements Serializable {
     private Long orgId;
 
-    private String enable;
+    private Long courseId;
 
     private String courseCode;
 
-    public Long getId() {
-        return id;
-    }
+    private String id;
 
-    public void setId(Long id) {
-        this.id = id;
-    }
+    private String name;
 
-    public String getName() {
-        return name;
+    private Boolean enable;
+
+    public Long getOrgId() {
+        return orgId;
     }
 
-    public void setName(String name) {
-        this.name = name;
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
     }
 
     public Long getCourseId() {
@@ -43,28 +36,36 @@ public class CoursePropertyDto {
         this.courseId = courseId;
     }
 
-    public Long getOrgId() {
-        return orgId;
+    public String getCourseCode() {
+        return courseCode;
     }
 
-    public void setOrgId(Long orgId) {
-        this.orgId = orgId;
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
     }
 
-    public String getEnable() {
-        return enable;
+    public String getId() {
+        return id;
     }
 
-    public void setEnable(String enable) {
-        this.enable = enable;
+    public void setId(String id) {
+        this.id = id;
     }
 
-    public String getCourseCode() {
-        return courseCode;
+    public String getName() {
+        return name;
     }
 
-    public void setCourseCode(String courseCode) {
-        this.courseCode = courseCode;
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
     }
 
-}
+}

+ 14 - 14
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/dto/CoursePropertyNumberDto.java

@@ -2,11 +2,11 @@ package cn.com.qmth.examcloud.core.questions.dao.entity.dto;
 
 public class CoursePropertyNumberDto {
 
-    private Long id;
+    private String id;
 
-    private Long propertyId;
+    private String propertyParentId;
 
-    private Long propertyParentId;
+    private String propertyId;
 
     private String propertyName;
 
@@ -26,28 +26,28 @@ public class CoursePropertyNumberDto {
 
     private Boolean disable; //是否显示
 
-    public Long getId() {
+    public String getId() {
         return id;
     }
 
-    public void setId(Long id) {
+    public void setId(String id) {
         this.id = id;
     }
 
-    public Long getPropertyId() {
-        return propertyId;
+    public String getPropertyParentId() {
+        return propertyParentId;
     }
 
-    public void setPropertyId(Long propertyId) {
-        this.propertyId = propertyId;
+    public void setPropertyParentId(String propertyParentId) {
+        this.propertyParentId = propertyParentId;
     }
 
-    public Long getPropertyParentId() {
-        return propertyParentId;
+    public String getPropertyId() {
+        return propertyId;
     }
 
-    public void setPropertyParentId(Long propertyParentId) {
-        this.propertyParentId = propertyParentId;
+    public void setPropertyId(String propertyId) {
+        this.propertyId = propertyId;
     }
 
     public String getPropertyName() {
@@ -122,4 +122,4 @@ public class CoursePropertyNumberDto {
         this.disable = disable;
     }
 
-}
+}

+ 5 - 3
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/dto/PropertyConvert.java

@@ -6,9 +6,10 @@ public class PropertyConvert {
 
     public static PropertyDto of(Property entity) {
         PropertyDto dto = new PropertyDto();
-        dto.setId(entity.getId());
-        dto.setParentId(entity.getParentId());
+        dto.setOrgId(entity.getOrgId());
         dto.setCoursePropertyId(entity.getCoursePropertyId());
+        dto.setParentId(entity.getParentId());
+        dto.setId(entity.getId());
         dto.setName(entity.getName());
         dto.setNumber(entity.getNumber());
         dto.setRemark(entity.getRemark());
@@ -17,9 +18,10 @@ public class PropertyConvert {
 
     public static Property of(PropertyDto dto) {
         Property entity = new Property();
+        entity.setOrgId(dto.getOrgId());
+        entity.setCoursePropertyId(dto.getCoursePropertyId());
         entity.setId(dto.getId());
         entity.setParentId(dto.getParentId());
-        entity.setCoursePropertyId(dto.getCoursePropertyId());
         entity.setName(dto.getName());
         entity.setNumber(dto.getNumber());
         entity.setRemark(dto.getRemark());

+ 44 - 29
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/dto/PropertyDto.java

@@ -1,5 +1,7 @@
 package cn.com.qmth.examcloud.core.questions.dao.entity.dto;
 
+import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -7,38 +9,67 @@ import java.util.List;
  * @describle 属性Dto
  * @date 2017.11.6
  */
-public class PropertyDto {
+public class PropertyDto implements Serializable {
 
-    private Long id;
+    private Long orgId;
 
-    private Long coursePropertyId;
+    private String coursePropertyId;
+
+    private String parentId;
+
+    private String id;
 
     private String name;
 
     private Integer number;
 
-    private Long parentId;
-
     private String remark;
 
-    private List<PropertyDto> propertyDtos;
+    private List<PropertyDto> propertyList;
 
-    public Long getId() {
-        return id;
+    public List<PropertyDto> getPropertyList() {
+        if (propertyList == null) {
+            return new ArrayList<>();
+        }
+        return propertyList;
     }
 
-    public void setId(Long id) {
-        this.id = id;
+    public void setPropertyList(List<PropertyDto> propertyList) {
+        this.propertyList = propertyList;
+    }
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
     }
 
-    public Long getCoursePropertyId() {
+    public String getCoursePropertyId() {
         return coursePropertyId;
     }
 
-    public void setCoursePropertyId(Long coursePropertyId) {
+    public void setCoursePropertyId(String coursePropertyId) {
         this.coursePropertyId = coursePropertyId;
     }
 
+    public String getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(String parentId) {
+        this.parentId = parentId;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
     public String getName() {
         return name;
     }
@@ -55,14 +86,6 @@ public class PropertyDto {
         this.number = number;
     }
 
-    public Long getParentId() {
-        return parentId;
-    }
-
-    public void setParentId(Long parentId) {
-        this.parentId = parentId;
-    }
-
     public String getRemark() {
         return remark;
     }
@@ -71,12 +94,4 @@ public class PropertyDto {
         this.remark = remark;
     }
 
-    public List<PropertyDto> getPropertyDtos() {
-        return propertyDtos;
-    }
-
-    public void setPropertyDtos(List<PropertyDto> propertyDtos) {
-        this.propertyDtos = propertyDtos;
-    }
-
-}
+}

+ 13 - 53
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/CoursePropertyService.java

@@ -9,89 +9,49 @@ import java.util.List;
 
 /**
  * @author weiwenhai
- * @describle 课程属性 coursePropertyService
+ * @describle 课程属性
  * @date 2017.11.2
  */
 public interface CoursePropertyService {
 
     /**
      * 查询所有课程属性
-     *
-     * @param orgId
-     * @return
      */
-    public List<CourseProperty> findAllByOrgId(Long orgId);
+    List<CourseProperty> findAllByOrgId(Long orgId);
 
     /**
      * 查询所有课程属性带分页
-     *
-     * @param coursePropertyDto
-     * @param pageable
-     * @return
      */
-    public Page<CourseProperty> findAllByOrg(CoursePropertyDto coursePropertyDto, Pageable pageable);
+    Page<CourseProperty> findList(CoursePropertyDto dto, Pageable pageable);
 
     /**
      * 保存课程属性
-     *
-     * @param coursePropertyDto
      */
-    public void saveCourseProperty(CoursePropertyDto coursePropertyDto) throws Exception;
-
-    /**
-     * 启用
-     *
-     * @param id
-     * @param orgId
-     */
-    public void openCourseProperty(Long id);
-
-    /**
-     * 禁用
-     *
-     * @param id
-     * @param orgId
-     */
-    public void closeCourseProperty(Long id);
+    void saveCourseProperty(CoursePropertyDto dto);
 
     /**
      * 根据课程id查询所有课程属性
-     *
-     * @param courseId
-     * @return
      */
-    public List<CourseProperty> findAllByCourseId(Long courseId);
+    List<CourseProperty> findAllByCourseId(Long courseId);
 
     /**
      * 根据课程code查询所有课程属性
-     *
-     * @param courseId
-     * @return
      */
-    public List<CourseProperty> findAllByCourseCode(String code);
+    List<CourseProperty> findAllByCourseCode(String courseCode);
 
     /**
      * 根据课程code查询所有开启的课程属性
-     *
-     * @param code
-     * @param enable
-     * @return
      */
-    public List<CourseProperty> findAllEnable(String code, Boolean enable);
+    List<CourseProperty> findByEnable(String courseCode, Boolean enable);
 
     /**
-     * 批量启用
-     *
-     * @param idList
-     * @param orgId
+     * 批量启用/批量禁用
      */
-    public void opensCourseProperty(List<String> idList);
+    void updateCoursePropertyStatus(List<String> coursePropertyIds, Boolean enable);
 
     /**
-     * 批量禁用
-     *
-     * @param idList
-     * @param orgId
+     * 启用/禁用
      */
-    public void closesCourseProperty(List<String> idList);
-}
+    void updateCoursePropertyStatus(String coursePropertyId, Boolean enable);
+
+}

+ 32 - 23
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ImportPaperService.java

@@ -1014,29 +1014,32 @@ public class ImportPaperService {
                 }
                 throw new PaperException(importPaperCheck.getErrorInfo());
             }
+
             for (CourseProperty courseProperty : courseProperties) {
                 Property propertyParent = new Property();
                 propertyParent.setCoursePropertyId(courseProperty.getId());
-                propertyParent.setParentId(0L);
+                propertyParent.setParentId(Property.ROOT_PARENT_ID);
                 propertyParent.setName(firstProperty);
 
                 //查询一级属性是否存在
-                List<Property> propertieParents = propertyRepo.findAll(Example.of(propertyParent));
+                List<Property> parentProperties = propertyRepo.findAll(Example.of(propertyParent));
+
                 //存在一级属性
-                if (propertieParents != null && propertieParents.size() > 0) {
+                if (parentProperties != null && parentProperties.size() > 0) {
                     isFirstEmpty = false;
-                    for (Property proParent : propertieParents) {
+                    for (Property proParent : parentProperties) {
                         Property propertySon = new Property();
                         propertySon.setCoursePropertyId(courseProperty.getId());
                         propertySon.setParentId(proParent.getId());
                         propertySon.setName(secondProperty);
 
                         //查询二级属性
-                        List<Property> propertieSons = propertyRepo.findAll(Example.of(propertySon));
+                        List<Property> sonProperties = propertyRepo.findAll(Example.of(propertySon));
+
                         //存在二级属性
-                        if (propertieSons != null && propertieSons.size() > 0) {
+                        if (sonProperties != null && sonProperties.size() > 0) {
                             isSecondEmpty = false;
-                            for (Property proSon : propertieSons) {
+                            for (Property proSon : sonProperties) {
                                 //保存一级和二级属性
                                 QuesProperty quesProperty = new QuesProperty(proParent, proSon, courseProperty);
                                 String idNumber = quesProperty.getCoursePropertyName() + "-" + quesProperty.getFirstProperty().getId() + "-" + quesProperty.getSecondProperty().getId();
@@ -1047,6 +1050,7 @@ public class ImportPaperService {
                     }
                 }
             }
+
             if (isFirstEmpty) {
                 if (importPaperCheck.getNestedHeadNumber() != 0) {
                     importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第" + importPaperCheck.getNestedHeadNumber() + "个题" + subQuesNum + "中,小题一级属性值与课程属性中一级属性不匹配,请检查");
@@ -1055,6 +1059,7 @@ public class ImportPaperService {
                 }
                 throw new PaperException(importPaperCheck.getErrorInfo());
             }
+
             if (isSecondEmpty) {
                 if (importPaperCheck.getNestedHeadNumber() != 0) {
                     importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第" + importPaperCheck.getNestedHeadNumber() + "个题" + subQuesNum + "中,小题二级属性值与课程属性中二级属性不匹配,请检查");
@@ -1063,11 +1068,12 @@ public class ImportPaperService {
                 }
                 throw new PaperException(importPaperCheck.getErrorInfo());
             }
-        }
-        //一级属性有值,二级属性为空
-        else if (StringUtils.isNotBlank(firstProperty) && StringUtils.isBlank(secondProperty)) {
+        } else if (StringUtils.isNotBlank(firstProperty) && StringUtils.isBlank(secondProperty)) {
+            //一级属性有值,二级属性为空
+
             boolean isFirstEmpty = true;
             boolean isSecondEmpty = true;
+
             //根据课程查询所有课程属性树
             List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseCodeAndEnable(paper.getCourse().getCode(), true);
             if (courseProperties == null || courseProperties.size() < 1) {
@@ -1083,18 +1089,20 @@ public class ImportPaperService {
                 //查询一级属性
                 Property propertyParent = new Property();
                 propertyParent.setCoursePropertyId(courseProperty.getId());
-                propertyParent.setParentId(0L);
+                propertyParent.setParentId(Property.ROOT_PARENT_ID);
                 propertyParent.setName(firstProperty);
 
-                List<Property> propertieParents = propertyRepo.findAll(Example.of(propertyParent));
+                List<Property> parentProperties = propertyRepo.findAll(Example.of(propertyParent));
+
                 //存在一级属性
-                if (propertieParents != null && propertieParents.size() > 0) {
+                if (parentProperties != null && parentProperties.size() > 0) {
                     isFirstEmpty = false;
-                    for (Property proParent : propertieParents) {
+                    for (Property proParent : parentProperties) {
                         //根据一级属性查询二级属性
-                        List<Property> proSons = propertyRepo.findByParentIdOrderByNumber(proParent.getId());
+                        List<Property> sonProperties = propertyRepo.findByParentIdOrderByNumber(proParent.getId());
+
                         //存在二级属性,跳过
-                        if (proSons != null && proSons.size() > 0) {
+                        if (sonProperties != null && sonProperties.size() > 0) {
                             continue;
                         } else {
                             isSecondEmpty = false;
@@ -1115,6 +1123,7 @@ public class ImportPaperService {
                 }
                 throw new PaperException(importPaperCheck.getErrorInfo());
             }
+
             if (isSecondEmpty) {
                 if (importPaperCheck.getNestedHeadNumber() != 0) {
                     importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第" + importPaperCheck.getNestedHeadNumber() + "个题" + subQuesNum + "中,小题二级属性值与课程属性中二级属性不匹配,请检查");
@@ -1123,9 +1132,8 @@ public class ImportPaperService {
                 }
                 throw new PaperException(importPaperCheck.getErrorInfo());
             }
-        }//一级,二级都为空
-        else {
-
+        } else {
+            //一级,二级都为空
         }
     }
 
@@ -1137,8 +1145,7 @@ public class ImportPaperService {
      * @param difficulty
      * @param publicity
      */
-    private void checkAttributeIsFull(String firstProperty, String secondProperty, Double difficulty,
-                                      Boolean publicity, ImportPaperCheck importPaperCheck, int subQuesNum) throws Exception {
+    private void checkAttributeIsFull(String firstProperty, String secondProperty, Double difficulty, Boolean publicity, ImportPaperCheck importPaperCheck, int subQuesNum) throws Exception {
         if (firstProperty == null) {
             if (importPaperCheck.getNestedHeadNumber() != 0) {
                 importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第" + importPaperCheck.getNestedHeadNumber() + "个题" + subQuesNum + "中,小题一级属性缺失,请检查");
@@ -1147,6 +1154,7 @@ public class ImportPaperService {
             }
             throw new PaperException(importPaperCheck.getErrorInfo());
         }
+
         if (secondProperty == null) {
             if (importPaperCheck.getNestedHeadNumber() != 0) {
                 importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第" + importPaperCheck.getNestedHeadNumber() + "个题" + subQuesNum + "中,小题二级属性缺失,请检查");
@@ -1155,6 +1163,7 @@ public class ImportPaperService {
             }
             throw new PaperException(importPaperCheck.getErrorInfo());
         }
+
         if (difficulty == null) {
             if (importPaperCheck.getNestedHeadNumber() != 0) {
                 importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第" + importPaperCheck.getNestedHeadNumber() + "个题" + subQuesNum + "中,小题难度缺失,请检查");
@@ -1163,6 +1172,7 @@ public class ImportPaperService {
             }
             throw new PaperException(importPaperCheck.getErrorInfo());
         }
+
         if (publicity == null) {
             if (importPaperCheck.getNestedHeadNumber() != 0) {
                 importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第" + importPaperCheck.getNestedHeadNumber() + "个题" + subQuesNum + "中,小题公开性缺失,请检查");
@@ -1204,8 +1214,7 @@ public class ImportPaperService {
      * @param importPaperCheck
      * @throws Exception
      */
-    public void processNestedQues(List<Object> pList, int index, Question question, PaperDetailUnit paperDetailUnit,
-                                  ImportPaperCheck importPaperCheck, WordprocessingMLPackage wordMLPackage, Paper paper) throws Exception {
+    public void processNestedQues(List<Object> pList, int index, Question question, PaperDetailUnit paperDetailUnit, ImportPaperCheck importPaperCheck, WordprocessingMLPackage wordMLPackage, Paper paper) throws Exception {
         // 题型
         String nestedQuesType = "";
         //处理套题的头信息

+ 13 - 46
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PropertyService.java

@@ -1,6 +1,5 @@
 package cn.com.qmth.examcloud.core.questions.service;
 
-import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.core.questions.dao.entity.Property;
 import cn.com.qmth.examcloud.core.questions.dao.entity.dto.PropertyDto;
 
@@ -15,79 +14,47 @@ public interface PropertyService {
 
     /**
      * 保存属性
-     *
-     * @param propertyDtos
      */
-    public void saveProperty(List<PropertyDto> propertyDtos, User user);
-
-    /**
-     * 查询属性
-     *
-     * @param coursePropertyId
-     * @param user
-     * @return
-     */
-    public List<PropertyDto> propertyDtos(Long coursePropertyId, User user);
+    void saveProperty(List<PropertyDto> dtoList, Long orgId);
 
     /**
      * 新增属性
-     *
-     * @param property
-     * @param user
      */
-    public void saveProperty(Property property, User user) throws Exception;
+    void saveProperty(PropertyDto dto);
 
     /**
      * 删除属性
-     *
-     * @param propertyId
      */
-    public void deleteProperty(Long propertyId, Long coursePropertyId, User user);
+    void deleteProperty(String propertyId, String coursePropertyId, Long orgId);
 
     /**
      * 查询所有属性
-     *
-     * @param coursePropertyId
-     * @param user
-     * @return
      */
-    public List<Property> findAll(Long coursePropertyId, User user);
+    List<Property> findProperties(String coursePropertyId, Long orgId);
 
     /**
      * 查询某个树下的子节点
-     *
-     * @param property
-     * @return
      */
-    public List<Property> findPropertySons(Property property);
+    List<Property> findSonProperties(String propertyId);
 
     /**
-     * 查询某个树下的子节点
-     *
-     * @param property
-     * @return
+     * 查询课程属性下面的所有父节点
      */
-    public List<Property> findPropertySons(Long propertyId);
+    List<Property> findParentProperties(String coursePropertyId, Long orgId);
 
     /**
-     * 查询课程属性下面的所有父节点
-     *
-     * @param property
-     * @return
+     * 查询属性
      */
-    public List<Property> findPropertyParents(Long coursePropertyId, Long orgId);
+    List<PropertyDto> findParentPropertyDtoList(String coursePropertyId, Long orgId);
 
     /**
      * 上移
-     *
-     * @param property
      */
-    public void moveUp(Property property) throws Exception;
+    void moveUp(PropertyDto dto);
 
     /**
      * 下移
-     *
-     * @param property
      */
-    public void moveDown(Property property) throws Exception;
-}
+    void moveDown(PropertyDto dto);
+
+}

+ 27 - 28
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/PropertyAssembler.java

@@ -2,6 +2,7 @@ package cn.com.qmth.examcloud.core.questions.service.bean;
 
 import cn.com.qmth.examcloud.core.questions.dao.entity.Property;
 import cn.com.qmth.examcloud.core.questions.dao.entity.dto.PropertyDto;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
@@ -12,40 +13,38 @@ public class PropertyAssembler {
 
     /**
      * 得到父节点对象
-     *
-     * @param propertyDto
-     * @return
      */
-    public Property toProperty(PropertyDto propertyDto) {
-        Property property = null;
-        if (propertyDto != null) {
-            property = new Property();
-            property.setId(propertyDto.getId());
-            property.setCoursePropertyId(propertyDto.getCoursePropertyId());
-            property.setName(propertyDto.getName());
-            property.setParentId(propertyDto.getCoursePropertyId());
-            property.setRemark(propertyDto.getRemark());
+    public Property toProperty(PropertyDto dto) {
+        if (dto != null) {
+            Property property = new Property();
+            property.setCoursePropertyId(dto.getCoursePropertyId());
+            property.setParentId(dto.getCoursePropertyId());
+            property.setId(dto.getId());
+            property.setName(dto.getName());
+            property.setRemark(dto.getRemark());
+            return property;
         }
-        return property;
+
+        return null;
     }
 
     /**
      * 得到子类节点对象
-     *
-     * @param propertyDto
-     * @return
      */
-    public List<Property> toPropertySon(PropertyDto propertyDto) {
-        Property property = null;
-        List<PropertyDto> propertyDtos = propertyDto.getPropertyDtos();
-        if (propertyDtos != null && propertyDtos.size() > 0) {
-            List<Property> properties = new ArrayList<>();
-            for (PropertyDto propertyDto2 : propertyDtos) {
-                property = toProperty(propertyDto2);
-                properties.add(property);
-            }
-            return properties;
+    public List<Property> toPropertySon(PropertyDto dto) {
+        List<PropertyDto> propertyList = dto.getPropertyList();
+
+        if (CollectionUtils.isEmpty(propertyList)) {
+            return null;
         }
-        return null;
+
+        List<Property> properties = new ArrayList<>();
+        for (PropertyDto propertyDto : propertyList) {
+            Property property = toProperty(propertyDto);
+            properties.add(property);
+        }
+
+        return properties;
     }
-}
+
+}

+ 103 - 91
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/CoursePropertyServiceImpl.java

@@ -1,27 +1,29 @@
 package cn.com.qmth.examcloud.core.questions.service.impl;
 
-import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
-import cn.com.qmth.examcloud.core.basic.api.request.GetCourseReq;
-import cn.com.qmth.examcloud.core.basic.api.response.GetCourseResp;
+import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.core.questions.base.Constants;
 import cn.com.qmth.examcloud.core.questions.base.Model;
 import cn.com.qmth.examcloud.core.questions.dao.CoursePropertyRepo;
 import cn.com.qmth.examcloud.core.questions.dao.entity.CourseProperty;
 import cn.com.qmth.examcloud.core.questions.dao.entity.dto.CoursePropertyDto;
 import cn.com.qmth.examcloud.core.questions.service.CoursePropertyService;
+import cn.com.qmth.examcloud.support.cache.CacheHelper;
+import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
 
-import javax.persistence.criteria.Predicate;
-import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 /**
  * @author weiwenhai
- * @describle 课程属性 coursePropertyServiceImpl
+ * @describle 课程属性
  * @date 2017.11.2
  */
 @Service("coursePropertyService")
@@ -30,124 +32,134 @@ public class CoursePropertyServiceImpl implements CoursePropertyService {
     @Autowired
     private CoursePropertyRepo coursePropertyRepo;
 
-    @Autowired
-    CourseCloudService courseCloudService;
-
     @Override
     public List<CourseProperty> findAllByOrgId(Long orgId) {
-        List<CourseProperty> courseProperties = coursePropertyRepo.findByOrgId(orgId);
-        return courseProperties;
+        return coursePropertyRepo.findByOrgId(orgId);
     }
 
     @Override
-    public void saveCourseProperty(CoursePropertyDto coursePropertyDto) throws Exception {
-        coursePropertyDto.setEnable("1");
-        CourseProperty courseProperty = coursePropertyRepo.findByNameAndOrgId(coursePropertyDto.getName(), coursePropertyDto.getOrgId());
-        if (courseProperty != null) {
-            throw new Exception("课程属性名已经存在");
+    public void saveCourseProperty(CoursePropertyDto dto) {
+        if (StringUtils.isBlank(dto.getName())) {
+            throw new StatusException(Constants.SYS_CODE_400, "属性名不能为空!");
         }
-        courseProperty = new CourseProperty(coursePropertyDto);
-        coursePropertyRepo.save(courseProperty);
-    }
 
-    @Override
-    public Page<CourseProperty> findAllByOrg(CoursePropertyDto coursePropertyDto, Pageable pageable) {
-        Specification<CourseProperty> specification = getSpecification(coursePropertyDto);
-        Page<CourseProperty> coursePropertyies = coursePropertyRepo.findAll(specification, pageable);
-        List<CourseProperty> list = coursePropertyies.getContent();
-        if (list != null && list.size() > 0) {
-            for (CourseProperty courseProperty : list) {
-                GetCourseReq req = new GetCourseReq();
-                req.setId(courseProperty.getCourseId());
-                req.setRootOrgId(courseProperty.getOrgId());
-                GetCourseResp resp = courseCloudService.getCourse(req);
-                courseProperty.setCourseName(resp.getCourseBean().getName());
-            }
+        if (dto.getOrgId() == null) {
+            throw new StatusException(Constants.SYS_CODE_400, "所属机构不能为空!");
         }
-        return coursePropertyies;
-    }
 
-    private Specification<CourseProperty> getSpecification(CoursePropertyDto coursePropertyDto) {
-        CourseProperty courseProperty = new CourseProperty(coursePropertyDto);
-        Specification<CourseProperty> specification = (root, query, cb) -> {
-            List<Predicate> predicates = new ArrayList<>();
-            if (!StringUtils.isEmpty(courseProperty.getOrgId())) {
-                predicates.add(cb.equal(root.get("orgId"), courseProperty.getOrgId()));
-            }
-            if (!StringUtils.isEmpty(courseProperty.getName())) {
-                predicates.add(cb.like(root.get("name"), "%" + courseProperty.getName() + "%"));
-            }
-            if (!StringUtils.isEmpty(courseProperty.getCourseId())) {
-                predicates.add(cb.equal(root.get("courseId"), courseProperty.getCourseId()));
-            }
-            if (!StringUtils.isEmpty(courseProperty.getEnable())) {
-                predicates.add(cb.equal(root.get("enable"), courseProperty.getEnable()));
-            }
-            return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-        };
-        return specification;
-    }
+        if (dto.getCourseId() == null || StringUtils.isBlank(dto.getCourseCode())) {
+            throw new StatusException(Constants.SYS_CODE_400, "所属课程不能为空!");
+        }
 
-    @Override
-    public void openCourseProperty(Long id) {
-        CourseProperty courseProperty = Model.of(coursePropertyRepo.findById(id));
+        CourseProperty courseProperty = coursePropertyRepo.findByOrgIdAndName(dto.getOrgId(), dto.getName());
+        if (courseProperty != null) {
+            throw new StatusException(Constants.SYS_CODE_500, "课程属性名已经存在!");
+        }
+
+        if (StringUtils.isBlank(dto.getId())) {
+            dto.setId(null);//剔除空字符串ID(导致异常数据)
+        }
+
+        courseProperty = new CourseProperty();
+        courseProperty.setId(dto.getId());
+        courseProperty.setName(dto.getName());
+        courseProperty.setOrgId(dto.getOrgId());
+        courseProperty.setCourseId(dto.getCourseId());
+        courseProperty.setCourseCode(dto.getCourseCode());
         courseProperty.setEnable(true);
+        courseProperty.setUpdateTime(new Date());
+
         coursePropertyRepo.save(courseProperty);
     }
 
     @Override
-    public void closeCourseProperty(Long id) {
-        CourseProperty courseProperty = Model.of(coursePropertyRepo.findById(id));
-        courseProperty.setEnable(false);
-        coursePropertyRepo.save(courseProperty);
+    public Page<CourseProperty> findList(CoursePropertyDto dto, Pageable pageable) {
+        CourseProperty params = new CourseProperty();
+
+        if (dto.getOrgId() != null) {
+            params.setOrgId(dto.getOrgId());
+        }
+
+        if (dto.getCourseId() != null) {
+            params.setCourseId(dto.getCourseId());
+        }
+
+        if (dto.getEnable() != null) {
+            params.setEnable(dto.getEnable());
+        }
+
+        Example<CourseProperty> query;
+        if (!StringUtils.isEmpty(dto.getName())) {
+            params.setName(dto.getName());
+
+            ExampleMatcher matcher = ExampleMatcher.matching().withMatcher("name", match -> match.contains());
+
+            query = Example.of(params, matcher);
+        } else {
+            query = Example.of(params);
+        }
+
+        Page<CourseProperty> page = coursePropertyRepo.findAll(query, pageable);
+
+        List<CourseProperty> list = page.getContent();
+        if (CollectionUtils.isEmpty(list)) {
+            return page;
+        }
+
+        for (CourseProperty courseProperty : list) {
+            CourseCacheBean course = CacheHelper.getCourse(courseProperty.getCourseId());
+            if (course != null) {
+                courseProperty.setCourseName(course.getName());
+            }
+        }
+
+        return page;
     }
 
     @Override
     public List<CourseProperty> findAllByCourseId(Long courseId) {
-        List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseId(courseId);
-        return courseProperties;
+        return coursePropertyRepo.findByCourseId(courseId);
     }
 
     @Override
-    public List<CourseProperty> findAllByCourseCode(String code) {
-        List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseCode(code);
-        return courseProperties;
+    public List<CourseProperty> findAllByCourseCode(String courseCode) {
+        return coursePropertyRepo.findByCourseCode(courseCode);
     }
 
     @Override
-    public List<CourseProperty> findAllEnable(String code, Boolean enable) {
-        List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseCodeAndEnable(code, true);
-        return courseProperties;
+    public List<CourseProperty> findByEnable(String courseCode, Boolean enable) {
+        return coursePropertyRepo.findByCourseCodeAndEnable(courseCode, enable);
     }
 
     @Override
-    public void opensCourseProperty(List<String> idList) {
-        List<Long> ids = new ArrayList<Long>();
-        if (idList != null && idList.size() > 0) {
-            for (String id : idList) {
-                ids.add(Long.parseLong(id));
-            }
+    public void updateCoursePropertyStatus(List<String> coursePropertyIds, Boolean enable) {
+        if (CollectionUtils.isEmpty(coursePropertyIds)) {
+            return;
+        }
+
+        List<CourseProperty> courseProperties = coursePropertyRepo.findByIdIn(coursePropertyIds);
+        if (CollectionUtils.isEmpty(courseProperties)) {
+            return;
         }
-        List<CourseProperty> courseProperties = coursePropertyRepo.findByIdIn(ids);
+
         for (CourseProperty courseProperty : courseProperties) {
-            courseProperty.setEnable(true);
+            courseProperty.setEnable(enable);
+            courseProperty.setUpdateTime(new Date());
         }
+
         coursePropertyRepo.saveAll(courseProperties);
     }
 
     @Override
-    public void closesCourseProperty(List<String> idList) {
-        List<Long> ids = new ArrayList<Long>();
-        if (idList != null && idList.size() > 0) {
-            for (String id : idList) {
-                ids.add(Long.parseLong(id));
-            }
-        }
-        List<CourseProperty> courseProperties = coursePropertyRepo.findByIdIn(ids);
-        for (CourseProperty courseProperty : courseProperties) {
-            courseProperty.setEnable(false);
+    public void updateCoursePropertyStatus(String coursePropertyId, Boolean enable) {
+        CourseProperty courseProperty = Model.of(coursePropertyRepo.findById(coursePropertyId));
+        if (courseProperty == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "课程属性已不存在!");
         }
-        coursePropertyRepo.saveAll(courseProperties);
+
+        courseProperty.setEnable(enable);
+        courseProperty.setUpdateTime(new Date());
+        coursePropertyRepo.save(courseProperty);
     }
 
-}
+}

+ 4 - 4
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExportPaperServiceImpl.java

@@ -563,10 +563,10 @@ public class ExportPaperServiceImpl implements ExportPaperService {
 
         //3.遍历课程属性集合,根据课程属性查询一级
         for (CourseProperty courseProperty : courseProperties) {
-            List<Property> parentProperties = propertyService.findPropertyParents(courseProperty.getId(), courseProperty.getOrgId());
+            List<Property> parentProperties = propertyService.findParentProperties(courseProperty.getId(), courseProperty.getOrgId());
             if (parentProperties != null && parentProperties.size() > 0) {
                 for (Property parentProperty : parentProperties) {
-                    List<Property> sonProperties = propertyService.findPropertySons(parentProperty.getId());
+                    List<Property> sonProperties = propertyService.findSonProperties(parentProperty.getId());
                     if (sonProperties != null && sonProperties.size() > 0) {
                         for (Property sonProperty : sonProperties) {
                             //单选题集合
@@ -858,10 +858,10 @@ public class ExportPaperServiceImpl implements ExportPaperService {
             //遍历课程属性集合,根据课程属性查询一级
             if (courseProperties != null && courseProperties.size() > 0) {
                 for (CourseProperty courseProperty : courseProperties) {
-                    List<Property> parentProperties = propertyService.findPropertyParents(courseProperty.getId(), courseProperty.getOrgId());
+                    List<Property> parentProperties = propertyService.findParentProperties(courseProperty.getId(), courseProperty.getOrgId());
                     if (parentProperties != null && parentProperties.size() > 0) {
                         for (Property parentProperty : parentProperties) {
-                            List<Property> sonProperties = propertyService.findPropertySons(parentProperty.getId());
+                            List<Property> sonProperties = propertyService.findSonProperties(parentProperty.getId());
                             if (sonProperties != null && sonProperties.size() > 0) {
                                 for (Property sonProperty : sonProperties) {
                                     //单选题集合

+ 181 - 108
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PropertyServiceImpl.java

@@ -1,6 +1,7 @@
 package cn.com.qmth.examcloud.core.questions.service.impl;
 
-import cn.com.qmth.examcloud.api.commons.security.bean.User;
+import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.core.questions.base.Constants;
 import cn.com.qmth.examcloud.core.questions.base.Model;
 import cn.com.qmth.examcloud.core.questions.dao.PropertyRepo;
 import cn.com.qmth.examcloud.core.questions.dao.entity.Property;
@@ -8,6 +9,11 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.dto.PropertyConvert;
 import cn.com.qmth.examcloud.core.questions.dao.entity.dto.PropertyDto;
 import cn.com.qmth.examcloud.core.questions.service.PropertyService;
 import cn.com.qmth.examcloud.core.questions.service.bean.PropertyAssembler;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.compress.utils.Lists;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -16,182 +22,249 @@ import java.util.List;
 
 /**
  * @author weiwenhai
- * @describle 课程属性 coursePropertyServiceImpl
+ * @describle 课程属性
  * @date 2017.11.8
  */
 @Service("propertyService")
 public class PropertyServiceImpl implements PropertyService {
-
+    private static final Logger log = LoggerFactory.getLogger(PropertyServiceImpl.class);
     @Autowired
     private PropertyRepo propertyRepo;
 
     @Override
-    public void saveProperty(List<PropertyDto> propertyDtos, User user) {
+    public void saveProperty(List<PropertyDto> dtoList, Long orgId) {
+        if (CollectionUtils.isEmpty(dtoList)) {
+            throw new StatusException(Constants.SYS_CODE_500, "属性列表不能为空!");
+        }
+        if (orgId == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "机构ID不能为空!");
+        }
+
         PropertyAssembler propertyAssembler = new PropertyAssembler();
-        for (int i = 0; i < propertyDtos.size(); i++) {
+        for (int i = 0; i < dtoList.size(); i++) {
             //取到父类节点对象
-            Property property = propertyAssembler.toProperty(propertyDtos.get(i));
+            PropertyDto dto = dtoList.get(i);
+
+            Property property = propertyAssembler.toProperty(dto);
             property.setNumber(i + 1);
-            property.setOrgId(user.getRootOrgId());
+            property.setOrgId(orgId);
             property = propertyRepo.save(property);
-            List<Property> properties = propertyAssembler.toPropertySon(propertyDtos.get(i));
-            if (properties != null && properties.size() > 0) {
-                for (int j = 0; j < properties.size(); j++) {
-                    properties.get(j).setParentId(property.getId());
-                    properties.get(j).setNumber(j + 1);
+
+            List<Property> sonProperties = propertyAssembler.toPropertySon(dto);
+            if (CollectionUtils.isNotEmpty(sonProperties)) {
+                for (int j = 0; j < sonProperties.size(); j++) {
+                    Property sonProperty = sonProperties.get(j);
+                    sonProperty.setParentId(property.getId());
+                    sonProperty.setNumber(j + 1);
                 }
-                propertyRepo.saveAll(properties);
+
+                propertyRepo.saveAll(sonProperties);
             }
         }
     }
 
     @Override
-    public List<PropertyDto> propertyDtos(Long coursePropertyId, User user) {
-        List<PropertyDto> propertyDtos = new ArrayList<>();
-        //查询所有父节点对象
-        List<Property> propertieParents = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(user.getRootOrgId(), coursePropertyId, 0l);
-        if (propertieParents != null && propertieParents.size() > 0) {
-            for (Property property : propertieParents) {
-                PropertyDto propertyDtoParent = PropertyConvert.of(property);
-                //查询所有子节点对象
-                List<Property> propertiesSons = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(user.getRootOrgId(), coursePropertyId, property.getId());
-                if (propertiesSons != null && propertiesSons.size() > 0) {
-                    List<PropertyDto> propertyDtosSons = new ArrayList<>();
-                    for (Property property2 : propertiesSons) {
-                        PropertyDto propertyDto2 = PropertyConvert.of(property2);
-                        propertyDtosSons.add(propertyDto2);
-                    }
-                    propertyDtoParent.setPropertyDtos(propertyDtosSons);
-                }
-                propertyDtos.add(propertyDtoParent);
-            }
+    public void saveProperty(PropertyDto dto) {
+        if (dto.getOrgId() == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "机构ID不能为空!");
+        }
+        if (dto.getCoursePropertyId() == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "课程属性ID不能为空!");
+        }
+        if (dto.getParentId() == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "上级ID不能为空!");
+        }
+        if (StringUtils.isEmpty(dto.getName())) {
+            throw new StatusException(Constants.SYS_CODE_500, "属性名不能为空!");
         }
-        return propertyDtos;
-    }
 
-    @Override
-    public void saveProperty(Property property, User user) throws Exception {
-        //新增
+        if (StringUtils.isBlank(dto.getId())) {
+            dto.setId(null);//剔除空字符串ID(导致异常数据)
+        }
+
+        Property property = PropertyConvert.of(dto);
         if (property.getId() == null) {
-            //检查是否重名
-            Property sameName = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdAndName(user.getRootOrgId(), property.getCoursePropertyId(), property.getParentId(), property.getName());
-            if (sameName != null) {
-                throw new Exception("属性名已经存在");
+            //新增
+            Property existProperty = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdAndName(property.getOrgId(), property.getCoursePropertyId(), property.getParentId(), property.getName());
+            if (existProperty != null) {
+                throw new StatusException(Constants.SYS_CODE_500, "属性名已经存在");
             }
+
             Integer number = 0;
-            List<Property> propertieParents = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(user.getRootOrgId(), property.getCoursePropertyId(), property.getParentId());
-            if (propertieParents != null && propertieParents.size() > 0) {
-                number = propertieParents.get(propertieParents.size() - 1).getNumber();
+            List<Property> parentProperties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(property.getOrgId(), property.getCoursePropertyId(), property.getParentId());
+            if (parentProperties != null && parentProperties.size() > 0) {
+                number = parentProperties.get(parentProperties.size() - 1).getNumber();
             }
+
             property.setNumber(number + 1);
         } else {
-            //得到原来的对象
-            Property propertyOld = Model.of(propertyRepo.findById(property.getId()));
-            if (!propertyOld.getName().equals(property.getName())) {
+            //修改
+            Property oldProperty = Model.of(propertyRepo.findById(property.getId()));
+            if (oldProperty == null) {
+                throw new StatusException(Constants.SYS_CODE_500, "当前属性已不存在!");
+            }
+
+            if (!oldProperty.getName().equals(property.getName())) {
                 //检查是否重名
-                Property sameName = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdAndName(user.getRootOrgId(), property.getCoursePropertyId(), property.getParentId(), property.getName());
-                if (sameName != null) {
-                    throw new Exception("属性名已经存在");
+                Property existProperty = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdAndName(property.getOrgId(), property.getCoursePropertyId(), property.getParentId(), property.getName());
+                if (existProperty != null) {
+                    throw new StatusException(Constants.SYS_CODE_500, "属性名已经存在");
                 }
             }
         }
-        property.setOrgId(user.getRootOrgId());
+
         propertyRepo.save(property);
     }
 
     @Override
-    public void deleteProperty(Long propertyId, Long coursePropertyId, User user) {
+    public void deleteProperty(String propertyId, String coursePropertyId, Long orgId) {
         //查询子节点对象
-        List<Property> properties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(user.getRootOrgId(), coursePropertyId, propertyId);
-        if (properties != null && properties.size() > 0) {
-            for (Property property : properties) {
+        List<Property> childProperties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(orgId, coursePropertyId, propertyId);
+        if (childProperties != null && childProperties.size() > 0) {
+            for (Property property : childProperties) {
                 propertyRepo.delete(property);
             }
         }
+
         propertyRepo.deleteById(propertyId);
     }
 
     @Override
-    public List<Property> findAll(Long coursePropertyId, User user) {
-        List<PropertyDto> propertyDtos = propertyDtos(coursePropertyId, user);
+    public List<Property> findProperties(String coursePropertyId, Long orgId) {
+        List<PropertyDto> parentProperties = this.findParentPropertyDtoList(coursePropertyId, orgId);
+        if (CollectionUtils.isEmpty(parentProperties)) {
+            return Lists.newArrayList();
+        }
+
         List<Property> properties = new ArrayList<>();
-        if (propertyDtos != null && propertyDtos.size() > 0) {
-            for (PropertyDto propertyDto : propertyDtos) {
-                Property property = PropertyConvert.of(propertyDto);
-                properties.add(property);
-                if (propertyDto.getPropertyDtos() != null && propertyDto.getPropertyDtos().size() > 0) {
-                    for (PropertyDto propertyDtoSon : propertyDto.getPropertyDtos()) {
-                        Property propertySon = PropertyConvert.of(propertyDtoSon);
-                        properties.add(propertySon);
-                    }
+
+        for (PropertyDto parentDto : parentProperties) {
+            Property parentProperty = PropertyConvert.of(parentDto);
+            properties.add(parentProperty);
+
+            if (parentDto.getPropertyList() != null && parentDto.getPropertyList().size() > 0) {
+                for (PropertyDto sonDto : parentDto.getPropertyList()) {
+                    Property sonProperty = PropertyConvert.of(sonDto);
+                    properties.add(sonProperty);
                 }
             }
         }
+
         return properties;
     }
 
     @Override
-    public List<Property> findPropertySons(Property property) {
-        List<Property> properySonsList = propertyRepo.findByParentIdOrderByNumber(property.getId());
-        return properySonsList;
+    public List<Property> findSonProperties(String propertyId) {
+        return propertyRepo.findByParentIdOrderByNumber(propertyId);
     }
 
     @Override
-    public List<Property> findPropertySons(Long propertyId) {
-        List<Property> properySonsList = propertyRepo.findByParentIdOrderByNumber(propertyId);
-        return properySonsList;
+    public List<Property> findParentProperties(String coursePropertyId, Long orgId) {
+        return propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(orgId, coursePropertyId, Property.ROOT_PARENT_ID);
     }
 
     @Override
-    public List<Property> findPropertyParents(Long coursePropertyId, Long orgId) {
-        List<Property> properties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(orgId, coursePropertyId, 0l);
-        return properties;
+    public List<PropertyDto> findParentPropertyDtoList(String coursePropertyId, Long orgId) {
+        //查询所有父节点对象
+        List<Property> parentProperties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(orgId, coursePropertyId, Property.ROOT_PARENT_ID);
+
+        List<PropertyDto> dtoList = new ArrayList<>();
+        if (CollectionUtils.isEmpty(parentProperties)) {
+            return dtoList;
+        }
+
+        for (Property parentProperty : parentProperties) {
+            PropertyDto parentDto = PropertyConvert.of(parentProperty);
+
+            //查询所有子节点对象
+            List<Property> sonProperties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(orgId, coursePropertyId, parentProperty.getId());
+
+            if (CollectionUtils.isNotEmpty(sonProperties)) {
+                List<PropertyDto> list = new ArrayList<>();
+                for (Property sonProperty : sonProperties) {
+                    PropertyDto sonDto = PropertyConvert.of(sonProperty);
+                    list.add(sonDto);
+                }
+                parentDto.setPropertyList(list);
+            }
+
+            dtoList.add(parentDto);
+        }
+
+        return dtoList;
     }
 
     @Override
-    public void moveUp(Property property) throws Exception {
+    public void moveUp(PropertyDto dto) {
+        Property curProperty = Model.of(propertyRepo.findById(dto.getId()));
+        if (curProperty == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "当前属性已不存在!");
+        }
+
         //查询所有一级属性
-        List<Property> properties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(property.getOrgId(), property.getCoursePropertyId(), 0L);
-        if (properties.size() < 2) {
-            throw new Exception("无法上移");
-        } else {
-            for (int i = 0; i < properties.size(); i++) {
-                if (property.getId().equals(properties.get(i).getId())) {
-                    if (i == 0) {
-                        throw new Exception("无法上移");
-                    } else {
-                        Integer number = property.getNumber();
-                        property.setNumber(properties.get(i - 1).getNumber());
-                        properties.get(i - 1).setNumber(number);
-                        propertyRepo.save(property);
-                        propertyRepo.save(properties.get(i - 1));
-                    }
+        List<Property> parentProperties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(curProperty.getOrgId(), curProperty.getCoursePropertyId(), Property.ROOT_PARENT_ID);
+        if (CollectionUtils.isEmpty(parentProperties)) {
+            throw new StatusException(Constants.SYS_CODE_500, "无法上移!");
+        }
+
+        if (parentProperties.size() == 1) {
+            throw new StatusException(Constants.SYS_CODE_500, "无法上移!");
+        }
+
+        for (int i = 0; i < parentProperties.size(); i++) {
+            if (curProperty.getId().equals(parentProperties.get(i).getId())) {
+                if (i == 0) {
+                    throw new StatusException(Constants.SYS_CODE_500, "无法上移!");
                 }
+
+                Property nearProperty = parentProperties.get(i - 1);
+
+                //交换编号
+                Integer curNumber = curProperty.getNumber();
+                curProperty.setNumber(nearProperty.getNumber());
+                nearProperty.setNumber(curNumber);
+
+                propertyRepo.save(curProperty);
+                propertyRepo.save(nearProperty);
             }
         }
     }
 
     @Override
-    public void moveDown(Property property) throws Exception {
+    public void moveDown(PropertyDto dto) {
+        Property curProperty = Model.of(propertyRepo.findById(dto.getId()));
+        if (curProperty == null) {
+            throw new StatusException(Constants.SYS_CODE_500, "当前属性已不存在!");
+        }
+
         //查询所有一级属性
-        List<Property> properties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(property.getOrgId(), property.getCoursePropertyId(), 0l);
-        if (properties.size() < 2) {
-            throw new Exception("无法下移");
-        } else {
-            for (int i = 0; i < properties.size(); i++) {
-                if (property.getId().equals(properties.get(i).getId())) {
-                    if (i == (properties.size() - 1)) {
-                        throw new Exception("无法下移");
-                    } else {
-                        Integer number = property.getNumber();
-                        property.setNumber(properties.get(i + 1).getNumber());
-                        properties.get(i + 1).setNumber(number);
-                        propertyRepo.save(property);
-                        propertyRepo.save(properties.get(i + 1));
-                    }
+        List<Property> parentProperties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(curProperty.getOrgId(), curProperty.getCoursePropertyId(), Property.ROOT_PARENT_ID);
+
+        if (CollectionUtils.isEmpty(parentProperties)) {
+            throw new StatusException(Constants.SYS_CODE_500, "无法下移!");
+        }
+
+        if (parentProperties.size() == 1) {
+            throw new StatusException(Constants.SYS_CODE_500, "无法下移!");
+        }
+
+        for (int i = 0; i < parentProperties.size(); i++) {
+            if (curProperty.getId().equals(parentProperties.get(i).getId())) {
+                if (i == (parentProperties.size() - 1)) {
+                    throw new StatusException(Constants.SYS_CODE_500, "无法下移!");
                 }
+
+                Property nearProperty = parentProperties.get(i + 1);
+
+                //交换编号
+                Integer curNumber = curProperty.getNumber();
+                curProperty.setNumber(nearProperty.getNumber());
+                nearProperty.setNumber(curNumber);
+
+                propertyRepo.save(curProperty);
+                propertyRepo.save(nearProperty);
             }
         }
     }
 
-}
+}

+ 30 - 10
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/QuesServiceImpl.java

@@ -227,33 +227,38 @@ public class QuesServiceImpl implements QuesService {
      */
     public Page<Question> findAll(QuestionSearchCondition searchCondition, int curPage, int pageSize) {
         formatQuesCondition(searchCondition);
+
         Query query = new Query();
         query.addCriteria(Criteria.where("orgId").is(searchCondition.getOrgId()));
         query.addCriteria(Criteria.where("course.enable").is("true"));
+
         if (StringUtils.isNotBlank(searchCondition.getCourseNo())) {
             query.addCriteria(Criteria.where("course.code").is(searchCondition.getCourseNo()));
         }
+
         if (StringUtils.isNotBlank(searchCondition.getCourseLevel())) {
             query.addCriteria(Criteria.where("course.level").is(searchCondition.getCourseLevel()));
         }
+
         if (searchCondition.getQuestionType() != null) {
             query.addCriteria(Criteria.where("questionType").is(searchCondition.getQuestionType()));
         }
+
         if (searchCondition.getPublicity() != null) {
             query.addCriteria(Criteria.where("publicity").is(searchCondition.getPublicity()));
         }
+
         if (searchCondition.getCoursePropertyName() != null) {
             query.addCriteria(Criteria.where("quesProperties.coursePropertyName").is(searchCondition.getCoursePropertyName()));
         }
+
         //二级属性不为空,那么一级属性也不为空
-        if (searchCondition.getSecondPropertyId() != null) {
+        if (StringUtils.isNotEmpty(searchCondition.getSecondPropertyId())) {
             query.addCriteria(Criteria.where("quesProperties").elemMatch(
-                    Criteria.where("firstProperty.id").is(Long.parseLong(searchCondition.getFirstPropertyId()))
-                            .and("secondProperty.id").is(Long.parseLong(searchCondition.getSecondPropertyId()))));
+                    Criteria.where("firstProperty.id").is(searchCondition.getFirstPropertyId()).and("secondProperty.id").is(searchCondition.getSecondPropertyId())));
         } else {
             if (searchCondition.getFirstPropertyId() != null) {
-                query.addCriteria(Criteria.where("quesProperties").elemMatch(
-                        Criteria.where("firstProperty.id").is(Long.parseLong(searchCondition.getFirstPropertyId()))));
+                query.addCriteria(Criteria.where("quesProperties").elemMatch(Criteria.where("firstProperty.id").is(searchCondition.getFirstPropertyId())));
             }
         }
 
@@ -272,24 +277,31 @@ public class QuesServiceImpl implements QuesService {
         if (StringUtils.isEmpty(searchCondition.getCourseNo())) {
             searchCondition.setCourseNo(null);
         }
+
         if (StringUtils.isEmpty(searchCondition.getCourseLevel())) {
             searchCondition.setCourseLevel(null);
         }
+
         if (StringUtils.isEmpty(searchCondition.getCourseMajor())) {
             searchCondition.setCourseMajor(null);
         }
+
         if (StringUtils.isEmpty(String.valueOf(searchCondition.getPublicity()))) {
             searchCondition.setPublicity(null);
         }
+
         if (StringUtils.isEmpty(searchCondition.getCoursePropertyName())) {
             searchCondition.setCoursePropertyName(null);
         }
+
         if (StringUtils.isEmpty(searchCondition.getFirstPropertyId())) {
             searchCondition.setFirstPropertyId(null);
         }
+
         if (StringUtils.isEmpty(searchCondition.getSecondPropertyId())) {
             searchCondition.setSecondPropertyId(null);
         }
+
         if (StringUtils.isEmpty(searchCondition.getDifficulty())) {
             searchCondition.setDifficulty(null);
         }
@@ -594,34 +606,38 @@ public class QuesServiceImpl implements QuesService {
     @Override
     public long findQuesCount(QuestionSearchCondition searchCondition) {
         formatQuesCondition(searchCondition);
+
         Query query = new Query();
         query.addCriteria(Criteria.where("orgId").is(searchCondition.getOrgId()));
         query.addCriteria(Criteria.where("course.enable").is("true"));
+
         if (StringUtils.isNotBlank(searchCondition.getCourseNo())) {
             query.addCriteria(Criteria.where("course.code").is(searchCondition.getCourseNo()));
         }
+
         if (searchCondition.getQuestionType() != null) {
             query.addCriteria(Criteria.where("questionType").is(searchCondition.getQuestionType()));
         }
+
         if (searchCondition.getPublicity() != null) {
             query.addCriteria(Criteria.where("publicity").is(searchCondition.getPublicity()));
         }
+
         if (searchCondition.getCoursePropertyName() != null) {
             query.addCriteria(Criteria.where("quesProperties.coursePropertyName").is(searchCondition.getCoursePropertyName()));
         }
+
         if (searchCondition.getDifficulty() != null) {
             query.addCriteria(Criteria.where("difficulty").is(searchCondition.getDifficulty()));
         }
 
         //二级属性不为空,那么一级属性也不为空
-        if (searchCondition.getSecondPropertyId() != null) {
+        if (StringUtils.isNotEmpty(searchCondition.getSecondPropertyId())) {
             query.addCriteria(Criteria.where("quesProperties").elemMatch(
-                    Criteria.where("firstProperty.id").is(Long.parseLong(searchCondition.getFirstPropertyId()))
-                            .and("secondProperty.id").is(Long.parseLong(searchCondition.getSecondPropertyId()))));
+                    Criteria.where("firstProperty.id").is(searchCondition.getFirstPropertyId()).and("secondProperty.id").is(searchCondition.getSecondPropertyId())));
         } else {
             if (searchCondition.getFirstPropertyId() != null) {
-                query.addCriteria(Criteria.where("quesProperties").elemMatch(
-                        Criteria.where("firstProperty.id").is(Long.parseLong(searchCondition.getFirstPropertyId()))));
+                query.addCriteria(Criteria.where("quesProperties").elemMatch(Criteria.where("firstProperty.id").is(searchCondition.getFirstPropertyId())));
             }
         }
 
@@ -630,14 +646,17 @@ public class QuesServiceImpl implements QuesService {
         if (questionList == null || questionList.size() < 1) {
             return count;
         }
+
         List<String> oIds = new ArrayList<>();
         for (Question unit : questionList) {
             oIds.add(unit.getId());
         }
+
         List<ObjectId> objectIds = new ArrayList<>();
         for (String id : oIds) {
             objectIds.add(new ObjectId(id));
         }
+
         Query query2 = new Query();
         query2.addCriteria(Criteria.where("question.$id").in(objectIds));
         query2.addCriteria(Criteria.where("paperType").is(PaperType.IMPORT));
@@ -649,6 +668,7 @@ public class QuesServiceImpl implements QuesService {
                 count++;
             }
         }
+
         return count;
     }
 

+ 0 - 3
examcloud-core-questions-starter/src/main/java/cn/com/qmth/examcloud/core/questions/starter/QuestionPoolApplication.java

@@ -3,7 +3,6 @@ package cn.com.qmth.examcloud.core.questions.starter;
 import cn.com.qmth.examcloud.web.bootstrap.AppBootstrap;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.domain.EntityScan;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
 import org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@@ -11,8 +10,6 @@ import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
 import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
-import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
-import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
 import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
 import org.springframework.web.multipart.MultipartResolver;
 import org.springframework.web.multipart.commons.CommonsMultipartResolver;