use of org.springframework.web.bind.annotation.RequestMethod in project disconf by knightliao.
the class RoleResourceMgrImpl method checkUserPermission.
/**
* @param pattern
* @param method
*
* @return
*/
@Override
public boolean checkUserPermission(String pattern, RequestMethod method) {
// 获取用户角色
Visitor visitor = ThreadContext.getSessionVisitor();
if (visitor == null) {
return false;
}
String urlPattarn = pattern;
if (!urlPattarn.endsWith(RoleResourceConstant.URL_SPLITOR)) {
urlPattarn += RoleResourceConstant.URL_SPLITOR;
}
Integer roleId = visitor.getRoleId();
Map<String, Map<RequestMethod, List<Integer>>> roleResMap = getAllAsMap();
Map<RequestMethod, List<Integer>> methodMap = roleResMap.get(urlPattarn);
if (methodMap == null) {
return false;
}
List<Integer> roleIdList = methodMap.get(method);
if (roleIdList == null) {
return false;
}
if (!roleIdList.contains(roleId)) {
return false;
}
return true;
}
Aggregations