Java项目:ssm教务管理系统

发布于:2023-01-12 ⋅ 阅读:(574) ⋅ 点赞:(0)

作者主页:夜未央5788

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

随着中国教育体制的不断改革与完善,学校的学生教师管理员等对互联网的使用也越来越频繁。随着学生与教师数量的不断增多,教务管理的容量,安全性,便捷性显得尤为重要。传统的人工管理的劣势也慢慢显现出来,但是其中的一优点还需要继续采纳,所以传统的人工与计算机的结合成为了目前的主流。对此我开发了一套基于SSM框架的教务管理系统。
该系统采用的是Spring、SpringMVC、Mybatis、Shiro、LayUI、腾讯云。

该项目分为管理员、教师、学生三种角色。
主要实现了用户的登录注册,公告的浏览,选课操作,不同的管理员对不同信息的管理,教师对课程评分,教师结课等功能。该系统我在完成基础功能的前提下完成了上线。
 

关键词:教务;教务管理系统;云服务器;JAVA;SSM

环境需要

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. 后端:Spring+SpringMVC+Mybatis+Shiro

2. 前端:JSP+LayUI+Echarts+jQuery

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;

3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ 登录
管理员:admin 123456
学生:zhangsan 123456

教师:wangliu 123456

运行截图

 

 

 

 

 

 

相关代码

基础课程控制器

package com.jubilantz.controller;

import com.jubilantz.entity.EasBaseCourse;
import com.jubilantz.entity.EasClass;
import com.jubilantz.services.EasBaseCourseService;
import com.jubilantz.utils.PageUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author JubilantZ
 * @Date: 2021/4/21 21:40
 */
@Controller
@RequestMapping("/easBaseCourse")
public class EasBaseCourseController {
    @Autowired
    private EasBaseCourseService easBaseCourseService;

    @RequestMapping("/index")
    public String index() throws Exception {
        return "system/baseCourse/index";
    }

    @RequestMapping("/list")
    @ResponseBody
    public Map<String,Object> list(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "10") Integer limit,
                                   EasBaseCourse easBaseCourse) throws Exception{
        Map<String,Object> map = new HashMap<>();
        int count = easBaseCourseService.getCount();
//        System.out.println("总行数:"+count);
        PageUtil pageUtil = new  PageUtil(page,limit);
        List<EasBaseCourse> list = easBaseCourseService.getList(easBaseCourse,pageUtil);

        map.put("count",count);
        map.put("data",list);
        map.put("code",0);
        map.put("msg","");

        return map;
    }

    @RequestMapping("/baseCourseAddForm")
    public String baseCourseAddForm() throws Exception {
        return "system/baseCourse/baseCourseAddForm";
    }

    @RequestMapping(value = "/addBaseCourse",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> addBaseCourse(EasBaseCourse easBaseCourse) throws Exception{
        Map<String,Object> map = new HashMap<>();

//        System.out.println("我是基本课程名称:"+easBaseCourse.getCoursename());
//        System.out.println("我是基本课程简介:"+easBaseCourse.getSynopsis());
        List<EasBaseCourse> list = easBaseCourseService.findBaseCourseName(easBaseCourse.getCoursename());

        if (list.size() != 0){
            map.put("msg","基本课程已存在");
            map.put("result",false);
        }else if(easBaseCourse.getCoursename().length() <= 0){
            map.put("msg","课程名称不能为空");
            map.put("result",false);
        }else{
            //课程为null也可以添加 待完善
            easBaseCourseService.addBaseCourse(easBaseCourse);
            map.put("msg","添加成功");
            map.put("result",true);
        }
        return map;
    }

    @RequestMapping("/batchDeleteBaseCourse")
    @ResponseBody
    @RequiresPermissions("basecourse:delete")
    public Map<String, Object> batchDeleteBaseCourse(Integer[] ids) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        easBaseCourseService.batchDeleteBaseCourse(ids);
        map.put("msg","删除成功");
        map.put("result",true);
        return map;
    }

    @RequestMapping(value = "/getBaseCourseView")
    @ResponseBody
    public EasBaseCourse getBaseCourseView(Integer id) throws Exception {
        return easBaseCourseService.getBaseCourseView(id);
    }


    @RequestMapping(value = "/editBaseCourse",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> editBaseCourse(EasBaseCourse easBaseCourse) throws Exception{
        Map<String, Object> map = new HashMap<>();

        easBaseCourseService.updateBaseCourse(easBaseCourse);

        map.put("result",true);
        return map;
    }

    @RequestMapping("/search")
    @ResponseBody
    public List<EasBaseCourse> search() throws Exception{
        return easBaseCourseService.getAll();
    }

}

课程控制器

package com.jubilantz.controller;

import com.jubilantz.entity.EasClass;
import com.jubilantz.services.EasClassService;
import com.jubilantz.utils.PageUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author JubilantZ
 * @Date: 2021/4/15 12:35
 */
@Controller
@RequestMapping("/easClass")
public class EasClassController {
    @Autowired
    private EasClassService easClassService;

    @RequestMapping("/search")
    @ResponseBody
    public List<EasClass> search() throws Exception{
        return easClassService.getAll();
    }

    @RequestMapping("/index")
    public String index() throws Exception {
        return "system/class/index";
    }

    @RequestMapping("/list")
    @ResponseBody
    public Map<String,Object> list(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "10") Integer limit,
                                   EasClass easClass) throws Exception{
        Map<String,Object> map = new HashMap<>();
        int count = easClassService.getCount();
//        System.out.println("总行数:"+count);
        PageUtil pageUtil = new  PageUtil(page,limit);
        List<EasClass> list = easClassService.getList(easClass,pageUtil);

        map.put("count",count);
        map.put("data",list);
        map.put("code",0);
        map.put("msg","");

        return map;
    }

    @RequestMapping("/classForm")
    public String classForm() throws Exception {
        return "system/class/classForm";
    }

    @RequestMapping(value = "/addClass",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> addClass(EasClass easClass) throws Exception{
        Map<String,Object> map = new HashMap<>();

//        System.out.println("我是基本课程名称:"+easBaseCourse.getCoursename());
//        System.out.println("我是基本课程简介:"+easBaseCourse.getSynopsis());
        List<EasClass> list = easClassService.findClassName(easClass.getClasses());

        if (list.size() != 0){
            map.put("msg","班级已存在");
            map.put("result",false);
        }else if(easClass.getClasses().length() <= 0){
            map.put("msg","班级不能为空");
            map.put("result",false);
        }else{
            //课程为null也可以添加 待完善
            easClassService.addClass(easClass);
            map.put("msg","添加成功");
            map.put("result",true);
        }
        return map;
    }

    @RequestMapping("/batchDeleteClass")
    @ResponseBody
    @RequiresPermissions("class:delete")
    public Map<String, Object> batchDeleteClass(Integer[] ids) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
//        System.out.println("前台传来的为:"+ids);
        easClassService.batchDeleteClass(ids);
        map.put("msg","删除成功");
        map.put("result",true);
        return map;
    }

    @RequestMapping(value = "/getClassView")
    @ResponseBody
    public EasClass getClassView(Integer id) throws Exception {
        return easClassService.getClassView(id);
    }

    @RequestMapping(value = "/editClass",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> editClass(EasClass easClass) throws Exception{
        Map<String, Object> map = new HashMap<>();

        easClassService.updateClass(easClass);

        map.put("result",true);
        return map;
    }
}

图表控制器

package com.jubilantz.controller;

import com.jubilantz.entity.EasBaseCourse;
import com.jubilantz.services.EasBaseCourseService;
import com.jubilantz.services.EasCourseService;
import com.jubilantz.services.EasStudentService;
import com.jubilantz.services.EasTeacherService;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author JubilantZ
 * @Date: 2021/4/29 18:29
 */
@RequestMapping("/easEchart")
@Controller
public class EasEchartController {
    @Autowired
    private EasStudentService easStudentService;
    @Autowired
    private EasTeacherService easTeacherService;
    @Autowired
    private EasCourseService easCourseService;
    @Autowired
    private EasBaseCourseService easBaseCourseService;

    @RequestMapping("/scoreEchart")
    public String scoreEchart(){
        return "echarts/ScoreEcharts";
    }

    @RequestMapping("/peopleEchart")
    public String peopleEchart(){
        return "echarts/peopleEcharts";
    }

    @RequestMapping("/getAllStuAndTea")
    @ResponseBody
    public Map<String,Object> getAllStuAndTea(){
        Map<String, Object> map = new HashMap<>();

        int totalStu = easStudentService.getTotal();
        int totalTea = easTeacherService.getTotal();

//        System.out.println("教师总行数---->"+totalTea);

        map.put("totalStu",totalStu);
        map.put("totalTea",totalTea);
        map.put("code",0);
        map.put("msg","我是返回的内容");

        return map;
    }

    @RequestMapping("/getAllSex")
    @ResponseBody
    public Map<String,Object> getAllSex(){
        Map<String, Object> map = new HashMap<>();

        int totalMan = easStudentService.getTotalSex("男");
        int totalWoman = easStudentService.getTotalSex("女");
        map.put("totalMan",totalMan);
        map.put("totalWoman",totalWoman);
        map.put("code",0);
        map.put("msg","我是返回的内容");

        return map;
    }


    @RequestMapping("/getAllClassScore")
    @ResponseBody
    public Map<String,Object> getAllClassScore(Integer baseCourseId) throws Exception {
        Map<String, Object> map = new HashMap<>();
//        System.out.println("基础课程id为:"+baseCourseId);

        //根据基本课程id 和是否结束 来获取每门课程 合格条数 和不合格条数
        EasBaseCourse easBaseCourse = easBaseCourseService.getBaseCourseById(baseCourseId);
        String coursename = easBaseCourse.getCoursename();
        int totalPass = easCourseService.getTotalPass(baseCourseId);
        int totalNoPass = easCourseService.getTotalNoPass(baseCourseId);
//        if(totalPass != 0 && totalNoPass !=0 ){
        if(totalPass != 0 || totalNoPass != 0 ){
            map.put("coursename",coursename);
            map.put("totalPass",totalPass);
            map.put("totalNoPass",totalNoPass);
//            System.out.println("通过人数:"+totalPass);
//            System.out.println("未通过人数:"+totalNoPass);
//            System.out.println("coursename:"+coursename);

        }else {
            map.put("coursename",coursename);
            map.put("totalPass",0);
            map.put("totalNoPass",0);

//            System.out.println("通过人数:"+totalPass);
//            System.out.println("未通过人数:"+totalNoPass);
        }

        return map;
    }
}

登录控制器

package com.jubilantz.controller;

import com.jubilantz.entity.EasPermission;
import com.jubilantz.entity.EasUser;
import com.jubilantz.mappers.EasPermissionMapper;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException;
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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author JubilantZ
 * @Date: 2021/4/8 15:40
 */
@Controller
@RequestMapping("/easLogin")
public class EasLoginController {
    @Autowired
    private EasPermissionMapper easPermissionMapper;

    @RequestMapping("/main")
    public String main() throws Exception{
        return "main";
    }
//    @RequestMapping("/home")
//    public String home() throws Exception{
//        return "system/home/homePage";
//    }

    @RequestMapping("/success")
    @ResponseBody
    public Map<String,Object> success(HttpSession session) throws Exception{
        Map<String,Object> map = new HashMap<>();
        map.put("code",0);
        EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();
        session.setAttribute(Constants.LOGIN_USER,easUser);

        List<EasPermission> list = easPermissionMapper.getPersByUserId(easUser.getId());
        session.setAttribute(Constants.LOGIN_USER_PERS,list);

        return map;
    }

    @RequestMapping(value = "/login",method = RequestMethod.GET)
    public String login() throws Exception{
        return "login";
    }

    /**
     * post方式的login方式什么时候调用?
     * 身份认证失败的时候会自动调用
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> login(HttpServletRequest request) throws Exception{
        Map<String,Object> map = new HashMap<>();
//        System.out.println("认证失败了吧!来我这了吧");
        String exceptionName = request.getAttribute("shiroLoginFailure").toString();

        if (exceptionName.equals(UnknownAccountException.class.getName())){
            map.put("code",1);
            map.put("msg","用户名不正确");
            return map;
        }else if(exceptionName.equals(IncorrectCredentialsException.class.getName())){
            map.put("code",2);
            map.put("msg","密码不正确");
            return map;
        }else if (exceptionName.equals("randomCodeError")){
            map.put("code",3);
            map.put("msg","验证码不正确");
            return map;
        }
        return null;
    }


}

主控制器

package com.jubilantz.controller;

import com.jubilantz.entity.EasNotice;
import com.jubilantz.entity.EasUser;
import com.jubilantz.services.EasNoticeService;
import com.jubilantz.services.EasUserService;
import com.jubilantz.utils.PageUtil;
import org.apache.shiro.SecurityUtils;
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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author JubilantZ
 * @Date: 2021/4/28 20:25
 */
@RequestMapping("/main")
@Controller
public class EasMainController {
    @Autowired
    private EasNoticeService easNoticeService;

    @Autowired
    private EasUserService easUserService;

    @RequestMapping("/homePage")
    public String homePage() throws Exception{
        return "system/home/homePage";
    }

//    @RequestMapping(value="/getNotice",method = RequestMethod.GET)
//    @ResponseBody
//    public Map<String,Object> getNotice(@RequestParam(defaultValue = "1") Integer page,
//                                        @RequestParam(defaultValue = "2") Integer limit,
//                                        EasNotice easNotice) throws Exception {
//        Map<String,Object> map = new HashMap<>();
//
        System.out.println("模糊查询的内容为:"+easNotice.getContent());
//
//        EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();//获取EasUser对象
//
//        //判断用户有没有 角色 有就返回角色id 没有就返回1000
//
//        Integer roleId = easUserService.findRoleIdByUserId(easUser.getId());
//
//
//        String strRoleId =roleId +"";
        System.out.println("roleId:"+roleId);
        System.out.println("strRoleId:"+strRoleId);
//        PageUtil pageUtil = new  PageUtil(page,limit);
//
//        //没有角色
//        if(roleId == null || !(strRoleId.length() >0 || roleId == 2)){//全体可见的部分公告,没要求
//            //type = 1 全员可见 type = 2 教师可见  type = 3 草稿  管理员可见
//            int type = 1;
//            int count = easNoticeService.getCountByTypeAndEasNotice(type,easNotice);
//            pageUtil.setTotal(count);
//            pageUtil.setCount(limit);
//            int totalPage = pageUtil.getTotalPage();
            System.out.println("总页数为"+totalPage);
//
//            List<EasNotice> list = easNoticeService.getNoticeListByTypeAndEasNotice(type,easNotice,pageUtil);
//
//            map.put("totalPage",totalPage);
//            map.put("count",count);
//            map.put("data",list);
//            map.put("code",0);
//            map.put("msg","");
//        }else if(roleId == 3){//增加教师公告可见
//            int type = 2;
//            int count = easNoticeService.getCountByTypeAndEasNotice(type,easNotice);
//            List<EasNotice> list = easNoticeService.getNoticeListByTypeAndEasNotice(type,easNotice,pageUtil);
//            pageUtil.setTotal(count);
//            pageUtil.setCount(limit);
//            int totalPage = pageUtil.getTotalPage();
            System.out.println("总页数为"+totalPage);
//
//            map.put("totalPage",totalPage);
//            map.put("count",count);
//            map.put("data",list);
//            map.put("code",0);
//            map.put("msg","");
//        }else{//管理员可见全部
//            int type = 3;
//            int count = easNoticeService.getCountByTypeAndEasNotice(type,easNotice);
//            List<EasNotice> list = easNoticeService.getNoticeListByTypeAndEasNotice(type,easNotice,pageUtil);
//
//            pageUtil.setTotal(count);
//            pageUtil.setCount(limit);
//            int totalPage = pageUtil.getTotalPage();
//
//            map.put("totalPage",totalPage);
//
//            map.put("count",count);
//            map.put("data",list);
//            map.put("code",0);
//            map.put("msg","");
//        }
//
//        return map;
//    }

    @RequestMapping(value="/getNotice",method = RequestMethod.GET)
    @ResponseBody
    public Map<String,Object> getNotice(@RequestParam(defaultValue = "1") Integer page,
                                        @RequestParam(defaultValue = "2") Integer limit,
                                        EasNotice easNotice) throws Exception {
        Map<String,Object> map = new HashMap<>();
//        System.out.println("模糊查询的内容为:"+easNotice.getContent());
        EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();//获取EasUser对象
        //判断用户有没有 角色 有就返回角色id 没有就返回1000

        List<Integer> rolelist = easUserService.findRoleIdByUserId2(easUser.getId());


        PageUtil pageUtil = new  PageUtil(page,limit);
        if(rolelist.size() >= 2){
            int type = 3;
            int count = easNoticeService.getCountByTypeAndEasNotice(type,easNotice);
            List<EasNotice> list = easNoticeService.getNoticeListByTypeAndEasNotice(type,easNotice,pageUtil);

            pageUtil.setTotal(count);
            pageUtil.setCount(limit);
            int totalPage = pageUtil.getTotalPage();

            map.put("totalPage",totalPage);

            map.put("count",count);
            map.put("data",list);
            map.put("code",0);
            map.put("msg","");
        }else {
            if(rolelist.size() == 0 || rolelist.get(0) == 2){
                //type = 1 全员可见 type = 2 教师可见  type = 3 草稿  管理员可见
                int type = 1;
                int count = easNoticeService.getCountByTypeAndEasNotice(type,easNotice);
                pageUtil.setTotal(count);
                pageUtil.setCount(limit);
                int totalPage = pageUtil.getTotalPage();
//            System.out.println("总页数为"+totalPage);

                List<EasNotice> list = easNoticeService.getNoticeListByTypeAndEasNotice(type,easNotice,pageUtil);

                map.put("totalPage",totalPage);
                map.put("count",count);
                map.put("data",list);
                map.put("code",0);
                map.put("msg","");
            }else if(rolelist.get(0) == 3) {
                int type = 2;
                int count = easNoticeService.getCountByTypeAndEasNotice(type,easNotice);
                List<EasNotice> list = easNoticeService.getNoticeListByTypeAndEasNotice(type,easNotice,pageUtil);
                pageUtil.setTotal(count);
                pageUtil.setCount(limit);
                int totalPage = pageUtil.getTotalPage();
//            System.out.println("总页数为"+totalPage);

                map.put("totalPage",totalPage);
                map.put("count",count);
                map.put("data",list);
                map.put("code",0);
                map.put("msg","");
            }else{
                int type = 3;
                int count = easNoticeService.getCountByTypeAndEasNotice(type,easNotice);
                List<EasNotice> list = easNoticeService.getNoticeListByTypeAndEasNotice(type,easNotice,pageUtil);

                pageUtil.setTotal(count);
                pageUtil.setCount(limit);
                int totalPage = pageUtil.getTotalPage();

                map.put("totalPage",totalPage);

                map.put("count",count);
                map.put("data",list);
                map.put("code",0);
                map.put("msg","");
            }
        }

        return map;
    }


    //点击查看具体通知
    @RequestMapping(value="/lookNotice")
    public ModelAndView look(Integer id){
        ModelAndView modelAndView = new ModelAndView();
//        System.out.println("我是通知id:"+id);

        List<EasNotice> list = easNoticeService.getNoticeById(id);
        modelAndView.addObject("noticeList",list);
        modelAndView.setViewName("system/notice/homeNotice");

        return modelAndView;
    }


}

如果你也想学习本系统,下面领取。关注并回复:176ssm


网站公告

今日签到

点亮在社区的每一天
去签到