查询权限列表增加排序功能
This commit is contained in:
+5
-5
@@ -14,15 +14,15 @@ import java.util.List;
|
||||
public interface SysAuthorityRepository extends JpaRepository<SysAuthority, String> {
|
||||
SysAuthority getByCode(String code);
|
||||
|
||||
List<SysAuthority> getByEnable(String enable);
|
||||
List<SysAuthority> getByEnableOrderBySort(String enable);
|
||||
|
||||
List<SysAuthority> getByParentIdAndEnable(String parentId, String enable);
|
||||
List<SysAuthority> getByParentIdAndEnableOrderBySort(String parentId, String enable);
|
||||
|
||||
List<SysAuthority> getByParentId(String parentId);
|
||||
List<SysAuthority> getByParentIdOrderBySort(String parentId);
|
||||
|
||||
List<SysAuthority> getByEnableAndIdIn(String enable, List<String> ids);
|
||||
List<SysAuthority> getByEnableAndIdInOrderBySort(String enable, List<String> ids);
|
||||
|
||||
List<SysAuthority> getByIdIn(List<String> ids);
|
||||
List<SysAuthority> getByIdInOrderBySort(List<String> ids);
|
||||
|
||||
SysAuthority getBySort(int sort);
|
||||
}
|
||||
|
||||
@@ -145,9 +145,9 @@ public class SysAuthorityService {
|
||||
*/
|
||||
public List<SysAuthority> listByEnable(String enable) {
|
||||
if (StringUtils.isNotEmpty(enable))
|
||||
return sysAuthorityRepository.getByEnable(enable);
|
||||
return sysAuthorityRepository.getByEnableOrderBySort(enable);
|
||||
else
|
||||
return sysAuthorityRepository.findAll();
|
||||
return sysAuthorityRepository.findAll(new Sort(Sort.Direction.ASC, "sort"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,12 +158,10 @@ public class SysAuthorityService {
|
||||
* @return
|
||||
*/
|
||||
public List<SysAuthority> listByParentEnable(String parentId, String enable) {
|
||||
if (StringUtils.isEmpty(parentId))
|
||||
parentId = CommonConstant.ROOT;
|
||||
if (StringUtils.isNotEmpty(enable))
|
||||
return sysAuthorityRepository.getByParentIdAndEnable(parentId, enable);
|
||||
return sysAuthorityRepository.getByParentIdAndEnableOrderBySort(parentId, enable);
|
||||
else
|
||||
return sysAuthorityRepository.getByParentId(parentId);
|
||||
return sysAuthorityRepository.getByParentIdOrderBySort(parentId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,9 +179,9 @@ public class SysAuthorityService {
|
||||
List<String> authorityIds = roleAuthorities.stream().map(SysRoleAuthority::getAuthorityId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(authorityIds))
|
||||
if (StringUtils.isNotEmpty(enable))
|
||||
list = sysAuthorityRepository.getByEnableAndIdIn(enable, authorityIds);
|
||||
list = sysAuthorityRepository.getByEnableAndIdInOrderBySort(enable, authorityIds);
|
||||
else
|
||||
list = sysAuthorityRepository.getByIdIn(authorityIds);
|
||||
list = sysAuthorityRepository.getByIdInOrderBySort(authorityIds);
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -214,9 +212,9 @@ public class SysAuthorityService {
|
||||
List<SysAuthVo> list = new ArrayList<>();
|
||||
List<SysAuthority> authoritys;
|
||||
if (StringUtils.isNotEmpty(enable))
|
||||
authoritys = sysAuthorityRepository.getByParentIdAndEnable(parentId, enable);
|
||||
authoritys = sysAuthorityRepository.getByParentIdAndEnableOrderBySort(parentId, enable);
|
||||
else
|
||||
authoritys = sysAuthorityRepository.getByParentId(parentId);
|
||||
authoritys = sysAuthorityRepository.getByParentIdOrderBySort(parentId);
|
||||
if (CollectionUtils.isEmpty(authoritys))
|
||||
return list;
|
||||
SysAuthVo vo;
|
||||
|
||||
@@ -101,6 +101,8 @@ public class SysAuthorityControl {
|
||||
@ApiOperation(value = "根据父节点查询子节点")
|
||||
@ApiImplicitParam(name = "parentId", value = "父id,可为空", paramType = "query", dataType = "string")
|
||||
public JSONObject listByParentId(String parentId) {
|
||||
if(StringUtils.isEmpty(parentId))
|
||||
parentId=CommonConstant.ROOT;
|
||||
if (!CommonConstant.ROOT.equals(parentId) && sysAuthorityService.getById(parentId) == null)
|
||||
return JSONObjResult.toJSONObj("父节点不存在");
|
||||
List<SysAuthority> queryByParentId = sysAuthorityService.listByParentEnable(parentId, null);
|
||||
|
||||
Reference in New Issue
Block a user