Search in sources :

Example 1 with QRoleMenu

use of com.github.liuweijw.business.admin.domain.QRoleMenu in project fw-cloud-framework by liuweijw.

the class MenuServiceImpl method findMenuPermissions.

@Override
@Cacheable(value = AdminCacheKey.PERMISSION_INFO, key = AdminCacheKey.PERMISSION_INFO_KEY_ROLECODE)
public Set<String> findMenuPermissions(String roleCode) {
    Set<String> permissions = new HashSet<>();
    // 查询Role
    Role role = roleRepository.findRoleByRoleCode(roleCode.trim());
    if (null == role)
        return permissions;
    // 查询菜单
    QRoleMenu qRoleMenu = QRoleMenu.roleMenu;
    QRoleMenuPermission qRoleMenuPermission = QRoleMenuPermission.roleMenuPermission;
    List<RoleMenuPermission> rList = this.queryFactory.select(qRoleMenuPermission).from(qRoleMenuPermission, qRoleMenu).where(qRoleMenu.roleId.eq(role.getRoleId())).where(qRoleMenuPermission.roleMenuId.eq(qRoleMenu.id)).fetch();
    if (null == rList || rList.size() == 0)
        return permissions;
    rList.stream().forEach(r -> {
        permissions.add(r.getPermission());
    });
    return permissions;
}
Also used : Role(com.github.liuweijw.business.admin.domain.Role) QRoleMenuPermission(com.github.liuweijw.business.admin.domain.QRoleMenuPermission) RoleMenuPermission(com.github.liuweijw.business.admin.domain.RoleMenuPermission) QRoleMenuPermission(com.github.liuweijw.business.admin.domain.QRoleMenuPermission) QRoleMenu(com.github.liuweijw.business.admin.domain.QRoleMenu) HashSet(java.util.HashSet) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 2 with QRoleMenu

use of com.github.liuweijw.business.admin.domain.QRoleMenu in project fw-cloud-framework by liuweijw.

the class MenuServiceImpl method findMenuByRoleId.

@Override
@Cacheable(key = "'menu_' + #roleId")
public List<Menu> findMenuByRoleId(Integer roleId) {
    if (null == roleId)
        return null;
    QRoleMenu qRoleMenu = QRoleMenu.roleMenu;
    QMenu qMenu = QMenu.menu;
    List<Menu> rList = this.queryFactory.select(qMenu).from(qRoleMenu, qMenu).where(qRoleMenu.roleId.eq(roleId)).where(qRoleMenu.menuId.eq(qMenu.menuId)).fetch();
    return rList;
}
Also used : QMenu(com.github.liuweijw.business.admin.domain.QMenu) AuthMenu(com.github.liuweijw.core.beans.system.AuthMenu) QMenu(com.github.liuweijw.business.admin.domain.QMenu) QRoleMenu(com.github.liuweijw.business.admin.domain.QRoleMenu) Menu(com.github.liuweijw.business.admin.domain.Menu) QRoleMenu(com.github.liuweijw.business.admin.domain.QRoleMenu) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 3 with QRoleMenu

use of com.github.liuweijw.business.admin.domain.QRoleMenu in project fw-cloud-framework by liuweijw.

the class PermissionServiceImpl method findMenuPermissionByRoleId.

@Override
@Cacheable(cacheNames = AdminCacheKey.PERMISSION_INFO, key = "'permission_' + #roleId")
public List<RoleMenuPermission> findMenuPermissionByRoleId(Integer roleId) {
    if (null == roleId)
        return null;
    // 查询菜单
    QRoleMenu qRoleMenu = QRoleMenu.roleMenu;
    QRoleMenuPermission qRoleMenuPermission = QRoleMenuPermission.roleMenuPermission;
    List<RoleMenuPermission> rList = this.queryFactory.select(qRoleMenuPermission).from(qRoleMenuPermission, qRoleMenu).where(qRoleMenu.roleId.eq(roleId)).where(qRoleMenuPermission.roleMenuId.eq(qRoleMenu.id)).fetch();
    return rList;
}
Also used : QRoleMenuPermission(com.github.liuweijw.business.admin.domain.QRoleMenuPermission) RoleMenuPermission(com.github.liuweijw.business.admin.domain.RoleMenuPermission) QRoleMenuPermission(com.github.liuweijw.business.admin.domain.QRoleMenuPermission) QRoleMenu(com.github.liuweijw.business.admin.domain.QRoleMenu) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 4 with QRoleMenu

use of com.github.liuweijw.business.admin.domain.QRoleMenu in project fw-cloud-framework by liuweijw.

the class PermissionServiceImpl method delRoleMenuPermission.

private boolean delRoleMenuPermission(Integer roleId) {
    QRoleMenu qRoleMenu = QRoleMenu.roleMenu;
    List<RoleMenu> roleMeunList = this.queryFactory.selectFrom(qRoleMenu).where(qRoleMenu.roleId.eq(roleId.intValue())).fetch();
    Set<Integer> roleMenuIdList = new HashSet<Integer>();
    roleMeunList.forEach(r -> {
        roleMenuIdList.add(r.getId());
        roleMenuRepository.delete(r.getId());
    });
    Integer[] roleMenuIdArray = new Integer[roleMenuIdList.size()];
    return this.delRoleMenuPermissionByRoleMenuId(roleMenuIdList.toArray(roleMenuIdArray));
}
Also used : QRoleMenu(com.github.liuweijw.business.admin.domain.QRoleMenu) RoleMenu(com.github.liuweijw.business.admin.domain.RoleMenu) QRoleMenu(com.github.liuweijw.business.admin.domain.QRoleMenu) HashSet(java.util.HashSet)

Aggregations

QRoleMenu (com.github.liuweijw.business.admin.domain.QRoleMenu)4 Cacheable (org.springframework.cache.annotation.Cacheable)3 QRoleMenuPermission (com.github.liuweijw.business.admin.domain.QRoleMenuPermission)2 RoleMenuPermission (com.github.liuweijw.business.admin.domain.RoleMenuPermission)2 HashSet (java.util.HashSet)2 Menu (com.github.liuweijw.business.admin.domain.Menu)1 QMenu (com.github.liuweijw.business.admin.domain.QMenu)1 Role (com.github.liuweijw.business.admin.domain.Role)1 RoleMenu (com.github.liuweijw.business.admin.domain.RoleMenu)1 AuthMenu (com.github.liuweijw.core.beans.system.AuthMenu)1