use of io.jpom.permission.NodeDataPermission in project Jpom by dromara.
the class PermissionInterceptor method checkNodeDataPermission.
/**
* 检查管理员权限
*
* @param userModel 用户
* @param response 响应
* @param handlerMethod 拦截到到方法
* @return true 有权限
*/
private boolean checkNodeDataPermission(UserModel userModel, HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod) {
NodeDataPermission nodeDataPermission = this.getNodeDataPermission(handlerMethod);
if (nodeDataPermission == null || userModel.isSuperSystemUser()) {
return true;
}
NodeModel node = (NodeModel) request.getAttribute("node");
if (node != null) {
String parameterName = nodeDataPermission.parameterName();
BaseNodeService<?> baseNodeService = SpringUtil.getBean(nodeDataPermission.cls());
String dataId = request.getParameter(parameterName);
if (StrUtil.isNotEmpty(dataId)) {
BaseNodeModel data = baseNodeService.getData(node.getId(), dataId);
if (data != null) {
boolean exists = userBindWorkspaceService.exists(userModel.getId(), data.getWorkspaceId());
if (!exists) {
this.errorMsg(response, "您没有对应到数据权限:-3");
return false;
}
}
}
}
return true;
}
Aggregations