Author homepage: Programming Paper Crane
About the author: Java, front-end, and Pythone have been developed for many years, and have worked as a senior engineer, project manager, and architect
Main content: Java project development, graduation design development, interview technology arrangement, latest technology sharing
Favorites, likes, don't get lost, it's good to pay attention to the author
Item number: BS-PT-070
1. Project Introduction
There are many computer hardware enthusiasts in the society, and they urgently need a platform for publishing professional hardware evaluation data and a community for communication and interaction. The computer hardware exchange platform developed this time serves these enthusiasts as a professional hardware evaluation platform. This has played a very good role in the popularization of computer-related hardware products and the sharing of hardware evaluation data.
This platform is mainly used to publish the evaluation data of computer hardware and for the exchange and discussion of the majority of enthusiasts. There are many computer hardware products appearing every year. These products generally have special organizations to conduct related evaluations, and many enthusiasts pay attention to these hardware. The performance of the product, this development platform can realize the release and sharing of hardware evaluation data, and hand it over to the majority of enthusiasts for online discussion.
This system is mainly divided into the system front end and the system back end. The front end mainly displays the data information of computer hardware evaluation released by some evaluation specialists. The majority of enthusiasts can view and participate in the discussion online, and users can also view it through the corresponding classification or article tags. Related review articles. And display the hottest comment posts according to the comment information, and provide full-text search and online message functions. You can also apply for a website link online, and the background administrator can add an external link after review. Backstage administrators and evaluation specialists log in to the background system to publish relevant evaluation articles, set related categories and tags, manage relevant discussion information and reply, and also manage information of evaluation specialists. Administrators can also participate in relevant business modules, display platform information, add friendship links, etc.
Second, the environment introduction
Locale: Java: jdk1.8
Database: Mysql: mysql5.7
Application server: Tomcat: tomcat8.5.31
Development tools: IDEA or eclipse
Background development technology: SSM framework
Front-end development technology: Jquery,Jquery-UI,BootStrap,Ajax,JSP
Three, system display
Front-end home page
Article viewing and comments
View hardware review articles by category
online message
article archive
Reviewer login
background display
Evaluation Article View
Hardware evaluation classification management
Tag management
custom page
External link management
Platform announcement
comment management
Reviewer Management
Platform front-end menu management
Fourth, the core code display
package com.liuyanzhao.ssm.blog.controller.admin; import com.liuyanzhao.ssm.blog.entity.Article; import com.liuyanzhao.ssm.blog.entity.Comment; import com.liuyanzhao.ssm.blog.entity.User; import com.liuyanzhao.ssm.blog.service.ArticleService; import com.liuyanzhao.ssm.blog.service.CommentService; import com.liuyanzhao.ssm.blog.service.UserService; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.liuyanzhao.ssm.blog.util.MyUtils.getIpAddr; /** * @author znz */ @Controller public class AdminController { @Autowired private UserService userService; @Autowired private ArticleService articleService; @Autowired private CommentService commentService; /** * Background Home * * @return */ @RequestMapping("/admin") public String index(Model model) { //Article list List<Article> articleList = articleService.listRecentArticle(5); model.addAttribute("articleList",articleList); //comment list List<Comment> commentList = commentService.listRecentComment(5); model.addAttribute("commentList",commentList); return "Admin/index"; } /** * The login page is displayed * * @return */ @RequestMapping("/login") public String loginPage() { return "Admin/login"; } /** * Login authentication * * @param request * @param response * @return */ @RequestMapping(value = "/loginVerify",method = RequestMethod.POST) @ResponseBody public String loginVerify(HttpServletRequest request, HttpServletResponse response) { Map<String, Object> map = new HashMap<String, Object>(); String username = request.getParameter("username"); String password = request.getParameter("password"); String rememberme = request.getParameter("rememberme"); User user = userService.getUserByNameOrEmail(username); if(user==null) { map.put("code",0); map.put("msg","Invalid username!"); } else if(!user.getUserPass().equals(password)) { map.put("code",0); map.put("msg","wrong password!"); } else { //login successful map.put("code",1); map.put("msg",""); //add session request.getSession().setAttribute("user", user); //add cookie if(rememberme!=null) { //Create two Cookie objects Cookie nameCookie = new Cookie("username", username); //Set the validity period of the Cookie to 3 days nameCookie.setMaxAge(60 * 60 * 24 * 3); Cookie pwdCookie = new Cookie("password", password); pwdCookie.setMaxAge(60 * 60 * 24 * 3); response.addCookie(nameCookie); response.addCookie(pwdCookie); } user.setUserLastLoginTime(new Date()); user.setUserLastLoginIp(getIpAddr(request)); userService.updateUser(user); } String result = new JSONObject(map).toString(); return result; } /** * sign out * * @param session * @return */ @RequestMapping(value = "/admin/logout") public String logout(HttpSession session) { session.removeAttribute("user"); session.invalidate(); return "redirect:/login"; } }
package com.znz.ssm.blog.controller.admin; import cn.hutool.http.HtmlUtil; import com.github.pagehelper.PageInfo; import com.znz.ssm.blog.dto.ArticleParam; import com.znz.ssm.blog.entity.Article; import com.znz.ssm.blog.service.ArticleService; import com.znz.ssm.blog.service.CategoryService; import com.znz.ssm.blog.service.TagService; import com.znz.ssm.blog.entity.Category; import com.znz.ssm.blog.entity.Tag; import com.znz.ssm.blog.entity.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpSession; import java.util.ArrayList; import java.util.HashMap; import java.util.List; /** * @author znz */ @Controller @RequestMapping("/admin/article") public class BackArticleController { @Autowired private ArticleService articleService; @Autowired private TagService tagService; @Autowired private CategoryService categoryService; /** * Background article list display * * @return modelAndView */ @RequestMapping(value = "") public String index(@RequestParam(required = false, defaultValue = "1") Integer pageIndex, @RequestParam(required = false, defaultValue = "10") Integer pageSize, @RequestParam(required = false) String status, Model model) { HashMap<String, Object> criteria = new HashMap<>(1); if (status == null) { model.addAttribute("pageUrlPrefix", "/admin/article?pageIndex"); } else { criteria.put("status", status); model.addAttribute("pageUrlPrefix", "/admin/article?status=" + status + "&pageIndex"); } PageInfo<Article> articlePageInfo = articleService.pageArticle(pageIndex, pageSize, criteria); model.addAttribute("pageInfo", articlePageInfo); return "Admin/Article/index"; } /** * Add article page display in the background * * @return */ @RequestMapping(value = "/insert") public String insertArticleView(Model model) { List<Category> categoryList = categoryService.listCategory(); List<Tag> tagList = tagService.listTag(); model.addAttribute("categoryList", categoryList); model.addAttribute("tagList", tagList); return "Admin/Article/insert"; } /** * Add article submission operation in the background * * @param articleParam * @return */ @RequestMapping(value = "/insertSubmit", method = RequestMethod.POST) public String insertArticleSubmit(HttpSession session, ArticleParam articleParam) { Article article = new Article(); //User ID User user = (User) session.getAttribute("user"); if (user != null) { article.setArticleUserId(user.getUserId()); } article.setArticleTitle(articleParam.getArticleTitle()); //Thesis int summaryLength = 150; String summaryText = HtmlUtil.cleanHtmlTag(articleParam.getArticleContent()); if (summaryText.length() > summaryLength) { String summary = summaryText.substring(0, summaryLength); article.setArticleSummary(summary); } else { article.setArticleSummary(summaryText); } article.setArticleContent(articleParam.getArticleContent()); article.setArticleStatus(articleParam.getArticleStatus()); //fill category List<Category> categoryList = new ArrayList<>(); if (articleParam.getArticleChildCategoryId() != null) { categoryList.add(new Category(articleParam.getArticleParentCategoryId())); } if (articleParam.getArticleChildCategoryId() != null) { categoryList.add(new Category(articleParam.getArticleChildCategoryId())); } article.setCategoryList(categoryList); //fill tab List<Tag> tagList = new ArrayList<>(); if (articleParam.getArticleTagIds() != null) { for (int i = 0; i < articleParam.getArticleTagIds().size(); i++) { Tag tag = new Tag(articleParam.getArticleTagIds().get(i)); tagList.add(tag); } } article.setTagList(tagList); articleService.insertArticle(article); return "redirect:/admin/article"; } /** * delete article * * @param id Article ID */ @RequestMapping(value = "/delete/{id}") public void deleteArticle(@PathVariable("id") Integer id) { articleService.deleteArticle(id); } /** * Edit article page display * * @param id * @return */ @RequestMapping(value = "/edit/{id}") public ModelAndView editArticleView(@PathVariable("id") Integer id) { ModelAndView modelAndView = new ModelAndView(); Article article = articleService.getArticleByStatusAndId(null, id); modelAndView.addObject("article", article); List<Category> categoryList = categoryService.listCategory(); modelAndView.addObject("categoryList", categoryList); List<Tag> tagList = tagService.listTag(); modelAndView.addObject("tagList", tagList); modelAndView.setViewName("Admin/Article/edit"); return modelAndView; } /** * Edit Article Submission * * @param articleParam * @return */ @RequestMapping(value = "/editSubmit", method = RequestMethod.POST) public String editArticleSubmit(ArticleParam articleParam) { Article article = new Article(); article.setArticleId(articleParam.getArticleId()); article.setArticleTitle(articleParam.getArticleTitle()); article.setArticleContent(articleParam.getArticleContent()); article.setArticleStatus(articleParam.getArticleStatus()); //Thesis int summaryLength = 150; String summaryText = HtmlUtil.cleanHtmlTag(article.getArticleContent()); if (summaryText.length() > summaryLength) { String summary = summaryText.substring(0, summaryLength); article.setArticleSummary(summary); } else { article.setArticleSummary(summaryText); } //fill category List<Category> categoryList = new ArrayList<>(); if (articleParam.getArticleChildCategoryId() != null) { categoryList.add(new Category(articleParam.getArticleParentCategoryId())); } if (articleParam.getArticleChildCategoryId() != null) { categoryList.add(new Category(articleParam.getArticleChildCategoryId())); } article.setCategoryList(categoryList); //fill tab List<Tag> tagList = new ArrayList<>(); if (articleParam.getArticleTagIds() != null) { for (int i = 0; i < articleParam.getArticleTagIds().size(); i++) { Tag tag = new Tag(articleParam.getArticleTagIds().get(i)); tagList.add(tag); } } article.setTagList(tagList); articleService.updateArticleDetail(article); return "redirect:/admin/article"; } }
package com.znz.ssm.blog.controller.admin; import com.znz.ssm.blog.entity.Category; import com.znz.ssm.blog.service.ArticleService; import com.znz.ssm.blog.service.CategoryService; import org.springframework.beans.factory.annotation.Autowired; 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.RequestMethod; import org.springframework.web.servlet.ModelAndView; import java.util.List; /** * @author znz */ @Controller @RequestMapping("/admin/category") public class BackCategoryController { @Autowired private ArticleService articleService; @Autowired private CategoryService categoryService; /** * Background classification list display * * @return */ @RequestMapping(value = "") public ModelAndView categoryList() { ModelAndView modelandview = new ModelAndView(); List<Category> categoryList = categoryService.listCategoryWithCount(); modelandview.addObject("categoryList",categoryList); modelandview.setViewName("Admin/Category/index"); return modelandview; } /** * Add category submission in the background * * @param category * @return */ @RequestMapping(value = "/insertSubmit",method = RequestMethod.POST) public String insertCategorySubmit(Category category) { categoryService.insertCategory(category); return "redirect:/admin/category"; } /** * delete category * * @param id * @return */ @RequestMapping(value = "/delete/{id}") public String deleteCategory(@PathVariable("id") Integer id) { //It is forbidden to delete categories with articles int count = articleService.countArticleByCategoryId(id); if (count == 0) { categoryService.deleteCategory(id); } return "redirect:/admin/category"; } /** * Edit category page display * * @param id * @return */ @RequestMapping(value = "/edit/{id}") public ModelAndView editCategoryView(@PathVariable("id") Integer id) { ModelAndView modelAndView = new ModelAndView(); Category category = categoryService.getCategoryById(id); modelAndView.addObject("category",category); List<Category> categoryList = categoryService.listCategoryWithCount(); modelAndView.addObject("categoryList",categoryList); modelAndView.setViewName("Admin/Category/edit"); return modelAndView; } /** * Edit Category Submission * * @param category Classification * @return redirect */ @RequestMapping(value = "/editSubmit",method = RequestMethod.POST) public String editCategorySubmit(Category category) { categoryService.updateCategory(category); return "redirect:/admin/category"; } }
V. Project Summary
Under the impact of the mobile Internet, the traditional way of online communication on the Internet seems to be on the verge of extinction, replaced by the popular instant chat, online video and other tools. Although this method of chatting and communicating through voice and video is simple and convenient, it is more suitable for one-on-one communication between individuals. Although compared with finding a common community group, if you want to conduct continuous discussions on a certain topic, And to express their own opinions independently, the traditional form of community exchange forum is still indispensable.
In the earliest days, the forum community only played the role of announcing some stock market and company instant information, but with the development of the times, now it has reached the level of all-encompassing content, including national events and professional fields. , down to daily life, basic necessities of life, a variety of communication forums are dizzying, and its wide range of applications makes it the core of today's communication community. The development from static to dynamic makes the community forum [4] better realize the communication between users.