Search in sources :

Example 1 with QRoleMenuPermission

use of com.github.liuweijw.business.admin.domain.QRoleMenuPermission 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 QRoleMenuPermission

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

the class PermissionServiceImpl method delRoleMenuPermissionByRoleMenuId.

private boolean delRoleMenuPermissionByRoleMenuId(Integer... roleMenuArray) {
    QRoleMenuPermission qRoleMenuPermission = QRoleMenuPermission.roleMenuPermission;
    long num = this.queryFactory.delete(qRoleMenuPermission).where(qRoleMenuPermission.roleMenuId.in(roleMenuArray)).execute();
    return num > 0;
}
Also used : QRoleMenuPermission(com.github.liuweijw.business.admin.domain.QRoleMenuPermission)

Example 3 with QRoleMenuPermission

use of com.github.liuweijw.business.admin.domain.QRoleMenuPermission 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)

Aggregations

QRoleMenuPermission (com.github.liuweijw.business.admin.domain.QRoleMenuPermission)3 QRoleMenu (com.github.liuweijw.business.admin.domain.QRoleMenu)2 RoleMenuPermission (com.github.liuweijw.business.admin.domain.RoleMenuPermission)2 Cacheable (org.springframework.cache.annotation.Cacheable)2 Role (com.github.liuweijw.business.admin.domain.Role)1 HashSet (java.util.HashSet)1