-- 员工档案「岗位 / 职级」字典初始数据(幂等:已存在同 DictType+DictCode 则跳过) -- dictType: employee_position / employee_job_level -- MySQL 5.7+ / 8.0 SET NAMES utf8mb4; -- ========== 岗位 employee_position ========== INSERT INTO `t_dict_type` (`DictType`, `Remark`, `TypeSort`, `IsDeleted`, `CreateUserId`) SELECT 'employee_position', '员工岗位', 0, 0, 0 FROM DUAL WHERE NOT EXISTS ( SELECT 1 FROM `t_dict_type` WHERE `DictType` = 'employee_position' AND `IsDeleted` = 0 ); INSERT INTO `t_dict` (`DictType`, `DictSort`, `DictCode`, `DictName`, `IsDeleted`, `CreateUserId`) SELECT v.`DictType`, v.`DictSort`, v.`DictCode`, v.`DictName`, 0, 0 FROM ( SELECT 'employee_position' AS DictType, 1 AS DictSort, 'generalManager' AS DictCode, '总经理' AS DictName UNION ALL SELECT 'employee_position', 2, 'deputyGeneralManager', '副总经理' UNION ALL SELECT 'employee_position', 3, 'logisticsAdvisor', '物流顾问' UNION ALL SELECT 'employee_position', 4, 'csManager', '客服主管' UNION ALL SELECT 'employee_position', 5, 'csSpecialist', '客服专员' UNION ALL SELECT 'employee_position', 6, 'opsManager', '运营经理' UNION ALL SELECT 'employee_position', 7, 'opsSpecialist', '运营专员' UNION ALL SELECT 'employee_position', 8, 'financeManager', '财务经理' UNION ALL SELECT 'employee_position', 9, 'financeSpecialist', '财务专员' UNION ALL SELECT 'employee_position', 10, 'warehouseManager', '仓储主管' UNION ALL SELECT 'employee_position', 11, 'warehouseClerk', '仓管员' UNION ALL SELECT 'employee_position', 12, 'customsSpecialist', '关务专员' UNION ALL SELECT 'employee_position', 13, 'productManager', '产品经理' UNION ALL SELECT 'employee_position', 14, 'techEngineer', '技术工程师' UNION ALL SELECT 'employee_position', 15, 'hrAdmin', '人事行政' UNION ALL SELECT 'employee_position', 16, 'marketingSpecialist', '市场专员' UNION ALL SELECT 'employee_position', 17, 'dispatcher', '调度员' ) AS v WHERE NOT EXISTS ( SELECT 1 FROM `t_dict` d WHERE d.`DictType` = v.`DictType` AND d.`DictCode` = v.`DictCode` AND d.`IsDeleted` = 0 ); UPDATE `t_dict` SET `IsDeleted` = 1, `UpdateTime` = NOW() WHERE `DictType` = 'employee_position' AND `DictCode` IN ( 'salesDirector', 'salesManager', 'salesSpecialist', 'logisticsAdvisorDirector', 'logisticsAdvisorManager' ) AND `IsDeleted` = 0; -- ========== 职级 employee_job_level(一级~五级) ========== INSERT INTO `t_dict_type` (`DictType`, `Remark`, `TypeSort`, `IsDeleted`, `CreateUserId`) SELECT 'employee_job_level', '员工职级', 0, 0, 0 FROM DUAL WHERE NOT EXISTS ( SELECT 1 FROM `t_dict_type` WHERE `DictType` = 'employee_job_level' AND `IsDeleted` = 0 ); INSERT INTO `t_dict` (`DictType`, `DictSort`, `DictCode`, `DictName`, `IsDeleted`, `CreateUserId`) SELECT v.`DictType`, v.`DictSort`, v.`DictCode`, v.`DictName`, 0, 0 FROM ( SELECT 'employee_job_level' AS DictType, 1 AS DictSort, '1' AS DictCode, '一级' AS DictName UNION ALL SELECT 'employee_job_level', 2, '2', '二级' UNION ALL SELECT 'employee_job_level', 3, '3', '三级' UNION ALL SELECT 'employee_job_level', 4, '4', '四级' UNION ALL SELECT 'employee_job_level', 5, '5', '五级' ) AS v WHERE NOT EXISTS ( SELECT 1 FROM `t_dict` d WHERE d.`DictType` = v.`DictType` AND d.`DictCode` = v.`DictCode` AND d.`IsDeleted` = 0 );