优化
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
-- 一期回归测试环境增量迁移汇总
|
||||
-- 适用版本:MySQL 8.0
|
||||
-- 涉及数据库:baiyue_iam、baiyue_warehouse、baiyue_order、baiyue_firstleg
|
||||
-- 涉及数据库:baiyue_iam、baiyue_warehouse、baiyue_order、baiyue_firstleg、baiyue_file
|
||||
-- 安全边界:不创建数据库、不清表、不删除业务数据、不写入演示租户及演示业务数据。
|
||||
-- 可重复执行:所有新增字段、表、索引和权限均带存在性判断或幂等写入。
|
||||
-- 重要说明:MySQL DDL 会隐式提交,本脚本不能作为一个跨库事务整体回滚。
|
||||
@@ -100,7 +100,8 @@ VALUES
|
||||
(5102010, 0, 'PLATFORM', 'MENU', 5102000, 'platform:order:list', '订单列表', '/first-leg-orders/list', NULL, 10, 'ACTIVE', 1, 0),
|
||||
(5102020, 0, 'PLATFORM', 'MENU', 5102000, 'platform:firstleg:task:list', '履约任务', '/first-leg-tasks/list', NULL, 20, 'ACTIVE', 1, 0),
|
||||
(5103020, 0, 'PLATFORM', 'MENU', 5103000, 'platform:express:list', '快递公司', '/master-data/express', NULL, 20, 'ACTIVE', 1, 0),
|
||||
(5103030, 0, 'PLATFORM', 'MENU', 5103000, 'platform:counterparty:list', '往来单位', '/master-data/counterparties', NULL, 30, 'ACTIVE', 1, 0)
|
||||
(5103030, 0, 'PLATFORM', 'MENU', 5103000, 'platform:counterparty:list', '往来单位', '/master-data/counterparties', NULL, 30, 'ACTIVE', 1, 0),
|
||||
(5103040, 0, 'PLATFORM', 'MENU', 5103000, 'platform:download:list', '下载中心', '/downloads', NULL, 40, 'ACTIVE', 1, 0)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
permission_type = VALUES(permission_type),
|
||||
parent_id = VALUES(parent_id),
|
||||
@@ -120,6 +121,7 @@ VALUES
|
||||
(5100014, 0, 'PLATFORM', 'BUTTON', 5100010, 'platform:customer:view', '查看企业客户档案', NULL, NULL, 15, 'ACTIVE', 1, 0),
|
||||
(5100012, 0, 'PLATFORM', 'BUTTON', 5100010, 'platform:customer:edit', '编辑企业客户', NULL, NULL, 20, 'ACTIVE', 1, 0),
|
||||
(5100013, 0, 'PLATFORM', 'BUTTON', 5100010, 'platform:customer:status', '启停企业客户', NULL, NULL, 30, 'ACTIVE', 1, 0),
|
||||
(5100015, 0, 'PLATFORM', 'BUTTON', 5100010, 'platform:customer:export', '导出企业客户', NULL, NULL, 40, 'ACTIVE', 1, 0),
|
||||
(5101011, 0, 'PLATFORM', 'BUTTON', 5101010, 'platform:user:create', '新增内部用户', NULL, NULL, 10, 'ACTIVE', 1, 0),
|
||||
(5101012, 0, 'PLATFORM', 'BUTTON', 5101010, 'platform:user:edit', '编辑内部用户', NULL, NULL, 20, 'ACTIVE', 1, 0),
|
||||
(5101013, 0, 'PLATFORM', 'BUTTON', 5101010, 'platform:user:status', '启停内部用户', NULL, NULL, 30, 'ACTIVE', 1, 0),
|
||||
@@ -146,7 +148,8 @@ VALUES
|
||||
(5103023, 0, 'PLATFORM', 'BUTTON', 5103020, 'platform:express:status', '启停快递公司', NULL, NULL, 30, 'ACTIVE', 1, 0),
|
||||
(5103031, 0, 'PLATFORM', 'BUTTON', 5103030, 'platform:counterparty:create', '新增往来单位', NULL, NULL, 10, 'ACTIVE', 1, 0),
|
||||
(5103032, 0, 'PLATFORM', 'BUTTON', 5103030, 'platform:counterparty:edit', '编辑往来单位', NULL, NULL, 20, 'ACTIVE', 1, 0),
|
||||
(5103033, 0, 'PLATFORM', 'BUTTON', 5103030, 'platform:counterparty:status', '启停往来单位', NULL, NULL, 30, 'ACTIVE', 1, 0)
|
||||
(5103033, 0, 'PLATFORM', 'BUTTON', 5103030, 'platform:counterparty:status', '启停往来单位', NULL, NULL, 30, 'ACTIVE', 1, 0),
|
||||
(5103041, 0, 'PLATFORM', 'BUTTON', 5103040, 'platform:download:all', '查看全部下载任务', NULL, NULL, 10, 'ACTIVE', 1, 0)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
permission_type = VALUES(permission_type),
|
||||
parent_id = VALUES(parent_id),
|
||||
@@ -203,7 +206,7 @@ SELECT r.id, p.id, 0
|
||||
AND r.deleted = 0
|
||||
AND p.permission_code IN (
|
||||
'platform:customer', 'platform:customer:list', 'platform:customer:create',
|
||||
'platform:customer:view', 'platform:customer:edit', 'platform:customer:status',
|
||||
'platform:customer:view', 'platform:customer:edit', 'platform:customer:status', 'platform:customer:export',
|
||||
'platform:system', 'platform:user:list', 'platform:user:create', 'platform:user:edit',
|
||||
'platform:user:status', 'platform:user:reset-password', 'platform:user:grant-role',
|
||||
'platform:role:list', 'platform:role:create', 'platform:role:grant',
|
||||
@@ -218,7 +221,8 @@ SELECT r.id, p.id, 0
|
||||
'platform:master-data', 'platform:express:list', 'platform:express:create',
|
||||
'platform:express:edit', 'platform:express:status',
|
||||
'platform:counterparty:list', 'platform:counterparty:create',
|
||||
'platform:counterparty:edit', 'platform:counterparty:status'
|
||||
'platform:counterparty:edit', 'platform:counterparty:status',
|
||||
'platform:download:list', 'platform:download:all'
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE tenant_id = VALUES(tenant_id);
|
||||
|
||||
@@ -237,6 +241,20 @@ SELECT DISTINCT existing_grant.role_id, view_permission.id, existing_grant.tenan
|
||||
AND existing_permission.permission_code IN ('platform:customer:list', 'platform:customer:review')
|
||||
ON DUPLICATE KEY UPDATE tenant_id = VALUES(tenant_id);
|
||||
|
||||
-- 已有客户列表或审核角色获得客户导出及本人下载任务查询,不继承查看全部任务权限。
|
||||
INSERT INTO iam_role_permission (role_id, permission_id, tenant_id)
|
||||
SELECT DISTINCT existing_grant.role_id, added_permission.id, existing_grant.tenant_id
|
||||
FROM iam_role_permission existing_grant
|
||||
JOIN iam_permission existing_permission ON existing_permission.id = existing_grant.permission_id
|
||||
JOIN iam_permission added_permission
|
||||
ON added_permission.tenant_id = 0
|
||||
AND added_permission.app_code = 'PLATFORM'
|
||||
AND added_permission.permission_code IN ('platform:customer:export', 'platform:download:list')
|
||||
WHERE existing_permission.tenant_id = 0
|
||||
AND existing_permission.app_code = 'PLATFORM'
|
||||
AND existing_permission.permission_code IN ('platform:customer:list', 'platform:customer:review')
|
||||
ON DUPLICATE KEY UPDATE tenant_id = VALUES(tenant_id);
|
||||
|
||||
-- 已存在的商户超级管理员/企业管理员获得对应租户的角色维护权限。
|
||||
INSERT INTO iam_role_permission (role_id, permission_id, tenant_id)
|
||||
SELECT r.id, p.id, r.tenant_id
|
||||
@@ -627,18 +645,59 @@ EXECUTE firstleg_task_list_index_stmt;
|
||||
DEALLOCATE PREPARE firstleg_task_list_index_stmt;
|
||||
|
||||
-- ============================================================================
|
||||
-- 5. 执行后只读核验
|
||||
-- 5. File:公共导出与下载中心任务表
|
||||
-- ============================================================================
|
||||
USE baiyue_file;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS file_export_task (
|
||||
id BIGINT UNSIGNED NOT NULL COMMENT '导出任务ID(雪花ID)',
|
||||
tenant_id BIGINT UNSIGNED NOT NULL COMMENT '申请人所属租户ID,平台任务为0',
|
||||
app_code VARCHAR(24) NOT NULL COMMENT '申请端',
|
||||
task_no VARCHAR(40) NOT NULL COMMENT '导出任务编号',
|
||||
export_type VARCHAR(64) NOT NULL COMMENT '导出类型',
|
||||
format VARCHAR(16) NOT NULL DEFAULT 'XLSX' COMMENT '导出格式',
|
||||
task_name VARCHAR(128) NOT NULL COMMENT '任务名称',
|
||||
parameters_json JSON NOT NULL COMMENT '筛选条件快照',
|
||||
status VARCHAR(24) NOT NULL DEFAULT 'PENDING' COMMENT '任务状态',
|
||||
total_rows BIGINT UNSIGNED NULL,
|
||||
processed_rows BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
file_name VARCHAR(255) NULL,
|
||||
object_key VARCHAR(512) NULL,
|
||||
content_type VARCHAR(128) NULL,
|
||||
size_bytes BIGINT UNSIGNED NULL,
|
||||
failure_message VARCHAR(1000) NULL,
|
||||
requested_by BIGINT UNSIGNED NOT NULL,
|
||||
requested_username VARCHAR(128) NULL,
|
||||
requested_at DATETIME(3) NOT NULL,
|
||||
started_at DATETIME(3) NULL,
|
||||
completed_at DATETIME(3) NULL,
|
||||
expires_at DATETIME(3) NULL,
|
||||
created_by BIGINT UNSIGNED NULL,
|
||||
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
updated_by BIGINT UNSIGNED NULL,
|
||||
updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
deleted TINYINT(1) NOT NULL DEFAULT 0,
|
||||
version INT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_file_export_task_no (task_no),
|
||||
KEY idx_file_export_owner (tenant_id, app_code, requested_by, requested_at),
|
||||
KEY idx_file_export_status (status, requested_at),
|
||||
KEY idx_file_export_expiry (status, expires_at)
|
||||
) ENGINE=InnoDB COMMENT='公共异步导出任务表';
|
||||
|
||||
-- ============================================================================
|
||||
-- 6. 执行后只读核验
|
||||
-- ============================================================================
|
||||
SELECT
|
||||
'IAM权限资源' AS check_item,
|
||||
COUNT(*) AS actual_count,
|
||||
44 AS expected_count,
|
||||
IF(COUNT(*) = 44, '通过', '请检查缺失权限') AS check_result
|
||||
47 AS expected_count,
|
||||
IF(COUNT(*) = 47, '通过', '请检查缺失权限') AS check_result
|
||||
FROM baiyue_iam.iam_permission
|
||||
WHERE deleted = 0
|
||||
AND permission_code IN (
|
||||
'platform:customer', 'platform:customer:list', 'platform:customer:create',
|
||||
'platform:customer:view', 'platform:customer:edit', 'platform:customer:status',
|
||||
'platform:customer:view', 'platform:customer:edit', 'platform:customer:status', 'platform:customer:export',
|
||||
'platform:system', 'platform:user:list', 'platform:user:create', 'platform:user:edit',
|
||||
'platform:user:status', 'platform:user:reset-password', 'platform:user:grant-role',
|
||||
'platform:role:list', 'platform:role:create', 'platform:role:grant',
|
||||
@@ -653,7 +712,8 @@ WHERE deleted = 0
|
||||
'platform:master-data', 'platform:express:list', 'platform:express:create',
|
||||
'platform:express:edit', 'platform:express:status',
|
||||
'platform:counterparty:list', 'platform:counterparty:create',
|
||||
'platform:counterparty:edit', 'platform:counterparty:status'
|
||||
'platform:counterparty:edit', 'platform:counterparty:status',
|
||||
'platform:download:list', 'platform:download:all'
|
||||
);
|
||||
|
||||
SELECT
|
||||
@@ -705,5 +765,12 @@ WHERE table_schema = 'baiyue_firstleg'
|
||||
AND table_name = 'fl_fulfillment_task'
|
||||
AND index_name = 'idx_task_tenant_created';
|
||||
|
||||
SELECT
|
||||
IF(COUNT(*) = 1, '通过', '缺失') AS export_task_table,
|
||||
'baiyue_file.file_export_task' AS object_name
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = 'baiyue_file'
|
||||
AND table_name = 'file_export_task';
|
||||
|
||||
SELECT 'MIGRATION_COMPLETED' AS migration_status,
|
||||
'请确认上方所有核验结果均为通过后再启动服务回归' AS message;
|
||||
|
||||
Reference in New Issue
Block a user