-- Flyway migration V3 — seed test / demo data
-- Generated: 2026-05-08
-- 账号速查:
--   品牌 BR001 超管: admin       密码 Admin@123
--   品牌 BR001 普通: zhangwei    密码 Test@123   (有 usr:create + usr:view)
--   品牌 BR001 普通: lina        密码 Test@123   (有 usr:view)
--   品牌 BR001 普通: wanglei     密码 Test@123   (有 usr:view + doc:edit，bCanEditDoc=1)
--   品牌 BR001 普通: locked_user 密码 Test@123   (已禁用)
--   品牌 BR002 超管: admin       密码 Admin@123  (同名但不同品牌)
--   品牌 BR002 普通: chenhao     密码 Mgr@123

SET NAMES utf8mb4;
SET foreign_key_checks = 0;

-- ------------------------------------------------------------
-- 1. brand
-- ------------------------------------------------------------
INSERT IGNORE INTO `brand`
  (`sId`, `sBrandsId`, `sSubsidiaryId`, `tCreateDate`, `sName`, `sShortName`, `sNo`)
VALUES
  ('BR001', 'BR001', NULL, '2026-01-01 09:00:00', '小羚羊科技有限公司', '小羚羊科技', 'BR001'),
  ('BR002', 'BR002', NULL, '2026-01-01 09:00:00', '羚羊贸易有限公司',   '羚贸',       'BR002');

-- ------------------------------------------------------------
-- 2. tStaff
-- ------------------------------------------------------------
INSERT IGNORE INTO `tStaff`
  (`sId`, `sBrandsId`, `sSubsidiaryId`, `tCreateDate`, `sStaffNo`, `sStaffName`, `sDepartment`, `sCreatedBy`, `bDeleted`)
VALUES
  ('STAFF-001', 'BR001', NULL, '2026-01-01 09:00:00', 'E001', '张伟', '管理部', 'admin', 0),
  ('STAFF-002', 'BR001', NULL, '2026-01-01 09:00:00', 'E002', '李娜', '销售部', 'admin', 0),
  ('STAFF-003', 'BR001', NULL, '2026-01-01 09:00:00', 'E003', '王磊', '财务部', 'admin', 0),
  ('STAFF-004', 'BR001', NULL, '2026-01-01 09:00:00', 'E004', '刘洋', '仓储部', 'admin', 0),
  ('STAFF-005', 'BR002', NULL, '2026-01-01 09:00:00', 'E005', '陈浩', '管理部', 'admin', 0),
  ('STAFF-006', 'BR002', NULL, '2026-01-01 09:00:00', 'E006', '赵敏', '运营部', 'admin', 0);

-- ------------------------------------------------------------
-- 3. usr_permission_group
-- ------------------------------------------------------------
INSERT IGNORE INTO `usr_permission_group`
  (`sId`, `sBrandsId`, `sSubsidiaryId`, `tCreateDate`, `sGroupCode`, `sGroupName`, `sCategory`)
VALUES
  ('PG-B1-001', 'BR001', NULL, '2026-01-01 09:00:00', 'usr:create', '新增用户', '用户管理'),
  ('PG-B1-002', 'BR001', NULL, '2026-01-01 09:00:00', 'usr:edit',   '修改用户', '用户管理'),
  ('PG-B1-003', 'BR001', NULL, '2026-01-01 09:00:00', 'usr:view',   '查看用户', '用户管理'),
  ('PG-B1-004', 'BR001', NULL, '2026-01-01 09:00:00', 'doc:edit',   '单据修改', '单据管理'),
  ('PG-B2-001', 'BR002', NULL, '2026-01-01 09:00:00', 'usr:create', '新增用户', '用户管理'),
  ('PG-B2-002', 'BR002', NULL, '2026-01-01 09:00:00', 'usr:edit',   '修改用户', '用户管理'),
  ('PG-B2-003', 'BR002', NULL, '2026-01-01 09:00:00', 'usr:view',   '查看用户', '用户管理');

-- ------------------------------------------------------------
-- 4. usr_user
-- 密码哈希:
--   Admin@123 → $2b$10$khppncqEcBIKXWx4WKBZB.NyFUpm/NDGKnISRvOWbskDKE6dcL1Ze
--   Test@123  → $2b$10$JdsHfv.wG2hWkzFO5Ui/euK3wBzK2O1TbLSKKDzZJodVZ5SOVI632
--   Mgr@123   → $2b$10$hOa8yBAohVkjhTO3iMsE6Ov1mPA2UcoUId2NukwVBsB4b7j9Rs8l6
-- ------------------------------------------------------------
INSERT IGNORE INTO `usr_user`
  (`sId`, `sBrandsId`, `sSubsidiaryId`, `tCreateDate`, `sUserCode`, `sUsername`, `sPasswordHash`,
   `sUserType`, `sLanguage`, `bCanEditDoc`, `bIsDisabled`, `sEmployeeId`, `sCreatorUsername`,
   `tLastLoginDate`, `iLoginFailCount`, `tLockUntil`)
VALUES
  ('USR-B1-001', 'BR001', NULL, '2026-01-01 09:00:00',
   'UC001', 'admin', '$2b$10$khppncqEcBIKXWx4WKBZB.NyFUpm/NDGKnISRvOWbskDKE6dcL1Ze',
   '超级管理员', '中文', 0, 0, NULL, 'system', NULL, 0, NULL),

  ('USR-B1-002', 'BR001', NULL, '2026-01-02 10:00:00',
   'UC002', 'zhangwei', '$2b$10$JdsHfv.wG2hWkzFO5Ui/euK3wBzK2O1TbLSKKDzZJodVZ5SOVI632',
   '普通用户', '中文', 0, 0, 'STAFF-001', 'admin', NULL, 0, NULL),

  ('USR-B1-003', 'BR001', NULL, '2026-01-02 10:30:00',
   'UC003', 'lina', '$2b$10$JdsHfv.wG2hWkzFO5Ui/euK3wBzK2O1TbLSKKDzZJodVZ5SOVI632',
   '普通用户', '英文', 0, 0, 'STAFF-002', 'admin', NULL, 0, NULL),

  ('USR-B1-004', 'BR001', NULL, '2026-01-03 09:00:00',
   'UC004', 'wanglei', '$2b$10$JdsHfv.wG2hWkzFO5Ui/euK3wBzK2O1TbLSKKDzZJodVZ5SOVI632',
   '普通用户', '中文', 1, 0, 'STAFF-003', 'admin', NULL, 0, NULL),

  ('USR-B1-005', 'BR001', NULL, '2026-01-04 09:00:00',
   'UC005', 'locked_user', '$2b$10$JdsHfv.wG2hWkzFO5Ui/euK3wBzK2O1TbLSKKDzZJodVZ5SOVI632',
   '普通用户', '中文', 0, 1, NULL, 'admin', NULL, 0, NULL),

  ('USR-B2-001', 'BR002', NULL, '2026-01-01 09:00:00',
   'UC101', 'admin', '$2b$10$khppncqEcBIKXWx4WKBZB.NyFUpm/NDGKnISRvOWbskDKE6dcL1Ze',
   '超级管理员', '中文', 0, 0, NULL, 'system', NULL, 0, NULL),

  ('USR-B2-002', 'BR002', NULL, '2026-01-02 09:00:00',
   'UC102', 'chenhao', '$2b$10$hOa8yBAohVkjhTO3iMsE6Ov1mPA2UcoUId2NukwVBsB4b7j9Rs8l6',
   '普通用户', '繁体', 0, 0, 'STAFF-005', 'admin', NULL, 0, NULL);

-- ------------------------------------------------------------
-- 5. usr_user_permission
-- ------------------------------------------------------------
INSERT IGNORE INTO `usr_user_permission`
  (`sId`, `sBrandsId`, `sSubsidiaryId`, `tCreateDate`, `sUserId`, `sPermGroupId`)
VALUES
  ('UPM-001', 'BR001', NULL, '2026-01-02 10:00:00', 'USR-B1-002', 'PG-B1-001'),
  ('UPM-002', 'BR001', NULL, '2026-01-02 10:00:00', 'USR-B1-002', 'PG-B1-003'),
  ('UPM-003', 'BR001', NULL, '2026-01-02 10:30:00', 'USR-B1-003', 'PG-B1-003'),
  ('UPM-004', 'BR001', NULL, '2026-01-03 09:00:00', 'USR-B1-004', 'PG-B1-003'),
  ('UPM-005', 'BR001', NULL, '2026-01-03 09:00:00', 'USR-B1-004', 'PG-B1-004'),
  ('UPM-006', 'BR002', NULL, '2026-01-02 09:00:00', 'USR-B2-002', 'PG-B2-003');

SET foreign_key_checks = 1;
