-- V45: 添加默认系统用户种子数据
-- 用于解决登录后鉴权断链问题
-- 用户ID与AuthService中的演示用户ID对应

-- 清理可能存在的旧数据
DELETE FROM sys_user WHERE id IN (1, 2, 3, 4);
DELETE FROM sys_user_role WHERE user_id IN (1, 2, 3, 4);

-- 超级管理员用户 (id=1, username=admin)
-- 密码: admin (SHA-256: 8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918)
INSERT INTO sys_user (id, username, password_hash, real_name, email, phone, department_id, status, is_certified, is_blacklisted, created_at, updated_at)
VALUES (1, 'admin', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', '超级管理员', 'admin@mosquito.com', '13800138000', NULL, 'ACTIVE', TRUE, FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);

-- 运营经理用户 (id=2, username=operator)
-- 密码: password (SHA-256: 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8)
INSERT INTO sys_user (id, username, password_hash, real_name, email, phone, department_id, status, is_certified, is_blacklisted, created_at, updated_at)
VALUES (2, 'operator', '5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8', '运营经理', 'operator@mosquito.com', '13800138001', NULL, 'ACTIVE', TRUE, FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);

-- 市场专员用户 (id=3, username=marketing)
-- 密码: password (SHA-256: 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8)
INSERT INTO sys_user (id, username, password_hash, real_name, email, phone, department_id, status, is_certified, is_blacklisted, created_at, updated_at)
VALUES (3, 'marketing', '5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8', '市场专员', 'marketing@mosquito.com', '13800138002', NULL, 'ACTIVE', TRUE, FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);

-- 审计员用户 (id=4, username=auditor)
-- 密码: password (SHA-256: 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8)
INSERT INTO sys_user (id, username, password_hash, real_name, email, phone, department_id, status, is_certified, is_blacklisted, created_at, updated_at)
VALUES (4, 'auditor', '5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8', '审计员', 'auditor@mosquito.com', '13800138003', NULL, 'ACTIVE', TRUE, FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);

-- 为用户分配角色 (与V37保持一致)
-- 超级管理员 (user_id=1) -> 超级管理员角色 (role_id=1)
INSERT INTO sys_user_role (user_id, role_id, created_at) VALUES (1, 1, CURRENT_TIMESTAMP);

-- 运营经理 (user_id=2) -> 运营经理角色 (role_id=4)
INSERT INTO sys_user_role (user_id, role_id, created_at) VALUES (2, 4, CURRENT_TIMESTAMP);

-- 市场专员 (user_id=3) -> 市场专员角色 (role_id=11)
INSERT INTO sys_user_role (user_id, role_id, created_at) VALUES (3, 11, CURRENT_TIMESTAMP);

-- 审计员 (user_id=4) -> 审计员角色 (role_id=15)
INSERT INTO sys_user_role (user_id, role_id, created_at) VALUES (4, 15, CURRENT_TIMESTAMP);
