末尾获取源码
开发语言:Java
Java开发工具:JDK1.8
后端框架:SSM
前端:采用JSP技术开发
数据库:MySQL5.7和Navicat管理工具结合
服务器:Tomcat8.5
开发软件:IDEA / Eclipse
是否Maven项目:是
目录
一、项目简介
二、设计原则
三、系统项目截图
3.1用户功能实现
3.2管理员功能实现
编辑 3.3裁判功能实现
四、核心代码
4.1登录相关
4.2文件上传
4.3封装
五、系统测试
1、测试定义
2、性能测试
3、测试原理
4、测试分析
一、项目简介
在当今社会上,体育运动越来越普及,参与运动会的人越来越多,但是目前对运动会信息管理还是处于手工记录的时代,这远远满足不了现在用户需求,因此建立一个运动会信息管理系统已经变的非常重要。
本文重点阐述了学校运动会信息管理系统的开发过程,以实际运用为开发背景,基于B/S结构,运用了JSP技术和MYSQL作为系统数据库进行开发,充分保证系统的安全性和稳定性。本系统界面良好,操作简单方便,通过系统概述、系统分析、系统设计、数据库设计、系统测试这几个部分,详细的说明了系统的开发过程,最后并对整个开发过程进行了总结,实现了学校运动会信息管理的重要功能。
本系统经过测试,运行效果稳定,操作方便、快捷,是一个功能全面、实用性好、安全性高,并具有良好的可扩展性、可维护性的学校运动会信息管理系统。
二、设计原则
在开始开发项目之前,必须要先考虑项目的实用性、科学性,以及该项目是否能够真正让用户受益并尽可能的发挥项目的作用。因此,在开发前,通过以下几条原则对项目进行判断:
(1)可行性原则。项目需要保证经济可行性和技术可行性,这包括了项目在浏览端、服务端等方面上的经济和技术上是可以达成的。
(2)适应性原则。项目要保证可维护性和可扩展性,这是每个非短期项目都需要考虑的,并且不论是维护还是扩展,都必须要建立在适应用户的正常需求的基础上。
(3)安全性及保密性原则。要充分保证用户信息的安全性和保密性,不能因为开发上的疏忽,导致用户的信息泄露。
(4)系统工程原则。为了确保项目的整体性,在项目调查、项目分析、项目设计、项目开发的过程中,都需遵从项目工程的方法和步骤逐步进行。
(5)统一规划、分期实施、逐步完善原则。项目开发的过程中,要按照规划、分期实施,特别是要注意在项目开发过程中要有条理,从点到面,一步步完善,不要贪图进度,要循环渐进的对项目进行开发。
三、系统项目截图
3.1用户功能实现
用户进入本系统可查看系统信息
未有账号的用户可进入注册界面进行注册操作
用户要想进行比赛报名操作,必须登录系统
用户在比赛详情界面可查看比赛详细信息,登录后可进行报名操作,比赛详情界面展示
用户登录后可选择比赛进行报名操作,比赛报名界面展示
用户登录后可进行留言反馈操作,留言反馈界面展示
用户可修改个人信息,个人信息界面展示 用户可进入比赛成绩界面查看个人比赛成绩信息,比赛成绩界面展示
3.2管理员功能实现
管理员要想进入系统后台对系统进行管理操作,必须进行登录系统,管理员登录界面展示
管理员可查看所有裁判信息,并可对其进行修改和删除操作,同时也可添加裁判信息,裁判界面展示
管理员可添加、修改和删除用户信息,用户管理界面展示
管理员可增删改查比赛项目信息,比赛项目管理界面展示
管理员可增删改查比赛信息,比赛信息管理界面展示
3.3裁判功能实现
裁判可查看所有赛事报名信息,并可对其进行审核和删除操作,赛事报名管理界面展示
裁判能添加、修改和删除比赛成绩信息,比赛成绩管理界面展示
四、核心代码
4.1登录相关
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文件上传
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封装
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;
}
}
五、系统测试
1、测试定义
系统测试是系统开发中不可缺少的部分,所以测试的重要性是不可言喻的,系统开发后,测试下能否可以正常稳定的运行。如果测试过程中出现了BUG,就需要我们去修复BUG完善系统,这样开发的流程是非常正确稳定的且是开发系统的必经之路,不进行系统测试这一步骤,系统开发就是有缺陷的。测试的目的是为了确保开发出来的系统产品在确认正式使用之前,将没有完善或者说把尽可能出现的bug修复,保证开发出来的系统质量过硬,让系统中可能出现的BUG和一些不够完善的设计不会影响到使用者的工作内容。所以说系统测试是系统在开发过程中,不可以缺少的一部分。系统开发与测试需要控制再一个点,这个点就是让系统中的缺陷和bug在一定的范围内,让使用系统的的用户不会收到影响,提高用户的信用度,正常并且稳定的运行即可。
2、性能测试
每一款项目的开发都需要经过上百上千甚至更多次的测试来确保项目的质量,其根本目的就是为了提高用户的体验感,用户体验感高,所发布的项目才会受欢迎。而如果一个项目没有经历过测试的千锤百炼就发布,那么用户在体验这项目时,必将会碰到这样那样的BUG,导致用户体验感差。而用户体验感差的话,使用该项目的人数必将减少,所以像这样的恶性循环,我们一定要避免。
系统的功能性测试又被称作为黑盒测试,系统的功能性测试主要考量的是一个系统的功能。即一个系统的功能是否缺失,能否正常使用进行测试。如果随意测试会导致测试时间过程,需实时数据进行有效的进行测试,减少系统延期上线。
3、测试原理
系统测试是为了让测试人员在系统正式上线之前,找到系统可能存在的问题和漏洞。以便于可以再遇到问题之前及时对系统进行改进。系统测试人员需要通过模拟用户的使用环境进行测试,这是为了让系统在实际用户使用的情况下查看系统的运行状态,来验证整个软件是否满足用户的要求,基本功能可不可以实现。模拟环境测试只是一方面,系统测试人员需要对系统进行后台代码的测试和系统界面的合理性进行全面测试。软件测试的理论基础是系统测试的原理,为了实现软件存在具有实际的应用价值,软件测试必须严格的遵循系统测试的方法和原则。
在测试时,要让测试用例符合规范,测试用例是否规范,对于系统的测试结果来说很重要。这就需要软件测试人员具备一定的专业技能,不能盲目测试,否则测试出来的结果与测试预期的结果不一样,会导致测试人员判断失误,从而影响整个系统的使用,那么就会造成无法挽回结果出现。
4、测试分析
通过测试的整个过程,本学校运动会信息管理系统的每个模块的功能都还比较成功,但也发现了一些问题,比如登录页面登录进不了系统,是因为配置文件中的数据库的密码不一致等,在发现后及时进行了修改。目前系统还存在很多需要改进的地方,将会在今后的使用和维护中不断完善。