Java project: design and implementation of course selection recommendation communication platform (java+springboot+ssm+mysql)

Design of main functional modules:

Login registration, homepage information browsing, course selection classification viewing, course selection details viewing, comment exchange, collection, browsing volume, background data management, user management, course selection category management, course selection information details management, comment exchange and reply management, announcement information management, etc

Main technologies:

Java, spring MVC, mybatis, mysql, tomcat, jquery, layui, JavaScript, html, css, jsp, log4j and other common basic technologies.


Main functions: front end:


Home page of course selection platform:

input http://localhost/ Visit the homepage of the course selection recommendation exchange platform, view the rotation chart and various information, and click to enter the details page

Login registration management:

Recommended classification of course selection:

Click to view the classified course recommendation information, view the course information by category, and the administrator can add the course classification information in the background

And click ranking according to the number of visits

Course details:

For course details, you can view course details, author information, views and other specific data, as well as comments, collections and other operations

My personal Center:

Include my personal information and favorites

Main functions: BACKGROUND:

System homepage design:

The main function modules include data maintenance such as home page information statistics, course selection type management, course selection details management, user management, comment and announcement management.

Course selection type management:

Course selection information details management:

List information viewing, adding, modifying, deleting and retrieving

Details:

Notice and announcement information:

Data list viewing, adding, modifying, deleting, etc

User information management:

Comment exchange and reply Management:

Data management of comments and replies

Display of some key codes:

Login module:

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.*;
 
/**
 * Root path and other request processing
 * 
 * @author Li Yangyong
 *
 */
@Controller
public class IndexController {
 
  @Value("${imageFilePath}")
  private String imageFilePath; // File path
 
  @Resource
  private NoticeService noticeService;
 
  @Resource
  private UserService userService;
 
  @Resource
  private ArticleService articleService;
  @Resource
  private ClassifyService classifyService;
 
 
 
  @RequestMapping("/")
  public String index(HttpSession session) {
 
    // Query announcement
    session.setAttribute("noticeList", noticeService.list(0, 5));
    return "index";// Jump to 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;
  }
  /**
   * Login page
   * 
   * @return
   */
  @RequestMapping("/login")
  public String login() {
    return "login";
  }
 
  /**
   * Front desk login page
   * 
   * @return
   */
  @RequestMapping("/webLogin")
  public String webLogin() {
    return "webLogin";
  }
 
  /**
   * register
   * 
   * @return
   */
  @RequestMapping("/regist")
  public String regist() {
    return "regist";
  }
 
  /**
   * Save registration information
   * 
   * @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";
  }
 
  /**
   * Log out
   * 
   * @param request
   * @return
   */
  @RequestMapping("/quit")
  public String quit(HttpServletRequest request) {
    HttpSession session = request.getSession();
    session.removeAttribute("user");
    return "index";
  }
 
 
  /**
   * Log out
   * 
   * @param request
   * @return
   */
  @RequestMapping("/quitAdmin")
  public String quitAdmin(HttpServletRequest request) {
    HttpSession session = request.getSession();
    session.removeAttribute("user");
    return "login";
  }
 
  /**
   * Verify 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", "Wrong user name or password!");
      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;
  }
 
  /**
   * View personal information
   * 
   * @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;
  }
 
  /**
   * View personal course favorites
   * 
   * @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;
  }
 
  /**
   * View personal follow-up users
   * 
   * @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;
  }
 
  /**
   * Save user information
   * 
   * @param user
   * @return
   */
  @RequestMapping("/save")
  public ModelAndView save(User user) {
    ModelAndView mav = new ModelAndView();
    userService.save(user);
    mav.setViewName("/index");
    return mav;
  }
 
  /**
   * Write notes page
   * 
   * @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;
  }
 
  /**
   * Save notes
   * 
   * @param article
   * @param request
   * @return
   */
  @RequestMapping("addNote")
  public ModelAndView addNote(Article article, HttpServletRequest request) {
    ModelAndView mav = new ModelAndView();
    // Get current user information
    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());
    // Get current user information
    articleService.save(article);
    mav.setViewName("/index");
    return mav;
  }
 
  /**
   * View notes
   * 
   * @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";
  }
 
  /**
   * View personal notes load data list
   * 
   * @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; // start time
    String s_ePublishDate = null; // End time
    if (StringUtil.isNotEmpty(publishDates)) {
      String[] strs = publishDates.split(" - "); // Split time period
      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); // PageCount 
    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;
  }
 
  /**
   * Background default home page
   * 
   * @return
   */
  @RequestMapping("/index")
  public String root() {
    return "/common/index";
  }
 
  /**
   * Blogger information page
   * 
   * @return
   */
  @RequestMapping("/blogger")
  public String blogger() {
    return "/blogger/index";
  }
 
  /**
   * Picture upload processing @ Title: ckeditorUpload @param file picture file @ return parameter description @ return
   * Map<String,Object> Return type @ 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(); // Get file name
    String suffixName = fileName.substring(fileName.lastIndexOf(".")); // Gets the suffix of the file
    String newFileName = "";
    try {
      newFileName = DateUtil.getCurrentDateStr() + suffixName; // New file name
      FileUtils.copyInputStreamToFile(file.getInputStream(), new File(imageFilePath + newFileName)); // upload
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    resultMap.put("code", 0);
    resultMap1.put("filePath", newFileName);
    resultMap.put("data", resultMap1);
    return resultMap;
  }
 
}

Main table design:

User table:

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
;
 

Course selection type table:

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
;
 

Course selection details:

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
;
 

Comment exchange form:

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
;
 

Reply information form:

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
;
 

For details, you can chat privately. Thank you for your support and help!

Click to view more java boutique projects > > >

Keywords: Java MySQL JSP Mybatis Spring

Added by Joseph07 on Thu, 27 Jan 2022 18:06:31 +0200