Files
yunzerwebsiteallinone/go/docs/sql/create_approval_binding.sql
T
2026-10-07 22:56:35 +08:00

30 lines
1.7 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- =============================================================
-- 审批流功能绑定(biz_type ↔ flow 多对多关联)
--
-- 对应模型:go/models/approval.go ApprovalBinding
-- 用途:给某个功能(biz_type)绑定"可选审批流"清单,业务代码通过
-- ListAvailableFlows(scope, tid, bizType, userOrgID) 拿到过滤后的
-- 可用流;若一条流程设置了 apply_dept_ids,则仅该部门成员可见。
--
-- 注意:本表**不含条件表达式 / 优先级**——条件分支在流程内部(条件网关)
-- 实现,与绑定层无关。
-- =============================================================
SET NAMES utf8mb4;
CREATE TABLE IF NOT EXISTS `yz_approval_binding` (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`scope` TINYINT NOT NULL DEFAULT 1 COMMENT '1租户 2平台',
`tid` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '租户ID(平台侧为0)',
`biz_type` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '功能/单据类型:reimburse/bid/domain',
`flow_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '绑定的审批流ID',
`flow_code` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '审批流编号(冗余,方便查询)',
`remark` VARCHAR(200) NOT NULL DEFAULT '' COMMENT '备注',
`is_deleted` TINYINT NOT NULL DEFAULT 0,
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_scope_tid_biz_flow` (`scope`,`tid`,`biz_type`,`flow_id`),
KEY `idx_flow` (`flow_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='审批流功能绑定(biz_type↔flow 多对多)';