-- 角色权限Seed数据 (V26)
-- H2兼容版本
-- 根据管理后台PRD v1.0: 15角色 + 225权限点

-- ==================== 角色数据 ====================
-- 先插入角色数据 (15个角色)
INSERT INTO sys_role (id, role_code, role_name, role_level, data_scope, description, status, created_at, updated_at) VALUES
(1, 'super_admin', '超级管理员', 'SYSTEM', 'ALL', '系统最高权限，可管理所有功能和数据', 'ENABLED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(2, 'system_admin', '系统管理员', 'SYSTEM', 'ALL', '系统管理角色，负责系统配置', 'ENABLED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(3, 'operation_director', '运营总监', 'MANAGEMENT', 'DEPARTMENT', '运营部门最高负责人', 'ENABLED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(4, 'operation_manager', '运营经理', 'MANAGEMENT', 'DEPARTMENT', '运营部门负责人', 'ENABLED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(5, 'marketing_director', '市场总监', 'MANAGEMENT', 'DEPARTMENT', '市场部门最高负责人', 'ENABLED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(6, 'marketing_manager', '市场经理', 'MANAGEMENT', 'DEPARTMENT', '市场部门负责人', 'ENABLED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(7, 'finance_manager', '财务经理', 'MANAGEMENT', 'DEPARTMENT', '财务部门负责人', 'ENABLED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(8, 'risk_manager', '风控经理', 'MANAGEMENT', 'DEPARTMENT', '风控部门负责人', 'ENABLED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(9, 'cs_manager', '客服主管', 'MANAGEMENT', 'DEPARTMENT', '客服部门负责人', 'ENABLED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(10, 'operation_specialist', '运营专员', 'EXECUTION', 'OWN', '运营执行人员', 'ENABLED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(11, 'marketing_specialist', '市场专员', 'EXECUTION', 'OWN', '市场执行人员', 'ENABLED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(12, 'finance_specialist', '财务专员', 'EXECUTION', 'OWN', '财务执行人员', 'ENABLED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(13, 'risk_specialist', '风控专员', 'EXECUTION', 'OWN', '风控执行人员', 'ENABLED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(14, 'cs_agent', '客服专员', 'EXECUTION', 'OWN', '客服执行人员', 'ENABLED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
(15, 'auditor', '审计员', 'AUDIT', 'ALL', '负责系统审计工作', 'ENABLED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);

-- ==================== 权限数据 ====================
-- 权限数据 (225个权限点，按模块划分)

-- 1. 仪表盘模块 (15个权限)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at) VALUES
(1, 'dashboard:view', '查看仪表盘', 'dashboard', 'index', 'view', 'ALL', '查看仪表盘首页数据', 1, 'ENABLED', CURRENT_TIMESTAMP),
(2, 'dashboard:kpi:view', '查看KPI指标', 'dashboard', 'kpi', 'view', 'ALL', '查看关键绩效指标', 2, 'ENABLED', CURRENT_TIMESTAMP),
(3, 'dashboard:kpi:export', '导出KPI数据', 'dashboard', 'kpi', 'export', 'ALL', '导出KPI数据', 3, 'ENABLED', CURRENT_TIMESTAMP),
(4, 'dashboard:activity:view', '查看活动概览', 'dashboard', 'activity', 'view', 'ALL', '查看活动统计数据', 4, 'ENABLED', CURRENT_TIMESTAMP),
(5, 'dashboard:activity:export', '导出活动数据', 'dashboard', 'activity', 'export', 'ALL', '导出活动统计数据', 5, 'ENABLED', CURRENT_TIMESTAMP),
(6, 'dashboard:trend:view', '查看趋势图表', 'dashboard', 'trend', 'view', 'ALL', '查看数据趋势图表', 6, 'ENABLED', CURRENT_TIMESTAMP),
(7, 'dashboard:realtime:view', '查看实时数据', 'dashboard', 'realtime', 'view', 'ALL', '查看实时数据流', 7, 'ENABLED', CURRENT_TIMESTAMP),
(8, 'dashboard:alert:view', '查看告警信息', 'dashboard', 'alert', 'view', 'ALL', '查看系统告警', 8, 'ENABLED', CURRENT_TIMESTAMP),
(9, 'dashboard:alert:handle', '处理告警', 'dashboard', 'alert', 'handle', 'ALL', '处理系统告警', 9, 'ENABLED', CURRENT_TIMESTAMP),
(10, 'dashboard:todo:view', '查看待办事项', 'dashboard', 'todo', 'view', 'ALL', '查看待办任务', 10, 'ENABLED', CURRENT_TIMESTAMP),
(11, 'dashboard:todo:handle', '处理待办', 'dashboard', 'todo', 'handle', 'ALL', '处理待办任务', 11, 'ENABLED', CURRENT_TIMESTAMP),
(12, 'dashboard:pv:view', '查看PV数据', 'dashboard', 'pv', 'view', 'ALL', '查看页面访问量', 12, 'ENABLED', CURRENT_TIMESTAMP),
(13, 'dashboard:uv:view', '查看UV数据', 'dashboard', 'uv', 'view', 'ALL', '查看独立访客数', 13, 'ENABLED', CURRENT_TIMESTAMP),
(14, 'dashboard:kfactor:view', '查看K因子', 'dashboard', 'kfactor', 'view', 'ALL', '查看病毒传播系数', 14, 'ENABLED', CURRENT_TIMESTAMP),
(15, 'dashboard:cac:view', '查看CAC', 'dashboard', 'cac', 'view', 'ALL', '查看用户获取成本', 15, 'ENABLED', CURRENT_TIMESTAMP);

-- 2. 活动管理模块 (30个权限)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at) VALUES
(16, 'activity:list:view', '查看活动列表', 'activity', 'list', 'view', 'ALL', '查看活动列表', 16, 'ENABLED', CURRENT_TIMESTAMP),
(17, 'activity:create', '创建活动', 'activity', 'index', 'create', 'ALL', '创建新活动', 17, 'ENABLED', CURRENT_TIMESTAMP),
(18, 'activity:edit', '编辑活动', 'activity', 'index', 'edit', 'ALL', '编辑活动信息', 18, 'ENABLED', CURRENT_TIMESTAMP),
(19, 'activity:delete', '删除活动', 'activity', 'index', 'delete', 'ALL', '删除活动', 19, 'ENABLED', CURRENT_TIMESTAMP),
(20, 'activity:detail:view', '查看活动详情', 'activity', 'detail', 'view', 'ALL', '查看活动详细信息', 20, 'ENABLED', CURRENT_TIMESTAMP),
(21, 'activity:publish', '发布活动', 'activity', 'index', 'publish', 'ALL', '发布活动', 21, 'ENABLED', CURRENT_TIMESTAMP),
(22, 'activity:pause', '暂停活动', 'activity', 'index', 'pause', 'ALL', '暂停活动', 22, 'ENABLED', CURRENT_TIMESTAMP),
(23, 'activity:resume', '恢复活动', 'activity', 'index', 'resume', 'ALL', '恢复活动', 23, 'ENABLED', CURRENT_TIMESTAMP),
(24, 'activity:stats:view', '查看活动统计', 'activity', 'stats', 'view', 'ALL', '查看活动统计数据', 24, 'ENABLED', CURRENT_TIMESTAMP),
(25, 'activity:stats:export', '导出活动统计', 'activity', 'stats', 'export', 'ALL', '导出活动统计数据', 25, 'ENABLED', CURRENT_TIMESTAMP),
(26, 'activity:participant:view', '查看参与者', 'activity', 'participant', 'view', 'ALL', '查看活动参与者列表', 26, 'ENABLED', CURRENT_TIMESTAMP),
(27, 'activity:reward:view', '查看奖励配置', 'activity', 'reward', 'view', 'ALL', '查看活动奖励配置', 27, 'ENABLED', CURRENT_TIMESTAMP),
(28, 'activity:reward:edit', '编辑奖励配置', 'activity', 'reward', 'edit', 'ALL', '编辑活动奖励配置', 28, 'ENABLED', CURRENT_TIMESTAMP),
(29, 'activity:rule:view', '查看规则配置', 'activity', 'rule', 'view', 'ALL', '查看活动规则配置', 29, 'ENABLED', CURRENT_TIMESTAMP),
(30, 'activity:rule:edit', '编辑规则配置', 'activity', 'rule', 'edit', 'ALL', '编辑活动规则配置', 30, 'ENABLED', CURRENT_TIMESTAMP),
(31, 'activity:share:view', '查看分享设置', 'activity', 'share', 'view', 'ALL', '查看分享配置', 31, 'ENABLED', CURRENT_TIMESTAMP),
(32, 'activity:share:edit', '编辑分享设置', 'activity', 'share', 'edit', 'ALL', '编辑分享配置', 32, 'ENABLED', CURRENT_TIMESTAMP),
(33, 'activity:callback:view', '查看回调配置', 'activity', 'callback', 'view', 'ALL', '查看回调配置', 33, 'ENABLED', CURRENT_TIMESTAMP),
(34, 'activity:callback:edit', '编辑回调配置', 'activity', 'callback', 'edit', 'ALL', '编辑回调配置', 34, 'ENABLED', CURRENT_TIMESTAMP),
(35, 'activity:approval:submit', '提交活动审批', 'activity', 'approval', 'submit', 'ALL', '提交活动审批申请', 35, 'ENABLED', CURRENT_TIMESTAMP),
(36, 'activity:approval:cancel', '取消活动审批', 'activity', 'approval', 'cancel', 'ALL', '取消活动审批申请', 36, 'ENABLED', CURRENT_TIMESTAMP),
(37, 'activity:template:view', '查看活动模板', 'activity', 'template', 'view', 'ALL', '查看活动模板', 37, 'ENABLED', CURRENT_TIMESTAMP),
(38, 'activity:copy', '复制活动', 'activity', 'index', 'copy', 'ALL', '复制活动', 38, 'ENABLED', CURRENT_TIMESTAMP),
(39, 'activity:export', '导出活动', 'activity', 'index', 'export', 'ALL', '导出活动数据', 39, 'ENABLED', CURRENT_TIMESTAMP),
(40, 'activity:import', '导入活动', 'activity', 'index', 'import', 'ALL', '导入活动数据', 40, 'ENABLED', CURRENT_TIMESTAMP),
(41, 'activity:batch:publish', '批量发布活动', 'activity', 'index', 'batch_publish', 'ALL', '批量发布活动', 41, 'ENABLED', CURRENT_TIMESTAMP),
(42, 'activity:batch:delete', '批量删除活动', 'activity', 'index', 'batch_delete', 'ALL', '批量删除活动', 42, 'ENABLED', CURRENT_TIMESTAMP),
(43, 'activity:log:view', '查看活动日志', 'activity', 'log', 'view', 'ALL', '查看活动操作日志', 43, 'ENABLED', CURRENT_TIMESTAMP),
(44, 'activity:category:view', '查看活动分类', 'activity', 'category', 'view', 'ALL', '查看活动分类', 44, 'ENABLED', CURRENT_TIMESTAMP),
(45, 'activity:category:edit', '编辑活动分类', 'activity', 'category', 'edit', 'ALL', '编辑活动分类', 45, 'ENABLED', CURRENT_TIMESTAMP);

-- 3. 用户管理模块 (20个权限)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at) VALUES
(46, 'user:list:view', '查看用户列表', 'user', 'list', 'view', 'ALL', '查看用户列表', 46, 'ENABLED', CURRENT_TIMESTAMP),
(47, 'user:detail:view', '查看用户详情', 'user', 'detail', 'view', 'ALL', '查看用户详细信息', 47, 'ENABLED', CURRENT_TIMESTAMP),
(48, 'user:create', '创建用户', 'user', 'index', 'create', 'ALL', '创建新用户', 48, 'ENABLED', CURRENT_TIMESTAMP),
(49, 'user:edit', '编辑用户', 'user', 'index', 'edit', 'ALL', '编辑用户信息', 49, 'ENABLED', CURRENT_TIMESTAMP),
(50, 'user:delete', '删除用户', 'user', 'index', 'delete', 'ALL', '删除用户', 50, 'ENABLED', CURRENT_TIMESTAMP),
(51, 'user:freeze', '冻结用户', 'user', 'index', 'freeze', 'ALL', '冻结用户账号', 51, 'ENABLED', CURRENT_TIMESTAMP),
(52, 'user:unfreeze', '解冻用户', 'user', 'index', 'unfreeze', 'ALL', '解冻用户账号', 52, 'ENABLED', CURRENT_TIMESTAMP),
(53, 'user:reset:password', '重置密码', 'user', 'index', 'reset_password', 'ALL', '重置用户密码', 53, 'ENABLED', CURRENT_TIMESTAMP),
(54, 'user:export', '导出用户', 'user', 'index', 'export', 'ALL', '导出用户数据', 54, 'ENABLED', CURRENT_TIMESTAMP),
(55, 'user:import', '导入用户', 'user', 'index', 'import', 'ALL', '导入用户数据', 55, 'ENABLED', CURRENT_TIMESTAMP),
(56, 'user:invite:view', '查看邀请记录', 'user', 'invite', 'view', 'ALL', '查看用户邀请记录', 56, 'ENABLED', CURRENT_TIMESTAMP),
(57, 'user:invite:export', '导出邀请记录', 'user', 'invite', 'export', 'ALL', '导出邀请记录', 57, 'ENABLED', CURRENT_TIMESTAMP),
(58, 'user:reward:view', '查看用户奖励', 'user', 'reward', 'view', 'ALL', '查看用户奖励记录', 58, 'ENABLED', CURRENT_TIMESTAMP),
(59, 'user:reward:grant', '发放用户奖励', 'user', 'reward', 'grant', 'ALL', '手动发放用户奖励', 59, 'ENABLED', CURRENT_TIMESTAMP),
(60, 'user:role:assign', '分配用户角色', 'user', 'role', 'assign', 'ALL', '分配用户角色', 60, 'ENABLED', CURRENT_TIMESTAMP),
(61, 'user:department:assign', '分配用户部门', 'user', 'department', 'assign', 'ALL', '分配用户到部门', 61, 'ENABLED', CURRENT_TIMESTAMP),
(62, 'user:tag:manage', '管理用户标签', 'user', 'tag', 'manage', 'ALL', '管理用户标签', 62, 'ENABLED', CURRENT_TIMESTAMP),
(63, 'user:behavior:view', '查看用户行为', 'user', 'behavior', 'view', 'ALL', '查看用户行为数据', 63, 'ENABLED', CURRENT_TIMESTAMP),
(64, 'user:sensitive:view', '查看敏感信息', 'user', 'sensitive', 'view', 'ALL', '查看用户敏感信息', 64, 'ENABLED', CURRENT_TIMESTAMP),
(65, 'user:batch:freeze', '批量冻结用户', 'user', 'index', 'batch_freeze', 'ALL', '批量冻结用户', 65, 'ENABLED', CURRENT_TIMESTAMP);

-- 4. 奖励管理模块 (25个权限)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at) VALUES
(66, 'reward:list:view', '查看奖励列表', 'reward', 'list', 'view', 'ALL', '查看奖励列表', 66, 'ENABLED', CURRENT_TIMESTAMP),
(67, 'reward:detail:view', '查看奖励详情', 'reward', 'detail', 'view', 'ALL', '查看奖励详情', 67, 'ENABLED', CURRENT_TIMESTAMP),
(68, 'reward:create', '创建奖励', 'reward', 'index', 'create', 'ALL', '创建奖励规则', 68, 'ENABLED', CURRENT_TIMESTAMP),
(69, 'reward:edit', '编辑奖励', 'reward', 'index', 'edit', 'ALL', '编辑奖励规则', 69, 'ENABLED', CURRENT_TIMESTAMP),
(70, 'reward:delete', '删除奖励', 'reward', 'index', 'delete', 'ALL', '删除奖励规则', 70, 'ENABLED', CURRENT_TIMESTAMP),
(71, 'reward:grant', '发放奖励', 'reward', 'index', 'grant', 'ALL', '手动发放奖励', 71, 'ENABLED', CURRENT_TIMESTAMP),
(72, 'reward:batch:grant', '批量发放奖励', 'reward', 'index', 'batch_grant', 'ALL', '批量发放奖励', 72, 'ENABLED', CURRENT_TIMESTAMP),
(73, 'reward:approve', '审批奖励', 'reward', 'index', 'approve', 'ALL', '审批奖励申请', 73, 'ENABLED', CURRENT_TIMESTAMP),
(74, 'reward:reject', '拒绝奖励', 'reward', 'index', 'reject', 'ALL', '拒绝奖励申请', 74, 'ENABLED', CURRENT_TIMESTAMP),
(75, 'reward:export', '导出奖励', 'reward', 'index', 'export', 'ALL', '导出奖励数据', 75, 'ENABLED', CURRENT_TIMESTAMP),
(76, 'reward:stats:view', '查看奖励统计', 'reward', 'stats', 'view', 'ALL', '查看奖励统计数据', 76, 'ENABLED', CURRENT_TIMESTAMP),
(77, 'reward:rule:view', '查看奖励规则', 'reward', 'rule', 'view', 'ALL', '查看奖励规则配置', 77, 'ENABLED', CURRENT_TIMESTAMP),
(78, 'reward:rule:edit', '编辑奖励规则', 'reward', 'rule', 'edit', 'ALL', '编辑奖励规则配置', 78, 'ENABLED', CURRENT_TIMESTAMP),
(79, 'reward:ticket:view', '查看优惠券', 'reward', 'ticket', 'view', 'ALL', '查看优惠券列表', 79, 'ENABLED', CURRENT_TIMESTAMP),
(80, 'reward:ticket:create', '创建优惠券', 'reward', 'ticket', 'create', 'ALL', '创建优惠券', 80, 'ENABLED', CURRENT_TIMESTAMP),
(81, 'reward:ticket:edit', '编辑优惠券', 'reward', 'ticket', 'edit', 'ALL', '编辑优惠券', 81, 'ENABLED', CURRENT_TIMESTAMP),
(82, 'reward:ticket:delete', '删除优惠券', 'reward', 'ticket', 'delete', 'ALL', '删除优惠券', 82, 'ENABLED', CURRENT_TIMESTAMP),
(83, 'reward:ticket:issue', '发放优惠券', 'reward', 'ticket', 'issue', 'ALL', '发放优惠券', 83, 'ENABLED', CURRENT_TIMESTAMP),
(84, 'reward:points:view', '查看积分', 'reward', 'points', 'view', 'ALL', '查看积分余额', 84, 'ENABLED', CURRENT_TIMESTAMP),
(85, 'reward:points:adjust', '调整积分', 'reward', 'points', 'adjust', 'ALL', '调整用户积分', 85, 'ENABLED', CURRENT_TIMESTAMP),
(86, 'reward:level:view', '查看等级配置', 'reward', 'level', 'view', 'ALL', '查看会员等级配置', 86, 'ENABLED', CURRENT_TIMESTAMP),
(87, 'reward:level:edit', '编辑等级配置', 'reward', 'level', 'edit', 'ALL', '编辑会员等级配置', 87, 'ENABLED', CURRENT_TIMESTAMP),
(88, 'reward:history:view', '查看奖励历史', 'reward', 'history', 'view', 'ALL', '查看奖励发放历史', 88, 'ENABLED', CURRENT_TIMESTAMP),
(89, 'reward:pending:view', '查看待审批奖励', 'reward', 'pending', 'view', 'ALL', '查看待审批奖励列表', 89, 'ENABLED', CURRENT_TIMESTAMP),
(90, 'reward:limit:view', '查看奖励限额', 'reward', 'limit', 'view', 'ALL', '查看奖励限额配置', 90, 'ENABLED', CURRENT_TIMESTAMP);

-- 5. 风险管理模块 (20个权限)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at) VALUES
(91, 'risk:alert:view', '查看风险告警', 'risk', 'alert', 'view', 'ALL', '查看风险告警列表', 91, 'ENABLED', CURRENT_TIMESTAMP),
(92, 'risk:alert:handle', '处理风险告警', 'risk', 'alert', 'handle', 'ALL', '处理风险告警', 92, 'ENABLED', CURRENT_TIMESTAMP),
(93, 'risk:alert:ignore', '忽略风险告警', 'risk', 'alert', 'ignore', 'ALL', '忽略风险告警', 93, 'ENABLED', CURRENT_TIMESTAMP),
(94, 'risk:rule:view', '查看风控规则', 'risk', 'rule', 'view', 'ALL', '查看风控规则列表', 94, 'ENABLED', CURRENT_TIMESTAMP),
(95, 'risk:rule:create', '创建风控规则', 'risk', 'rule', 'create', 'ALL', '创建风控规则', 95, 'ENABLED', CURRENT_TIMESTAMP),
(96, 'risk:rule:edit', '编辑风控规则', 'risk', 'rule', 'edit', 'ALL', '编辑风控规则', 96, 'ENABLED', CURRENT_TIMESTAMP),
(97, 'risk:rule:delete', '删除风控规则', 'risk', 'rule', 'delete', 'ALL', '删除风控规则', 97, 'ENABLED', CURRENT_TIMESTAMP),
(98, 'risk:rule:enable', '启用风控规则', 'risk', 'rule', 'enable', 'ALL', '启用风控规则', 98, 'ENABLED', CURRENT_TIMESTAMP),
(99, 'risk:rule:disable', '禁用风控规则', 'risk', 'rule', 'disable', 'ALL', '禁用风控规则', 99, 'ENABLED', CURRENT_TIMESTAMP),
(100, 'risk:stats:view', '查看风控统计', 'risk', 'stats', 'view', 'ALL', '查看风控统计数据', 100, 'ENABLED', CURRENT_TIMESTAMP),
(101, 'risk:case:view', '查看风险案件', 'risk', 'case', 'view', 'ALL', '查看风险案件列表', 101, 'ENABLED', CURRENT_TIMESTAMP),
(102, 'risk:case:handle', '处理风险案件', 'risk', 'case', 'handle', 'ALL', '处理风险案件', 102, 'ENABLED', CURRENT_TIMESTAMP),
(103, 'risk:whitelist:view', '查看白名单', 'risk', 'whitelist', 'view', 'ALL', '查看风控白名单', 103, 'ENABLED', CURRENT_TIMESTAMP),
(104, 'risk:whitelist:add', '添加白名单', 'risk', 'whitelist', 'add', 'ALL', '添加白名单', 104, 'ENABLED', CURRENT_TIMESTAMP),
(105, 'risk:whitelist:remove', '移除白名单', 'risk', 'whitelist', 'remove', 'ALL', '移除白名单', 105, 'ENABLED', CURRENT_TIMESTAMP),
(106, 'risk:blacklist:view', '查看黑名单', 'risk', 'blacklist', 'view', 'ALL', '查看风控黑名单', 106, 'ENABLED', CURRENT_TIMESTAMP),
(107, 'risk:blacklist:add', '添加黑名单', 'risk', 'blacklist', 'add', 'ALL', '添加黑名单', 107, 'ENABLED', CURRENT_TIMESTAMP),
(108, 'risk:blacklist:remove', '移除黑名单', 'risk', 'blacklist', 'remove', 'ALL', '移除黑名单', 108, 'ENABLED', CURRENT_TIMESTAMP),
(109, 'risk:log:view', '查看风控日志', 'risk', 'log', 'view', 'ALL', '查看风控操作日志', 109, 'ENABLED', CURRENT_TIMESTAMP),
(110, 'risk:config:view', '查看风控配置', 'risk', 'config', 'view', 'ALL', '查看风控配置', 110, 'ENABLED', CURRENT_TIMESTAMP);

-- 6. 审批中心模块 (15个权限)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at) VALUES
(111, 'approval:list:view', '查看审批列表', 'approval', 'list', 'view', 'ALL', '查看审批列表', 111, 'ENABLED', CURRENT_TIMESTAMP),
(112, 'approval:detail:view', '查看审批详情', 'approval', 'detail', 'view', 'ALL', '查看审批详情', 112, 'ENABLED', CURRENT_TIMESTAMP),
(113, 'approval:submit', '提交审批', 'approval', 'index', 'submit', 'ALL', '提交审批申请', 113, 'ENABLED', CURRENT_TIMESTAMP),
(114, 'approval:approve', '审批通过', 'approval', 'index', 'approve', 'ALL', '审批通过', 114, 'ENABLED', CURRENT_TIMESTAMP),
(115, 'approval:reject', '审批拒绝', 'approval', 'index', 'reject', 'ALL', '审批拒绝', 115, 'ENABLED', CURRENT_TIMESTAMP),
(116, 'approval:cancel', '取消审批', 'approval', 'index', 'cancel', 'ALL', '取消审批申请', 116, 'ENABLED', CURRENT_TIMESTAMP),
(117, 'approval:delegate', '委托审批', 'approval', 'index', 'delegate', 'ALL', '委托他人审批', 117, 'ENABLED', CURRENT_TIMESTAMP),
(118, 'approval:escalate', '升级审批', 'approval', 'index', 'escalate', 'ALL', '升级审批', 118, 'ENABLED', CURRENT_TIMESTAMP),
(119, 'approval:history:view', '查看审批历史', 'approval', 'history', 'view', 'ALL', '查看审批历史记录', 119, 'ENABLED', CURRENT_TIMESTAMP),
(120, 'approval:export', '导出审批记录', 'approval', 'index', 'export', 'ALL', '导出审批记录', 120, 'ENABLED', CURRENT_TIMESTAMP),
(121, 'approval:template:view', '查看审批模板', 'approval', 'template', 'view', 'ALL', '查看审批模板', 121, 'ENABLED', CURRENT_TIMESTAMP),
(122, 'approval:template:edit', '编辑审批模板', 'approval', 'template', 'edit', 'ALL', '编辑审批模板', 122, 'ENABLED', CURRENT_TIMESTAMP),
(123, 'approval:pending:view', '查看待审批', 'approval', 'pending', 'view', 'ALL', '查看待我审批的任务', 123, 'ENABLED', CURRENT_TIMESTAMP),
(124, 'approval:processed:view', '查看已审批', 'approval', 'processed', 'view', 'ALL', '查看我已审批的任务', 124, 'ENABLED', CURRENT_TIMESTAMP),
(125, 'approval:stats:view', '查看审批统计', 'approval', 'stats', 'view', 'ALL', '查看审批统计数据', 125, 'ENABLED', CURRENT_TIMESTAMP);

-- 7. 审计日志模块 (15个权限)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at) VALUES
(126, 'audit:log:view', '查看审计日志', 'audit', 'log', 'view', 'ALL', '查看审计日志', 126, 'ENABLED', CURRENT_TIMESTAMP),
(127, 'audit:log:export', '导出审计日志', 'audit', 'log', 'export', 'ALL', '导出审计日志', 127, 'ENABLED', CURRENT_TIMESTAMP),
(128, 'audit:log:search', '搜索审计日志', 'audit', 'log', 'search', 'ALL', '搜索审计日志', 128, 'ENABLED', CURRENT_TIMESTAMP),
(129, 'audit:log:detail', '查看日志详情', 'audit', 'log', 'detail', 'ALL', '查看审计日志详情', 129, 'ENABLED', CURRENT_TIMESTAMP),
(130, 'audit:user:view', '查看用户操作', 'audit', 'user', 'view', 'ALL', '查看用户操作记录', 130, 'ENABLED', CURRENT_TIMESTAMP),
(131, 'audit:system:view', '查看系统操作', 'audit', 'system', 'view', 'ALL', '查看系统操作记录', 131, 'ENABLED', CURRENT_TIMESTAMP),
(132, 'audit:security:view', '查看安全日志', 'audit', 'security', 'view', 'ALL', '查看安全相关日志', 132, 'ENABLED', CURRENT_TIMESTAMP),
(133, 'audit:login:view', '查看登录日志', 'audit', 'login', 'view', 'ALL', '查看用户登录日志', 133, 'ENABLED', CURRENT_TIMESTAMP),
(134, 'audit:sensitive:view', '查看敏感操作', 'audit', 'sensitive', 'view', 'ALL', '查看敏感操作记录', 134, 'ENABLED', CURRENT_TIMESTAMP),
(135, 'audit:report:view', '查看审计报告', 'audit', 'report', 'view', 'ALL', '查看审计报告', 135, 'ENABLED', CURRENT_TIMESTAMP),
(136, 'audit:report:export', '导出审计报告', 'audit', 'report', 'export', 'ALL', '导出审计报告', 136, 'ENABLED', CURRENT_TIMESTAMP),
(137, 'audit:config:view', '查看审计配置', 'audit', 'config', 'view', 'ALL', '查看审计配置', 137, 'ENABLED', CURRENT_TIMESTAMP),
(138, 'audit:config:edit', '编辑审计配置', 'audit', 'config', 'edit', 'ALL', '编辑审计配置', 138, 'ENABLED', CURRENT_TIMESTAMP),
(139, 'audit:alert:view', '查看审计告警', 'audit', 'alert', 'view', 'ALL', '查看审计告警', 139, 'ENABLED', CURRENT_TIMESTAMP),
(140, 'audit:alert:handle', '处理审计告警', 'audit', 'alert', 'handle', 'ALL', '处理审计告警', 140, 'ENABLED', CURRENT_TIMESTAMP);

-- 8. 通知管理模块 (10个权限)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at) VALUES
(141, 'notification:list:view', '查看通知列表', 'notification', 'list', 'view', 'ALL', '查看通知列表', 141, 'ENABLED', CURRENT_TIMESTAMP),
(142, 'notification:detail:view', '查看通知详情', 'notification', 'detail', 'view', 'ALL', '查看通知详情', 142, 'ENABLED', CURRENT_TIMESTAMP),
(143, 'notification:send', '发送通知', 'notification', 'index', 'send', 'ALL', '发送通知', 143, 'ENABLED', CURRENT_TIMESTAMP),
(144, 'notification:batch:send', '批量发送通知', 'notification', 'index', 'batch_send', 'ALL', '批量发送通知', 144, 'ENABLED', CURRENT_TIMESTAMP),
(145, 'notification:delete', '删除通知', 'notification', 'index', 'delete', 'ALL', '删除通知', 145, 'ENABLED', CURRENT_TIMESTAMP),
(146, 'notification:read', '标记已读', 'notification', 'index', 'read', 'ALL', '标记通知已读', 146, 'ENABLED', CURRENT_TIMESTAMP),
(147, 'notification:batch:read', '批量标记已读', 'notification', 'index', 'batch_read', 'ALL', '批量标记已读', 147, 'ENABLED', CURRENT_TIMESTAMP),
(148, 'notification:unread:view', '查看未读通知', 'notification', 'unread', 'view', 'ALL', '查看未读通知', 148, 'ENABLED', CURRENT_TIMESTAMP),
(149, 'notification:template:view', '查看通知模板', 'notification', 'template', 'view', 'ALL', '查看通知模板', 149, 'ENABLED', CURRENT_TIMESTAMP),
(150, 'notification:template:edit', '编辑通知模板', 'notification', 'template', 'edit', 'ALL', '编辑通知模板', 150, 'ENABLED', CURRENT_TIMESTAMP);

-- 9. 系统配置模块 (20个权限)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at) VALUES
(151, 'system:config:view', '查看系统配置', 'system', 'config', 'view', 'ALL', '查看系统配置', 151, 'ENABLED', CURRENT_TIMESTAMP),
(152, 'system:config:edit', '编辑系统配置', 'system', 'config', 'edit', 'ALL', '编辑系统配置', 152, 'ENABLED', CURRENT_TIMESTAMP),
(153, 'system:cache:view', '查看缓存状态', 'system', 'cache', 'view', 'ALL', '查看缓存状态', 153, 'ENABLED', CURRENT_TIMESTAMP),
(154, 'system:cache:clear', '清理缓存', 'system', 'cache', 'clear', 'ALL', '清理系统缓存', 154, 'ENABLED', CURRENT_TIMESTAMP),
(155, 'system:cache:refresh', '刷新缓存', 'system', 'cache', 'refresh', 'ALL', '刷新缓存', 155, 'ENABLED', CURRENT_TIMESTAMP),
(156, 'system:api:view', '查看API配置', 'system', 'api', 'view', 'ALL', '查看API配置', 156, 'ENABLED', CURRENT_TIMESTAMP),
(157, 'system:api:create', '创建API Key', 'system', 'api', 'create', 'ALL', '创建API Key', 157, 'ENABLED', CURRENT_TIMESTAMP),
(158, 'system:api:delete', '删除API Key', 'system', 'api', 'delete', 'ALL', '删除API Key', 158, 'ENABLED', CURRENT_TIMESTAMP),
(159, 'system:api:enable', '启用API Key', 'system', 'api', 'enable', 'ALL', '启用API Key', 159, 'ENABLED', CURRENT_TIMESTAMP),
(160, 'system:api:disable', '禁用API Key', 'system', 'api', 'disable', 'ALL', '禁用API Key', 160, 'ENABLED', CURRENT_TIMESTAMP),
(161, 'system:log:view', '查看系统日志', 'system', 'log', 'view', 'ALL', '查看系统日志', 161, 'ENABLED', CURRENT_TIMESTAMP),
(162, 'system:log:export', '导出系统日志', 'system', 'log', 'export', 'ALL', '导出系统日志', 162, 'ENABLED', CURRENT_TIMESTAMP),
(163, 'system:monitor:view', '查看系统监控', 'system', 'monitor', 'view', 'ALL', '查看系统监控数据', 163, 'ENABLED', CURRENT_TIMESTAMP),
(164, 'system:health:view', '查看健康检查', 'system', 'health', 'view', 'ALL', '查看系统健康状态', 164, 'ENABLED', CURRENT_TIMESTAMP),
(165, 'system:backup:view', '查看备份列表', 'system', 'backup', 'view', 'ALL', '查看数据备份列表', 165, 'ENABLED', CURRENT_TIMESTAMP),
(166, 'system:backup:create', '创建备份', 'system', 'backup', 'create', 'ALL', '创建数据备份', 166, 'ENABLED', CURRENT_TIMESTAMP),
(167, 'system:backup:restore', '恢复备份', 'system', 'backup', 'restore', 'ALL', '恢复数据备份', 167, 'ENABLED', CURRENT_TIMESTAMP),
(168, 'system:backup:delete', '删除备份', 'system', 'backup', 'delete', 'ALL', '删除备份', 168, 'ENABLED', CURRENT_TIMESTAMP),
(169, 'system:job:view', '查看定时任务', 'system', 'job', 'view', 'ALL', '查看定时任务列表', 169, 'ENABLED', CURRENT_TIMESTAMP),
(170, 'system:job:edit', '编辑定时任务', 'system', 'job', 'edit', 'ALL', '编辑定时任务', 170, 'ENABLED', CURRENT_TIMESTAMP);

-- 10. 权限管理模块 (30个权限)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at) VALUES
(171, 'permission:list:view', '查看权限列表', 'permission', 'list', 'view', 'ALL', '查看权限列表', 171, 'ENABLED', CURRENT_TIMESTAMP),
(172, 'permission:detail:view', '查看权限详情', 'permission', 'detail', 'view', 'ALL', '查看权限详情', 172, 'ENABLED', CURRENT_TIMESTAMP),
(173, 'permission:create', '创建权限', 'permission', 'index', 'create', 'ALL', '创建新权限', 173, 'ENABLED', CURRENT_TIMESTAMP),
(174, 'permission:edit', '编辑权限', 'permission', 'index', 'edit', 'ALL', '编辑权限', 174, 'ENABLED', CURRENT_TIMESTAMP),
(175, 'permission:delete', '删除权限', 'permission', 'index', 'delete', 'ALL', '删除权限', 175, 'ENABLED', CURRENT_TIMESTAMP),
(176, 'role:list:view', '查看角色列表', 'role', 'list', 'view', 'ALL', '查看角色列表', 176, 'ENABLED', CURRENT_TIMESTAMP),
(177, 'role:detail:view', '查看角色详情', 'role', 'detail', 'view', 'ALL', '查看角色详情', 177, 'ENABLED', CURRENT_TIMESTAMP),
(178, 'role:create', '创建角色', 'role', 'index', 'create', 'ALL', '创建新角色', 178, 'ENABLED', CURRENT_TIMESTAMP),
(179, 'role:edit', '编辑角色', 'role', 'index', 'edit', 'ALL', '编辑角色', 179, 'ENABLED', CURRENT_TIMESTAMP),
(180, 'role:delete', '删除角色', 'role', 'index', 'delete', 'ALL', '删除角色', 180, 'ENABLED', CURRENT_TIMESTAMP),
(181, 'role:assign:permission', '分配角色权限', 'role', 'permission', 'assign', 'ALL', '为角色分配权限', 181, 'ENABLED', CURRENT_TIMESTAMP),
(182, 'role:assign:user', '分配用户角色', 'role', 'user', 'assign', 'ALL', '为用户分配角色', 182, 'ENABLED', CURRENT_TIMESTAMP),
(183, 'department:list:view', '查看部门列表', 'department', 'list', 'view', 'ALL', '查看部门列表', 183, 'ENABLED', CURRENT_TIMESTAMP),
(184, 'department:detail:view', '查看部门详情', 'department', 'detail', 'view', 'ALL', '查看部门详情', 184, 'ENABLED', CURRENT_TIMESTAMP),
(185, 'department:create', '创建部门', 'department', 'index', 'create', 'ALL', '创建新部门', 185, 'ENABLED', CURRENT_TIMESTAMP),
(186, 'department:edit', '编辑部门', 'department', 'index', 'edit', 'ALL', '编辑部门', 186, 'ENABLED', CURRENT_TIMESTAMP),
(187, 'department:delete', '删除部门', 'department', 'index', 'delete', 'ALL', '删除部门', 187, 'ENABLED', CURRENT_TIMESTAMP),
(188, 'department:user:add', '添加部门用户', 'department', 'user', 'add', 'ALL', '添加用户到部门', 188, 'ENABLED', CURRENT_TIMESTAMP),
(189, 'department:user:remove', '移除部门用户', 'department', 'user', 'remove', 'ALL', '从部门移除用户', 189, 'ENABLED', CURRENT_TIMESTAMP),
(190, 'department:leader:assign', '分配部门负责人', 'department', 'leader', 'assign', 'ALL', '分配部门负责人', 190, 'ENABLED', CURRENT_TIMESTAMP),
(191, 'menu:list:view', '查看菜单列表', 'menu', 'list', 'view', 'ALL', '查看菜单列表', 191, 'ENABLED', CURRENT_TIMESTAMP),
(192, 'menu:create', '创建菜单', 'menu', 'index', 'create', 'ALL', '创建菜单', 192, 'ENABLED', CURRENT_TIMESTAMP),
(193, 'menu:edit', '编辑菜单', 'menu', 'index', 'edit', 'ALL', '编辑菜单', 193, 'ENABLED', CURRENT_TIMESTAMP),
(194, 'menu:delete', '删除菜单', 'menu', 'index', 'delete', 'ALL', '删除菜单', 194, 'ENABLED', CURRENT_TIMESTAMP),
(195, 'menu:sort', '排序菜单', 'menu', 'index', 'sort', 'ALL', '排序菜单', 195, 'ENABLED', CURRENT_TIMESTAMP),
(196, 'resource:list:view', '查看资源列表', 'resource', 'list', 'view', 'ALL', '查看资源列表', 196, 'ENABLED', CURRENT_TIMESTAMP),
(197, 'resource:create', '创建资源', 'resource', 'index', 'create', 'ALL', '创建资源', 197, 'ENABLED', CURRENT_TIMESTAMP),
(198, 'resource:edit', '编辑资源', 'resource', 'index', 'edit', 'ALL', '编辑资源', 198, 'ENABLED', CURRENT_TIMESTAMP),
(199, 'resource:delete', '删除资源', 'resource', 'index', 'delete', 'ALL', '删除资源', 199, 'ENABLED', CURRENT_TIMESTAMP),
(200, 'data:scope:view', '查看数据权限', 'data', 'scope', 'view', 'ALL', '查看数据权限配置', 200, 'ENABLED', CURRENT_TIMESTAMP);

-- 剩余25个权限 (用于未来扩展)
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at) VALUES
(201, 'report:view', '查看报表', 'report', 'index', 'view', 'ALL', '查看各类报表', 201, 'ENABLED', CURRENT_TIMESTAMP),
(202, 'report:export', '导出报表', 'report', 'index', 'export', 'ALL', '导出报表数据', 202, 'ENABLED', CURRENT_TIMESTAMP),
(203, 'data:analysis:view', '查看数据分析', 'data', 'analysis', 'view', 'ALL', '查看数据分析', 203, 'ENABLED', CURRENT_TIMESTAMP),
(204, 'data:mining:view', '查看数据挖掘', 'data', 'mining', 'view', 'ALL', '查看数据挖掘结果', 204, 'ENABLED', CURRENT_TIMESTAMP),
(205, 'campaign:list:view', '查看营销活动', 'campaign', 'list', 'view', 'ALL', '查看营销活动列表', 205, 'ENABLED', CURRENT_TIMESTAMP),
(206, 'campaign:create', '创建营销活动', 'campaign', 'index', 'create', 'ALL', '创建营销活动', 206, 'ENABLED', CURRENT_TIMESTAMP),
(207, 'campaign:edit', '编辑营销活动', 'campaign', 'index', 'edit', 'ALL', '编辑营销活动', 207, 'ENABLED', CURRENT_TIMESTAMP),
(208, 'campaign:delete', '删除营销活动', 'campaign', 'index', 'delete', 'ALL', '删除营销活动', 208, 'ENABLED', CURRENT_TIMESTAMP),
(209, 'shortlink:list:view', '查看短链列表', 'shortlink', 'list', 'view', 'ALL', '查看短链接列表', 209, 'ENABLED', CURRENT_TIMESTAMP),
(210, 'shortlink:create', '创建短链', 'shortlink', 'index', 'create', 'ALL', '创建短链接', 210, 'ENABLED', CURRENT_TIMESTAMP),
(211, 'shortlink:delete', '删除短链', 'shortlink', 'index', 'delete', 'ALL', '删除短链接', 211, 'ENABLED', CURRENT_TIMESTAMP),
(212, 'shortlink:stats:view', '查看短链统计', 'shortlink', 'stats', 'view', 'ALL', '查看短链接统计', 212, 'ENABLED', CURRENT_TIMESTAMP),
(213, 'callback:list:view', '查看回调列表', 'callback', 'list', 'view', 'ALL', '查看回调列表', 213, 'ENABLED', CURRENT_TIMESTAMP),
(214, 'callback:config', '配置回调', 'callback', 'index', 'config', 'ALL', '配置回调', 214, 'ENABLED', CURRENT_TIMESTAMP),
(215, 'callback:test', '测试回调', 'callback', 'index', 'test', 'ALL', '测试回调', 215, 'ENABLED', CURRENT_TIMESTAMP),
(216, 'integration:view', '查看集成配置', 'integration', 'index', 'view', 'ALL', '查看集成配置', 216, 'ENABLED', CURRENT_TIMESTAMP),
(217, 'integration:edit', '编辑集成配置', 'integration', 'index', 'edit', 'ALL', '编辑集成配置', 217, 'ENABLED', CURRENT_TIMESTAMP),
(218, 'webhook:view', '查看Webhook', 'webhook', 'index', 'view', 'ALL', '查看Webhook列表', 218, 'ENABLED', CURRENT_TIMESTAMP),
(219, 'webhook:create', '创建Webhook', 'webhook', 'index', 'create', 'ALL', '创建Webhook', 219, 'ENABLED', CURRENT_TIMESTAMP),
(220, 'webhook:edit', '编辑Webhook', 'webhook', 'index', 'edit', 'ALL', '编辑Webhook', 220, 'ENABLED', CURRENT_TIMESTAMP),
(221, 'webhook:delete', '删除Webhook', 'webhook', 'index', 'delete', 'ALL', '删除Webhook', 221, 'ENABLED', CURRENT_TIMESTAMP),
(222, 'sensitive:access', '访问敏感数据', 'sensitive', 'index', 'access', 'ALL', '访问敏感数据', 222, 'ENABLED', CURRENT_TIMESTAMP),
(223, 'sensitive:export', '导出敏感数据', 'sensitive', 'index', 'export', 'ALL', '导出敏感数据', 223, 'ENABLED', CURRENT_TIMESTAMP),
(224, 'download:view', '查看下载记录', 'download', 'list', 'view', 'ALL', '查看下载记录', 224, 'ENABLED', CURRENT_TIMESTAMP),
(225, 'download:approve', '审批下载', 'download', 'index', 'approve', 'ALL', '审批下载申请', 225, 'ENABLED', CURRENT_TIMESTAMP);

-- ==================== 角色权限映射 ====================
-- 为每个角色分配权限 (简化版本，核心角色拥有所有权限)

-- 超级管理员拥有所有权限
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 1, id FROM sys_permission;

-- 系统管理员拥有大部分权限
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 2, id FROM sys_permission WHERE id <= 200;

-- 审计员拥有审计和查看权限
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 15, id FROM sys_permission WHERE permission_code LIKE 'audit:%' OR permission_code LIKE 'dashboard:%';

-- 运营总监/经理
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 3, id FROM sys_permission WHERE module_code IN ('dashboard', 'activity', 'approval', 'notification');
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 4, id FROM sys_permission WHERE module_code IN ('dashboard', 'activity', 'approval', 'notification');

-- 市场总监/经理
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 5, id FROM sys_permission WHERE module_code IN ('dashboard', 'activity', 'reward', 'approval', 'notification');
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 6, id FROM sys_permission WHERE module_code IN ('dashboard', 'activity', 'reward', 'approval', 'notification');

-- 财务经理
INSERT INTO sys_permission (id, permission_code, permission_name, module_code, resource_code, operation_code, data_scope, description, sort_order, status, created_at) VALUES
(226, 'reward:finance:view', '查看财务奖励', 'reward', 'finance', 'view', 'DEPARTMENT', '查看财务相关奖励', 91, 'ENABLED', CURRENT_TIMESTAMP),
(227, 'reward:finance:approve', '审批财务奖励', 'reward', 'finance', 'approve', 'DEPARTMENT', '审批大额奖励', 92, 'ENABLED', CURRENT_TIMESTAMP);

INSERT INTO sys_role_permission (role_id, permission_id) VALUES (7, 226), (7, 227);

-- 风控经理
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 8, id FROM sys_permission WHERE module_code IN ('risk', 'dashboard', 'approval');

-- 客服主管
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 9, id FROM sys_permission WHERE module_code IN ('dashboard', 'user', 'activity', 'notification');

-- 运营/市场专员 (个人数据权限)
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 10, id FROM sys_permission WHERE module_code IN ('dashboard', 'activity') AND operation_code IN ('view', 'stats:view');
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 11, id FROM sys_permission WHERE module_code IN ('dashboard', 'activity') AND operation_code IN ('view', 'stats:view');

-- 财务/风控专员
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 12, id FROM sys_permission WHERE module_code = 'reward' AND operation_code = 'view';
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 13, id FROM sys_permission WHERE module_code = 'risk' AND operation_code = 'view';

-- 客服专员
INSERT INTO sys_role_permission (role_id, permission_id)
SELECT 14, id FROM sys_permission WHERE module_code IN ('user', 'activity') AND operation_code = 'view';
