Campus Blog Management System Based on SpringBoot

Background of the project

With the rapid development of the current network, the online management system has gradually developed rapidly, and the online management mode has been quickly integrated into many websites, resulting in the "campus blog system", which makes the campus blog system more convenient and simple. .
For the design of the campus blog system, the system development mainly uses java language technology, and the MySQL database is used to complete the data storage in the design of the whole system, which is developed according to the current situation of the campus blog system and the actual needs. To realize the network management of the campus blog system, all kinds of information are stored in an orderly manner. After entering the campus blog system page, you can start to operate the main control interface. The main functions include administrators: home page, personal center, blogger management, articles Category management, article information management, report and complaint management, system management, blogger; home page, personal center, article information management, report and complaint management, my collection management, front page home page; home page, article information, system announcement, personal center, background management, online customer service and other functions.
This paper mainly describes the development background of the campus blog system, which mainly introduces the demand analysis and functional requirements, and makes a detailed test and summary of the system. Specifically from the business process, database design and system structure and many other issues. Hope to use advanced computer technology and network technology to change the current situation of campus blog system and improve management efficiency.

feature design

Functional block diagram

Administrator use case requirements

Blogger use case requirements

The functional structure diagram of the system

Functional screenshot

Implementation of administrator function module

The administrator logs in, by filling in the user name, password, role and other information, after the input is completed, select login to enter the campus blog system

The administrator manages the blogger to obtain the blogger account, the blogger's name, avatar, gender, age, mobile phone, and email, and perform details, deletion, and modification.

The administrator can perform details, delete, and modify operations on article classification management, viewing classification and other information

Carousel; this page is the management interface of carousel. The administrator can manage the homepage carousel on this page, add new pictures to the carousel by creating a new operation, and can also modify the uploaded pictures and delete the pictures.

The administrator edits the title, introduction, picture and other information of the system announcement, and performs details, deletion and modification operations

The administrator edits the article information management. The article title, category, picture, release date, blogger account, email and other information are detailed, deleted, and modified.

The administrator edits the title, type, picture, report content, report time, blogger account, mobile phone, review reply, review status, review and other information for the report and complaint management. Details, deletion, and modification operations

Blogger function realization module

Campus blog system, in the system you can view the home page, personal center, article information management, reporting and complaint management, my collection management, etc.

Bloggers can view the title, type, picture, report content, report time, blogger account, mobile phone, review reply, review status, review and make details, and modify operations for report and complaint management.

My collection management to view collection names, collection pictures and details, delete operations

Front-end function realization module

Campus blog system, you can view the home page, article information, system announcement, personal center, background management, online customer service, etc. on the home page of the system

Blogger registration, register by checking the blogger account number, password, blogger name, gender, age, mobile phone, email, etc. on the registration page

Blogger login, log in by filling in the account number, password and other information on the login page

Personal center, on the personal center page, you can view the blogger account, blogger name, avatar, gender, age, mobile phone, email and other information to update information, log out

Article information, in the article information page, you can view the article title, category, picture, release date, blogger account, email, number of clicks and other detailed information to click me to collect

Related code

Database configuration

# Tomcat
server:
    tomcat:
        uri-encoding: UTF-8
    port: 8080
    servlet:
        context-path: /springbootr1tjf

spring:
    datasource:
        driverClassName: com.mysql.jdbc.Driver
        url: jdbc:mysql://127.0.0.1:3306/springbootr1tjf?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
        username: root
        password: 123456

#        driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
#        url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=springbootr1tjf
#        username: sa
#        password: 123456

    servlet:
      multipart:
        max-file-size: 10MB
        max-request-size: 10MB
    resources:
      static-locations: classpath:static/,file:static/

#mybatis
mybatis-plus:
  mapper-locations: classpath*:mapper/*.xml
  #Entity scan, multiple package s are separated by commas or semicolons
  typeAliasesPackage: com.entity
  global-config:
    #Primary key type 0: "Database ID auto-increment", 1: "User input ID",2: "Global unique ID (numeric type unique ID)", 3: "Global unique ID UUID";
    id-type: 1
    #Field strategy 0: "Ignore judgment", 1: "Non-NULL judgment"), 2: "Non-null judgment"
    field-strategy: 2
    #CamelCase underscore conversion
    db-column-underline: true
    #Refresh mapper debugging artifact
    refresh-mapper: true
    #Tombstone configuration
    logic-delete-value: -1
    logic-not-delete-value: 0
    #Custom SQL Injector
    sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
  configuration:
    map-underscore-to-camel-case: true
    cache-enabled: false
    call-setters-on-nulls: true
    #springboot project mybatis plus set jdbcTypeForNull (oracle database needs to be configured with JdbcType.NULL, the default is Other)
    jdbc-type-for-null: 'null' 

controller

package com.controller;


import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;

/**
 * Login related
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;

	/**
	 * Log in
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("Incorrect account or password");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		return R.ok().put("token", token);
	}
	
	/**
	 * register
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("user already exists");
    	}
        userService.insert(user);
        return R.ok();
    }

	/**
	 * quit
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("exit successfully");
	}
	
	/**
     * reset Password
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("Account does not exist");
    	}
    	user.setPassword("123456");
        userService.update(user,null);
        return R.ok("Password reset to: 123456");
    }
	
	/**
     * list
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UserEntity user){
        EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
    	PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }

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

    /**
     * information
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * Get the user's session user information
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }

    /**
     * save
     */
    @PostMapping("/save")
    public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("user already exists");
    	}
        userService.insert(user);
        return R.ok();
    }

    /**
     * Revise
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
    	UserEntity u = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername()));
    	if(u!=null && u.getId()!=user.getId() && u.getUsername().equals(user.getUsername())) {
    		return R.error("Username already exists.");
    	}
        userService.updateById(user);//Update all
        return R.ok();
    }

    /**
     * delete
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        userService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

Business layer (Service)

package com.service;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.IService;
import com.entity.UserEntity;
import com.utils.PageUtils;


/**
 * system user
 */
public interface UserService extends IService<UserEntity> {
 	PageUtils queryPage(Map<String, Object> params);
    
   	List<UserEntity> selectListView(Wrapper<UserEntity> wrapper);
   	
   	PageUtils queryPage(Map<String, Object> params,Wrapper<UserEntity> wrapper);
	   	
}

Data Access Layer (Dao)

package com.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.entity.UserEntity;

/**
 * user
 */
public interface UserDao extends BaseMapper<UserEntity> {
	
	List<UserEntity> selectListView(@Param("ew") Wrapper<UserEntity> wrapper);

	List<UserEntity> selectListView(Pagination page,@Param("ew") Wrapper<UserEntity> wrapper);
	
}


Tags: Database Java Spring Boot Vue

Posted by kts on Mon, 30 May 2022 18:17:58 +0530