-- =====================================================
-- 初始化资源权限数据
-- =====================================================

-- 等级成就
-- V1段：初学者 (0-10小时，每2小时一级)
INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`,`icon`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
('ACH001', 'learning_time_l1_1', '初学者 I', 'v1-icon.svg', '开始学习之旅', 2, 1.1, 1, 60*60, 5, 1, 0),
('ACH002', 'learning_time_l1_2', '初学者 II', 'v1-icon.svg', '累计学习时长达到2小时', 2, 1.2, 1, 2*60*60, 10, 2, 0),
('ACH003', 'learning_time_l1_3', '初学者 III', 'v1-icon.svg', '累计学习时长达到4小时', 2, 1.3, 1, 4*60*60, 15, 3, 0),
('ACH004', 'learning_time_l1_4', '初学者 IV', 'v1-icon.svg', '累计学习时长达到6小时', 2, 1.4, 1, 6*60*60, 20, 4, 0),
('ACH005', 'learning_time_l1_5', '初学者 V', 'v1-icon.svg', '累计学习时长达到10小时', 2, 1.5, 1, 10*60*60, 25, 5, 0),

-- V2段：勤学者 (10-30小时，每4小时一级)
('ACH006', 'learning_time_l2_1', '勤学者 I', 'v2-icon.svg', '累计学习时长达到14小时', 2, 2.1, 1, 14*60*60, 30, 6, 0),
('ACH007', 'learning_time_l2_2', '勤学者 II', 'v2-icon.svg', '累计学习时长达到18小时', 2, 2.2, 1, 18*60*60, 35, 7, 0),
('ACH008', 'learning_time_l2_3', '勤学者 III', 'v2-icon.svg', '累计学习时长达到22小时', 2, 2.3, 1, 22*60*60, 40, 8, 0),
('ACH009', 'learning_time_l2_4', '勤学者 IV', 'v2-icon.svg', '累计学习时长达到26小时', 2, 2.4, 1, 26*60*60, 45, 9, 0),
('ACH010', 'learning_time_l2_5', '勤学者 V', 'v2-icon.svg', '累计学习时长达到30小时', 2, 2.5, 1, 30*60*60, 50, 10, 0),

-- V3段：学习达人 (30-100小时，每14小时一级)
('ACH011', 'learning_time_l3_1', '学习达人 I', 'v3-icon.svg', '累计学习时长达到44小时', 2, 3.1, 1, 44*60*60, 60, 11, 0),
('ACH012', 'learning_time_l3_2', '学习达人 II', 'v3-icon.svg', '累计学习时长达到58小时', 2, 3.2, 1, 58*60*60, 70, 12, 0),
('ACH013', 'learning_time_l3_3', '学习达人 III', 'v3-icon.svg', '累计学习时长达到72小时', 2, 3.3, 1, 72*60*60, 80, 13, 0),
('ACH014', 'learning_time_l3_4', '学习达人 IV', 'v3-icon.svg', '累计学习时长达到86小时', 2, 3.4, 1, 86*60*60, 90, 14, 0),
('ACH015', 'learning_time_l3_5', '学习达人 V', 'v3-icon.svg', '累计学习时长达到100小时', 2, 3.5, 1, 100*60*60, 100, 15, 0),

-- V4段：学习狂人 (100-300小时，每40小时一级)
('ACH016', 'learning_time_l4_1', '学习狂人 I', 'v4-icon.svg', '累计学习时长达到140小时', 2, 4.1, 1, 140*60*60, 120, 16, 0),
('ACH017', 'learning_time_l4_2', '学习狂人 II', 'v4-icon.svg', '累计学习时长达到180小时', 2, 4.2, 1, 180*60*60, 140, 17, 0),
('ACH018', 'learning_time_l4_3', '学习狂人 III', 'v4-icon.svg', '累计学习时长达到220小时', 2, 4.3, 1, 220*60*60, 160, 18, 0),
('ACH019', 'learning_time_l4_4', '学习狂人 IV', 'v4-icon.svg', '累计学习时长达到260小时', 2, 4.4, 1, 260*60*60, 180, 19, 0),
('ACH020', 'learning_time_l4_5', '学习狂人 V', 'v4-icon.svg', '累计学习时长达到300小时', 2, 4.5, 1, 300*60*60, 200, 20, 0),

-- V5段：学习大师 (300-1000小时，每140小时一级)
('ACH021', 'learning_time_l5_1', '学习大师 I', 'v5-icon.svg', '累计学习时长达到440小时', 2, 5.1, 1, 440*60*60, 250, 21, 0),
('ACH022', 'learning_time_l5_2', '学习大师 II', 'v5-icon.svg', '累计学习时长达到580小时', 2, 5.2, 1, 580*60*60, 300, 22, 0),
('ACH023', 'learning_time_l5_3', '学习大师 III', 'v5-icon.svg', '累计学习时长达到720小时', 2, 5.3, 1, 720*60*60, 350, 23, 0),
('ACH024', 'learning_time_l5_4', '学习大师 IV', 'v5-icon.svg', '累计学习时长达到860小时', 2, 5.4, 1, 860*60*60, 400, 24, 0),
('ACH025', 'learning_time_l5_5', '学习大师 V', 'v5-icon.svg', '累计学习时长达到1000小时', 2, 5.5, 1, 1000*60*60, 500, 25, 0),

-- V6段：学习宗师 (1000-2000小时，每200小时一级)
('ACH026', 'learning_time_l6_1', '学习宗师 I', 'v6-icon.svg', '累计学习时长达到1200小时', 2, 6.1, 1, 1200*60*60, 600, 26, 0),
('ACH027', 'learning_time_l6_2', '学习宗师 II', 'v6-icon.svg', '累计学习时长达到1400小时', 2, 6.2, 1, 1400*60*60, 700, 27, 0),
('ACH028', 'learning_time_l6_3', '学习宗师 III', 'v6-icon.svg', '累计学习时长达到1600小时', 2, 6.3, 1, 1600*60*60, 800, 28, 0),
('ACH029', 'learning_time_l6_4', '学习宗师 IV', 'v6-icon.svg', '累计学习时长达到1800小时', 2, 6.4, 1, 1800*60*60, 900, 29, 0),
('ACH030', 'learning_time_l6_5', '学习宗师 V', 'v6-icon.svg', '累计学习时长达到2000小时', 2, 6.5, 1, 2000*60*60, 1000, 30, 0);

-- 为所有成就创建资源权限
INSERT INTO `tb_resource_permission` (id, resource_type, resource_id, dept_id, role_id, can_read, can_write, can_execute, creator, create_time) VALUES
-- V1段权限
('perm_achievement_001', 6, 'learning_time_l1_1', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_002', 6, 'learning_time_l1_2', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_003', 6, 'learning_time_l1_3', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_004', 6, 'learning_time_l1_4', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_005', 6, 'learning_time_l1_5', NULL, NULL, 1, 0, 0, '1', now()),
-- V2段权限
('perm_achievement_006', 6, 'learning_time_l2_1', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_007', 6, 'learning_time_l2_2', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_008', 6, 'learning_time_l2_3', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_009', 6, 'learning_time_l2_4', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_010', 6, 'learning_time_l2_5', NULL, NULL, 1, 0, 0, '1', now()),
-- V3段权限
('perm_achievement_011', 6, 'learning_time_l3_1', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_012', 6, 'learning_time_l3_2', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_013', 6, 'learning_time_l3_3', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_014', 6, 'learning_time_l3_4', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_015', 6, 'learning_time_l3_5', NULL, NULL, 1, 0, 0, '1', now()),
-- V4段权限
('perm_achievement_016', 6, 'learning_time_l4_1', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_017', 6, 'learning_time_l4_2', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_018', 6, 'learning_time_l4_3', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_019', 6, 'learning_time_l4_4', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_020', 6, 'learning_time_l4_5', NULL, NULL, 1, 0, 0, '1', now()),
-- V5段权限
('perm_achievement_021', 6, 'learning_time_l5_1', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_022', 6, 'learning_time_l5_2', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_023', 6, 'learning_time_l5_3', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_024', 6, 'learning_time_l5_4', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_025', 6, 'learning_time_l5_5', NULL, NULL, 1, 0, 0, '1', now()),
-- V6段权限
('perm_achievement_026', 6, 'learning_time_l6_1', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_027', 6, 'learning_time_l6_2', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_028', 6, 'learning_time_l6_3', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_029', 6, 'learning_time_l6_4', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_030', 6, 'learning_time_l6_5', NULL, NULL, 1, 0, 0, '1', now());


-- 勋章成就
INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`,`icon`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
('ACH101', 'time_1', '启蒙笃行', 'time-1.svg', '开始学习之旅', 1, 1, 1, 30*60, 1, 1, 0),
('ACH102', 'time_2', '深耕不辍', 'time-2.svg', '', 1, 2, 1, 5*60*60, 2, 2, 0),
('ACH103', 'time_3', '笃信致远', 'time-3.svg', '', 1, 3, 1, 20*60*60, 3, 3, 0),
('ACH104', 'time_4', '厚德博学', 'time-4.svg', '', 1, 4, 1, 50*60*60, 4, 4, 0),
('ACH105', 'time_5', '信仰领航', 'time-5.svg', '', 1, 5, 1, 100*60*60, 5, 5, 0);

INSERT INTO `tb_resource_permission` (id, resource_type, resource_id, dept_id, role_id, can_read, can_write, can_execute, creator, create_time) VALUES
('perm_achievement_101', 6, 'ACH101', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_102', 6, 'ACH102', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_103', 6, 'ACH103', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_104', 6, 'ACH104', NULL, NULL, 1, 0, 0, '1', now()),
('perm_achievement_105', 6, 'ACH105', NULL, NULL, 1, 0, 0, '1', now());
