Java+spring novel reading website based on ssm \

*Get the source code at the end of the article

development environment

Project No.: Java+spring ssm285 novel reading website \graduation design
Development language: Java
Development tools: IDEA /Eclipse
Database: MYSQL5.7
Application service: Tomcat7/Tomcat8
Using framework: ssm+vue

Project introduction

The development of the Internet has driven the rapid development of the novel industry. All major websites can see the shadow of novel reading. The increase of readers has further inhibited the improvement of market consumption. With the increasingly fierce market competition, although many authors take the initiative to choose the credit sales model, they lack sufficient attention and good quality control. Some authors have not established independent credit practice management, It is unable to accurately obtain the reader's credit information in the early stage of the transaction, but it is easy to perform the credit, which makes it impossible to get a benign improvement.
Novel reading website, the main modules include viewing; administrators; Homepage, personal center, reader management, author management, novel information management, novel classification management, balance recharge management, purchase novel management, download novel management, system management, readers; Personal center, balance recharge management, purchase novel management, download novel management, my collection management, etc. Author: personal center, novel information management, novel classification management, balance recharge management, purchase novel management, download novel management, my collection management. Home page: novel information, my, jump to backstage function. The administrator in the system is mainly to store and manage all kinds of information safely and effectively, and can also manage, update and maintain the system, and have corresponding operation permissions for the front and back desks.

System screenshot






critical code

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.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.XiaoshuoxinxiEntity;
import com.entity.view.XiaoshuoxinxiView;

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


/**
 * Novel information
 * Back end interface
 * @author 
 * @email 
 * @date 2021-03-07 10:13:33
 */
@RestController
@RequestMapping("/xiaoshuoxinxi")
public class XiaoshuoxinxiController {
    @Autowired
    private XiaoshuoxinxiService xiaoshuoxinxiService;
    


    /**
     * Backend list
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,XiaoshuoxinxiEntity xiaoshuoxinxi, HttpServletRequest request){

        EntityWrapper<XiaoshuoxinxiEntity> ew = new EntityWrapper<XiaoshuoxinxiEntity>();
    	PageUtils page = xiaoshuoxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xiaoshuoxinxi), params), params));
		request.setAttribute("data", page);
        return R.ok().put("data", page);
    }
    
    /**
     * Front end list
     */
	@IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params,XiaoshuoxinxiEntity xiaoshuoxinxi, HttpServletRequest request){
        EntityWrapper<XiaoshuoxinxiEntity> ew = new EntityWrapper<XiaoshuoxinxiEntity>();
    	PageUtils page = xiaoshuoxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xiaoshuoxinxi), params), params));
		request.setAttribute("data", page);
        return R.ok().put("data", page);
    }

	/**
     * list
     */
    @RequestMapping("/lists")
    public R list( XiaoshuoxinxiEntity xiaoshuoxinxi){
       	EntityWrapper<XiaoshuoxinxiEntity> ew = new EntityWrapper<XiaoshuoxinxiEntity>();
      	ew.allEq(MPUtil.allEQMapPre( xiaoshuoxinxi, "xiaoshuoxinxi")); 
        return R.ok().put("data", xiaoshuoxinxiService.selectListView(ew));
    }

	 /**
     * query
     */
    @RequestMapping("/query")
    public R query(XiaoshuoxinxiEntity xiaoshuoxinxi){
        EntityWrapper< XiaoshuoxinxiEntity> ew = new EntityWrapper< XiaoshuoxinxiEntity>();
 		ew.allEq(MPUtil.allEQMapPre( xiaoshuoxinxi, "xiaoshuoxinxi")); 
		XiaoshuoxinxiView xiaoshuoxinxiView =  xiaoshuoxinxiService.selectView(ew);
		return R.ok("Query of novel information succeeded").put("data", xiaoshuoxinxiView);
    }
	
    /**
     * Back end details
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        XiaoshuoxinxiEntity xiaoshuoxinxi = xiaoshuoxinxiService.selectById(id);
		xiaoshuoxinxi.setClicknum(xiaoshuoxinxi.getClicknum()+1);
		xiaoshuoxinxi.setClicktime(new Date());
		xiaoshuoxinxiService.updateById(xiaoshuoxinxi);
        return R.ok().put("data", xiaoshuoxinxi);
    }

    /**
     * Front end details
     */
	@IgnoreAuth
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id){
        XiaoshuoxinxiEntity xiaoshuoxinxi = xiaoshuoxinxiService.selectById(id);
		xiaoshuoxinxi.setClicknum(xiaoshuoxinxi.getClicknum()+1);
		xiaoshuoxinxi.setClicktime(new Date());
		xiaoshuoxinxiService.updateById(xiaoshuoxinxi);
        return R.ok().put("data", xiaoshuoxinxi);
    }
    


    /**
     * Like or step on
     */
    @RequestMapping("/thumbsup/{id}")
    public R vote(@PathVariable("id") String id,String type){
        XiaoshuoxinxiEntity xiaoshuoxinxi = xiaoshuoxinxiService.selectById(id);
        if(type.equals("1")) {
        	xiaoshuoxinxi.setThumbsupnum(xiaoshuoxinxi.getThumbsupnum()+1);
        } else {
        	xiaoshuoxinxi.setCrazilynum(xiaoshuoxinxi.getCrazilynum()+1);
        }
        xiaoshuoxinxiService.updateById(xiaoshuoxinxi);
        return R.ok("Successful voting");
    }

    /**
     * Backend save
     */
    @RequestMapping("/save")
    public R save(@RequestBody XiaoshuoxinxiEntity xiaoshuoxinxi, HttpServletRequest request){
    	xiaoshuoxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(xiaoshuoxinxi);

        xiaoshuoxinxiService.insert(xiaoshuoxinxi);
        return R.ok();
    }
    
    /**
     * Front end save
     */
    @RequestMapping("/add")
    public R add(@RequestBody XiaoshuoxinxiEntity xiaoshuoxinxi, HttpServletRequest request){
    	xiaoshuoxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(xiaoshuoxinxi);

        xiaoshuoxinxiService.insert(xiaoshuoxinxi);
        return R.ok();
    }

    /**
     * modify
     */
    @RequestMapping("/update")
    public R update(@RequestBody XiaoshuoxinxiEntity xiaoshuoxinxi, HttpServletRequest request){
        //ValidatorUtils.validateEntity(xiaoshuoxinxi);
        xiaoshuoxinxiService.updateById(xiaoshuoxinxi);//Update all
        return R.ok();
    }
    

    /**
     * delete
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        xiaoshuoxinxiService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
    
    /**
     * Reminder interface
     */
	@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<XiaoshuoxinxiEntity> wrapper = new EntityWrapper<XiaoshuoxinxiEntity>();
		if(map.get("remindstart")!=null) {
			wrapper.ge(columnName, map.get("remindstart"));
		}
		if(map.get("remindend")!=null) {
			wrapper.le(columnName, map.get("remindend"));
		}


		int count = xiaoshuoxinxiService.selectCount(wrapper);
		return R.ok().put("count", count);
	}
	
	
	/**
     * Front end intelligent sorting
     */
	@IgnoreAuth
    @RequestMapping("/autoSort")
    public R autoSort(@RequestParam Map<String, Object> params,XiaoshuoxinxiEntity xiaoshuoxinxi, HttpServletRequest request,String pre){
        EntityWrapper<XiaoshuoxinxiEntity> ew = new EntityWrapper<XiaoshuoxinxiEntity>();
        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 = xiaoshuoxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xiaoshuoxinxi), params), params));
        return R.ok().put("data", page);
    }


}

Tags: Java Spring

Posted by Gulsaes on Thu, 02 Jun 2022 23:01:02 +0530