School sports meeting information management system based on SSM

Get the source code at the end
Development language: Java
Java development tools: JDK1.8
Back-end framework: SSM
Front-end: Developed using JSP technology
Database: MySQL5.7 and Navicat management tools combined
Server: Tomcat8.5
Development software: IDEA / Eclipse
Maven project: yes


Table of contents

1. Project Introduction

2. Design principles

3. System project screenshots

3.1 User function implementation

3.2 Administrator function implementation

​Edit 3.3 Implementation of referee function

4. Core code

4.1 Login related

4.2 File upload

4.3 Packaging

5. System testing

1. Test definition

2. Performance test

3. Testing principle

4. Test analysis


1. Project Introduction

In today's society, sports are becoming more and more popular, and more and more people participate in sports games, but the current information management of sports games is still in the era of manual records, which is far from meeting the needs of current users. Therefore, a sports meeting information management system is established has become very important.

This article focuses on the development process of the school sports meeting information management system. It takes practical application as the development background, is based on the B/S structure, and uses JSP technology and MYSQL as the system database for development to fully ensure the security and stability of the system. This system has a good interface and is simple and convenient to operate. Through the system overview, system analysis, system design, database design, and system testing, the system development process is explained in detail. Finally, the entire development process is summarized and realized. An important function of school sports meeting information management.

After testing, the system has stable operation effect, convenient and fast operation, and is a school sports meeting information management system with comprehensive functions, good practicability, high security, good scalability and maintainability.


2. Design principles

Before starting to develop a project, you must first consider the practicability and scientific nature of the project, and whether the project can really benefit users and maximize the role of the project. Therefore, before development, the project should be judged according to the following principles:

(1) Principle of feasibility. The project needs to ensure economic feasibility and technical feasibility, which includes the economic and technical achievability of the project in terms of browser and server.

(2) Principle of adaptability. The project must ensure maintainability and scalability, which is a consideration for every non-short-term project, and whether it is maintenance or expansion, it must be based on adapting to the normal needs of users.

(3) Principles of security and confidentiality. The security and confidentiality of user information must be fully guaranteed, and user information must not be leaked due to negligence in development.

(4) Systems engineering principles. In order to ensure the integrity of the project, in the process of project investigation, project analysis, project design, and project development, it is necessary to follow the methods and steps of project engineering and proceed step by step.

(5) The principles of unified planning, phased implementation and gradual improvement. In the process of project development, it is necessary to follow the plan and implement it in phases. In particular, we must pay attention to the orderliness in the project development process, from point to surface, and improve step by step. Don't be greedy for progress, and develop the project in a cyclical and gradual manner.



3. System project screenshots

3.1 User function implementation

Users can view system information after entering this system

Users who do not have an account can enter the registration interface to register.

 

Users must log in to the system if they want to register for the competition.

 

Users can view the detailed information of the competition on the competition details interface. After logging in, they can perform registration operations. The competition details interface is displayed.

 

After logging in, the user can select a competition to register, and the competition registration interface is displayed.

 After logging in, users can perform message feedback operations, and the message feedback interface is displayed.

Users can modify personal information, and the personal information interface is displayed.  Users can enter the competition results interface to view personal competition results information, and the competition results interface is displayed.

3.2 Administrator function implementation

If the administrator wants to enter the system background to perform management operations on the system, he must log in to the system. The administrator login interface is displayed.

The administrator can view all referee information, modify and delete it, and can also add referee information and display the referee interface.

 

Administrators can add, modify and delete user information, and the user management interface is displayed

 

Administrators can add, delete, modify and check competition event information, and the competition event management interface is displayed.

 

Administrators can add, delete, modify and check game information, and the game information management interface is displayed

 3.3 Implementation of referee function

Referees can view all event registration information, and can review and delete it. The event registration management interface is displayed

Referees can add, modify and delete game score information, and the game score management interface is displayed

 


4. Core code

4.1 Login related


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;

/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;

	/**
	 * 登录
	 */
	@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("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		return R.ok().put("token", token);
	}
	
	/**
	 * 注册
	 */
	@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("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 密码重置
     */
    @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("账号不存在");
    	}
    	user.setPassword("123456");
        userService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @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);
    }

	/**
     * 列表
     */
    @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));
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @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);
    }

    /**
     * 保存
     */
    @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("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
        userService.updateById(user);//全部更新
        return R.ok();
    }

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

4.2 File upload

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;

/**
 * 上传文件映射表
 */
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
	@Autowired
    private ConfigService configService;
	/**
	 * 上传文件
	 */
	@RequestMapping("/upload")
	public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
		if (file.isEmpty()) {
			throw new EIException("上传文件不能为空");
		}
		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) && 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);
	}
	
	/**
	 * 下载文件
	 */
	@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);
	}
	
}

4.3 Packaging

package com.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 */
public class R extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public R() {
		put("code", 0);
	}
	
	public static R error() {
		return error(500, "未知异常,请联系管理员");
	}
	
	public static R error(String msg) {
		return error(500, msg);
	}
	
	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;
	}
	
	public static R ok(Map<String, Object> map) {
		R r = new R();
		r.putAll(map);
		return r;
	}
	
	public static R ok() {
		return new R();
	}

	public R put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}

5. System testing

1. Test definition

System testing is an indispensable part of system development, so the importance of testing is indescribable. After the system is developed, test whether it can run normally and stably. If a BUG occurs during the testing process, we need to fix the BUG and improve the system. In this way, the development process is very correct and stable and is the only way to develop the system. Without system testing, system development will be defective. . The purpose of testing is to ensure that the developed system products will not be perfected or have as many bugs fixed as possible before they are confirmed for official use, to ensure that the developed system is of excellent quality and to eliminate possible BUGs and some imperfections in the system. The design will not affect the user's work content. Therefore, system testing is an indispensable part of the system development process. System development and testing need to control another point. This point is to keep the defects and bugs in the system within a certain range, so that users who use the system will not be affected, improve the user's credibility, and run normally and stably. .

2. Performance test

The development of each project needs to go through hundreds, thousands or even more tests to ensure the quality of the project. The fundamental purpose is to improve the user experience. If the user experience is high, the released projects will be popular. And if a project is released without going through a lot of testing, then when users experience the project, they will definitely encounter bugs of one kind or another, resulting in a poor user experience. If the user experience is poor, the number of people using the project will inevitably decrease, so we must avoid a vicious cycle like this.

System functional testing is also called black box testing. System functional testing mainly considers the functions of a system. That is, whether the function of a system is missing and whether it can be used normally is tested. Random testing will lead to a long test process, and real-time data is required for effective testing to reduce delays in system rollout.

3. Testing principle

System testing is to allow testers to find possible problems and loopholes in the system before it is officially launched. In order to make timely improvements to the system before encountering problems again. System testers need to test by simulating the user's use environment. This is to allow the system to check the operating status of the system under the actual user's use to verify whether the entire software meets the user's requirements and whether the basic functions can be realized. Simulation environment testing is only one aspect. System testers need to test the background code of the system and conduct a comprehensive test of the rationality of the system interface. The theoretical basis of software testing is the principle of system testing. In order to realize the actual application value of software, software testing must strictly follow the methods and principles of system testing.

When testing, it is important to make the test cases comply with the specifications. Whether the test cases are standardized is very important for the test results of the system. This requires software testers to have certain professional skills, and they cannot test blindly. Otherwise, the test results will be different from the expected test results, which will cause testers to make mistakes in judgment, which will affect the use of the entire system, and will cause irreparable results. Appear.

4. Test analysis

Through the whole process of testing, the functions of each module of the school sports meeting information management system are relatively successful, but some problems have also been found, such as the login page cannot be logged into the system, because the passwords of the database in the configuration file are inconsistent, etc. Modifications were made promptly after discovery. At present, there are still many areas for improvement in the system, which will be continuously improved in future use and maintenance.

 

 

Guess you like

Origin blog.csdn.net/weixin_52721608/article/details/132764506