Java毕业设计MVC:基于SSM实现计算机硬件评测交流平台

news2025/7/9 9:20:18

作者主页:编程千纸鹤

作者简介:Java、前端、Pythone开发多年,做过高程,项目经理,架构师

主要内容:Java项目开发、毕业设计开发、面试技术整理、最新技术分享

收藏点赞不迷路  关注作者有好处

项目编号:BS-PT-070

一,项目简介

计算机硬件在社会上有很多广泛的发烧友,他们急需一个发布专业硬件测评数据的平台并进行交流互动的社区。本次开发实现的计算机硬件交流平台就是作为一个专业的硬件测评平台为这些发烧爱好者服务的。这对于计算机相关硬件产品的普及和硬件测评数据的分享,都起到了很好的作用。

本平台主要用来发布计算机硬件的评测数据并供广大爱好者交流讨论,计算机的每年有很多的硬件产品出现,这些产品一般会有专门的机构进行相关的测评,也有很多的爱好者关注这些硬件产品的性能,这个开发的平台能够实现硬件评测数据的发布分享,并交由广大爱好者进行在线讨论。

本系统主要分为系统前端和系统后端,前端主要展示一些评测专员发布的计算机硬件评测的数据信息,广大的爱好者可以在线查看并参与讨论,用户也可以通过相应的分类或文章标签进行查看相关的评测文章。并根据评论信息展示最热的评论贴子,同时提供全文检索和在线留言的功能。也可以在线申请网站链接,后台管理员审核后可以添加外链。后台管理员和评测专员登陆后台系统可以发布相关的评测文章,设置相关的类别和标签,管理相关的讨论信息并进行回复,也可以对评测专员信息进行管理操作。管理员同时可以参加相关的业务模块,展示平台信息,添加友情连接等。

二,环境介绍

语言环境:Java:  jdk1.8

数据库:Mysql: mysql5.7

应用服务器:Tomcat:  tomcat8.5.31

开发工具:IDEA或eclipse

后台开发技术:SSM框架

前台开发技术:Jquery,Jquery-UI,BootStrap,Ajax,JSP

三,系统展示

前端首页

文章查看及评论

分类查看硬件评测文章

在线留言

文章归档

评测人员登陆

后台展示

评测文章查看

硬件评测分类管理

标签管理

自定义页面

外链管理

平台公告

评论管理

评测员管理

平台前端菜单管理

四,核心代码展示

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;

    /**
     * 后台首页
     *
     * @return
     */
    @RequestMapping("/admin")
    public String index(Model model)  {
        //文章列表
        List<Article> articleList = articleService.listRecentArticle(5);
        model.addAttribute("articleList",articleList);
        //评论列表
        List<Comment> commentList = commentService.listRecentComment(5);
        model.addAttribute("commentList",commentList);
        return "Admin/index";
    }

    /**
     * 登录页面显示
     *
     * @return
     */
    @RequestMapping("/login")
    public String loginPage() {
        return "Admin/login";
    }

    /**
     * 登录验证
     *
     * @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","用户名无效!");
        } else if(!user.getUserPass().equals(password)) {
            map.put("code",0);
            map.put("msg","密码错误!");
        } else {
            //登录成功
            map.put("code",1);
            map.put("msg","");
            //添加session
            request.getSession().setAttribute("user", user);
            //添加cookie
            if(rememberme!=null) {
                //创建两个Cookie对象
                Cookie nameCookie = new Cookie("username", username);
                //设置Cookie的有效期为3天
                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;
    }

    /**
     * 退出登录
     *
     * @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;

    /**
     * 后台文章列表显示
     *
     * @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";
    }


    /**
     * 后台添加文章页面显示
     *
     * @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";
    }

    /**
     * 后台添加文章提交操作
     *
     * @param articleParam
     * @return
     */
    @RequestMapping(value = "/insertSubmit", method = RequestMethod.POST)
    public String insertArticleSubmit(HttpSession session, ArticleParam articleParam) {
        Article article = new Article();
        //用户ID
        User user = (User) session.getAttribute("user");
        if (user != null) {
            article.setArticleUserId(user.getUserId());
        }
        article.setArticleTitle(articleParam.getArticleTitle());
        //文章摘要
        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());
        //填充分类
        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);
        //填充标签
        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";
    }


    /**
     * 删除文章
     *
     * @param id 文章ID
     */
    @RequestMapping(value = "/delete/{id}")
    public void deleteArticle(@PathVariable("id") Integer id) {
        articleService.deleteArticle(id);
    }


    /**
     * 编辑文章页面显示
     *
     * @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;
    }


    /**
     * 编辑文章提交
     *
     * @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());
        //文章摘要
        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);
        }
        //填充分类
        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);
        //填充标签
        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;

    /**
     * 后台分类列表显示
     *
     * @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;

    }


    /**
     * 后台添加分类提交
     *
     * @param category
     * @return
     */
    @RequestMapping(value = "/insertSubmit",method = RequestMethod.POST)
    public String insertCategorySubmit(Category category)  {
        categoryService.insertCategory(category);
        return "redirect:/admin/category";
    }

    /**
     * 删除分类
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/delete/{id}")
    public String deleteCategory(@PathVariable("id") Integer id)  {
        //禁止删除有文章的分类
        int count = articleService.countArticleByCategoryId(id);

        if (count == 0) {
            categoryService.deleteCategory(id);
        }
        return "redirect:/admin/category";
    }

    /**
     * 编辑分类页面显示
     *
     * @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;
    }

    /**
     * 编辑分类提交
     *
     * @param category 分类
     * @return 重定向
     */
    @RequestMapping(value = "/editSubmit",method = RequestMethod.POST)
    public String editCategorySubmit(Category category)  {
        categoryService.updateCategory(category);
        return "redirect:/admin/category";
    }
}

五,项目总结

目前在移互联网的冲击下,传统的互联网在线沟通的方式似乎已经处于消亡的边缘,替而代之的是现在火爆的即时聊天,在线视频等等工具。而这种通过语音和视频进行聊天沟通的方式虽然简洁方便,但更适合于个体间的一对一交流,虽然相寻找共同的社群群体来讲,如果想就某一主题进行持续性讨论,并自主发表自己的意见,传统的社区交流论坛形式仍然是不可或缺的。

在最早的时候,论坛社区仅是起到公布一些股市以及公司即时信息的作用,但随着时代的发展,现在的它,内容已经达到了无所不含的程度,上到国家大事、专业领域,下到日常生活,衣食住行,各式各样的交流论坛让人目不暇接,其适用范围的广泛使其成为了当今交流社区的核心。由静态到动态的发展让社区论坛[4]更好的实现了用户之间的交流。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/18297.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

(杂)网易云歌单导入到apple music

喜欢apple music的简洁&#xff0c;就想着把网易云的歌单捣鼓进去。 获取歌单歌曲列表&#xff1a;https://yyrcd.com/n2s/ 转移歌单&#xff1a;https://soundiiz.com/zh/&#xff0c;首次使用需要注册&#xff0c;免费版只能一次导入200首。 平台选择apple music 登录授权即可…

Linux下 man命令的使用 及 中文man手册的安装

文章目录1. man命令使用2. 安装中文man手册1. man命令使用 man命令是Linux下最核心的命令之一。而man命令也并不是英文单词“man”的意思&#xff0c;它是单词manual的缩写&#xff0c;即使用手册的意思。man命令会列出一份完整的说明。其内容包括命令语法、各选项的意义及相关…

第三章 线性模型

3.1 基本形式 给定由d个属性描述的示例x(x1; x2; x3; … ; xd)。线性模型试图学得一个通过属性的线性组合来进行预测的函数&#xff0c;即 3.2 线性回归 线性回归试图学得一个线性模型尽可能准确地预测实值输出标记。 对于如何确定w和b&#xff0c;均方误差是回归任务中最常…

这样做时间轴,让你的PPT更出彩!

文章目录**▌方法一&#xff1a;美化时间节点****▌方法二&#xff1a;利用图片中的“轴”****▌方法三&#xff1a;时间轴不一定需要“轴”****▌方法四&#xff1a;把时间轴拆成数页****▌总结**已剪辑自: https://zhuanlan.zhihu.com/p/56672211 嗨&#xff0c;大家好&#…

【Linux】一万七千字详解 —— 基本指令(二)

文章目录前言man 指令cp 指令mv 指令echo 指令(含输出重定向)cat 指令(含输入重定向)wc 指令more 指令less 指令head 和 tail 指令(含管道用法)date 指令cal 指令sort 指令find 和 which 和 whereis 指令alias 指令grep 指令top 指令zip 和 unzip 指令结语前言 今天的主要内容…

C语言源代码系列-管理系统之学生选修课程系统

往期文章分享点击跳转>《导航贴》- Unity手册&#xff0c;系统实战学习点击跳转>《导航贴》- Android手册&#xff0c;重温移动开发 &#x1f449;关于作者 众所周知&#xff0c;人生是一个漫长的流程&#xff0c;不断克服困难&#xff0c;不断反思前进的过程。在这个过…

想归隐啦——与自然生活为伴

目录 一、陶渊明-桃花源记 二、梭罗-瓦尔登湖 结庐在人境&#xff0c;而无车马喧。问君何能尔&#xff1f;心远地自偏。采菊东篱下&#xff0c;悠然见南山 一、陶渊明-桃花源记 晋太元中&#xff0c;武陵人捕鱼为业。缘溪行&#xff0c;忘路之远近。忽逢桃花林&#xff0c;夹…

第五届“传智杯”全国大学生计算机大赛(练习赛)传智杯 #5 练习赛] 平等的交易

[传智杯 #5 练习赛] 平等的交易 题目描述 你有 nnn 件道具可以买&#xff0c;其中第 iii 件的价格为 aia_iai​。 你有 www 元钱。你仅能用钱购买其中的一件商道具。当然&#xff0c;你可以拿你手中的道具换取其他的道具&#xff0c;只是这些商道具的价值之和&#xff0c;不…

Vuecli项目结构,及组件的使用

根目录文件介绍 node_modules &#xff1a;管理项目中使用的依赖 public&#xff1a;存放一些静态资源&#xff0c;webpack打包时会放入dist文件夹内。 src&#xff1a;书写vue源代码【重点】 .gitignore &#xff1a;存放需要被git忽略文件&#xff08;不需要保存&#xff09;…

[附源码]java毕业设计青少年计算机知识学习系统

项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; SSM mybatis Maven Vue 等等组成&#xff0c;B/S模式 M…

ArcGIS制作横向图例

ArcGIS制作横向图例 右键栅格图层&#xff0c;Symbology——Stretched 切换布局视图——View——Layout View&#xff0c;添加经纬网并调整 Insert——Legend&#xff0c;一路默认点下去 双击图例&#xff0c;Items——Style&#xff0c;进一步调整 选择图中标注的这个样式&am…

ES6 Symbol 内置值及使用场景

Symbol 基本使用 ES6 引入了一种新的原始数据类型 Symbol&#xff0c;表示独一无二的值。它是 JavaScript 语言的第七种数据类型&#xff0c;是一种类似于字符串的数据类型。 Symbol 特点 1) Symbol 的值是唯一的&#xff0c;用来解决命名冲突的问题 2) Symbol 值不能与其…

Spring之Bean的实例化

文章目录前言一、通过构造方法实例化二、通过简单工厂模式实例化三、通过factory-bean实例化四、通过FactoryBean接口实例化前言 Spring为Bean提供了多种实例化方法&#xff0c;通常包括四种方式。目的是&#xff1a;更加灵活 第一种&#xff1a;通过构造方法实例化第二种&am…

计算机网络——第五章网络层笔记(4)

距离矢量路由选择协议&#xff08;DV算法&#xff09; 每个路由器维护一张表&#xff0c;表中列出了当前已知的到每个目标的最佳距离&#xff0c;以及为了到达那个目标&#xff0c;应该从哪个接口转发。 DV算法是动态的和分布式的&#xff0c;它常被用于小型网络&#xff0c;…

开发时长一年半golang工程师应该具备什么样的技术能力?

一、为什么会有人选择golang? 其实无非是被动和主动。 **被动&#xff1a;**面试新公司后&#xff0c;被领导调岗现学golang&#xff0c;因为公司需要。 **主动&#xff1a;**觉得这个方向有前景&#xff0c;大厂有需求&#xff0c;学了可以升职加薪&#xff01; 所以不管…

visual studio连接远程开发

一、问题提出 vscode在连接远程调试时不知道如何调试cmake&#xff0c;研究了半天没研究出来&#xff0c;因此决定使用visual studio进行调试。 二、安装 Linux端 cmake版本最低为3.11&#xff0c;可以从此网站下载&#xff1a;https://cmake.org/files/v3.11/ 之前安装的visu…

怎么样恢复移动硬盘格式化的数据呢?

怎么样恢复移动硬盘格式化的数据呢&#xff1f; 这是一个让人很困扰的问题&#xff0c;其实格式化后的数据可以使用牛学长数据恢复工具一键恢复数据&#xff0c;它可以快速识别指定存储介质中所有丢失的文件&#xff0c;操作简单且恢复成功率高。 其工作原理只会提取原有数据&…

安装mayavi

mayavi是一款可视化工具&#xff0c;知乎说直接pip install mayavi不好使&#xff0c;所以我就直接没试&#xff0c;我直接试的好使的。 下面的链接是一个各种依赖包的地址&#xff0c;点开进去之后找mayavi https://link.zhihu.com/?targethttps%3A//www.lfd.uci.edu/~gohlke…

详解Unity中的新版Nav Mesh|导航寻路系统 (一)

前言 之前我们讲解过Unity的Nav Mesh系统&#xff0c;其中提到过这个新版的Nav Mesh&#xff0c;它解决现有Nav Mesh的几个缺陷&#xff0c;比如无法动态烘焙&#xff0c;无法按照Agent的半径和高度适当的判断可行路径。现在新版Nav Mesh可以彻底解决这个问题&#xff01;某种…

Android Studio 插件开发2、网络请求、创建dialog、trello获取cardId等

网络请求 点击这里就出来一个弹框 更新Actions 关注这个 <actions><action id"TrelloAction"class"com.anguomob.anguo.actions.trello.TrelloAction"text"TrelloAction"description"Move a trello card from to do to the next …