Ejemplo n.º 1
0
 // @CacheEvict(value="SpringSecurityCache",allEntries=true)
 public void deleteRelatedPrivilegeR2s(String roleId, Collection<String> r2Ids) {
   Role role = roleDao.findOne(roleId);
   Iterable<RoleR2Privilege> r2s = roleR2PrivilegeDao.findAll(r2Ids);
   for (RoleR2Privilege r2 : r2s) {
     // 确认检查传入的关联主键是否的确属于当前关联角色
     if (r2.getRole().equals(role)) {
       roleR2PrivilegeDao.delete(r2);
     }
   }
 }
Ejemplo n.º 2
0
 // @CacheEvict(value="SpringSecurityCache",allEntries=true)
 public void addUnRelatedPrivilegeR2s(String roleId, Collection<String> privilegeIds) {
   Role role = roleDao.findOne(roleId);
   Iterable<Privilege> privileges = privilegeDao.findAll(privilegeIds);
   for (Privilege privilege : privileges) {
     RoleR2Privilege r2 = new RoleR2Privilege();
     r2.setRole(role);
     r2.setPrivilege(privilege);
     roleR2PrivilegeDao.save(r2);
   }
 }
Ejemplo n.º 3
0
 @Transactional(readOnly = true)
 public Page<RoleR2Privilege> findRelatedRoleR2PrivilegesForRole(
     final String roleId, final GroupPropertyFilter groupFilter, Pageable pageable) {
   Specification<RoleR2Privilege> specification =
       new Specification<RoleR2Privilege>() {
         @Override
         public Predicate toPredicate(
             Root<RoleR2Privilege> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
           Predicate predicate = buildPredicatesFromFilters(groupFilter, root, query, builder);
           return builder.and(predicate, builder.equal(root.get("role").get("id"), roleId));
         }
       };
   return roleR2PrivilegeDao.findAll(specification, pageable);
 }