Search in sources :

Example 1 with NodeDataPermission

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;
}
Also used : BaseNodeModel(io.jpom.model.BaseNodeModel) NodeModel(io.jpom.model.data.NodeModel) BaseNodeModel(io.jpom.model.BaseNodeModel) NodeDataPermission(io.jpom.permission.NodeDataPermission)

Aggregations

BaseNodeModel (io.jpom.model.BaseNodeModel)1 NodeModel (io.jpom.model.data.NodeModel)1 NodeDataPermission (io.jpom.permission.NodeDataPermission)1