表结构:
` --审批流
create table approve_workflow
(
id bigserial primary key,
name varchar(255) not null,--工作流名称
node_ids bigserial[] not null --审批节点
);
--审批节点
create table approve_workflow_node
(
id bigserial primary key,
name varchar(255) not null, --节点名称
role_ids bigserial[] not null --角色
);
--审批角色
create table approve_workflow_role
(
id bigserial primary key,
name varchar(255) not null, --角色名称
domain_accounts varchar(255)[] not null --审批人列表
); `
查询审批角色中包含某个账户的 审批流ID
select distinct(workflow.id) as workflow_id from approve_workflow as workflow cross join unnest(workflow.node_ids) as workflow_node_id left join approve_workflow_node as node on node.id = workflow_node_id cross join unnest(node.role_ids) as node_role_id left join approve_workflow_role as role on role.id = node_role_id where 'zhoushu4801' = any (array [role.domain_accounts])