-- V35: 规范化权限码为PRD四段式
-- 格式: module.resource.operation.dataScope (如 activity.index.view.ALL)
-- 保留兼容层：PermissionCodeResolver支持旧冒号格式

-- 更新现有权限码为四段式
-- 活动管理模块
UPDATE sys_permission SET permission_code = 'activity.index.view.ALL' WHERE permission_code = 'activity:view';
UPDATE sys_permission SET permission_code = 'activity.index.create.ALL' WHERE permission_code = 'activity:create';
UPDATE sys_permission SET permission_code = 'activity.index.update.ALL' WHERE permission_code = 'activity:update';
UPDATE sys_permission SET permission_code = 'activity.index.delete.ALL' WHERE permission_code = 'activity:delete';
UPDATE sys_permission SET permission_code = 'activity.index.publish.ALL' WHERE permission_code = 'activity:publish';
UPDATE sys_permission SET permission_code = 'activity.index.pause.ALL' WHERE permission_code = 'activity:pause';
UPDATE sys_permission SET permission_code = 'activity.index.resume.ALL' WHERE permission_code = 'activity:resume';
UPDATE sys_permission SET permission_code = 'activity.index.end.ALL' WHERE permission_code = 'activity:end';
UPDATE sys_permission SET permission_code = 'activity.index.export.ALL' WHERE permission_code = 'activity:export';
UPDATE sys_permission SET permission_code = 'activity.stats.view.ALL' WHERE permission_code = 'activity:stats';
UPDATE sys_permission SET permission_code = 'activity.approval.approve.ALL' WHERE permission_code = 'activity:approve';
UPDATE sys_permission SET permission_code = 'activity.approval.submit.ALL' WHERE permission_code = 'activity:submit';

-- 用户管理模块
UPDATE sys_permission SET permission_code = 'user.index.view.ALL' WHERE permission_code = 'user:view';
UPDATE sys_permission SET permission_code = 'user.index.create.ALL' WHERE permission_code = 'user:create';
UPDATE sys_permission SET permission_code = 'user.index.update.ALL' WHERE permission_code = 'user:update';
UPDATE sys_permission SET permission_code = 'user.index.delete.ALL' WHERE permission_code = 'user:delete';
UPDATE sys_permission SET permission_code = 'user.index.freeze.ALL' WHERE permission_code = 'user:freeze';
UPDATE sys_permission SET permission_code = 'user.index.unfreeze.ALL' WHERE permission_code = 'user:unfreeze';
UPDATE sys_permission SET permission_code = 'user.index.certify.ALL' WHERE permission_code = 'user:certify';
UPDATE sys_permission SET permission_code = 'user.index.export.ALL' WHERE permission_code = 'user:export';

-- 奖励管理模块
UPDATE sys_permission SET permission_code = 'reward.index.view.ALL' WHERE permission_code = 'reward:view';
UPDATE sys_permission SET permission_code = 'reward.index.approve.ALL' WHERE permission_code = 'reward:approve';
UPDATE sys_permission SET permission_code = 'reward.index.grant.ALL' WHERE permission_code = 'reward:grant';
UPDATE sys_permission SET permission_code = 'reward.index.reject.ALL' WHERE permission_code = 'reward:reject';
UPDATE sys_permission SET permission_code = 'reward.index.export.ALL' WHERE permission_code = 'reward:export';
UPDATE sys_permission SET permission_code = 'reward.index.apply.ALL' WHERE permission_code = 'reward:apply';
UPDATE sys_permission SET permission_code = 'reward.index.cancel.ALL' WHERE permission_code = 'reward:cancel';
UPDATE sys_permission SET permission_code = 'reward.index.reconcile.ALL' WHERE permission_code = 'reward:reconcile';

-- 风险管理模块
UPDATE sys_permission SET permission_code = 'risk.index.view.ALL' WHERE permission_code = 'risk:view';
UPDATE sys_permission SET permission_code = 'risk.rule.manage.ALL' WHERE permission_code = 'risk:rule';
UPDATE sys_permission SET permission_code = 'risk.index.audit.ALL' WHERE permission_code = 'risk:audit';
UPDATE sys_permission SET permission_code = 'risk.blacklist.manage.ALL' WHERE permission_code = 'risk:blacklist';
UPDATE sys_permission SET permission_code = 'risk.index.export.ALL' WHERE permission_code = 'risk:export';

-- 审批中心模块
UPDATE sys_permission SET permission_code = 'approval.index.view.ALL' WHERE permission_code = 'approval:view';
UPDATE sys_permission SET permission_code = 'approval.index.handle.ALL' WHERE permission_code = 'approval:handle';
UPDATE sys_permission SET permission_code = 'approval.index.delegate.ALL' WHERE permission_code = 'approval:delegate';

-- 审计日志模块
UPDATE sys_permission SET permission_code = 'audit.index.view.ALL' WHERE permission_code = 'audit:view';
UPDATE sys_permission SET permission_code = 'audit.index.export.ALL' WHERE permission_code = 'audit:export';

-- 系统配置模块
UPDATE sys_permission SET permission_code = 'system.index.view.ALL' WHERE permission_code = 'system:view';
UPDATE sys_permission SET permission_code = 'system.config.manage.ALL' WHERE permission_code = 'system:config';
UPDATE sys_permission SET permission_code = 'system.cache.manage.ALL' WHERE permission_code = 'system:cache';

-- 权限管理模块
UPDATE sys_permission SET permission_code = 'permission.index.view.ALL' WHERE permission_code = 'permission:view';
UPDATE sys_permission SET permission_code = 'permission.index.manage.ALL' WHERE permission_code = 'permission:manage';
UPDATE sys_permission SET permission_code = 'role.index.view.ALL' WHERE permission_code = 'role:view';
UPDATE sys_permission SET permission_code = 'role.index.manage.ALL' WHERE permission_code = 'role:manage';
UPDATE sys_permission SET permission_code = 'department.index.view.ALL' WHERE permission_code = 'dept:view';
UPDATE sys_permission SET permission_code = 'department.index.manage.ALL' WHERE permission_code = 'dept:manage';

-- 通知管理模块
UPDATE sys_permission SET permission_code = 'notification.index.view.ALL' WHERE permission_code = 'notification:view';
UPDATE sys_permission SET permission_code = 'notification.index.manage.ALL' WHERE permission_code = 'notification:manage';

-- 仪表盘模块
UPDATE sys_permission SET permission_code = 'dashboard.index.view.ALL' WHERE permission_code = 'dashboard:view';
UPDATE sys_permission SET permission_code = 'dashboard.index.export.ALL' WHERE permission_code = 'dashboard:export';

-- 敏感数据访问权限
UPDATE sys_permission SET permission_code = 'system.sensitive.access.ALL' WHERE permission_code = 'sensitive:access';
