您的当前位置:首页正文

springboot新闻推荐系统源码和论文

2024-11-28 来源:个人技术集锦

基于springboot+vue的新闻推荐系统

摘要

随着信息互联网购物的飞速发展,国内放开了自媒体的政策,一般企业都开始开发属于自己内容分发平台的网站。本文介绍了新闻推荐系统的开发全过程。通过分析企业对于新闻推荐系统的需求,创建了一个计算机管理新闻推荐系统的方案。文章介绍了新闻推荐系统的系统分析部分,包括可行性分析等,系统设计部分主要介绍了系统功能设计和数据库设计。

本新闻推荐系统有管理员和用户两个角色。管理员功能有个人中心,用户管理,排行榜管理,新闻管理,我的收藏管理,系统管理等。用户功能可以在首页查看新闻排行榜,新闻信息,并可以注册登录,收藏新闻,对新闻评论。用户注册登录,评论新闻,收藏新闻,查看新闻,搜索新闻。因而具有一定的实用性。

本站是一个B/S模式系统,采用Spring Boot框架作为开发技术,MYSQL数据库设计开发,充分保证系统的稳定性。系统具有界面清晰、操作简单,功能齐全的特点,使得新闻推荐系统管理工作系统化、规范化。

关键词:新闻推荐系统;Spring Boot框架;MYSQL数据库

springboot新闻推荐系统源码和论文045

演示视频:

springboot新闻推荐系统源码和论文

Abstract

With the rapid development of information Internet shopping, China has liberalized the self-media policy, and most companies have begun to develop websites that belong to their own content distribution platforms. This article introduces the whole process of the development of news recommendation system. By analyzing the enterprise's demand for news recommendation system, a program of computer management news recommendation system was created. The article introduces the system analysis part of the news recommendation system, including feasibility analysis, etc. The system design part mainly introduces the system function design and database design.

This news recommendation system has two roles: administrator and user. Administrator functions include personal center, user management, ranking management, news management, my collection management, system management, etc. The user function can view news rankings and news information on the home page, and can register and log in, collect news, and comment on news. User registration and login, comment news, bookmark news, view news, search news. So it has a certain practicability.

This site is a B/S model system, using Spring Boot framework as the development technology, MYSQL database design and development, fully guarantee the stability of the system. The system has the characteristics of clear interface, simple operation and complete functions, which makes the management of the news recommendation system systematized and standardized.

Keywords:News recommendation system; Spring Boot framework; MYSQL database

 

package com.controller;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;

import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;

import com.entity.PaixingbangEntity;
import com.entity.view.PaixingbangView;

import com.service.PaixingbangService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;


/**
 * 排行榜
 * 后端接口
 * @author 
 * @email 
 * @date 2023-04-10 13:56:20
 */
@RestController
@RequestMapping("/paixingbang")
public class PaixingbangController {
    @Autowired
    private PaixingbangService paixingbangService;
    


    /**
     * 后端列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,PaixingbangEntity paixingbang,
		HttpServletRequest request){
        EntityWrapper<PaixingbangEntity> ew = new EntityWrapper<PaixingbangEntity>();
		PageUtils page = paixingbangService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, paixingbang), params), params));

        return R.ok().put("data", page);
    }
    
    /**
     * 前端列表
     */
	@IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params,PaixingbangEntity paixingbang, HttpServletRequest request){
        EntityWrapper<PaixingbangEntity> ew = new EntityWrapper<PaixingbangEntity>();
		PageUtils page = paixingbangService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, paixingbang), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/lists")
    public R list( PaixingbangEntity paixingbang){
       	EntityWrapper<PaixingbangEntity> ew = new EntityWrapper<PaixingbangEntity>();
      	ew.allEq(MPUtil.allEQMapPre( paixingbang, "paixingbang")); 
        return R.ok().put("data", paixingbangService.selectListView(ew));
    }

	 /**
     * 查询
     */
    @RequestMapping("/query")
    public R query(PaixingbangEntity paixingbang){
        EntityWrapper< PaixingbangEntity> ew = new EntityWrapper< PaixingbangEntity>();
 		ew.allEq(MPUtil.allEQMapPre( paixingbang, "paixingbang")); 
		PaixingbangView paixingbangView =  paixingbangService.selectView(ew);
		return R.ok("查询排行榜成功").put("data", paixingbangView);
    }
	
    /**
     * 后端详情
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        PaixingbangEntity paixingbang = paixingbangService.selectById(id);
		paixingbang.setClicknum(paixingbang.getClicknum()+1);
		paixingbang.setClicktime(new Date());
		paixingbangService.updateById(paixingbang);
        return R.ok().put("data", paixingbang);
    }

    /**
     * 前端详情
     */
	@IgnoreAuth
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id){
        PaixingbangEntity paixingbang = paixingbangService.selectById(id);
		paixingbang.setClicknum(paixingbang.getClicknum()+1);
		paixingbang.setClicktime(new Date());
		paixingbangService.updateById(paixingbang);
        return R.ok().put("data", paixingbang);
    }
    


    /**
     * 赞或踩
     */
    @RequestMapping("/thumbsup/{id}")
    public R vote(@PathVariable("id") String id,String type){
        PaixingbangEntity paixingbang = paixingbangService.selectById(id);
        if(type.equals("1")) {
        	paixingbang.setThumbsupnum(paixingbang.getThumbsupnum()+1);
        } else {
        	paixingbang.setCrazilynum(paixingbang.getCrazilynum()+1);
        }
        paixingbangService.updateById(paixingbang);
        return R.ok("投票成功");
    }

    /**
     * 后端保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody PaixingbangEntity paixingbang, HttpServletRequest request){
    	paixingbang.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(paixingbang);
        paixingbangService.insert(paixingbang);
        return R.ok();
    }
    
    /**
     * 前端保存
     */
    @RequestMapping("/add")
    public R add(@RequestBody PaixingbangEntity paixingbang, HttpServletRequest request){
    	paixingbang.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(paixingbang);
        paixingbangService.insert(paixingbang);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody PaixingbangEntity paixingbang, HttpServletRequest request){
        //ValidatorUtils.validateEntity(paixingbang);
        paixingbangService.updateById(paixingbang);//全部更新
        return R.ok();
    }
    

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        paixingbangService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
    
    /**
     * 提醒接口
     */
	@RequestMapping("/remind/{columnName}/{type}")
	public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, 
						 @PathVariable("type") String type,@RequestParam Map<String, Object> map) {
		map.put("column", columnName);
		map.put("type", type);
		
		if(type.equals("2")) {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			Calendar c = Calendar.getInstance();
			Date remindStartDate = null;
			Date remindEndDate = null;
			if(map.get("remindstart")!=null) {
				Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
				c.setTime(new Date()); 
				c.add(Calendar.DAY_OF_MONTH,remindStart);
				remindStartDate = c.getTime();
				map.put("remindstart", sdf.format(remindStartDate));
			}
			if(map.get("remindend")!=null) {
				Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
				c.setTime(new Date());
				c.add(Calendar.DAY_OF_MONTH,remindEnd);
				remindEndDate = c.getTime();
				map.put("remindend", sdf.format(remindEndDate));
			}
		}
		
		Wrapper<PaixingbangEntity> wrapper = new EntityWrapper<PaixingbangEntity>();
		if(map.get("remindstart")!=null) {
			wrapper.ge(columnName, map.get("remindstart"));
		}
		if(map.get("remindend")!=null) {
			wrapper.le(columnName, map.get("remindend"));
		}


		int count = paixingbangService.selectCount(wrapper);
		return R.ok().put("count", count);
	}
	
	/**
     * 前端智能排序
     */
	@IgnoreAuth
    @RequestMapping("/autoSort")
    public R autoSort(@RequestParam Map<String, Object> params,PaixingbangEntity paixingbang, HttpServletRequest request,String pre){
        EntityWrapper<PaixingbangEntity> ew = new EntityWrapper<PaixingbangEntity>();
        Map<String, Object> newMap = new HashMap<String, Object>();
        Map<String, Object> param = new HashMap<String, Object>();
		Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();
		while (it.hasNext()) {
			Map.Entry<String, Object> entry = it.next();
			String key = entry.getKey();
			String newKey = entry.getKey();
			if (pre.endsWith(".")) {
				newMap.put(pre + newKey, entry.getValue());
			} else if (StringUtils.isEmpty(pre)) {
				newMap.put(newKey, entry.getValue());
			} else {
				newMap.put(pre + "." + newKey, entry.getValue());
			}
		}
		params.put("sort", "clicknum");
        params.put("order", "desc");
		PageUtils page = paixingbangService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, paixingbang), params), params));
        return R.ok().put("data", page);
    }


}

 

package com.controller;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;

import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;

import com.entity.XinwenEntity;
import com.entity.view.XinwenView;

import com.service.XinwenService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;


/**
 * 新闻
 * 后端接口
 * @author 
 * @email 
 * @date 2021-04-10 13:56:20
 */
@RestController
@RequestMapping("/xinwen")
public class XinwenController {
    @Autowired
    private XinwenService xinwenService;
    


    /**
     * 后端列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,XinwenEntity xinwen,
		HttpServletRequest request){
        EntityWrapper<XinwenEntity> ew = new EntityWrapper<XinwenEntity>();
		PageUtils page = xinwenService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xinwen), params), params));

        return R.ok().put("data", page);
    }
    
    /**
     * 前端列表
     */
	@IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params,XinwenEntity xinwen, HttpServletRequest request){
        EntityWrapper<XinwenEntity> ew = new EntityWrapper<XinwenEntity>();
		PageUtils page = xinwenService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xinwen), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/lists")
    public R list( XinwenEntity xinwen){
       	EntityWrapper<XinwenEntity> ew = new EntityWrapper<XinwenEntity>();
      	ew.allEq(MPUtil.allEQMapPre( xinwen, "xinwen")); 
        return R.ok().put("data", xinwenService.selectListView(ew));
    }

	 /**
     * 查询
     */
    @RequestMapping("/query")
    public R query(XinwenEntity xinwen){
        EntityWrapper< XinwenEntity> ew = new EntityWrapper< XinwenEntity>();
 		ew.allEq(MPUtil.allEQMapPre( xinwen, "xinwen")); 
		XinwenView xinwenView =  xinwenService.selectView(ew);
		return R.ok("查询新闻成功").put("data", xinwenView);
    }
	
    /**
     * 后端详情
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        XinwenEntity xinwen = xinwenService.selectById(id);
		xinwen.setClicknum(xinwen.getClicknum()+1);
		xinwen.setClicktime(new Date());
		xinwenService.updateById(xinwen);
        return R.ok().put("data", xinwen);
    }

    /**
     * 前端详情
     */
	@IgnoreAuth
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id){
        XinwenEntity xinwen = xinwenService.selectById(id);
		xinwen.setClicknum(xinwen.getClicknum()+1);
		xinwen.setClicktime(new Date());
		xinwenService.updateById(xinwen);
        return R.ok().put("data", xinwen);
    }
    


    /**
     * 赞或踩
     */
    @RequestMapping("/thumbsup/{id}")
    public R vote(@PathVariable("id") String id,String type){
        XinwenEntity xinwen = xinwenService.selectById(id);
        if(type.equals("1")) {
        	xinwen.setThumbsupnum(xinwen.getThumbsupnum()+1);
        } else {
        	xinwen.setCrazilynum(xinwen.getCrazilynum()+1);
        }
        xinwenService.updateById(xinwen);
        return R.ok("投票成功");
    }

    /**
     * 后端保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody XinwenEntity xinwen, HttpServletRequest request){
    	xinwen.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(xinwen);
        xinwenService.insert(xinwen);
        return R.ok();
    }
    
    /**
     * 前端保存
     */
    @RequestMapping("/add")
    public R add(@RequestBody XinwenEntity xinwen, HttpServletRequest request){
    	xinwen.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(xinwen);
        xinwenService.insert(xinwen);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody XinwenEntity xinwen, HttpServletRequest request){
        //ValidatorUtils.validateEntity(xinwen);
        xinwenService.updateById(xinwen);//全部更新
        return R.ok();
    }
    

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        xinwenService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
    
    /**
     * 提醒接口
     */
	@RequestMapping("/remind/{columnName}/{type}")
	public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, 
						 @PathVariable("type") String type,@RequestParam Map<String, Object> map) {
		map.put("column", columnName);
		map.put("type", type);
		
		if(type.equals("2")) {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			Calendar c = Calendar.getInstance();
			Date remindStartDate = null;
			Date remindEndDate = null;
			if(map.get("remindstart")!=null) {
				Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
				c.setTime(new Date()); 
				c.add(Calendar.DAY_OF_MONTH,remindStart);
				remindStartDate = c.getTime();
				map.put("remindstart", sdf.format(remindStartDate));
			}
			if(map.get("remindend")!=null) {
				Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
				c.setTime(new Date());
				c.add(Calendar.DAY_OF_MONTH,remindEnd);
				remindEndDate = c.getTime();
				map.put("remindend", sdf.format(remindEndDate));
			}
		}
		
		Wrapper<XinwenEntity> wrapper = new EntityWrapper<XinwenEntity>();
		if(map.get("remindstart")!=null) {
			wrapper.ge(columnName, map.get("remindstart"));
		}
		if(map.get("remindend")!=null) {
			wrapper.le(columnName, map.get("remindend"));
		}


		int count = xinwenService.selectCount(wrapper);
		return R.ok().put("count", count);
	}
	
	/**
     * 前端智能排序
     */
	@IgnoreAuth
    @RequestMapping("/autoSort")
    public R autoSort(@RequestParam Map<String, Object> params,XinwenEntity xinwen, HttpServletRequest request,String pre){
        EntityWrapper<XinwenEntity> ew = new EntityWrapper<XinwenEntity>();
        Map<String, Object> newMap = new HashMap<String, Object>();
        Map<String, Object> param = new HashMap<String, Object>();
		Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();
		while (it.hasNext()) {
			Map.Entry<String, Object> entry = it.next();
			String key = entry.getKey();
			String newKey = entry.getKey();
			if (pre.endsWith(".")) {
				newMap.put(pre + newKey, entry.getValue());
			} else if (StringUtils.isEmpty(pre)) {
				newMap.put(newKey, entry.getValue());
			} else {
				newMap.put(pre + "." + newKey, entry.getValue());
			}
		}
		params.put("sort", "clicknum");
        params.put("order", "desc");
		PageUtils page = xinwenService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xinwen), params), params));
        return R.ok().put("data", page);
    }


}

显示全文