博主主页:Java旅途
简介:分享计算机知识、学习路线、系统源码及教程
文末获取源码
高校运动会信息管理系统基于Spring+SpringMVC+Mybatis开发,主要用来管理高校运动会信息,系统分为管理员何运动员两种角色。系统主要功能如下:
管理员:
运动员:
EventController
package com.handy.controller;
import com.handy.domain.Event;
import com.handy.domain.Matches;
import com.handy.service.EventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/event")
public class EventController {
@Autowired
private EventService eventService;
/**
* 查询所有项目信息
*
* @return
*/
@RequestMapping("/findAll.do")
public ModelAndView findAll() {
ModelAndView mv = new ModelAndView();
List<Event> eventList = eventService.findAll();
mv.addObject("event", eventList);
mv.setViewName("event-list");
return mv;
}
/**
* 查询项目详细信息
*
* @param eId
* @return
*/
@RequestMapping("/findDetailsByeId.do")
public ModelAndView findDetailsByeId(Integer eId) {
ModelAndView mv = new ModelAndView();
Map<String, Object> map = eventService.findDetailsByeId(eId);
Event event = (Event) map.get("event");
List<Matches> matchesList = (List<Matches>) map.get("matchesList");
mv.addObject("matchesList", matchesList);
mv.addObject("event", event);
mv.setViewName("event-details");
return mv;
}
/**
* 项目详细信息和该项目下参赛情况
*
* @param eId
* @return
*/
@RequestMapping("/manageFindDetailsByeId.do")
public ModelAndView manageFindDetailsBysId(Integer eId) {
ModelAndView mv = new ModelAndView();
Map<String, Object> map = eventService.findDetailsByeId(eId);
Event event = (Event) map.get("event");
List<Matches> matchesList = (List<Matches>) map.get("matchesList");
mv.addObject("matchesList", matchesList);
mv.addObject("event", event);
mv.setViewName("event-manage-details");
return mv;
}
/**
* 成绩录入
*
* @param eId
* @return
*/
@RequestMapping("/matchesInput.do")
public ModelAndView matchesInput(Integer eId) {
ModelAndView mv = new ModelAndView();
Map<String, Object> map = eventService.findDetailsByeId(eId);
Event event = (Event) map.get("event");
List<Matches> matchesList = (List<Matches>) map.get("matchesList2");
mv.addObject("matchesList", matchesList);
mv.addObject("event", event);
mv.setViewName("matches-manage-input");
return mv;
}
/**
* 学生参赛项目列表
*
* @param uId
* @return
*/
@RequestMapping("/participateEvent.do")
public ModelAndView participateEvent(String uId) {
ModelAndView mv = new ModelAndView();
List<Event> eventList = eventService.findNewAll(uId);
mv.addObject("event", eventList);
mv.setViewName("participateEvent-list");
return mv;
}
/**
* 参加比赛
*
* @param eId
* @param No
*/
@RequestMapping("/participate.do")
public void participate(Integer eId, String No) {
eventService.participate(eId, No);
}
/**
* 项目管理页面
*
* @return
*/
@RequestMapping("/manage.do")
public ModelAndView manage() {
ModelAndView mv = new ModelAndView();
List<Event> eventList = eventService.findAll();
mv.addObject("event", eventList);
mv.setViewName("event-manage");
return mv;
}
/**
* 项目录入
*
* @param event
* @return
*/
@RequestMapping(value = "/insert.do", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public String insert(@RequestBody Event event) {
try {
eventService.insert(event);
} catch (Exception e) {
return "新增失败!";
}
return "200";
}
/**
* 项目修改
*
* @param event
* @return
*/
@RequestMapping(value = "/update.do", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public String update(@RequestBody Event event) {
try {
eventService.update(event);
} catch (Exception e) {
return "修改失败!";
}
return "200";
}
/**
* 根据id获取项目信息到模态框
*
* @param id
* @return
*/
@RequestMapping(value = "/findById.do", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
@ResponseBody
public Event findById(@RequestParam(name = "id") Integer id) {
return eventService.findById(id);
}
/**
* 删除项目
*
* @param id
* @return
*/
@RequestMapping("/deleteById.do")
public String deleteByIds(Integer[] id) {
eventService.deleteById(id);
return "redirect:manage.do";
}
/**
* 将该项目下的参赛人员进行成绩排名
*
* @param id
*/
@RequestMapping(value = "/rank.do")
public void rank(Integer id) {
eventService.rank(id);
}
/**
* 随机分道
*
* @param id
* @return
*/
@RequestMapping(value = "/random.do")
public String random(Integer id) {
try {
eventService.random(id);
} catch (Exception e) {
return "生成失败!";
}
return "200";
}
}
SportmeetingController
package com.handy.controller;
import com.handy.domain.Broadcast;
import com.handy.domain.Event;
import com.handy.domain.Matches;
import com.handy.domain.Sportmeeting;
import com.handy.service.SportmeetingService;
import com.handy.utils.Excel.ExcelExportUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/sportmeeting")
public class SportmeetingController {
@Autowired
private SportmeetingService sportmeetingService;
/**
* 查询所有运动会开幕信息
*
* @return
*/
@RequestMapping("/findAll.do")
public ModelAndView findAll() {
ModelAndView mv = new ModelAndView();
List<Sportmeeting> sportmeetingList = sportmeetingService.findAll();
mv.addObject("sportmeeting", sportmeetingList);
mv.setViewName("sportmeeting-list");
return mv;
}
/**
* 删除运动会信息
*
* @param sId
* @return
*/
@RequestMapping("/deleteByPK.do")
public void deleteByIds(Integer[] sId) {
sportmeetingService.deleteByPK(sId);
}
/**
* 查询运动会详细信息
*
* @param sId
* @return
*/
@RequestMapping("/findDetailsBysId.do")
public ModelAndView findDetailsBysId(Integer sId) {
ModelAndView mv = new ModelAndView();
Map<String, Object> map = sportmeetingService.findDetailsBysId(sId);
Sportmeeting sportmeeting = (Sportmeeting) map.get("sportmeeting");
List<Broadcast> broadcastList = (List<Broadcast>) map.get("broadcastList");
List<Event> eventList = (List<Event>) map.get("eventList");
List<Matches> matchesList = (List<Matches>) map.get("matchesList");
mv.addObject("event", eventList);
mv.addObject("matches", matchesList);
mv.addObject("broadcast", broadcastList);
mv.addObject("sportmeeting", sportmeeting);
mv.setViewName("sportmeeting-details");
return mv;
}
/**
* 根据id查询项目
*
* @param id
* @return
*/
@RequestMapping(value = "/findBysId.do", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
@ResponseBody
public Sportmeeting findProjectById(@RequestParam(name = "id") Integer id) {
return sportmeetingService.findBysId(id);
}
/**
* 新建一场运动会
*
* @param sportmeeting
* @return
*/
@RequestMapping(value = "/insert.do", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public String insert(@RequestBody Sportmeeting sportmeeting) {
try {
sportmeetingService.insert(sportmeeting);
} catch (Exception e) {
return "新增失败!";
}
return "200";
}
/**
* 修改运动会开幕信息
*
* @param sportmeeting
* @return
*/
@RequestMapping(value = "/update.do", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public String update(@RequestBody Sportmeeting sportmeeting) {
System.out.println(sportmeeting);
try {
sportmeetingService.update(sportmeeting);
} catch (Exception e) {
return "修改失败!";
}
return "200";
}
/**
* 运动会开幕信息管理页面
*
* @return
*/
@RequestMapping("/manage.do")
public ModelAndView add() {
ModelAndView mv = new ModelAndView();
List<Sportmeeting> sportmeetingList = sportmeetingService.findAll();
mv.addObject("sportmeeting", sportmeetingList);
mv.setViewName("sportmeeting-manage");
return mv;
}
/**
* 运动会开幕信息导出
*
* @param response
* @throws Exception
*/
@RequestMapping("/export.do")
public void exportExcelStyle(HttpServletResponse response) throws Exception {
List<Sportmeeting> sportmeetings = sportmeetingService.exportExcel();
ExcelExportUtil excelExportUtil = new ExcelExportUtil();
Map<String, Object> params = new HashMap<String, Object>();
params.put("classFilePath", "/excel/template.xlsx");
params.put("styleIndex", 2);
params.put("rowIndex", 2);
params.put("objs", sportmeetings);
params.put("fileName", "s.xlsx");
excelExportUtil.export(response, params);
}
/**
* 修改运动会的状态
*
* @param Id
* @param Status
* @return
*/
@RequestMapping("updateStatus.do")
public String updateStatus(Integer Id, Boolean Status) {
sportmeetingService.updateStatus(Id, Status);
return "redirect:manage.do";
}
/**
* 本届运动会的信息管理
*
* @param sId
* @return
*/
@RequestMapping("/manageFindDetailsBysId.do")
public ModelAndView manageFindDetailsBysId(Integer sId) {
ModelAndView mv = new ModelAndView();
Map<String, Object> map = sportmeetingService.findDetailsBysId(sId);
Sportmeeting sportmeeting = (Sportmeeting) map.get("sportmeeting");
List<Broadcast> broadcastList = (List<Broadcast>) map.get("broadcastList");
List<Event> eventList = (List<Event>) map.get("eventList");
List<Matches> matchesList = (List<Matches>) map.get("matchesList");
mv.addObject("event", eventList);
mv.addObject("matches", matchesList);
mv.addObject("broadcast", broadcastList);
mv.addObject("sportmeeting", sportmeeting);
mv.setViewName("sportmeeting-manage-details");
return mv;
}
/**
* 遍历所有运动会到选择框上
*
* @return
*/
@RequestMapping(value = "/findAllSportmeetings.do", produces = "application/json; charset=utf-8")
@ResponseBody
public List<Sportmeeting> findAllSportmeetings() {
return sportmeetingService.findAllSportmeetings();
}
}
大家点赞、收藏、关注、评论啦 、点开下方卡片关注后回复 105