基于springboot的高校评价教师工作量管理系统设计
前端:若依(vue3)
后端:springboot + mybatis-plus
2024-3-22
从零开始的若依框架学习
准备好了运行若依前后端分离项目所需的编程环境
开发环境搭建
后端开发环境的搭建
- 安装JDK,并且配置环境变量(已完成)
- 安装MAVEN,配置环境变量,配置阿里云的镜像(已完成)
- 安装IDEA开发工具(已完成)
- 安装npm,配置华为云的镜像(已完成)
前端开发环境搭建
- NODE.JS安装版本V16(已完成)
- 安装VSCODE开发工具 (已完成)
数据库环境搭建与配置
- 安装MYSQL数据库(已完成)
- 安装一个数据库可视化的工具NaviCat (已完成)
- 安装REDIS缓存数据库(已完成)
代码备份
- 安装Git(已完成)
该系统使用Spring框架搭建后端
使用vue3和element-ui以及ruoyi框架搭建前端
使用MySQL和NavCat进行数据库的管理
使用Mybatis和Mybatis-Plus等技术来处理数据库后端与数据库的操作
使用Redis作为前端与数据库之间的缓存
设计并架构高校教师工作量管理的OA系统
2024-3-23
前端启动
- 右键项目根目录下的ruoyi-ui,选择Open in Terminal,意为在此处打开终端
- 终端输入
npm install
,安装npm以及相关组件 - 终端输入
npm run dev
,启动前端 - 启动成功后会自动弹出前端网页
后端启动
-
创建名为ruoyi的数据库
-
在ruoyi数据库中,执行项目根目录下的sql文件夹中的.sql文件
-
在idea右侧的Datebase数据库中连接ruoyi数据库(可选)
-
修改数据库参数,文件位于项目根目录下的ruoyi-admin→src→main→resources→application-druid.yml,修改数据库名、用户名、密码
-
修改依赖,文件位于项目根目录下的ruoyi-admin→pom.xml,把
<!-- Mysql驱动包 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-jave</artifactId> </dependency>
修改为
<!-- Mysql驱动包 --> <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> <version>8.0.33</version> </dependency>
不然启动会报错
-
刷新一遍maven,在idea右侧的Maven中执行
mvn clean
,然后再执行mvn compile
-
重新build一次项目
-
启动Redis
-
启动RuoYiApplication(启动项目)
Git添加
- 点击idea上方的VCS,选择倒数第三个选项,然后选择git base here,选择当前项目文件夹
- 点击idea左侧的Commit,全选文件,然后输入提交描述,点击Commit按钮
- 打开Gitee官网,选择创建仓库,然后复制仓库地址
- 点击idea上方的VCS,选择Git,然后点击Push,再在弹出的窗口点击左上角的分支,把仓库地址粘贴进去,点击Push按钮
- 到Gitee的仓库网页中确认是否Push成功
系统结构
教师工作量管理系统
- 个人中心
- 教师管理
- 分类信息管理
- 课程信息管理
- 工作量管理
- 系统管理
2024-3-24
数据库表结构分析
该系统只有两种角色,一种是管理员,另一种是教师
学校教务处即为管理员,管理员可以管理所有人的账号信息,包括修改密码、删除用户等;还可以给教师安排课表,以及统计教师的工作量并反映到图表上
教师可以编辑自己的个人信息,查看自己当前课表,
教师有以下方面的信息会纳入工作量评价标准:
-
授课(√)
-
担任班主任、辅导员,需要坐班答疑、巡视学生生活情况等(√)
-
编写科研论文、参与教研活动(√)
-
编写教材、教案,审编教材、教案(√)
-
参与学生成绩考核,编写试题,批改试卷(√)
-
指导学生毕业设计(√)
-
考证,开展讲座等其他活动(√)
数据库表就可以如下设置:
用户表
user(用户)表:储存用户账号信息以及系统角色:
id(数据库ID)
username(用户名)
password(密码)
role(角色)只有两种角色,0是管理员,1是教师
教师表
teacher(教师)表:存储教师的个人信息。字段如下:
t_id(数据库ID)
t_number(教师工号)
t_name(教师名字)
t_sex(教师性别)
t_college(所属学院)
t_photo(教师照片)
t_phone(教师电话)
t_email(教师邮箱)
t_post(职务)可以是辅导员、班主任等,该项与工作量评价有关
last_update_time(最后更新时间)
该表大部分信息都可以由教师自行填写到一份Excel表格中,然后统一录入
照片可以由教师自行上传
工号、学院、职务由管理员进行统一的设置,教师不可自行填写/修改
每次修改过后都会记录更新时间
课程表
course(课程)表:存储教师的上课信息。字段如下:
c_id(数据库ID)
c_name(课程名)
c_time(上课时间)
c_local(上课地点)
t_id(上课教师id)
t_name(上课教师名)
c_term(上课学期)1代表上学期,2代表下学期,该项与工作量评价有关
c_hour(上课总课时)该项与工作量评价有关
课程主要由管理员进行安排录入
可能会出现同名的教师,所以用教师id和教师名共同进行判断
论文表
thesis(论文)表:存储教师上传的论文信息。字段如下:
th_id(数据库ID)
t_id(教师id)
t_name(教师名)
th_name(论文名)
th_content(论文内容)
th_time(发布时间)
last_update_time(最后更新时间)
该表与工作量评价有关
教材表
textbook (教材)表:储存教师编写的教材信息。字段如下:
tx_id(数据库ID)
t_id(教师id)
t_name(教师名)
tx_name(教材名)
tx_content(教材内容)
tx_photo(教材封面)
tx_time(发布时间)
last_update_time(最后更新时间)
该表与工作量评价有关
参与学生课程成绩考核表
student_exams(参与学生课程成绩考核)表:储存教师参与学生成绩考核的信息。字段如下:
se_id(数据库ID)
t_id(教师id)
t_name(教师名)
c_name(参与的课程名)
se_content(参与的工作内容)例如编写试题、批改试卷、担任监考
se_time(参与时间)
last_update_time(最后更新时间)
该表与工作量评价有关
指导学生毕业论文表
guild_thesis(指导学生毕业论文)表:存储教师指导的学生毕业设计信息。字段如下:
gu_id(数据库ID)
t_id(教师id)
t_name(教师名)
gu_thesis(指导的毕业论文名)
gu_student(指导的学生名)
gu_time(指导时间)
last_update_time(最后更新时间)
该表与工作量评价有关
其他活动表
others(其他活动)表:储存教师参加的其他活动信息。字段如下:
ot_id(数据库ID)
t_id(教师id)
t_name(教师名)
ot_local(活动地点)
ot_content(活动内容)
ot_photo(活动图片)
ot_time(活动时间)
last_update_time(最后更新时间)
该表与工作量评价有关
数据库表具体设计
在md文档中,使用快捷键ctrl+T快速创建表格
hm是我的名字许航銘中名的首字母缩写
用户表 hm_user
字段 | 类型 | 是否允许为空 | 默认值 | 注释 |
---|---|---|---|---|
id(主键自增) | bigint(20) | 否 | 主键 | |
username | varchar(20) | 否 | 用户名 | |
password | varchar(20) | 否 | 密码 | |
role | varchar(1) | 否 | 角色 |
教师表 hm_teacher
字段 | 类型 | 是否允许为空 | 默认值 | 注释 |
---|---|---|---|---|
t_id(主键自增) | bigint(20) | 否 | 主键 | |
t_number | varchar(20) | 是 | NULL | 教师工号 |
t_name | varchar(20) | 是 | NULL | 教师名字 |
t_sex | varchar(1) | 是 | NULL | 教师性别 |
t_college | varchar(20) | 是 | NULL | 所属学院 |
t_photo | LONGBLOB | 是 | NULL | 教师照片 |
t_phone | varchar(20) | 是 | NULL | 教师电话 |
t_email | varchar(40) | 是 | NULL | 教师邮箱 |
t_post | varchar(20) | 是 | NULL | 教师职务 |
last_update_time | date | 是 | NULL | 最后更新时间 |
课程表 hm_course
字段 | 类型 | 是否允许为空 | 默认值 | 注释 |
---|---|---|---|---|
c_id(主键自增) | bigint(20) | 否 | 主键 | |
c_name | varchar(40) | 是 | NULL | 课程名 |
c_time | varchar(40) | 是 | NULL | 上课时间 |
c_local | varchar(40) | 是 | NULL | 上课地点 |
t_id | bigint(20) | 是 | NULL | 上课教师id |
t_name | varchar(20) | 是 | NULL | 上课教师名 |
c_term | varchar(20) | 是 | NULL | 上课学期 |
c_hour | varchar(20) | 是 | NULL | 上课总课时 |
论文表 hm_thesis
字段 | 类型 | 是否允许为空 | 默认值 | 注释 |
---|---|---|---|---|
th_id(主键自增) | bigint(20) | 否 | 主键 | |
t_id | bigint(20) | 是 | NULL | 教师id |
t_name | varchar(20) | 是 | NULL | 教师名 |
th_name | varchar(100) | 是 | NULL | 论文名 |
th_content | LONGBLOB | 是 | NULL | 论文内容 |
th_time | date | 是 | NULL | 发布时间 |
last_update_time | date | 是 | NULL | 最后更新时间 |
教材表 hm_textbook
字段 | 类型 | 是否允许为空 | 默认值 | 注释 |
---|---|---|---|---|
tx_id(主键自增) | bigint(20) | 否 | 主键 | |
t_id | bigint(20) | 是 | NULL | 教师id |
t_name | varchar(20) | 是 | NULL | 教师名 |
tx_name | varchar(20) | 是 | NULL | 教材名 |
tx_content | LONGBLOB | 是 | NULL | 教材内容 |
tx_photo | LONGBLOB | 是 | NULL | 教材封面 |
tx_time | date | 是 | NULL | 发布时间 |
last_update_time | date | 是 | NULL | 最后更新时间 |
参与学生课程成绩考核表 hm_student_exams
字段 | 类型 | 是否允许为空 | 默认值 | 注释 |
---|---|---|---|---|
se_id(主键自增) | bigint(20) | 否 | 主键 | |
t_id | bigint(20) | 是 | NULL | 教师id |
t_name | varchar(20) | 是 | NULL | 教师名 |
c_name | varchar(20) | 是 | NULL | 参与的课程名 |
se_content | varchar(255) | 是 | NULL | 参与的工作内容 |
se_time | date | 是 | NULL | 参与时间 |
last_update_time | date | 是 | NULL | 最后更新时间 |
指导学生毕业论文表 hm_guild_thesis
字段 | 类型 | 是否允许为空 | 默认值 | 注释 |
---|---|---|---|---|
gu_id(主键自增) | bigint(20) | 否 | 主键 | |
t_id | bigint(20) | 是 | NULL | 教师id |
t_name | varchar(20) | 是 | NULL | 教师名 |
gu_thesis | varchar(100) | 是 | NULL | 指导的毕业论文名 |
gu_student | varchar(20) | 是 | NULL | 指导的学生名 |
gu_time | date | 是 | NULL | 指导时间 |
last_update_time | date | 是 | NULL | 最后更新时间 |
其他活动表 hm_others
字段 | 类型 | 是否允许为空 | 默认值 | 注释 |
---|---|---|---|---|
ot_id(主键自增) | bigint(20) | 否 | 主键 | |
t_id | bigint(20) | 是 | NULL | 教师id |
t_name | varchar(20) | 是 | NULL | 教师名 |
ot_local | varchar(20) | 是 | NULL | 活动地点 |
ot_content | varchar(255) | 是 | NULL | 活动内容 |
ot_photo | LONGBLOB | 是 | NULL | 活动图片 |
ot_time | date | 是 | NULL | 活动时间 |
last_update_time | date | 是 | NULL | 最后更新时间 |
2024-3-25
创建数据库表 SQL语句
MySQL中存放文件的策略与表设计实践样例:
DROP TABLE IF EXISTS files;
CREATE TABLE files (
id INT AUTO_INCREMENT PRIMARY KEY,
file_name VARCHAR(255) NOT NULL,
file_type VARCHAR(255) NOT NULL,
file_size INT NOT NULL,
file_content LONGBLOB NOT NULL,
upload_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
创建用户表(空表)
DROP TABLE IF EXISTS hm_user;
CREATE TABLE hm_user (
id bigint(20) AUTO_INCREMENT PRIMARY KEY,
username varchar(20) NOT NULL,
password varchar(20) NOT NULL,
role varchar(1) NOT NULL
);
创建教师表(空表)
DROP TABLE IF EXISTS hm_teacher;
CREATE TABLE hm_teacher (
t_id bigint(20) AUTO_INCREMENT PRIMARY KEY,
t_number varchar(20),
t_name varchar(20),
t_sex varchar(1),
t_college varchar(20),
t_photo LONGBLOB,
t_phone varchar(20),
t_email varchar(40),
t_post varchar(20),
last_update_time date
);
创建课程表(空表)
DROP TABLE IF EXISTS hm_course;
CREATE TABLE hm_course (
c_id bigint(20) AUTO_INCREMENT PRIMARY KEY,
c_name varchar(40),
c_time varchar(40),
c_local varchar(40),
t_id bigint(20),
t_name varchar(20),
c_term varchar(20),
c_hour varchar(40)
);
创建论文表(空表)
DROP TABLE IF EXISTS hm_thesis;
CREATE TABLE hm_thesis (
th_id bigint(20) AUTO_INCREMENT PRIMARY KEY,
t_id bigint(20),
t_name varchar(20),
th_name varchar(100),
th_content LONGBLOB,
th_time date,
last_update_time date
);
创建教材表(空表)
DROP TABLE IF EXISTS hm_textbook;
CREATE TABLE hm_textbook (
tx_id bigint(20) AUTO_INCREMENT PRIMARY KEY,
t_id bigint(20),
t_name varchar(20),
tx_name varchar(20),
tx_content LONGBLOB,
tx_photo LONGBLOB,
tx_time date,
last_update_time date
);
创建参与学生课程成绩考核表(空表)
DROP TABLE IF EXISTS hm_student_exams;
CREATE TABLE hm_student_exams (
se_id bigint(20) AUTO_INCREMENT PRIMARY KEY,
t_id bigint(20),
t_name varchar(20),
c_name varchar(20),
se_content varchar(255),
se_time date,
last_update_time date
);
创建指导学生毕业论文表(空表)
DROP TABLE IF EXISTS hm_guild_thesis;
CREATE TABLE hm_guild_thesis (
se_id bigint(20) AUTO_INCREMENT PRIMARY KEY,
t_id bigint(20),
t_name varchar(20),
gu_thesis varchar(100),
gu_student varchar(20),
gu_time date,
last_update_time date
);
创建其他活动表(空表)
DROP TABLE IF EXISTS hm_others;
CREATE TABLE hm_others (
ot_id bigint(20) AUTO_INCREMENT PRIMARY KEY,
t_id bigint(20),
t_name varchar(20),
ot_local varchar(20),
ot_content varchar(255),
ot_photo LONGBLOB,
ot_time date,
last_update_time date
);
汇总
另存为hm_20240325_CT.sql
文件
hm是名的简写,中间发布日期,结尾是 Create Table 创建表的缩写
-- 创建用户表(空表)
DROP TABLE IF EXISTS hm_user;
CREATE TABLE hm_user (
id bigint(20) AUTO_INCREMENT PRIMARY KEY,
username varchar(20) NOT NULL,
password varchar(20) NOT NULL,
role varchar(1) NOT NULL
);
-- 创建教师表(空表)
DROP TABLE IF EXISTS hm_teacher;
CREATE TABLE hm_teacher (
t_id bigint(20) AUTO_INCREMENT PRIMARY KEY,
t_number varchar(20),
t_name varchar(20),
t_sex varchar(1),
t_college varchar(20),
t_photo LONGBLOB,
t_phone varchar(20),
t_email varchar(40),
t_post varchar(20),
last_update_time date
);
-- 创建课程表(空表)
DROP TABLE IF EXISTS hm_course;
CREATE TABLE hm_course (
c_id bigint(20) AUTO_INCREMENT PRIMARY KEY,
c_name varchar(40),
c_time varchar(40),
c_local varchar(40),
t_id bigint(20),
t_name varchar(20),
c_term varchar(20),
c_hour varchar(40)
);
-- 创建论文表(空表)
DROP TABLE IF EXISTS hm_thesis;
CREATE TABLE hm_thesis (
th_id bigint(20) AUTO_INCREMENT PRIMARY KEY,
t_id bigint(20),
t_name varchar(20),
th_name varchar(100),
th_content LONGBLOB,
th_time date,
last_update_time date
);
-- 创建教材表(空表)
DROP TABLE IF EXISTS hm_textbook;
CREATE TABLE hm_textbook (
tx_id bigint(20) AUTO_INCREMENT PRIMARY KEY,
t_id bigint(20),
t_name varchar(20),
tx_name varchar(20),
tx_content LONGBLOB,
tx_photo LONGBLOB,
tx_time date,
last_update_time date
);
-- 创建参与学生课程成绩考核表(空表)
DROP TABLE IF EXISTS hm_student_exams;
CREATE TABLE hm_student_exams (
se_id bigint(20) AUTO_INCREMENT PRIMARY KEY,
t_id bigint(20),
t_name varchar(20),
c_name varchar(20),
se_content varchar(255),
se_time date,
last_update_time date
);
DROP TABLE IF EXISTS hm_guild_thesis;
CREATE TABLE hm_guild_thesis (
se_id bigint(20) AUTO_INCREMENT PRIMARY KEY,
t_id bigint(20),
t_name varchar(20),
gu_thesis varchar(100),
gu_student varchar(20),
gu_time date,
last_update_time date
);
-- 创建其他活动表(空表)
DROP TABLE IF EXISTS hm_others;
CREATE TABLE hm_others (
ot_id bigint(20) AUTO_INCREMENT PRIMARY KEY,
t_id bigint(20),
t_name varchar(20),
ot_local varchar(20),
ot_content varchar(255),
ot_photo LONGBLOB,
ot_time date,
last_update_time date
);
为数据库表添加初始数据 SQL语句
SQL中用于向表格中添加数据的语句样例:
-- 创建名为students的表格
CREATE TABLE students (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50),
age INT,
gender CHAR(1)
);
-- 使用INSERT INTO语句向students表格中添加数据
INSERT INTO students (name, age, gender) VALUES ('张三', 20, '男');
INSERT INTO students (name, age, gender) VALUES ('李四', 22, '女');
INSERT INTO students (name, age, gender) VALUES ('王五', 21, '男');
添加用户数据
-- 添加用户数据
INSERT INTO hm_user (username, password, role) VALUES ('admin', 'admin', '0');
INSERT INTO hm_user (username, password, role) VALUES ('张三', 'zhangsan', '1');
INSERT INTO hm_user (username, password, role) VALUES ('李四', 'lisi', '1');
INSERT INTO hm_user (username, password, role) VALUES ('王五', 'wangwu', '1');
role = 0 为管理员,role = 1 为教师
小知识点:如果id字段设置为自增,在新增数据时不需要填写id字段的数据
添加教师数据
-- 添加教师数据
INSERT INTO hm_teacher (t_number, t_name, t_sex, t_college, t_phone, t_email, t_post, last_update_time) VALUES ('202009601148', '张三', '男', '计算机科学与技术', '15347718888', '1622668888@qq.com', '讲师', '2024-3-25');
INSERT INTO hm_teacher (t_number, t_name, t_sex, t_college, t_phone, t_email, t_post, last_update_time) VALUES ('202009601149', '李四', '男', '通信工程', '15347719999', '1622669999@qq.com', '班主任', '2024-3-25');
INSERT INTO hm_teacher (t_number, t_name, t_sex, t_college, t_phone, t_email, t_post, last_update_time) VALUES ('202009601150', '王五', '女', '自动化', '15347710000', '1622660000@qq.com', '辅导员', '2024-3-25');
添加课程数据
-- 添加课程数据
INSERT INTO hm_course (c_name, c_time, c_local, t_id, t_name, c_term, c_hour) VALUES ('大学语文(上)', '(11-13节)8周', '4东101', 1, '张三', '2024-1', '32');
INSERT INTO hm_course (c_name, c_time, c_local, t_id, t_name, c_term, c_hour) VALUES ('大学语文(下)', '(9-11节)8周', '4东102', 1, '张三', '2024-2', '32');
INSERT INTO hm_course (c_name, c_time, c_local, t_id, t_name, c_term, c_hour) VALUES ('高等数学(上)', '(9-13节)12周', '5东202', 2, '李四', '2024-1', '48');
INSERT INTO hm_course (c_name, c_time, c_local, t_id, t_name, c_term, c_hour) VALUES ('高等数学(下)', '(1-4节)12周', '5东203', 2, '李四', '2024-2', '48');
INSERT INTO hm_course (c_name, c_time, c_local, t_id, t_name, c_term, c_hour) VALUES ('大学英语', '(3-4节)6周', '6东302', 3, '王五', '2024-1', '24');
INSERT INTO hm_course (c_name, c_time, c_local, t_id, t_name, c_term, c_hour) VALUES ('大学英语', '(1-2节)6周', '6东303', 3, '王五', '2024-2', '24');
添加论文数据
-- 添加论文数据
INSERT INTO hm_thesis (t_id, t_name, th_name, th_time, last_update_time) VALUES (1, '张三', '基于springboot高校教师工作量管理系统设计', '2023-6-25', '2024-3-25');
INSERT INTO hm_thesis (t_id, t_name, th_name, th_time, last_update_time) VALUES (1, '张三', '基于springboot学生宿舍管理系统设计', '2024-3-25', '2024-3-25');
INSERT INTO hm_thesis (t_id, t_name, th_name, th_time, last_update_time) VALUES (2, '李四', '智能压力传感器系统设计', '2023-6-25', '2024-3-25');
INSERT INTO hm_thesis (t_id, t_name, th_name, th_time, last_update_time) VALUES (2, '李四', '嵌入式激光打标机运动控制卡软件系统设计', '2024-3-25', '2024-3-25');
INSERT INTO hm_thesis (t_id, t_name, th_name, th_time, last_update_time) VALUES (3, '王五', '动力部一降压变电站综合自动化系统改造及应用', '2023-6-25', '2024-3-25');
INSERT INTO hm_thesis (t_id, t_name, th_name, th_time, last_update_time) VALUES (3, '王五', '液位控制系统设计', '2024-3-25', '2024-3-25');
添加教材数据
-- 添加教材数据
INSERT INTO hm_textbook (t_id, t_name, tx_name, tx_time, last_update_time) VALUES (1, '张三', '中学语文(上)', '2023-6-25', '2024-3-25');
INSERT INTO hm_textbook (t_id, t_name, tx_name, tx_time, last_update_time) VALUES (1, '张三', '中学语文(下)', '2024-3-25', '2024-3-25');
INSERT INTO hm_textbook (t_id, t_name, tx_name, tx_time, last_update_time) VALUES (2, '李四', '中学数学(上)', '2023-6-25', '2024-3-25');
INSERT INTO hm_textbook (t_id, t_name, tx_name, tx_time, last_update_time) VALUES (2, '李四', '中学数学(下)', '2024-3-25', '2024-3-25');
INSERT INTO hm_textbook (t_id, t_name, tx_name, tx_time, last_update_time) VALUES (3, '王五', '中学英语(上)', '2023-6-25', '2024-3-25');
INSERT INTO hm_textbook (t_id, t_name, tx_name, tx_time, last_update_time) VALUES (3, '王五', '中学英语(下)', '2024-3-25', '2024-3-25');
添加参与学生课程成绩考核数据
-- 添加参与学生课程成绩考核数据
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (1, '张三', '大学语文(上)', '批改试卷', '2024-3-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (1, '张三', '大学语文(下)', '批改试卷', '2024-6-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (1, '张三', '高等数学(上)', '协助监考', '2024-3-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (1, '张三', '高等数学(下)', '协助监考', '2024-6-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (2, '李四', '高等数学(上)', '批改试卷', '2024-3-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (2, '李四', '高等数学(下)', '批改试卷', '2024-6-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (2, '李四', '大学英语(上)', '协助监考', '2024-3-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (2, '李四', '大学英语(下)', '协助监考', '2024-6-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (3, '王五', '大学英语(上)', '批改试卷', '2024-3-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (3, '王五', '大学英语(下)', '批改试卷', '2024-6-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (3, '王五', '大学语文(上)', '协助监考', '2024-3-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (3, '王五', '大学语文(下)', '协助监考', '2024-6-25', '2024-3-25');
添加指导学生毕业论文数据
-- 添加指导学生毕业论文数据
INSERT INTO hm_guild_thesis (t_id, t_name, gu_thesis, gu_student, gu_time, last_update_time) VALUES (1, '张三', '基于springboot高校食堂管理系统设计', '小明', '2024-3-25', '2024-3-25');
INSERT INTO hm_guild_thesis (t_id, t_name, gu_thesis, gu_student, gu_time, last_update_time) VALUES (1, '张三', '基于springboot购物商城系统设计', '小红', '2024-3-25', '2024-3-25');
INSERT INTO hm_guild_thesis (t_id, t_name, gu_thesis, gu_student, gu_time, last_update_time) VALUES (2, '李四', '卷积编码和维特比译码的FPGA实现', '小张', '2024-3-25', '2024-3-25');
INSERT INTO hm_guild_thesis (t_id, t_name, gu_thesis, gu_student, gu_time, last_update_time) VALUES (2, '李四', 'CVSD音频编译码算法研究与FPGA实现', '小王', '2024-3-25', '2024-3-25');
INSERT INTO hm_guild_thesis (t_id, t_name, gu_thesis, gu_student, gu_time, last_update_time) VALUES (3, '王五', '砌块砖成型机PLC自动控制系统', '小美', '2024-3-25', '2024-3-25');
INSERT INTO hm_guild_thesis (t_id, t_name, gu_thesis, gu_student, gu_time, last_update_time) VALUES (3, '王五', '电气自动化及电气自动化的发展前景', '小丽', '2024-3-25', '2024-3-25');
添加其他活动数据
-- 添加其他活动数据
INSERT INTO hm_others (t_id, t_name, ot_local, ot_content, ot_time, last_update_time) VALUES (1, '张三', '广西计算机考点', '考取计算机资格证书', '2023-6-25', '2024-3-25');
INSERT INTO hm_others (t_id, t_name, ot_local, ot_content, ot_time, last_update_time) VALUES (1, '张三', '广西科技大学', '开展springboot相关技术讲座', '2024-3-25', '2024-3-25');
INSERT INTO hm_others (t_id, t_name, ot_local, ot_content, ot_time, last_update_time) VALUES (2, '李四', '广西通信工程考点', '考取通信工程资格证书', '2023-6-25', '2024-3-25');
INSERT INTO hm_others (t_id, t_name, ot_local, ot_content, ot_time, last_update_time) VALUES (2, '李四', '广西科技大学', '开展通信工程相关技术讲座', '2024-3-25', '2024-3-25');
INSERT INTO hm_others (t_id, t_name, ot_local, ot_content, ot_time, last_update_time) VALUES (3, '王五', '广西自动化考点', '考取自动化资格证书', '2023-6-25', '2024-3-25');
INSERT INTO hm_others (t_id, t_name, ot_local, ot_content, ot_time, last_update_time) VALUES (3, '王五', '广西科技大学', '开展自动化相关技术讲座', '2024-3-25', '2024-3-25');
汇总
另存为hm_20240327_ID.sql
文件
hm是名的简写,中间发布日期,结尾是 Insert Data 插入数据的缩写
-- 添加用户数据
INSERT INTO hm_user (username, password, role) VALUES ('admin', 'admin', '0');
INSERT INTO hm_user (username, password, role) VALUES ('张三', 'zhangsan', '1');
INSERT INTO hm_user (username, password, role) VALUES ('李四', 'lisi', '1');
INSERT INTO hm_user (username, password, role) VALUES ('王五', 'wangwu', '1');
-- 添加教师数据
INSERT INTO hm_teacher (t_number, t_name, t_sex, t_college, t_phone, t_email, t_post, last_update_time) VALUES ('202009601148', '张三', '男', '计算机科学与技术', '15347718888', '1622668888@qq.com', '讲师', '2024-3-25');
INSERT INTO hm_teacher (t_number, t_name, t_sex, t_college, t_phone, t_email, t_post, last_update_time) VALUES ('202009601149', '李四', '男', '通信工程', '15347719999', '1622669999@qq.com', '班主任', '2024-3-25');
INSERT INTO hm_teacher (t_number, t_name, t_sex, t_college, t_phone, t_email, t_post, last_update_time) VALUES ('202009601150', '王五', '女', '自动化', '15347710000', '1622660000@qq.com', '辅导员', '2024-3-25');
-- 添加课程数据
INSERT INTO hm_course (c_name, c_time, c_local, t_id, t_name, c_term, c_hour) VALUES ('大学语文(上)', '(11-13节)8周', '4东101', 1, '张三', '2024-1', '32');
INSERT INTO hm_course (c_name, c_time, c_local, t_id, t_name, c_term, c_hour) VALUES ('大学语文(下)', '(9-11节)8周', '4东102', 1, '张三', '2024-2', '32');
INSERT INTO hm_course (c_name, c_time, c_local, t_id, t_name, c_term, c_hour) VALUES ('高等数学(上)', '(9-13节)12周', '5东202', 2, '李四', '2024-1', '48');
INSERT INTO hm_course (c_name, c_time, c_local, t_id, t_name, c_term, c_hour) VALUES ('高等数学(下)', '(1-4节)12周', '5东203', 2, '李四', '2024-2', '48');
INSERT INTO hm_course (c_name, c_time, c_local, t_id, t_name, c_term, c_hour) VALUES ('大学英语', '(3-4节)6周', '6东302', 3, '王五', '2024-1', '24');
INSERT INTO hm_course (c_name, c_time, c_local, t_id, t_name, c_term, c_hour) VALUES ('大学英语', '(1-2节)6周', '6东303', 3, '王五', '2024-2', '24');
-- 添加论文数据
INSERT INTO hm_thesis (t_id, t_name, th_name, th_time, last_update_time) VALUES (1, '张三', '基于springboot高校教师工作量管理系统设计', '2023-6-25', '2024-3-25');
INSERT INTO hm_thesis (t_id, t_name, th_name, th_time, last_update_time) VALUES (1, '张三', '基于springboot学生宿舍管理系统设计', '2024-3-25', '2024-3-25');
INSERT INTO hm_thesis (t_id, t_name, th_name, th_time, last_update_time) VALUES (2, '李四', '智能压力传感器系统设计', '2023-6-25', '2024-3-25');
INSERT INTO hm_thesis (t_id, t_name, th_name, th_time, last_update_time) VALUES (2, '李四', '嵌入式激光打标机运动控制卡软件系统设计', '2024-3-25', '2024-3-25');
INSERT INTO hm_thesis (t_id, t_name, th_name, th_time, last_update_time) VALUES (3, '王五', '动力部一降压变电站综合自动化系统改造及应用', '2023-6-25', '2024-3-25');
INSERT INTO hm_thesis (t_id, t_name, th_name, th_time, last_update_time) VALUES (3, '王五', '液位控制系统设计', '2024-3-25', '2024-3-25');
-- 添加教材数据
INSERT INTO hm_textbook (t_id, t_name, tx_name, tx_time, last_update_time) VALUES (1, '张三', '中学语文(上)', '2023-6-25', '2024-3-25');
INSERT INTO hm_textbook (t_id, t_name, tx_name, tx_time, last_update_time) VALUES (1, '张三', '中学语文(下)', '2024-3-25', '2024-3-25');
INSERT INTO hm_textbook (t_id, t_name, tx_name, tx_time, last_update_time) VALUES (2, '李四', '中学数学(上)', '2023-6-25', '2024-3-25');
INSERT INTO hm_textbook (t_id, t_name, tx_name, tx_time, last_update_time) VALUES (2, '李四', '中学数学(下)', '2024-3-25', '2024-3-25');
INSERT INTO hm_textbook (t_id, t_name, tx_name, tx_time, last_update_time) VALUES (3, '王五', '中学英语(上)', '2023-6-25', '2024-3-25');
INSERT INTO hm_textbook (t_id, t_name, tx_name, tx_time, last_update_time) VALUES (3, '王五', '中学英语(下)', '2024-3-25', '2024-3-25');
-- 添加参与学生课程成绩考核数据
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (1, '张三', '大学语文(上)', '批改试卷', '2024-3-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (1, '张三', '大学语文(下)', '批改试卷', '2024-6-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (1, '张三', '高等数学(上)', '协助监考', '2024-3-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (1, '张三', '高等数学(下)', '协助监考', '2024-6-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (2, '李四', '高等数学(上)', '批改试卷', '2024-3-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (2, '李四', '高等数学(下)', '批改试卷', '2024-6-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (2, '李四', '大学英语(上)', '协助监考', '2024-3-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (2, '李四', '大学英语(下)', '协助监考', '2024-6-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (3, '王五', '大学英语(上)', '批改试卷', '2024-3-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (3, '王五', '大学英语(下)', '批改试卷', '2024-6-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (3, '王五', '大学语文(上)', '协助监考', '2024-3-25', '2024-3-25');
INSERT INTO hm_student_exams (t_id, t_name, c_name, se_content, se_time, last_update_time) VALUES (3, '王五', '大学语文(下)', '协助监考', '2024-6-25', '2024-3-25');
-- 添加指导学生毕业论文数据
INSERT INTO hm_guild_thesis (t_id, t_name, gu_thesis, gu_student, gu_time, last_update_time) VALUES (1, '张三', '基于springboot高校食堂管理系统设计', '小明', '2024-3-25', '2024-3-25');
INSERT INTO hm_guild_thesis (t_id, t_name, gu_thesis, gu_student, gu_time, last_update_time) VALUES (1, '张三', '基于springboot购物商城系统设计', '小红', '2024-3-25', '2024-3-25');
INSERT INTO hm_guild_thesis (t_id, t_name, gu_thesis, gu_student, gu_time, last_update_time) VALUES (2, '李四', '卷积编码和维特比译码的FPGA实现', '小张', '2024-3-25', '2024-3-25');
INSERT INTO hm_guild_thesis (t_id, t_name, gu_thesis, gu_student, gu_time, last_update_time) VALUES (2, '李四', 'CVSD音频编译码算法研究与FPGA实现', '小王', '2024-3-25', '2024-3-25');
INSERT INTO hm_guild_thesis (t_id, t_name, gu_thesis, gu_student, gu_time, last_update_time) VALUES (3, '王五', '砌块砖成型机PLC自动控制系统', '小美', '2024-3-25', '2024-3-25');
INSERT INTO hm_guild_thesis (t_id, t_name, gu_thesis, gu_student, gu_time, last_update_time) VALUES (3, '王五', '电气自动化及电气自动化的发展前景', '小丽', '2024-3-25', '2024-3-25');
-- 添加其他活动数据
INSERT INTO hm_others (t_id, t_name, ot_local, ot_content, ot_time, last_update_time) VALUES (1, '张三', '广西计算机考点', '考取计算机资格证书', '2023-6-25', '2024-3-25');
INSERT INTO hm_others (t_id, t_name, ot_local, ot_content, ot_time, last_update_time) VALUES (1, '张三', '广西科技大学', '开展springboot相关技术讲座', '2024-3-25', '2024-3-25');
INSERT INTO hm_others (t_id, t_name, ot_local, ot_content, ot_time, last_update_time) VALUES (2, '李四', '广西通信工程考点', '考取通信工程资格证书', '2023-6-25', '2024-3-25');
INSERT INTO hm_others (t_id, t_name, ot_local, ot_content, ot_time, last_update_time) VALUES (2, '李四', '广西科技大学', '开展通信工程相关技术讲座', '2024-3-25', '2024-3-25');
INSERT INTO hm_others (t_id, t_name, ot_local, ot_content, ot_time, last_update_time) VALUES (3, '王五', '广西自动化考点', '考取自动化资格证书', '2023-6-25', '2024-3-25');
INSERT INTO hm_others (t_id, t_name, ot_local, ot_content, ot_time, last_update_time) VALUES (3, '王五', '广西科技大学', '开展自动化相关技术讲座', '2024-3-25', '2024-3-25');
2024-3-26
功能模块需求分析
管理员:
- 管理全部用户账号权限、身份
- 编辑教师工号、姓名、学院、职务信息
- 添加课程信息
- 对教师上传的内容进行查看或修改
教师:
- 编辑个人信息
- 查看课表
- 上传论文信息
- 上传教材信息
- 上传参与学生课程成绩考核信息
- 上传指导学生毕业论文信息
- 上传其他活动信息
用户管理功能模块的实现
2024-3-27
教师管理功能模块的实现
前端实现
一、使用element-ui前端组件库,快速搭建出前端页面
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="工号" prop="tNumber">
<el-input
v-model="queryParams.tNumber"
placeholder="请输入工号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="姓名" prop="tName">
<el-input
v-model="queryParams.tName"
placeholder="请输入姓名"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="性别" prop="tSex">
<el-select v-model="queryParams.tSex" placeholder="请选择性别" clearable>
<el-option
v-for="dict in dict.type.sys_user_sex"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="学院" prop="tCollege">
<el-input
v-model="queryParams.tCollege"
placeholder="请输入学院"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="电话" prop="tPhone">
<el-input
v-model="queryParams.tPhone"
placeholder="请输入电话"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="邮箱" prop="tEmail">
<el-input
v-model="queryParams.tEmail"
placeholder="请输入邮箱"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="职务" prop="tPost">
<el-input
v-model="queryParams.tPost"
placeholder="请输入职务"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="最后更新日期" prop="lastUpdateTime">
<el-date-picker clearable
v-model="queryParams.lastUpdateTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择最后更新日期">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['teacher:teacher:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['teacher:teacher:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['teacher:teacher:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['teacher:teacher:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="teacherList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="id" align="center" prop="tId" />
<el-table-column label="工号" align="center" prop="tNumber" />
<el-table-column label="姓名" align="center" prop="tName" />
<el-table-column label="性别" align="center" prop="tSex">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_user_sex" :value="scope.row.tSex"/>
</template>
</el-table-column>
<el-table-column label="学院" align="center" prop="tCollege" />
<el-table-column label="照片" align="center" prop="tPhoto" width="100">
<template slot-scope="scope">
<image-preview :src="scope.row.tPhoto" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column label="电话" align="center" prop="tPhone" />
<el-table-column label="邮箱" align="center" prop="tEmail" />
<el-table-column label="职务" align="center" prop="tPost" />
<el-table-column label="最后更新日期" align="center" prop="lastUpdateTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.lastUpdateTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['teacher:teacher:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['teacher:teacher:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改教师对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="工号" prop="tNumber">
<el-input v-model="form.tNumber" placeholder="请输入工号" />
</el-form-item>
<el-form-item label="姓名" prop="tName">
<el-input v-model="form.tName" placeholder="请输入姓名" />
</el-form-item>
<el-form-item label="性别" prop="tSex">
<el-radio-group v-model="form.tSex">
<el-radio
v-for="dict in dict.type.sys_user_sex"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="学院" prop="tCollege">
<el-input v-model="form.tCollege" placeholder="请输入学院" />
</el-form-item>
<el-form-item label="照片" prop="tPhoto">
<image-upload v-model="form.tPhoto"/>
</el-form-item>
<el-form-item label="电话" prop="tPhone">
<el-input v-model="form.tPhone" placeholder="请输入电话" />
</el-form-item>
<el-form-item label="邮箱" prop="tEmail">
<el-input v-model="form.tEmail" placeholder="请输入邮箱" />
</el-form-item>
<el-form-item label="职务" prop="tPost">
<el-input v-model="form.tPost" placeholder="请输入职务" />
</el-form-item>
<el-form-item label="最后更新日期" prop="lastUpdateTime">
<el-date-picker clearable
v-model="form.lastUpdateTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择最后更新日期">
</el-date-picker>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listTeacher, getTeacher, delTeacher, addTeacher, updateTeacher } from "@/api/teacher/teacher";
export default {
name: "Teacher",
dicts: ['sys_user_sex'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 教师表格数据
teacherList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
tNumber: null,
tName: null,
tSex: null,
tCollege: null,
tPhoto: null,
tPhone: null,
tEmail: null,
tPost: null,
lastUpdateTime: null
},
// 表单参数
form: {},
// 表单校验
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询教师列表 */
getList() {
this.loading = true;
listTeacher(this.queryParams).then(response => {
this.teacherList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
tId: null,
tNumber: null,
tName: null,
tSex: null,
tCollege: null,
tPhoto: null,
tPhone: null,
tEmail: null,
tPost: null,
lastUpdateTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.tId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加教师";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const tId = row.tId || this.ids
getTeacher(tId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改教师";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.tId != null) {
updateTeacher(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addTeacher(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const tIds = row.tId || this.ids;
this.$modal.confirm('是否确认删除教师编号为"' + tIds + '"的数据项?').then(function() {
return delTeacher(tIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('teacher/teacher/export', {
...this.queryParams
}, `teacher_${new Date().getTime()}.xlsx`)
}
}
};
</script>
二、根据功能需要编写api接口文档
import request from '@/utils/request'
// 查询教师列表
export function listTeacher(query) {
return request({
url: '/teacher/teacher/list',
method: 'get',
params: query
})
}
// 查询教师详细
export function getTeacher(tId) {
return request({
url: '/teacher/teacher/' + tId,
method: 'get'
})
}
// 新增教师
export function addTeacher(data) {
return request({
url: '/teacher/teacher',
method: 'post',
data: data
})
}
// 修改教师
export function updateTeacher(data) {
return request({
url: '/teacher/teacher',
method: 'put',
data: data
})
}
// 删除教师
export function delTeacher(tId) {
return request({
url: '/teacher/teacher/' + tId,
method: 'delete'
})
}
管理员需要对教师信息进行增添,删除,修改和查询。
查询使用get请求,因为不需要发送数据给后端,只需要从后端获取数据;
新增使用post请求,因为要发送数据给后端,让后端发送给数据库进行新增,post请求可以携带的数据量更大,而且安全性更高;
修改使用put请求,这是专门的修改数据库专用的请求,表明该请求用于修改数据库中的值;
删除使用delete请求,和put请求同理。
后端实现
一、根据数据库表编写对应的实体类
package com.ruoyi.teacher.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 教师对象 hm_teacher
*
* @author xuhangming
* @date 2024-03-28
*/
public class Teacher extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long tId;
/** 工号 */
@Excel(name = "工号")
private String tNumber;
/** 姓名 */
@Excel(name = "姓名")
private String tName;
/** 性别 */
@Excel(name = "性别")
private String tSex;
/** 学院 */
@Excel(name = "学院")
private String tCollege;
/** 照片 */
@Excel(name = "照片")
private String tPhoto;
/** 电话 */
@Excel(name = "电话")
private String tPhone;
/** 邮箱 */
@Excel(name = "邮箱")
private String tEmail;
/** 职务 */
@Excel(name = "职务")
private String tPost;
/** 最后更新日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "最后更新日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date lastUpdateTime;
public void settId(Long tId)
{
this.tId = tId;
}
public Long gettId()
{
return tId;
}
public void settNumber(String tNumber)
{
this.tNumber = tNumber;
}
public String gettNumber()
{
return tNumber;
}
public void settName(String tName)
{
this.tName = tName;
}
public String gettName()
{
return tName;
}
public void settSex(String tSex)
{
this.tSex = tSex;
}
public String gettSex()
{
return tSex;
}
public void settCollege(String tCollege)
{
this.tCollege = tCollege;
}
public String gettCollege()
{
return tCollege;
}
public void settPhoto(String tPhoto)
{
this.tPhoto = tPhoto;
}
public String gettPhoto()
{
return tPhoto;
}
public void settPhone(String tPhone)
{
this.tPhone = tPhone;
}
public String gettPhone()
{
return tPhone;
}
public void settEmail(String tEmail)
{
this.tEmail = tEmail;
}
public String gettEmail()
{
return tEmail;
}
public void settPost(String tPost)
{
this.tPost = tPost;
}
public String gettPost()
{
return tPost;
}
public void setLastUpdateTime(Date lastUpdateTime)
{
this.lastUpdateTime = lastUpdateTime;
}
public Date getLastUpdateTime()
{
return lastUpdateTime;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("tId", gettId())
.append("tNumber", gettNumber())
.append("tName", gettName())
.append("tSex", gettSex())
.append("tCollege", gettCollege())
.append("tPhoto", gettPhoto())
.append("tPhone", gettPhone())
.append("tEmail", gettEmail())
.append("tPost", gettPost())
.append("lastUpdateTime", getLastUpdateTime())
.toString();
}
}
这里根据数据库中的teacher表,编写对应的对象实体类。
private static final long serialVersionUID = 1L;
上述代码的意思是定义一个私有的、long类型的序列化ID常量并取值为1L,序列化ID的作用是提供一个唯一标识符,用于确保序列化和反序列化操作的正确性和兼容性。
/** 工号 */
@Excel(name = "工号")
private String tNumber;
被@Excel
注解标记的字段,可以使用excel文件中同名的字段内容进行自动导入。
/** 照片 */
@Excel(name = "照片")
private String tPhoto;
在表的设计中,t_photo 字段使用 LONGBLOB 类型来存储照片格式的数据
BLOB原名为Binary Large OBject,翻译过来是二进制大对象,这里LONGBLOB 代表是长二进制大对象,它会将图片转换成二进制编码进行储存,在数据库中我们可以直接看到这些二进制编码的位数(长度)。
/** 最后更新日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "最后更新日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date lastUpdateTime;
被@JsonFormat
注解标记的字段通常是日期/时间数据,该注解会将输入的日期自动转换为括号内的日期格式。这里"yyyy-MM-dd"中,y代表year 年份,重复了4次表示长度为4;M代表month 月份,重复两次代表长度为2;d代表day 日期,重复两次代表长度为2。输入的日期会自动转换为年在前,月在中间,日在最后的符合我们中国人习惯的日期格式。例如 2024-03-31。
public void settId(Long tId)
{
this.tId = tId;
}
public Long gettId()
{
return tId;
}
该 teacher 类即为 hm_teacher 表中数据的对象,是数据库对象在java中的体现。
逐字段编写完后是对应的get和set方法。get意为获取,get方法可以获取到某个字段的值;set意为设置,set方法可以设置某个字段的值。
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("tId", gettId())
.append("tNumber", gettNumber())
.append("tName", gettName())
.append("tSex", gettSex())
.append("tCollege", gettCollege())
.append("tPhoto", gettPhoto())
.append("tPhone", gettPhone())
.append("tEmail", gettEmail())
.append("tPost", gettPost())
.append("lastUpdateTime", getLastUpdateTime())
.toString();
}
get和set方法编写完后是该类的toString方法,toString意为以String(字符串)的格式输出,该方法用于输出对象的信息,默认是输出全部的信息。
二、根据功能需要编写对应的mapper接口
package com.ruoyi.teacher.mapper;
import java.util.List;
import com.ruoyi.teacher.domain.Teacher;
/**
* 教师Mapper接口
*
* @author xuhangming
* @date 2024-03-28
*/
public interface TeacherMapper
{
/**
* 查询教师
*
* @param tId 教师主键
* @return 教师
*/
public Teacher selectTeacherByTId(Long tId);
/**
* 查询教师列表
*
* @param teacher 教师
* @return 教师集合
*/
public List<Teacher> selectTeacherList(Teacher teacher);
/**
* 新增教师
*
* @param teacher 教师
* @return 结果
*/
public int insertTeacher(Teacher teacher);
/**
* 修改教师
*
* @param teacher 教师
* @return 结果
*/
public int updateTeacher(Teacher teacher);
/**
* 删除教师
*
* @param tId 教师主键
* @return 结果
*/
public int deleteTeacherByTId(Long tId);
/**
* 批量删除教师
*
* @param tIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteTeacherByTIds(Long[] tIds);
}
对于一张数据库表的操作,需要有最基础的增、删、改、查操作。所以在mapper接口中我定义了以下方法:查询单条记录;查询全部记录;新增单条记录;修改单条记录;删除单条记录;删除多条记录。可以看到只有批量查询和删除,并没有批量新增和修改,因为批量新增可以用excel表格导入做到,批量修改需要根据具体情况具体制作,对单个的修改已经能满足日常工作需求。
三、根据数据库表和mapper接口编写对应的mapper.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.teacher.mapper.TeacherMapper">
<resultMap type="Teacher" id="TeacherResult">
<result property="tId" column="t_id" />
<result property="tNumber" column="t_number" />
<result property="tName" column="t_name" />
<result property="tSex" column="t_sex" />
<result property="tCollege" column="t_college" />
<result property="tPhoto" column="t_photo" />
<result property="tPhone" column="t_phone" />
<result property="tEmail" column="t_email" />
<result property="tPost" column="t_post" />
<result property="lastUpdateTime" column="last_update_time" />
</resultMap>
<sql id="selectTeacherVo">
select t_id, t_number, t_name, t_sex, t_college, t_photo, t_phone, t_email, t_post, last_update_time from hm_teacher
</sql>
<select id="selectTeacherList" parameterType="Teacher" resultMap="TeacherResult">
<include refid="selectTeacherVo"/>
<where>
<if test="tNumber != null and tNumber != ''"> and t_number like concat('%', #{tNumber}, '%')</if>
<if test="tName != null and tName != ''"> and t_name like concat('%', #{tName}, '%')</if>
<if test="tSex != null and tSex != ''"> and t_sex = #{tSex}</if>
<if test="tCollege != null and tCollege != ''"> and t_college like concat('%', #{tCollege}, '%')</if>
<if test="tPhoto != null and tPhoto != ''"> and t_photo = #{tPhoto}</if>
<if test="tPhone != null and tPhone != ''"> and t_phone like concat('%', #{tPhone}, '%')</if>
<if test="tEmail != null and tEmail != ''"> and t_email like concat('%', #{tEmail}, '%')</if>
<if test="tPost != null and tPost != ''"> and t_post like concat('%', #{tPost}, '%')</if>
<if test="lastUpdateTime != null "> and last_update_time = #{lastUpdateTime}</if>
</where>
</select>
<select id="selectTeacherByTId" parameterType="Long" resultMap="TeacherResult">
<include refid="selectTeacherVo"/>
where t_id = #{tId}
</select>
<insert id="insertTeacher" parameterType="Teacher" useGeneratedKeys="true" keyProperty="tId">
insert into hm_teacher
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tNumber != null">t_number,</if>
<if test="tName != null">t_name,</if>
<if test="tSex != null">t_sex,</if>
<if test="tCollege != null">t_college,</if>
<if test="tPhoto != null">t_photo,</if>
<if test="tPhone != null">t_phone,</if>
<if test="tEmail != null">t_email,</if>
<if test="tPost != null">t_post,</if>
<if test="lastUpdateTime != null">last_update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tNumber != null">#{tNumber},</if>
<if test="tName != null">#{tName},</if>
<if test="tSex != null">#{tSex},</if>
<if test="tCollege != null">#{tCollege},</if>
<if test="tPhoto != null">#{tPhoto},</if>
<if test="tPhone != null">#{tPhone},</if>
<if test="tEmail != null">#{tEmail},</if>
<if test="tPost != null">#{tPost},</if>
<if test="lastUpdateTime != null">#{lastUpdateTime},</if>
</trim>
</insert>
<update id="updateTeacher" parameterType="Teacher">
update hm_teacher
<trim prefix="SET" suffixOverrides=",">
<if test="tNumber != null">t_number = #{tNumber},</if>
<if test="tName != null">t_name = #{tName},</if>
<if test="tSex != null">t_sex = #{tSex},</if>
<if test="tCollege != null">t_college = #{tCollege},</if>
<if test="tPhoto != null">t_photo = #{tPhoto},</if>
<if test="tPhone != null">t_phone = #{tPhone},</if>
<if test="tEmail != null">t_email = #{tEmail},</if>
<if test="tPost != null">t_post = #{tPost},</if>
<if test="lastUpdateTime != null">last_update_time = #{lastUpdateTime},</if>
</trim>
where t_id = #{tId}
</update>
<delete id="deleteTeacherByTId" parameterType="Long">
delete from hm_teacher where t_id = #{tId}
</delete>
<delete id="deleteTeacherByTIds" parameterType="String">
delete from hm_teacher where t_id in
<foreach item="tId" collection="array" open="(" separator="," close=")">
#{tId}
</foreach>
</delete>
</mapper>
mapper.xml文件存储的是实际操作数据库的SQL语句,该文件和mapper接口相互呼应,即mapper.xml文件是mapper接口的具体实现。
<resultMap type="Teacher" id="TeacherResult">
<result property="tId" column="t_id"/>
<result property="tNumber" column="t_number"/>
<result property="tName" column="t_name"/>
<result property="tSex" column="t_sex"/>
<result property="tCollege" column="t_college"/>
<result property="tPhoto" column="t_photo"/>
<result property="tPhone" column="t_phone"/>
<result property="tEmail" column="t_email"/>
<result property="tPost" column="t_post"/>
<result property="lastUpdateTime" column="last_update_time"/>
</resultMap>
在数据库中,我们是允许字段名中带下划线的,但是我们创建的java对象命名是以驼峰命名法为规范来命名的,所以第一步是给表中的字段取别名,让数据库字段别名和java中的属性名相同,达到字段和属性一一对应的效果。
这里的代码定义了一个resultMap,result是返回,map是K/V键值对,代表返回键值对;返回类型是Teacher对象,即方法一中的实体类;id为TeacherResult,只要后续方法中的resultMap中的值为TeacherResult,即以该对象类型返回。
-- 增添
INSERT
-- 删除
DELETE
-- 修改
UPDATE
-- 查询
SELECT
增删改查分别对应INSERT、DELETE、UPDATE和SELECT,使用对应的关键字来编写SQL语句,从而实现对数据库的增删改查操作
<select id="selectTeacherList" parameterType="Teacher" resultMap="TeacherResult">
<include refid="selectTeacherVo"/>
<where>
<if test="tNumber != null and tNumber != ''">and t_number like concat('%', #{tNumber}, '%')</if>
<if test="tName != null and tName != ''">and t_name like concat('%', #{tName}, '%')</if>
<if test="tSex != null and tSex != ''">and t_sex = #{tSex}</if>
<if test="tCollege != null and tCollege != ''">and t_college like concat('%', #{tCollege}, '%')</if>
<if test="tPhoto != null and tPhoto != ''">and t_photo = #{tPhoto}</if>
<if test="tPhone != null and tPhone != ''">and t_phone like concat('%', #{tPhone}, '%')</if>
<if test="tEmail != null and tEmail != ''">and t_email like concat('%', #{tEmail}, '%')</if>
<if test="tPost != null and tPost != ''">and t_post like concat('%', #{tPost}, '%')</if>
<if test="lastUpdateTime != null ">and last_update_time = #{lastUpdateTime}</if>
</where>
</select>
以select开头,代表该SQL语句是查询功能;
id=“selectTeacherList”,代表该SQL语句对应mapper接口中的selectTeacherList方法,调用mapper接口中的selectTeacherList方法实际上执行该语句;
parameterType=“Teacher”,代表该SQL语句会接受一个参数,参数类型是Teacher对象;
resultMap=“TeacherResult”,代表使用名为TeacherResult的resultMap作为返回值(上文提到过);
,表示把名为selectTeacherVo的SQL语句中的代码,原封不动的加入到当前位置(重复代码不用重复写,减轻程序员的工作量)
是mysql的动态标签,可以根据不同的查询条件方便的编写SQL语句,它会自动帮你处理数据库语法逻辑
and like都是条件满足类型的SQL关键字,if用于判断,and用于连接不同的判断内容,like在此处用于模糊查询,只要在内容中出现关键字即返回查询结果,不需要查询输入的内容和搜索出的内容完全相同。例如:教师姓名为”许航銘“,我只需要输入“许”,就可以查询出全部名字中带有“许”的老师。
四、编写对应的service接口和service实现类
service接口
package com.ruoyi.teacher.service;
import java.util.List;
import com.ruoyi.teacher.domain.Teacher;
/**
* 教师Service接口
*
* @author xuhangming
* @date 2024-03-28
*/
public interface ITeacherService
{
/**
* 查询教师
*
* @param tId 教师主键
* @return 教师
*/
public Teacher selectTeacherByTId(Long tId);
/**
* 查询教师列表
*
* @param teacher 教师
* @return 教师集合
*/
public List<Teacher> selectTeacherList(Teacher teacher);
/**
* 新增教师
*
* @param teacher 教师
* @return 结果
*/
public int insertTeacher(Teacher teacher);
/**
* 修改教师
*
* @param teacher 教师
* @return 结果
*/
public int updateTeacher(Teacher teacher);
/**
* 批量删除教师
*
* @param tIds 需要删除的教师主键集合
* @return 结果
*/
public int deleteTeacherByTIds(Long[] tIds);
/**
* 删除教师信息
*
* @param tId 教师主键
* @return 结果
*/
public int deleteTeacherByTId(Long tId);
}
service实现类
package com.ruoyi.teacher.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.teacher.mapper.TeacherMapper;
import com.ruoyi.teacher.domain.Teacher;
import com.ruoyi.teacher.service.ITeacherService;
/**
* 教师Service业务层处理
*
* @author xuhangming
* @date 2024-03-28
*/
@Service
public class TeacherServiceImpl implements ITeacherService
{
@Autowired
private TeacherMapper teacherMapper;
/**
* 查询教师
*
* @param tId 教师主键
* @return 教师
*/
@Override
public Teacher selectTeacherByTId(Long tId)
{
return teacherMapper.selectTeacherByTId(tId);
}
/**
* 查询教师列表
*
* @param teacher 教师
* @return 教师
*/
@Override
public List<Teacher> selectTeacherList(Teacher teacher)
{
return teacherMapper.selectTeacherList(teacher);
}
/**
* 新增教师
*
* @param teacher 教师
* @return 结果
*/
@Override
public int insertTeacher(Teacher teacher)
{
return teacherMapper.insertTeacher(teacher);
}
/**
* 修改教师
*
* @param teacher 教师
* @return 结果
*/
@Override
public int updateTeacher(Teacher teacher)
{
return teacherMapper.updateTeacher(teacher);
}
/**
* 批量删除教师
*
* @param tIds 需要删除的教师主键
* @return 结果
*/
@Override
public int deleteTeacherByTIds(Long[] tIds)
{
return teacherMapper.deleteTeacherByTIds(tIds);
}
/**
* 删除教师信息
*
* @param tId 教师主键
* @return 结果
*/
@Override
public int deleteTeacherByTId(Long tId)
{
return teacherMapper.deleteTeacherByTId(tId);
}
}
service层用于被controller层调用,被调用后会处理相关的业务逻辑代码,并调用mapper层实现对数据库的操作。代码量和业务的具体需求相关,基础的增删改查功能全部都能在数据库完成,因此这里的service层只提供方法接口,而不需要对数据进行进一步的加工。
五、编写对应的controller控制类
package com.ruoyi.teacher.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teacher.domain.Teacher;
import com.ruoyi.teacher.service.ITeacherService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 教师Controller
*
* @author xuhangming
* @date 2024-03-28
*/
@RestController
@RequestMapping("/teacher/teacher")
public class TeacherController extends BaseController
{
@Autowired
private ITeacherService teacherService;
/**
* 查询教师列表
*/
@PreAuthorize("@ss.hasPermi('teacher:teacher:list')")
@GetMapping("/list")
public TableDataInfo list(Teacher teacher)
{
startPage();
List<Teacher> list = teacherService.selectTeacherList(teacher);
return getDataTable(list);
}
/**
* 导出教师列表
*/
@PreAuthorize("@ss.hasPermi('teacher:teacher:export')")
@Log(title = "教师", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Teacher teacher)
{
List<Teacher> list = teacherService.selectTeacherList(teacher);
ExcelUtil<Teacher> util = new ExcelUtil<Teacher>(Teacher.class);
util.exportExcel(response, list, "教师数据");
}
/**
* 获取教师详细信息
*/
@PreAuthorize("@ss.hasPermi('teacher:teacher:query')")
@GetMapping(value = "/{tId}")
public AjaxResult getInfo(@PathVariable("tId") Long tId)
{
return success(teacherService.selectTeacherByTId(tId));
}
/**
* 新增教师
*/
@PreAuthorize("@ss.hasPermi('teacher:teacher:add')")
@Log(title = "教师", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Teacher teacher)
{
return toAjax(teacherService.insertTeacher(teacher));
}
/**
* 修改教师
*/
@PreAuthorize("@ss.hasPermi('teacher:teacher:edit')")
@Log(title = "教师", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Teacher teacher)
{
return toAjax(teacherService.updateTeacher(teacher));
}
/**
* 删除教师
*/
@PreAuthorize("@ss.hasPermi('teacher:teacher:remove')")
@Log(title = "教师", businessType = BusinessType.DELETE)
@DeleteMapping("/{tIds}")
public AjaxResult remove(@PathVariable Long[] tIds)
{
return toAjax(teacherService.deleteTeacherByTIds(tIds));
}
}
controller层用于接收来自前端发出的请求(通常是Ajax请求),然后根据请求的不同,执行对应的方法.
@RestController注解,该注解是@Controller和@ResponseBody注解的结合体,前者表明了该类是一个控制类,后者标识方法/类返回的内容应该作为HTTP响应的正文部分返回给客户端;
@RequestMapping(“/teacher/teacher”)注解,该注解标明的前端的映射地址/路径,路径为"/teacher/teacher";
public class TeacherController extends BaseController,extends 表示继承。其他全部的controller都会继承BaseController,因为部分方法和功能的代码相同,所以把相同部分的代码全部丢入了BaseController中;
@Autowired注解,该注解标明的接口,会直接向bean中注入该接口的实现类,这里的注解加到了ITeacherService接口上,因此我们可以调用该接口的具体实现方法;
/**
* 查询教师列表
*/
@PreAuthorize("@ss.hasPermi('teacher:teacher:list')")
@GetMapping("/list")
public TableDataInfo list(Teacher teacher)
{
startPage();
List<Teacher> list = teacherService.selectTeacherList(teacher);
return getDataTable(list);
}
@PreAuthorize注解,该注解会在方法执行前进行权限验证,如果权限验证通过,那么才可以执行该方法,该注解是权限管理的重要组成部分;@ss.hasPermi(‘teacher:teacher:list’),检验用户是否有teacher:teacher:list权限;
@GetMapping注解,表明前端发送过来的是Get请求,请求地址为"/list"。或者换个说法,该注解表明这个方法,只能接收前端的Get请求,并且这个请求的请求地址是"/list";
startPage()方法,调用分页工具类中的分页方法,因为该方法返回的是一个list列表,因此这里用到了分页工具类PageUtils的分页功能;
getDataTable方法,检验数据库是否查询成功,如果成功,返回http状态码200和查询出来的列表,并设置前端需要的值(比如总页数等)。
2024-3-28
课程管理功能模块的实现
2024-3-29
论文管理功能模块的实现
2024-3-30
教材管理功能模块的实现
2024-3-31
参与学生课程成绩考核管理功能模块的实现
2024-4-1
指导学生毕业论文管理功能模块的实现
2024-4-2
其他活动管理功能模块的实现
2024-4-6
至此管理员系统还差工作量显示功能模块
教师系统还待制作
教师功能模块的实现
首先,教师可以显示课程列表、论文列表、教材列表、课程考核列表、指导论文列表、活动列表,这些列表的增删改操作与管理员列表一致,但是默认查询并显示的只有教师自己的数据。也就是说可以在保持原有功能不变的情况下,单独对教师这个角色进行限制,让教师角色只能访问以上的功能模块,并且只能查询出自己的数据。
在经过一下午的测试后,发现之前设计的角色不够方便,于是要开始重新设计角色
现在新的系统角色如下:
- teacher,权限同名,可以使用教师管理菜单,负责管理全部教师的信息并查看他们的工作量情况
- ordinary,权限同名,可以使用我是教师菜单,只能查看自己相关的数据,无法看到他人的数据
2024-4-7
教师自行修改个人信息功能模块的实现
只做对应部分的修改功能,学院、工号、职务等不允许修改
2024-4-8
自动设置最后更新日期的实现
使用js自带的获取当前日期的函数
const date = new Date()
2024-4-9
教师自动查询并显示个人信息的实现
从前端的cookie缓存中获取用户名,把用户名加在前端请求体中,后端接收到请求和用户名,查询出相同用户名的teather表中的数据
// 获取cookie中的用户名
export function getUsernameFromCookie() {
const cookies = document.cookie.split('; ');
for (let i = 0; i < cookies.length; i++) {
const [key, value] = cookies[i].split('=');
if (key === 'username') {
return decodeURIComponent(value);
}
}
return null;
}
2024-4-10
完成了[我是教师]菜单中的[课程信息查看]功能模块
2024-4-11
完成了[我是教师]菜单中的[论文信息编辑]功能模块
2024-4-12
完成了[我是教师]菜单中的[指导信息编辑]功能模块
2024-4-13
完成了[我是教师]菜单中的[活动信息编辑]功能模块
2024-4-14
完成了[我是教师]菜单中的[考试信息编辑]功能模块
2024-4-15
完成了[我是教师]菜单中的[教材信息编辑]功能模块
2024-4-16
至此只差[首页]中的工作量显示功能模块未完成,开始毕业设计论文的编写
的实现类,这里的注解加到了ITeacherService接口上,因此我们可以调用该接口的具体实现方法;
/**
* 查询教师列表
*/
@PreAuthorize("@ss.hasPermi('teacher:teacher:list')")
@GetMapping("/list")
public TableDataInfo list(Teacher teacher)
{
startPage();
List<Teacher> list = teacherService.selectTeacherList(teacher);
return getDataTable(list);
}
@PreAuthorize注解,该注解会在方法执行前进行权限验证,如果权限验证通过,那么才可以执行该方法,该注解是权限管理的重要组成部分;@ss.hasPermi(‘teacher:teacher:list’),检验用户是否有teacher:teacher:list权限;
@GetMapping注解,表明前端发送过来的是Get请求,请求地址为"/list"。或者换个说法,该注解表明这个方法,只能接收前端的Get请求,并且这个请求的请求地址是"/list";
startPage()方法,调用分页工具类中的分页方法,因为该方法返回的是一个list列表,因此这里用到了分页工具类PageUtils的分页功能;
getDataTable方法,检验数据库是否查询成功,如果成功,返回http状态码200和查询出来的列表,并设置前端需要的值(比如总页数等)。
2024-3-28
课程管理功能模块的实现
2024-3-29
论文管理功能模块的实现
2024-3-30
教材管理功能模块的实现
2024-3-31
参与学生课程成绩考核管理功能模块的实现
2024-4-1
指导学生毕业论文管理功能模块的实现
2024-4-2
其他活动管理功能模块的实现
2024-4-6
至此管理员系统还差工作量显示功能模块
教师系统还待制作
教师功能模块的实现
首先,教师可以显示课程列表、论文列表、教材列表、课程考核列表、指导论文列表、活动列表,这些列表的增删改操作与管理员列表一致,但是默认查询并显示的只有教师自己的数据。也就是说可以在保持原有功能不变的情况下,单独对教师这个角色进行限制,让教师角色只能访问以上的功能模块,并且只能查询出自己的数据。
在经过一下午的测试后,发现之前设计的角色不够方便,于是要开始重新设计角色
现在新的系统角色如下:
- teacher,权限同名,可以使用教师管理菜单,负责管理全部教师的信息并查看他们的工作量情况
- ordinary,权限同名,可以使用我是教师菜单,只能查看自己相关的数据,无法看到他人的数据
2024-4-7
教师自行修改个人信息功能模块的实现
只做对应部分的修改功能,学院、工号、职务等不允许修改
2024-4-8
自动设置最后更新日期的实现
使用js自带的获取当前日期的函数
const date = new Date()
2024-4-9
教师自动查询并显示个人信息的实现
从前端的cookie缓存中获取用户名,把用户名加在前端请求体中,后端接收到请求和用户名,查询出相同用户名的teather表中的数据
// 获取cookie中的用户名
export function getUsernameFromCookie() {
const cookies = document.cookie.split('; ');
for (let i = 0; i < cookies.length; i++) {
const [key, value] = cookies[i].split('=');
if (key === 'username') {
return decodeURIComponent(value);
}
}
return null;
}