SSM框架(spring+springmvc+mybatis)+Mysql实现的高校运动会管理系统(角色分为管理员和普通用户 功能包含普通学生老师参赛、开幕广播

2022-07-24 15:51:33 浏览数 (1)

@TOC

SSM框架(spring springmvc mybatis) Mysql

本系统为了解决高校运动会复杂流程的管理,通过分学生、教师、管理员端,实现了管理员对器材、用户、项目、院系、班级、学生、教师、成绩等管理,普通用户端可以查看运动会项目信息、可以选择参赛,极大的提升了运动会线下组织和沟通人员的繁琐。

实现功能截图

登录

请添加图片描述请添加图片描述

管理员端:

用户管理:

请添加图片描述请添加图片描述

学生信息

请添加图片描述请添加图片描述

教师信息

请添加图片描述请添加图片描述

班级信息

请添加图片描述请添加图片描述

院系信息

请添加图片描述请添加图片描述

器材归还登记

请添加图片描述请添加图片描述

器材借还记录

请添加图片描述请添加图片描述

器材采购管理

请添加图片描述请添加图片描述

器材借用登记

请添加图片描述请添加图片描述

运动会广播信息

请添加图片描述请添加图片描述

运动会开幕信息

请添加图片描述请添加图片描述

运动器材信息

请添加图片描述请添加图片描述

开幕管理

请添加图片描述请添加图片描述

广播管理

请添加图片描述请添加图片描述

比赛成绩信息

请添加图片描述请添加图片描述

比赛项目信息

请添加图片描述请添加图片描述

成绩管理

请添加图片描述请添加图片描述

角色管理

请添加图片描述请添加图片描述

反馈日记

请添加图片描述请添加图片描述

访问日记

请添加图片描述请添加图片描述

个人信息

请添加图片描述请添加图片描述

项目管理

请添加图片描述请添加图片描述

学生教师角色

个人信息

请添加图片描述请添加图片描述

我的参赛

请添加图片描述请添加图片描述

项目列表

请添加图片描述请添加图片描述

运动会广播信息

请添加图片描述请添加图片描述

运动会开幕信息

请添加图片描述请添加图片描述

运动会器材信息

请添加图片描述请添加图片描述

主页

请添加图片描述请添加图片描述

系统功能

本会议管理系统实现了以下功能:

1、登录

2、个人信息管理

分为管理员和普通用户(学生、老师)

管理员:

3、学生信息

4、教师管理

5、班级管理

6、院系信息

7、运动会广播信息、开幕信息、器材信息

8、广播管理

9、开幕管理

10、器材借还登记

11、器材归还记录

12、器材采购管理

13、比赛成绩信息

14、比赛项目信息

15、成绩管理

16、用户管理

17、角色管理

18、反馈日记、访问日记

学生、老师:

19、运动会广播信息、开幕信息、运动器材信息

20、项目列表、我的参赛

使用技术

数据库:mysql

开发工具:Idea(Myeclispe、Eclipse也可以)

知识点:SSM框架(spring springmvc mybatis)

代码

实体类

Student.java

代码语言:java复制
package com.handy.domain;

import com.handy.utils.Excel.ExcelAttribute;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 公众号:程序猿矛盾体
 * 微信:Code2Life2
 */
@Data
@NoArgsConstructor
public class Student {

    /**
     * id
     */
    @ExcelAttribute(sort = 0)
    private Integer sId;
    /**
     * 学号
     */
    @ExcelAttribute(sort = 1)
    private String sNo;
    /**
     * 姓名
     */
    @ExcelAttribute(sort = 2)
    private String sName;
    /**
     * 性别
     */
    @ExcelAttribute(sort = 3)
    private Boolean sGender;

    private String sGenderStr;
    /**
     * 班级号
     */
    @ExcelAttribute(sort = 4)
    private Integer sClassid;
    /**
     * 电话号码
     */
    @ExcelAttribute(sort = 5)
    private String sPhone;
    /**
     * 电子邮箱
     */
    @ExcelAttribute(sort = 6)
    private String sEmail;
    /**
     * 身份证号
     */
    @ExcelAttribute(sort = 7)
    private String sIdcard;

    private String oSNo;

    private String Password;

    private List<Integer> RoleList;

    private Boolean Status;

    private Classes classes;

    private User user;

    public Student(String sNo, String sName, Boolean sGender, Integer sClassid, String sPhone, String sEmail, String sIdcard) {
        this.sNo = sNo;
        this.sName = sName;
        this.sGender = sGender;
        this.sClassid = sClassid;
        this.sPhone = sPhone;
        this.sEmail = sEmail;
        this.sIdcard = sIdcard;
    }

    public String getSGenderStr() {
        if (sGender == false)
            sGenderStr = "女";
        else if (sGender == true)
            sGenderStr = "男";
        return sGenderStr;
    }

    public void setSGender(Boolean sGender) {
        if (sGenderStr == "男")
            sGender = true;
        else if (sGenderStr == "女")
            sGender = false;
        this.sGender = sGender;
    }

}

Sportmeeting.java

代码语言:java复制
package com.handy.domain;

import com.alibaba.fastjson.annotation.JSONField;
import com.handy.utils.Date.DateUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;
/**
 * 公众号:程序猿矛盾体
 * 微信:Code2Life2
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Sportmeeting {
    /**
     * 运动会id
     */
    private Integer sId;
    /**
     * 运动会名称
     */
    private String sName;
    /**
     * 运动会主题
     */
    private String sTheme;
    /**
     * 举办地点
     */
    private String sPlace;
    /**
     * 举办时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date sDate;
    private String sDateStr;
    /**
     * 开始时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date sStarttime;
    private String sStarttimeStr;
    /**
     * 结束时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date sEndtime;
    private String sEndtimeStr;
    /**
     * 描述
     */
    private String sDescription;
    /**
     * 运动会开启关闭状态
     */
    private Boolean sStatus;


    private List<Broadcast> broadcast;

    public String getSDateStr() {
        if (sDate != null)
            sDateStr = DateUtils.date2String(sDate, "yyyy-MM-dd HH:mm:ss");
        return sDateStr;
    }

    public String getSStarttimeStr() {
        if (sStarttime != null)
            sStarttimeStr = DateUtils.date2String(sStarttime, "yyyy-MM-dd HH:mm:ss");
        return sStarttimeStr;
    }

    public String getSEndtimeStr() {
        if (sEndtime != null)
            sEndtimeStr = DateUtils.date2String(sEndtime, "yyyy-MM-dd HH:mm:ss");
        return sEndtimeStr;
    }

}

service层

StudentServiceImpl.java

代码语言:java复制
package com.handy.service.impl;

import com.handy.dao.*;
import com.handy.domain.Borrow;
import com.handy.domain.Matches;
import com.handy.domain.Student;
import com.handy.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 公众号:程序猿矛盾体
 * 微信:Code2Life2
 */
@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Autowired
    private MatchesMapper matchesMapper;

    @Autowired
    private BorrowMapper borrowMapper;

    @Autowired
    private RoleUserMapper roleUserMapper;

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private PasswordEncoder passwordEncoder;

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public List<Student> findAll() {
        return studentMapper.findAll();
    }

    @Override
    public Student selectByPK(Integer id) {
        return studentMapper.selectByPK(id);
    }


    @Override
    public Map<String, Object> findDetailsBysId(Integer sId) {
        Map<String, Object> map = new HashMap<>();

        Student student = studentMapper.selectByPK(sId);
        map.put("student", student);

        String no = studentMapper.selectsNoBysId(sId);
        List<Matches> matchesList = matchesMapper.selectBymNo(no);
        map.put("matchesList", matchesList);

        List<Borrow> borrowList = borrowMapper.selectBybNo(no);
        map.put("borrowList", borrowList);

        return map;

    }


    @Override
    public void deleteByPK(String[] sNo) {
        if (sNo != null && sNo.length != 0) {
            for (String id : sNo) {
                studentMapper.deleteByPK(id);
            }
        }
    }

    @Override
    public List<Student> exportExcel() {
        return studentMapper.findAll();
    }

    @Override
    public void insert(Student student) {
        String newPassword = passwordEncoder.encode(student.getPassword());
        userMapper.insert(student.getSNo(), newPassword, student.getStatus());
        List<Integer> roleList = student.getRoleList();
        if (roleList != null && roleList.size() != 0) {
            for (Integer role : roleList) {
                roleUserMapper.insert(role, student.getSNo());
            }
        }
        studentMapper.insert(student);
    }

    @Override
    public void update(Student student) {
        String newPassword = passwordEncoder.encode(student.getPassword());
        userMapper.updatePW(newPassword, student.getOSNo());
        userMapper.updateUstatus(student.getOSNo(), student.getStatus());

        roleUserMapper.delete(student.getOSNo());
        List<Integer> roleList = student.getRoleList();
        if (roleList != null && roleList.size() != 0) {
            for (Integer role : roleList) {
                roleUserMapper.insert(role, student.getOSNo());
            }
        }

        studentMapper.update(student);
        userMapper.updatePK(student.getSNo(), student.getOSNo());
    }

    @Override
    public Student findById(Integer id) {

        return studentMapper.findById(id);
    }

    @Override
    public List<Student> findAllStudents() {

        return studentMapper.findAllStudents();
    }

    @Override
    public void importExcel(List<Student> students) {
        studentMapper.importExcel(students);
    }
}

SportmeetingServiceImpl.java

代码语言:java复制
package com.handy.service.impl;

import com.handy.dao.BroadcastMapper;
import com.handy.dao.EventMapper;
import com.handy.dao.MatchesMapper;
import com.handy.dao.SportmeetingMapper;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 公众号:程序猿矛盾体
 * 微信:Code2Life2
 */
@Service
public class SportmeetingServiceImpl implements SportmeetingService {

    @Autowired
    private SportmeetingMapper sportmeetingMapper;

    @Autowired
    private BroadcastMapper broadcastMapper;

    @Autowired
    private EventMapper eventMapper;

    @Autowired
    private MatchesMapper matchesMapper;

    @Override
    public List<Sportmeeting> findAll() {
        return sportmeetingMapper.findAll();
    }

    @Override
    public void deleteByPK(Integer[] sId) {
        if (sId != null && sId.length != 0) {
            for (Integer id : sId) {
                sportmeetingMapper.deleteByPK(id);
            }
        }
    }

    @Override
    public Map<String, Object> findDetailsBysId(Integer sId) {
        Map<String, Object> map = new HashMap<>();
        Sportmeeting sportmeeting = sportmeetingMapper.selectByPK(sId);
        map.put("sportmeeting", sportmeeting);
        List<Broadcast> broadcastList = broadcastMapper.selectBybSportmeetingid(sId);
        map.put("broadcastList", broadcastList);
        List<Event> eventList = eventMapper.findBysId(sId);
        map.put("eventList", eventList);
        List<Matches> matchesList = matchesMapper.findBysId(sId);
        map.put("matchesList", matchesList);
        return map;
    }


    @Override
    public void insert(Sportmeeting sportmeeting) {
        sportmeetingMapper.insert(sportmeeting);
    }

    @Override
    public List<Sportmeeting> exportExcel() {
        return sportmeetingMapper.exportExcel();
    }

    @Override
    public void updateStatus(Integer id, Boolean status) {
        sportmeetingMapper.updateStatus(id, status);
    }

    @Override
    public Sportmeeting findBysId(Integer id) {

        return sportmeetingMapper.findBysId(id);
    }

    @Override
    public Integer update(Sportmeeting sportmeeting) {
        return sportmeetingMapper.updateByPKSelective(sportmeeting);
    }

    @Override
    public List<Sportmeeting> findAllSportmeetings() {

        return sportmeetingMapper.findAllSportmeetings();
    }
}

controller层

StudentController.java

代码语言:java复制
package com.handy.controller;

import com.handy.annotation.FormToken;
import com.handy.domain.Borrow;
import com.handy.domain.Matches;
import com.handy.domain.Student;
import com.handy.service.StudentService;
import com.handy.utils.Excel.ExcelExportUtil;
import com.handy.utils.Excel.ExcelImportUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.security.RolesAllowed;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 公众号:程序猿矛盾体
 * 微信:Code2Life2
 */
@RolesAllowed("ADMIN")
@Controller
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentService studentService;


//    /**
//     * 查询所有学生信息,通过PageHelper进行封装
//     *
//     * @param page
//     * @param size
//     * @return
//     * @throws Exception
//     */
//    @RequestMapping("/findAll.do")
//    public ModelAndView findAll(@RequestParam(name = "page", required = true, defaultValue = "1") Integer page, @RequestParam(name = "size", required = true, defaultValue = "50") Integer size) throws Exception {
//        ModelAndView mv = new ModelAndView();
//        List<Student> studentList = studentService.findAll(page, size);
//        PageInfo pageInfo = new PageInfo(studentList);
//        mv.addObject("pageInfo", pageInfo);
//        mv.setViewName("student-list");
//        return mv;
//    }


    /**
     * 查询所有学生信息
     *
     * @return
     */
    @FormToken(save = true)//添加session 防止表单重复提交,在进入列表的时候添加session,在保存项目的时候通过识别session就能防止表单重复提交
    @RequestMapping("/findAll.do")
    public ModelAndView findAll() {
        ModelAndView mv = new ModelAndView();
        List<Student> studentList = studentService.findAll();
        mv.addObject("student", studentList);
        mv.setViewName("student-list");
        return mv;
    }


    /**
     * 删除学生信息
     *
     * @param sNo
     * @return
     */
    @RequestMapping("/deleteByPK.do")
    public String deleteByIds(String[] sNo) {
        studentService.deleteByPK(sNo);
        return "redirect:findAll.do";
    }

    /**
     * 查询学生详细信息
     *
     * @param sId
     * @return
     */
    @RequestMapping("/findDetailsBysId.do")
    public ModelAndView findDetailsBysId(Integer sId) {
        ModelAndView mv = new ModelAndView();
        Map<String, Object> map = studentService.findDetailsBysId(sId);
        Student student = (Student) map.get("student");
        List<Matches> matchesList = (List<Matches>) map.get("matchesList");
        List<Borrow> borrowList = (List<Borrow>) map.get("borrowList");
        mv.addObject("borrow", borrowList);
        mv.addObject("matches", matchesList);
        mv.addObject("student", student);
        mv.setViewName("student-details");
        return mv;
    }

    /**
     * 根据id查询学生信息
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/findById.do", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    @ResponseBody
    public Student findById(@RequestParam(name = "id") Integer id) {
        return studentService.findById(id);
    }

    /**
     * 插入学生信息
     *
     * @param student
     * @return
     */
    @RequestMapping(value = "/insert.do", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String insert(@RequestBody Student student) {
        try {
            studentService.insert(student);
        } catch (Exception e) {
            return "新增失败!";
        }
        return "200";
    }

    /**
     * 修改学生信息
     *
     * @param student
     * @return
     */
    @RequestMapping(value = "/update.do", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String update(@RequestBody Student student) {
        try {
            studentService.update(student);
        } catch (Exception e) {
            return "修改失败!";
        }
        return "200";
    }

    /**
     * 遍历所有学生信息到选择框里
     *
     * @return
     */
    @RequestMapping(value = "/findAllStudents.do", produces = "application/json; charset=utf-8")
    @ResponseBody
    public List<Student> findAllStudents() {
        return studentService.findAllStudents();
    }

    /**
     * 导出学生信息到Excel
     *
     * @param response
     * @throws Exception
     */
    @RequestMapping("/exportToExcel.do")
    public void exportExcelStyle(HttpServletResponse response) throws Exception {
        List<Student> students = studentService.exportExcel();
        ExcelExportUtil excelExportUtil = new ExcelExportUtil();
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("classFilePath", "excel/template.xlsx");
        params.put("styleIndex", 1);
        params.put("rowIndex", 2);
        params.put("objs", students);
        params.put("fileName", "学生表.xlsx");
        excelExportUtil.export(response, params);
    }


    @RequestMapping("/uploadExcel")
    public String fileUpload(MultipartFile uploadFile, Model model){
        try {
            ExcelImportUtil<Student> excelImportUtil=new ExcelImportUtil<>();
            List<Student> students = excelImportUtil.excelImportUtil(uploadFile.getInputStream(), Student.class, 1);
            studentService.importExcel(students);
            model.addAttribute("result","上传成功");
        }catch (Exception e){
            e.printStackTrace();
            model.addAttribute("result","上传失败");
        }
        return "uploadsuccess";
    }
    
}

SportmeetingController.java

代码语言:java复制
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;
/**
 * 公众号:程序猿矛盾体
 * 微信:Code2Life2
 */
@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();
    }

}

0 人点赞