|
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import com.daqing.financial.hrauth.dao.RolePermissionMapper; |
|
|
|
|
import com.daqing.financial.hrauth.service.RolePermissionService; |
|
|
|
|
import com.daqing.framework.domain.hrms.PermissionEntity; |
|
|
|
|
import com.daqing.framework.domain.hrms.response.RolePermissionResponse; |
|
|
|
|
import com.daqing.framework.utils.PageUtils; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
@ -19,6 +20,7 @@ public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper, |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<PermissionEntity> listWithTree() { |
|
|
|
|
System.out.println("this.list()=================="+this.list()); |
|
|
|
|
return getPermissionTreeList(this.list(), 0L); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -31,7 +33,7 @@ public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper, |
|
|
|
|
if (size <= 0) { |
|
|
|
|
size = 10; |
|
|
|
|
} |
|
|
|
|
IPage<PermissionEntity> systemLogVo = this.getBaseMapper().pageByCondition(new Page(page, size)); |
|
|
|
|
IPage<RolePermissionResponse> systemLogVo = this.getBaseMapper().pageByCondition(new Page(page, size)); |
|
|
|
|
|
|
|
|
|
return new PageUtils(systemLogVo); |
|
|
|
|
} |
|
|
|
@ -44,4 +46,19 @@ public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper, |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<RolePermissionResponse> listWithPermissionTree(Long roleId) { |
|
|
|
|
//根据角色id查询单个角色对应的所有权限
|
|
|
|
|
List<RolePermissionResponse>list = this.getBaseMapper().queryPermissionByRoleId(roleId); |
|
|
|
|
return getRolePermissionTreeList(list, 0L); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<RolePermissionResponse> getRolePermissionTreeList(List<RolePermissionResponse> list, Long parentId) { |
|
|
|
|
return list.stream() |
|
|
|
|
.filter(item -> parentId.equals(item.getParentId())) |
|
|
|
|
.peek(item -> item.setChildren(getRolePermissionTreeList(list, item.getPermissionId()))) |
|
|
|
|
.sorted(Comparator.comparingInt(menu -> (menu.getSort() == null ? 0 : menu.getSort()))) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |