feat: 添加学生个人中心页面和数据库备份功能
refactor(auth): 重构认证模块适配Bootstrap 5样式 feat(controller): 在登录响应中返回用户对象 feat(server): 添加学生个人中心路由 refactor(models): 重构学生和成绩模型结构 style: 更新登录和注册页面UI设计 chore: 添加数据库备份脚本和空备份文件
This commit is contained in:
177
database/backup_2025-12-21T14-30-37-825Z.sql
Normal file
177
database/backup_2025-12-21T14-30-37-825Z.sql
Normal file
@@ -0,0 +1,177 @@
|
||||
|
||||
|
||||
-- Table structure for table `classes`
|
||||
DROP TABLE IF EXISTS `classes`;
|
||||
CREATE TABLE `classes` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '班级ID',
|
||||
`class_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '班级名称',
|
||||
`grade` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '年级',
|
||||
`major` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '专业',
|
||||
`teacher_id` int DEFAULT NULL COMMENT '班主任ID',
|
||||
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_class_name` (`class_name`) USING BTREE,
|
||||
KEY `idx_teacher_id` (`teacher_id`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='班级表';
|
||||
|
||||
-- Dumping data for table `classes`
|
||||
INSERT INTO `classes` VALUES
|
||||
(1, '计算机2301', '2023', '计算机科学与技术', 2001, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)'),
|
||||
(2, '软件工程2302', '2023', '软件工程', 2002, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)');
|
||||
|
||||
|
||||
-- Table structure for table `courses`
|
||||
DROP TABLE IF EXISTS `courses`;
|
||||
CREATE TABLE `courses` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '课程ID',
|
||||
`course_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '课程代码',
|
||||
`course_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '课程名称',
|
||||
`credit` decimal(3,1) NOT NULL DEFAULT '2.0' COMMENT '学分',
|
||||
`teacher_id` int NOT NULL COMMENT '授课教师ID',
|
||||
`class_id` int NOT NULL COMMENT '授课班级ID',
|
||||
`semester` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '学期',
|
||||
`academic_year` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '学年',
|
||||
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE KEY `course_code` (`course_code`) USING BTREE,
|
||||
KEY `idx_course_code` (`course_code`) USING BTREE,
|
||||
KEY `idx_teacher_id` (`teacher_id`) USING BTREE,
|
||||
KEY `idx_class_id` (`class_id`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='课程表';
|
||||
|
||||
-- Dumping data for table `courses`
|
||||
INSERT INTO `courses` VALUES
|
||||
(1, 'CS101', '高级程序设计', '4.0', 2001, 1, NULL, NULL, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)'),
|
||||
(2, 'SE201', '软件工程导论', '3.0', 2002, 2, NULL, NULL, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)'),
|
||||
(3, 'MAT101', '高等数学', '5.0', 2003, 1, NULL, NULL, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)');
|
||||
|
||||
|
||||
-- Table structure for table `grades`
|
||||
DROP TABLE IF EXISTS `grades`;
|
||||
CREATE TABLE `grades` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '成绩ID',
|
||||
`student_id` int NOT NULL COMMENT '学生ID',
|
||||
`course_id` int NOT NULL COMMENT '课程ID',
|
||||
`usual_score` decimal(5,2) DEFAULT NULL COMMENT '平时成绩',
|
||||
`midterm_score` decimal(5,2) DEFAULT NULL COMMENT '期中成绩',
|
||||
`final_score` decimal(5,2) DEFAULT NULL COMMENT '期末成绩',
|
||||
`total_score` decimal(5,2) DEFAULT NULL COMMENT '总评成绩',
|
||||
`grade_point` decimal(3,2) DEFAULT NULL COMMENT '绩点',
|
||||
`grade_level` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '成绩等级(A/B/C/D/F)',
|
||||
`teacher_id` int NOT NULL COMMENT '录入教师ID',
|
||||
`remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '备注',
|
||||
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE KEY `uk_student_course` (`student_id`,`course_id`) USING BTREE,
|
||||
KEY `idx_student_id` (`student_id`) USING BTREE,
|
||||
KEY `idx_course_id` (`course_id`) USING BTREE,
|
||||
KEY `idx_teacher_id` (`teacher_id`) USING BTREE,
|
||||
KEY `idx_total_score` (`total_score`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='成绩表';
|
||||
|
||||
-- Dumping data for table `grades`
|
||||
INSERT INTO `grades` VALUES
|
||||
(1, 3001, 1, '90.00', '85.00', '88.00', '87.70', '3.00', NULL, 2001, NULL, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)'),
|
||||
(2, 3001, 3, '80.00', '75.00', '82.00', '79.30', '2.00', NULL, 2003, NULL, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)'),
|
||||
(3, 3002, 1, '95.00', '92.00', '94.00', '93.70', '4.00', NULL, 2001, NULL, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)'),
|
||||
(4, 3003, 2, '88.00', '80.00', '85.00', '84.40', '3.00', NULL, 2002, NULL, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)');
|
||||
|
||||
|
||||
-- Table structure for table `operation_logs`
|
||||
DROP TABLE IF EXISTS `operation_logs`;
|
||||
CREATE TABLE `operation_logs` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '日志ID',
|
||||
`user_id` int NOT NULL COMMENT '操作用户ID',
|
||||
`operation_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '操作类型',
|
||||
`operation_target` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '操作目标',
|
||||
`operation_details` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '操作详情',
|
||||
`ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'IP地址',
|
||||
`user_agent` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '用户代理',
|
||||
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '操作时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_user_id` (`user_id`) USING BTREE,
|
||||
KEY `idx_operation_type` (`operation_type`) USING BTREE,
|
||||
KEY `idx_created_at` (`created_at`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='操作日志表';
|
||||
|
||||
|
||||
-- Table structure for table `scores`
|
||||
DROP TABLE IF EXISTS `scores`;
|
||||
CREATE TABLE `scores` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '成绩记录ID',
|
||||
`student_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '学生ID',
|
||||
`course` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '课程名称',
|
||||
`score` decimal(5,2) NOT NULL COMMENT '成绩',
|
||||
`teacher_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '教师ID',
|
||||
`class` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '班级',
|
||||
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_student_id` (`student_id`) USING BTREE,
|
||||
KEY `idx_teacher_id` (`teacher_id`) USING BTREE,
|
||||
KEY `idx_class` (`class`) USING BTREE,
|
||||
CONSTRAINT `scores_ibfk_1` FOREIGN KEY (`student_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT,
|
||||
CONSTRAINT `scores_ibfk_2` FOREIGN KEY (`teacher_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT,
|
||||
CONSTRAINT `scores_chk_1` CHECK (((`score` >= 0) and (`score` <= 100)))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='成绩记录表';
|
||||
|
||||
|
||||
-- Table structure for table `sessions`
|
||||
DROP TABLE IF EXISTS `sessions`;
|
||||
CREATE TABLE `sessions` (
|
||||
`session_id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
|
||||
`expires` int unsigned NOT NULL,
|
||||
`data` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
|
||||
PRIMARY KEY (`session_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;
|
||||
|
||||
-- Dumping data for table `sessions`
|
||||
INSERT INTO `sessions` VALUES
|
||||
('KY6QaavAiws7rkdEBFIFDoHefl2bxzlI', 1766334525, '{"cookie":{"originalMaxAge":86400000,"expires":"2025-12-21T16:28:44.650Z","secure":false,"httpOnly":true,"path":"/"},"user":{"id":"teststudent","name":"????","role":"student","class":"2023?1?"}}'),
|
||||
('KaDFs4HogLmkjS0HAs6qki6g2FmE3sTL', 1766334465, '{"cookie":{"originalMaxAge":86400000,"expires":"2025-12-21T16:27:45.314Z","secure":false,"httpOnly":true,"path":"/"},"user":{"id":"teststudent","name":"????","role":"student","class":"2023?1?"}}'),
|
||||
('P-_AKfysnsUwA6PypoYdyXCxa-_8TiCE', 1766413502, '{"cookie":{"originalMaxAge":86400000,"expires":"2025-12-22T14:25:01.323Z","secure":false,"httpOnly":true,"path":"/"},"user":{"id":"3001","name":"陈同学","role":"student","class":"计算机2301","studentInfo":{"id":"3001","name":"陈同学","class":"计算机2301"}}}'),
|
||||
('QAhXDQ1FOlhU6RhaFOm3ghRtLOW4hBTd', 1766334812, '{"cookie":{"originalMaxAge":86400000,"expires":"2025-12-21T16:33:31.987Z","secure":false,"httpOnly":true,"path":"/"},"user":{"id":"teststudent","name":"????","role":"student","class":"2023?1?"}}'),
|
||||
('SAuQyktAI9gAHpXbjARpe-9BL42pDRiV', 1766334764, '{"cookie":{"originalMaxAge":86400000,"expires":"2025-12-21T16:32:43.695Z","secure":false,"httpOnly":true,"path":"/"},"user":{"id":"teststudent","name":"????","role":"student","class":"2023?1?"}}'),
|
||||
('XduN1lYhGPeIaLTHbLTNVnTCBtKUCkJR', 1766334689, '{"cookie":{"originalMaxAge":86400000,"expires":"2025-12-21T16:31:28.994Z","secure":false,"httpOnly":true,"path":"/"},"user":{"id":"teststudent","name":"????","role":"student","class":"2023?1?"}}'),
|
||||
('Y59PFvvqK7M0DKZshc6ONTmFQjzGyMmV', 1766334426, '{"cookie":{"originalMaxAge":86400000,"expires":"2025-12-21T16:27:05.673Z","secure":false,"httpOnly":true,"path":"/"},"user":{"id":"teststudent","name":"????","role":"student","class":"2023?1?"}}'),
|
||||
('rlscT2Pi2EAyLXHs1CNXyQmNSiW8vEo4', 1766334271, '{"cookie":{"originalMaxAge":86400000,"expires":"2025-12-21T16:24:30.682Z","secure":false,"httpOnly":true,"path":"/"},"user":{"id":"teststudent","name":"????","role":"student","class":"2023?1?"}}'),
|
||||
('rsaOCJRjYQLPtUWlDmUFJgWcCYZbOCgJ', 1766410574, '{"cookie":{"originalMaxAge":86400000,"expires":"2025-12-21T15:54:39.935Z","secure":false,"httpOnly":true,"path":"/"},"user":{"id":"123","name":"经济局","role":"student","class":"123"}}'),
|
||||
('wXxRpNTGY0wqLaHsebSAsw1I6Pb7Ed6w', 1766410584, '{"cookie":{"originalMaxAge":86400000,"expires":"2025-12-22T13:35:43.191Z","secure":false,"httpOnly":true,"path":"/"},"user":{"id":"567","name":"急急急","role":"teacher","class":"567"}}');
|
||||
|
||||
|
||||
-- Table structure for table `students`
|
||||
DROP TABLE IF EXISTS `students`;
|
||||
CREATE TABLE `students` (
|
||||
`id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '学生ID(与users表id一致)',
|
||||
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '姓名',
|
||||
`class` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '班级',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
CONSTRAINT `students_ibfk_1` FOREIGN KEY (`id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='学生详细信息表';
|
||||
|
||||
-- Dumping data for table `students`
|
||||
INSERT INTO `students` VALUES
|
||||
('3001', '陈同学', '计算机2301'),
|
||||
('3002', '林同学', '计算机2301'),
|
||||
('3003', '黄同学', '软件工程2302'),
|
||||
('3004', '吴同学', '软件工程2302');
|
||||
|
||||
|
||||
-- Table structure for table `users`
|
||||
DROP TABLE IF EXISTS `users`;
|
||||
CREATE TABLE `users` (
|
||||
`id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '用户ID(学号/工号)',
|
||||
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '姓名',
|
||||
`password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '密码(bcrypt加密)',
|
||||
`role` enum('student','teacher','admin') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '角色',
|
||||
`class` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '班级(学生和教师需要,管理员为NULL)',
|
||||
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_role` (`role`) USING BTREE,
|
||||
KEY `idx_class` (`class`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='用户表';
|
||||
|
||||
-- Dumping data for table `users`
|
||||
Reference in New Issue
Block a user