基于java ssm springboot实现选课推荐交流平台系统设计和实现必须收藏
Posted java李杨勇
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于java ssm springboot实现选课推荐交流平台系统设计和实现必须收藏相关的知识,希望对你有一定的参考价值。
夏天到了、小雪来给大家降降温
话不多说、直接进入主题
目录
主要功能模块设计:
登录注册、首页信息浏览、选课分类查看、选课详情查看、评论交流、收藏、浏览量、以及后台数据管理、用户管理、选课类别管理、选课信息详情管理、评论交流和回复管理、以及公告信息管理等
主要技术:
Java、springmvc、mybatis、mysql、tomcat、jquery、layui、javascript、html、css、jsp、log4j等一些常见的基本技术。
主要功能实现前端:
选课平台首页:
输入http://localhost/访问选课推荐交流平台首页、可以查看轮播图以及各类信息、点击进入详情页面
登录注册管理:
选课推荐分类:
点击查看分类课程推荐信息、按照类别查看课程信息、管理员可以在后台添加课程分类信息
以及根据访问量来进行点击排行、
课程详情信息:
课程详情可以查看课程详情信息以及作者信息和浏览量等具体数据、也可以进行评论和收藏等操作
我的个人中心:
包括我的个人信息和收藏夹信息、
主要功能实现后台:
系统主页设计:
主要功能模块有首页的信息统计、选课类型管理、选课详情管理、用户管理、评论和公告管理等数据维护。
选课类型管理:
选课信息详情管理:
列表信息查看添加修改删除以及检索等操作
详情信息
通知公告信息:
数据列表查看和添加修改删除等操作
用户信息管理:
评论交流回复管理:
评论和回复的数据管理
部分关键代码展示:
登录模块:
package com.longwang.controller;
import com.longwang.entity.Article;
import com.longwang.entity.Classify;
import com.longwang.entity.User;
import com.longwang.service.ArticleService;
import com.longwang.service.ClassifyService;
import com.longwang.service.NoticeService;
import com.longwang.service.UserService;
import com.longwang.util.DateUtil;
import com.longwang.util.StringUtil;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.util.*;
/**
* 根路径以及其他请求处理
*
* @author 李杨勇
*
*/
@Controller
public class IndexController {
@Value("${imageFilePath}")
private String imageFilePath; // 文件路径
@Resource
private NoticeService noticeService;
@Resource
private UserService userService;
@Resource
private ArticleService articleService;
@Resource
private ClassifyService classifyService;
@RequestMapping("/")
public String index(HttpSession session) {
// 查询公告
session.setAttribute("noticeList", noticeService.list(0, 5));
return "index";// 跳转到index.html
}
@RequestMapping("/delete")
public Map<String, Object> delete(Integer userId) {
Map<String, Object> resultMap = new HashMap<String, Object>();
userService.delete(userId);
resultMap.put("errorNo", 0);
return resultMap;
}
/**
* 登录页面
*
* @return
*/
@RequestMapping("/login")
public String login() {
return "login";
}
/**
* 前台登录页面
*
* @return
*/
@RequestMapping("/webLogin")
public String webLogin() {
return "webLogin";
}
/**
* 注册
*
* @return
*/
@RequestMapping("/regist")
public String regist() {
return "regist";
}
/**
* 保存注册信息
*
* @param user
* @return
*/
@RequestMapping("/saveUser")
public String saveUser(User user) {
List<Article> randomArticle = articleService.getRandomArticle(3);
String ids="";
for (int i = 0; i < randomArticle.size(); i++) {
Integer articleId = randomArticle.get(i).getArticleId();
ids+=articleId+",";
}
ids = ids.substring(0, ids.length() -1);
user.setArticleIds(ids);
userService.save(user);
return "webLogin";
}
/**
* 退出登录
*
* @param request
* @return
*/
@RequestMapping("/quit")
public String quit(HttpServletRequest request) {
HttpSession session = request.getSession();
session.removeAttribute("user");
return "index";
}
/**
* 退出登录
*
* @param request
* @return
*/
@RequestMapping("/quitAdmin")
public String quitAdmin(HttpServletRequest request) {
HttpSession session = request.getSession();
session.removeAttribute("user");
return "login";
}
/**
* 验证登录
*
* @param user
* @param request
* @return
*/
@RequestMapping("/checkLogin")
public ModelAndView checkLogin(User user, HttpServletRequest request) {
ModelAndView mav = new ModelAndView();
HttpSession session = request.getSession();
User u = userService.findByUsernameAndPassword(user.getUsername(), user.getPassword());
if (u == null) {
mav.addObject("user", user);
mav.addObject("errorInfo", "用户名或者密码错误!");
mav.setViewName("webLogin");
} else {
u.setLatelyLoginTime(new Date());
userService.save(u);
session.setAttribute("user", u);
mav.addObject("username", u.getUsername());
mav.addObject("user", u);
mav.addObject("success", true);
mav.setViewName("/index");
}
return mav;
}
/**
* 查看个人信息
*
* @return
*/
@RequestMapping("viewPerson")
public ModelAndView viewPerson(HttpServletRequest request) {
User user = (User) request.getSession().getAttribute("user");
ModelAndView mav = new ModelAndView();
User u = userService.findById(user.getUserId());
mav.addObject("user", u);
mav.setViewName("/viewPerson");
return mav;
}
/**
* 查看个人课程收藏夹
*
* @return
*/
@RequestMapping("viewCollection")
public ModelAndView viewCollection(HttpServletRequest request, HttpSession session) {
User user = (User) request.getSession().getAttribute("user");
ModelAndView mav = new ModelAndView();
User u = userService.findById(user.getUserId());
String artIds = u.getArticleIds();
List<String> result = new ArrayList<>();
if (StringUtils.isNotBlank(artIds)) {
result = Arrays.asList(StringUtils.split(artIds, ","));
}
List<Integer> retIds = new ArrayList<>();
for (String temp : result) {
retIds.add(Integer.valueOf(temp).intValue());
}
List<Article> retArt = articleService.findByListId(retIds);
session.setAttribute("noticeList", noticeService.list(0, 5));
mav.addObject("retArt", retArt);
mav.addObject("user", u);
mav.setViewName("/viewCollection");
return mav;
}
/**
* 查看个人关注用户
*
* @return
*/
@RequestMapping("viewFocusUser")
public ModelAndView viewFocusUser(HttpServletRequest request, HttpSession session) {
User user = (User) request.getSession().getAttribute("user");
ModelAndView mav = new ModelAndView();
User u = userService.findById(user.getUserId());
String userIds = u.getUserIds();
List<String> result = new ArrayList<>();
if (StringUtils.isNotBlank(userIds)) {
result = Arrays.asList(StringUtils.split(userIds, ","));
}
List<Integer> retIds = new ArrayList<>();
for (String temp : result) {
retIds.add(Integer.valueOf(temp).intValue());
}
List<User> retArt = userService.findByListId(retIds);
session.setAttribute("noticeList", noticeService.list(0, 5));
mav.addObject("retArt", retArt);
mav.addObject("user", u);
mav.setViewName("/viewFocusUser");
return mav;
}
/**
* 保存用户信息
*
* @param user
* @return
*/
@RequestMapping("/save")
public ModelAndView save(User user) {
ModelAndView mav = new ModelAndView();
userService.save(user);
mav.setViewName("/index");
return mav;
}
/**
* 写笔记页面
*
* @param request
* @return
*/
// @RequestMapping("notePage")
// public String notePage(HttpServletRequest request, Model model) {
// User user = (User) request.getSession().getAttribute("user");
// if (user == null) {
// return "webLogin";
// }
// List<Classify> list = classifyService.findAll();
// model.addAttribute("list", list);
// return "one";
// }
@RequestMapping("notePage")
public ModelAndView notePage(HttpServletRequest request) {
ModelAndView mav = new ModelAndView();
User user = (User) request.getSession().getAttribute("user");
if (user == null) {
mav.setViewName("/webLogin");
return mav;
}
List<Classify> list = classifyService.findAll();
mav.addObject("list", list);
mav.setViewName("/one");
return mav;
}
/**
* 保存笔记
*
* @param article
* @param request
* @return
*/
@RequestMapping("addNote")
public ModelAndView addNote(Article article, HttpServletRequest request) {
ModelAndView mav = new ModelAndView();
// 获取当前用户信息
User user = (User) request.getSession().getAttribute("user");
article.setUserId(user.getUserId());
article.setPublishDate(new Date());
article.setClick(0);
article.setCommentNum(0);
article.setContentNoTag(StringUtil.Html2Text(article.getContent()));
articleService.save(article);
mav.setViewName("/index");
return mav;
}
@RequestMapping("saveNote")
public ModelAndView saveNote(Article article, HttpServletRequest request) {
ModelAndView mav = new ModelAndView();
Article a = articleService.findById(article.getArticleId());
article.setPublishDate(a.getPublishDate());
// 获取当前用户信息
articleService.save(article);
mav.setViewName("/index");
return mav;
}
/**
* 查看笔记
*
* @return
*/
@RequestMapping("viewNote")
public String viewNote(HttpSession session) {
session.setAttribute("noticeList", noticeService.list(0, 5));
return "mylist";
}
@RequestMapping("/delete/{id}")
public String delete(@PathVariable(value = "id") String id) throws Exception {
articleService.delete(Integer.parseInt(id));
return "mylist";
}
/**
* 查看个人笔记加载数据列表
*
* @param article
* @param publishDates
* @param page
* @param pageSize
* @return
*/
@RequestMapping("/mylist")
public Map<String, Object> list(Article article,
@RequestParam(value = "publishDates", required = false) String publishDates,
@RequestParam(value = "page", required = false) Integer page,
@RequestParam(value = "pageSize", required = false) Integer pageSize, HttpServletRequest request) {
Map<String, Object> resultMap = new HashMap<String, Object>();
// User user = (User) request.getSession().getAttribute("user");
// article.setUserId(user.getUserId());
String s_bPublishDate = null; // 开始时间
String s_ePublishDate = null; // 结束时间
if (StringUtil.isNotEmpty(publishDates)) {
String[] strs = publishDates.split(" - "); // 拆分时间段
s_bPublishDate = strs[0];
s_ePublishDate = strs[1];
}
Long total = articleService.getCount(article, s_bPublishDate, s_ePublishDate);
int totalPage = (int) (total % pageSize == 0 ? total / pageSize : total / pageSize + 1); // 总页数
resultMap.put("totalPage", totalPage);
resultMap.put("errorNo", 0);
resultMap.put("data", articleService.list(article, s_bPublishDate, s_ePublishDate, page - 1, pageSize));
resultMap.put("total", total);
return resultMap;
}
/**
* 后台默认首页
*
* @return
*/
@RequestMapping("/index")
public String root() {
return "/common/index";
}
/**
* 博主信息页面
*
* @return
*/
@RequestMapping("/blogger")
public String blogger() {
return "/blogger/index";
}
/**
* 图片上传处理 @Title: ckeditorUpload @param file 图片文件 @return 参数说明 @return
* Map<String,Object> 返回类型 @throws
*/
@ResponseBody
@RequestMapping("/upload")
public Map<String, Object> ckeditorUpload(@RequestParam("file") MultipartFile file) {
Map<String, Object> resultMap = new HashMap<String, Object>();
Map<String, Object> resultMap1 = new HashMap<String, Object>();
String fileName = file.getOriginalFilename(); // 获取文件名
String suffixName = fileName.substring(fileName.lastIndexOf(".")); // 获取文件的后缀
String newFileName = "";
try {
newFileName = DateUtil.getCurrentDateStr() + suffixName; // 新文件名
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(imageFilePath + newFileName)); // 上传
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
resultMap.put("code", 0);
resultMap1.put("filePath", newFileName);
resultMap.put("data", resultMap1);
return resultMap;
}
}
配置模块:
server:
port: 80
servlet:
context-path: /
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/choosing_courses?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: 123456
jpa:
hibernate:
ddl-auto: update
show-sql: true
database-platform: org.hibernate.dialect.MySQLDialect
thymeleaf:
cache: false
thymeleaf:
prefix: classpath:/templates/
MD5Salt: longwang
imageFilePath: C:\\\\Users\\\\Administrator\\\\Desktop\\\\choosingCourses\\\\src\\\\main\\\\webapp\\\\static\\\\images\\\\
downloadImagePath: C:\\\\Users\\\\Administrator\\\\Desktop\\\\choosingCourses\\\\src\\\\main\\\\webapp
lucenePath: C:\\\\Users\\\\Administrator\\\\Desktop\\\\choosingCourses\\\\lucene
主要表设计:
用户表:
CREATE TABLE `NewTable` (
`user_id` int(11) NOT NULL AUTO_INCREMENT ,
`head_portrait` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`lately_login_time` datetime NULL DEFAULT NULL ,
`nickname` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`registration_date` datetime NULL DEFAULT NULL ,
`sex` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`open_id` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`article_ids` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`birthday` date NULL DEFAULT NULL ,
`momo` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`phone` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`user_ids` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
PRIMARY KEY (`user_id`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=20
ROW_FORMAT=COMPACT
;
选课类型表:
CREATE TABLE `NewTable` (
`classify_id` int(11) NOT NULL AUTO_INCREMENT ,
`classify_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL ,
PRIMARY KEY (`classify_id`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci
AUTO_INCREMENT=27
ROW_FORMAT=COMPACT
;
选课详情表:
CREATE TABLE `NewTable` (
`article_id` int(11) NOT NULL AUTO_INCREMENT ,
`author` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL ,
`click` int(11) NULL DEFAULT NULL ,
`comment_num` int(11) NULL DEFAULT NULL ,
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL ,
`image_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
`is_original` int(11) NULL DEFAULT NULL ,
`is_top` int(11) NULL DEFAULT NULL ,
`publish_date` datetime NULL DEFAULT NULL ,
`title` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL ,
`classify_id` int(11) NULL DEFAULT NULL ,
`user_id` int(11) NULL DEFAULT NULL ,
PRIMARY KEY (`article_id`),
FOREIGN KEY (`classify_id`) REFERENCES `t_classify` (`classify_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
INDEX `FKo4fros4yfq1m9ay7sgtlcvbc4` (`classify_id`) USING BTREE
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci
AUTO_INCREMENT=58
ROW_FORMAT=COMPACT
;
评论交流表:
CREATE TABLE `NewTable` (
`comment_id` int(11) NOT NULL AUTO_INCREMENT ,
`comment_date` datetime NULL DEFAULT NULL ,
`content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
`article_id` int(11) NULL DEFAULT NULL ,
`user_id` int(11) NULL DEFAULT NULL ,
PRIMARY KEY (`comment_id`),
FOREIGN KEY (`article_id`) REFERENCES `t_article` (`article_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
FOREIGN KEY (`user_id`) REFERENCES `t_user` (`user_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
INDEX `FKlsvvc2ob8lxg2m9qqry15ru0y` (`article_id`) USING BTREE ,
INDEX `FKtamaoacctq4qpko6bvtv0ke1p` (`user_id`) USING BTREE
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci
AUTO_INCREMENT=15
ROW_FORMAT=COMPACT
;
回复信息表:
CREATE TABLE `NewTable` (
`reply_id` int(11) NOT NULL AUTO_INCREMENT ,
`content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
`reply_date` datetime NULL DEFAULT NULL ,
`comment_id` int(11) NULL DEFAULT NULL ,
`user_id` int(11) NULL DEFAULT NULL ,
PRIMARY KEY (`reply_id`),
FOREIGN KEY (`comment_id`) REFERENCES `t_comment` (`comment_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
FOREIGN KEY (`user_id`) REFERENCES `t_user` (`user_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
INDEX `FKk4ydp71wampdbnguly8iks4rf` (`comment_id`) USING BTREE ,
INDEX `FKslt6r79iw1p9cbxns09erjv6v` (`user_id`) USING BTREE
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci
AUTO_INCREMENT=6
ROW_FORMAT=COMPACT
;
基于java ssm springboot+VUE疫情防疫系统系统前后端分离设计和实现
基于java springboot+mybatis电影售票网站管理系统前台+后台设计和实现
基于java ssm springboot+mybatis酒庄内部管理系统设计和实现
基于JAVA springboot+mybatis智慧生活分享平台设计和实现
基于Java springboot+vue+redis前后端分离家具商城平台系统设计和实现
基于JAVA SSM springboot实现的抗疫物质信息管理系统设计和实现
查看更多博主首页更多实战项目 >>>
好了,今天就到这儿吧,小伙伴们点赞、收藏、评论,一键三连走起呀,下期见~~
以上是关于基于java ssm springboot实现选课推荐交流平台系统设计和实现必须收藏的主要内容,如果未能解决你的问题,请参考以下文章
基于javaweb基于ssm框架学生信息管理(选课)系统设计与实现(项目源码)
java基于微信小程序的学生选课系统+ssm+uinapp+Mysql+计算机毕业设计