Project No.: BS-GX-009
Development tools: IDEA /Eclipse
Database: mysql5 7+Redis
Front end development: Layui+Bootstrap
Back end development: SSM development framework
Functional requirements:
It is divided into three stages
The first stage is: the competition stage of the teaching and Research Office (the teacher competition of the same teaching and Research Office). Several teaching and research offices of the same college select several people with high scores from the teaching and research office to advance to the second stage: the college competition.
The second stage is: college competition stage: select the teachers with the highest scores from the first stage to represent the college in the third stage (finals)
The third stage is: Finals: the players who are promoted from the second stage compete, rank, and select the champion, runner up and runner up.
The management system mainly realizes the following main functions:
1. Main contents of the competition (online competition) stage of the teaching and Research Office:
(1) Teacher registration, login and exit functions;
(2) Teachers' personal information management;
(3) Teacher registration function; (not all registered teachers will register, and only after registration can they be contestants)
(4) Teachers upload participating videos;
(5) Judge scoring function; (each judge scores the contestants of a certain competition database table: competition ID contestant ID judge ID score)
(6) The administrator logs in, views the teacher information (including the uploaded video) and modifies the teacher score (enter the value calculated by the score of the judges (the highest score and the lowest score of the ten judges are removed, and the rest is taken as the average value)
(7) Promotion function. (in stage 1, select several players with the highest scores to promote to stage 2 college competition)
2. Main contents of college competition (offline competition) stage:
(1) Judges' scoring (each judge scores the contestants of a certain competition. Database table: competition ID contestant ID judges' ID scores)
(2) The administrator logs in, views the teacher's information, and modifies the teacher's score (enter the calculated value of the score given by the judges (the highest score and the lowest score are removed from the ten judges, and the rest is taken as the average)
(3) Promotion function. (in stage 2, select several players with the highest scores to promote to stage 3 college competition)
3. Main contents of school finals (offline competitions):
(1) Judges' scoring (each judge scores the contestants of a certain competition. Database table: competition ID contestant ID judges' ID scores)
(2) The administrator logs in, views the teacher's information, and modifies the teacher's score (enter the calculated value of the score given by the judges (the highest score and the lowest score are removed from the ten judges, and the rest is taken as the average)
(3) The ranking selects the champion, runner up and runner up
Here are some functions of the system:
Login of participating users:
Registration:
Upload video after successful registration:
Judges log in to the system and start scoring: all judges enter the system to score each work
Administrator login:
Promotion management: it can be managed in stages, including teaching and Research Office, school and college finals. It is mainly ranked according to the average score generated by each judge
The front-end homepage can view the comparison ranking results of each stage:
System core implementation code:
package controller; import com.alibaba.fastjson.JSON; import entity.Response; import entity.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import service.LoginService; @Controller @RequestMapping(value = "login") public class LoginController { @Autowired private LoginService loginService; @ResponseBody @RequestMapping(value = "login.do") public Response login(String userName,String password){ User user = loginService.login(userName,password); Response res = new Response(); if (user != null){ Integer flag = loginService.loginStatus(user); if (flag == 1){ res.setMessage("Login succeeded!"); user.setIslogin(true); res.setTag(true); res.setUser(user); } }else { res.setMessage("Login failed, please check whether the account or password is correct!"); res.setTag(false); } return res; } @ResponseBody @RequestMapping(value = "register.do") public Response register(User user){ Response res = new Response(); System.out.println("data=>"+user+user.getName()+user.getPhonenum()); Integer flag = loginService.checkUser(user.getUsername(),user.getPhonenum()); if (flag == 1){ res.setTag(false); res.setMessage("This user is already registered!"); }else { User userInfo = loginService.register(user); if (userInfo != null) { res.setTag(true); res.setMessage("Account registration succeeded!"); res.setUser(userInfo); }else { res.setTag(false); res.setMessage("Account registration failed!"); } } return res; } @ResponseBody @RequestMapping(value = "logout.do") public Response logout(String id){ Response res = new Response(); int flag = loginService.logout(id); if (flag == 1){ res.setTag(true); res.setMessage("Account exit login succeeded!"); }else { res.setTag(false); res.setMessage("Failed to log out! Please contact the administrator"); } return res; } @ResponseBody @RequestMapping(value = "updateUserInfo.do") public Response updateUserInfo(User user){ Response res = new Response(); int flag = loginService.updateUser(user); if (flag == 1){ res.setMessage("Data modification succeeded!"); res.setUser(loginService.getUserInfo(user.getId())); res.setTag(true); }else { res.setMessage("Data modification failed!"); res.setTag(false); } return res; } }
package controller; import entity.Match; import entity.ResponseJSON; import org.apache.commons.io.FileUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import service.DateTimeService; import service.MatchService; import util.DateUtil; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; @Controller @RequestMapping("file") public class VideoController { String path = "D:\\uploadFiles\\"; @Autowired private MatchService matchService; @Autowired private DateTimeService dateTimeService; @RequestMapping(value="upload.do") @ResponseBody public ResponseJSON upload(MultipartHttpServletRequest request) { String deadLine = dateTimeService.getDeadLine(); // Get file map collection Map<String, MultipartFile> fileMap = request.getFileMap(); MultipartFile file1 = fileMap.get("file"); String mediaType = file1.getContentType(); ResponseJSON rsp = new ResponseJSON(); String[] un = request.getParameterMap().get("id"); String[] ftl = request.getParameterMap().get("mediaType"); String playerId = un[0]; if (file1.isEmpty()) { rsp.setTag(false); rsp.setMessage("The uploaded file cannot be empty"); } else { String originalFilename = file1.getOriginalFilename(); try { // Create a road to upload // File fdir = new File("/home/uploadFiles"); File fdir = new File(path); if (!fdir.exists()) { fdir.mkdirs(); } // File upload to path FileUtils.copyInputStreamToFile(file1.getInputStream(), new File(fdir, originalFilename)); // coding rsp.setTag(true); rsp.setMessage("Upload file succeeded"); } catch (Exception e) { rsp.setTag(false); rsp.setMessage("Failed to upload file"); } } Match req = new Match(); req.setPlayerid(playerId); req.setVideourl(file1.getOriginalFilename()); req.setMediaType(mediaType); if(matchService.fileIsExist(req)>0) { File file = new File(matchService.getFileUrl(req).getVideourl());// read file.delete(); int flag = matchService.uploadVideo(req); if (flag == 1) { rsp.setMessage("Upload file succeeded,Source file overwritten"); } }else { Match match = new Match(); String filePath = file1.getOriginalFilename(); match.setVideourl(filePath); match.setPlayerid(playerId); match.setMediaType(mediaType); matchService.uploadVideo(match); Date date = new Date(); SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); matchService.uploadVideo(match); } return rsp; } @RequestMapping(value="download",produces = "application/json;charset=UTF-8") @ResponseBody public ResponseJSON download(HttpServletRequest request, HttpServletResponse response) { String fn = request.getParameter("fileName").toString(); ResponseJSON rsp = new ResponseJSON(); //Simulation file, myfile Txt is the file to be downloaded // String path = "/home/uploadFiles/"+fn; String paths = path + fn; System.out.println(paths+"Download path"); //Get input stream InputStream bis; try { bis = new BufferedInputStream(new FileInputStream(new File(paths))); System.out.println("obtain file success"); String filename = URLEncoder.encode(fn,"UTF-8"); //Set file download header response.addHeader("Content-Disposition", "attachment;filename=" + filename); //1. Set the file ContentType. This setting will automatically determine the type of downloaded file // response.setContentType("multipart/form-data"); response.setContentType("application/json;charset=UTF-8"); BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); System.out.println("Start to flow"); int len = 0; while((len = bis.read()) != -1){ out.write(len); out.flush(); } out.close(); rsp.setTag(true); rsp.setMessage("Download File succeeded"); } catch (IOException e) { rsp.setTag(false); rsp.setMessage("Failed to download file"); } return rsp; } }
package controller; import entity.Judges; import entity.Match; import entity.Response; import entity.ResponseJSON; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import service.JudgeService; import java.util.List; @Controller @RequestMapping(value = "judge") public class JudgeController { @Autowired private JudgeService judgeService; @ResponseBody @RequestMapping(value = "rateMatch") public ResponseJSON rateMatch(Judges match){ ResponseJSON res = new ResponseJSON(); int flag = judgeService.getVideoMenu(match); if (flag == 0) { res.setMessage("Failed to score!"); res.setTag(true); }else { res.setMessage("Scoring successful!"); res.setTag(true); } return res; } @ResponseBody @RequestMapping(value = "checkScored") public ResponseJSON checkScored(Judges match){ ResponseJSON res = new ResponseJSON(); return res; } @ResponseBody @RequestMapping(value = "calculationAverage") public ResponseJSON calculationAverage(String matchId,String playerId,String adminId){ ResponseJSON res = new ResponseJSON(); int flag = judgeService.checkAdmin(adminId); int judgeNum =judgeService.checkJudged(matchId,playerId); if (flag == 0){ res.setTag(false); res.setMessage("You do not have permission to enter scores"); } if (judgeNum < 3 ){ res.setTag(false); res.setMessage("Scoring has not been completed!"); }else { int updated = judgeService.updateTotalScore(matchId,playerId); if (updated == 1){ res.setTag(true); res.setMessage("Modify score completed!"); }else { res.setTag(false); res.setMessage("Failed to update total score!"); } int ended = judgeService.checkMatchEnd(matchId); if (ended == 0){ String level = judgeService.getCurrentLevel(matchId); if (level.equals("Has ended")){ res.setTag(true); res.setMessage("The third runner up of Guanya has been determined!"); }else { int promote = judgeService.updatePromotion(matchId, level); if (promote == 1) { res.setMessage("The total score of all participants has been generated, and the competition result has been generated!"); res.setTag(true); } else { res.setMessage("The total score of all participants has been generated. The result of this competition failed. Please contact the administrator!"); res.setTag(false); } } } } return res; } }