Java教务管理系统

这篇具有很好参考价值的文章主要介绍了Java教务管理系统。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

介绍:

本项目采用MVC框架,对代码分层,分为Dao,Pojo,Service,Utils,View, swing的视图设计上我是参考了其他人的设置,功能上全由个人编写,第一版的实现可能会由有很多不足的地方,欢迎大家评论区讨论。

效果展示:

学生端

登陆功能,图片大家可以随意更换

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

首页

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

课程查询

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

选课系统

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

成绩查询

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

通知管理

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

个人中心

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

教师端

首页

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

教学安排

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

成绩录入

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

个人中心

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

管理员端

首页

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

老师管理

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

学生管理

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

通知管理

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

个人中心

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

技术实现:

swing ,maven ,mybatis

主要功能: 

  1. 不同用户的登录

  1. 用户菜单的绘制

  1. 学生用户选课功能,查看课程功能,成绩查询功能,个人信息展示功能

  1. 教师用户成绩录入功能,查看授课功能,个人信息展示功能

  1. 管理员用户管理学生功能,管理教师功能,管理通知功能,个人信息展示功能

数据库代码:

/*
 Navicat Premium Data Transfer

 Source Server         : mysql
 Source Server Type    : MySQL
 Source Server Version : 80030 (8.0.30)
 Source Host           : localhost:3306
 Source Schema         : EMS

 Target Server Type    : MySQL
 Target Server Version : 80030 (8.0.30)
 File Encoding         : 65001

 Date: 10/01/2023 22:19:02
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for academy
-- ----------------------------
DROP TABLE IF EXISTS `academy`;
CREATE TABLE `academy` (
  `a_id` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `a_name` char(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`a_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of academy
-- ----------------------------
BEGIN;
INSERT INTO `academy` (`a_id`, `a_name`) VALUES ('a_001', '数学与大数据学院');
INSERT INTO `academy` (`a_id`, `a_name`) VALUES ('a_002', '经济管理学院');
INSERT INTO `academy` (`a_id`, `a_name`) VALUES ('a_003', '社会管理学院');
INSERT INTO `academy` (`a_id`, `a_name`) VALUES ('a_004', '马克思主义学院');
INSERT INTO `academy` (`a_id`, `a_name`) VALUES ('a_005', '法学与社会学学院');
INSERT INTO `academy` (`a_id`, `a_name`) VALUES ('a_006', '计算机科学学院');
INSERT INTO `academy` (`a_id`, `a_name`) VALUES ('a_007', '工业设计和陶瓷学院');
INSERT INTO `academy` (`a_id`, `a_name`) VALUES ('a_008', '计算机信息学院');
INSERT INTO `academy` (`a_id`, `a_name`) VALUES ('a_009', '生命科学学院');
INSERT INTO `academy` (`a_id`, `a_name`) VALUES ('a_010', '艺术和设计学院');
INSERT INTO `academy` (`a_id`, `a_name`) VALUES ('a_011', '人文科学学院');
COMMIT;

-- ----------------------------
-- Table structure for class
-- ----------------------------
DROP TABLE IF EXISTS `class`;
CREATE TABLE `class` (
  `c_id` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `c_name` char(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `c_num` int DEFAULT NULL,
  `d_id` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`c_id`) USING BTREE,
  KEY `d.id` (`d_id`),
  CONSTRAINT `d.id` FOREIGN KEY (`d_id`) REFERENCES `department` (`d_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of class
-- ----------------------------
BEGIN;
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c101', '数创1', 30, 'd_01');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c102', '数传2', 30, 'd_01');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c103', '数创2', 30, 'd_01');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c104', '大数据技术1', 30, 'd_02');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c105', '大数据技术2', 30, 'd_02');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c106', '数师1', 30, 'd_03');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c107', '数师2', 30, 'd_03');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c108', '会计2', 30, 'd_04');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c109', '会计2', 30, 'd_04');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c110', '法学1', 30, 'd_05');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c111', '计科1', 30, 'd_06');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c112', '计科2', 30, 'd_06');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c113', '工业设计1', 30, 'd_07');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c114', '工业设计2', 30, 'd_07');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c115', '马哲1', 30, 'd_08');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c116', '马应1', 30, 'd_09');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c117', '法应1', 30, 'd_10');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c118', '律政1', 30, 'd_11');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c119', '计创2', 30, 'd_12');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c120', '计应1', 30, 'd_13');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c121', '工应1', 30, 'd_14');
INSERT INTO `class` (`c_id`, `c_name`, `c_num`, `d_id`) VALUES ('c122', '数媒1', 30, 'd_15');
COMMIT;

-- ----------------------------
-- Table structure for course
-- ----------------------------
DROP TABLE IF EXISTS `course`;
CREATE TABLE `course` (
  `course_id` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `curse_name` char(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `course_type` char(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `course_credit` int DEFAULT NULL,
  PRIMARY KEY (`course_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of course
-- ----------------------------
BEGIN;
INSERT INTO `course` (`course_id`, `curse_name`, `course_type`, `course_credit`) VALUES ('c001', '高等数学', '必修', 4);
INSERT INTO `course` (`course_id`, `curse_name`, `course_type`, `course_credit`) VALUES ('c002', '大学英语', '必修', 4);
INSERT INTO `course` (`course_id`, `curse_name`, `course_type`, `course_credit`) VALUES ('c003', '数据结构', '必修', 3);
INSERT INTO `course` (`course_id`, `curse_name`, `course_type`, `course_credit`) VALUES ('c004', '代数方程', '必修', 2);
INSERT INTO `course` (`course_id`, `curse_name`, `course_type`, `course_credit`) VALUES ('c005', '线性代数', '必修', 3);
INSERT INTO `course` (`course_id`, `curse_name`, `course_type`, `course_credit`) VALUES ('c006', 'Java web', '必修', 2);
INSERT INTO `course` (`course_id`, `curse_name`, `course_type`, `course_credit`) VALUES ('c007', 'Python', '必修', 2);
INSERT INTO `course` (`course_id`, `curse_name`, `course_type`, `course_credit`) VALUES ('c008', 'C/C++', '必修', 2);
COMMIT;

-- ----------------------------
-- Table structure for course_plan
-- ----------------------------
DROP TABLE IF EXISTS `course_plan`;
CREATE TABLE `course_plan` (
  `cp_year` char(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `cp_class` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `course_id` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `cp_week` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`cp_year`,`cp_class`,`course_id`) USING BTREE,
  KEY `course.id` (`course_id`),
  CONSTRAINT `course.id` FOREIGN KEY (`course_id`) REFERENCES `course` (`course_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of course_plan
-- ----------------------------
BEGIN;
INSERT INTO `course_plan` (`cp_year`, `cp_class`, `course_id`, `cp_week`) VALUES ('2020-2021上', '10', 'c001', '18');
INSERT INTO `course_plan` (`cp_year`, `cp_class`, `course_id`, `cp_week`) VALUES ('2020-2021上', '10', 'c002', '8');
INSERT INTO `course_plan` (`cp_year`, `cp_class`, `course_id`, `cp_week`) VALUES ('2020-2021上', '10', 'c003', '18');
INSERT INTO `course_plan` (`cp_year`, `cp_class`, `course_id`, `cp_week`) VALUES ('2020-2021上', '10', 'c004', '9');
INSERT INTO `course_plan` (`cp_year`, `cp_class`, `course_id`, `cp_week`) VALUES ('2020-2021上', '10', 'c005', '10');
INSERT INTO `course_plan` (`cp_year`, `cp_class`, `course_id`, `cp_week`) VALUES ('2020-2021下', '10', 'c001', '8');
INSERT INTO `course_plan` (`cp_year`, `cp_class`, `course_id`, `cp_week`) VALUES ('2020-2021下', '10', 'c006', '12');
INSERT INTO `course_plan` (`cp_year`, `cp_class`, `course_id`, `cp_week`) VALUES ('2020-2021下', '10', 'c007', '12');
INSERT INTO `course_plan` (`cp_year`, `cp_class`, `course_id`, `cp_week`) VALUES ('2020-2021下', '10', 'c008', '8');
COMMIT;

-- ----------------------------
-- Table structure for department
-- ----------------------------
DROP TABLE IF EXISTS `department`;
CREATE TABLE `department` (
  `d_id` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `d_name` char(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `a_id` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`d_id`) USING BTREE,
  KEY `a.id` (`a_id`),
  CONSTRAINT `a.id` FOREIGN KEY (`a_id`) REFERENCES `academy` (`a_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of department
-- ----------------------------
BEGIN;
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_01', '数学与应用数学', 'a_001');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_02', '大数据技术', 'a_001');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_03', '数学师范', 'a_001');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_04', '会计', 'a_002');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_05', '人力资源管理', 'a_002');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_06', '社会人文', 'a_003');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_07', '社会学', 'a_003');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_08', '马克思主义哲学', 'a_004');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_09', '马克思主义应用学', 'a_004');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_10', '法学应用', 'a_005');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_11', '律政', 'a_005');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_12', '计算机科学', 'a_006');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_13', '计算机应用', 'a_006');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_14', '工业设计', 'a_007');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_15', '数字媒体', 'a_007');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_16', '人工智能', 'a_008');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_17', '信息技术应用', 'a_008');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_18', '网络安全', 'a_008');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_19', '生命研究学', 'a_009');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_20', '生命科学', 'a_009');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_21', '艺画应用', 'a_010');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_22', '艺术学', 'a_010');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_23', '人文教育', 'a_011');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_24', '教育学', 'a_011');
INSERT INTO `department` (`d_id`, `d_name`, `a_id`) VALUES ('d_25', '社会政治学', 'a_011');
COMMIT;

-- ----------------------------
-- Table structure for grade
-- ----------------------------
DROP TABLE IF EXISTS `grade`;
CREATE TABLE `grade` (
  `tc_id` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `s_id` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `g_ordinary` float DEFAULT NULL,
  `g_exam` float DEFAULT NULL,
  `g_final` float DEFAULT NULL,
  PRIMARY KEY (`tc_id`,`s_id`) USING BTREE,
  KEY `s.id_s` (`s_id`),
  CONSTRAINT `s.id_s` FOREIGN KEY (`s_id`) REFERENCES `student` (`s_id`),
  CONSTRAINT `tc.id_tc` FOREIGN KEY (`tc_id`) REFERENCES `teaching_class` (`tc_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of grade
-- ----------------------------
BEGIN;
INSERT INTO `grade` (`tc_id`, `s_id`, `g_ordinary`, `g_exam`, `g_final`) VALUES ('tc1001', '20220101', 42, 40, 82);
INSERT INTO `grade` (`tc_id`, `s_id`, `g_ordinary`, `g_exam`, `g_final`) VALUES ('tc1002', '20220115', 45, 50, 95);
COMMIT;

-- ----------------------------
-- Table structure for student
-- ----------------------------
DROP TABLE IF EXISTS `student`;
CREATE TABLE `student` (
  `s_id` char(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '学生学号',
  `s_name` char(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `s_sex` char(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `c_id` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`s_id`) USING BTREE,
  KEY `c.id` (`c_id`),
  CONSTRAINT `c.id` FOREIGN KEY (`c_id`) REFERENCES `class` (`c_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of student
-- ----------------------------
BEGIN;
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220101', '温如玉', '男', 'c101');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220102', '伍六七', '男', 'c101');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220103', '王法', '男', 'c101');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220104', '上官晴', '女', 'c102');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220105', '王琪', '女', 'c103');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220106', '张天赐', '男', 'c104');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220107', '张三', '男', 'c105');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220108', '李四', '男', 'c102');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220109', '诸葛慈', '女', 'c110');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220110', '练剑黄', '男', 'c111');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220111', '欧阳蓉儿', '女', 'c109');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220112', '唐三彩', '男', 'c116');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220113', '张艺得', '男', 'c113');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220114', '德古拉', '女', 'c102');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220115', '瑞克桑切斯', '男', 'c101');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220116', '莫蒂', '男', 'c101');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220117', '桑美', '女', 'c111');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220118', '杰瑞', '男', 'c122');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220119', '西米', '女', 'c111');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220120', '肖九', '男', 'c106');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220121', '六儿', '女', 'c107');
INSERT INTO `student` (`s_id`, `s_name`, `s_sex`, `c_id`) VALUES ('20220122', '李一', '男', 'c108');
COMMIT;

-- ----------------------------
-- Table structure for teacher
-- ----------------------------
DROP TABLE IF EXISTS `teacher`;
CREATE TABLE `teacher` (
  `t_id` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '老师账号',
  `t_name` char(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `t_sex` char(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`t_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of teacher
-- ----------------------------
BEGIN;
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101011', '东方芯源', '女');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101012', '小蝴蝶', '女');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101013', '天一案', '女');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101014', '麦克', '男');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101015', '闷油瓶', '男');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101016', '吴邪', '男');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101017', '风清扬', '男');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101018', '剑韭黄', '男');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101019', '黑棋', '女');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101020', 'Aniya', '女');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101021', '柒', '男');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101022', '小白', '女');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101023', '小黑', '女');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101024', '柯南', '男');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101025', '毛利小五郎', '男');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101026', '天下霸唱', '男');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101027', '黄大仙', '女');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101028', '狐仙儿', '女');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101029', '八重', '女');
INSERT INTO `teacher` (`t_id`, `t_name`, `t_sex`) VALUES ('101101030', '惊爆点', '男');
COMMIT;

-- ----------------------------
-- Table structure for teacher_techering_class
-- ----------------------------
DROP TABLE IF EXISTS `teacher_techering_class`;
CREATE TABLE `teacher_techering_class` (
  `t_id` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `tc_id` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  PRIMARY KEY (`t_id`,`tc_id`) USING BTREE,
  KEY `tc.id` (`tc_id`),
  CONSTRAINT `t.id_t` FOREIGN KEY (`t_id`) REFERENCES `teacher` (`t_id`),
  CONSTRAINT `tc.id_tclass` FOREIGN KEY (`tc_id`) REFERENCES `teaching_class` (`tc_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of teacher_techering_class
-- ----------------------------
BEGIN;
INSERT INTO `teacher_techering_class` (`t_id`, `tc_id`) VALUES ('101101020', 'tc1002');
INSERT INTO `teacher_techering_class` (`t_id`, `tc_id`) VALUES ('101101030', 'tc1003');
INSERT INTO `teacher_techering_class` (`t_id`, `tc_id`) VALUES ('101101011', 'tc1004');
INSERT INTO `teacher_techering_class` (`t_id`, `tc_id`) VALUES ('101101011', 'tc1005');
INSERT INTO `teacher_techering_class` (`t_id`, `tc_id`) VALUES ('101101023', 'tc1007');
INSERT INTO `teacher_techering_class` (`t_id`, `tc_id`) VALUES ('101101017', 'tc1010');
COMMIT;

-- ----------------------------
-- Table structure for teaching_class
-- ----------------------------
DROP TABLE IF EXISTS `teaching_class`;
CREATE TABLE `teaching_class` (
  `tc_id` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `tc_name` char(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `tc_num` int DEFAULT NULL,
  `tc_time` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `tc_point` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`tc_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of teaching_class
-- ----------------------------
BEGIN;
INSERT INTO `teaching_class` (`tc_id`, `tc_name`, `tc_num`, `tc_time`, `tc_point`) VALUES ('tc1001', '高数1班', 30, '1-2 ', 'A栋101');
INSERT INTO `teaching_class` (`tc_id`, `tc_name`, `tc_num`, `tc_time`, `tc_point`) VALUES ('tc1002', '大英1班', 30, '2-3', 'B栋102');
INSERT INTO `teaching_class` (`tc_id`, `tc_name`, `tc_num`, `tc_time`, `tc_point`) VALUES ('tc1003', ' Java web1班', 30, '1-3', 'C栋102');
INSERT INTO `teaching_class` (`tc_id`, `tc_name`, `tc_num`, `tc_time`, `tc_point`) VALUES ('tc1004', 'Python1班', 30, '2-3', 'B栋001');
INSERT INTO `teaching_class` (`tc_id`, `tc_name`, `tc_num`, `tc_time`, `tc_point`) VALUES ('tc1005', 'C1班', 30, '2-3', 'A栋102');
INSERT INTO `teaching_class` (`tc_id`, `tc_name`, `tc_num`, `tc_time`, `tc_point`) VALUES ('tc1006', '线性代数1班', 30, '2-3', 'C栋102');
INSERT INTO `teaching_class` (`tc_id`, `tc_name`, `tc_num`, `tc_time`, `tc_point`) VALUES ('tc1007', '代数1班', 30, '2-3', 'D栋122');
INSERT INTO `teaching_class` (`tc_id`, `tc_name`, `tc_num`, `tc_time`, `tc_point`) VALUES ('tc1008', '大英2班', 30, '1-2', 'B栋012');
INSERT INTO `teaching_class` (`tc_id`, `tc_name`, `tc_num`, `tc_time`, `tc_point`) VALUES ('tc1009', '大英3班', 30, '3-4', 'B栋100');
INSERT INTO `teaching_class` (`tc_id`, `tc_name`, `tc_num`, `tc_time`, `tc_point`) VALUES ('tc1010', '高数2班', 30, '3-5', 'A栋111');
COMMIT;

-- ----------------------------
-- Table structure for teaching_programme
-- ----------------------------
DROP TABLE IF EXISTS `teaching_programme`;
CREATE TABLE `teaching_programme` (
  `cp_year` char(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `cp_class` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `tc_id` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `course_id` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`cp_year`,`cp_class`,`tc_id`) USING BTREE,
  KEY `course.id_cp` (`course_id`),
  KEY `quote_course.plan` (`cp_year`,`cp_class`,`course_id`),
  KEY `quote_tc.id` (`tc_id`),
  CONSTRAINT `quote_course.plan` FOREIGN KEY (`cp_year`, `cp_class`, `course_id`) REFERENCES `course_plan` (`cp_year`, `cp_class`, `course_id`),
  CONSTRAINT `quote_tc.id` FOREIGN KEY (`tc_id`) REFERENCES `teaching_class` (`tc_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of teaching_programme
-- ----------------------------
BEGIN;
INSERT INTO `teaching_programme` (`cp_year`, `cp_class`, `tc_id`, `course_id`) VALUES ('2020-2021上', '10', 'tc1001', 'c001');
INSERT INTO `teaching_programme` (`cp_year`, `cp_class`, `tc_id`, `course_id`) VALUES ('2020-2021下', '10', 'tc1010', 'c001');
INSERT INTO `teaching_programme` (`cp_year`, `cp_class`, `tc_id`, `course_id`) VALUES ('2020-2021上', '10', 'tc1002', 'c002');
INSERT INTO `teaching_programme` (`cp_year`, `cp_class`, `tc_id`, `course_id`) VALUES ('2020-2021下', '10', 'tc1003', 'c006');
INSERT INTO `teaching_programme` (`cp_year`, `cp_class`, `tc_id`, `course_id`) VALUES ('2020-2021下', '10', 'tc1005', 'c008');
COMMIT;

-- ----------------------------
-- Table structure for thing
-- ----------------------------
DROP TABLE IF EXISTS `thing`;
CREATE TABLE `thing` (
  `thingtxt` text,
  `tine` datetime DEFAULT NULL,
  `id` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of thing
-- ----------------------------
BEGIN;
INSERT INTO `thing` (`thingtxt`, `tine`, `id`) VALUES ('2023年2月20正式开学', '2023-01-10 11:33:29', 1);
COMMIT;

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
  `u_id` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `u_pwd` char(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `u_status` char(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`u_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of user
-- ----------------------------
BEGIN;
INSERT INTO `user` (`u_id`, `u_pwd`, `u_status`) VALUES ('101101011', '000000', '老师');
INSERT INTO `user` (`u_id`, `u_pwd`, `u_status`) VALUES ('20220101', '123456', '学生');
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;

总体功能图:

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

总体流程图:

java教务系统,java,个人开发,maven,mybatis,intellij-idea,Powered by 金山文档

Maven设置:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>EMS</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>
    <!--    导入依赖-->
    <dependencies>
        <!--        mysql驱动-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.30</version>
        </dependency>
        <!--        mybatis驱动-->
        <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.5.7</version>
        </dependency>
        <!--        junit单元测试-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>

    </dependencies>
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                    <include>**/*.png</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>


</project>

Mybatis设置:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "https://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    <settings>
        <setting name="logImpl" value="STDOUT_LOGGING"/>
<!--        <setting name="mapUnderscoreToCamelCase" value="true"/>-->
    </settings>
    <environments default="development">
        <environment id="development">
            <transactionManager type="JDBC"/>
            <dataSource type="POOLED">
                <property name="driver" value="com.mysql.jdbc.Driver"/>
                <property name="url" value="jdbc:mysql://localhost:3306/EMS"/>
                <property name="username" value="root"/>
                <property name="password" value="你自己的密码"/>
            </dataSource>
        </environment>
    </environments>

    <mappers>
        <mapper resource="com/dwz/Dao/UserMapper.xml"></mapper>
        <mapper resource="com/dwz/Dao/StudentsMapper.xml"></mapper>
        <mapper resource="com/dwz/Dao/TeacherMapper.xml"></mapper>
    </mappers>

</configuration>

Dao层实现:

StudentMapper

package com.dwz.Dao;

import com.dwz.Pojo.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

public interface StudentMapper {
//    查询学生
    Student getStudents_s_id(String id);

//    获得学生信息
    List<Student> getStudentList();

//    获得学生的学年信息
    List<String> getCp_year();

//    获得授课id
    List<String> getTeachingClassId(Map<String,Object> map);

//    获得教师班级
    Teacher_class getTeacherclass1(String tc_id);

//    获得教师班级列表
    List<Teacher_class> getTeacherclass2(Map map);

//    获得课程信息
    List<Seclet_Course> getSelectCourse(String cp_year);

//    获得授课名字
    String getTeachingclassIdbyName(String tc_name);

//    增加选课记录
    boolean addCourse(@Param("s_id")String s_id,@Param("tc_name")String tc_name);

    /*
    * 获得成绩列表
    * */
    List<Grade> GetGradeList(Map<String,Object> map);

    /*
    * 通过成绩的tc_id查找这门课程的名字
    * */
    String GetCourseName(String tc_id);

    /*
    * 学生修改密码功能
    * */
    String GetOldPassword(String Sid);
    boolean UpdatePassword(@Param("newPassword") String newPassword, @Param("Sid") String id);

    /*
    * 获得学院名称
    * */
    String GetAcademyName(String ClassId);

    /*
    * 获得通知信息
    * */
    List<Thing> GetInform();

}

StudentMapper.xml

StudentMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dwz.Dao.StudentMapper">


    <select id="getStudents_s_id" resultMap="Studentmapper" parameterType="String">
        select EMS.student.s_id, EMS.student.c_id,
               EMS.student.s_name,EMS.student.s_sex,
               EMS.class.c_name
        from EMS.student join EMS.class on class.c_id = student.c_id
        where EMS.student.s_id = #{id}
    </select>
    <resultMap id="Studentmapper" type="com.dwz.Pojo.Student">
        <result column="c_name" property="c_id"></result>
    </resultMap>


    <select id="getStudentList" resultType="com.dwz.Pojo.Student">
        select *from EMS.student s
    </select>



    <select id="getCp_year" resultType="String">
        select distinct EMS.course_plan.cp_year from EMS.course_plan
    </select>


    <select id="getTeachingClassId" resultType="String" parameterType="map">
        SELECT EMS.grade_f.tc_id FROM EMS.grade_f,EMS.teaching_programme
        WHERE grade_f.tc_id = teaching_programme.tc_id
          AND cp_year = #{cp_year}
          AND s_id = #{s_id};
    </select>


    <select id="getTeacherclass1" resultMap="TeachingClassMapper" parameterType="String" >
        select EMS.teaching_programme.tc_id ,EMS.teaching_class.tc_name,
               EMS.teaching_class.tc_point,EMS.teaching_class.tc_time,
               EMS.teaching_class.tc_num ,EMS.course.curse_name
        from EMS.teaching_programme ,EMS.teaching_class, EMS.course
        where EMS.teaching_class.tc_id = EMS.teaching_programme.tc_id
        and EMS.teaching_programme.course_id = EMS.course.course_id
        and teaching_programme.tc_id = #{tc_id}
    </select>
    <resultMap id="TeachingClassMapper" type="com.dwz.Pojo.Teacher_class">
        <result column="tc_id" property="tc_id"/>
        <result column="tc_name" property="tc_name"/>
        <result column="curse_name" property="curse_name"/>
        <result column="tc_time" property="tc_time"/>
        <result column="tc_point" property="tc_point"/>
        <result column="tc_num" property="tc_num"/>
    </resultMap>
    <select id="getTeacherclass2" parameterType="map" resultMap="TeachingClassMapper">
        SELECT EMS.teaching_programme.tc_id,
               EMS.teaching_class.tc_name,
               EMS.course.curse_name,
               EMS.teaching_class.tc_time,
               EMS.teaching_class.tc_point,
               EMS.teaching_class.tc_num
        FROM EMS.teaching_class,EMS.teaching_programme,EMS.course
        WHERE teaching_class.tc_id = teaching_programme.tc_id
        AND
        teaching_programme.course_id = course.course_id
        AND
        <foreach collection="teachingClassIdList" item="teachingClassId" open="(" close=")" separator="or">
            teaching_programme.tc_id = #{teachingClassId}
        </foreach>
    </select>


    <select id="getSelectCourse" parameterType="String" resultMap="SelectCourse">
        select EMS.teaching_programme.cp_year AS cp_year,
               EMS.teaching_programme.cp_class AS cp_class,
               EMS.course.curse_name AS course_name,
               EMS.teaching_programme.tc_id AS tc_id,
               EMS.teaching_class.tc_name AS tc_name,
               EMS.course.course_credit AS course_credit,
               EMS.teacher.t_name AS t_name,
               EMS.teaching_class.tc_point AS tc_point,
               EMS.teaching_class.tc_time AS tc_time
        from ((((EMS.teaching_programme join EMS.teaching_class) join EMS.course) join EMS.teacher_techering_class) join EMS.teacher)
        where ((teaching_programme.tc_id = teaching_class.tc_id)
            and (teaching_programme.course_id = course.course_id)
            and (teaching_programme.tc_id = teacher_techering_class.tc_id)
            and (teacher_techering_class.t_id = EMS.teacher.t_id)
            and (course.course_type = '必修'))
            and (cp_year = #{cp_year})
    </select>
    <resultMap id="SelectCourse" type="com.dwz.Pojo.Seclet_Course">
        <result column="tc_name" property="teacherClass"/>
        <result column="course_credit" property="credit"/>
        <result column="t_name" property="teacherName"/>
        <result column="tc_time" property="courseTime"/>
        <result column="tc_point" property="coursePoint"/>
        <result column="course_name" property="courseName"/>
        <result column="cp_class" property="cpClass"/>
    </resultMap>


    <select id="getTeachingclassIdbyName" parameterType="String" resultType="String">
        SELECT EMS.teaching_class.tc_id FROM EMS.teaching_class WHERE tc_name = #{tc_name}
    </select>


    <insert id="addCourse" parameterType="String">
        INSERT INTO `EMS`.`grade_f` VALUES (#{tc_name},#{s_id},NULL,NULL,NULL)
    </insert>


    <select id="GetGradeList" resultMap="GradeMapper" parameterType="map">
        select `grade_f`.`s_id` AS `s_id`,
               `student`.`s_name` AS `s_name`,
               `course`.`curse_name` AS `course_name`,
               `grade_f`.`g_ps` AS `g_ps`,
               `grade_f`.`g_exam` AS `g_exam`,
               `grade_f`.`g_final` AS `g_final`,
               `teaching_programme`.`cp_year` AS `cp_year`
        from (((EMS.`grade_f` join EMS.`teaching_programme`) join EMS.`student`) join EMS.`course`)
        where ((`grade_f`.`s_id` = `student`.`s_id`) and (`grade_f`.`tc_id` = `teaching_programme`.`tc_id`)
            and (`course`.`course_id` = `teaching_programme`.`course_id`))
            and(grade_f.s_id = #{sid} AND cp_year = #{cpYear})
    </select>
    <resultMap id="GradeMapper" type="com.dwz.Pojo.Grade">
        <result column="s_id" property="s_id"/>
        <result column="s_name" property="s_name"/>
        <result column="course_name" property="course_name"/>
        <result column="g_ps" property="g_ps"/>
        <result column="g_exam" property="g_exam"/>
        <result column="g_final" property="g_final"/>
    </resultMap>



    <select id="GetCourseName" parameterType="String" resultType="String">
        SELECT curse_name
        FROM EMS.teaching_programme
                 JOIN EMS.grade_f ON teaching_programme.tc_id = grade_f.tc_id
                 JOIN EMS.student ON grade_f.s_id = student.s_id
                 JOIN EMS.course ON teaching_programme.course_id = course.course_id
        WHERE grade_f.tc_id = #{tc_id}
    </select>


    <select id="GetOldPassword" parameterType="String" resultType="String">
        select u_pwd from EMS.user where u_id = #{Sid}
    </select>


    <update id="UpdatePassword" parameterType="String">
        UPDATE EMS.user SET u_pwd = #{newPassword} WHERE u_id = #{Sid}
    </update>


    <select id="GetAcademyName" parameterType="String" resultType="String">
        SELECT academy.a_name
        FROM EMS.academy JOIN EMS.department ON academy.a_id = department.a_id
                     JOIN EMS.class ON class.d_id = department.d_id
        WHERE class.c_name = #{ClassId}
    </select>
    
    <select id="GetInform"  resultType="com.dwz.Pojo.Thing">
        select * from EMS.thing
    </select>
</mapper>

TeacherMapper

package com.dwz.Dao;

import com.dwz.Pojo.Grade;
import com.dwz.Pojo.Teacher;
import com.dwz.Pojo.TeacherPlan;
import com.dwz.Pojo.Teaching_programme;

import java.util.List;
import java.util.Map;

public interface TeacherMapper {
    /*
    * 通过id获得教师用户
    * */
    Teacher getTeacher(String t_id);
    /*
    * 获得教师列表
    * */
    List<Teacher> getTeacherList();
    /*
    * 获得教师课程安排
    * */
    List<TeacherPlan> getTeacherProgramme(Map<String,Object> map);
    /*
    * 成绩录入
    * */
    List<Grade> GetGradeByClass(String tc_name);

    /*
    * 更新成绩
    * */
    String getTeachingclassIdbyName(String tc_name);
    boolean UpdateGrade(Map<String,Object> map);


}

TeacherMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dwz.Dao.TeacherMapper">


    <select id="getTeacher" parameterType="String" resultType="com.dwz.Pojo.Teacher">
        select *from EMS.teacher t where t_id = #{t_id}
    </select>



    <select id="getTeacherList" resultType="com.dwz.Pojo.Teacher">
        select *from EMS.teacher t
    </select>



    <select id="getTeacherProgramme" parameterType="map" resultMap="GetTeacherProgrammeMapper">
        SELECT t_id,tc_name,tc_time,tc_point,cp_year FROM EMS.teacher_techering_class
          JOIN EMS.teaching_class ON EMS.teacher_techering_class.tc_id = EMS.teaching_class.tc_id
          JOIN EMS.teaching_programme ON EMS.teacher_techering_class.tc_id = teaching_programme.tc_id
        where teacher_techering_class.t_id = #{t_id} and cp_year = #{cp_year}
    </select>
    <resultMap id="GetTeacherProgrammeMapper" type="com.dwz.Pojo.TeacherPlan">
        <result column="tc_name" property="tc_name"/>
        <result column="tc_time" property="tc_time"/>
        <result column="tc_point" property="tc_point"/>
    </resultMap>


    <select id="GetGradeByClass" parameterType="String" resultMap="GetGradeMapper">
        SELECT student.s_id,student.s_name,grade_f.g_ps,grade_f.g_exam,grade_f.g_final ,teaching_class.tc_name
        FROM EMS.grade_f
            JOIN EMS.student ON grade_f.s_id = student.s_id
            JOIN EMS.teaching_class ON teaching_class.tc_id = grade_f.tc_id
        where teaching_class.tc_name = #{tc_name}
    </select>
    <resultMap id="GetGradeMapper" type="com.dwz.Pojo.Grade">
        <result column="s_id" property="s_id"/>
        <result column="s_name" property="s_name"/>
        <result column="course_name" property="course_name"/>
        <result column="g_ps" property="g_ps"/>
        <result column="g_exam" property="g_exam"/>
        <result column="g_final" property="g_final"/>
    </resultMap>


    <update id="UpdateGrade" parameterType="map">
        UPDATE EMS.grade_f SET g_ps = #{ps},g_exam = #{exam},g_final = #{final}
        WHERE tc_id = #{tcId} AND s_id = #{sId}
    </update>

    <select id="getTeachingclassIdbyName" parameterType="String" resultType="String">
        SELECT tc_id FROM EMS.teaching_class WHERE tc_name = #{tc_name}
    </select>
</mapper>

UserMapper

package com.dwz.Dao;

import com.dwz.Pojo.User;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

public interface UserMapper {
    /*
    * 得到全部的用户,用户分为三部分,管理员,学生,账号
    * */
    List<User> getUserList();
    /*
    * 通过id获得用户
    * */
    User getUserById(String u_id);
    /*
    * 获得教师用户
    * */
    List<User> GetTeacherUser();
    /*
    * 修改教师密码
    * */
    boolean UpdateTeacherUserPwd(Map<String,Object> map);
    /*
    * 获得学生用户
    * */
    List<User> GetStudentUser();
    /*
    * 修改学生密码
    * */
    boolean UpdateStudentUserPwd(Map<String,Object> map);
    /*
    *增加学生用户
    * */
    boolean AddStudentUser(Map<String,Object> map);
    /*
    * 增加老师用户
    * */
    boolean AddTeacherUser(Map<String,Object> map);
    /*
    * 增加通知
    * */
    boolean AddInform(Map<String,Object> map);
    /*
    * 通知删除
    * */
    boolean DeleteInform(String id);
}

UserMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dwz.Dao.UserMapper">
    <select id="getUserList" resultType="com.dwz.Pojo.User">
        select *from EMS.user u
    </select>
    
    <select id="getUserById" parameterType="String" resultType="com.dwz.Pojo.User">
        select *from EMS.user u where u_id = #{u_id}
    </select>

    <select id="GetTeacherUser" resultType="com.dwz.Pojo.User">
        SELECT `user`.u_id ,teacher.t_name,`user`.u_pwd ,`user`.u_status
        FROM EMS.`user` join EMS.teacher on user.u_id = teacher.t_id
        WHERE `user`.u_status RLIKE '^老'
    </select>

    <update id="UpdateTeacherUserPwd" parameterType="map" >
        update EMS.user set u_pwd = #{pwd}
        where u_id = #{t_id}
    </update>

    <select id="GetStudentUser" resultType="com.dwz.Pojo.User">
        SELECT `user`.u_id ,student.s_name,`user`.u_pwd ,`user`.u_status
        FROM EMS.`user` join EMS.student on user.u_id = student.s_id
        WHERE `user`.u_status RLIKE '^学'
    </select>


    <update id="UpdateStudentUserPwd" parameterType="map" >
        update EMS.user set u_pwd = #{pwd}
        where u_id = #{t_id}
    </update>

    <insert id="AddStudentUser" parameterType="map" statementType="CALLABLE">
        call EMS.s_add(#{id,mode=IN},#{sname,mode=IN},#{ssex,mode=IN})
    </insert>

    <insert id="AddTeacherUser" parameterType="map" statementType="CALLABLE">
        call EMS.t_add(#{id,mode=IN},#{sname,mode=IN},#{ssex,mode=IN})
    </insert>

    <insert id="AddInform" parameterType="map">
        INSERT INTO EMS.thing(thingtxt,tine,id,`year`) VALUES(#{thingtxt}, NOW(), #{id}, #{year})
    </insert>

    <delete id="DeleteInform" parameterType="String" >
        delete from EMS.thing where id = #{id}
    </delete>
</mapper>

Pojo层实现

这里我是直接先将数据库的表全部作为实体类的,但是实际上没有这个必要,我是觉得比较省事,要什么方法直接拿就行了,不用再去临时加。

User

package com.dwz.Pojo;

public class User {
    private String u_id;
    private String u_pwd;
    private String u_status;
    private String t_name;
    private String s_name;
    private String ssex;


    @Override
    public String toString() {
        return "User{" +
                "u_id='" + u_id + '\'' +
                ", u_pwd='" + u_pwd + '\'' +
                ", u_status='" + u_status + '\'' +
                ", t_name='" + t_name + '\'' +
                ", s_name='" + s_name + '\'' +
                ", ssex='" + ssex + '\'' +
                '}';
    }

    public String getS_name() {
        return s_name;
    }

    public String getSsex() {
        return ssex;
    }

    public void setSsex(String ssex) {
        this.ssex = ssex;
    }

    public void setS_name(String s_name) {
        this.s_name = s_name;
    }

    public String getT_name() {
        return t_name;
    }

    public void setT_name(String t_name) {
        this.t_name = t_name;
    }

    public User() {
    }

    public User(String u_id, String u_pwd, String u_status) {
        this.u_id = u_id;
        this.u_pwd = u_pwd;
        this.u_status = u_status;
    }

    public String getU_id() {
        return u_id;
    }

    public void setU_id(String u_id) {
        this.u_id = u_id;
    }

    public String getU_pwd() {
        return u_pwd;
    }

    public void setU_pwd(String u_pwd) {
        this.u_pwd = u_pwd;
    }

    public String getU_status() {
        return u_status;
    }

    public void setU_status(String u_status) {
        this.u_status = u_status;
    }
}

Student

package com.dwz.Pojo;

public class Student {
    private String s_id;
    private String s_name;
    private String s_sex;
    private String c_id;

    public Student() {
    }

    public Student(String s_id, String s_name, String s_sex, String c_id) {
        this.s_id = s_id;
        this.s_name = s_name;
        this.s_sex = s_sex;
        this.c_id = c_id;
    }

    @Override
    public String toString() {
        return "Student{" +
                "s_id='" + s_id + '\'' +
                ", s_name='" + s_name + '\'' +
                ", s_sex='" + s_sex + '\'' +
                ", c_id='" + c_id + '\'' +
                '}';
    }

    public String getS_id() {
        return s_id;
    }

    public void setS_id(String s_id) {
        this.s_id = s_id;
    }

    public String getS_name() {
        return s_name;
    }

    public void setS_name(String s_name) {
        this.s_name = s_name;
    }

    public String getS_sex() {
        return s_sex;
    }

    public void setS_sex(String s_sex) {
        this.s_sex = s_sex;
    }

    public String getC_id() {
        return c_id;
    }

    public void setC_id(String c_id) {
        this.c_id = c_id;
    }
}

Teacher

package com.dwz.Pojo;

public class Teacher {
    private String t_id;
    private String t_name;
    private String t_sex;

    public Teacher() {
    }

    public Teacher(String t_id, String t_name, String t_sex) {
        this.t_id = t_id;
        this.t_name = t_name;
        this.t_sex = t_sex;
    }

    public String getT_id() {
        return t_id;
    }

    public void setT_id(String t_id) {
        this.t_id = t_id;
    }

    public String getT_name() {
        return t_name;
    }

    public void setT_name(String t_name) {
        this.t_name = t_name;
    }

    public String getT_sex() {
        return t_sex;
    }

    public void setT_sex(String t_sex) {
        this.t_sex = t_sex;
    }

    @Override
    public String toString() {
        return "Teacher{" +
                "t_id='" + t_id + '\'' +
                ", t_name='" + t_name + '\'' +
                ", t_sex='" + t_sex + '\'' +
                '}';
    }

}

Class

package com.dwz.Pojo;

public class Class {
    private String c_id;
    private String c_name;
    private int c_num;
    private String d_id;

    @Override
    public String toString() {
        return "Class{" +
                "c_id='" + c_id + '\'' +
                ", c_name='" + c_name + '\'' +
                ", c_num=" + c_num +
                ", d_id='" + d_id + '\'' +
                '}';
    }

    public Class() {
    }

    public Class(String c_id, String c_name, int c_num, String d_id) {
        this.c_id = c_id;
        this.c_name = c_name;
        this.c_num = c_num;
        this.d_id = d_id;
    }

    public String getC_id() {
        return c_id;
    }

    public void setC_id(String c_id) {
        this.c_id = c_id;
    }

    public String getC_name() {
        return c_name;
    }

    public void setC_name(String c_name) {
        this.c_name = c_name;
    }

    public int getC_num() {
        return c_num;
    }

    public void setC_num(int c_num) {
        this.c_num = c_num;
    }

    public String getD_id() {
        return d_id;
    }

    public void setD_id(String d_id) {
        this.d_id = d_id;
    }
}

Academy

package com.dwz.Pojo;

public class Academy {
    private String a_id;
    private String a_name;

    @Override
    public String toString() {
        return "Academy{" +
                "a_id='" + a_id + '\'' +
                ", a_name='" + a_name + '\'' +
                '}';
    }

    public Academy(String a_id, String a_name) {
        this.a_id = a_id;
        this.a_name = a_name;
    }

    public Academy() {
    }

    public String getA_id() {
        return a_id;
    }

    public void setA_id(String a_id) {
        this.a_id = a_id;
    }

    public String getA_name() {
        return a_name;
    }

    public void setA_name(String a_name) {
        this.a_name = a_name;
    }
}

Academy

package com.dwz.Pojo;

public class Course {
    private String course_id;
    private String curse_name;
    private String course_type;
    private int course_credit;

    public Course(String course_id, String curse_name, String course_type, int course_credit) {
        this.course_id = course_id;
        this.curse_name = curse_name;
        this.course_type = course_type;
        this.course_credit = course_credit;
    }
    public Course() {
    }

    @Override
    public String toString() {
        return "Course{" +
                "course_id='" + course_id + '\'' +
                ", curse_name='" + curse_name + '\'' +
                ", course_type='" + course_type + '\'' +
                ", course_credit=" + course_credit +
                '}';
    }

    public String getCourse_id() {
        return course_id;
    }

    public void setCourse_id(String course_id) {
        this.course_id = course_id;
    }

    public String getCurse_name() {
        return curse_name;
    }

    public void setCurse_name(String curse_name) {
        this.curse_name = curse_name;
    }

    public String getCourse_type() {
        return course_type;
    }

    public void setCourse_type(String course_type) {
        this.course_type = course_type;
    }

    public int getCourse_credit() {
        return course_credit;
    }

    public void setCourse_credit(int course_credit) {
        this.course_credit = course_credit;
    }
}

Course_plan

package com.dwz.Pojo;

public class Course_plan {
    private String cp_year;
    private String cp_class;
    private String course_id;
    private String cp_week;

    public Course_plan(String cp_year, String cp_class, String course_id, String cp_week) {
        this.cp_year = cp_year;
        this.cp_class = cp_class;
        this.course_id = course_id;
        this.cp_week = cp_week;
    }
    public Course_plan() {
    }
    @Override
    public String toString() {
        return "Course_plan{" +
                "cp_year='" + cp_year + '\'' +
                ", cp_class='" + cp_class + '\'' +
                ", course_id='" + course_id + '\'' +
                ", cp_week='" + cp_week + '\'' +
                '}';
    }

    public String getCp_year() {
        return cp_year;
    }

    public void setCp_year(String cp_year) {
        this.cp_year = cp_year;
    }

    public String getCp_class() {
        return cp_class;
    }

    public void setCp_class(String cp_class) {
        this.cp_class = cp_class;
    }

    public String getCourse_id() {
        return course_id;
    }

    public void setCourse_id(String course_id) {
        this.course_id = course_id;
    }

    public String getCp_week() {
        return cp_week;
    }

    public void setCp_week(String cp_week) {
        this.cp_week = cp_week;
    }
}

Department

package com.dwz.Pojo;

public class Department {
    private String d_id;
    private String d_name;
    private String a_id;

    public Department(String d_id, String d_name, String a_id) {
        this.d_id = d_id;
        this.d_name = d_name;
        this.a_id = a_id;
    }
    public Department() {
    }
    @Override
    public String toString() {
        return "Department{" +
                "d_id='" + d_id + '\'' +
                ", d_name='" + d_name + '\'' +
                ", a_id='" + a_id + '\'' +
                '}';
    }
    public String getD_id() {
        return d_id;
    }

    public void setD_id(String d_id) {
        this.d_id = d_id;
    }

    public String getD_name() {
        return d_name;
    }

    public void setD_name(String d_name) {
        this.d_name = d_name;
    }

    public String getA_id() {
        return a_id;
    }

    public void setA_id(String a_id) {
        this.a_id = a_id;
    }
}

Grade

package com.dwz.Pojo;

public class Grade {
    private String tc_id;
    private String s_id;
    private Double g_ps;
    private Double g_exam;
    private Double g_final;
    private String course_name;
    private String s_name;

    public Grade(String tc_id, String s_id, Double g_ps, Double g_exam, Double g_final) {
        this.tc_id = tc_id;
        this.s_id = s_id;
        this.g_ps = g_ps;
        this.g_exam = g_exam;
        this.g_final = g_final;
    }

    public String getS_name() {
        return s_name;
    }

    public void setS_name(String s_name) {
        this.s_name = s_name;
    }

    public String getCourse_name() {
        return course_name;
    }

    public void setCourse_name(String course_name) {
        this.course_name = course_name;
    }


    @Override
    public String toString() {
        return "Grade{" +
                "tc_id='" + tc_id + '\'' +
                ", s_id='" + s_id + '\'' +
                ", g_ps=" + g_ps +
                ", g_exam=" + g_exam +
                ", g_final=" + g_final +
                ", course_name='" + course_name + '\'' +
                ", s_name='" + s_name + '\'' +
                '}';
    }

    public Grade() {
    }

    public String getTc_id() {
        return tc_id;
    }

    public void setTc_id(String tc_id) {
        this.tc_id = tc_id;
    }

    public String getS_id() {
        return s_id;
    }

    public void setS_id(String s_id) {
        this.s_id = s_id;
    }

    public Double getG_ps() {
        return g_ps;
    }

    public void setG_ps(Double g_ps) {
        this.g_ps = g_ps;
    }

    public Double getG_exam() {
        return g_exam;
    }

    public void setG_exam(Double g_exam) {
        this.g_exam = g_exam;
    }

    public Double getG_final() {
        return g_final;
    }

    public void setG_final(Double g_final) {
        this.g_final = g_final;
    }
}

Seclet_Course

package com.dwz.Pojo;

public class Seclet_Course {
    private String courseName;
    private String teacherClass;
    private int credit;
    private String teacherName;
    private String courseTime;
    private String coursePoint;
    private String cpClass;

    public Seclet_Course() {
    }

    @Override
    public String toString() {
        return "Seclet_Course{" +
                "courseName='" + courseName + '\'' +
                ", teacherClass='" + teacherClass + '\'' +
                ", credit=" + credit +
                ", teacherName='" + teacherName + '\'' +
                ", courseTime='" + courseTime + '\'' +
                ", coursePoint='" + coursePoint + '\'' +
                ", cpClass='" + cpClass + '\'' +
                '}';
    }

    public Seclet_Course(String courseName, String teacherClass, int credit, String teacherName,
                         String courseTime, String coursePoint, String cpClass) {
        this.courseName = courseName;
        this.teacherClass = teacherClass;
        this.credit = credit;
        this.teacherName = teacherName;
        this.courseTime = courseTime;
        this.coursePoint = coursePoint;
        this.cpClass = cpClass;
    }

    public String getCourseName() {
        return courseName;
    }

    public void setCourseName(String courseName) {
        this.courseName = courseName;
    }

    public String getTeacherClass() {
        return teacherClass;
    }

    public void setTeacherClass(String teacherClass) {
        this.teacherClass = teacherClass;
    }

    public int getCredit() {
        return credit;
    }

    public void setCredit(int credit) {
        this.credit = credit;
    }

    public String getTeacherName() {
        return teacherName;
    }

    public void setTeacherName(String teacherName) {
        this.teacherName = teacherName;
    }

    public String getCourseTime() {
        return courseTime;
    }

    public void setCourseTime(String courseTime) {
        this.courseTime = courseTime;
    }

    public String getCoursePoint() {
        return coursePoint;
    }

    public void setCoursePoint(String coursePoint) {
        this.coursePoint = coursePoint;
    }

    public String getCpClass() {
        return cpClass;
    }

    public void setCpClass(String cpClass) {
        this.cpClass = cpClass;
    }
}

Teacher_class

package com.dwz.Pojo;

public class Teacher_class {
    private String tc_id;
    private String tc_name;
    private String curse_name;
    private int tc_num;
    private String tc_time;
    private String tc_point;

    public Teacher_class(String tc_id, String tc_name, int tc_num, String tc_time, String tc_point) {
        this.tc_id = tc_id;
        this.tc_name = tc_name;
        this.tc_num = tc_num;
        this.tc_time = tc_time;
        this.tc_point = tc_point;
    }

    @Override
    public String toString() {
        return "Teacher_class{" +
                "tc_id='" + tc_id + '\'' +
                ", tc_name='" + tc_name + '\'' +
                ", course_name='" + curse_name + '\'' +
                ", tc_num=" + tc_num +
                ", tc_time='" + tc_time + '\'' +
                ", tc_point='" + tc_point + '\'' +
                '}';
    }

    public Teacher_class() {
    }

    public String getCurse_name() {
        return curse_name;
    }

    public void setCurse_name(String curse_name) {
        this.curse_name = curse_name;
    }

    public String getTc_id() {
        return tc_id;
    }

    public void setTc_id(String tc_id) {
        this.tc_id = tc_id;
    }

    public String getTc_name() {
        return tc_name;
    }

    public void setTc_name(String tc_name) {
        this.tc_name = tc_name;
    }

    public int getTc_num() {
        return tc_num;
    }

    public void setTc_num(int tc_num) {
        this.tc_num = tc_num;
    }

    public String getTc_time() {
        return tc_time;
    }

    public void setTc_time(String tc_time) {
        this.tc_time = tc_time;
    }

    public String getTc_point() {
        return tc_point;
    }

    public void setTc_point(String tc_point) {
        this.tc_point = tc_point;
    }
}

TeacherPlan

package com.dwz.Pojo;

public class TeacherPlan {
    private String tc_name;
    private String tc_time;
    private String tc_point;

    public TeacherPlan(String tc_name, String tc_time, String tc_point) {
        this.tc_name = tc_name;
        this.tc_time = tc_time;
        this.tc_point = tc_point;
    }

    @Override
    public String toString() {
        return "TeacherPlan{" +
                "tc_name='" + tc_name + '\'' +
                ", tc_time='" + tc_time + '\'' +
                ", tc_point='" + tc_point + '\'' +
                '}';
    }

    public String getTc_name() {
        return tc_name;
    }

    public void setTc_name(String tc_name) {
        this.tc_name = tc_name;
    }

    public String getTc_time() {
        return tc_time;
    }

    public void setTc_time(String tc_time) {
        this.tc_time = tc_time;
    }

    public String getTc_point() {
        return tc_point;
    }

    public void setTc_point(String tc_point) {
        this.tc_point = tc_point;
    }
}

Teaching_programme

package com.dwz.Pojo;

public class Teaching_programme {
    private String cp_year;
    private String cp_class;
    private String tc_id;
    private String course_id;

    public Teaching_programme(String cp_year, String cp_class, String tc_id, String course_id) {
        this.cp_year = cp_year;
        this.cp_class = cp_class;
        this.tc_id = tc_id;
        this.course_id = course_id;
    }


    @Override
    public String toString() {
        return "Teaching_programme{" +
                "cp_year='" + cp_year + '\'' +
                ", cp_class='" + cp_class + '\'' +
                ", tc_id='" + tc_id + '\'' +
                ", course_id='" + course_id + '\'' +
                '}';
    }

    public String getCp_year() {
        return cp_year;
    }

    public void setCp_year(String cp_year) {
        this.cp_year = cp_year;
    }

    public String getCp_class() {
        return cp_class;
    }

    public void setCp_class(String cp_class) {
        this.cp_class = cp_class;
    }

    public String getTc_id() {
        return tc_id;
    }

    public void setTc_id(String tc_id) {
        this.tc_id = tc_id;
    }

    public String getCourse_id() {
        return course_id;
    }

    public void setCourse_id(String course_id) {
        this.course_id = course_id;
    }
}

Thing

package com.dwz.Pojo;

public class Thing {
    private String thingtxt;
    private String tine;
    private String  id;
    private String year;

    public Thing(String thingtxt, String tine, String id, String year) {
        this.thingtxt = thingtxt;
        this.tine = tine;
        this.id = id;
        this.year = year;
    }

    public Thing() {
    }

    public String getThingtxt() {
        return thingtxt;
    }

    public void setThingtxt(String thingtxt) {
        this.thingtxt = thingtxt;
    }

    public String getTine() {
        return tine;
    }

    public void setTine(String tine) {
        this.tine = tine;
    }

    public String  getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getYear() {
        return year;
    }

    public void setYear(String year) {
        this.year = year;
    }
}

Service层实现

StudentService

package com.dwz.Service;

import com.dwz.Dao.StudentMapper;
import com.dwz.Pojo.*;
import com.dwz.Utlis.Mybatis;
import org.apache.ibatis.session.SqlSession;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class StudentService {

//    根据s_id获得Student用户
    public Student getStudent(String s_id){
        SqlSession sqlSession = Mybatis.getSqlSession();
        StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);
        Student students = studentMapper.getStudents_s_id(s_id);
        sqlSession.close();
        return students;
    }
//    获得全部学生用户
    public List<Student> getStudentList(){
        SqlSession sqlSession = Mybatis.getSqlSession();
        StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);
        List<Student> studentList = studentMapper.getStudentList();
        sqlSession.close();
        return studentList;
    }
//    获得年份列表
    public List<String> getYear(){
        SqlSession sqlSession = Mybatis.getSqlSession();
        StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);
        List<String> cp_yearList = studentMapper.getCp_year();
        sqlSession.close();
        return cp_yearList;
    }

//    获得班级
    public List<Teacher_class> getTeachingclass(String id,String year){
        SqlSession sqlSession = Mybatis.getSqlSession();
        StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
        Map<String, Object> map = new HashMap<>();
        map.put("s_id", id);
        map.put("cp_year", year);
        List<String> teachingClassId = mapper.getTeachingClassId(map);
        if (teachingClassId.size() == 0)
            return new ArrayList<>();
        map.put("teachingClassIdList",teachingClassId);
        List<Teacher_class> teachingClassList = mapper.getTeacherclass2(map);
        sqlSession.close();
        return teachingClassList;
    }

//    获得选课信息
    public List<Seclet_Course> getSelectcourse(String studentid,String cp_year){
        String id = studentid.substring(0, 2);
        SqlSession sqlSession = Mybatis.getSqlSession();
        StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
        List<Seclet_Course> selectCourse = mapper.getSelectCourse(cp_year);
        return selectCourse;
    }
//    判断是否冲突
    public boolean isConflict(String id, String year, String course) {
        List<Teacher_class> teachingclass = getTeachingclass(id, year);
        String[] s = course.split(" ");
        for (int i = 0; i < teachingclass.size(); i++) {
            for (int j = 0; j < s.length; j++) {
                if (teachingclass.get(i).getTc_time().contains(s[j]))
                    return true;
            }
        }
        return false;
    }
//    增加选课记录
    public boolean courseAdd(String teachingClassname ,String studentId) {
        SqlSession sqlSession = Mybatis.getSqlSession();
        StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);

        String teachingclassId = mapper.getTeachingclassIdbyName(teachingClassname);
        System.out.println(studentId);
        System.out.println(teachingclassId);
        boolean res = mapper.addCourse(studentId,teachingclassId);
        sqlSession.commit();
        sqlSession.close();
        if (res) {
            return true;
        }
        return false;
    }

    /*
    * 实现成绩
    * */
    public List<Grade> getGrade(String id, String year) {
        SqlSession sqlSession = Mybatis.getSqlSession();
        StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
        Map<String, Object> map = new HashMap();
        map.put("sid", id);
        map.put("cpYear", year);
        List<Grade> gradeList = mapper.GetGradeList(map);
        sqlSession.close();
        return gradeList;
    }
    /*
    * 根据成绩的tc_id去寻找课程的名字
    * */
    public String GetCourseByid(String tc_id){
        SqlSession sqlSession = Mybatis.getSqlSession();
        StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
        String CourseName = mapper.GetCourseName(tc_id);
        sqlSession.close();
        return CourseName;
    }
    /*
    * 获得旧密码
    * */
    public String GetOldPassword(String StuedntId){
        SqlSession sqlSession = Mybatis.getSqlSession();
        StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
        String OldPassword = mapper.GetOldPassword(StuedntId);
        sqlSession.close();
        return OldPassword;
    }
    public boolean updatePassword(String newPassword, String id) {
        SqlSession sqlSession = Mybatis.getSqlSession();
        StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
        boolean b = mapper.UpdatePassword(newPassword,id);
        sqlSession.commit();
        if (b)
            return true;
        return false;
    }

    /*
    * 通过班级账号获得学院名称
    * */
    public String GetAcademyName(String ClassId){
        SqlSession sqlSession = Mybatis.getSqlSession();
        StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
        String academyName = mapper.GetAcademyName(ClassId);
        System.out.println(academyName);
        sqlSession.close();
        return academyName;
    }

    public List<Thing> GetInform(){
        SqlSession sqlSession = Mybatis.getSqlSession();
        StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
        List<Thing> things = mapper.GetInform();
        for (Thing thing: things){
            System.out.println(thing);
        }
        return things;
    }
}

TeacherService

package com.dwz.Service;

import com.dwz.Dao.StudentMapper;
import com.dwz.Dao.TeacherMapper;
import com.dwz.Pojo.Grade;
import com.dwz.Pojo.Student;
import com.dwz.Pojo.Teacher;
import com.dwz.Pojo.TeacherPlan;
import com.dwz.Utlis.Mybatis;
import org.apache.ibatis.session.SqlSession;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TeacherService {
    //    根据s_id获得Student用户
    public Teacher getTeacher(String s_id){
        SqlSession sqlSession = Mybatis.getSqlSession();
        TeacherMapper teacherMapper = sqlSession.getMapper(TeacherMapper.class);
        Teacher teacher = teacherMapper.getTeacher(s_id);
        sqlSession.close();
        return teacher;
    }
    //    获得全部老师用户
    public List<Teacher> getTeacherList(){
        SqlSession sqlSession = Mybatis.getSqlSession();
        TeacherMapper teacherMapper = sqlSession.getMapper(TeacherMapper.class);
        List<Teacher> teacherList = teacherMapper.getTeacherList();
        sqlSession.close();
        return teacherList;
    }

    /*
    * 获得教学计划
    * */
    public List<TeacherPlan> GetTeacherPlan(String t_id , String cp_year){
        SqlSession sqlSession = Mybatis.getSqlSession();
        TeacherMapper teacherMapper = sqlSession.getMapper(TeacherMapper.class);
        Map<String, Object> map = new HashMap<>();
        map.put("t_id",t_id);
        map.put("cp_year",cp_year);
        List<TeacherPlan> planList = teacherMapper.getTeacherProgramme(map);
        sqlSession.close();
        return planList;
    }
    /*
    * 修改成绩
    * */
    public List<Grade> GetGradeByClass(String tc_name){
        SqlSession sqlSession = Mybatis.getSqlSession();
        TeacherMapper mapper = sqlSession.getMapper(TeacherMapper.class);
        List<Grade> grades = mapper.GetGradeByClass(tc_name);
        sqlSession.close();
        return grades;
    }
    public boolean updateGrade(List<Grade> grades, String className) {
        SqlSession sqlSession = Mybatis.getSqlSession();
        TeacherMapper mapper = sqlSession.getMapper(TeacherMapper.class);
        String teachingclassId = mapper.getTeachingclassIdbyName(className);

        Map<String, Object> map = new HashMap<>();
        map.put("tcId", teachingclassId);
        for (Grade grade : grades) {
            map.put("sId", grade.getS_id());
            map.put("ps", grade.getG_ps());
            map.put("exam", grade.getG_exam());
            map.put("final", grade.getG_final());
            mapper.UpdateGrade(map);
            sqlSession.commit();
        }
        sqlSession.close();
        return true;
    }

}

UserService

package com.dwz.Service;

import com.dwz.Dao.UserMapper;
import com.dwz.Pojo.Thing;
import com.dwz.Pojo.User;
import com.dwz.Utlis.Mybatis;
import org.apache.ibatis.session.SqlSession;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class UserService {
    public boolean judgeUser(User user){
        SqlSession sqlSession = Mybatis.getSqlSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        User userMapperUser = userMapper.getUserById(user.getU_id());
        /*
        * 代码解释
        * 这里不是传了一个user的用户嘛,我们拿到这个user的id,拿着这个id通过
        * Mybatis去数据库找到这个用户,然后关闭,在去数据库调出这个用户的密码,
        * 将这个密码和user自己传进来的密码进行比较即可*/
        sqlSession.close();
        if (userMapperUser != null){
            if (userMapperUser.getU_pwd().equals(user.getU_pwd())){
                user.setU_status(userMapperUser.getU_status());
                return true;
            }
        }
        return false;
    }
    /*获得User对象*/
    public User getUser(String u_id){
        SqlSession sqlSession = Mybatis.getSqlSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        User user = userMapper.getUserById(u_id);
        sqlSession.close();
        return user;
    }

    /*
    * 获得教师用户信息
    * */
    public List<User> GetTeacherUser(){
        SqlSession sqlSession = Mybatis.getSqlSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        List<User> userList = userMapper.GetTeacherUser();
        for (User user : userList ){
            System.out.println(user);
        }
        sqlSession.close();
        return userList;
    }

    /*
    * 修改教师密码
    * */
    /*TeacherUpdateTest
    * */
    public boolean UpdateTeacherPwd(List<User> teacherUpdateTests){
        SqlSession sqlSession = Mybatis.getSqlSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        Map<String,Object> map = new HashMap<>();
        for (User teacherUpdateTest : teacherUpdateTests){
            map.put("t_id",teacherUpdateTest.getU_id());
            map.put("pwd",teacherUpdateTest.getU_pwd());
            userMapper.UpdateTeacherUserPwd(map);
            sqlSession.commit();
        }
        sqlSession.close();
        return true;
    }

    /*
    * 获得学生用户
    * */
    public List<User> GetStudentUser(){
        SqlSession sqlSession = Mybatis.getSqlSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        List<User> userList = userMapper.GetStudentUser();
        for (User user : userList ){
            System.out.println(user);
        }
        sqlSession.close();
        return userList;
    }

    /*
    * 修改学生用户密码
    * */
    public boolean UpdateStudentPwd(List<User> StudentList){
        SqlSession sqlSession = Mybatis.getSqlSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        Map<String,Object> map = new HashMap<>();
        for (User StudentUser : StudentList){
            map.put("t_id",StudentUser.getU_id());
            map.put("pwd",StudentUser.getU_pwd());
            userMapper.UpdateTeacherUserPwd(map);
            sqlSession.commit();
        }
        sqlSession.close();
        return true;
    }

    /*
    * 增加学生账户
    * */
    public boolean AddStudent(List<User> Studentslist){
        SqlSession sqlSession = Mybatis.getSqlSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        Map<String,Object> map = new HashMap<>();
        for (User user:Studentslist){
            map.put("id",user.getU_id());
            map.put("sname",user.getS_name());
            map.put("ssex",user.getSsex());
            userMapper.AddStudentUser(map);
            sqlSession.commit();
        }
        sqlSession.close();
        return true;
    }

    /*
     * 增加老师账户
     * */
    public boolean AddTeacher(List<User> list){
        SqlSession sqlSession = Mybatis.getSqlSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        Map<String,Object> map = new HashMap<>();
        for (User user:list){
            map.put("id",user.getU_id());
            map.put("sname",user.getT_name());
            map.put("ssex",user.getSsex());
            userMapper.AddTeacherUser(map);
            sqlSession.commit();
        }
        sqlSession.close();
        return true;
    }

    /*
    * 增加通知
    * */
    public boolean AddInform(List<Thing> thingList){
        SqlSession sqlSession = Mybatis.getSqlSession();
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        Map<String,Object> map = new HashMap<>();
        for (Thing thing:thingList){
            map.put("thingtxt",thing.getThingtxt());
            map.put("id",thing.getId());
            map.put("year",thing.getYear());
            mapper.AddInform(map);
            sqlSession.commit();
        }
        sqlSession.close();
        return true;
    }

    /*
    * 删除通知
    * */
    public boolean DeleteInform(String id){
        SqlSession sqlSession = Mybatis.getSqlSession();
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        mapper.DeleteInform(id);
        sqlSession.commit();
        sqlSession.close();
        return true;
    }
}

Utlis层实现

工具类其实就是将一样的代码提取出来,叫做工具文章来源地址https://www.toymoban.com/news/detail-526411.html

Button

package com.dwz.Utlis;

import javax.swing.*;
import java.awt.*;

public class Button extends JFrame {
    //设置导航栏的按钮
    public JButton getButton (String text,String img){
        ImageIcon imageIcon = new ImageIcon(ClassLoader.getSystemResource(img));
        imageIcon.setImage(imageIcon.getImage().getScaledInstance(28,28, Image.SCALE_DEFAULT));
        Font font = new Font("行书",Font.LAYOUT_LEFT_TO_RIGHT,16);
        JButton jbt1 = new JButton(text,imageIcon);
        jbt1.setFont(font);
        //无边框
        jbt1.setBorderPainted(false);
        //文字与图片垂直对齐
        jbt1.setVerticalTextPosition(SwingConstants.BOTTOM);
        //点击变成手型
        jbt1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        return jbt1;
    }
}

Mybatis

package com.dwz.Utlis;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class Mybatis {
    private static SqlSessionFactory sqlSessionFactory;
    static {
        try {
//            使用Mybatis第一步,获取sqlSessionFactory对象
            String resource = "mybatis-config.xml";
            InputStream inputStream = Resources.getResourceAsStream(resource);
            sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
//   既然有了 SqlSessionFactory,顾名思义,我们可以从中获得 SqlSession 的实例。
//    SqlSession 提供了在数据库执行 SQL 命令所需的所有方法。
//    你可以通过 SqlSession 实例来直接执行已映射的 SQL 语句
    public static SqlSession getSqlSession(){
        SqlSession sqlSession = sqlSessionFactory.openSession();
        return sqlSession;
    }
}

replacementPanel

package com.dwz.Utlis;

import java.awt.*;

public class replacementPanel {

    //刷新画板
    public void replacement(Container change, Container res) {
        change.removeAll();
        change.add(res);
        change.validate();
        change.repaint();
    }
}

Tool

package com.dwz.Utlis;

import javax.swing.*;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;

public class Tool {
    //设置列宽
    public static void setColumnSize(JTable table, int i, int preferedWidth, int maxWidth, int minWidth) {
        //表格的列模型
        TableColumnModel cm = table.getColumnModel();
        //得到第i个列对象
        TableColumn column = cm.getColumn(i);
        column.setPreferredWidth(preferedWidth);
        column.setMaxWidth(maxWidth);
        column.setMinWidth(minWidth);
    }

    //获取星期字符串
    public static String getWeek(char week) {
        switch (week) {
            case '1':
                return "周一";
            case '2':
                return "周二";
            case '3':
                return "周三";
            case '4':
                return "周四";
            case '5':
                return "周五";
        }
        return null;
    }

    public static String getPitch(char pitch) {
        switch (pitch) {
            case '1':
                return "[1-2]节";
            case '2':
                return "[3-4]节";
            case '3':
                return "[5-6]节";
            case '4':
                return "[7-8]节";
            case '5':
                return "[9-10]节";
        }
        return null;
    }
    //转换密码为字符串
    public static String transitionPassword(char[] password) {
        String res = "";
        for (char ch : password) {
            res += ch;
        }
        return res;
    }
}

View层实现

AdminView

package com.dwz.View;

import com.dwz.Pojo.Thing;
import com.dwz.Pojo.User;
import com.dwz.Service.StudentService;
import com.dwz.Service.UserService;
import com.dwz.Utlis.Button;
import com.dwz.Utlis.Tool;
import com.dwz.Utlis.replacementPanel;
import sun.swing.table.DefaultTableCellHeaderRenderer;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

public class AdminView extends JFrame {
    User user;
    public JPanel getAdminhome() {
        JPanel jpHome = new JPanel();
        JTextArea textArea = new JTextArea();
        String text = user.getU_id();
        text += "管理员:欢迎使用教务管理系统!";
        textArea.setText(text);
        textArea.setFont(new Font("黑体", 1, 30));
        ImageIcon imageIcon = new ImageIcon("src/main/resources/img/fd.png");
        JLabel jLabel = new JLabel(imageIcon);
        Dimension dimension = new Dimension(800, 500);
        jLabel.setPreferredSize(dimension);
        jpHome.add(jLabel,BorderLayout.CENTER);
        jpHome.add(textArea);
        return jpHome;
    }

    public JPanel getAdminhome1() {
        JPanel jpHome = new JPanel();
        JTextArea textArea = new JTextArea();
        String text = user.getU_id();
        text += "管理员:欢迎使用教务管理系统!";
        textArea.setText(text);
        textArea.setFont(new Font("黑体", 1, 30));
        jpHome.add(textArea);
        return jpHome;
    }

    public AdminView(User user){
        super("教务管理系统");
        this.user = user;
        Container cp = this.getContentPane();
        cp.setLayout(new BorderLayout());
        JButton Home = new com.dwz.Utlis.Button().getButton("首页", "img/shouyefill.png");
        JButton Teacher = new com.dwz.Utlis.Button().getButton("老师管理", "img/laoshiguanli.png");
        JButton Student = new com.dwz.Utlis.Button().getButton("学生管理", "img/xueshengguanli-01.png");
        JButton User = new com.dwz.Utlis.Button().getButton("个人中心", "img/yonghuguanli.png");
        JButton Inform = new Button().getButton("通知管理", "img/guoneizhengtongzhichaxun.png");
        JPanel bar = new JPanel();
        bar.add(Home);
        bar.add(Teacher);
        bar.add(Student);
        bar.add(Inform);
        bar.add(User);
        JPanel mid = getAdminhome();
        cp.add(bar, BorderLayout.NORTH);
        cp.add(mid, BorderLayout.CENTER);

        this.setSize(800, 650);
        //居中
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        Home.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new replacementPanel().replacement(mid ,getAdminhome1());
            }
        });
        Teacher.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new replacementPanel().replacement(mid,GetTeacherUser());
            }
        });
        Student.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new replacementPanel().replacement(mid,GetStudentUser());
            }
        });
        Inform.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new replacementPanel().replacement(mid,getInform());
            }
        });
        User.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new replacementPanel().replacement(mid,getAdminuser());
            }
        });
    }

    /*
    * 教师用户管理
    * */
    public JPanel GetTeacherUser() {
        JPanel jpTeacherUser = new JPanel(new BorderLayout());
        JPanel top = new JPanel();
        JButton jbtUpdatepwd = new JButton("修改密码");
        JButton AddTeacher = new JButton("增加");
        JButton jVerifyButton = new JButton("确认");
        top.add(jbtUpdatepwd);
        top.add(AddTeacher);
        top.add(jVerifyButton);
        jpTeacherUser.add(top, BorderLayout.NORTH);
        JTable table = new JTable() {
            public boolean isCellEditable(int row, int column) {
                return true;
            }
        };
        JScrollPane tab = new JScrollPane(table);
        //表格内容居中
        DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();//单元格渲染器
        tcr.setHorizontalAlignment(JLabel.CENTER);
        table.setDefaultRenderer(Object.class, tcr);
        //表格表头居中
        DefaultTableCellHeaderRenderer hr = new DefaultTableCellHeaderRenderer();
        hr.setHorizontalAlignment(JLabel.CENTER);
        hr.setPreferredSize(new Dimension(25, 25));
        table.getTableHeader().setDefaultRenderer(hr);
        //设置面板大小
        tab.setPreferredSize(new Dimension(650, 500));
        //设置透明
        tab.setOpaque(false);
        tab.getViewport().setOpaque(false);
        jpTeacherUser.add(tab, BorderLayout.CENTER);
        List<User> teacherUser = new UserService().GetTeacherUser();
        Object[][] tableDate = new Object[teacherUser.size()][5];
        for (int i = 0; i < teacherUser.size(); i++) {
            for (int j = 0; j < 5; j++) {
                if (j == 0)
                    tableDate[i][j] = teacherUser.get(i).getU_id();
                else if (j == 1)
                    tableDate[i][j] = teacherUser.get(i).getT_name();
                else if (j == 2)
                    tableDate[i][j] = teacherUser.get(i).getU_pwd();
                else if (j==3)
                    tableDate[i][j] = teacherUser.get(i).getU_status();
            }
        }
        String[] name = {"ID","姓名","密码", "身份"};
        table.removeAll();
        DefaultTableModel tableModel = (DefaultTableModel) table.getModel();    //获得表格模型
        tableModel.setRowCount(0);    //清空表格中的数据
        tableModel.setColumnIdentifiers(name);    //设置表头
        Tool.setColumnSize(table,1,10,160,160);
        for (int i = 0; i < teacherUser.size(); i++) {
            tableModel.addRow(tableDate[i]);
        }
        table.setRowHeight(30);
        table.setModel(tableModel);    //应用表格模型
        JFrame jf = this;


        AddTeacher.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                tableModel.addRow(new Object[1]);
            }
        });
        jVerifyButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //重新进行表格渲染
                List<User> users = new ArrayList<>();
                User userTeacher = new User();
                for (int j = 0; j < table.getColumnCount(); j++) {
                    if (j == 0)
                        userTeacher.setU_id((String) table.getValueAt(table.getSelectedRow(), j));
                    else if (j == 1){
                        userTeacher.setT_name((String) table.getValueAt(table.getSelectedRow(),j));
                    }
                    else if (j == 3)
                        userTeacher.setSsex((String) table.getValueAt(table.getSelectedRow(),j));
                    users.add(userTeacher);
                }
                boolean addTeacher = new UserService().AddTeacher(users);
                System.out.println(addTeacher);
            }
        });

        jbtUpdatepwd.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                List<User> users = new ArrayList<>();
                for (int i = 0; i < table.getRowCount(); i++) {
                    User test = new User();
                    for (int j = 0; j < table.getColumnCount(); j++) {
                        if (j == 0)
                            test.setU_id((String) table.getValueAt(i, j));
                        else if (j == 2)
                            test.setU_pwd((String) table.getValueAt(i, j));
                    }
                    users.add(test);
                    System.out.println(users);
                }
                if (new UserService().UpdateTeacherPwd(users)) {
                    JOptionPane.showMessageDialog(jf, "密码修改成功", "提示", JOptionPane.PLAIN_MESSAGE);
                    //重新进行表格渲染
                    List<User> userList = new UserService().GetTeacherUser();
                    Object[][] tableDate = new Object[userList.size()][5];
                    for (int i = 0; i < userList.size(); i++) {
                        for (int j = 0; j < 5; j++) {
                            if (j == 0)
                                tableDate[i][j] = userList.get(i).getU_id();
                            else if (j == 1)
                                tableDate[i][j] = userList.get(i).getT_name();
                            else if (j == 2)
                                tableDate[i][j] = userList.get(i).getU_pwd();
                            else if (j == 3)
                                tableDate[i][j] = userList.get(i).getU_status();
                        }
                    }
                    String[] name = {"ID", "姓名", "密码", "状态"};
                    table.removeAll();
                    DefaultTableModel tableModel = (DefaultTableModel) table.getModel();    //获得表格模型
                    tableModel.setRowCount(0);    //清空表格中的数据
                    tableModel.setColumnIdentifiers(name);    //设置表头
                    for (int i = 0; i < userList.size(); i++) {
                        tableModel.addRow(tableDate[i]);
                    }
                    table.setRowHeight(30);
                    table.setModel(tableModel);    //应用表格模型
                }
            }
        });
        return jpTeacherUser;

    }

    /*
    * 学生用户管理
    * */
    public JPanel GetStudentUser(){
        JPanel jpStudentUser = new JPanel(new BorderLayout());
        JPanel top = new JPanel();
        JButton jbtUpdatepwd = new JButton("修改密码");
        JButton AddStudent = new JButton("增加");
        JButton jVerifyButton = new JButton("确认");
        top.add(jbtUpdatepwd);
        top.add(AddStudent);
        top.add(jVerifyButton);
        jpStudentUser.add(top, BorderLayout.NORTH);
        JTable table = new JTable() {
            public boolean isCellEditable(int row, int column) {
                return true;
            }
        };
        JScrollPane tab = new JScrollPane(table);
        //表格内容居中
        DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();//单元格渲染器
        tcr.setHorizontalAlignment(JLabel.CENTER);
        table.setDefaultRenderer(Object.class, tcr);
        //表格表头居中
        DefaultTableCellHeaderRenderer hr = new DefaultTableCellHeaderRenderer();
        hr.setHorizontalAlignment(JLabel.CENTER);
        hr.setPreferredSize(new Dimension(25, 25));
        table.getTableHeader().setDefaultRenderer(hr);
        //设置面板大小
        tab.setPreferredSize(new Dimension(650, 500));
        //设置透明
        tab.setOpaque(false);
        tab.getViewport().setOpaque(false);
        jpStudentUser.add(tab, BorderLayout.CENTER);
        List<User> studentUser = new UserService().GetStudentUser();
        Object[][] tableDate = new Object[studentUser.size()][5];
        for (int i = 0; i < studentUser.size(); i++) {
            for (int j = 0; j < 5; j++) {
                if (j == 0)
                    tableDate[i][j] = studentUser.get(i).getU_id();
                else if (j == 1)
                    tableDate[i][j] = studentUser.get(i).getS_name();
                else if (j == 2)
                    tableDate[i][j] = studentUser.get(i).getU_pwd();
                else if (j==3)
                    tableDate[i][j] = studentUser.get(i).getU_status();
            }
        }
        String[] name = {"ID","姓名","密码", "身份(可输入性别栏)"};
        table.removeAll();
        DefaultTableModel tableModel = (DefaultTableModel) table.getModel();    //获得表格模型
        tableModel.setRowCount(0);    //清空表格中的数据
        tableModel.setColumnIdentifiers(name);    //设置表头
        Tool.setColumnSize(table,1,10,160,160);
        for (int i = 0; i < studentUser.size(); i++) {
            tableModel.addRow(tableDate[i]);
        }
        table.setRowHeight(30);
        table.setModel(tableModel);    //应用表格模型
        JFrame jf = this;

        AddStudent.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                tableModel.addRow(new Object[1]);
            }
        });
        jVerifyButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //重新进行表格渲染
                List<User> users = new ArrayList<>();
                User userStudent = new User();
                for (int j = 0; j < table.getColumnCount(); j++) {
                    if (j == 0)
                        userStudent.setU_id((String) table.getValueAt(table.getSelectedRow(), j));
                    else if (j == 1){
                        userStudent.setS_name((String) table.getValueAt(table.getSelectedRow(),j));
                    }
                    else if (j == 3)
                        userStudent.setSsex((String) table.getValueAt(table.getSelectedRow(),j));
                users.add(userStudent);
                }
                boolean addStudent = new UserService().AddStudent(users);
                System.out.println(addStudent);
            }
        });
        jbtUpdatepwd.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                List<User> users = new ArrayList<>();
                for (int i = 0; i < table.getRowCount(); i++) {
                    User userStudent = new User();
                    for (int j = 0; j < table.getColumnCount(); j++) {
                        if (j == 0)
                            userStudent.setU_id((String) table.getValueAt(i, j));
                        else if (j == 2)
                            userStudent.setU_pwd((String) table.getValueAt(i, j));
                    }
                    users.add(userStudent);
                }
                if (new UserService().UpdateStudentPwd(users)) {
                    JOptionPane.showMessageDialog(jf, "密码修改成功", "提示", JOptionPane.PLAIN_MESSAGE);
                    //重新进行表格渲染
                    List<User> userList = new UserService().GetStudentUser();
                    Object[][] tableDate = new Object[userList.size()][5];
                    for (int i = 0; i < userList.size(); i++) {
                        for (int j = 0; j < 5; j++) {
                            if (j == 0)
                                tableDate[i][j] = userList.get(i).getU_id();
                            else if (j == 1)
                                tableDate[i][j] = userList.get(i).getS_name();
                            else if (j == 2)
                                tableDate[i][j] = userList.get(i).getU_pwd();
                            else if (j == 3)
                                tableDate[i][j] = userList.get(i).getU_status();
                        }
                    }
                    String[] name = {"ID", "姓名", "密码", "状态"};
                    table.removeAll();
                    DefaultTableModel tableModel = (DefaultTableModel) table.getModel();    //获得表格模型
                    tableModel.setRowCount(0);    //清空表格中的数据
                    tableModel.setColumnIdentifiers(name);    //设置表头
                    for (int i = 0; i < userList.size(); i++) {
                        tableModel.addRow(tableDate[i]);
                    }
                    table.setRowHeight(30);
                    table.setModel(tableModel);    //应用表格模型
                }
            }
        });
        return jpStudentUser;
    }

    /*
    * 通知管理
    * */
    public JPanel getInform() {
        JPanel jpGrade = new JPanel(new BorderLayout());
        JPanel top = new JPanel();
        List<Thing> things = new StudentService().GetInform();
        JButton AddjButton = new JButton("增加");
        JButton VerifyjButton = new JButton("确认");
        JButton jDeleteButton = new JButton("删除");
        top.add(AddjButton);
        top.add(VerifyjButton);
        top.add(jDeleteButton);
        jpGrade.add(top, BorderLayout.NORTH);
        JTable table = new JTable() {
            public boolean isCellEditable(int row, int column) {
                return true;
            }
        };
        JScrollPane tab = new JScrollPane(table);
        //表格内容居中
        DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();//单元格渲染器
        tcr.setHorizontalAlignment(JLabel.CENTER);
        table.setDefaultRenderer(Object.class, tcr);
        //表格表头居中
        DefaultTableCellHeaderRenderer hr = new DefaultTableCellHeaderRenderer();
        hr.setHorizontalAlignment(JLabel.CENTER);
        hr.setPreferredSize(new Dimension(25, 25));
        table.getTableHeader().setDefaultRenderer(hr);
        //设置面板大小
        tab.setPreferredSize(new Dimension(650, 500));
        //设置透明
        tab.setOpaque(false);
        tab.getViewport().setOpaque(false);
        jpGrade.add(tab, BorderLayout.CENTER);
        DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
        List<Thing> inform = new StudentService().GetInform();
        Object[][] tableDate = new Object[inform.size()][5];
        for (int i = 0; i < inform.size(); i++) {
            for (int j = 0; j < 5; j++) {
                if (j == 0)
                    tableDate[i][j] = inform.get(i).getThingtxt();
                else if (j == 1)
                    tableDate[i][j] = inform.get(i).getYear();
                else if (j == 2)
                    tableDate[i][j] = inform.get(i).getTine();
                else if (j==3){
                    tableDate[i][j] = inform.get(i).getId();
                }
            }
        }
        String[] name = {"通知", "年份", "时间","编号"};
        table.removeAll();
        tableModel.setRowCount(0);    //清空表格中的数据
        tableModel.setColumnIdentifiers(name);    //设置表头
        Tool.setColumnSize(table,1,10,160,160);
        for (int i = 0; i < inform.size(); i++) {
            tableModel.addRow(tableDate[i]);
        }
        table.setRowHeight(30);
        table.setModel(tableModel);    //应用表格模型
        jDeleteButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String id;
                id = (String) table.getValueAt(table.getSelectedRow(),3);
                boolean b = new UserService().DeleteInform(id);
                System.out.println(b);
            }
        });
        AddjButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                tableModel.addRow(new Object[1]);
            }
        });
        VerifyjButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                List<Thing> thingList = new ArrayList<>();
                Thing thing = new Thing();
                for (int j = 0; j < table.getColumnCount(); j++) {
                    if (j == 0)
                        thing.setThingtxt((String) table.getValueAt(table.getSelectedRow(), j));
                    else if (j == 1)
                        thing.setYear((String) table.getValueAt(table.getSelectedRow(),j));
                    else if (j == 3){
                        thing.setId((String) table.getValueAt(table.getSelectedRow(),j));
                    }
                    thingList.add(thing);
                }
                boolean addInform = new UserService().AddInform(thingList);
                System.out.println(addInform);
            }
        });
        return jpGrade;
    }

    /*
    * 管理员页面
    * */

    public JPanel getAdminuser() {
        JPanel jpStudentuser = new JPanel(new GridLayout(6, 2, 2, 2));
        JPanel jPanel = new JPanel(new BorderLayout());
        JFrame jf = this;
        JLabel jlId = new JLabel("账号:");
        JLabel jlPwd = new JLabel("密码:");
        JTextField jtfId = new JTextField(10);
        jtfId.setEditable(false);
        jtfId.setText(user.getU_id());
        JTextField jtfName = new JTextField(10);
        jtfName.setEditable(false);
        jtfName.setText(user.getU_pwd());
        JButton jbt = new JButton("修改密码");
        JButton jbtQuit = new JButton("退出");
        JPanel jpBottom = new JPanel();
        jpBottom.add(jbt);
        jpBottom.add(jbtQuit);
        jpStudentuser.add(jlId);
        jpStudentuser.add(jtfId);
        jpStudentuser.add(jlPwd);
        jpStudentuser.add(jtfName);
        jPanel.add(jpStudentuser, BorderLayout.NORTH);
        jPanel.add(jpBottom, BorderLayout.CENTER);
        //修改密码事件
        jbt.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JPasswordField jpOldPassword = new JPasswordField();
                JPasswordField jpPassword = new JPasswordField();
                JPasswordField jpRepassword = new JPasswordField();
                Object[] message = {
                        "旧密码:", jpOldPassword,
                        "新密码:", jpPassword,
                        "重复新密码:", jpRepassword
                };
                int option = JOptionPane.showConfirmDialog(jf, message, "修改密码", JOptionPane.YES_OPTION);
                if (option == JOptionPane.YES_OPTION) {
                    String oldPassword = new StudentService().GetOldPassword(user.getU_pwd());
                    if (!oldPassword.equals(Tool.transitionPassword(jpOldPassword.getPassword()))) {
                        JOptionPane.showMessageDialog(jf, "原密码输入错误", "错误 ", 0);
                    } else if (!Tool.transitionPassword(jpPassword.getPassword()).equals(Tool.transitionPassword(jpRepassword.getPassword()))) {
                        JOptionPane.showMessageDialog(jf, "两次密码输入不一致", "错误 ", 0);
                    } else {
                        if (new StudentService().updatePassword(Tool.transitionPassword(jpPassword.getPassword()), user.getU_id())) {
                            JOptionPane.showMessageDialog(jf, "密码修改成功!", "提示", JOptionPane.PLAIN_MESSAGE);
                            jf.dispose();
                            new Login().setVisible(true);
                        }
                    }
                }
            }
        });
        //退出事件
        jbtQuit.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                jf.dispose();
                new Login().setVisible(true);
            }
        });
        return jPanel;
    }
}

StudentsView

package com.dwz.View;

import com.dwz.Pojo.*;
import com.dwz.Pojo.Class;
import com.dwz.Service.StudentService;
import com.dwz.Utlis.Button;
import com.dwz.Utlis.Tool;
import com.dwz.Utlis.replacementPanel;
import sun.swing.table.DefaultTableCellHeaderRenderer;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.xml.bind.annotation.XmlAnyAttribute;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

public class StudentsView extends JFrame {
    Student student;

    /*首页面板*/
    public JPanel getStudenthome() {
        JPanel jpHome = new JPanel();
        JTextArea textArea = new JTextArea();
        String text = student.getS_name();
        text += "同学:欢迎使用教务管理系统!";
        textArea.setText(text);
        textArea.setFont(new Font("黑体", 1, 30));
        ImageIcon imageIcon = new ImageIcon("src/main/resources/img/fd.png");
        JLabel jLabel = new JLabel(imageIcon);
        Dimension dimension = new Dimension(800, 500);
        jLabel.setPreferredSize(dimension);
        jLabel.setVerticalAlignment(SwingUtilities.CENTER);
        jpHome.add(textArea);
        jpHome.add(jLabel,BorderLayout.CENTER);
        return jpHome;
    }
    /*主页面板*/
    public JPanel getStudenthome1() {
        JPanel jpHome = new JPanel();
        JTextArea textArea = new JTextArea();
        String text = student.getS_name();
        text += "同学:欢迎使用教务管理系统!";
        textArea.setText(text);
        textArea.setFont(new Font("黑体", 2, 30));
        jpHome.add(textArea);
        return jpHome;
    }
    /*视图*/
    public StudentsView(Student student){
        super("教务管理系统");
        this.student = student;
        Container cp = this.getContentPane();
        cp.setLayout(new BorderLayout());

        JButton Home = new Button().getButton("首页", "img/shouyefill.png");
        JButton Course = new Button().getButton("课程查询", "img/kechengchaxun.png");
        JButton Selectcourse = new Button().getButton("选课系统", "img/zizhuxuanke.png");
        JButton Grade = new Button().getButton("成绩查询", "img/chengjichaxun-.png");
        JButton User = new Button().getButton("个人中心", "img/yonghuguanli.png");
        JButton Inform = new Button().getButton("通知管理", "img/guoneizhengtongzhichaxun.png");

        JPanel bar = new JPanel();
        bar.add(Home);
        bar.add(Course);
        bar.add(Selectcourse);
        bar.add(Grade);
        bar.add(Inform);
        bar.add(User);

        JPanel mid = getStudenthome();
        cp.add(bar, BorderLayout.NORTH);
        cp.add(mid, BorderLayout.CENTER);
        this.setSize(800, 650);
        //居中
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        Home.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new replacementPanel().replacement(mid,getStudenthome1());
            }
        });
        Course.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new replacementPanel().replacement(mid,getStudentCourse());
            }
        });
        Selectcourse.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new replacementPanel().replacement(mid,getSelectCourse());
            }
        });
        Grade.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new replacementPanel().replacement(mid,getStudentgrade());
            }
        });
        Inform.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new replacementPanel().replacement(mid,getInform());
            }
        });
        User.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new replacementPanel().replacement(mid,getStudentuser());
            }
        });

    }

    /*
    * 获得选课
    * */
    public JPanel getStudentCourse(){
        class TableViewRenderer extends JTextArea implements TableCellRenderer {
            public TableViewRenderer() {
                //将表格设为自动换行
                setLineWrap(true);
                //单词过长的时候是否把长单词移动到下一行
                setWrapStyleWord(true);
            }
            public Component getTableCellRendererComponent(JTable jtable, Object obj, //obj指的是单元格内容
                                                           boolean isSelected,
                                                           boolean hasFocus, int row, int column) {
                setText(obj == null ? "" : obj.toString()); //利用JTextArea的setText设置文本方法
                return this;
            }
        }
        JPanel jpCourse = new JPanel(new BorderLayout());
        JPanel top = new JPanel();
        JLabel jlYear = new JLabel("学年:");
        JComboBox<String> comboBox = new JComboBox<>();
        comboBox.addItem("--请选择--");    //向下拉列表中添加一项
        List<String> year = new StudentService().getYear();
        for (String str : year) {
            comboBox.addItem(str);
        }
        JButton jbtSelect = new JButton("查询");
        top.add(jlYear);
        top.add(comboBox);
        top.add(jbtSelect);
        jpCourse.add(top, BorderLayout.NORTH);
        //不可编辑表格内容
        JTable table = new JTable() {
            public boolean isCellEditable(int row, int column) {
                return false;
            }
        };
        JScrollPane tab = new JScrollPane(table);
        //表格内容居中且换行
        TableViewRenderer tableViewRenderer = new TableViewRenderer();          //自定义表格格式渲染器
        tableViewRenderer.setPreferredSize(new Dimension(50, 75));
        tableViewRenderer.setBackground(new Color(211, 211, 211));
        table.setDefaultRenderer(Object.class, tableViewRenderer);
        //表格表头居中
        DefaultTableCellHeaderRenderer hr = new DefaultTableCellHeaderRenderer();
        hr.setHorizontalAlignment(JLabel.CENTER);
        hr.setPreferredSize(new Dimension(50, 78));
        table.getTableHeader().setDefaultRenderer(hr);
        //设置面板大小
        tab.setPreferredSize(new Dimension(750, 472));
        //设置透明
        tab.setOpaque(false);
        tab.getViewport().setOpaque(false);
        jpCourse.add(tab, BorderLayout.CENTER);
        jbtSelect.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Object cp_year = comboBox.getSelectedItem();
                List<Teacher_class> teachingclass = new StudentService().getTeachingclass(student.getS_id(), (String) cp_year);
                Object[][] tableDate = new Object[5][6];
                tableDate[0][0] = "\n\n          1-2节";
                tableDate[1][0] = "\n\n          3-4节";
                tableDate[2][0] = "\n\n          5-6节";
                tableDate[3][0] = "\n\n          7-8节";
                tableDate[4][0] = "\n\n          9-10节";
                for (int i = 0; i < 5; i++) {
                    for (int j = 1; j < 6; j++) {
                        tableDate[i][j] = "";
                    }
                }
                String[] name = {" ", "周一", "周二", "周三", "周四", "周五"};
                for (int i = 0; i < teachingclass.size(); i++) {
                    String res;
                    String tc_time = teachingclass.get(i).getTc_time();
                    //获得最终上课时间与地点
                    String[] res_time = tc_time.split(" ");
                    for (int j = 0; j < res_time.length; j++) {
                        int week = res_time[j].charAt(0) - '0';
                        int section = res_time[j].charAt(2) - '0';
                        res = "\n  " + teachingclass.get(i).getTc_name() + "\n  " + teachingclass.get(i).getTc_point();
                        tableDate[section - 1][week] = res;
                    }
                }
                table.removeAll();
                DefaultTableModel tableModel = (DefaultTableModel) table.getModel();    //获得表格模型
                tableModel.setRowCount(0);    //清空表格中的数据
                tableModel.setColumnIdentifiers(name);    //设置表头
                for (int i = 0; i < 5; i++) {
                    tableModel.addRow(tableDate[i]);
                }
                table.setRowHeight(78);
                table.setModel(tableModel);    //应用表格模型
            }
        });
        return jpCourse;
    }

    /*
    * 选择课程
    * */
    public JPanel getSelectCourse(){
        JPanel jpSC = new JPanel(new BorderLayout());
        JPanel top = new JPanel();
        JLabel jlYear = new JLabel("学年:");
        JComboBox<String> comboBox = new JComboBox<>();
        comboBox.addItem("--请选择--");    //向下拉列表中添加一项
        List<String> year = new StudentService().getYear();
        for (String str : year) {
            comboBox.addItem(str);
        }
        JButton jbtSelect = new JButton("查询");
        JButton jbtAdd = new JButton("选择");
        top.add(jbtAdd);
        top.add(jlYear);
        top.add(comboBox);
        top.add(jbtSelect);
        jpSC.add(top, BorderLayout.NORTH);

        JTable table = new JTable() {
            public boolean isCellEditable(int row, int column) {
                return false;
            }
        };
        JScrollPane tab = new JScrollPane(table);
        //表格内容居中
        DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();//单元格渲染器
        tcr.setHorizontalAlignment(JLabel.CENTER);
        table.setDefaultRenderer(Object.class, tcr);
        //表格表头居中
        DefaultTableCellHeaderRenderer hr = new DefaultTableCellHeaderRenderer();
        hr.setHorizontalAlignment(JLabel.CENTER);
        hr.setPreferredSize(new Dimension(25, 25));
        table.getTableHeader().setDefaultRenderer(hr);
        //设置面板大小
        tab.setPreferredSize(new Dimension(750, 480));
        //设置透明
        tab.setOpaque(false);
        tab.getViewport().setOpaque(false);
        jpSC.add(tab, BorderLayout.CENTER);
        JFrame jf = this;
        //查询选课点击事件
        jbtSelect.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Object cp_year = comboBox.getSelectedItem();
                List<Seclet_Course> selectCourse = new StudentService().getSelectcourse(student.getS_id(), (String)cp_year);
                System.out.println(selectCourse);
                Object[][] tableDate = new Object[selectCourse.size()][5];
                for (int i = 0; i < selectCourse.size(); i++) {
                    for (int j = 0; j < 5; j++) {
                        if (j == 0)
                            tableDate[i][j] = selectCourse.get(i).getCourseName();
                        else if (j == 1)
                            tableDate[i][j] = selectCourse.get(i).getCredit();
                        else if (j == 2)
                            tableDate[i][j] = selectCourse.get(i).getTeacherClass();
                        else if (j == 3)
                            tableDate[i][j] = selectCourse.get(i).getTeacherName();
                        else {
                            String str = "";
                            str += selectCourse.get(i).getCoursePoint();
                            str += '/';
                            String[] s = selectCourse.get(i).getCourseTime().split(" ");
                            for (int k = 0; k < s.length; k++) {
                                str += Tool.getWeek(s[k].charAt(0));
                                str += Tool.getPitch(s[k].charAt(2));
                                if (k != s.length - 1)
                                    str += ',';
                            }
                            tableDate[i][j] = str;
                        }
                    }
                }
                String[] name = {"课程名", "课程学分", "课程班级", "教学教师", "上课地点/上课时间"};
                table.removeAll();
                DefaultTableModel tableModel = (DefaultTableModel) table.getModel();    //获得表格模型
                tableModel.setRowCount(0);    //清空表格中的数据
                tableModel.setColumnIdentifiers(name);    //设置表头
                for (int i = 0; i < selectCourse.size(); i++) {
                    tableModel.addRow(tableDate[i]);
                }
                Tool.setColumnSize(table, 0, 140, 140, 140);
                Tool.setColumnSize(table, 1, 80, 80, 80);
                Tool.setColumnSize(table, 2, 140, 140, 140);
                Tool.setColumnSize(table, 3, 80, 80, 80);
                table.setRowHeight(30);
                table.setModel(tableModel);    //应用表格模型
            }
        });
        //增加课程
        jbtAdd.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    int count = table.getSelectedRow();//获取你选中的行号(记录)
                    System.out.println(count);
                    String className = table.getValueAt(count, 2).toString();//读取你获取行号的某一列的值(也就是字段)
                    System.out.println(className);
                    Object cp_year = comboBox.getSelectedItem();
                    List<Seclet_Course> courses = new StudentService().getSelectcourse(student.getS_id(), (String) cp_year);
                    //选中的课程安排
                    String courseTime = courses.get(count).getCourseTime();
                    //判断是否与当前课程冲突
                    boolean conflict = new StudentService().isConflict(student.getS_id(), (String) cp_year, courseTime);
                    if (conflict) {
                        JOptionPane.showMessageDialog(jf, "请检查选择的课是否与已选的选课冲突!", "错误 ", JOptionPane.ERROR_MESSAGE);
                    } else {
                        boolean courseAdd = new StudentService().courseAdd(className, student.getS_id());
                        System.out.println(courseAdd);
                        if (courseAdd)
                            JOptionPane.showMessageDialog(jf, "选课成功!", "提示", JOptionPane.PLAIN_MESSAGE);
                        else
                            JOptionPane.showMessageDialog(jf, "请检查是否已选择该课", "错误 ", JOptionPane.ERROR_MESSAGE);
                    }
                } catch (Exception e1) {
                    JOptionPane.showMessageDialog(jf, "未选择要选修的课程!", "错误 ", JOptionPane.ERROR_MESSAGE);
                }
            }
        });
        return jpSC;
    }
    /*
    * 获取学生成绩
    * */
    public JPanel getStudentgrade() {
        JPanel jpGrade = new JPanel(new BorderLayout());
        JPanel top = new JPanel();
        JLabel jlYear = new JLabel("学年:");
        JComboBox<String> comboBox = new JComboBox<>();
        comboBox.addItem("--请选择--");    //向下拉列表中添加一项
        List<String> year = new StudentService().getYear();
        for (String str : year) {
            comboBox.addItem(str);
        }
        JButton jbtSelect = new JButton("查询");
        top.add(jlYear);
        top.add(comboBox);
        top.add(jbtSelect);
        jpGrade.add(top, BorderLayout.NORTH);
        JTable table = new JTable() {
            public boolean isCellEditable(int row, int column) {
                return false;
            }
        };
        JScrollPane tab = new JScrollPane(table);
        //表格内容居中
        DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();//单元格渲染器
        tcr.setHorizontalAlignment(JLabel.CENTER);
        table.setDefaultRenderer(Object.class, tcr);
        //表格表头居中
        DefaultTableCellHeaderRenderer hr = new DefaultTableCellHeaderRenderer();
        hr.setHorizontalAlignment(JLabel.CENTER);
        hr.setPreferredSize(new Dimension(25, 25));
        table.getTableHeader().setDefaultRenderer(hr);
        //设置面板大小
        tab.setPreferredSize(new Dimension(650, 500));
        //设置透明
        tab.setOpaque(false);
        tab.getViewport().setOpaque(false);
        jpGrade.add(tab, BorderLayout.CENTER);
        jbtSelect.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Object cp_year = comboBox.getSelectedItem();
                List<Grade> grade = new StudentService().getGrade(student.getS_id(), (String) cp_year);
                Object[][] tableDate = new Object[grade.size()][5];
                for (int i = 0; i < grade.size(); i++) {
                    for (int j = 0; j < 5; j++) {
                        if (j == 0)
                            tableDate[i][j] = grade.get(i).getS_id();
                        else if (j == 1)
                            tableDate[i][j] = grade.get(i).getCourse_name();
                        else if (j == 2)
                            tableDate[i][j] = grade.get(i).getG_ps();
                        else if (j == 3)
                            tableDate[i][j] = grade.get(i).getG_exam();
                        else
                            tableDate[i][j] = grade.get(i).getG_final();
                    }
                }
                String[] name = {"学号", "课程名", "平时性成绩", "考试成绩","总成绩"};
                table.removeAll();
                DefaultTableModel tableModel = (DefaultTableModel) table.getModel();    //获得表格模型
                tableModel.setRowCount(0);    //清空表格中的数据
                tableModel.setColumnIdentifiers(name);    //设置表头
                Tool.setColumnSize(table,1,10,160,160);
                for (int i = 0; i < grade.size(); i++) {
                    tableModel.addRow(tableDate[i]);
                }
                table.setRowHeight(30);
                table.setModel(tableModel);    //应用表格模型
            }
        });
        return jpGrade;
    }
    /*
    * 通知管理页面
    * */
    public JPanel getInform() {
        JPanel jpGrade = new JPanel(new BorderLayout());
        JPanel top = new JPanel();
        List<Thing> things = new StudentService().GetInform();
        jpGrade.add(top, BorderLayout.NORTH);
        JTable table = new JTable() {
            public boolean isCellEditable(int row, int column) {
                return false;
            }
        };
        JScrollPane tab = new JScrollPane(table);
        //表格内容居中
        DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();//单元格渲染器
        tcr.setHorizontalAlignment(JLabel.CENTER);
        table.setDefaultRenderer(Object.class, tcr);
        //表格表头居中
        DefaultTableCellHeaderRenderer hr = new DefaultTableCellHeaderRenderer();
        hr.setHorizontalAlignment(JLabel.CENTER);
        hr.setPreferredSize(new Dimension(25, 25));
        table.getTableHeader().setDefaultRenderer(hr);
        //设置面板大小
        tab.setPreferredSize(new Dimension(650, 500));
        //设置透明
        tab.setOpaque(false);
        tab.getViewport().setOpaque(false);
        jpGrade.add(tab, BorderLayout.CENTER);


        List<Thing> inform = new StudentService().GetInform();
        Object[][] tableDate = new Object[inform.size()][5];
        for (int i = 0; i < inform.size(); i++) {
            for (int j = 0; j < 5; j++) {
                if (j == 0)
                    tableDate[i][j] = inform.get(i).getThingtxt();
                else if (j == 1)
                    tableDate[i][j] = inform.get(i).getYear();
                else if (j == 2)
                    tableDate[i][j] = inform.get(i).getTine();
            }
        }
        String[] name = {"通知", "年份", "时间"};
        table.removeAll();
        DefaultTableModel tableModel = (DefaultTableModel) table.getModel();    //获得表格模型
        tableModel.setRowCount(0);    //清空表格中的数据
        tableModel.setColumnIdentifiers(name);    //设置表头
        Tool.setColumnSize(table,1,10,160,160);
        for (int i = 0; i < inform.size(); i++) {
            tableModel.addRow(tableDate[i]);
        }
        table.setRowHeight(30);
        table.setModel(tableModel);    //应用表格模型
//        jbtSelect.addActionListener(new ActionListener() {
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                List<Thing> inform = new StudentService().GetInform();
//                Object[][] tableDate = new Object[inform.size()][5];
//                for (int i = 0; i < inform.size(); i++) {
//                    for (int j = 0; j < 5; j++) {
//                        if (j == 0)
//                            tableDate[i][j] = inform.get(i).getThingtxt();
//                        else if (j == 1)
//                            tableDate[i][j] = inform.get(i).getYear();
//                        else if (j == 2)
//                            tableDate[i][j] = inform.get(i).getTine();
//                    }
//                }
//                String[] name = {"通知", "年份", "时间"};
//                table.removeAll();
//                DefaultTableModel tableModel = (DefaultTableModel) table.getModel();    //获得表格模型
//                tableModel.setRowCount(0);    //清空表格中的数据
//                tableModel.setColumnIdentifiers(name);    //设置表头
//                Tool.setColumnSize(table,1,10,160,160);
//                for (int i = 0; i < inform.size(); i++) {
//                    tableModel.addRow(tableDate[i]);
//                }
//                table.setRowHeight(30);
//                table.setModel(tableModel);    //应用表格模型
//            }
//        });
        return jpGrade;
    }


    /*学生个人信息以及修改密码面板*/
    public JPanel getStudentuser() {
        JPanel jpStudentuser = new JPanel(new GridLayout(6, 2, 2, 2));
        JPanel jPanel = new JPanel(new BorderLayout());
        JFrame jf = this;
        JLabel jlId = new JLabel("学号:");
        JLabel jlName = new JLabel("姓名:");
        JLabel jlSex = new JLabel("性别:");
        JLabel jlAc = new JLabel("学院:");
        JLabel jlClass = new JLabel("行政班级:");
        JTextField jtfId = new JTextField(10);
        jtfId.setEditable(false);
        jtfId.setText(student.getS_id());
        JTextField jtfName = new JTextField(10);
        jtfName.setEditable(false);
        jtfName.setText(student.getS_name());
        JTextField jtfSex = new JTextField(10);
        jtfSex.setEditable(false);
        jtfSex.setText(student.getS_sex());
        JTextField jtfAc = new JTextField(10);
        jtfAc.setEditable(false);
        String ac = new StudentService().GetAcademyName(student.getC_id());
        jtfAc.setText(ac);
        JTextField jtfClass = new JTextField(10);
        jtfClass.setEditable(false);
        jtfClass.setText(student.getC_id());
        JButton jbt = new JButton("修改密码");
        JButton jbtQuit = new JButton("退出");
        JPanel jpBottom = new JPanel();
        jpBottom.add(jbt);
        jpBottom.add(jbtQuit);
        jpStudentuser.add(jlId);
        jpStudentuser.add(jtfId);
        jpStudentuser.add(jlName);
        jpStudentuser.add(jtfName);
        jpStudentuser.add(jlSex);
        jpStudentuser.add(jtfSex);
        jpStudentuser.add(jlAc);
        jpStudentuser.add(jtfAc);

        jpStudentuser.add(jlClass);
        jpStudentuser.add(jtfClass);
        jPanel.add(jpStudentuser, BorderLayout.NORTH);
        jPanel.add(jpBottom, BorderLayout.CENTER);
        //修改密码事件
        jbt.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JPasswordField jpOldPassword = new JPasswordField();
                JPasswordField jpPassword = new JPasswordField();
                JPasswordField jpRepassword = new JPasswordField();
                Object[] message = {
                        "旧密码:", jpOldPassword,
                        "新密码:", jpPassword,
                        "重复新密码:", jpRepassword
                };
                int option = JOptionPane.showConfirmDialog(jf, message, "修改密码", JOptionPane.YES_OPTION);
                if (option == JOptionPane.YES_OPTION) {
                    String oldPassword = new StudentService().GetOldPassword(student.getS_id());
                    if (!oldPassword.equals(Tool.transitionPassword(jpOldPassword.getPassword()))) {
                        JOptionPane.showMessageDialog(jf, "原密码输入错误", "错误 ", 0);
                    } else if (!Tool.transitionPassword(jpPassword.getPassword()).equals(Tool.transitionPassword(jpRepassword.getPassword()))) {
                        JOptionPane.showMessageDialog(jf, "两次密码输入不一致", "错误 ", 0);
                    } else {
                        if (new StudentService().updatePassword(Tool.transitionPassword(jpPassword.getPassword()), student.getS_id())) {
                            JOptionPane.showMessageDialog(jf, "密码修改成功!", "提示", JOptionPane.PLAIN_MESSAGE);
                            jf.dispose();
                            new Login().setVisible(true);
                        }
                    }
                }
            }
        });
        //退出事件
        jbtQuit.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                jf.dispose();
                new Login().setVisible(true);
            }
        });
        return jPanel;
    }

}

TeacherView

package com.dwz.View;

import com.dwz.Pojo.Grade;
import com.dwz.Pojo.Teacher;
import com.dwz.Pojo.TeacherPlan;
import com.dwz.Service.StudentService;
import com.dwz.Service.TeacherService;
import com.dwz.Utlis.Button;
import com.dwz.Utlis.Tool;
import com.dwz.Utlis.replacementPanel;
import sun.swing.table.DefaultTableCellHeaderRenderer;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

public class TeacherView extends JFrame {
    Teacher teacher;
    /*首页面板*/
    public JPanel getTeacherhome() {
        JPanel jpHome = new JPanel();
        JTextArea textArea = new JTextArea();
        String text = teacher.getT_name();
        text += "老师:欢迎使用教务管理系统!";
        ImageIcon imageIcon = new ImageIcon("src/main/resources/img/fd.png");
        JLabel jLabel = new JLabel(imageIcon);
        Dimension dimension = new Dimension(800, 500);
        jLabel.setPreferredSize(dimension);

        textArea.setText(text);
        textArea.setFont(new Font("黑体", 1, 30));
        jpHome.add(textArea);
        jpHome.add(jLabel,BorderLayout.NORTH);
        return jpHome;
    }
    /*主页面板*/
    public JPanel getTeacherhome1() {
        JPanel jpHome = new JPanel();
        JTextArea textArea = new JTextArea();
        String text = teacher.getT_name();
        text += "老师:欢迎使用教务管理系统!";
        textArea.setText(text);
        textArea.setFont(new Font("黑体", 1, 30));
        jpHome.add(textArea);
        return jpHome;
    }


    public TeacherView(Teacher teacher) {
        super("教务管理系统");
        this.teacher = teacher;
        Container cp = this.getContentPane();
        cp.setLayout(new BorderLayout());
        JButton jbtHome = new Button().getButton("首页", "img/shouyefill.png");
        JButton jbtArrangement = new Button().getButton("教学安排", "img/mianshoujiaoxueanpai.png");
        JButton jbtGradeinput = new Button().getButton("成绩录入", "img/chengjiluru.png");
        JButton jbtUser = new Button().getButton("个人中心", "img/laoshi.png");
        JPanel bar = new JPanel();
        bar.add(jbtHome);
        bar.add(jbtArrangement);
        bar.add(jbtGradeinput);
        bar.add(jbtUser);
        JPanel mid = getTeacherhome();
        cp.add(bar, BorderLayout.NORTH);
        cp.add(mid, BorderLayout.CENTER);
        this.setSize(800, 650);
        //居中
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jbtHome.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new replacementPanel().replacement(mid,getTeacherhome1());
            }
        });
        jbtArrangement.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new replacementPanel().replacement(mid,getArrangement());
            }
        });
        jbtGradeinput.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new replacementPanel().replacement(mid,getGradeinput());
            }
        });
        jbtUser.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new replacementPanel().replacement(mid,getUser());
            }
        });
    }
    /*
    * 得到教学计划
    * */
    public JPanel getArrangement() {
        JPanel arrangement = new JPanel(new BorderLayout());
        class TableViewRenderer extends JTextArea implements TableCellRenderer {
            public TableViewRenderer() {
                //将表格设为自动换行
                setLineWrap(true);
                setWrapStyleWord(true);
            }
            public Component getTableCellRendererComponent(JTable jtable, Object obj, //obj指的是单元格内容
                                                           boolean isSelected, boolean hasFocus, int row, int column) {
                setText(obj == null ? "" : obj.toString()); //利用JTextArea的setText设置文本方法
                return this;
            }
        }
        JPanel top = new JPanel();
        JLabel jlYear = new JLabel("学年:");
        JComboBox<String> comboBox = new JComboBox<>();
        comboBox.addItem("--请选择--");    //向下拉列表中添加一项
        java.util.List<String> year = new StudentService().getYear();
        for (String str : year) {
            comboBox.addItem(str);
        }
        JButton jbtSelect = new JButton("查询");
        top.add(jlYear);
        top.add(comboBox);
        top.add(jbtSelect);
        arrangement.add(top, BorderLayout.NORTH);
        //不可编辑表格内容
        JTable table = new JTable() {
            public boolean isCellEditable(int row, int column) {
                return false;
            }
        };
        JScrollPane tab = new JScrollPane(table);
        //表格内容居中
        DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();//单元格渲染器
        TableViewRenderer tableViewRenderer = new TableViewRenderer();
        tableViewRenderer.setPreferredSize(new Dimension(50, 75));
        tableViewRenderer.setBackground(new Color(211, 211, 211));
        table.setDefaultRenderer(Object.class, tableViewRenderer);
        //表格表头居中
        DefaultTableCellHeaderRenderer hr = new DefaultTableCellHeaderRenderer();
        hr.setHorizontalAlignment(JLabel.CENTER);
        hr.setPreferredSize(new Dimension(50, 78));
        table.getTableHeader().setDefaultRenderer(hr);
        //设置面板大小
        tab.setPreferredSize(new Dimension(750, 472));
        //设置透明
        tab.setOpaque(false);
        tab.getViewport().setOpaque(false);
        arrangement.add(tab, BorderLayout.CENTER);
        jbtSelect.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Object cp_year = comboBox.getSelectedItem();
                List<TeacherPlan> teachingplan = new TeacherService().GetTeacherPlan(teacher.getT_id(), (String) cp_year);
                Object[][] tableDate = new Object[5][6];
                tableDate[0][0] = "\n\n          1-2节";
                tableDate[1][0] = "\n\n          3-4节";
                tableDate[2][0] = "\n\n          5-6节";
                tableDate[3][0] = "\n\n          7-8节";
                tableDate[4][0] = "\n\n          9-10节";
                for (int i = 0; i < 5; i++) {
                    for (int j = 1; j < 6; j++) {
                        tableDate[i][j] = "";
                    }
                }
                String[] name = {" ", "周一", "周二", "周三", "周四", "周五"};
                for (int i = 0; i < teachingplan.size(); i++) {
                    String res;
                    String tc_time = teachingplan.get(i).getTc_time();
                    //获得最终上课时间与地点
                    String[] res_time = tc_time.split(" ");
                    for (int j = 0; j < res_time.length; j++) {
                        int week = res_time[j].charAt(0) - '0';
                        int section = res_time[j].charAt(2) - '0';
                        res = "\n  " + teachingplan.get(i).getTc_name() + "\n  " + teachingplan.get(i).getTc_point();
                        tableDate[section - 1][week] = res;
                    }
                }
                table.removeAll();
                DefaultTableModel tableModel = (DefaultTableModel) table.getModel();    //获得表格模型
                tableModel.setRowCount(0);    //清空表格中的数据
                tableModel.setColumnIdentifiers(name);    //设置表头
                for (int i = 0; i < 5; i++) {
                    tableModel.addRow(tableDate[i]);
                }
                table.setRowHeight(78);
                table.setModel(tableModel);    //应用表格模型
            }
        });
        return arrangement;
    }

    public JPanel getGradeinput() {
        JPanel gradeInput = new JPanel(new BorderLayout());
        JPanel top = new JPanel();
        JLabel jlYear = new JLabel("学年:");
        JComboBox<String> comboBox = new JComboBox<>();
        comboBox.addItem("--请选择--");    //向下拉列表中添加一项
        java.util.List<String> year = new StudentService().getYear();
        for (String str : year) {
            comboBox.addItem(str);
        }
        JLabel jlClass = new JLabel("教学班级:");
        JComboBox<String> cmbClass = new JComboBox<>();
        cmbClass.addItem("--请选择--");
        JButton jbtSelect = new JButton("查询");
        JButton jbtSubmit = new JButton("提交");
        top.add(jbtSubmit);
        top.add(jlYear);
        top.add(comboBox);
        top.add(jlClass);
        top.add(cmbClass);
        top.add(jbtSelect);
        gradeInput.add(top, BorderLayout.NORTH);
        JTable table = new JTable();
        JScrollPane tab = new JScrollPane(table);
        //表格内容居中
        DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();//单元格渲染器
        tcr.setHorizontalAlignment(JLabel.CENTER);
        table.setDefaultRenderer(Object.class, tcr);
        //表格表头居中
        DefaultTableCellHeaderRenderer hr = new DefaultTableCellHeaderRenderer();
        hr.setHorizontalAlignment(JLabel.CENTER);
        hr.setPreferredSize(new Dimension(25, 25));
        table.getTableHeader().setDefaultRenderer(hr);
        //设置面板大小
        tab.setPreferredSize(new Dimension(600, 500));
        //设置透明
        tab.setOpaque(false);
        tab.getViewport().setOpaque(false);
        gradeInput.add(tab, BorderLayout.CENTER);
        JPanel bottom = new JPanel();
//        JLabel jlOrd = new JLabel("平时成绩占比:");
//        JLabel jlF = new JLabel("考试成绩占比");
//        JTextField jtfOrd = new JTextField(4);
//        JTextField jtfF = new JTextField(4);
//        bottom.add(jlOrd);
//        bottom.add(jtfOrd);
//        bottom.add(jlF);
//        bottom.add(jtfF);
//        bottom.add(jbtSubmit);
        gradeInput.add(bottom, BorderLayout.SOUTH);
        comboBox.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Object cp_year = comboBox.getSelectedItem();
                List<TeacherPlan> teachingplan = new TeacherService().GetTeacherPlan(teacher.getT_id(), (String) cp_year);
                cmbClass.removeAllItems();
                if (teachingplan.size() == 0)
                    cmbClass.addItem("无对应教学班级");
                else {
                    for (int i = 0; i < teachingplan.size(); i++) {
                        cmbClass.addItem(teachingplan.get(i).getTc_name());
                    }
                }
            }
        });
        jbtSelect.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Object className = cmbClass.getSelectedItem();
                List<Grade> gradebyClass = new TeacherService().GetGradeByClass((String) className);
                Object[][] tableDate = new Object[gradebyClass.size()][5];
                for (int i = 0; i < gradebyClass.size(); i++) {
                    for (int j = 0; j < 5; j++) {
                        if (j == 0)
                            tableDate[i][j] = gradebyClass.get(i).getS_id();
                        else if (j == 1)
                            tableDate[i][j] = gradebyClass.get(i).getS_name();
                        else if (j == 2)
                            tableDate[i][j] = gradebyClass.get(i).getG_ps();
                        else if (j == 3)
                            tableDate[i][j] = gradebyClass.get(i).getG_exam();
                        else
                            tableDate[i][j] = gradebyClass.get(i).getG_final();
                    }
                }
                String[] name = {"学号", "姓名", "平时成绩", "考试成绩", "总成绩"};
                table.removeAll();

                DefaultTableModel tableModel = (DefaultTableModel) table.getModel();    //获得表格模型

                tableModel.setRowCount(0);    //清空表格中的数据

                tableModel.setColumnIdentifiers(name);    //设置表头
                for (int i = 0; i < gradebyClass.size(); i++) {
                    tableModel.addRow(tableDate[i]);
                }
                table.setRowHeight(30);
                table.setModel(tableModel);    //应用表格模型
            }
        });
        JFrame jf = this;

        jbtSubmit.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                List<Grade> grades = new ArrayList<>();
                Object className = cmbClass.getSelectedItem();
                for (int i = 0; i < table.getRowCount(); i++) {
                    Grade grade = new Grade();
                    for (int j = 0; j < table.getColumnCount(); j++) {
                        if (j == 0)
                            grade.setS_id((String) table.getValueAt(i, j));
                        else if (j == 2)
                            grade.setG_ps(Double.valueOf(table.getValueAt(i, j).toString()));
                        else if (j == 3)
                            grade.setG_exam(Double.valueOf(table.getValueAt(i, j).toString()));
                        else if (j == 4) {
                            Double res;
//                            res = Double.valueOf(jtfOrd.getText()) * Double.valueOf(table.getValueAt(i, 2).toString())+
//                                    Double.valueOf(jtfF.getText()) * Double.valueOf(table.getValueAt(i, 3).toString());;
//                            res += Double.valueOf(jtfF.getText()) * Double.valueOf(table.getValueAt(i, 3).toString());
                            res = Double.valueOf(table.getValueAt(i, 2).toString())+
                                    Double.valueOf(table.getValueAt(i, 3).toString());
                            grade.setG_final(res);
                        } else
                            continue;
                    }
                    grades.add(grade);
                }
                if (new TeacherService().updateGrade(grades, (String) className)) {
                    JOptionPane.showMessageDialog(jf, "成绩录入成功", "提示", JOptionPane.PLAIN_MESSAGE);
                    //重新进行表格渲染
                    List<Grade> gradebyClass = new TeacherService().GetGradeByClass((String) className);
                    Object[][] tableDate = new Object[gradebyClass.size()][5];
                    for (int i = 0; i < gradebyClass.size(); i++) {
                        for (int j = 0; j < 5; j++) {
                            if (j == 0)
                                tableDate[i][j] = gradebyClass.get(i).getS_id();
                            else if (j == 1)
                                tableDate[i][j] = gradebyClass.get(i).getS_name();
                            else if (j == 2)
                                tableDate[i][j] = gradebyClass.get(i).getG_ps();
                            else if (j == 3)
                                tableDate[i][j] = gradebyClass.get(i).getG_exam();
                            else
                                tableDate[i][j] = gradebyClass.get(i).getG_final();
                        }
                    }
                    String[] name = {"学号", "姓名", "平时性成绩", "考试成绩", "总成绩"};
                    table.removeAll();
                    DefaultTableModel tableModel = (DefaultTableModel) table.getModel();    //获得表格模型
                    tableModel.setRowCount(0);    //清空表格中的数据
                    tableModel.setColumnIdentifiers(name);    //设置表头
                    for (int i = 0; i < gradebyClass.size(); i++) {
                        tableModel.addRow(tableDate[i]);
                    }
                    table.setRowHeight(30);
                    table.setModel(tableModel);    //应用表格模型
                }
            }
        });
        return gradeInput;
    }

    /*用户管理面板*/
    public JPanel getUser() {
        JPanel jpTeacheruser = new JPanel(new GridLayout(6, 2, 2, 2));
        JPanel jPanel = new JPanel(new BorderLayout());
        JFrame jf = this;
        JLabel jlId = new JLabel("教师号:");
        JLabel jlName = new JLabel("姓名:");
        JLabel jlSex = new JLabel("性别:");
        JTextField jtfId = new JTextField(10);
        jtfId.setEditable(false);
        jtfId.setText(teacher.getT_id());
        JTextField jtfName = new JTextField(10);
        jtfName.setEditable(false);
        jtfName.setText(teacher.getT_name());
        JTextField jtfSex = new JTextField(10);
        jtfSex.setEditable(false);
        jtfSex.setText(teacher.getT_sex());
//        JTextField jtfDate = new JTextField(10);
//        jtfDate.setEditable(false);
//        jtfDate.setText(teacher.getT_date());
        JButton jbt = new JButton("修改密码");
        JButton jbtQuit = new JButton("退出");
        JPanel jpBottom = new JPanel();
        jpBottom.add(jbt);
        jpBottom.add(jbtQuit);
        jpTeacheruser.add(jlId);
        jpTeacheruser.add(jtfId);
        jpTeacheruser.add(jlName);
        jpTeacheruser.add(jtfName);
        jpTeacheruser.add(jlSex);
        jpTeacheruser.add(jtfSex);

//        jpTeacheruser.add(jtfDate);
        jPanel.add(jpTeacheruser, BorderLayout.NORTH);
        jPanel.add(jpBottom, BorderLayout.CENTER);
        //修改密码事件
        jbt.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JPasswordField jpOldPassword = new JPasswordField();
                JPasswordField jpPassword = new JPasswordField();
                JPasswordField jpRepassword = new JPasswordField();
                Object[] message = {
                        "旧密码:", jpOldPassword,
                        "新密码:", jpPassword,
                        "重复新密码:", jpRepassword
                };
                int option = JOptionPane.showConfirmDialog(jf, message, "修改密码", JOptionPane.YES_OPTION);
                if (option == JOptionPane.YES_OPTION) {
                    String oldPassword = new StudentService().GetOldPassword(teacher.getT_id());
                    if (!oldPassword.equals(Tool.transitionPassword(jpOldPassword.getPassword()))) {
                        JOptionPane.showMessageDialog(jf, "原密码输入错误", "错误 ", 0);
                    } else if (!Tool.transitionPassword(jpPassword.getPassword()).equals(Tool.transitionPassword(jpRepassword.getPassword()))) {
                        JOptionPane.showMessageDialog(jf, "两次密码输入不一致", "错误 ", 0);
                    } else {
                        if (new StudentService().updatePassword(Tool.transitionPassword(jpPassword.getPassword()), teacher.getT_id())) {
                            JOptionPane.showMessageDialog(jf, "密码修改成功!", "提示", JOptionPane.PLAIN_MESSAGE);
                            jf.dispose();
                            new Login().setVisible(true);
                        }
                    }
                }
            }
        });
        //退出事件
        jbtQuit.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                jf.dispose();
                new Login().setVisible(true);
            }
        });
        return jPanel;
    }
}

Login

package com.dwz.View;

import com.dwz.Pojo.User;
import com.dwz.Service.StudentService;
import com.dwz.Service.TeacherService;
import com.dwz.Service.UserService;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

public class Login extends JFrame {
    JTextField jtfId = new JTextField(15);
    JPasswordField jpfPassword = new JPasswordField(15);
    JLabel jlId = new JLabel("账号:");
    JLabel jlPassword = new JLabel("密码:");
    JButton jbtLogin = new JButton("登录");

    public Login(){
        this.setTitle("教务管理系统");
        this.setLayout(new FlowLayout());

        ImageIcon imageIcon = new ImageIcon("src/main/resources/img/img.png");
        JLabel jLabel = new JLabel(imageIcon);
        Dimension dimension = new Dimension(308, 133);
        jLabel.setPreferredSize(dimension);
        this.add(jLabel);

        JPanel Jlogin = new JPanel();
        Jlogin.add(jlId);
        Jlogin.add(jtfId);

        JPanel jpPassword = new JPanel();
        jpPassword.add(jlPassword);
        jpPassword.add(jpfPassword);

        JPanel jpLogin = new JPanel();
        jpLogin.add(jbtLogin);

        this.add(Jlogin);
        this.add(jpPassword);
        this.add(jpLogin);
        /*this.pack(); //设置初始大小*/
        this.setSize(308, 290);
        //居中
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JFrame jf = this;
        jpfPassword.addKeyListener(new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent pwd) {
                if(pwd.getKeyChar() == '\n')
                    jbtLogin.doClick();
            }
        });
        jbtLogin.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String uId = jtfId.getText();
                String uPassword = "";
                char[] password = jpfPassword.getPassword();
                for (int i = 0; i < password.length; i++) {
                    uPassword += password[i];
                }
                User user = new User(uId, uPassword, null);
                UserService userService = new UserService();
                if (userService.judgeUser(user)) {
                    if (user.getU_status().equals("老师")) {
                        jf.dispose();
                        TeacherView teacherView = new TeacherView(new TeacherService().getTeacher(uId));
                        teacherView.setVisible(true);
                    } else if (user.getU_status().equals("学生")){
                        jf.dispose();
                        StudentsView studentsView = new StudentsView(new StudentService().getStudent(uId));
                        studentsView.setVisible(true);
                    }else {
                        jf.dispose();
                        AdminView adminView = new AdminView(new UserService().getUser(uId));
                        adminView.setVisible(true);
                    }
                }else {
                    JOptionPane.showMessageDialog(jf, "用户名密码输入有误,请重新输入", "错误", JOptionPane.WARNING_MESSAGE);
                }
            }
        });
    }
}

EMSmain

package com.dwz.View;

public class EMSmain {
    public static void main(String[] args) {
        new Login().setVisible(true);
    }
}

到了这里,关于Java教务管理系统的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 数据库--教务管理系统(数据库部分--Java-jdbc连接)

    我所设计的教务管理系统包括6大部分,学生信息、教师信息、课程信息、班级信息、选课信息、教授信息。该系统可以通过不同的群体进行操作:学生群体可以对个人信息、班级、教师信息进行查询操作,对于课程则可以进行选课操作;教师群体可以个人信息、班级信息、学

    2024年02月03日
    浏览(58)
  • 基于Java+Vue+uniapp微信小程序高校教务管理系统设计和实现

    博主介绍 : ✌ 全网粉丝30W+,csdn特邀作者、博客专家、CSDN新星计划导师、Java领域优质创作者,博客之星、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战 ✌ 🍅 文末获取源码联系 🍅 👇🏻 精彩专栏 推荐订阅 👇🏻 不然下次找不到哟 2022-2024年

    2024年02月05日
    浏览(85)
  • 基于微信小程序的教学教务管理系统(后台Java+SSM+MySQL)

    目 录 摘 要 I ABSTRACT II 第1章 绪论 1 1.1 研究目的及意义 1 1.2 国内外研究现状 1 1.3研究内容及结构 2 1.3.1研究主要内容 2 1.3.2论文结构 2 第2章 相关技术说明 4 2.1 Java语言 4 2.2 SSM框架 5 2.3 Vue.js框架 6 2.4 Eclipse开发工具 7 2.5 数据库 8 2.6系统开发环境概述 9 第3章 系统需求分析 11 3

    2024年02月09日
    浏览(60)
  • 【附源码】基于Java的教务管理系统q61909计算机毕设SSM

    项目运行环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。 项目技术: Springboot + mybatis + Maven +mysql5.7或8.0+html+css+js等等组成,B/S模式 + Maven管理等等。 环境需要 1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其

    2024年02月06日
    浏览(46)
  • Springboot 订餐管理系统idea开发mysql数据库web结构java编程计算机网页源码maven项目

    一、源码特点   springboot 订餐管理系统是一套完善的信息系统,结合springboot框架和bootstrap完成本系统,对理解JSP java编程开发语言有帮助系统采用springboot框架(MVC模式开发),系统具有 完整的源代码和数据库,系统主要采用B/S模式开发。 前段主要技术 bootstrap.css jquery 后端主

    2024年02月07日
    浏览(49)
  • ideaSSM医院挂号管理系统VS开发mysql数据库web结构java编程计算机网页源码maven项目

    一、源码特点   SSM医院挂号管理系统是一套完善的完整医院类型系统,结合SSM框架和bootstrap完成本系统SpringMVC spring mybatis ,对理解JSP java编程开发语言有帮助系统采用SSM框架(MVC模式 开发),系统具有完整的源代码和数据库,系统主要采用B/S模式开发。 ideaSSM医院挂号管理系

    2024年02月03日
    浏览(38)
  • 【开源】基于JAVA的个人健康管理系统

    项目编号: S 040 ,文末获取源码。 color{red}{项目编号:S040,文末获取源码。} 项目编号: S 040 ,文末获取源码。 基于JAVA+Vue+SpringBoot+MySQL的个人健康管理系统,包含了健康档案模块、体检档案模块、健康咨询模块,还包含系统自带的用户管理、部门管理、角色管理、菜单管

    2024年02月04日
    浏览(50)
  • 【开源】基于JAVA语言的个人健康管理系统

    项目编号: S 040 ,文末获取源码。 color{red}{项目编号:S040,文末获取源码。} 项目编号: S 040 ,文末获取源码。 基于JAVA+Vue+SpringBoot+MySQL的个人健康管理系统,包含了健康档案模块、体检档案模块、健康咨询模块,还包含系统自带的用户管理、部门管理、角色管理、菜单管

    2024年02月04日
    浏览(60)
  • 基于SSM框架开发的教务管理系统(毕业设计,期末设计)

    目录 🍬1 前言 1.1 项目所需要的知识 1.2 开发项目的环境和工具 🍬2 系统结构 2.1系统流程图(E-R图) 2.2配置pom.xml 🍬3 程序设计及运行 3.1添加课程信息 (1)功能描述 (2)实现代码 (3)实现截图 3.2学生已修课程 (1)功能描述 (2)实现代码 (3)实现截图 3.3添加教师信

    2024年02月08日
    浏览(66)
  • ssm368基于java web个人财务管理系统+jsp

    文章仅展示部分内容,详细的毕设论文和演示视频源代码可以私信我的扣扣 题目:基于java web个人财务管理系统 摘 要 随着软件信息技术的兴起,许多手工作业也升级为软件管理数据,本次针对个人财务数据的管理,开发一款个人财务管理系统,该系统可以解决许多信息管理

    2024年02月20日
    浏览(44)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包