当前位置: 首页 > article >正文

计算机毕业设计 校园新闻管理系统的设计与实现 Java实战项目 附源码+文档+视频讲解

博主介绍:✌从事软件开发10年之余,专注于Java技术领域、Python人工智能及数据挖掘、小程序项目开发和Android项目开发等。CSDN、掘金、华为云、InfoQ、阿里云等平台优质作者✌
🍅文末获取源码联系🍅
👇🏻 精彩专栏推荐订阅👇🏻 不然下次找不到哟
————————————————
计算机毕业设计《1000套》✌

Python毕设精品项目✌

微信小程序毕设精品项目✌

大数据及机器学习毕设精品项目✌

目录

1、项目介绍及开发技术

1.1 项目介绍

1.2 开发技术

2、系统功能设计结构图

3、功能截图

3.1 前台功能

3.2 后台功能

4、数据库表结构设计

5、关键代码

5.1 新闻Controller模块 

5.2 新闻Service模块 

5.3 新闻ServiceImpl模块

5.4  新闻Dao模块

6、论文目录结构

7、源码获取


1、项目介绍及开发技术

1.1 项目介绍

在信息爆炸的时代,校园新闻管理系统成为了连接学校与学生、教职工之间信息传递的重要桥梁。它不仅承载着传递校园新闻、通知公告的功能,也是校园文化和学术交流的重要平台。随着互联网技术的不断发展,传统的校园新闻传播方式已经无法满足现代校园对信息传播速度和广度的要求。因此,我们设计并开发了一个校园新闻管理系统,旨在通过数字化手段提升校园新闻的传播效率和互动性。

背景:
校园内的信息传播需要一个集中的平台来发布和管理新闻、公告和学术动态。传统的校园新闻多通过纸质媒体或校园广播进行传播,这些方式在时效性和互动性上存在局限。随着学生和教职工对信息获取方式的多样化需求,建立一个集成化的数字平台变得尤为重要。

目的意义:

  • 1. 提升信息传播效率:系统通过在线发布新闻和公告,确保信息能够迅速传达给每一位校园成员。
  • 2. 增强信息互动性:论坛交流平台允许用户就新闻内容进行讨论和交流,增强了信息的互动性和参与度。
  • 3. 方便信息管理:系统为管理员提供了新闻、公告和论坛帖子的管理功能,使得信息更新和维护更加便捷。
  • 4. 促进学术交流:新闻系统不仅传递新闻,还可以发布学术讲座和研究成果,促进校园内的学术交流。
  • 5. 个性化信息服务:用户可以通过个人中心收藏新闻,系统可以根据用户的阅读习惯推荐相关新闻,提供个性化的信息服务。

综上所述,校园新闻管理系统的设计与实现,不仅能够为校园提供一个快速、便捷的新闻传播渠道,还能够通过论坛交流和个性化服务,增强校园成员之间的信息互动和学术探讨。通过技术手段优化校园新闻传播流程,该系统有望成为校园信息传播和文化交流的重要工具,为构建数字化校园环境做出贡献。
 

1.2 开发技术

类别技术名称用途/描述
开发语言Java一种广泛使用的面向对象编程语言。
框架Spring Boot简化Spring应用的初始搭建以及开发过程。
ORM工具MyBatis PlusMyBatis的增强工具,简化CRUD操作。
数据库MySQL流行的关系型数据库管理系统。
构建工具Maven项目管理和理解工具。
开发工具IDEA集成开发环境,用于代码编写和调试。
JDK版本JDK 1.8+Java开发工具包,提供运行Java程序所需的环境。
前端框架Vue用于构建用户界面的渐进式JavaScript框架。
UI框架Element UI基于Vue的桌面端组件库。
前端技术HTML网页内容的标准标记语言。
前端技术CSS描述HTML文档的样式。
前端技术JS网页脚本语言,用于实现网页的动态效果。

2、系统功能设计结构图

功能模块结构图

├── 前端
│   ├── 登录
│   ├── 注册
│   ├── 论坛交流
│   ├── 公告信息
│   ├── 新闻信息
│   └── 个人中心
│       ├── 个人信息
│       └── 新闻收藏

└── 后端
    ├── 登录
    ├── 首页
    ├── 个人中心
    ├── 管理员管理
    ├── 基础数据管理
    │   ├── 帖子类型管理
    │   ├── 公告类型管理
    │   └── 新闻类型管理
    ├── 论坛交流管理
    ├── 公告信息管理
    ├── 新闻管理
    ├── 用户管理
    └── 轮播图管理

系统MVC框架,请求流程展示:

3、功能截图

3.1 前台功能

3.2 后台功能

4、数据库表结构设计

/*Table structure for table `config` */

DROP TABLE IF EXISTS `config`;

CREATE TABLE `config` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `name` varchar(100) NOT NULL COMMENT '配置参数名称',
  `value` varchar(100) DEFAULT NULL COMMENT '配置参数值',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='配置文件';


/*Table structure for table `forum` */

DROP TABLE IF EXISTS `forum`;

CREATE TABLE `forum` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `forum_name` varchar(200) DEFAULT NULL COMMENT '帖子标题  Search111 ',
  `yonghu_id` int(11) DEFAULT NULL COMMENT '用户',
  `users_id` int(11) DEFAULT NULL COMMENT '管理员',
  `forum_content` longtext COMMENT '发布内容',
  `super_ids` int(11) DEFAULT NULL COMMENT '父id',
  `forum_types` int(11) DEFAULT NULL COMMENT '帖子类型  Search111 ',
  `forum_state_types` int(11) DEFAULT NULL COMMENT '帖子状态',
  `insert_time` timestamp NULL DEFAULT NULL COMMENT '发帖时间',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '修改时间',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show2',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 COMMENT='论坛交流';

/*Data for the table `forum` */


DROP TABLE IF EXISTS `news`;

CREATE TABLE `news` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键 ',
  `news_name` varchar(200) DEFAULT NULL COMMENT '新闻名称  Search111 ',
  `news_uuid_number` varchar(200) DEFAULT NULL COMMENT '新闻编号',
  `news_photo` varchar(200) DEFAULT NULL COMMENT '新闻照片',
  `news_file` varchar(200) DEFAULT NULL COMMENT '附件',
  `news_video` varchar(200) DEFAULT NULL COMMENT '视频',
  `zan_number` int(11) DEFAULT NULL COMMENT '赞',
  `cai_number` int(11) DEFAULT NULL COMMENT '踩',
  `news_types` int(11) DEFAULT NULL COMMENT '新闻类型 Search111',
  `news_erji_types` int(11) DEFAULT NULL COMMENT '二级类型 Search111',
  `news_clicknum` int(11) DEFAULT NULL COMMENT '新闻热度',
  `news_content` longtext COMMENT '新闻内容 ',
  `shangxia_types` int(11) DEFAULT NULL COMMENT '是否上架 ',
  `insert_time` timestamp NULL DEFAULT NULL COMMENT '录入时间',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间  show1 show2 photoShow',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT='新闻';


DROP TABLE IF EXISTS `news_collection`;

CREATE TABLE `news_collection` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `news_id` int(11) DEFAULT NULL COMMENT '新闻',
  `yonghu_id` int(11) DEFAULT NULL COMMENT '用户',
  `news_collection_types` int(11) DEFAULT NULL COMMENT '类型',
  `insert_time` timestamp NULL DEFAULT NULL COMMENT '收藏时间',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show3 photoShow',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8 COMMENT='新闻收藏';



DROP TABLE IF EXISTS `token`;

CREATE TABLE `token` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `userid` bigint(20) NOT NULL COMMENT '员工id',
  `username` varchar(100) NOT NULL COMMENT '员工名',
  `tablename` varchar(100) DEFAULT NULL COMMENT '表名',
  `role` varchar(100) DEFAULT NULL COMMENT '角色',
  `token` varchar(200) NOT NULL COMMENT '密码',
  `addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '新增时间',
  `expiratedtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '过期时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='token表';


DROP TABLE IF EXISTS `users`;

CREATE TABLE `users` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `username` varchar(100) NOT NULL COMMENT '员工名',
  `password` varchar(100) NOT NULL COMMENT '密码',
  `role` varchar(100) DEFAULT '管理员' COMMENT '角色',
  `addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '新增时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='管理员';

/*Data for the table `users` */



CREATE TABLE `yonghu` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `username` varchar(200) DEFAULT NULL COMMENT '账户',
  `password` varchar(200) DEFAULT NULL COMMENT '密码',
  `yonghu_uuid_number` varchar(200) DEFAULT NULL COMMENT '用户编号 Search111 ',
  `yonghu_name` varchar(200) DEFAULT NULL COMMENT '用户姓名 Search111 ',
  `yonghu_phone` varchar(200) DEFAULT NULL COMMENT '用户手机号',
  `yonghu_id_number` varchar(200) DEFAULT NULL COMMENT '用户身份证号',
  `yonghu_photo` varchar(200) DEFAULT NULL COMMENT '用户头像',
  `sex_types` int(11) DEFAULT NULL COMMENT '性别',
  `yonghu_email` varchar(200) DEFAULT NULL COMMENT '用户邮箱',
  `jinyong_types` int(11) DEFAULT NULL COMMENT '账户状态 Search111 ',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COMMENT='用户';

5、关键代码

5.1 新闻Controller模块 



package com.controller;

import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;

import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;

/**
 * 新闻
 * 后端接口
 * @author
 * @email
*/
@RestController
@Controller
@RequestMapping("/news")
public class NewsController {
    private static final Logger logger = LoggerFactory.getLogger(NewsController.class);

    private static final String TABLE_NAME = "news";

    @Autowired
    private NewsService newsService;


    @Autowired
    private TokenService tokenService;

    @Autowired
    private DictionaryService dictionaryService;//字典
    @Autowired
    private ForumService forumService;//论坛交流
    @Autowired
    private GonggaoService gonggaoService;//公告信息
    @Autowired
    private NewsCollectionService newsCollectionService;//新闻收藏
    @Autowired
    private NewsLiuyanService newsLiuyanService;//新闻留言
    @Autowired
    private YonghuService yonghuService;//用户
    @Autowired
    private UsersService usersService;//管理员


    /**
    * 后端列表
    */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永不会进入");
        else if("用户".equals(role))
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        CommonUtil.checkMap(params);
        PageUtils page = newsService.queryPage(params);

        //字典表数据转换
        List<NewsView> list =(List<NewsView>)page.getList();
        for(NewsView c:list){
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(c, request);
        }
        return R.ok().put("data", page);
    }

    /**
    * 后端详情
    */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        NewsEntity news = newsService.selectById(id);
        if(news !=null){
            //entity转view
            NewsView view = new NewsView();
            BeanUtils.copyProperties( news , view );//把实体数据重构到view中
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody NewsEntity news, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,news:{}",this.getClass().getName(),news.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永远不会进入");

        Wrapper<NewsEntity> queryWrapper = new EntityWrapper<NewsEntity>()
            .eq("news_name", news.getNewsName())
            .eq("news_video", news.getNewsVideo())
            .eq("zan_number", news.getZanNumber())
            .eq("cai_number", news.getCaiNumber())
            .eq("news_types", news.getNewsTypes())
            .eq("news_erji_types", news.getNewsErjiTypes())
            .eq("shangxia_types", news.getShangxiaTypes())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        NewsEntity newsEntity = newsService.selectOne(queryWrapper);
        if(newsEntity==null){
            news.setZanNumber(1);
            news.setCaiNumber(1);
            news.setNewsClicknum(1);
            news.setShangxiaTypes(1);
            news.setInsertTime(new Date());
            news.setCreateTime(new Date());
            newsService.insert(news);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody NewsEntity news, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        logger.debug("update方法:,,Controller:{},,news:{}",this.getClass().getName(),news.toString());
        NewsEntity oldNewsEntity = newsService.selectById(news.getId());//查询原先数据

        String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");
        if("".equals(news.getNewsPhoto()) || "null".equals(news.getNewsPhoto())){
                news.setNewsPhoto(null);
        }
        if("".equals(news.getNewsFile()) || "null".equals(news.getNewsFile())){
                news.setNewsFile(null);
        }
        if("".equals(news.getNewsVideo()) || "null".equals(news.getNewsVideo())){
                news.setNewsVideo(null);
        }
        if("".equals(news.getNewsContent()) || "null".equals(news.getNewsContent())){
                news.setNewsContent(null);
        }

            newsService.updateById(news);//根据id更新
            return R.ok();
    }



    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
        List<NewsEntity> oldNewsList =newsService.selectBatchIds(Arrays.asList(ids));//要删除的数据
        newsService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }


    /**
     * 批量上传
     */
    @RequestMapping("/batchInsert")
    public R save( String fileName, HttpServletRequest request){
        logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
        Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
        try {
            List<NewsEntity> newsList = new ArrayList<>();//上传的东西
            Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
            Date date = new Date();
            int lastIndexOf = fileName.lastIndexOf(".");
            if(lastIndexOf == -1){
                return R.error(511,"该文件没有后缀");
            }else{
                String suffix = fileName.substring(lastIndexOf);
                if(!".xls".equals(suffix)){
                    return R.error(511,"只支持后缀为xls的excel文件");
                }else{
                    URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
                    File file = new File(resource.getFile());
                    if(!file.exists()){
                        return R.error(511,"找不到上传文件,请联系管理员");
                    }else{
                        List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
                        dataList.remove(0);//删除第一行,因为第一行是提示
                        for(List<String> data:dataList){
                            //循环
                            NewsEntity newsEntity = new NewsEntity();
//                            newsEntity.setNewsName(data.get(0));                    //新闻名称 要改的
//                            newsEntity.setNewsUuidNumber(data.get(0));                    //新闻编号 要改的
//                            newsEntity.setNewsPhoto("");//详情和图片
//                            newsEntity.setNewsFile(data.get(0));                    //附件 要改的
//                            newsEntity.setNewsVideo(data.get(0));                    //视频 要改的
//                            newsEntity.setZanNumber(Integer.valueOf(data.get(0)));   //赞 要改的
//                            newsEntity.setCaiNumber(Integer.valueOf(data.get(0)));   //踩 要改的
//                            newsEntity.setNewsTypes(Integer.valueOf(data.get(0)));   //新闻类型 要改的
//                            newsEntity.setNewsErjiTypes(Integer.valueOf(data.get(0)));   //二级类型 要改的
//                            newsEntity.setNewsClicknum(Integer.valueOf(data.get(0)));   //新闻热度 要改的
//                            newsEntity.setNewsContent("");//详情和图片
//                            newsEntity.setShangxiaTypes(Integer.valueOf(data.get(0)));   //是否上架 要改的
//                            newsEntity.setInsertTime(date);//时间
//                            newsEntity.setCreateTime(date);//时间
                            newsList.add(newsEntity);


                            //把要查询是否重复的字段放入map中
                                //新闻编号
                                if(seachFields.containsKey("newsUuidNumber")){
                                    List<String> newsUuidNumber = seachFields.get("newsUuidNumber");
                                    newsUuidNumber.add(data.get(0));//要改的
                                }else{
                                    List<String> newsUuidNumber = new ArrayList<>();
                                    newsUuidNumber.add(data.get(0));//要改的
                                    seachFields.put("newsUuidNumber",newsUuidNumber);
                                }
                        }

                        //查询是否重复
                         //新闻编号
                        List<NewsEntity> newsEntities_newsUuidNumber = newsService.selectList(new EntityWrapper<NewsEntity>().in("news_uuid_number", seachFields.get("newsUuidNumber")));
                        if(newsEntities_newsUuidNumber.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(NewsEntity s:newsEntities_newsUuidNumber){
                                repeatFields.add(s.getNewsUuidNumber());
                            }
                            return R.error(511,"数据库的该表中的 [新闻编号] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                        newsService.insertBatch(newsList);
                        return R.ok();
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            return R.error(511,"批量插入数据异常,请联系管理员");
        }
    }



    /**
    * 个性推荐
    */
    @IgnoreAuth
    @RequestMapping("/gexingtuijian")
    public R gexingtuijian(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("gexingtuijian方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
        CommonUtil.checkMap(params);
        List<NewsView> returnNewsViewList = new ArrayList<>();

        //查看收藏
        Map<String, Object> params1 = new HashMap<>(params);params1.put("sort","id");params1.put("yonghuId",request.getSession().getAttribute("userId"));
        params1.put("shangxiaTypes",1);
        params1.put("newsYesnoTypes",2);
        PageUtils pageUtils = newsCollectionService.queryPage(params1);
        List<NewsCollectionView> collectionViewsList =(List<NewsCollectionView>)pageUtils.getList();
        Map<Integer,Integer> typeMap=new HashMap<>();//购买的类型list
        for(NewsCollectionView collectionView:collectionViewsList){
            Integer newsTypes = collectionView.getNewsTypes();
            if(typeMap.containsKey(newsTypes)){
                typeMap.put(newsTypes,typeMap.get(newsTypes)+1);
            }else{
                typeMap.put(newsTypes,1);
            }
        }
        List<Integer> typeList = new ArrayList<>();//排序后的有序的类型 按最多到最少
        typeMap.entrySet().stream().sorted((o1, o2) -> o2.getValue() - o1.getValue()).forEach(e -> typeList.add(e.getKey()));//排序
        Integer limit = Integer.valueOf(String.valueOf(params.get("limit")));
        for(Integer type:typeList){
            Map<String, Object> params2 = new HashMap<>(params);params2.put("newsTypes",type);
            params2.put("shangxiaTypes",1);
            params2.put("newsYesnoTypes",2);
            PageUtils pageUtils1 = newsService.queryPage(params2);
            List<NewsView> newsViewList =(List<NewsView>)pageUtils1.getList();
            returnNewsViewList.addAll(newsViewList);
            if(returnNewsViewList.size()>= limit) break;//返回的推荐数量大于要的数量 跳出循环
        }
        params.put("shangxiaTypes",1);
        params.put("newsYesnoTypes",2);
        //正常查询出来商品,用于补全推荐缺少的数据
        PageUtils page = newsService.queryPage(params);
        if(returnNewsViewList.size()<limit){//返回数量还是小于要求数量
            int toAddNum = limit - returnNewsViewList.size();//要添加的数量
            List<NewsView> newsViewList =(List<NewsView>)page.getList();
            for(NewsView newsView:newsViewList){
                Boolean addFlag = true;
                for(NewsView returnNewsView:returnNewsViewList){
                    if(returnNewsView.getId().intValue() ==newsView.getId().intValue()) addFlag=false;//返回的数据中已存在此商品
                }
                if(addFlag){
                    toAddNum=toAddNum-1;
                    returnNewsViewList.add(newsView);
                    if(toAddNum==0) break;//够数量了
                }
            }
        }else {
            returnNewsViewList = returnNewsViewList.subList(0, limit);
        }

        for(NewsView c:returnNewsViewList)
            dictionaryService.dictionaryConvert(c, request);
        page.setList(returnNewsViewList);
        return R.ok().put("data", page);
    }

    /**
    * 前端列表
    */
    @IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));

        CommonUtil.checkMap(params);
        PageUtils page = newsService.queryPage(params);

        //字典表数据转换
        List<NewsView> list =(List<NewsView>)page.getList();
        for(NewsView c:list)
            dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段

        return R.ok().put("data", page);
    }

    /**
    * 前端详情
    */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
        logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        NewsEntity news = newsService.selectById(id);
            if(news !=null){

                //点击数量加1
                news.setNewsClicknum(news.getNewsClicknum()+1);
                newsService.updateById(news);

                //entity转view
                NewsView view = new NewsView();
                BeanUtils.copyProperties( news , view );//把实体数据重构到view中

                //修改对应字典表字段
                dictionaryService.dictionaryConvert(view, request);
                return R.ok().put("data", view);
            }else {
                return R.error(511,"查不到数据");
            }
    }


    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody NewsEntity news, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,news:{}",this.getClass().getName(),news.toString());
        Wrapper<NewsEntity> queryWrapper = new EntityWrapper<NewsEntity>()
            .eq("news_name", news.getNewsName())
            .eq("news_uuid_number", news.getNewsUuidNumber())
            .eq("news_video", news.getNewsVideo())
            .eq("zan_number", news.getZanNumber())
            .eq("cai_number", news.getCaiNumber())
            .eq("news_types", news.getNewsTypes())
            .eq("news_erji_types", news.getNewsErjiTypes())
            .eq("news_clicknum", news.getNewsClicknum())
            .eq("shangxia_types", news.getShangxiaTypes())
//            .notIn("news_types", new Integer[]{102})
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        NewsEntity newsEntity = newsService.selectOne(queryWrapper);
        if(newsEntity==null){
                news.setZanNumber(1);
                news.setCaiNumber(1);
            news.setNewsClicknum(1);
            news.setInsertTime(new Date());
            news.setCreateTime(new Date());
        newsService.insert(news);

            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

}

5.2 新闻Service模块 

 package com.service;

import com.baomidou.mybatisplus.service.IService;
import com.utils.PageUtils;
import com.entity.NewsEntity;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
import java.util.List;

/**
 * 新闻 服务类
 */
public interface NewsService extends IService<NewsEntity> {

    /**
    * @param params 查询参数
    * @return 带分页的查询出来的数据
    */
     PageUtils queryPage(Map<String, Object> params);

}

5.3 新闻ServiceImpl模块


package com.service.impl;

import com.utils.StringUtil;
import com.service.DictionaryService;
import com.utils.ClazzDiff;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.util.*;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import com.utils.PageUtils;
import com.utils.Query;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import com.dao.NewsDao;
import com.entity.NewsEntity;
import com.service.NewsService;
import com.entity.view.NewsView;

/**
 * 新闻 服务实现类
 */
@Service("newsService")
@Transactional
public class NewsServiceImpl extends ServiceImpl<NewsDao, NewsEntity> implements NewsService {

    @Override
    public PageUtils queryPage(Map<String,Object> params) {
        Page<NewsView> page =new Query<NewsView>(params).getPage();
        page.setRecords(baseMapper.selectListView(page,params));
        return new PageUtils(page);
    }


}

5.4  新闻Dao模块


package com.dao;

import com.entity.NewsEntity;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;

import org.apache.ibatis.annotations.Param;
import com.entity.view.NewsView;

/**
 * 新闻 Dao 接口
 *
 * @author 
 */
public interface NewsDao extends BaseMapper<NewsEntity> {

   List<NewsView> selectListView(Pagination page,@Param("params")Map<String,Object> params);

}

6、论文目录结构

摘要... I

Abstract... II

1 绪论... 1
   1.1 项目简介... 1
   1.2 调查研究... 1
       1.2.1 研究背景及意义... 1
       1.2.2 国内外研究现状... 2
       1.2.3 研究主要内容... 2
   1.3 论文的章节安排... 3

2 系统相关技术介绍... 4
   2.1 Java语言... 4
   2.2 SpringBoot框架... 4
   2.3 Vue框架... 4
   2.4 MySQL数据库... 4

3 系统需求分析... 6
   3.1 可行性分析... 6
       3.1.1 技术可行性... 6
       3.1.2 经济可行性... 6
       3.1.3 操作可行性... 6
   3.2 系统功能需求... 6
       3.2.1 用户端功能需求... 6
       3.2.2 XX端功能需求... 6
       3.2.3 管理员端功能需求... 6
   3.3 系统性能需求... 6

4 系统总体设计... 7
   4.1 系统总体架构设计... 7
   4.2 系统的功能设计... 7
   4.3 数据库设计... 7
       4.3.1 概念设计E-R图... 7
       4.3.2 逻辑设计关系模式... 7
       4.3.3 数据库物理设计... 7

5 系统详细实现... 14
   5.1 系统实现环境... 14
   5.2 用户端... 14
       5.2.1 登录页面... 14
       5.2.2 注册页面... 14
       5.2.3 XXXX页面... 14
       5.2.4 XXXX页面... 14
       5.2.5 XXXX页面... 14
   5.3 XXXX端... 15
       5.3.1 XXXX页面... 15
       5.3.2 XXXX页面... 15
       5.3.3 XXXX页面... 15
       5.3.4 XXXX页面... 15
   5.4 管理端... 15
       5.4.1 用户管理页面... 15
       5.4.2 XXXX页面... 15
       5.4.3 XXXX页面... 16
       5.4.4 XXXX页面... 16

6 系统测试... 16
   6.1 测试目的... 16
   6.2 测试方法... 16
   6.3 测试用例... 16
       6.3.1 XXXX测试... 16
       6.3.2 XXXX测试... 16
   6.4 测试结果... 16

结论... 17

参考文献... 18

致谢... 19

更多源码:

计算机毕业设计选题1000套等你来!!!

Python毕设精品项目

微信小程序毕设精品项目  

大数据及机器学习毕设精品项目 

7、源码获取

感谢大家的阅读,如有不懂的问题可以评论区交流或私聊!

喜欢文章可以点赞、收藏、关注、评论

下方联系方式获取源码


http://www.kler.cn/news/319366.html

相关文章:

  • 详细介绍swoole以及其优缺点
  • Spring Boot实战:使用@Import进行业务模块自动化装配
  • 正向科技格雷母线内胆,适应任何糟糕工业环境
  • 828华为云征文 | 使用Flexus X实例搭建Dubbo-Admin服务
  • Elasticsearch 单机和集群环境部署教程
  • QT创建线程,QT多线程的创建和使用,QT线程池
  • 【华为】用策略路由解决双出口运营商问题
  • Git 工作区、暂存区与修改全解析
  • 网络安全证书考取相关知识
  • 【Linux】环境部署kafka集群
  • 工业一体机在汽车零部件工厂ESOP系统中的关键作用
  • 【记录】在返回值类型为BigDecimal情况下末尾小数位为0的会省略不显示
  • linux如何启用ipv6随机地址
  • QT 中的信号与槽机制详解
  • 2:java的介绍与基础2:Scanner
  • 【BurpSuite】Cross-site scripting (XSS 学徒部分:1-9)
  • JVM面试问题集
  • 航班延误背后隐秘原因--网络安全
  • 41. 如何在MyBatis-Plus中实现批量操作?批量插入和更新的最佳实践是什么?
  • MELON的难题- 华为OD统一考试(E卷)
  • 【Unity服务】如何使用Unity Version Control
  • transformer模型写诗词
  • 【大模型教程】如何在Spring Boot中无缝集成LangChain4j,玩转AI大模型!
  • day-60 字符串中最多数目的子序列
  • 整合SpringSecurity框架经典报错
  • 大数据实验一: Linux系统安装和使用
  • 看Threejs好玩示例,学习创新与技术(GridDistortionEffect)
  • [Redis][List]详细讲解
  • 秋分之际,又搭建了一款微信记账本小程序
  • 大模型智能体在金融公告理解领域的应用 | OPENAIGC开发者大赛高校组AI创新之星奖