diff --git a/src/main/java/club/joylink/rtss/services/permission/AcPermissionService.java b/src/main/java/club/joylink/rtss/services/permission/AcPermissionService.java index 394baf2b2..4a1d43749 100644 --- a/src/main/java/club/joylink/rtss/services/permission/AcPermissionService.java +++ b/src/main/java/club/joylink/rtss/services/permission/AcPermissionService.java @@ -145,10 +145,16 @@ public class AcPermissionService { */ @Transactional(readOnly = true) public PageVO findByPage(FindPermissionBasicByPageReqVo req) { - PageVO page = new PageVO<>(); + //查询条件 + final boolean hasCondition = null != req.getName() || null != req.getDes(); + final boolean multiConditions = null != req.getName() && null != req.getDes(); + //多个条件与、一个条件默认按与处理 + final boolean makeAnd = hasCondition && (multiConditions && req.getLogicAnd() || !multiConditions); + //多个条件或 + final boolean makeOr = multiConditions && !req.getLogicAnd(); // PermissionExample permissionExample = new PermissionExample(); - if (null != req.getName() || null != req.getDes()) { + if (makeAnd) { PermissionExample.Criteria pc = permissionExample.createCriteria(); if (null != req.getName()) { if (req.getNameLike()) { @@ -165,7 +171,22 @@ public class AcPermissionService { } } } + if (makeOr) { + PermissionExample.Criteria nc = permissionExample.or(); + if (req.getNameLike()) { + nc.andNameLike(String.format("%%%s%%", req.getName())); + } else { + nc.andNameEqualTo(req.getName()); + } + PermissionExample.Criteria dc = permissionExample.or(); + if (req.getDesLike()) { + dc.andDesLike(String.format("%%%s%%", req.getDes())); + } else { + dc.andDesEqualTo(req.getDes()); + } + } // + PageVO page = new PageVO<>(); long sum = this.permissionDAO.countByExample(permissionExample); page.setTotal(sum); page.setPageNum(req.getPageNum()); @@ -188,7 +209,7 @@ public class AcPermissionService { } return page; } - + /////////////////////////////////////////////////////////////////////////////////////////////////////// private List findAbilitiesByPermissionId(Long permissionId) { PermissionSystemAbilityExample psaExample = new PermissionSystemAbilityExample(); psaExample.createCriteria().andPermissionIdEqualTo(permissionId); diff --git a/src/main/java/club/joylink/rtss/vo/permission/FindPermissionBasicByPageReqVo.java b/src/main/java/club/joylink/rtss/vo/permission/FindPermissionBasicByPageReqVo.java index 5eff45c0a..6212401ad 100644 --- a/src/main/java/club/joylink/rtss/vo/permission/FindPermissionBasicByPageReqVo.java +++ b/src/main/java/club/joylink/rtss/vo/permission/FindPermissionBasicByPageReqVo.java @@ -29,6 +29,10 @@ public class FindPermissionBasicByPageReqVo extends PageQueryVO { * 按权限描述查询时,默认true,true-模糊查询,false-精确查询 */ private Boolean desLike = true; + /** + * 当查询条件有多个时,条件间关系:true-且,false-或;默认值为true + */ + private Boolean logicAnd = true; /** * 是否降序,true-降序,false-升序,默认值为true; */