-- ------------------------------------------------------------
-- 学生选课管理系统 - 角色、菜单与权限初始化脚本
-- 依赖基础库：RuoYi-Vue 3.9.0（ry_20250522.sql）
-- ------------------------------------------------------------

-- 1. 菜单目录与页面
INSERT INTO sys_menu VALUES('2000', '选课管理', '0', '5', 'education', NULL, '', '', 1, 0, 'M', '0', '0', '', 'education', 'admin', SYSDATE(), '', NULL, '学生选课管理根目录');

INSERT INTO sys_menu VALUES('2001', '学生档案', '2000', '1', 'student', 'education/student/index', '', 'EducationStudent', 1, 0, 'C', '0', '0', 'education:student:list', 'peoples', 'admin', SYSDATE(), '', NULL, '学生档案管理');
INSERT INTO sys_menu VALUES('2002', '教师档案', '2000', '2', 'teacher', 'education/teacher/index', '', 'EducationTeacher', 1, 0, 'C', '0', '0', 'education:teacher:list', 'user', 'admin', SYSDATE(), '', NULL, '教师档案管理');
INSERT INTO sys_menu VALUES('2003', '课程信息', '2000', '3', 'course', 'education/course/index', '', 'EducationCourse', 1, 0, 'C', '0', '0', 'education:course:list', 'education', 'admin', SYSDATE(), '', NULL, '课程基础信息');
INSERT INTO sys_menu VALUES('2004', '学期设置', '2000', '4', 'semester', 'education/semester/index', '', 'EducationSemester', 1, 0, 'C', '0', '0', 'education:semester:list', 'calendar', 'admin', SYSDATE(), '', NULL, '学期与选课窗口');
INSERT INTO sys_menu VALUES('2005', '开课计划', '2000', '5', 'courseClass', 'education/courseClass/index', '', 'EducationCourseClass', 1, 0, 'C', '0', '0', 'education:courseClass:list', 'schedule', 'admin', SYSDATE(), '', NULL, '开课及排课管理');
INSERT INTO sys_menu VALUES('2006', '选课中心', '2000', '6', 'center', 'education/enroll/center', '', 'EducationCenter', 1, 0, 'C', '0', '0', 'education:center:list', 'shopping-cart', 'admin', SYSDATE(), '', NULL, '学生在线选课门户');
INSERT INTO sys_menu VALUES('2007', '选课结果', '2000', '7', 'result', 'education/enroll/result', '', 'EducationResult', 1, 0, 'C', '0', '0', 'education:enroll:list', 'list', 'admin', SYSDATE(), '', NULL, '选课结果统计');
INSERT INTO sys_menu VALUES('2008', '成绩登记', '2000', '8', 'grade', 'education/grade/index', '', 'EducationGrade', 1, 0, 'C', '0', '0', 'education:grade:list', 'edit', 'admin', SYSDATE(), '', NULL, '教师成绩录入');

-- 2. 按钮权限
-- 学生档案
INSERT INTO sys_menu VALUES('2101', '学生查询', '2001', '1', '', '', '', '', 1, 0, 'F', '0', '0', 'education:student:query', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2102', '学生新增', '2001', '2', '', '', '', '', 1, 0, 'F', '0', '0', 'education:student:add', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2103', '学生修改', '2001', '3', '', '', '', '', 1, 0, 'F', '0', '0', 'education:student:edit', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2104', '学生删除', '2001', '4', '', '', '', '', 1, 0, 'F', '0', '0', 'education:student:remove', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2105', '学生导出', '2001', '5', '', '', '', '', 1, 0, 'F', '0', '0', 'education:student:export', '#', 'admin', SYSDATE(), '', NULL, '');

-- 教师档案
INSERT INTO sys_menu VALUES('2111', '教师查询', '2002', '1', '', '', '', '', 1, 0, 'F', '0', '0', 'education:teacher:query', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2112', '教师新增', '2002', '2', '', '', '', '', 1, 0, 'F', '0', '0', 'education:teacher:add', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2113', '教师修改', '2002', '3', '', '', '', '', 1, 0, 'F', '0', '0', 'education:teacher:edit', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2114', '教师删除', '2002', '4', '', '', '', '', 1, 0, 'F', '0', '0', 'education:teacher:remove', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2115', '教师导出', '2002', '5', '', '', '', '', 1, 0, 'F', '0', '0', 'education:teacher:export', '#', 'admin', SYSDATE(), '', NULL, '');

-- 课程信息
INSERT INTO sys_menu VALUES('2121', '课程查询', '2003', '1', '', '', '', '', 1, 0, 'F', '0', '0', 'education:course:query', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2122', '课程新增', '2003', '2', '', '', '', '', 1, 0, 'F', '0', '0', 'education:course:add', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2123', '课程修改', '2003', '3', '', '', '', '', 1, 0, 'F', '0', '0', 'education:course:edit', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2124', '课程删除', '2003', '4', '', '', '', '', 1, 0, 'F', '0', '0', 'education:course:remove', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2125', '课程导出', '2003', '5', '', '', '', '', 1, 0, 'F', '0', '0', 'education:course:export', '#', 'admin', SYSDATE(), '', NULL, '');

-- 学期设置
INSERT INTO sys_menu VALUES('2131', '学期查询', '2004', '1', '', '', '', '', 1, 0, 'F', '0', '0', 'education:semester:query', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2132', '学期新增', '2004', '2', '', '', '', '', 1, 0, 'F', '0', '0', 'education:semester:add', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2133', '学期修改', '2004', '3', '', '', '', '', 1, 0, 'F', '0', '0', 'education:semester:edit', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2134', '学期删除', '2004', '4', '', '', '', '', 1, 0, 'F', '0', '0', 'education:semester:remove', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2135', '学期发布', '2004', '5', '', '', '', '', 1, 0, 'F', '0', '0', 'education:semester:publish', '#', 'admin', SYSDATE(), '', NULL, '');

-- 开课计划
INSERT INTO sys_menu VALUES('2141', '计划查询', '2005', '1', '', '', '', '', 1, 0, 'F', '0', '0', 'education:courseClass:query', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2142', '计划新增', '2005', '2', '', '', '', '', 1, 0, 'F', '0', '0', 'education:courseClass:add', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2143', '计划修改', '2005', '3', '', '', '', '', 1, 0, 'F', '0', '0', 'education:courseClass:edit', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2144', '计划删除', '2005', '4', '', '', '', '', 1, 0, 'F', '0', '0', 'education:courseClass:remove', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2145', '计划发布', '2005', '5', '', '', '', '', 1, 0, 'F', '0', '0', 'education:courseClass:publish', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2146', '容量调整', '2005', '6', '', '', '', '', 1, 0, 'F', '0', '0', 'education:courseClass:capacity', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2147', '计划导出', '2005', '7', '', '', '', '', 1, 0, 'F', '0', '0', 'education:courseClass:export', '#', 'admin', SYSDATE(), '', NULL, '');

-- 选课中心
INSERT INTO sys_menu VALUES('2151', '课程检索', '2006', '1', '', '', '', '', 1, 0, 'F', '0', '0', 'education:center:query', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2152', '选课提交', '2006', '2', '', '', '', '', 1, 0, 'F', '0', '0', 'education:center:select', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2153', '退课申请', '2006', '3', '', '', '', '', 1, 0, 'F', '0', '0', 'education:center:drop', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2154', '选课锁定', '2006', '4', '', '', '', '', 1, 0, 'F', '0', '0', 'education:center:lock', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2155', '选课导出', '2006', '5', '', '', '', '', 1, 0, 'F', '0', '0', 'education:center:export', '#', 'admin', SYSDATE(), '', NULL, '');

-- 选课结果
INSERT INTO sys_menu VALUES('2156', '结果查询', '2007', '1', '', '', '', '', 1, 0, 'F', '0', '0', 'education:enroll:query', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2157', '结果导出', '2007', '2', '', '', '', '', 1, 0, 'F', '0', '0', 'education:enroll:export', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2158', '手动调整', '2007', '3', '', '', '', '', 1, 0, 'F', '0', '0', 'education:enroll:adjust', '#', 'admin', SYSDATE(), '', NULL, '');

-- 成绩登记
INSERT INTO sys_menu VALUES('2161', '成绩查询', '2008', '1', '', '', '', '', 1, 0, 'F', '0', '0', 'education:grade:query', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2162', '成绩录入', '2008', '2', '', '', '', '', 1, 0, 'F', '0', '0', 'education:grade:edit', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2163', '成绩导入', '2008', '3', '', '', '', '', 1, 0, 'F', '0', '0', 'education:grade:import', '#', 'admin', SYSDATE(), '', NULL, '');
INSERT INTO sys_menu VALUES('2164', '成绩导出', '2008', '4', '', '', '', '', 1, 0, 'F', '0', '0', 'education:grade:export', '#', 'admin', SYSDATE(), '', NULL, '');

-- 3. 角色定义
INSERT INTO sys_role VALUES('3', '教务管理员', 'edu_admin', 3, '1', 1, 1, '0', '0', 'admin', SYSDATE(), '', NULL, '负责整体选课业务');
INSERT INTO sys_role VALUES('4', '教师角色', 'teacher', 4, '5', 1, 1, '0', '0', 'admin', SYSDATE(), '', NULL, '授课老师使用');
INSERT INTO sys_role VALUES('5', '学生角色', 'student', 5, '5', 1, 1, '0', '0', 'admin', SYSDATE(), '', NULL, '学生选课登录');
INSERT INTO sys_role VALUES('6', '辅导员', 'counselor', 6, '4', 1, 1, '0', '0', 'admin', SYSDATE(), '', NULL, '学生事务辅导员');

-- 4. 角色与部门（示例绑定）
INSERT INTO sys_role_dept VALUES('3', '100');
INSERT INTO sys_role_dept VALUES('4', '103');
INSERT INTO sys_role_dept VALUES('5', '103');
INSERT INTO sys_role_dept VALUES('6', '103');

-- 5. 角色菜单授权
-- 超级管理员追加新菜单
INSERT INTO sys_role_menu (role_id, menu_id)
SELECT 1, menu_id FROM sys_menu WHERE menu_id BETWEEN 2000 AND 2164
ON DUPLICATE KEY UPDATE menu_id = VALUES(menu_id);

-- 教务管理员拥有全部选课功能
INSERT INTO sys_role_menu (role_id, menu_id)
SELECT 3, menu_id FROM sys_menu WHERE menu_id BETWEEN 2000 AND 2164
ON DUPLICATE KEY UPDATE menu_id = VALUES(menu_id);

-- 教师角色
INSERT INTO sys_role_menu VALUES ('4', '2000');
INSERT INTO sys_role_menu VALUES ('4', '2003');
INSERT INTO sys_role_menu VALUES ('4', '2004');
INSERT INTO sys_role_menu VALUES ('4', '2005');
INSERT INTO sys_role_menu VALUES ('4', '2007');
INSERT INTO sys_role_menu VALUES ('4', '2008');
INSERT INTO sys_role_menu VALUES ('4', '2121');
INSERT INTO sys_role_menu VALUES ('4', '2131');
INSERT INTO sys_role_menu VALUES ('4', '2141');
INSERT INTO sys_role_menu VALUES ('4', '2147');
INSERT INTO sys_role_menu VALUES ('4', '2156');
INSERT INTO sys_role_menu VALUES ('4', '2157');
INSERT INTO sys_role_menu VALUES ('4', '2161');
INSERT INTO sys_role_menu VALUES ('4', '2162');
INSERT INTO sys_role_menu VALUES ('4', '2164');

-- 学生角色
INSERT INTO sys_role_menu VALUES ('5', '2000');
INSERT INTO sys_role_menu VALUES ('5', '2006');
INSERT INTO sys_role_menu VALUES ('5', '2007');
INSERT INTO sys_role_menu VALUES ('5', '2151');
INSERT INTO sys_role_menu VALUES ('5', '2152');
INSERT INTO sys_role_menu VALUES ('5', '2153');
INSERT INTO sys_role_menu VALUES ('5', '2156');

-- 辅导员角色
INSERT INTO sys_role_menu VALUES ('6', '2000');
INSERT INTO sys_role_menu VALUES ('6', '2001');
INSERT INTO sys_role_menu VALUES ('6', '2006');
INSERT INTO sys_role_menu VALUES ('6', '2007');
INSERT INTO sys_role_menu VALUES ('6', '2101');
INSERT INTO sys_role_menu VALUES ('6', '2103');
INSERT INTO sys_role_menu VALUES ('6', '2105');
INSERT INTO sys_role_menu VALUES ('6', '2151');
INSERT INTO sys_role_menu VALUES ('6', '2156');
INSERT INTO sys_role_menu VALUES ('6', '2157');
