Search in sources :

Example 1 with RoleResource

use of com.baidu.disconf.web.service.roleres.bo.RoleResource in project disconf by knightliao.

the class RoleResourceMgrImpl method getAllAsMap.

/**
 * @return
 */
@Override
@Cacheable(value = "${role_res_cache_name}")
public Map<String, Map<RequestMethod, List<Integer>>> getAllAsMap() {
    Map<String, Map<RequestMethod, List<Integer>>> infoMap = new HashMap<String, Map<RequestMethod, List<Integer>>>();
    LOG.info("Querying role_resource table to get all...");
    List<RoleResource> roleResList = roleResDao.findAll();
    // 遍历列表,把数据按<url, <method, List<roleId>>>的形式加到infoMap
    for (RoleResource roleRes : roleResList) {
        String urlPattern = roleRes.getUrlPattern();
        if (!urlPattern.endsWith(RoleResourceConstant.URL_SPLITOR)) {
            urlPattern += RoleResourceConstant.URL_SPLITOR;
        }
        // LOG.info(urlPattern);
        Map<RequestMethod, List<Integer>> value = infoMap.get(urlPattern);
        if (value == null) {
            value = new HashMap<RequestMethod, List<Integer>>();
            infoMap.put(urlPattern, value);
        }
        updateMethodMap(value, roleRes.getRoleId(), roleRes.getMethodMask());
    }
    return infoMap;
}
Also used : HashMap(java.util.HashMap) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) RoleResource(com.baidu.disconf.web.service.roleres.bo.RoleResource) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) Cacheable(org.springframework.cache.annotation.Cacheable)

Aggregations

RoleResource (com.baidu.disconf.web.service.roleres.bo.RoleResource)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Cacheable (org.springframework.cache.annotation.Cacheable)1 RequestMethod (org.springframework.web.bind.annotation.RequestMethod)1