系统描述
基于spring boot vue的学生选课系统
前端:
Vue ElementUI axios
后端 springboot
持久层 mybatis Plus
会话 Spring Session +redis
日志 AOP MongoDB
数据库 MySQL
Redis:session 新闻 配置信息
MongoDB 业务日志
一、系统功能
学生 教师 管理员三种登录
利用网络爬虫 获取网站新闻信息 显示在首页
管理员登录:专业管理 班级管理 学生管理 教师管理 课程管理 选课管理 管理员管理
学生登录:选修课程 学生课程 课表查询 考试查询 成绩查询 信息维护
教师登录:授课查询 教师课表 成绩录入
二、系统截图
1.网络爬虫 新闻获取代码
代码如下(示例):
package com.mecol.select_course.manager;
import com.mecol.select_course.dao.redis.SdnuNewsDAO;
import com.mecol.select_course.model.bo.SdnuNewsBO;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Component
public class SdnuNewsManager extends BaseManager {
private static final int CRAWL_INTERVAL = 60 * 60 * 1000;
private static final int CRAWL_TIMEOUT = 30 * 1000;
private static final String CRAWL_TARGET_URL = "https://www.sdjtu.edu.cn/xxyw.htm";
private static final String BASE_URL = "https://www.sdjtu.edu.cn/";
private final SdnuNewsDAO sdnuNewsDAO;
public SdnuNewsManager(SdnuNewsDAO sdnuNewsDAO) {
this.sdnuNewsDAO = sdnuNewsDAO;
}
public List<SdnuNewsBO> getAllNews() {
Map<String, String> map = sdnuNewsDAO.getAllNews();
List<SdnuNewsBO> newsList = new ArrayList<>(map.size());
for (String key : map.keySet()) {
String value = map.get(key);
// 2019/01/01http://host/path
String date = value.substring(0, 10);
String url = value.substring(10);
newsList.add(new SdnuNewsBO(key, date, url));
}
return newsList;
}
//定时任务 fixedDelay参数,传入一个以毫秒为单位的时间间隔
@Scheduled(fixedDelay = CRAWL_INTERVAL)
public void crawlNews() {
Document pageDoc = fetchPage();
if (pageDoc == null) {
return;
}
List<SdnuNewsBO> newsList = parseNews(pageDoc);
sdnuNewsDAO.clear();
for (SdnuNewsBO news : newsList) {
sdnuNewsDAO.addNews(news.getTitle(), news.getDate() + news.getUrl());
}
}
private Document fetchPage() {
Document doc = null;
try {
doc = Jsoup.parse(new URL(CRAWL_TARGET_URL), CRAWL_TIMEOUT);
} catch (IOException ex) {
ex.printStackTrace();
}
return doc;
}
private List<SdnuNewsBO> parseNews(Document pageDoc) {
/*
Elements elements = pageDoc.body()
.getElementsByClass("TB3").get(0)
.getElementsByTag("table").get(0)
.getElementsByTag("tr");*/
Elements elements=pageDoc.body().getElementsByClass("news_list").select("li");
// System.out.println(elements);
List<SdnuNewsBO> newsList = new ArrayList<>();
for (Element element : elements) {
// System.out.println(element);
//if (!element.attr("id").startsWith("line")) {
// continue;
// }
// Element aTag = element.getElementsByTag("a").get(0);
//Element dateTag = element.getElementsByTag("td").get(2);
String url = BASE_URL +element.getElementsByTag("a").attr("href");
String title = element.getElementsByTag("a").attr("title");
String date1 = element.getElementsByClass("left_date").text();
String date=date1.substring(1,date1.length()-1);
// System.out.println(date);
newsList.add(new SdnuNewsBO(title, date, url));
}
return newsList;
}
}
2.pom
代码如下(示例):
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.mecol</groupId>
<artifactId>selectcourse</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>selectcourse</name>
<description>selectcourse</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.12.1</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
源码
https://pan.baidu.com/s/12rGMPHJb6E0IV2DgOzZUxw 提取码: gqx8