欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

基于java ssm springboot实现选课推荐交流平台系统

程序员文章站 2022-06-16 12:35:01
目录夏天到了、小雪来给大家降降温话不多说、直接进入主题主要功能模块设计:登录注册、首页信息浏览、选课分类查看、选课详情查看、评论交流、收藏、浏览量、以及后台数据管理、用户管理、选课类别管理、选课信息详...

夏天到了、小雪来给大家降降温

基于java ssm springboot实现选课推荐交流平台系统

话不多说、直接进入主题

主要功能模块设计:

登录注册、首页信息浏览、选课分类查看、选课详情查看、评论交流、收藏、浏览量、以及后台数据管理、用户管理、选课类别管理、选课信息详情管理、评论交流和回复管理、以及公告信息管理等

主要技术:

java、springmvc、mybatis、mysql、tomcat、jquery、layui、javascript、html、css、jsp、log4j等一些常见的基本技术。

主要功能实现前端:

选课平台首页:

输入http://localhost/访问选课推荐交流平台首页、可以查看轮播图以及各类信息、点击进入详情页面

基于java ssm springboot实现选课推荐交流平台系统

基于java ssm springboot实现选课推荐交流平台系统

登录注册管理:

基于java ssm springboot实现选课推荐交流平台系统

选课推荐分类:

点击查看分类课程推荐信息、按照类别查看课程信息、管理员可以在后台添加课程分类信息

以及根据访问量来进行点击排行、

基于java ssm springboot实现选课推荐交流平台系统

课程详情信息:

课程详情可以查看课程详情信息以及作者信息和浏览量等具体数据、也可以进行评论和收藏等操作

基于java ssm springboot实现选课推荐交流平台系统

基于java ssm springboot实现选课推荐交流平台系统

我的个人中心:

包括我的个人信息和收藏夹信息、

基于java ssm springboot实现选课推荐交流平台系统

主要功能实现后台:

系统主页设计:

主要功能模块有首页的信息统计、选课类型管理、选课详情管理、用户管理、评论和公告管理等数据维护。

基于java ssm springboot实现选课推荐交流平台系统

选课类型管理:

基于java ssm springboot实现选课推荐交流平台系统

选课信息详情管理:

列表信息查看添加修改删除以及检索等操作

基于java ssm springboot实现选课推荐交流平台系统

详情信息

基于java ssm springboot实现选课推荐交流平台系统

通知公告信息:

数据列表查看和添加修改删除等操作

基于java ssm springboot实现选课推荐交流平台系统

用户信息管理:

基于java ssm springboot实现选课推荐交流平台系统

评论交流回复管理:

评论和回复的数据管理

基于java ssm springboot实现选课推荐交流平台系统

部分关键代码展示:

登录模块:

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实现的文章就介绍到这了,更多相关交流平台系统内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!