Design and implementation of information technology knowledge contest system based on SpringBoot

Table of Contents

Preface

1. Technology stack

2. Introduction to system functions

User information management

Learn video management

Announcement type management

Announcement information management

3. Core code

1. Login module

2. File upload module

3. Code encapsulation

4. Conclusion


Foreword

Firstly, it takes a lot of time to manage information using traditional methods. Secondly, the data error rate is relatively high, and it is also difficult to change erroneous data. Finally, retrieving data is time-consuming and laborious. Therefore, installing the information technology knowledge competition system software on the computer to play its role in efficient information processing can standardize the information management process and allow the management work to be systematized and programmed. At the same time, the effective use of the information technology knowledge competition system can help Managers process information accurately and quickly.

The Information Technology Knowledge Competition system is also very cautious in the selection of development tools. In order to facilitate development and implementation, the development tool selected is Eclipse, and the database tool selected is Mysql. This is used to build a development environment to realize the functions of the information technology knowledge competition system. Among them, the administrator manages users and news announcements.

The Information Technology Knowledge Competition system is an application system designed and implemented using software development technology. It can achieve rapid information processing, whether it is for data addition, data maintenance and statistics, as well as data query and other processing requirements. Information Technology Knowledge Competition The system can handle it easily.

1. Technology Stack

Get the source code at the end
SpringBoot + Vue + JS + jQuery + Ajax…

2. Introduction to system functions

User Information Management

The functions provided to administrators on this page include: query management of user information, the ability to delete user information, modify user information, add user information, and also perform fuzzy query conditions for user names.

Learning Video Management

The functions provided to administrators on this page include: viewing published learning video data, modifying learning videos, invalidating learning videos and deleting them, and also performing fuzzy queries on learning video names, querying the type of learning video information, and other conditions. .

Announcement Type Management

The functions provided to administrators on this page include: conditional query based on announcement type, and the ability to add, modify, query, etc. to announcement types.

Announcement Information Management

The functions provided to administrators on this page include: adding, modifying, querying operations, etc. based on announcement information.

3. Core code

1. Login module

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.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;
 
/**
 * Login related
 */
@RequestMapping("users")
@RestController
public class UserController{
\t
@Autowired
private UserService userService;
\t
@Autowired
private TokenService tokenService;
 
/**
\t * 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("The account or password is incorrect");
}
String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
return R.ok().put("token", token);
}
\t
/**
\t * 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();
    }
 
/**
\t * quit
*/
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("Exit successfully");
}
\t
/**
     * 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 has been reset to: 123456");
    }
\t
/**
     * 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);
        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();
    }
}

2. File upload module

package com.controller;
 
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
 
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
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 org.springframework.web.multipart.MultipartFile;
 
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;
 
/**
 * Upload file mapping table
 */
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
@Autowired
    private ConfigService configService;
/**
\t * upload files
*/
@RequestMapping("/upload")
public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
if (file.isEmpty()) {
throw new EIException("The uploaded file cannot be empty");
}
String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
File path = new File(ResourceUtils.getURL("classpath:static").getPath());
if(!path.exists()) {
path = new File("");
}
File upload = new File(path.getAbsolutePath(),"/upload/");
if(!upload.exists()) {
upload.mkdirs();
}
String fileName = new Date().getTime() + "." + fileExt;
File dest = new File(upload.getAbsolutePath() + "/" + fileName);
file.transferTo(dest);
FileUtils.copyFile(dest, new File("C:\Users\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\ \static\upload" + "/" + fileName));
if(StringUtils.isNotBlank(type) & amp; & amp; type.equals("1")) {
ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
if(configEntity==null) {
configEntity = new ConfigEntity();
configEntity.setName("faceFile");
configEntity.setValue(fileName);
} else {
configEntity.setValue(fileName);
}
configService.insertOrUpdate(configEntity);
}
return R.ok().put("file", fileName);
}
\t
/**
\t * download file
*/
@IgnoreAuth
@RequestMapping("/download")
public ResponseEntity<byte[]> download(@RequestParam String fileName) {
try {
File path = new File(ResourceUtils.getURL("classpath:static").getPath());
if(!path.exists()) {
path = new File("");
}
File upload = new File(path.getAbsolutePath(),"/upload/");
if(!upload.exists()) {
upload.mkdirs();
}
File file = new File(upload.getAbsolutePath() + "/" + fileName);
if(file.exists()){
/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
getResponse().sendError(403);
}*/
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
headers.setContentDispositionFormData("attachment", fileName);
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
}
} catch (IOException e) {
e.printStackTrace();
}
return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
}
\t
}

3. Code encapsulation

package com.utils;
 
import java.util.HashMap;
import java.util.Map;
 
/**
 * Return data
 */
public class R extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
\t
public R() {
put("code", 0);
}
\t
public static R error() {
return error(500, "Unknown exception, please contact the administrator");
}
\t
public static R error(String msg) {
return error(500, msg);
}
\t
public static R error(int code, String msg) {
R r = new R();
r.put("code", code);
r.put("msg", msg);
return r;
}
 
public static R ok(String msg) {
R r = new R();
r.put("msg", msg);
return r;
}
\t
public static R ok(Map<String, Object> map) {
R r = new R();
r.putAll(map);
return r;
}
\t
public static Rok() {
return new R();
}
 
public R put(String key, Object value) {
super.put(key, value);
return this;
}
}

Four. Conclusion

I have previously learned software development knowledge from textbooks, including understanding the development process, learning development technology, and how to analyze and design system requirements. The teacher also selected a relatively representative management system to explain in class, and After class, we were assigned homework for us to practice. During this period, the teacher also let us understand the system implementation and testing. So when it comes to the development and production of this information technology knowledge competition system, I still have a relatively clear idea in my mind. During the production of the system and the writing of supporting documents, I carried out my work step by step according to the software development process.

From a system perspective, the difficulty in making an information technology knowledge competition system lies in the determination of functions, the design of the system structure, the design of databases with excellent performance, and the use of mature technologies to realize system functions. These are the things I face. Difficulties. In response to these difficulties, I have taken certain measures. When I didn’t know the functions of the system, I searched for many similar systems on the Internet, recorded the general functions of these systems, and adopted some functions that were useful to this system. In addition, I also obtained a lot of information about the system from the Internet. Design knowledge includes system module division, design principles, database table design and creation, etc. I also acquired technical knowledge of program coding from software development blogs, including the writing and use of data addition, deletion and modification code modules. After the coding of this system completed its corresponding functions, I patiently tested all the functions of the system, and finally found that the system I developed was qualified and could be accepted. Because in addition to having a simple and beautiful interface, this system can functionally meet the user’s needs for data operations, and the functions of this system are highly consistent with the functions of system analysis and design, and the system runs stably, facing user misoperations. , an error feedback mechanism has also been established, and the quality of the system is reliable. The only shortcoming is that the design of the system data table is not comprehensive in terms of field considerations, and the data types matched for the fields are not accurate. There are also many parts of the system code that have not been commented, and the code writing is not concise enough.

From a documentation perspective, after completing the production of the information technology knowledge competition system, the production process needs to be described, including how to conduct demand analysis, how to complete the system design, and the operating effects of the implemented system functions. describe. During this period, I also spent nearly a month to complete it. In order to meet the document formatting standards required by the college, I also learned the use of office software and formatting skills under the advice of my tutor many times. The hard work paid off, and the document I wrote was finally completed after many revisions.

All in all, although the production of the final design has gone through many links, if we take this matter seriously, we will gain a lot of knowledge in each link, and we will also exercise our practical abilities in the actual operations of each link. Through the production of this project, I began to understand that a lot of knowledge does not only come from books, but also from the knowledge explained by teachers in class, but also from major learning websites and life practices. At this point, I will continue to work hard and maintain the habit of active learning of new knowledge.

The knowledge points of the article match the official knowledge files, and you can further learn related knowledge. Java Skill TreeHomepageOverview 139503 people are learning the system