Search in sources :

Example 1 with UrlResource

use of com.ibeiliao.deployment.admin.vo.account.UrlResource in project Corgi by kevinYin.

the class AuthorizationServiceImpl method getUrlResourceSet.

/**
 * 返回所有的用户有权限的链接列表
 *
 * @param accountId
 * @param appId
 * @param regxSet
 *            使用了正则匹配的url
 * @return
 */
private Set<String> getUrlResourceSet(long accountId, int appId, Set<String> regxSet) {
    List<UrlResource> list = menuService.listMenuResourceByAccount(accountId, appId);
    Set<String> set = new HashSet<>(list.size() * 4 / 3);
    for (UrlResource urlResource : list) {
        set.add(urlResource.getUri());
        if (urlResource.getUri().indexOf("{") >= 0) {
            regxSet.add(urlResource.getUri());
        }
    }
    return set;
}
Also used : UrlResource(com.ibeiliao.deployment.admin.vo.account.UrlResource) HashSet(java.util.HashSet)

Example 2 with UrlResource

use of com.ibeiliao.deployment.admin.vo.account.UrlResource in project Corgi by kevinYin.

the class MenuServiceImpl method clearRedundantMenu.

@Override
@Transactional(propagation = Propagation.REQUIRED)
public void clearRedundantMenu(int appId, MenuItem root) {
    List<Menu> menus = listToBeDeletedMenu(appId, root);
    List<UrlResource> resources = listToBeDeletedResource(appId, root);
    for (Menu menu : menus) {
        logger.info("删除多余菜单." + "[menu=" + JsonUtil.toJSONString(menu) + "]");
        deleteMenu(menu);
    }
    for (UrlResource resource : resources) {
        int resId = resource.getResId();
        logger.info("删除多余菜单资源关系." + "[resId=" + resId + "]");
        menuResourcesRelationDao.deleteByResource(resId);
        logger.info("删除多余资源." + "[resId=" + resId + "]");
        urlResourceDao.deleteById(resId);
    }
}
Also used : UrlResource(com.ibeiliao.deployment.admin.vo.account.UrlResource) Menu(com.ibeiliao.deployment.admin.vo.account.Menu) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with UrlResource

use of com.ibeiliao.deployment.admin.vo.account.UrlResource in project Corgi by kevinYin.

the class MenuServiceImpl method listToBeDeletedResource.

/**
 * 获取待删除的资源
 *
 * @param appId
 * @param root
 * @return
 */
private List<UrlResource> listToBeDeletedResource(int appId, MenuItem root) {
    List<UrlResource> resources = new ArrayList<>();
    List<UrlResourcePO> urlResourcePOs = urlResourceDao.listByApp(appId);
    Map<String, Boolean> resourceMap = mapResources(appId, root);
    for (UrlResourcePO urlResourcePO : urlResourcePOs) {
        String key = urlResourcePO.getAppId() + "_" + urlResourcePO.getUri();
        if (!resourceMap.containsKey(key)) {
            UrlResource resource = VOUtil.from(urlResourcePO, UrlResource.class);
            resources.add(resource);
        }
    }
    return resources;
}
Also used : UrlResource(com.ibeiliao.deployment.admin.vo.account.UrlResource) UrlResourcePO(com.ibeiliao.deployment.admin.po.account.UrlResourcePO)

Aggregations

UrlResource (com.ibeiliao.deployment.admin.vo.account.UrlResource)3 UrlResourcePO (com.ibeiliao.deployment.admin.po.account.UrlResourcePO)1 Menu (com.ibeiliao.deployment.admin.vo.account.Menu)1 HashSet (java.util.HashSet)1 Transactional (org.springframework.transaction.annotation.Transactional)1