Search in sources :

Example 1 with RoleAssignVo

use of com.artlongs.sys.model.RoleAssignVo in project act-eagle-allone by mailtous.

the class SysPermissionService method savePermissionOfAssign.

public R savePermissionOfAssign(List<RoleAssignVo> roleAssignVoList) {
    if (C.empty(roleAssignVoList))
        return R.fail("权限分配没有指定角色。");
    for (RoleAssignVo roleAssignVo : roleAssignVoList) {
        SysPermission sysPermissionOfDB = getPermissionOf(roleAssignVo.getFuncId(), roleAssignVo.getRoleId());
        if (RoleAssignVo.on == roleAssignVo.getOnoff()) {
            // 添加角色的权限
            if (null == sysPermissionOfDB) {
                SysPermission sysPermission = new SysPermission();
                sysPermission.setRoleId(new Long(roleAssignVo.getRoleId()));
                sysPermission.setFuncId(new Long(roleAssignVo.getFuncId()));
                sysPermission.setCreateDate(new Date());
                sysPermission.setModifyDate(new Date());
                sysPermissionDao.save(sysPermission);
            }
        }
        if (RoleAssignVo.off == roleAssignVo.getOnoff()) {
            // 删除角色的权限
            if (null != sysPermissionOfDB) {
                sysPermissionDao.delete(sysPermissionOfDB);
            }
        }
    }
    SysRoleService.clearRoleCache();
    return R.success("角色的权限设置成功。");
}
Also used : RoleAssignVo(com.artlongs.sys.model.RoleAssignVo) SysPermission(com.artlongs.sys.model.SysPermission) Date(java.util.Date)

Example 2 with RoleAssignVo

use of com.artlongs.sys.model.RoleAssignVo in project act-eagle-allone by mailtous.

the class SysUserService method assignRole.

public R assignRole(List<RoleAssignVo> roleAssignVoList, SysUser sysUser) {
    if (C.notEmpty(roleAssignVoList)) {
        Set<Integer> roleIds = C.newSet(sysUser.roleIdList());
        for (RoleAssignVo roleAssignVo : roleAssignVoList) {
            if (RoleAssignVo.on == roleAssignVo.getOnoff()) {
                roleIds.add(roleAssignVo.getRoleId());
            } else {
                roleIds.remove(roleAssignVo.getRoleId());
            }
        }
        sysUser.setRoleIds(JSON.toJSONString(roleIds));
    }
    int rows = updateAndTime(sysUser);
    return rows > 0 ? R.success("用户设置角色成功!") : R.fail("用户设置角色失败!");
}
Also used : RoleAssignVo(com.artlongs.sys.model.RoleAssignVo)

Aggregations

RoleAssignVo (com.artlongs.sys.model.RoleAssignVo)2 SysPermission (com.artlongs.sys.model.SysPermission)1 Date (java.util.Date)1