Search in sources :

Example 1 with SysPermission

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

the class SysPermissionDao method getPermissionOf.

public SysPermission getPermissionOf(Integer funcid, Integer roleid) {
    // String sql = " select * from sys_permission where func_id=? and role_id = ?";
    // SysPermission sysPermission = getObj(sql, funcId, roleId);
    String sql = new Qe(SysPermission.class).where(new Qe().eq(funcId, funcid).and(new Qe().eq(roleId, roleid))).build();
    SysPermission sysPermission = getObj(sql);
    return sysPermission;
}
Also used : Qe(com.artlongs.framework.utils.Qe) SysPermission(com.artlongs.sys.model.SysPermission)

Example 2 with SysPermission

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

the class SysPermissionDao method getPermissionListByRoleid.

public List<SysPermission> getPermissionListByRoleid(Long roleid) {
    // String sql = " select * from sys_permission where role_id = ?";
    String sql = new Qe(SysPermission.class).where(new Qe().eq(roleId, roleid)).build();
    List<SysPermission> permissionList = getList(sql);
    return permissionList;
}
Also used : Qe(com.artlongs.framework.utils.Qe) SysPermission(com.artlongs.sys.model.SysPermission)

Example 3 with SysPermission

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

the class SysMenuService method getMyAllFuncMap.

/**
 * 取得我的全部功能列表
 *
 * @param roleIds
 * @return
 */
private Map<Integer, List<SysFunc>> getMyAllFuncMap(Integer sysUserId) {
    if (null == funcMap.get(sysUserId)) {
        List<SysFunc> funcList = C.newList();
        List<Integer> roleIds = sysUserService.getMyRoleList(sysUserId);
        if (C.notEmpty(roleIds)) {
            permissionMap = getPermissionMap(roleIds);
            if (C.notEmpty(permissionMap)) {
                for (List<SysPermission> permissionList : permissionMap.values()) {
                    for (SysPermission sysPermission : permissionList) {
                        SysFunc func = sysFuncService.get(sysPermission.getFuncId());
                        if (null != func) {
                            funcList.add(func);
                        }
                    }
                }
            }
            // 按sequence从小到大排序
            Collections.sort(funcList, Comparator.comparing(SysFunc::getSequence));
            // add
            funcMap.put(sysUserId, funcList);
        }
    }
    return funcMap;
}
Also used : SysFunc(com.artlongs.sys.model.SysFunc) SysPermission(com.artlongs.sys.model.SysPermission)

Example 4 with SysPermission

use of com.artlongs.sys.model.SysPermission 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 5 with SysPermission

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

the class SysRoleService method realDel.

public R realDel(Long id) {
    SysRole sysRole = get(id);
    if (null == sysRole) {
        return R.fail("找不到对应的角色!");
    }
    List<SysPermission> permissionList = permissionService.getPermissionList(id);
    if (C.notEmpty(permissionList)) {
        return R.fail("角色已经分配了权限,不允许删除。");
    }
    return R.tf(sysRoleDao.realDel(id));
}
Also used : SysRole(com.artlongs.sys.model.SysRole) SysPermission(com.artlongs.sys.model.SysPermission)

Aggregations

SysPermission (com.artlongs.sys.model.SysPermission)5 Qe (com.artlongs.framework.utils.Qe)2 RoleAssignVo (com.artlongs.sys.model.RoleAssignVo)1 SysFunc (com.artlongs.sys.model.SysFunc)1 SysRole (com.artlongs.sys.model.SysRole)1 Date (java.util.Date)1