Package com.sishuok.es.sys.permission.entity

Examples of com.sishuok.es.sys.permission.entity.Role


        Permission permission2 = new Permission();
        permission2.setName("123");
        permission2.setPermission("abc");
        permissionService.save(permission2);

        Role role = new Role();
        role.setName("abc");
        role.setRole("abc");
        role.addResourcePermission(
                new RoleResourcePermission(
                        resource1.getId(),
                        Sets.newHashSet(permission1.getId(), permission2.getId())));

        role.addResourcePermission(
                new RoleResourcePermission(
                        resource2.getId(),
                        Sets.newHashSet(permission1.getId(), permission2.getId())));


        roleService.save(role);
        clear();
        Role dbRole = roleService.findOne(role.getId());

        Assert.assertEquals(2, dbRole.getResourcePermissions().size());
        Assert.assertEquals(2, dbRole.getResourcePermissions().get(0).getPermissionIds().size());


        resourceService.delete(resource1);
        permissionService.delete(permission1);
        clear();
View Full Code Here


        Permission permission2 = new Permission();
        permission2.setName("123");
        permission2.setPermission("abc");
        permissionService.save(permission2);

        Role role = new Role();
        role.setName("abc");
        role.setRole("abc");
        role.addResourcePermission(
                new RoleResourcePermission(
                        resource1.getId(),
                        Sets.newHashSet(permission1.getId(), permission2.getId())));


        roleService.save(role);
        clear();
        Role dbRole = roleService.findOne(role.getId());

        Assert.assertEquals(1, dbRole.getResourcePermissions().size());
        Assert.assertEquals(2, dbRole.getResourcePermissions().get(0).getPermissionIds().size());

    }
View Full Code Here

        Permission permission2 = new Permission();
        permission2.setName("123");
        permission2.setPermission("abc");
        permissionService.save(permission2);

        Role role = new Role();
        role.setName("abc");
        role.setRole("abc");

        roleService.save(role);

        role.addResourcePermission(
                new RoleResourcePermission(
                        resource1.getId(),
                        Sets.newHashSet(permission1.getId(), permission2.getId())));

        clear();

        Role dbRole = roleService.findOne(role.getId());

        Assert.assertEquals(1, dbRole.getResourcePermissions().size());

        RoleResourcePermission roleResourcePermission = dbRole.getResourcePermissions().get(0);
        roleResourcePermission.getPermissionIds().remove(roleResourcePermission.getPermissionIds().iterator().next());
        //此处必须复制一份
        clear();

        dbRole = roleService.findOne(role.getId());

        Assert.assertEquals(1, dbRole.getResourcePermissions().get(0).getPermissionIds().size());

    }
View Full Code Here

    ) {

        this.permissionList.assertHasUpdatePermission();

        for (Long id : ids) {
            Role role = baseService.findOne(id);
            role.setShow(newStatus);
            baseService.update(role);
        }

        redirectAttributes.addFlashAttribute(Constants.MESSAGE, "操作成功!");
View Full Code Here

     * @param id
     * @param onlyDisplayShow 是否仅显示可见的
     * @return
     */
    public static boolean existsRole(Long id, Boolean onlyDisplayShow) {
        Role role = SpringUtils.getBean(RoleService.class).findOne(id);
        if (role == null) {
            return false;
        }
        if (Boolean.TRUE.equals(onlyDisplayShow) && Boolean.FALSE.equals(role.getShow())) {
            return false;
        }
        return true;
    }
View Full Code Here

        }
    }

    @Before(value = "roleServicePointcut() && roleMaybeCacheEvictAllPointcut(arg)", argNames = "arg")
    public void roleMaybeCacheClearAllAdvice(Role arg) {
        Role role = arg;
        if (role == null) {
            return;
        }
        Role dbRole = roleService.findOne(role.getId());
        if (dbRole == null) {
            return;
        }

        //只有当show/role发生改变时才清理缓存
        if (!dbRole.getShow().equals(role.getShow())
                || !dbRole.getRole().equals(role.getRole())
                || !(dbRole.getResourcePermissions().size() == role.getResourcePermissions().size()
                && dbRole.getResourcePermissions().containsAll(role.getResourcePermissions()))) {

            log.debug("cacheName:{}, method:roleMaybeCacheClearAllAdvice, cache clear", cacheName);
            clear();
        }
    }
View Full Code Here

TOP

Related Classes of com.sishuok.es.sys.permission.entity.Role

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.