-- ============================================================
-- 湛江市智慧人社运营运维（2025-2027年）项目
-- 就业一湛通服务平台 - 见习人员管理 字典数据初始化SQL
--
-- 说明：初始化见习人员大类标签、小类标签和自定义标签字典
-- 注意：见习人员从重点关注人员中独立出来，标签体系单独管理
-- 达梦数据库兼容（不加反引号，使用 FROM DUAL）
-- 创建日期：2026-06-04
-- ============================================================

-- ============================================================
-- 1. 初始化字典：见习人员大类标签 (internship_major_tag)
--    见习人员的大类标签固定为"见习人员"
-- ============================================================
INSERT INTO sys_dict (id, dict_name, dict_code, description, del_flag, create_by, create_time, update_by, update_time, type)
SELECT '178060500000003', '见习人员大类标签', 'internship_major_tag', '见习人员的大类标签', 0, 'admin', '2026-06-04 10:00:00', NULL, NULL, 0
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM sys_dict WHERE dict_code = 'internship_major_tag');

-- 字典项：见习人员
INSERT INTO sys_dict_item (id, dict_id, item_text, item_value, description, sort_order, status, create_by, create_time, update_by, update_time)
SELECT '178060500000013', d.id, '见习人员', '见习人员', '见习人员大类', 1, 1, 'admin', '2026-06-04 10:00:00', NULL, NULL
FROM sys_dict d WHERE d.dict_code = 'internship_major_tag' AND d.del_flag = 0
AND NOT EXISTS (SELECT 1 FROM sys_dict_item si WHERE si.dict_id = d.id AND si.item_value = '见习人员');

-- ============================================================
-- 2. 初始化字典：见习人员小类标签 (internship_minor_tag)
--    包含：离校2年内未就业高校毕业生、16-24岁失业青年
-- ============================================================
INSERT INTO sys_dict (id, dict_name, dict_code, description, del_flag, create_by, create_time, update_by, update_time, type)
SELECT '178060500000001', '见习人员小类标签', 'internship_minor_tag', '见习人员的小类标签：离校2年内未就业高校毕业生、16-24岁失业青年', 0, 'admin', '2026-06-04 10:00:00', NULL, NULL, 0
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM sys_dict WHERE dict_code = 'internship_minor_tag');

-- 字典项：离校2年内未就业高校毕业生
INSERT INTO sys_dict_item (id, dict_id, item_text, item_value, description, sort_order, status, create_by, create_time, update_by, update_time)
SELECT '178060500000011', d.id, '离校2年内未就业高校毕业生', '离校2年内未就业高校毕业生', '见习人员小类', 1, 1, 'admin', '2026-06-04 10:00:00', NULL, NULL
FROM sys_dict d WHERE d.dict_code = 'internship_minor_tag' AND d.del_flag = 0
AND NOT EXISTS (SELECT 1 FROM sys_dict_item si WHERE si.dict_id = d.id AND si.item_value = '离校2年内未就业高校毕业生');

-- 字典项：16-24岁失业青年
INSERT INTO sys_dict_item (id, dict_id, item_text, item_value, description, sort_order, status, create_by, create_time, update_by, update_time)
SELECT '178060500000012', d.id, '16-24岁失业青年', '16-24岁失业青年', '见习人员小类', 2, 1, 'admin', '2026-06-04 10:00:00', NULL, NULL
FROM sys_dict d WHERE d.dict_code = 'internship_minor_tag' AND d.del_flag = 0
AND NOT EXISTS (SELECT 1 FROM sys_dict_item si WHERE si.dict_id = d.id AND si.item_value = '16-24岁失业青年');

-- ============================================================
-- 3. 初始化字典：见习人员自定义标签 (internship_custom_tag)
--    初始为空，由管理员在系统中动态添加
-- ============================================================
INSERT INTO sys_dict (id, dict_name, dict_code, description, del_flag, create_by, create_time, update_by, update_time, type)
SELECT '178060500000002', '见习人员自定义标签', 'internship_custom_tag', '见习人员的自定义标签，由管理员动态维护', 0, 'admin', '2026-06-04 10:00:00', NULL, NULL, 0
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM sys_dict WHERE dict_code = 'internship_custom_tag');
