warm-flow工作流,新增权限监听器,动态设置

来源: 投稿
作者: min290631660
2024-04-01 11:28:00

本文介绍warm-flow工作流,权限监听器,办理中动态设置流程权限 

git地址https://gitee.com/warm_4/warm-flow.git

1、实现一下接口

public interface Listener extends Serializable {

    /** 开始监听器,当前任务开始前执行 */
    String LISTENER_START = "start";

    /** 结束监听器,当前任务完成后执行 */
    String LISTENER_END = "finish";

    /** 分派办理人监听器,分派后执行 */
    String LISTENER_ASSIGNMENT = "assignment";

    /** 权限监听器,办理任务动态设置权限 */
    String LISTENER_PERMISSION = "permission";

    void notify(ListenerVariable variable);
}
public class FinishListener implements Listener {
    private static final Logger log = LoggerFactory.getLogger(StartListener.class);

    @Override
    public void notify(ListenerVariable variable) {
        log.info("完成监听器:{}", variable);
        Instance instance = variable.getInstance();
        Map<String, Object> testLeaveMap = variable.getVariable();
        log.info("完成监听器结束;{}", "任务完成");
    }
}

2、页面配置监听器,传递后台通过逗号分割不同监听器 监听器类型和监听器路径,上下一一对应 

3、参数传递

public class PermissionListener implements Listener {

    private static final Logger log = LoggerFactory.getLogger(PermissionListener.class);

    @Override
    public void notify(ListenerVariable variable) {
        log.info("权限监听器开始;{}", variable);
        Instance instance = variable.getInstance();
        List<NodePermission> nodePermissionList = new ArrayList<>();
        NodePermission nodePermission1 = new NodePermission();
        NodePermission nodePermission2 = new NodePermission();
        NodePermission nodePermission3 = new NodePermission();
        // 动态传入组件权限标识
        nodePermission1.setNodeCode("1");
        nodePermission1.setPermissionFlag("role:1,role:2,role:100");
        nodePermission2.setNodeCode("2");
        nodePermission2.setPermissionFlag("role:1,role:2,role:100");
        nodePermission3.setNodeCode("3");
        nodePermission3.setPermissionFlag("role:1,role:2,role:101");

        nodePermissionList.add(nodePermission1);
        nodePermissionList.add(nodePermission2);
        nodePermissionList.add(nodePermission3);
        variable.setNodePermissionList(nodePermissionList);
        Map<String, Object> variableMap = variable.getVariable();
        TestLeave testLeave = (TestLeave) variableMap.get("testLeave");
        log.info("权限监听器结束");
    }
}
展开阅读全文
点击引领话题📣 发布并加入讨论🔥
0 评论
5 收藏
分享
返回顶部
顶部