Ver código fonte

新功能调试

lideyin 5 anos atrás
pai
commit
91f964062d

+ 22 - 15
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/IllegallyTypeController.java

@@ -59,7 +59,7 @@ public class IllegallyTypeController extends ControllerSupport {
     @Autowired
     IllegallyTypeRepo illegallyTypeRepo;
 
-    private static final String[] EXCEL_HEADER = new String[]{"违纪类型名称", "违纪类型代码","排序号"};
+    private static final String[] EXCEL_HEADER = new String[]{"违纪类型名称", "违纪类型代码", "排序号"};
 
     /**
      * 方法注释
@@ -75,10 +75,10 @@ public class IllegallyTypeController extends ControllerSupport {
     @ApiOperation(value = "分页查询违纪类型")
     @GetMapping("illegallyTypePage/{curPage}/{pageSize}")
     public PageInfo<IllegallyTypeDomain> illegallyTypePage(@PathVariable Integer curPage,
-                                                      @PathVariable Integer pageSize,
-                                                       @RequestParam(required = false) String name,
-                                                      @RequestParam(required = false) String code,
-                                                      @RequestParam(required = false) Boolean enable) {
+                                                           @PathVariable Integer pageSize,
+                                                           @RequestParam(required = false) String name,
+                                                           @RequestParam(required = false) String code,
+                                                           @RequestParam(required = false) Boolean enable) {
         User accessUser = getAccessUser();
 
         Specification<IllegallyTypeEntity> specification = (root, query, cb) -> {
@@ -119,12 +119,12 @@ public class IllegallyTypeController extends ControllerSupport {
             domain.setName(entity.getName());
             domain.setEnable(entity.getEnable());
             domain.setSortNo(entity.getSortNo());
-            domain.setDataCategory(entity.getDataCategory()==null? DataCategory.CUSTOM.name() :entity.getDataCategory().name());
+            domain.setDataCategory(entity.getDataCategory() == null ? DataCategory.CUSTOM.name() : entity.getDataCategory().name());
             domain.setUpdateTime(entity.getUpdateTime());
             domainList.add(domain);
         }
 
-        PageInfo<IllegallyTypeDomain> pageInfo=new PageInfo<>();
+        PageInfo<IllegallyTypeDomain> pageInfo = new PageInfo<>();
         pageInfo.setList(domainList);
         pageInfo.setTotal(page.getTotalElements());
 
@@ -132,11 +132,10 @@ public class IllegallyTypeController extends ControllerSupport {
     }
 
     @ApiOperation(value = "查询违纪类型")
-    @GetMapping("query")
+    @GetMapping("queryByNameLike")
     public List<IllegallyTypeEntity> query(@RequestParam(required = false) String name,
                                            @RequestParam(required = false) String code,
-                                           @RequestParam(required = false) Boolean enable,
-                                           @RequestParam(required = false) Long courseId) {
+                                           @RequestParam(required = false) Boolean enable) {
 
         User accessUser = getAccessUser();
         Long rootOrgId = accessUser.getRootOrgId();
@@ -144,7 +143,11 @@ public class IllegallyTypeController extends ControllerSupport {
         Specification<IllegallyTypeEntity> specification = (root, query, cb) -> {
             List<Predicate> predicates = new ArrayList<>();
 
-            predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
+            List<Long> rootOrgIdList = new ArrayList<>();
+            rootOrgIdList.add(rootOrgId);
+            rootOrgIdList.add(-1L);//系统级别的数据默认rootOrgId为-1
+
+            predicates.add(cb.in(root.get("rootOrgId").in(rootOrgIdList)));
 
             if (StringUtils.isNotBlank(name)) {
                 predicates.add(cb.like(root.get("name"), toSqlSearchPattern(name)));
@@ -166,8 +169,12 @@ public class IllegallyTypeController extends ControllerSupport {
             return list;
         }
 
+        List<Sort.Order> orderList=new ArrayList<>();
+        orderList.add(new Sort.Order(Direction.DESC,"dataCategory"));
+        orderList.add(new Sort.Order(Direction.ASC,"sortNo"));
+
         List<IllegallyTypeEntity> list = illegallyTypeRepo.findAll(specification,
-                new Sort(Direction.DESC, "updateTime"));
+                new Sort(orderList));
         return list;
     }
 
@@ -223,7 +230,7 @@ public class IllegallyTypeController extends ControllerSupport {
         info.setName(domain.getName());
         info.setEnable(domain.getEnable());
         info.setSortNo(domain.getSortNo());
-        info.setDataCategory(info.getDataCategory()==null? DataCategory.CUSTOM.name() :info.getDataCategory());
+        info.setDataCategory(info.getDataCategory() == null ? DataCategory.CUSTOM.name() : info.getDataCategory());
 
         IllegallyTypeEntity saved = illegallyTypeService.saveIllegallyType(info);
         return saved.getId();
@@ -253,7 +260,7 @@ public class IllegallyTypeController extends ControllerSupport {
         info.setName(domain.getName());
         info.setEnable(domain.getEnable());
         info.setSortNo(domain.getSortNo());
-        info.setDataCategory(info.getDataCategory()==null? DataCategory.CUSTOM.name() :info.getDataCategory());
+        info.setDataCategory(info.getDataCategory() == null ? DataCategory.CUSTOM.name() : info.getDataCategory());
 
         IllegallyTypeEntity saved = illegallyTypeService.saveIllegallyType(info);
         return saved.getId();
@@ -339,7 +346,7 @@ public class IllegallyTypeController extends ControllerSupport {
         List<Object[]> datas = Lists.newArrayList();
 
         for (IllegallyTypeEntity cur : list) {
-            datas.add(new Object[]{cur.getName(), cur.getCode(),cur.getSortNo()});
+            datas.add(new Object[]{cur.getName(), cur.getCode(), cur.getSortNo()});
         }
 
         String filePath = systemConfig.getTempDataDir() + File.separator