-- 权限码统一迁移 - V27
-- 添加前端和后端使用的简化格式权限码
-- 确保注解权限码100%可在DB权限表找到
-- 注意：只添加V26中不存在的简化权限码，避免主键和唯一约束冲突

-- 1. 仪表盘模块简化权限码 (只添加V26中不存在的)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 300, 'dashboard:simple:view', '查看仪表盘(简化)', 'dashboard', 'index', 'view', 'ALL', '查看仪表盘首页数据(简化)', 300, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'dashboard:simple:view')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 301, 'dashboard:simple:export', '导出仪表盘(简化)', 'dashboard', 'index', 'export', 'ALL', '导出仪表盘数据(简化)', 301, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'dashboard:simple:export')
ON CONFLICT (id) DO NOTHING;

-- 2. 活动管理模块简化权限码 (只添加V26中不存在的)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 302, 'activity:simple:view', '查看活动(简化)', 'activity', 'index', 'view', 'ALL', '查看活动列表和详情(简化)', 302, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'activity:simple:view')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 303, 'activity:simple:create', '创建活动(简化)', 'activity', 'index', 'create', 'ALL', '创建新活动(简化)', 303, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'activity:simple:create')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 304, 'activity:simple:update', '编辑活动(简化)', 'activity', 'index', 'edit', 'ALL', '编辑活动信息(简化)', 304, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'activity:simple:update')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 305, 'activity:simple:delete', '删除活动(简化)', 'activity', 'index', 'delete', 'ALL', '删除活动(简化)', 305, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'activity:simple:delete')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 306, 'activity:simple:publish', '发布活动(简化)', 'activity', 'index', 'publish', 'ALL', '发布活动(简化)', 306, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'activity:simple:publish')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 307, 'activity:simple:pause', '暂停活动(简化)', 'activity', 'index', 'pause', 'ALL', '暂停活动(简化)', 307, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'activity:simple:pause')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 308, 'activity:simple:resume', '恢复活动(简化)', 'activity', 'index', 'resume', 'ALL', '恢复活动(简化)', 308, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'activity:simple:resume')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 309, 'activity:simple:end', '结束活动(简化)', 'activity', 'index', 'end', 'ALL', '结束活动(简化)', 309, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'activity:simple:end')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 310, 'activity:simple:export', '导出活动(简化)', 'activity', 'index', 'export', 'ALL', '导出活动数据(简化)', 310, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'activity:simple:export')
ON CONFLICT (id) DO NOTHING;

-- 3. 用户管理模块简化权限码 (只添加V26中不存在的)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 311, 'user:simple:view', '查看用户(简化)', 'user', 'index', 'view', 'ALL', '查看用户列表和详情(简化)', 311, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'user:simple:view')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 312, 'user:simple:create', '创建用户(简化)', 'user', 'index', 'create', 'ALL', '创建新用户(简化)', 312, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'user:simple:create')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 313, 'user:simple:update', '编辑用户(简化)', 'user', 'index', 'edit', 'ALL', '编辑用户信息(简化)', 313, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'user:simple:update')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 314, 'user:simple:delete', '删除用户(简化)', 'user', 'index', 'delete', 'ALL', '删除用户(简化)', 314, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'user:simple:delete')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 315, 'user:simple:freeze', '冻结用户(简化)', 'user', 'index', 'freeze', 'ALL', '冻结用户账号(简化)', 315, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'user:simple:freeze')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 316, 'user:simple:unfreeze', '解冻用户(简化)', 'user', 'index', 'unfreeze', 'ALL', '解冻用户账号(简化)', 316, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'user:simple:unfreeze')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 317, 'user:simple:certify', '实名认证(简化)', 'user', 'index', 'certify', 'ALL', '用户实名认证(简化)', 317, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'user:simple:certify')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 318, 'user:simple:export', '导出用户(简化)', 'user', 'index', 'export', 'ALL', '导出用户数据(简化)', 318, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'user:simple:export')
ON CONFLICT (id) DO NOTHING;

-- 4. 奖励管理模块简化权限码 (只添加V26中不存在的)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 319, 'reward:simple:view', '查看奖励(简化)', 'reward', 'index', 'view', 'ALL', '查看奖励列表和详情(简化)', 319, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'reward:simple:view')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 320, 'reward:simple:approve', '审批奖励(简化)', 'reward', 'index', 'approve', 'ALL', '审批奖励申请(简化)', 320, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'reward:simple:approve')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 321, 'reward:simple:grant', '发放奖励(简化)', 'reward', 'index', 'grant', 'ALL', '手动发放奖励(简化)', 321, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'reward:simple:grant')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 322, 'reward:simple:reject', '拒绝奖励(简化)', 'reward', 'index', 'reject', 'ALL', '拒绝奖励申请(简化)', 322, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'reward:simple:reject')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 323, 'reward:simple:export', '导出奖励(简化)', 'reward', 'index', 'export', 'ALL', '导出奖励数据(简化)', 323, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'reward:simple:export')
ON CONFLICT (id) DO NOTHING;

-- 5. 风险管理模块简化权限码 (只添加V26中不存在的)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 324, 'risk:simple:view', '查看风控(简化)', 'risk', 'index', 'view', 'ALL', '查看风控信息(简化)', 324, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'risk:simple:view')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 325, 'risk:simple:rule', '管理风控规则(简化)', 'risk', 'rule', 'manage', 'ALL', '管理风控规则(简化)', 325, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'risk:simple:rule')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 326, 'risk:simple:audit', '审核风控(简化)', 'risk', 'index', 'audit', 'ALL', '审核风控事件(简化)', 326, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'risk:simple:audit')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 327, 'risk:simple:blacklist', '管理黑名单(简化)', 'risk', 'blacklist', 'manage', 'ALL', '管理黑名单(简化)', 327, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'risk:simple:blacklist')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 328, 'risk:simple:export', '导出风控(简化)', 'risk', 'index', 'export', 'ALL', '导出风控数据(简化)', 328, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'risk:simple:export')
ON CONFLICT (id) DO NOTHING;

-- 6. 审批中心模块简化权限码 (只添加V26中不存在的)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 329, 'approval:simple:view', '查看审批(简化)', 'approval', 'index', 'view', 'ALL', '查看审批列表(简化)', 329, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'approval:simple:view')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 330, 'approval:simple:handle', '处理审批(简化)', 'approval', 'index', 'handle', 'ALL', '处理审批申请(简化)', 330, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'approval:simple:handle')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 331, 'approval:simple:delegate', '委托审批(简化)', 'approval', 'index', 'delegate', 'ALL', '委托他人审批(简化)', 331, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'approval:simple:delegate')
ON CONFLICT (id) DO NOTHING;

-- 7. 审计日志模块简化权限码 (只添加V26中不存在的)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 332, 'audit:simple:view', '查看审计(简化)', 'audit', 'index', 'view', 'ALL', '查看审计日志(简化)', 332, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'audit:simple:view')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 333, 'audit:simple:export', '导出审计(简化)', 'audit', 'index', 'export', 'ALL', '导出审计日志(简化)', 333, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'audit:simple:export')
ON CONFLICT (id) DO NOTHING;

-- 8. 系统配置模块简化权限码 (只添加V26中不存在的)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 334, 'system:simple:view', '查看系统(简化)', 'system', 'index', 'view', 'ALL', '查看系统配置(简化)', 334, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'system:simple:view')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 335, 'system:simple:config', '系统配置(简化)', 'system', 'config', 'manage', 'ALL', '系统配置管理(简化)', 335, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'system:simple:config')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 336, 'system:simple:cache', '缓存管理(简化)', 'system', 'cache', 'manage', 'ALL', '缓存管理(简化)', 336, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'system:simple:cache')
ON CONFLICT (id) DO NOTHING;

-- 9. 权限管理模块简化权限码 (只添加V26中不存在的)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 337, 'permission:simple:view', '查看权限(简化)', 'permission', 'index', 'view', 'ALL', '查看权限列表(简化)', 337, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'permission:simple:view')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 338, 'permission:simple:manage', '权限管理(简化)', 'permission', 'index', 'manage', 'ALL', '管理权限(简化)', 338, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'permission:simple:manage')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 339, 'role:simple:view', '查看角色(简化)', 'role', 'index', 'view', 'ALL', '查看角色列表(简化)', 339, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'role:simple:view')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 340, 'role:simple:manage', '角色管理(简化)', 'role', 'index', 'manage', 'ALL', '管理角色(简化)', 340, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'role:simple:manage')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 341, 'dept:simple:view', '查看部门(简化)', 'department', 'index', 'view', 'ALL', '查看部门列表(简化)', 341, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'dept:simple:view')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 342, 'dept:simple:manage', '部门管理(简化)', 'department', 'index', 'manage', 'ALL', '管理部门(简化)', 342, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'dept:simple:manage')
ON CONFLICT (id) DO NOTHING;

-- 10. 通知管理模块简化权限码 (只添加V26中不存在的)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 343, 'notification:simple:view', '查看通知(简化)', 'notification', 'index', 'view', 'ALL', '查看通知列表(简化)', 343, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'notification:simple:view')
ON CONFLICT (id) DO NOTHING;

INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at)
SELECT 344, 'notification:simple:manage', '通知管理(简化)', 'notification', 'index', 'manage', 'ALL', '管理通知(简化)', 344, 'ENABLED', CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE permission_code = 'notification:simple:manage')
ON CONFLICT (id) DO NOTHING;

-- ==================== 角色权限映射 ====================
-- 为超级管理员添加简化权限码 (使用MERGE避免重复)
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 1, id FROM sys_permission WHERE permission_code LIKE '%:simple:%'
ON CONFLICT (role_id, permission_id) DO NOTHING;

-- 为系统管理员添加简化权限码
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 2, id FROM sys_permission WHERE permission_code LIKE '%:simple:%'
ON CONFLICT (role_id, permission_id) DO NOTHING;

-- 为运营总监添加简化权限码
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 3, id FROM sys_permission WHERE permission_code LIKE '%:simple:%'
ON CONFLICT (role_id, permission_id) DO NOTHING;

-- 为运营经理添加简化权限码
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 4, id FROM sys_permission WHERE permission_code LIKE '%:simple:%'
ON CONFLICT (role_id, permission_id) DO NOTHING;

-- 为运营专员添加简化权限码
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 10, id FROM sys_permission WHERE permission_code LIKE '%:simple:%'
ON CONFLICT (role_id, permission_id) DO NOTHING;

-- 为市场总监添加简化权限码
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 5, id FROM sys_permission WHERE permission_code LIKE '%:simple:%'
ON CONFLICT (role_id, permission_id) DO NOTHING;

-- 为市场经理添加简化权限码
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 6, id FROM sys_permission WHERE permission_code LIKE '%:simple:%'
ON CONFLICT (role_id, permission_id) DO NOTHING;

-- 为市场专员添加简化权限码
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 11, id FROM sys_permission WHERE permission_code LIKE '%:simple:%'
ON CONFLICT (role_id, permission_id) DO NOTHING;

-- 为财务经理添加简化权限码
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 7, id FROM sys_permission WHERE permission_code LIKE '%:simple:%'
ON CONFLICT (role_id, permission_id) DO NOTHING;

-- 为财务专员添加简化权限码
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 12, id FROM sys_permission WHERE permission_code LIKE '%:simple:%'
ON CONFLICT (role_id, permission_id) DO NOTHING;

-- 为风控经理添加简化权限码
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 8, id FROM sys_permission WHERE permission_code LIKE '%:simple:%'
ON CONFLICT (role_id, permission_id) DO NOTHING;

-- 为风控专员添加简化权限码
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 13, id FROM sys_permission WHERE permission_code LIKE '%:simple:%'
ON CONFLICT (role_id, permission_id) DO NOTHING;

-- 为客服主管添加简化权限码
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 9, id FROM sys_permission WHERE permission_code LIKE '%:simple:%'
ON CONFLICT (role_id, permission_id) DO NOTHING;

-- 为客服专员添加简化权限码
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 14, id FROM sys_permission WHERE permission_code LIKE '%:simple:%'
ON CONFLICT (role_id, permission_id) DO NOTHING;

-- 为审计员添加简化权限码
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 15, id FROM sys_permission WHERE permission_code LIKE '%:simple:%'
ON CONFLICT (role_id, permission_id) DO NOTHING;
