permission

This commit is contained in:
xzb 2022-10-14 14:25:02 +08:00
parent e577e255a9
commit d9828671c7
2 changed files with 28 additions and 3 deletions

View File

@ -145,10 +145,16 @@ public class AcPermissionService {
*/ */
@Transactional(readOnly = true) @Transactional(readOnly = true)
public PageVO<PermissionBasicRspVo> findByPage(FindPermissionBasicByPageReqVo req) { public PageVO<PermissionBasicRspVo> findByPage(FindPermissionBasicByPageReqVo req) {
PageVO<PermissionBasicRspVo> 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(); PermissionExample permissionExample = new PermissionExample();
if (null != req.getName() || null != req.getDes()) { if (makeAnd) {
PermissionExample.Criteria pc = permissionExample.createCriteria(); PermissionExample.Criteria pc = permissionExample.createCriteria();
if (null != req.getName()) { if (null != req.getName()) {
if (req.getNameLike()) { 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<PermissionBasicRspVo> page = new PageVO<>();
long sum = this.permissionDAO.countByExample(permissionExample); long sum = this.permissionDAO.countByExample(permissionExample);
page.setTotal(sum); page.setTotal(sum);
page.setPageNum(req.getPageNum()); page.setPageNum(req.getPageNum());
@ -188,7 +209,7 @@ public class AcPermissionService {
} }
return page; return page;
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////
private List<SystemAbility> findAbilitiesByPermissionId(Long permissionId) { private List<SystemAbility> findAbilitiesByPermissionId(Long permissionId) {
PermissionSystemAbilityExample psaExample = new PermissionSystemAbilityExample(); PermissionSystemAbilityExample psaExample = new PermissionSystemAbilityExample();
psaExample.createCriteria().andPermissionIdEqualTo(permissionId); psaExample.createCriteria().andPermissionIdEqualTo(permissionId);

View File

@ -29,6 +29,10 @@ public class FindPermissionBasicByPageReqVo extends PageQueryVO {
* 按权限描述查询时默认true,true-模糊查询false-精确查询 * 按权限描述查询时默认true,true-模糊查询false-精确查询
*/ */
private Boolean desLike = true; private Boolean desLike = true;
/**
* 当查询条件有多个时条件间关系true-false-默认值为true
*/
private Boolean logicAnd = true;
/** /**
* 是否降序true-降序false-升序默认值为true; * 是否降序true-降序false-升序默认值为true;
*/ */