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;
}
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;
}
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;
}
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));
}
Aggregations