基于javaweb+mysql的springboot田径运动会管理系统(java+springboot+thymeleaf+html+maven+mysql)

基于javaweb+mysql的springboot田径运动会管理系统(java+springboot+thymeleaf+html+maven+mysql)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot田径运动会管理系统(java+springboot+thymeleaf+html+maven+mysql)

项目介绍

本项目分为管理员、学生两种角色, 管理员主要功能包括: 功能:登录、查看个人资料、修改密码、选手管理、赛事管理、报名管理、成绩管理、开幕式管理、闭幕式管理 学生主要功能包括: 首页, 项目管理:报名项目、查看已报名项目; 成绩查询:单个项目查询、总成绩查询、个人总积分查询; 查看开幕式; 查看闭幕式; 个人资料:查看个人资料、修改密码;

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 8.0版本;

6.是否Maven项目:是;

技术栈

  1. 后端:SpringBoot

  2. 前端:Thymeleaf+HTML+CSS+jQuery

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ 登录 管理员账号/密码:10001/123456 学生账号/密码:1001/123456

@Controller
public class GradeController {

    @Autowired
    GradeService gradeService;
    @Autowired
    SportsService sportsService;
    @Autowired
    StudentService studentService;

    //去显示成绩页面
    @RequestMapping("/admin/toGetScore")
    public String toGetScore(Model model){
        //将项目名称返回
        List list = sportsService.querySports();
        model.addAttribute("list",list);
        //一加载页面默认查出一个项目的成绩
        List scoreDefault = gradeService.selectWithStuAndSportsDefault();
        //System.out.println(scoreDefault);
        model.addAttribute("scoreDefault",scoreDefault);
        return "admin/scorelist-byOne";
    }

    //显示单项目成绩
    @RequestMapping("/admin/getScoreBySportsName")
    public String getScoreBySportsName(@RequestParam("sportsId") Integer sportsId,Model model ){
        //将项目名称返回
        List list = sportsService.querySports();
        model.addAttribute("list",list);
        //将sportsId返回
        model.addAttribute("sportsId",sportsId);
        //System.out.println(sportsId);
        List scoreList = gradeService.selectWithStuAndSports(sportsId);
        model.addAttribute("scoreDefault",scoreList);
        return "admin/scorelist-byOne";
            if (captchaId.toLowerCase().equals(parameter.toLowerCase())) {
                if (student != null && password.equals(student.getPassword())) {
                    //用户存在,登录成功
                    session.setAttribute("student", student);
                    Cookie cookie1=new Cookie("id",student.getId()+"");
                    cookie1.setMaxAge(60*60*24);
                    response.addCookie(cookie1);
                    return "redirect:student/index-stu.html";
                } else {
                    model.addAttribute("msg", "用户名或者密码错误!");
                    model.addAttribute("id",id);
                    model.addAttribute("userType",userType);
                    return "login.html";
                }
            } else {
                //验证码错误
                model.addAttribute("msg", "验证码错误!");
                model.addAttribute("id",id);
                model.addAttribute("password",password);
                model.addAttribute("userType",userType);
                return "login.html";
            }

        }
    }

    @RequestMapping("/admin/logout")
    public String logout(HttpSession session){
        session.invalidate();
        return "redirect:login";
    }

    @RequestMapping("/student/logout")
    public String stuLogout(HttpSession session){
        session.invalidate();
        return "redirect:login";
    }
}
package com.xhu.controller;

                if (admin != null && password.equals(admin.getAdminPassword())) {
                    //用户存在,登录成功
                    session.setAttribute("admin", admin);
                    return "redirect:admin/index.html";
                } else {
                    model.addAttribute("msg", "用户名或者密码错误!");
                    model.addAttribute("id",id);
                    model.addAttribute("userType",userType);
                    return "login.html";
                }
            }
            else {
                //验证码错误
                model.addAttribute("msg", "验证码错误!");
//                Cookie[] cookies=request.getCookies();
//                for(Cookie cookie:cookies){
//                    if("id".equals(cookie.getName())){
//                         value1 = cookie.getValue();
//                    }
//                    if("password".equals(cookie.getName())){
//                        value2 = cookie.getValue();
//                    }
//                }
//                model.addAttribute("id",value1);
//                model.addAttribute("password",value2);
                model.addAttribute("id",id);
                model.addAttribute("password",password);
                model.addAttribute("userType",userType);

                return "login.html";
            }

        }
        else {
            Student student = studentService.queryStuById(id);

            if (captchaId.toLowerCase().equals(parameter.toLowerCase())) {
                if (student != null && password.equals(student.getPassword())) {
                    //用户存在,登录成功
                    session.setAttribute("student", student);
                    Cookie cookie1=new Cookie("id",student.getId()+"");
                    cookie1.setMaxAge(60*60*24);
                    response.addCookie(cookie1);
                    return "redirect:student/index-stu.html";
                } else {
                    model.addAttribute("msg", "用户名或者密码错误!");
                    model.addAttribute("id",id);

@Controller
public class SportsController {

    @Autowired
    private SportsService sportsService;
    @Autowired
    private RefereeService refereeService;
    @Autowired
    private StudentService studentService;

    //分页显示运动项目
    @RequestMapping("/admin/getSports/{pn}")
    public String getStuWithJson(@PathVariable(value = "pn") Integer pn,Model model){
        PageHelper.startPage(pn,5);
        //startPage后面紧跟的这个查询就是一个分页查询
        List<Sports> sports=sportsService.querySports();
        List sportsName = sportsService.querySportsName();

        model.addAttribute("sports",sports);
        model.addAttribute("sportsName",sportsName);

        PageInfo page=new PageInfo(sports,5);
        //System.out.println(page);
        model.addAttribute("pageInfo",page);
        model.addAttribute("sign","getSports");
        return "admin/sports-list";
    }

    String sportsName;
    String sportsType;
    //分页显示运动项目----带条件
    @RequestMapping("/admin/querySportsWithCondition/{pn}")
    public String querySportsWithCondition(@RequestParam(value = "sportsName",required = false)String sportsName,
                                        @RequestParam(value = "sportsType",required = false)String sportsType,
                                        @PathVariable(value = "pn") Integer pn,
                                        Model model){
        if(sportsName!=null||sportsType!=null) {
            this.sportsName = sportsName;
            this.sportsType = sportsType;
        }
//        System.out.println(this.id+"-->"+this.gender+"-->"+this.school);
        List sportsName1 = sportsService.querySportsName();
        model.addAttribute("sportsName",sportsName1);

        model.addAttribute("sports",this.sportsName);
        model.addAttribute("sportsType",this.sportsType);

        PageHelper.startPage(pn,5);
        List<Sports> sports=sportsService.querySportsWithCondition(this.sportsName,this.sportsType);
        PageInfo page=new PageInfo(sports,5);
        model.addAttribute("pageInfo",page);

@Controller
public class LoginController {

    @Autowired
    DefaultKaptcha defaultKaptcha;

    @Autowired
    StudentService studentService;

    @Autowired
    AdminService adminService;

//    @RequestMapping("/login.html")
//    public String login(){
//        return "login";
//    }

    //获取验证码
    @RequestMapping("/getCode")
    public void defaultKaptcha(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception{
        byte[] captchaChallengeAsJpeg = null;
        ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
        try {
            //生产验证码字符串并保存到session中
            String createText = defaultKaptcha.createText();
            httpServletRequest.getSession().setAttribute("vrifyCode", createText);
            //使用生产的验证码字符串返回一个BufferedImage对象并转为byte写入到byte数组中
            BufferedImage challenge = defaultKaptcha.createImage(createText);
            ImageIO.write(challenge, "jpg", jpegOutputStream);
        } catch (IllegalArgumentException e) {
            httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        List schoolName = studentService.querySchool();
        model.addAttribute("schoolName",schoolName);

        PageHelper.startPage(pn,5);
        List scoreAll = gradeService.getScoreAll();
        PageInfo page=new PageInfo(scoreAll,5);
        model.addAttribute("pageInfo",page);
        model.addAttribute("sign","toGetScoreAll");
        model.addAttribute("signTable","toGetScoreAll");
        //System.out.println(page);
        return "admin/score-all";
    }

    String gender;
    String school;
    //查询总项目情况--带条件
    @RequestMapping("/admin/getScoreAllWithCondition/{pn}")
    public String getScoreAllWithCondition(@RequestParam(value = "school",required = false)String school,
                                   @RequestParam(value = "gender",required = false)String gender,
                                   @PathVariable(value = "pn") Integer pn,
                                   Model model){

        if(school!=null||gender!=null) {
            this.school = school;
            this.gender = gender;
        }
//        System.out.println(this.id+"-->"+this.gender+"-->"+this.school);
        List schoolName = studentService.querySchool();
        model.addAttribute("schoolName",schoolName);

        model.addAttribute("school",this.school);
        model.addAttribute("gender",this.gender);

        PageHelper.startPage(pn,5);
        List scoreAllWithCondition = gradeService.getScoreAllWithCondition(this.school, this.gender);

        PageInfo page=new PageInfo(scoreAllWithCondition,5);
        model.addAttribute("pageInfo",page);
        model.addAttribute("sign","scoreAllWithCondition");
        model.addAttribute("signTable","toGetScoreAll");
        return "admin/score-all";
    }
        return Msg.success().add("msg","退赛成功!");
    }

    @RequestMapping("/student/toGetStudent/{id}")
    public String toGetStudent(@PathVariable("id")Integer id,Model model){
        Student student = studentService.queryStuById(id);
        model.addAttribute("student",student);
        return "student/student-data";
    }

    @RequestMapping("/student/updStuWithoutPassword")
    @ResponseBody
    public Msg updStuWithoutPassword(@RequestParam("id")Integer id,
                                     @RequestParam("name")String name,
                                     @RequestParam("gender")String gender,
                                     @RequestParam("school")String school,
                                     @RequestParam("phone")String phone,
                                     @RequestParam("email")String email){
        //System.out.println(id+"--"+name+"--"+gender+"--"+school+"--"+phone+"--"+email);
        studentService.updStuWithoutPassword(name,gender,school,phone,email,id);
        return Msg.success().add("msg","修改成功!");

    }
    //去修改学生密码页面
    @RequestMapping("student/toUpdStudentPass/{id}")
    public String toUpdStudentPass(@PathVariable("id")Integer id,Model model){
        model.addAttribute("id",id);
        return "student/student-pass-upd";
    }

    //修改密码
    @RequestMapping("/student/updStudentPass")
    @ResponseBody
    public Msg updStudentPass( @RequestParam("id")Integer id,
                             @RequestParam("studentPassword")String studentPassword,
                             @RequestParam("studentPassword2")String studentPassword2){
//        System.out.println(adminId+"--"+adminPassword+"--"+adminPassword2);
        studentService.updStuWithPassword(studentPassword,id);
        return Msg.success().add("msg","修改成功!请重新登录");
    }

}
package com.xhu.controller;


    //去添加学生页面
    @RequestMapping("/admin/toAdd")
    public String toAdd(){
        return "admin/student-add";
    }

    @PostMapping("/admin/addStu")
    public String addStu(Student student) {
       // System.out.println(student);
        studentService.addStu(student);
        return "redirect:admin/getStu/100";
    }

    //去修改学生页面
    @RequestMapping("/admin/toUpd/{stuId}")
    public String toUpd(@PathVariable("stuId")String stuId,Model model){
        int id=Integer.parseInt(stuId);
        Student student = studentService.queryStuById(id);
        model.addAttribute("student",student);
        return "admin/student-update";
    }

    //修改学生信息
    @RequestMapping("/admin/updStu")
    @ResponseBody
    public Msg updStu(Student student){
       // System.out.println(student);
        studentService.updStu(student);
        return Msg.success();
    }

    @RequestMapping(value = "/admin/delStuById/{stuId}",method = RequestMethod.DELETE)
    public String delStuById(@PathVariable("stuId") String stuId){
        int id=Integer.parseInt(stuId);
        studentService.delStuById(id);
        return "redirect:admin/getStu/1";
    }

}
package com.xhu.config;

    }

    //查询总项目情况
    @RequestMapping("/admin/toGetScoreAll/{pn}")
    public String toGetScoreAll(@PathVariable(value = "pn") Integer pn,Model model){
        List schoolName = studentService.querySchool();
        model.addAttribute("schoolName",schoolName);

        PageHelper.startPage(pn,5);
        List scoreAll = gradeService.getScoreAll();
        PageInfo page=new PageInfo(scoreAll,5);
        model.addAttribute("pageInfo",page);
        model.addAttribute("sign","toGetScoreAll");
        model.addAttribute("signTable","toGetScoreAll");
        //System.out.println(page);
        return "admin/score-all";
    }

    String gender;
    String school;
    //查询总项目情况--带条件
    @RequestMapping("/admin/getScoreAllWithCondition/{pn}")
    public String getScoreAllWithCondition(@RequestParam(value = "school",required = false)String school,
                                   @RequestParam(value = "gender",required = false)String gender,
                                   @PathVariable(value = "pn") Integer pn,
                                   Model model){

        if(school!=null||gender!=null) {
            this.school = school;
            this.gender = gender;
        }
//        System.out.println(this.id+"-->"+this.gender+"-->"+this.school);
        List schoolName = studentService.querySchool();
        model.addAttribute("schoolName",schoolName);

        model.addAttribute("school",this.school);
        model.addAttribute("gender",this.gender);

        PageHelper.startPage(pn,5);
        List scoreAllWithCondition = gradeService.getScoreAllWithCondition(this.school, this.gender);

        PageInfo page=new PageInfo(scoreAllWithCondition,5);
        model.addAttribute("pageInfo",page);
        model.addAttribute("sign","scoreAllWithCondition");
        model.addAttribute("signTable","toGetScoreAll");
        return "admin/score-all";
    }

    //查询学校总分情况
    String sportsType;
    @RequestMapping("/admin/scoreAll/{pn}")
    public String scoreAll(@RequestParam(value = "sportsType",required = false)String sportsType,
    }

    String sportsName;
    String sportsType;
    //分页显示运动项目----带条件
    @RequestMapping("/student/querySportsWithCondition/{pn}")
    public String querySportsWithCondition(@RequestParam(value = "sportsName",required = false)String sportsName,
                                        @RequestParam(value = "sportsType",required = false)String sportsType,
                                        @PathVariable(value = "pn") Integer pn,
                                        Model model){
        if(sportsName!=null||sportsType!=null) {
            this.sportsName = sportsName;
            this.sportsType = sportsType;
        }
//        System.out.println(this.id+"-->"+this.gender+"-->"+this.school);
        List sportsName1 = sportsService.querySportsName();
        model.addAttribute("sportsName",sportsName1);

        model.addAttribute("sports",this.sportsName);
        model.addAttribute("sportsType",this.sportsType);

        PageHelper.startPage(pn,5);
        List<Sports> sports=sportsService.querySportsWithCondition(this.sportsName,this.sportsType);
        PageInfo page=new PageInfo(sports,5);
        model.addAttribute("pageInfo",page);
        model.addAttribute("sign","querySportsWithCondition");
        return "student/sports-list-stu";

    }

    //去显示成绩页面
    @RequestMapping("/student/toGetScore")
    public String toGetScore(Model model){
        //将项目名称返回
        List list = sportsService.querySports();
        model.addAttribute("list",list);
        //一加载页面默认查出一个项目的成绩
        List scoreDefault = gradeService.selectWithStuAndSportsDefault();
        //System.out.println(scoreDefault);
        model.addAttribute("scoreDefault",scoreDefault);
        return "student/scorelist-byOne";
    }

    //显示单项目成绩
    @RequestMapping("/student/getScoreBySportsName")
    public String getScoreBySportsName(@RequestParam("sportsId") Integer sportsId,Model model ){
        //将项目名称返回
    StudentService studentService;

    @Autowired
    AdminService adminService;

//    @RequestMapping("/login.html")
//    public String login(){
//        return "login";
//    }

    //获取验证码
    @RequestMapping("/getCode")
    public void defaultKaptcha(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception{
        byte[] captchaChallengeAsJpeg = null;
        ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
        try {
            //生产验证码字符串并保存到session中
            String createText = defaultKaptcha.createText();
            httpServletRequest.getSession().setAttribute("vrifyCode", createText);
            //使用生产的验证码字符串返回一个BufferedImage对象并转为byte写入到byte数组中
            BufferedImage challenge = defaultKaptcha.createImage(createText);
            ImageIO.write(challenge, "jpg", jpegOutputStream);
        } catch (IllegalArgumentException e) {
            httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
        //定义response输出类型为image/jpeg类型,使用response输出流输出图片的byte数组
        captchaChallengeAsJpeg = jpegOutputStream.toByteArray();
        httpServletResponse.setHeader("Cache-Control", "no-store");
        httpServletResponse.setHeader("Pragma", "no-cache");
        httpServletResponse.setDateHeader("Expires", 0);
        httpServletResponse.setContentType("image/jpeg");
        ServletOutputStream responseOutputStream =
                httpServletResponse.getOutputStream();
        responseOutputStream.write(captchaChallengeAsJpeg);
        responseOutputStream.flush();
        responseOutputStream.close();
    }

    //验证码验证
    @RequestMapping("/login")
    public String login(@RequestParam("id")Integer id,
                        @RequestParam("password") String password,
                        @RequestParam("userType") String userType,
                        HttpServletRequest request,
                        HttpServletResponse response,
                        HttpSession session,
                        Model model) {
        //获取session域中验证码
        String captchaId = (String) request.getSession().getAttribute("vrifyCode");

                return "login.html";
            }

        }
        else {
            Student student = studentService.queryStuById(id);

            if (captchaId.toLowerCase().equals(parameter.toLowerCase())) {
                if (student != null && password.equals(student.getPassword())) {
                    //用户存在,登录成功
                    session.setAttribute("student", student);
                    Cookie cookie1=new Cookie("id",student.getId()+"");
                    cookie1.setMaxAge(60*60*24);
                    response.addCookie(cookie1);
                    return "redirect:student/index-stu.html";
                } else {
                    model.addAttribute("msg", "用户名或者密码错误!");
                    model.addAttribute("id",id);
                    model.addAttribute("userType",userType);
                    return "login.html";
                }
            } else {
                //验证码错误
                model.addAttribute("msg", "验证码错误!");
                model.addAttribute("id",id);
                model.addAttribute("password",password);
                model.addAttribute("userType",userType);
                return "login.html";
            }

        }
    }

    @RequestMapping("/admin/logout")
    public String logout(HttpSession session){
        session.invalidate();
        return "redirect:login";
    }

    @RequestMapping("/student/logout")
    public String stuLogout(HttpSession session){
        session.invalidate();
        return "redirect:login";
    }
}
package com.xhu.controller;


        PageHelper.startPage(pn,5);
        List scoreBySchool = gradeService.getScoreBySchool();
        //System.out.println(scoreBySchool);
        PageInfo page=new PageInfo(scoreBySchool,5);
        //System.out.println(page);
        model.addAttribute("pageInfo",page);
        model.addAttribute("sign","getSports");
        return "admin/scoreAllBySchool";
    }

    String school;
    String gender;
    //分页显示个人成绩----带条件
    @RequestMapping("/student/getScoreBySchoolWithCondition/{pn}")
    public String getScoreBySchoolWithCondition(@RequestParam(value = "school",required = false)String school,
                                           @RequestParam(value = "gender",required = false)String gender,
                                           @PathVariable(value = "pn") Integer pn,
                                           Model model){
        if(school!=null||gender!=null) {
            this.school = school;
            this.gender = gender;
        }
//        System.out.println(this.id+"-->"+this.gender+"-->"+this.school);
        List school1 = studentService.querySchool();
        model.addAttribute("schoolName",school1);

        model.addAttribute("school",this.school);
        model.addAttribute("gender",this.gender);

        PageHelper.startPage(pn,5);
        List score = gradeService.getScoreBySchoolWithCondition(this.school, this.gender);
        PageInfo page=new PageInfo(score,5);
        model.addAttribute("pageInfo",page);
        model.addAttribute("sign","querySportsWithCondition");
        return "admin/scoreAllBySchool";

    }
}
package com.xhu.controller;


    //打开闭幕式页面
    @RequestMapping("/admin/toCeremonyClose")
    public String toCeremonyClose(Model model){
        CeremonyClose ceremonyClose = ceremonyService.getCeremonyClose();
        //System.out.println(ceremonyOpen);
        model.addAttribute("ceremonyClose",ceremonyClose);
        return "admin/ceremony-close";
    }

    //去添加闭幕式页面
    @RequestMapping("/admin/toAddCeremonyClose")
    public String toAddCeremonyClose(Model model){
        return "admin/ceremonyClose-add";
    }

    //添加闭幕式
    @RequestMapping("/admin/addCeremonyClose")
    @ResponseBody
    public Msg addCeremonyClose(CeremonyClose ceremonyClose){
        //System.out.println(ceremonyOpen);
        ceremonyService.addCeremonyClose(ceremonyClose);
        return Msg.success().add("msg","添加成功");
    }

    //去修改闭幕式页面
    @RequestMapping("/admin/toUpdCeremonyClose/{ceremonyId}")
    public String toUpdCeremonyClose(@PathVariable("ceremonyId")String ceremonyId, Model model){
        //System.out.println(ceremonyId);
        CeremonyClose ceremonyCloseById = ceremonyService.getCeremonyCloseById(ceremonyId);
        model.addAttribute("ceremonyCloseById",ceremonyCloseById);
        return "admin/ceremonyClose-upd";
    }

    //修改闭幕式
    @RequestMapping("/admin/updCeremonyClose")
    @ResponseBody
    public Msg updCeremonyOpen(CeremonyClose ceremonyClose){
        //System.out.println(ceremonyOpen);
        ceremonyService.updCeremonyClose(ceremonyClose);
        return Msg.success().add("msg","修改成功");
    }
    //删除闭幕式
    @RequestMapping(value = "/admin/delCeremonyClose/{ceremonyId}",method = RequestMethod.DELETE)
    @ResponseBody
    public Msg delCeremonyClose(@PathVariable("ceremonyId")String ceremonyId){
        ceremonyService.delCeremonyClose(ceremonyId);
        return Msg.success().add("msg","删除成功!");
package com.xhu.controller;

@Controller
public class StudentController {

    @Autowired
    private StudentService studentService;

   // @RequestMapping("/admin/getStu")
    public String getStu(Model model){
        Collection<Student> list = studentService.queryStu();
        model.addAttribute("students",list);
        return "admin/student-list";
    }

    //分页显示学生
        sportsService.addSports(sports);
        return Msg.success();
    }

    //去运动项目修改页面
    @RequestMapping("/admin/toUpdSports/{sportsId}")
    public String toUpdSports(@PathVariable("sportsId")Integer sportsId , Model model) {
        Sports sports = sportsService.querySportsById(sportsId);
        model.addAttribute("sports",sports);

        List referee = refereeService.queryReferee();
        model.addAttribute("referee",referee);

        return "admin/sports-update";
    }

    //修改运动项目
    @RequestMapping("/admin/updSports")
    @ResponseBody
    public Msg updSports(Sports sports, Model model) {
        //System.out.println(sports);
        sportsService.updSports(sports);
        return Msg.success().add("msg","修改成功!");
    }

    //删除运动项目
    @RequestMapping(value = "/admin/toDelSports/{sportsId}",method = RequestMethod.DELETE)
    @ResponseBody
    public Msg toDelSports(@PathVariable("sportsId") String sportsId){
        int sportsId2=Integer.parseInt(sportsId);
        sportsService.delSportsById(sportsId2);
        return Msg.success().add("msg","删除成功!");
    }

//     根据类型查询运动项目
//    @RequestMapping(value = "/admin/querySportsByType",method = RequestMethod.GET)
//    @ResponseBody
//    public Msg querySportsByType(@RequestParam("sportsType") String sportsType,
    public String toGetScoreAll(@PathVariable(value = "pn") Integer pn,Model model){
        List schoolName = studentService.querySchool();
        model.addAttribute("schoolName",schoolName);

        PageHelper.startPage(pn,5);
        List scoreAll = gradeService.getScoreAll();
        PageInfo page=new PageInfo(scoreAll,5);
        model.addAttribute("pageInfo",page);
        model.addAttribute("sign","toGetScoreAll");
        model.addAttribute("signTable","toGetScoreAll");
        //System.out.println(page);
        return "admin/score-all";
    }

    String gender;
    String school;
    //查询总项目情况--带条件
    @RequestMapping("/admin/getScoreAllWithCondition/{pn}")
    public String getScoreAllWithCondition(@RequestParam(value = "school",required = false)String school,
                                   @RequestParam(value = "gender",required = false)String gender,
                                   @PathVariable(value = "pn") Integer pn,
                                   Model model){

        if(school!=null||gender!=null) {
            this.school = school;
            this.gender = gender;
        }
//        System.out.println(this.id+"-->"+this.gender+"-->"+this.school);
        List schoolName = studentService.querySchool();
        model.addAttribute("schoolName",schoolName);

        model.addAttribute("school",this.school);
        model.addAttribute("gender",this.gender);

        PageHelper.startPage(pn,5);
        List scoreAllWithCondition = gradeService.getScoreAllWithCondition(this.school, this.gender);

        PageInfo page=new PageInfo(scoreAllWithCondition,5);
        model.addAttribute("pageInfo",page);
        model.addAttribute("sign","scoreAllWithCondition");
        model.addAttribute("signTable","toGetScoreAll");
        return "admin/score-all";
    }

    //查询学校总分情况
    String sportsType;
            PageInfo page=new PageInfo(scoreBySchoolAll,5);
            //System.out.println(page);
            model.addAttribute("pageInfo",page);
            model.addAttribute("sign","scoreAll");
            model.addAttribute("signTable","scoreAll");
            return "admin/score-all";
        }
        else {
            model.addAttribute("sportsType",this.sportsType);
            PageHelper.startPage(pn,5);
            List scoreBySchoolTypeAll = gradeService.getScoreBySchoolTypeAll(this.sportsType);
            PageInfo page=new PageInfo(scoreBySchoolTypeAll,5);
            //System.out.println(page);
            model.addAttribute("pageInfo",page);
            model.addAttribute("sign","scoreAll");//分页
            model.addAttribute("signTable","scoreAllBySportsType");//表格
            return "admin/score-all";
        }
    }
}
package com.xhu.controller;

@Controller
public class EntryFormController {

    @Autowired
    EntryFormService entryFormService;
    @Autowired
    StudentService studentService;
                model.addAttribute("id",id);
                model.addAttribute("password",password);
                model.addAttribute("userType",userType);
                return "login.html";
            }

        }
    }

    @RequestMapping("/admin/logout")
    public String logout(HttpSession session){
        session.invalidate();
        return "redirect:login";
    }

    @RequestMapping("/student/logout")
    public String stuLogout(HttpSession session){
        session.invalidate();
        return "redirect:login";
    }
}
package com.xhu.controller;

@Controller
public class CeremonyController {

    @Autowired
    CeremonyService ceremonyService;


            if (captchaId.toLowerCase().equals(parameter.toLowerCase())) {
                if (student != null && password.equals(student.getPassword())) {
                    //用户存在,登录成功
                    session.setAttribute("student", student);
                    Cookie cookie1=new Cookie("id",student.getId()+"");
                    cookie1.setMaxAge(60*60*24);
                    response.addCookie(cookie1);
                    return "redirect:student/index-stu.html";
                } else {
                    model.addAttribute("msg", "用户名或者密码错误!");
                    model.addAttribute("id",id);
                    model.addAttribute("userType",userType);
                    return "login.html";
                }
            } else {
                //验证码错误
                model.addAttribute("msg", "验证码错误!");
                model.addAttribute("id",id);
                model.addAttribute("password",password);
                model.addAttribute("userType",userType);
                return "login.html";
            }

        }
    }

    @RequestMapping("/admin/logout")
    public String logout(HttpSession session){
        session.invalidate();
        return "redirect:login";
    }

    @RequestMapping("/student/logout")
    public String stuLogout(HttpSession session){
        session.invalidate();
        return "redirect:login";
    }
}
package com.xhu.controller;

        }
        int stuId=Integer.parseInt(id);//得到学生id
        sportsService.updSportsNumberDes(sportsId);
        entryFormService.delEntryFormById(stuId,sportsId);
        return Msg.success().add("msg","退赛成功!");
    }

    @RequestMapping("/student/toGetStudent/{id}")
    public String toGetStudent(@PathVariable("id")Integer id,Model model){
        Student student = studentService.queryStuById(id);
        model.addAttribute("student",student);
        return "student/student-data";
    }

    @RequestMapping("/student/updStuWithoutPassword")
    @ResponseBody
    public Msg updStuWithoutPassword(@RequestParam("id")Integer id,
                                     @RequestParam("name")String name,
                                     @RequestParam("gender")String gender,
                                     @RequestParam("school")String school,
                                     @RequestParam("phone")String phone,
                                     @RequestParam("email")String email){
        //System.out.println(id+"--"+name+"--"+gender+"--"+school+"--"+phone+"--"+email);
        studentService.updStuWithoutPassword(name,gender,school,phone,email,id);
        return Msg.success().add("msg","修改成功!");

    }
    //去修改学生密码页面
    @RequestMapping("student/toUpdStudentPass/{id}")
    public String toUpdStudentPass(@PathVariable("id")Integer id,Model model){
        model.addAttribute("id",id);
        return "student/student-pass-upd";
    }

    //修改密码
    @RequestMapping("/student/updStudentPass")
    @ResponseBody
    public Msg updStudentPass( @RequestParam("id")Integer id,
                             @RequestParam("studentPassword")String studentPassword,
                             @RequestParam("studentPassword2")String studentPassword2){
//        System.out.println(adminId+"--"+adminPassword+"--"+adminPassword2);
        studentService.updStuWithPassword(studentPassword,id);
        return Msg.success().add("msg","修改成功!请重新登录");
    }

}
package com.xhu.controller;
    @RequestMapping("/admin/updAdminPass")
    @ResponseBody
    public Msg updAdminPass( @RequestParam("adminId")Integer adminId,
                             @RequestParam("adminPassword")String adminPassword,
                             @RequestParam("adminPassword2")String adminPassword2){
//        System.out.println(adminId+"--"+adminPassword+"--"+adminPassword2);
        adminService.updAdminPass(adminPassword,adminId);
        return Msg.success().add("msg","修改成功!请重新登录");
    }

}
package com.xhu.controller;

@Controller
public class StuSportsController {

    @Autowired
    private SportsService sportsService;
    @Autowired
    private RefereeService refereeService;
    @Autowired
    private StudentService studentService;
    @Autowired
    GradeService gradeService;
    @Autowired
    CeremonyService ceremonyService;

    //分页显示运动项目
    @RequestMapping("/student/getSports/{pn}")
    public String getStuWithJson(@PathVariable(value = "pn") Integer pn, Model model, HttpServletRequest request){
        PageHelper.startPage(pn,5);
        //startPage后面紧跟的这个查询就是一个分页查询
        List<Sports> sports=sportsService.querySports();
        List sportsName = sportsService.querySportsName();

        model.addAttribute("sports",sports);
        model.addAttribute("sportsName",sportsName);

        PageInfo page=new PageInfo(sports,5);
    public String getStu(Model model){
        Collection<Student> list = studentService.queryStu();
        model.addAttribute("students",list);
        return "admin/student-list";
    }

    //分页显示学生
    @RequestMapping("/admin/getStu/{pn}")
    public String getStuWithJson(@PathVariable(value = "pn") Integer pn,Model model){
        //这不是分页查询
        //引入PageHelper分页插件
        //在查询之前只需要调用,传入页码,以及每页的大小
        PageHelper.startPage(pn,5);
        //startPage后面紧跟的这个查询就是一个分页查询
        List<Student> students=studentService.queryStu();
        List schooltype = studentService.querySchool();
//        System.out.println(school);
        model.addAttribute("schooltype",schooltype);
        //使用PageInfo包装查询后的结果,只需要将page交给页面就行了
        //封装了详细的分页信息,包括我们查询出来的数据,传入连续显示的页数
        PageInfo page=new PageInfo(students,5);
        //System.out.println(page);
        model.addAttribute("pageInfo",page);
        model.addAttribute("sign","getStu");
        return "admin/student-list";
    }

    Integer id;
    String gender;
    String school;
    //分页显示学生----带条件
    @RequestMapping("/admin/queryStuWithCondition/{pn}")
    public String queryStuWithCondition(@RequestParam(value = "school",required = false)String school,
                                        @RequestParam(value = "gender",required = false)String gender,
                                        @RequestParam(value = "id",required = false)Integer id,
                                        @PathVariable(value = "pn") Integer pn,
                                        Model model){
        //System.out.println(id+"-->"+gender+"-->"+school);
        if(id!=null||gender!=null||school!=null) {
            this.id = id;
            this.gender = gender;
            this.school = school;
        }
//        System.out.println(this.id+"-->"+this.gender+"-->"+this.school);
        List schooltype = studentService.querySchool();
                           @PathVariable(value = "pn") Integer pn,
                           Model model){
        //System.out.println(this.sportsType);
        if(sportsType!=null)
        this.sportsType=sportsType;

        List schoolName = studentService.querySchool();
        model.addAttribute("schoolName",schoolName);

        if(this.sportsType==""||this.sportsType==null){
            PageHelper.startPage(pn,5);
            List scoreBySchoolAll = gradeService.getScoreBySchoolAll();
            PageInfo page=new PageInfo(scoreBySchoolAll,5);
            //System.out.println(page);
            model.addAttribute("pageInfo",page);
            model.addAttribute("sign","scoreAll");
            model.addAttribute("signTable","scoreAll");
            return "admin/score-all";
        }
        else {
            model.addAttribute("sportsType",this.sportsType);
            PageHelper.startPage(pn,5);
            List scoreBySchoolTypeAll = gradeService.getScoreBySchoolTypeAll(this.sportsType);
            PageInfo page=new PageInfo(scoreBySchoolTypeAll,5);
            //System.out.println(page);
            model.addAttribute("pageInfo",page);
            model.addAttribute("sign","scoreAll");//分页
            model.addAttribute("signTable","scoreAllBySportsType");//表格
            return "admin/score-all";
        }
    }
}
package com.xhu.controller;


@Controller
public class StudentController {

    @Autowired
    private StudentService studentService;

   // @RequestMapping("/admin/getStu")
    public String getStu(Model model){
        Collection<Student> list = studentService.queryStu();
        model.addAttribute("students",list);
        return "admin/student-list";
    }

    //分页显示学生
    @RequestMapping("/admin/getStu/{pn}")
    public String getStuWithJson(@PathVariable(value = "pn") Integer pn,Model model){
        //这不是分页查询
        //引入PageHelper分页插件
        //在查询之前只需要调用,传入页码,以及每页的大小
        PageHelper.startPage(pn,5);
        //startPage后面紧跟的这个查询就是一个分页查询
        List<Student> students=studentService.queryStu();
        List schooltype = studentService.querySchool();
//        System.out.println(school);
        model.addAttribute("schooltype",schooltype);
        //使用PageInfo包装查询后的结果,只需要将page交给页面就行了
        //封装了详细的分页信息,包括我们查询出来的数据,传入连续显示的页数
        PageInfo page=new PageInfo(students,5);
        //System.out.println(page);
        model.addAttribute("pageInfo",page);
        model.addAttribute("sign","getStu");
        return "admin/student-list";
    }

    Integer id;
    String gender;
    String school;
    //分页显示学生----带条件
    @RequestMapping("/admin/queryStuWithCondition/{pn}")
    public String queryStuWithCondition(@RequestParam(value = "school",required = false)String school,
                                        @RequestParam(value = "gender",required = false)String gender,

    @PostMapping("/admin/addStu")
    public String addStu(Student student) {
       // System.out.println(student);
        studentService.addStu(student);
        return "redirect:admin/getStu/100";
    }

    //去修改学生页面
    @RequestMapping("/admin/toUpd/{stuId}")
    public String toUpd(@PathVariable("stuId")String stuId,Model model){
        int id=Integer.parseInt(stuId);
        Student student = studentService.queryStuById(id);
        model.addAttribute("student",student);
        return "admin/student-update";
    }

    //修改学生信息
    @RequestMapping("/admin/updStu")
    @ResponseBody
    public Msg updStu(Student student){
       // System.out.println(student);
        studentService.updStu(student);
        return Msg.success();
    }

    @RequestMapping(value = "/admin/delStuById/{stuId}",method = RequestMethod.DELETE)
    public String delStuById(@PathVariable("stuId") String stuId){
        int id=Integer.parseInt(stuId);
        studentService.delStuById(id);
        return "redirect:admin/getStu/1";
    }

}
package com.xhu.config;

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值