-- 更新默认角色权限
UPDATE roles SET 
  description = 'Admin',
  permissions = '["user:read","user:create","user:update","user:delete","insurance:read","insurance:create","insurance:update","insurance:delete","insurance:review","policy:read","policy:create","policy:update","policy:delete","claim:read","claim:create","claim:update","claim:review","system:read","system:update","system:admin"]'
WHERE name = 'admin';

-- 插入其他角色（如果不存在）
INSERT IGNORE INTO roles (name, description, permissions, status) VALUES 
('agent', 'Agent', '["insurance:read","insurance:create","policy:read","policy:create","claim:read","claim:create"]', 'active'),
('customer', 'Customer', '["insurance:read","policy:read","claim:read","claim:create"]', 'active');

-- 插入默认保险类型
INSERT INTO insurance_types (name, description, coverage_amount_min, coverage_amount_max, premium_rate, status) VALUES 
('人寿保险', '提供生命保障的保险产品', 10000.00, 1000000.00, 0.0025, 'active'),
('健康保险', '提供医疗保障的保险产品', 5000.00, 500000.00, 0.0030, 'active'),
('意外伤害保险', '提供意外伤害保障的保险产品', 1000.00, 200000.00, 0.0015, 'active'),
('财产保险', '提供财产保障的保险产品', 5000.00, 1000000.00, 0.0020, 'active'),
('车险', '提供车辆保障的保险产品', 1000.00, 500000.00, 0.0040, 'active');

-- 插入默认系统配置
INSERT INTO system_configs (config_key, config_value, description) VALUES 
('system_name', '"保险端口系统"', '系统名称'),
('company_name', '"XX保险公司"', '公司名称'),
('contact_email', '"support@insurance.com"', '联系邮箱'),
('contact_phone', '"400-123-4567"', '联系电话'),
('max_file_size', '10485760', '最大文件上传大小（字节）'),
('allowed_file_types', '["jpg", "jpeg", "png", "pdf", "doc", "docx"]', '允许上传的文件类型');

-- 创建管理员用户（密码需要在前端加密后存储）
-- 默认密码: admin123 (需要在前端使用bcrypt加密)
INSERT INTO users (username, password, real_name, email, phone, role_id, status) VALUES 
('admin', '$2b$12$r6KcJ3V9q8wY7hLmNpQZ0uBf3dG7hJ2kL9mNpQr3tY6zX8vB1cF4', '系统管理员', 'admin@insurance.com', '13800138000', 1, 'active');

COMMIT;