基于SSM框架的教务管理系统

前言:

教务管理系统是一种基于计算机技术的信息管理系统,主要用于学校、教育机构等管理教务事务。其功能包括但不限于:

主要分为三类角色:管理员、教师和学生

  1. 系统管理:包括用户管理、角色管理、权限管理、通知管理等。

  2. 信息管理:包括学生信息、教师信息、基本课程管理、班级信息等。

  3. 课程管理:包括课程信息(管理员)。

  4. 信息报表:包括成绩报表、人数报表。

教务管理系统的好处是提高了工作效率,减轻了管理人员的工作负担,方便了学生和教师的信息查询与交流,同时也提高了教育教学的质量

项目结构control层介绍:

Constants:
package com.jubilantz.controller;

public interface Constants {
    public static final String LOGIN_USER = "login_user";

    public static final String LOGIN_USER_PERS = "user_pers";

    public static final String VALIDATE_CODE = "validateCode";

    public static final String RANDOM_CODE = "randomCode";

    public static final String CODE_ERROR = "randomCodeError";

    //在个人资料位置用到过 数据库更改会有一点影响
    public static final String STUDENT = "学生";

    public static final String TEACHER = "教师";

}
EasBaseCourseController:
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 awei
 * @Date: 2023/5/20 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();
    }

}
EasClassController:
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 awei
 * @Date: 2023/5/23 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;
    }
}
EasCourseController:
package com.jubilantz.controller;

import com.jubilantz.entity.EasCourse;
import com.jubilantz.entity.EasStudent;
import com.jubilantz.entity.EasTeacher;
import com.jubilantz.entity.EasUser;
import com.jubilantz.mappers.EasCourseMapper;
import com.jubilantz.services.EasCourseService;
import com.jubilantz.services.EasStudentService;
import com.jubilantz.services.EasTeacherService;
import com.jubilantz.utils.PageUtil;
import org.apache.shiro.SecurityUtils;
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 javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author awei
 * @Date: 2023/5/21 21:40
 */
@Controller
@RequestMapping("/easCourse")
public class EasCourseController {
    @Autowired
    private EasCourseService easCourseService;
    @Autowired
    private EasTeacherService easTeacherService;
    @Autowired
    private EasStudentService easStudentService;


    @RequestMapping("/adminIndex")
    @RequiresPermissions("course:adminIndex")
    public String adminIndex() throws Exception {
        return "system/course/adminCourseIndex";
    }
    @RequestMapping("/studentIndex")
    @RequiresPermissions("course:studentIndex")
    public String studentIndex() throws Exception {
        return "system/course/studentCourseIndex";
    }
    @RequestMapping("/teacherIndex")
    @RequiresPermissions("course:teacherIndex")
    public String teacherIndex() throws Exception {
        return "system/course/teacherCourseIndex";
    }

    @RequestMapping("/courseAddForm")
    public String courseAddForm() throws Exception{
        return "system/course/courseAddForm";
    }

    @RequestMapping("/courseEditForm")
    public String courseEditForm() throws Exception{
        return "system/course/courseEditForm";
    }

    @RequestMapping("/getCourseList")
    @ResponseBody
    public Map<String,Object> getCourseList(@RequestParam(defaultValue = "1") Integer page,
                                            @RequestParam(defaultValue = "10") Integer limit,
                                            EasCourse easCourse) throws Exception{
        Map<String,Object> map = new HashMap<>();
        int count = easCourseService.getCount();
//        System.out.println("总行数:"+count);
        PageUtil pageUtil = new  PageUtil(page,limit);
        List<EasCourse> list = easCourseService.getList(easCourse,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 = "/addCourse",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> addCourse(EasCourse easCourse) throws Exception{
        Map<String,Object> map = new HashMap<>();

//        System.out.println("课程id:"+easCourse.getBaseCourseId());
//        System.out.println("教师id:"+easCourse.gettId());

        int res = 0;
        //查询是否有课程对应老师
        List<EasCourse> list = easCourseService.findCourseByBaseCourseIdAndTeacherId(easCourse.getBaseCourseId(),easCourse.gettId());

        if(easCourse.gettId() == null || easCourse.getBaseCourseId() == null){
            map.put("msg","课程名称和教师姓名不能为空");
            map.put("result",false);;
        } else if (list.size() != 0){
            //判断老师是否已经选择该课程
            map.put("msg","课程已存在");
            map.put("result",false);;
        }
        else if(easCourse.getId() == null || easCourse.getId().equals("")){
            try {
                res = easCourseService.addCourse(easCourse);
            } catch (Exception e) {
                e.printStackTrace();
//                System.out.println("添加失败!");
                map.put("msg","添加失败");
                map.put("result",false);;
            }
            if (res > 0){
                map.put("msg","添加成功");
                map.put("result",true);
            }else {
                map.put("msg", "添加失败");
                map.put("result", false);
            }
        }else{
            map.put("msg","添加失败,ID已经存在,请联系管理员");
            map.put("result",false);
        }

        return map;
    }

    @RequestMapping(value = "/getCourseById")
    @ResponseBody
    public EasCourse getCourseById(Integer id) throws Exception {
        EasCourse easCourse = easCourseService.getCourseById(id);

//        System.out.println("课程id为:"+id);
//        System.out.println("根据id查到的课程名称为:"+easCourse.getCourseName());

        return easCourse;
    }

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

//        System.out.println("id到底是不是null:"+easCourse.getId());
//        System.out.println("开始日期:"+easCourse.getStartDate());
//        System.out.println("结束日期:"+easCourse.getEndDate());

        if(easCourse.getId() != null){
            easCourseService.updateCourseById(easCourse);
//                easCourseMapper.updateDate(easCourse.getId(),startDate,endDate);

            map.put("result",true);
        }else{
            map.put("result",false);
        }

        return map;
    }


    @RequestMapping("/batchDeleteCourse")
    @ResponseBody
    @RequiresPermissions("course:adminDelete")
    public Map<String, Object> batchDeleteCourse(Integer[] ids) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        try{
            easCourseService.batchDeleteCourse(ids);
            map.put("msg","删除成功");
            map.put("result",true);
        }catch (Exception e){
            e.printStackTrace();
            map.put("result",false);
        }

        return map;
    }

    /**
     * 返回教师自己教的课程列表
     */
    @ResponseBody
    @RequestMapping(value="/getMyCourseList")
    public Map<String, Object> getMyCourseList(@RequestParam(defaultValue = "1") Integer page,
                                               @RequestParam(defaultValue = "10") Integer limit) {
        Map<String,Object> map = new HashMap<>();
        //获取用户信息
        EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();//获取EasUser对象
        String username = easUser.getUsername();
//        System.out.println("教师用户名为:"+username);
        EasTeacher easTeacher = easTeacherService.findTeacherByUsername(username);
        if (easTeacher.getUsername() == null || easTeacher.getUsername().equals("")){
            map.put("code",1);
            map.put("msg","您还没有教授课程");
        }else{
//            System.out.println("教师id为:"+easTeacher.getId());
            int count = easCourseService.getCountBytId(easTeacher.getId());

            PageUtil pageUtil = new  PageUtil(page,limit);
            List<EasCourse> list = easCourseService.getCourseListBytId(easTeacher.getId(),pageUtil);

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

        return map;
    }


    @RequestMapping(value="/complete")
    @ResponseBody
    public Map<String, Object> complete(EasCourse easCourse) {
        Map<String, Object> map = new HashMap<>();
        if(easCourse.getComplete() == 1){
            map.put("code",1);
            map.put("msg","课程已结束,无需再结束");

        }else{
            int res = easCourseService.completeCourse(easCourse);
            if (res > 0) {
                map.put("code",0);
            }else{
                map.put("code",2);
                map.put("msg","出错了");
            }
        }

        return map;
    }

    /**
     * 返回可选课程列表(可选:人数未满、课程开始时间在当前时间之后)
     * @param page
     * @param limit
     * @param isAll
     * @param searchKey
     * @return
     */
    @RequestMapping(value="/choiceList")
    @ResponseBody
    public Map<String, Object> getCourseChoiceList(@RequestParam(defaultValue = "1") Integer page,
                                      @RequestParam(defaultValue = "10") Integer limit,
                                      @RequestParam(defaultValue="1") int isAll,
                                      @RequestParam(defaultValue="")String searchKey) throws Exception {
        Map<String, Object> map = new HashMap<>();

        EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();//获取EasUser对象
        String username = easUser.getUsername();
//        System.out.println("教师用户名为:"+username);
        EasStudent easStudent = easStudentService.getStudentByUsername(username);
        if (easStudent.getUsername() == null || easStudent.getUsername().equals("")){
            map.put("code",1);
            map.put("msg","目前还没有选课信息");
        }else{
            PageUtil pageUtil = new PageUtil(page,limit);
            int sId = easStudent.getId();
            int count = easCourseService.getTotalItemsCountBySid(isAll, searchKey, sId);

            List<EasCourse> list = easCourseService.getCourseListBySid(isAll, searchKey, sId,pageUtil);

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

        return map;
    }

}
EasEchartController:
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;
    }
}
EasLoginController:
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;
    }


}
EasMainController:
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;
    }


}
EasNoticeController:
package com.jubilantz.controller;

import com.jubilantz.entity.EasNotice;
import com.jubilantz.services.EasNoticeService;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author JubilantZ
 * @Date: 2021/4/27 11:35
 */
@RequestMapping("/easNotice")
@Controller
public class EasNoticeController {
    @Autowired
    private EasNoticeService easNoticeService;

    @RequestMapping("/index")
    @RequiresPermissions("notice:query")
    public String index() throws Exception{
        return "system/notice/adminNoticeList";
    }

    @ResponseBody
    @RequestMapping("/list")
    public Map<String, Object> getNoticeList(
                                @RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10") Integer limit,
                                @RequestParam(defaultValue="")String searchKey) throws Exception {
        Map<String,Object> map = new HashMap<>();
        //一共三个权限 获取全部的行数
        int type = 3;
        int count = easNoticeService.getCountByType(type,searchKey);

        PageUtil pageUtil = new  PageUtil(page,limit);
        List<EasNotice> list = easNoticeService.getNoticeListByType(type,searchKey,pageUtil);


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

        return map;
    }

    @RequestMapping("/look")
    public ModelAndView showNotice(){
        return new ModelAndView("system/notice/notice");
    }

    @RequestMapping("/addPage")
    public ModelAndView toAddPage() {
        return new ModelAndView("system/notice/noticeAdd");
    }


    @RequestMapping("/addNotice")
    @ResponseBody
    public Map<String, Object> addNotice(@RequestParam(defaultValue="2")Integer opType, EasNotice easNotice) throws Exception {
        Map<String, Object> map = new HashMap<>();
//        System.out.println("通知id:"+easNotice.getId());
//        System.out.println("opType为:"+opType);
//        System.out.println("content为:"+easNotice.getContent());

        int res = 0;
        //opType等于0是添加 1是更新
        if (opType == 0) {
            try {
                res = easNoticeService.addNotice(easNotice);
            } catch (Exception e) {
//                System.out.println("添加失败!");
                map.put("result",false);
            }
            if (res > 0){
                map.put("result",true);
            }else{
                map.put("result",false);
            }

        } else if (opType == 1) {
            res = easNoticeService.updateNotice(easNotice);
            if (res > 0) {
                map.put("result",true);
            }else{
                map.put("result",false);
            }

        };

        return map;
    }

    @ResponseBody
    @RequestMapping("/deleteNotice")
    public Map<String, Object> deleteNotice(EasNotice easNotice) {
        Map<String, Object> map = new HashMap<>();
        if (easNoticeService.deleteNotice(easNotice) > 0) {
            map.put("result",true);
            map.put("msg","删除成功");
        }else {
            map.put("result",false);
            map.put("msg","删除失败");
        }
        return map;
    }

    /**
     * 批量删除通知
     * @param nIds
     * @return
     */
    @ResponseBody
    @RequestMapping("/deleteList")
    public Map<String, Object> deleteNoticeList(String nIds) {
        Map<String, Object> map = new HashMap<>();
        List<Integer> list = new ArrayList<Integer>();
        try {
            String[] ids = nIds.split(",");
            for (String id: ids) {
                list.add(Integer.parseInt(id));
            }
            if (easNoticeService.deleteNoticeList(list) > 0) {
                map.put("result",true);
                map.put("msg","批量删除成功");
            }else {
                map.put("result",false);
                map.put("msg","批量删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            map.put("result",false);
            map.put("msg","批量删除失败");
        }
        return map;
    }

    @ResponseBody
    @RequestMapping(value="/uploadImg")
    public String uploadImg(MultipartFile file, HttpServletRequest request) throws IOException {
        System.out.println("comming!");
        String path = request.getSession().getServletContext().getRealPath("/images");
        System.out.println("path>>"+path);
        //获取上传图片的名称
        String fileName = file.getOriginalFilename();
        System.out.println("fileName>>"+fileName);
//        //获取图片的后缀 例:.jpg
//        fileName = fileName.substring(fileName.lastIndexOf("."), fileName.length());
//        System.out.println("fileName1>>"+fileName);
//        //生成图片名称
//        fileName = System.currentTimeMillis() + fileName; //System.currentTimeMillis()产生一个当前的毫秒 +文件后缀 例.jpg
        System.out.println("fileName2>>"+fileName);
        File dir = new File(path, fileName);
        System.out.println("File>>"+dir);
        if(!dir.exists()){
            dir.mkdirs();
        }
//      MultipartFile自带的解析方法
        file.transferTo(dir);

        String jsonStr = "{\"code\":0,\"msg\":\"\",\"count\":" + null + ",\"data\":" + "{\"src\":\"" + "/images/" + fileName + "\"}" + "}";

        return jsonStr;
    }
}
EasPermissionController:
package com.jubilantz.controller;

import com.jubilantz.entity.EasPermission;
import com.jubilantz.mappers.EasPermissionMapper;
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.ResponseBody;

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

@Controller
@RequestMapping("/easPermission")
public class EasPermissionController {
    @Autowired
    private EasPermissionMapper easPermissionMapper;

    @RequestMapping("/index")
    @RequiresPermissions("permission:query")
    public String index() throws Exception{
        return "system/permission/index";
    }

    @RequestMapping("/parentList")
    @ResponseBody
    public List<EasPermission> parentList() {
        return easPermissionMapper.getParentPers();
    }

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

        map.put("code",0);
        map.put("msg",null);
        map.put("data",easPermissionMapper.getAll());

        return map;
    }
}
EasRegisterController:
package com.jubilantz.controller;

import com.jubilantz.entity.EasUser;
import com.jubilantz.services.EasRegisterService;
import com.jubilantz.services.EasUserService;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.crypto.hash.SimpleHash;
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.ResponseBody;

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

/**
 * @Author JubilantZ
 * @Date: 2021/4/24 17:06
 */
@RequestMapping("/easRegister")
@Controller
public class EasRegisterController {
    @Autowired
    private EasRegisterService easRegisterService;

    @Autowired
    private EasUserService easUserService;

    @RequestMapping("/registerForm")
    public String registerForm(){
        return "registerForm";
    }

    @RequestMapping(value = "/registerUser",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> registerUser(HttpServletRequest request) throws Exception{
        Map<String, Object> map = new HashMap<>();
        //获取页面输入的新旧密码
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String password2 = request.getParameter("password2");

        String regex = "^(?!([a-zA-Z]+|\\d+)$)[a-zA-Z\\d]{6,20}$";

        boolean matches = password.matches(regex);

//        System.out.println("页面输入的用户名为:"+username);
//        System.out.println("页面输入的密码为:"+password);

        List<EasUser> list = easUserService.findUserName(username);
        if(list.size() > 0){
            map.put("code",1);
            map.put("msg","用户名已存在,请重新输入");
        }else if(password.length() <= 0 || password2.length() <= 0 || username.length() <= 0){
            map.put("code",1);
            map.put("msg","用户名密码不能为空,请重新输入");
        }else if(!password.equals(password2)){
            map.put("code",1);
            map.put("msg","两次输入密码不一致,请重新输入");
        }else if(!matches){
            map.put("code",1);
            map.put("msg","密码必须包含字母、数字且长度为6-20位");
        }else if(matches){
            //由密码和用户名组成MD5加密  用户名为盐值
//            Md5Hash Md5Hash = new Md5Hash(password, username);
//            System.out.println("我是MD5Hash"+Md5Hash);
            String algorithmName = "MD5";//加密算法
            Object source = password;//要加密的密码
            Object salt = username;//盐值,一般都是用户名或者userid,要保证唯一
            int hashIterations = 1;//加密次数

            SimpleHash simpleHash = new SimpleHash(algorithmName,source,salt,hashIterations);
//            System.out.println("我是SimpleHash:"+simpleHash);

            EasUser easUser = new EasUser();
            easUser.setUsername(username);
            easUser.setPassword(simpleHash.toString());
            easUser.setSalt(username);
            easUser.setLocked("0");

            easUserService.addUser(easUser);

            map.put("code",0);
        }else{
            map.put("code",1);
            map.put("msg","注册失败,请联系管理员邮箱1260298750@qq.com!!!");
        }

        return map;
    }


}
EasRoleController:
package com.jubilantz.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jubilantz.entity.EasBaseCourse;
import com.jubilantz.entity.EasRole;
import com.jubilantz.mappers.EasRoleMapper;
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;

@Controller
@RequestMapping("/easRole")
public class EasRoleController {
    @Autowired
    private EasRoleMapper easRoleMapper;

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

    @RequestMapping("/index")
    @RequiresPermissions("role:query")
    public String index() throws Exception{
        return "system/role/index";
    }

    @RequestMapping("/rolePers")
    @ResponseBody
    public List<Long> rolePers(Integer id) throws Exception {
        return easRoleMapper.getPerIdsByRoleId(id);
    }

    @RequestMapping("/assignPers")
    @ResponseBody
    public Map<String,Object> assignPers(Integer roleId, String persIds) throws Exception{
        Map<String,Object> map = new HashMap<>();
        easRoleMapper.deleteRolePermissions(roleId);
        easRoleMapper.addRolePermissions(roleId,persIds.split(","));
        return map;
    }

    @RequestMapping("/list")
    @ResponseBody
    public Map<String,Object> list(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "10") Integer limit,
                                   EasRole easRole) throws Exception {
        Map<String,Object> map = new HashMap<>();

        int count = easRoleMapper.getCount();
        PageUtil pageUtil = new  PageUtil(page,limit);

        map.put("code",0);
        map.put("msg",null);
        map.put("data",easRoleMapper.getList(easRole,pageUtil));
        map.put("count",count);

        return map;
    }


    @RequestMapping("/roleForm")
    public String roleForm() throws Exception {
        return "system/role/roleForm";
    }

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

//        System.out.println("角色名称:"+easRole.getName());
//        System.out.println("角色是否可用:"+easRole.getAvailable());

        List<EasRole> list = easRoleMapper.findRoleName(easRole.getName());

        if (list.size() != 0){
            map.put("msg","角色已存在");
            map.put("result",false);
        }else if(easRole.getName().length() <= 0){
            map.put("msg","角色名称不能为空");
            map.put("result",false);
        }else{
            //课程为null也可以添加 待完善
            easRoleMapper.addRole(easRole);
            map.put("msg","添加成功");
            map.put("result",true);
        }
        return map;
    }

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

    @RequestMapping(value = "/getRoleView")
    @ResponseBody
    public EasRole getRoleView(Integer id) throws Exception {
        return easRoleMapper.getRoleView(id);
    }

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

        easRoleMapper.updateBaseCourse(easRole);

        map.put("result",true);
        return map;
    }
}
EasScoreController:
package com.jubilantz.controller;

import com.alibaba.fastjson.JSON;
import com.jubilantz.entity.*;
import com.jubilantz.services.EasScoreService;
import com.jubilantz.services.EasStudentService;
import com.jubilantz.services.EasTeacherService;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author JubilantZ
 * @Date: 2021/4/25 20:14
 */
@RequestMapping("/easScore")
@Controller
public class EasScoreController {
    @Autowired
    private EasScoreService easScoreService;
    @Autowired
    private EasStudentService easStudentService;
    @Autowired
    private EasTeacherService easTeacherService;

    //教师查看选我课的学生成绩列表 进行打分
    @RequestMapping("/scoreIndex")
    public String scoreIndex() throws Exception {
        return "system/score/studentScoreIndex";
    }

    //学生查看我的成绩页面
    @RequestMapping("/myScoreIndex")
    public String myScoreIndex() throws Exception {
        return "system/score/myScoreIndex";
    }

    //教师查看我的学生选课信息
    @RequestMapping("/myStudentIndex")
    public String myStudentIndex() throws Exception {
        return "system/score/myStudentIndex";
    }

    /**
     * 学生选课
     * @param courseId
     * @return
     * @throws Exception
     */
    @RequestMapping("/choiceCourse")
    @ResponseBody
    public Map<String, Object> choiceCourse(@RequestParam(defaultValue="")Integer courseId) throws Exception {
        Map<String, Object> map = new HashMap<>();
        if (courseId != null) {
            //获取学生信息
            EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();//获取EasUser对象
            String username = easUser.getUsername();
            EasStudent easStudent = easStudentService.getStudentByUsername(username);

//            System.out.println("学生用户名为:"+username);

            if (easStudent.getUsername() == null || easStudent.getUsername().equals("")){
                map.put("result",false);
                map.put("msg","出错了!");
            }else {

                EasScore easScore = new EasScore();
                easScore.setsId(easStudent.getId());
                easScore.setcId(courseId);

                //使用Date创建日期对象
                Date nowDate = new Date();

                //获取当前课程的开始日期
                Date startDate = easScoreService.getStartDateByCourseId(courseId);

                if(nowDate.getTime() > startDate.getTime()){
                    map.put("result",false);
                    map.put("msg","已经开课,无法选课!");
                }else{
                    int res = easScoreService.choiceCourse(easScore);

                    if (res > 0) {
                        map.put("result",true);
                        map.put("msg","选课成功!");
                    }else {
                        map.put("result",false);
                        map.put("msg","人数已满,选课失败!");
                    }
                }
//
//                int res = easScoreService.choiceCourse(easScore);
//
//                if (res > 0) {
//                    map.put("result",true);
//                    map.put("msg","选课成功!");
//                }else {
//                    map.put("result",false);
//                    map.put("msg","人数已满,选课失败!");
//                }
            }
        }else {
            map.put("result",false);
            map.put("msg","选课失败,请联系管理员!");
        }

        return map;
    }

    /**
     * 学生退课
     * @param courseId
     * @return
     * @throws Exception
     */
    @RequestMapping("/outCourse")
    @ResponseBody
    public Map<String, Object> outCourse(@RequestParam(defaultValue="")Integer courseId) throws Exception {
        Map<String, Object> map = new HashMap<>();

        if (courseId != null) {

            EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();//获取EasUser对象
            String username = easUser.getUsername();
            EasStudent easStudent = easStudentService.getStudentByUsername(username);

            if (easStudent.getUsername() == null || easStudent.getUsername().equals("")){
                map.put("result",false);
                map.put("msg","出错了!");
            }else{
                EasScore easScore = new EasScore();
                easScore.setsId(easStudent.getId());
                easScore.setcId(courseId);

                //使用Date创建日期对象
                Date nowDate=new Date();
//                System.out.println("当前的日期是------>"+nowDate);

                /**
                 * 创建格式化时间日期类
                 *构造入参String类型就是我们想要转换成的时间形式
                 */
//                SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//                SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
//                System.out.println("格式化后的时间------->"+format.format(date));
//                String ds=df.format(d);

                //获取当前课程的开始日期
                Date startDate = easScoreService.getStartDateByCourseId(courseId);

//                System.out.println("开始日期为------>"+startDate);

                if(nowDate.getTime() > startDate.getTime()){
                    map.put("result",false);
                    map.put("msg","已经开课,无法退课!");
                }else{
                    int res = easScoreService.deleteScore(easScore);

                    if (res > 0) {
                        map.put("result",true);
                        map.put("msg","退选成功!");
                    }else {
                        map.put("result",false);
                        map.put("msg","退课失败!");
                    }
                }

//                //删除成绩信息时 ,同时将课程表中该课程的人数-1 该方法在service中
//                int res = easScoreService.deleteScore(easScore);
//
//                if (res > 0) {
//                    map.put("result",true);
//                    map.put("msg","退选成功!");
//                }else {
//                    map.put("result",false);
//                    map.put("msg","退课失败!");
//                }
            }

        }else {
            map.put("result",false);
            map.put("msg","退课失败,请联系管理员!");
        }

        return map;
    }

    /**
     * 返回选修了我(教师)已结束课程的学生列表
     * @param page
     * @param limit
     * @param baseCourseId
     * @param classId
     * @return
     * @throws Exception
     */
    @RequestMapping("/stuScoreList")
    @ResponseBody
    public Map<String, Object> stuScoreList(@RequestParam(defaultValue = "1") Integer page,
                                            @RequestParam(defaultValue = "10") Integer limit,
                                            @RequestParam(required=false) Integer baseCourseId,
                                            @RequestParam(required=false) Integer classId) throws Exception {
    //    @requestparam(required = false)不传值后台也不会报错

        Map<String, Object> map = new HashMap<>();
        //获取当前教师id
        EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();//获取EasUser对象
        String username = easUser.getUsername();
        EasTeacher easTeacher = easTeacherService.findTeacherByUsername(username);

        //获取行数
        int count = easStudentService.getEndingCountBytIdandcId(easTeacher.getId(),baseCourseId,classId);
        PageUtil pageUtil = new  PageUtil(page,limit);


        List<EasStudent> list = easStudentService.getStudentScoreListByTid(easTeacher.getId(),baseCourseId,classId,pageUtil);

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

        return map;
    }

    /**
     * 获取我的学生选课信息
     * @param page
     * @param limit
     * @param baseCourseId
     * @param classId
     * @return
     * @throws Exception
     */
    @RequestMapping("/stuSelectCourseList")
    @ResponseBody
    public Map<String, Object> stuSelectCourseList(@RequestParam(defaultValue = "1") Integer page,
                                            @RequestParam(defaultValue = "10") Integer limit,
                                            @RequestParam(required=false) Integer baseCourseId,
                                            @RequestParam(required=false) Integer classId) throws Exception {
        //    @requestparam(required = false)不传值后台也不会报错

        Map<String, Object> map = new HashMap<>();
        //获取当前教师id
        EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();//获取EasUser对象
        String username = easUser.getUsername();
        EasTeacher easTeacher = easTeacherService.findTeacherByUsername(username);

        //获取行数
        int count = easStudentService.getCountBytIdandcId(easTeacher.getId(),baseCourseId,classId);
        PageUtil pageUtil = new  PageUtil(page,limit);


        List<EasStudent> list = easStudentService.getStudentSelectCourseListByTid(easTeacher.getId(),baseCourseId,classId,pageUtil);

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

        return map;
    }


    @RequestMapping("/updateScore")
    @ResponseBody
    public Map<String, Object> updateScore(EasScore easScore) throws Exception {
        Map<String, Object> map = new HashMap<>();

        int res = easScoreService.updateScore(easScore);
        if (res > 0){
            map.put("result",true);
            map.put("msg","评分成功");
        }else {
            map.put("result",false);
            map.put("msg","课程还未结束,评分失败");
        }

        return map;
    }

    @RequestMapping("/updateScoreList")
    @ResponseBody
    public Map<String, Object> updateScoreList(String scoreListStr) throws Exception {
        Map<String, Object> map = new HashMap<>();
        List<EasScore> scoreList = JSON.parseArray(scoreListStr,EasScore.class);
//        System.out.println("我是scoreList"+scoreList);

        int res = easScoreService.updateScoreByScoreList(scoreList);
        if (res > 0){
            map.put("result",true);
            map.put("msg","批量评分成功");
        }else {
            map.put("result",false);
            map.put("msg","批量评分失败,请联系管理员!");
        }


        return map;
    }

    @RequestMapping("/myScore")
    @ResponseBody
    public Map<String, Object> myScore(@RequestParam(defaultValue = "1") Integer page,
                                       @RequestParam(defaultValue = "10") Integer limit,
                                        Integer result) throws Exception {
        Map<String, Object> map = new HashMap<>();

        EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();//获取EasUser对象
        String username = easUser.getUsername();
        EasStudent easStudent = easStudentService.getStudentByUsername(username);

        PageUtil pageUtil = new PageUtil(page,limit);
        int sId = easStudent.getId();
        int count = easScoreService.getTotalItemsCount(sId,result);

        List<EasCourse> list = easScoreService.getCourseListBySid(sId,result,pageUtil);

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

        return map;
    }


}
EasStudentController:
package com.jubilantz.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jubilantz.entity.EasClass;
import com.jubilantz.entity.EasRole;
import com.jubilantz.entity.EasStudent;
import com.jubilantz.entity.EasUser;
import com.jubilantz.services.EasClassService;
import com.jubilantz.services.EasStudentService;
import org.apache.commons.beanutils.PropertyUtilsBean;
import org.apache.ibatis.annotations.Param;
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/14 10:11
 */
@Controller
@RequestMapping("/easStudent")
public class EasStudentController {
    @Autowired
    private EasStudentService easStudentService;


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



    @RequestMapping("/list")
    @ResponseBody
    public Map<String, Object> list(@RequestParam(defaultValue = "1") Integer page,
                                    @RequestParam(defaultValue = "10") Integer limit,
                                    EasStudent easStudent) throws Exception{
        Map<String, Object> map = new HashMap<>();

//        System.out.println("我是:" + easStudent.getClass_id());

        Page<EasStudent> pager = PageHelper.startPage(page,limit);
//        List<EasStudent> list = easStudentService.getList(easStudent);
        List<EasStudent> list = easStudentService.findList(easStudent);
//        System.out.println("获取信息总条数为:" + list.size());
//        for (EasStudent e:list
//             ) {
//            System.out.println(e.getUser().getUsername());
//            System.out.println(e.getName());
//            System.out.println(e.getClass_id());
//        }
        map.put("count",pager.getTotal());
        map.put("data",list);
        map.put("code",0);
        map.put("msg","");

        return map;
    }

}
EasTeacherController:
package com.jubilantz.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jubilantz.entity.EasClass;
import com.jubilantz.entity.EasTeacher;
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.List;
import java.util.Map;

/**
 * @Author JubilantZ
 * @Date: 2021/4/14 10:11
 */
@Controller
@RequestMapping("/easTeacher")
public class EasTeacherController {
    @Autowired
    private EasTeacherService easTeacherService;


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



    @RequestMapping("/list")
    @ResponseBody
    public Map<String, Object> list(@RequestParam(defaultValue = "1") Integer page,
                                    @RequestParam(defaultValue = "10") Integer limit,
                                    EasTeacher easTeacher) throws Exception{
        Map<String, Object> map = new HashMap<>();

//        分页不能用待修改。。。

        Page<EasTeacher> pager = PageHelper.startPage(page,limit);
//        List<EasTeacher> list = easTeacherService.getList(easTeacher);
        List<EasTeacher> list = easTeacherService.findTeacherList(easTeacher);
//        System.out.println("获取信息总条数为:" + list.size());
//        for (EasTeacher e:list
//             ) {
//            System.out.println(e.getUser().getUsername());
//            System.out.println(e.getName());
//        }
        map.put("count",pager.getTotal());
        map.put("data",list);
        map.put("code",0);
        map.put("msg","");

        return map;
    }

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

}
EasUserController:
package com.jubilantz.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jubilantz.entity.*;
import com.jubilantz.mappers.EasUserMapper;

import com.jubilantz.services.*;
import com.jubilantz.utils.PageUtil;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.crypto.hash.Md5Hash;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;


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

@Controller
@RequestMapping("/easUser")
public class EasUserController {
    @Autowired
    private EasUserMapper easUserMapper;
    @Autowired
    private EasUserService easUserService;
    @Autowired
    private EasClassService easClassService;
    @Autowired
    private EasStudentService easStudentService;
    @Autowired
    private EasTeacherService easTeacherService;
    @Autowired
    private EasRoleService easRoleService;

    @RequestMapping("/index")
    public String index(ModelMap modelMap) throws Exception {
        modelMap.put("roleList",easRoleService.getAll());
        return "system/user/index";
    }

    @RequestMapping("/list")
    @ResponseBody
    public Map<String,Object> list(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "10") Integer limit,
                                   EasUser condition, String roleIds) throws Exception{
        Map<String,Object> map = new HashMap<>();

        //将传递过来的角色编号封装到角色集合中
        if(roleIds != null && !roleIds.trim().equals("")){
            String[] array = roleIds.split(",");
            List<EasRole> roles = new ArrayList<>();
            for (int i = 0; i < array.length; i++) {
                EasRole role = new EasRole();
                role.setId(Integer.parseInt(array[i]));
                roles.add(role);
            }
            condition.setRoles(roles);
        }

//        Page<EasUser> pager = PageHelper.startPage(page,limit);
        int count = easUserService.getCount();
        PageUtil pageUtil = new  PageUtil(page,limit);
        List<EasUser> list = easUserMapper.getList(condition,pageUtil);

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

        return map;
    }

    @RequestMapping("/form")
    public String form(ModelMap modelMap) throws Exception {
        modelMap.put("roleList",easRoleService.getAll());
        return "system/user/form";
    }

    @RequestMapping("/basicForm")
    public String basicForm(ModelMap modelMap) throws Exception {
        modelMap.put("classList",easClassService.getAll());
        return "system/user/form2";
    }

    @RequestMapping("/batchDelete")
    @ResponseBody
    @RequiresPermissions("user:delete")
    public Map<String, Object> batchDelete(Integer[] ids) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        easUserMapper.batchDelete(ids);
        map.put("result",true);
        return map;
    }

    @RequestMapping(value = "/add",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> add(EasUser user,@RequestParam(defaultValue = "7") String roleIds) throws Exception{
        Map<String,Object> map = new HashMap<>();

        String[] array = roleIds.split(",");
        Integer[] ids = new Integer[array.length];
        for (int i = 0; i < array.length; i++) {
            ids[i] = Integer.parseInt(array[i]);
        }

        //对密码进行加密
        Md5Hash md5Hash = new Md5Hash(user.getPassword(),user.getSalt());
        user.setPassword(md5Hash.toString());

//        List<EasUser> list = easUserMapper.findUserName(user.getUsername());

        List<EasUser> list = easUserService.findUserName(user.getUsername());
        if (list.size() != 0){
            map.put("msg","用户名已存在");
            map.put("result",false);
        }else{
            if(user.getLocked() == null){
                user.setLocked("1");
                easUserService.addUser(user);
                easUserService.addUserRole(user,ids);

                //根据用户id查询eas_user_role表中的角色id
                int roleid = easUserService.findRoleIdByUserId(user.getId());
                //roleid = 2 为学生 3为教师 将用户名在学生表/教师表进行添加
                if(roleid == 2){
                    easStudentService.addUsername(user.getUsername());
                }else if(roleid == 3){
                    easTeacherService.addUsername(user.getUsername());
                }

            }else {
                easUserService.addUser(user);
                easUserService.addUserRole(user,ids);

                //根据用户id查询eas_user_role表中的角色id
                int roleid = easUserService.findRoleIdByUserId(user.getId());
                //roleid = 2 为学生 3为教师 将用户名在学生表/教师表进行添加
                if(roleid == 2){
                    easStudentService.addUsername(user.getUsername());
                }else if(roleid == 3){
                    easTeacherService.addUsername(user.getUsername());
                }
            }

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

    @RequestMapping(value = "/view")
    @ResponseBody
    public EasUser view(Integer id) throws Exception {
        EasUser easUser =easUserMapper.get(id);
        //将密码解密 放入对象中
//        System.out.println("解密一次后密码为:"+convertMD5(easUser.getPassword()));
        return easUser;
    }

    @RequestMapping(value = "/edit",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> edit(EasUser user, String roleIds) throws Exception{
        Map<String, Object> map = new HashMap<>();

        String[] array = roleIds.split(",");
        Integer[] ids= new Integer[array.length];
        for (int i=0 ;i < array.length; i++){
            ids[i] = Integer.parseInt(array[i]);
        }
        //获取原先未修改的对象
        EasUser easUser = easUserMapper.findUserById(user.getId());

        if (easUser.getPassword().equals(user.getPassword())) {
//            EasUser easUser = easUserMapper.findUserById(user.getId());
//            System.out.println("我是easUser密码"+easUser.getPassword());
//            System.out.println("我是user密码"+user.getPassword());
            user.setPassword(user.getPassword());
        }else{
            Md5Hash md5Hash = new Md5Hash(user.getPassword(),user.getSalt());
            user.setPassword(md5Hash.toString());
        }

        easUserService.updateUser(user);
        easUserService.deleteUserRole(user.getId());
        easUserService.addUserRole(user,ids);

        //根据用户id获取eas_user_role表中的数据行数
        int roleCount  = easUserService.getRoleCountByUid(user.getId());
        //判断用户是否只有一个角色
        if(roleCount == 1){
            //根据用户id查询eas_user_role表中的角色id
            int roleid = easUserService.findRoleIdByUserId(user.getId());
            //roleid = 2 为学生 3为教师 将用户名在学生表/教师表进行添加
            List list1 = easStudentService.findListByUsername(user.getUsername());
            List list2 = easTeacherService.findListByUsername(user.getUsername());

            if(roleid == 2){
                if(list1.size() == 0){
                    if(list2.size() > 0){
                        easTeacherService.deleteTeacher(user.getUsername());
                    }
                    easStudentService.addUsername(user.getUsername());
                }
            }else if(roleid == 3){
                if(list2.size() == 0){
                    if(list1.size() > 0){
                        easStudentService.deleteStudent(user.getUsername());
                    }
                    easTeacherService.addUsername(user.getUsername());
                }
            }
        }

//        //根据用户id查询eas_user_role表中的角色id
//        int roleid = easUserService.findRoleIdByUserId(user.getId());
//        //roleid = 2 为学生 3为教师 将用户名在学生表/教师表进行添加
//        List list1 = easStudentService.findListByUsername(user.getUsername());
//        List list2 = easTeacherService.findListByUsername(user.getUsername());
//
//        if(roleid == 2){
//            if(list1.size() == 0){
//                if(list2.size() > 0){
//                    easTeacherService.deleteTeacher(user.getUsername());
//                }
//                easStudentService.addUsername(user.getUsername());
//            }
//        }else if(roleid == 3){
//            if(list2.size() == 0){
//                if(list1.size() > 0){
//                    easStudentService.deleteStudent(user.getUsername());
//                }
//                easTeacherService.addUsername(user.getUsername());
//            }
//        }

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

    @RequestMapping("/passwordRestIndex")
    public String passwordRestIndex(){
        return "system/user/changePwd";
    }

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

        //获取页面输入的新旧密码
        String oldPassword = request.getParameter("oldPassword");
        String newPassword1 = request.getParameter("newPassword1");
        String newPassword2 = request.getParameter("newPassword2");

        String regex = "^(?!([a-zA-Z]+|\\d+)$)[a-zA-Z\\d]{6,20}$";

        boolean matches = newPassword1.matches(regex);

        //获取用户信息
        EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();//获取EasUser对象

        //将页面输入的密码进行加密 存入oldMd5Hash
        Md5Hash oldMd5Hash = new Md5Hash(oldPassword, easUser.getSalt());
        Md5Hash newMd5Hash = new Md5Hash(newPassword1, easUser.getSalt());

        //进行密码的判断
        if(oldPassword.length() <= 0 || newPassword1.length() <= 0 || newPassword2.length() <= 0){
//        if(oldPassword.equals("") || newPassword1.equals("") || newPassword2.equals("")){
            map.put("code",4);
            map.put("msg","密码不能为空");
        }else if(!easUser.getPassword().equals(oldMd5Hash.toString())){
            map.put("code",2);
            map.put("msg","输入的旧密码不正确");
        }else if(!newPassword1.equals(newPassword2)){
            map.put("code",1);
            map.put("msg","输入的新密码不一致");
        }else if(!matches){
            map.put("code",3);
            map.put("msg","密码必须包含字母、数字且长度为6-20位");
        }
//        else if(newPassword1.length() < 6 || newPassword1.length() >16){
//            map.put("code",3);
//            map.put("msg","密码长度为6~16位");
//        }
        else if(easUser.getPassword().equals(oldMd5Hash.toString())){
            easUser.setPassword(newMd5Hash.toString());
            easUserService.updateUser(easUser);
            map.put("code",0);
            map.put("msg","修改成功");
        }

        return map;
    }

    @RequestMapping("/basicInformationIndex")
    public String basicInformationIndex(Model model) throws Exception {
        //获取身份信息 判断是哪个角色
        EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();//获取EasUser对象
        Integer roleid = easUserService.findRoleIdByUserId(easUser.getId());
        String rolename = easRoleService.findRoleNameByRoleId(roleid);
//        System.out.println("角色id为:"+roleid);
//        System.out.println("角色名称为:"+rolename);
        if(roleid == 1000 || !(rolename.length() > 0)){
            model.addAttribute("code",1);
            model.addAttribute("msg","该用户还没有个人信息,请稍后再来查看和修改个人信息!");

        }else if(rolename.equals(Constants.STUDENT)){
            List<EasStudent> list = easStudentService.findListByUsername(easUser.getUsername());
//            System.out.println("我是学生信息:"+list);
            model.addAttribute("data",list);
            model.addAttribute("code",2);
            model.addAttribute("msg","学生信息成功");

        }else if(rolename.equals(Constants.TEACHER)){
            List<EasTeacher> list = easTeacherService.findListByUsername(easUser.getUsername());
//            System.out.println("我是教师信息:"+list.size());
            model.addAttribute("data",list);
            model.addAttribute("code",3);
            model.addAttribute("msg","教师信息成功");
        }else{
            model.addAttribute("code",4);
            model.addAttribute("msg","管理员还没有个人信息,请静候功能开放!");
        }

        return "system/user/basicInformation";
    }

    /**
     * 获取修改个人资料时用户已有的信息
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getBasicInformation")
    @ResponseBody
    public Object getBasicInformation() throws Exception {
        EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();//获取EasUser对象
        Integer roleid = easUserService.findRoleIdByUserId(easUser.getId());
        String rolename = easRoleService.findRoleNameByRoleId(roleid);
        if(roleid == 1000 || !(rolename.length() > 0)){
            System.out.println("我怎么变成null了!");
            return null;
        }else if(rolename.equals(Constants.STUDENT)){
            EasStudent easStudent = easStudentService.getStudentByUsername(easUser.getUsername());
            return easStudent;
        }else if(rolename.equals(Constants.TEACHER)){
            EasTeacher easTeacher = easTeacherService.getTeacherByUsername(easUser.getUsername());
            return easTeacher;
        }else{
            System.out.println("哪里出错了!");
            return null;
        }

    }

    @RequestMapping(value = "/modifyInformation",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> modifyInformation(EasStudent easStudent,EasTeacher easTeacher,Integer classes) throws Exception{
        Map<String, Object> map = new HashMap<>();
        EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();//获取EasUser对象
        Integer roleid = easUserService.findRoleIdByUserId(easUser.getId());
        String rolename = easRoleService.findRoleNameByRoleId(roleid);
        if(roleid == 1000 || !(rolename.length() > 0)){
            System.out.println("我怎么变成null了!");
            map.put("result",false);
            return map;
        }else if(rolename.equals(Constants.STUDENT)){
            //名称不符合必须重新set课程id
            easStudent.setClass_id(classes);
            easStudentService.updateStudent(easStudent);

            map.put("result",true);
            return map;
        }else if(rolename.equals(Constants.TEACHER)){
            easTeacherService.updateTeacher(easTeacher);

            map.put("result",true);
            return map;
        }else{
            /**
             * 可以扩充。。。
             */
            System.out.println("哪里出错了!");
            map.put("result",false);
            return map;
        }
    }


//    //url : /kan/5.html
//    @RequestMapping("/kan/{id}.shtml")
//    @ResponseBody
//    public EasUser kan(@PathVariable Integer id) throws Exception {
//        return easUserMapper.get(id);
//    }


}

login.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>教务管理系统</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <%@include file="common.jsp"%>
    <!--[if lt IE 9]>

    <![endif]-->
    <style>
        html, body {width: 100%;height: 100%;overflow: hidden}
        /*body {background: #1E9FFF;}*/
        body {background: #000000;}
        /*body {background: #2f332a;}*/
        body:after {content:'';background-repeat:no-repeat;background-size:cover;-webkit-filter:blur(3px);-moz-filter:blur(3px);-o-filter:blur(3px);-ms-filter:blur(3px);filter:blur(3px);position:absolute;top:0;left:0;right:0;bottom:0;z-index:-1;}
        .layui-container {width: 100%;height: 100%;overflow: hidden}
        .admin-login-background {width:360px;height:300px;position:absolute;left:50%;top:40%;margin-left:-180px;margin-top:-100px;}
        .logo-title {text-align:center;letter-spacing:2px;padding:14px 0;}
        .logo-title h1 {color:#1E9FFF;font-size:25px;font-weight:bold;}
        .login-form {background-color:#fff;border:1px solid #fff;border-radius:3px;padding:14px 20px;box-shadow:0 0 8px #eeeeee;}
        .login-form .layui-form-item {position:relative;}
        .login-form .layui-form-item label {position:absolute;left:1px;top:1px;width:38px;line-height:36px;text-align:center;color:#d2d2d2;}
        .login-form .layui-form-item input {padding-left:36px;}
        .captcha {width:60%;display:inline-block;}
        .captcha-img {display:inline-block;width:34%;float:right;}
        .captcha-img img {height:34px;border:1px solid #e6e6e6;height:36px;width:100%;}
    </style>
    <script>

        //验证码刷新
        function reloadValidateCode(){
            $("#validateCodeImg").attr("src","${path}/validatecode.jsp?data=" + new Date() + Math.floor(Math.random()*24));
        }

    </script>

</head>
<body>
<div class="layui-container">
    <div class="admin-login-background">
        <div class="layui-form login-form">
            <form id="login" class="layui-form" action="${path}/easLogin/login" method="post">
                <div class="layui-form-item logo-title">
                    <h1>教务管理系统</h1>
                </div>
                <div class="layui-form-item">
                    <label class="layui-icon layui-icon-username" ></label>
                    <input type="text" name="username" lay-verify="required|account" placeholder="用户名" autocomplete="off" class="layui-input" >
                </div>
                <div class="layui-form-item">
                    <label class="layui-icon layui-icon-password" ></label>
                    <input type="password" name="password" lay-verify="required|password" placeholder="密码" autocomplete="off" class="layui-input" >
                </div>
                <div class="layui-form-item">
                    <label class="layui-icon layui-icon-vercode" ></label>
                    <input type="text" name="randomCode" lay-verify="required" placeholder="图形验证码" autocomplete="off" class="layui-input verification captcha">
                    <div class="captcha-img">
                        <img   id="validateCodeImg"  src="${path}/validatecode.jsp" onclick="reloadValidateCode()">
                    </div>
                </div>
                <div class="layui-form-item">
                    <input type="checkbox" name="rememberMe" value="true" lay-skin="primary" title="记住密码">
                </div>
                <div class="layui-form-item">
                    <button type="submit"  class="layui-btn layui-btn layui-btn-normal layui-btn-fluid" lay-submit="" lay-filter="login" onclick="subForm();return false;">登 入</button>
                </div>

                <u><u></u><a onclick="registerForm();" style="margin-left: 70%">立即注册</a></u></p>

            </form>
        </div>
    </div>
</div>
<script src="${path}/lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>
<script>
    layui.use(['form','layer'], function () {
        var form = layui.form,
            layer = layui.layer;

        // 登录过期的时候,跳出ifram框架
        if (top.location !== self.location) top.location = self.location;

        // 粒子线条背景
        $(document).ready(function(){
            $('.layui-container').particleground({
                dotColor:'#7ec7fd',
                lineColor:'#7ec7fd'
            });
        });

    });

    
    function subForm() {
        var params = $("#login").serialize();
        $.post("${path}/easLogin/login",params,function (data) {
            if(data.code != 0){
                layui.layer.msg(data.msg,{icon:5});
            }else{
                layui.layer.msg("登录成功",{icon:1,time:1000},function () {
                    location.href = "${path}/easLogin/main";
                });

            }
        });

    }
    
    function registerForm() {
        $.get("${path}/easRegister/registerForm",function (str) {
            var resisterIndex = layer.open({
                type:1,
                title : '注册页面',
                content : str,
                area:'700px',
                skin:'layui-layer-molv',
                btn:['注册','重置'],
                zIndex:10,
                yes : function (index) {
                    var params2 = $("#register_form").serialize();
                    $.post('${path}/easRegister/registerUser',params2,function (data) {
                        // console.log("我是注册传来的数据:"+params2);
                        if(data.code === 0){
                            layui.layer.close(resisterIndex);
                            layui.layer.msg('注册成功',{icon:1,time:1000})
                        }else if(data.code === 1){
                            layui.layer.msg(data.msg,{zIndex:20,icon:5,time:1000})
                        }

                    });
                }
                ,btn2:function (index){
                    //重置表单add_course_form 为表单id
                     $('#register_form')[0].reset();
                    // form.render();//必须写,不写该按钮会变为关闭页面事件
                    form.render(null, 'registerForm');//更新 lay-filter="courseAddForm" 所在容器内的全部表单状态
                }

            });
        });
    }


</script>


</body>
</html>

main.js

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>教务管理系统</title>
    <%@include file="common.jsp"%>
    <script>
        layui.use('layer');
        function logout() {
            layer.confirm('确定要退了?',{icon:3,title:'提示'},function (index) {
                location.href = "${path}/easUser/logout";
            });
        }
    </script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">教务管理系统</div>

    <ul class="layui-nav layui-layout-left">
        <li class="layui-nav-item">
        <a href="${path}/main/homePage" target="middle"><i class="layui-icon" data-icon="&#xe68e;">&#xe68e;&nbsp;&nbsp;</i><cite>主页</cite></a>
        </li>

    </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
<%--                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img">--%>
                    <img src="${path}/images/320755dbe6849f1c26308e67c5eb2b67.jpeg" class="layui-nav-img">
                    ${sessionScope.login_user.username}
                </a>
                <dl class="layui-nav-child">
                    <%--   target="middle"在指定的框架中打开被链接文档。 --%>
                    <dd><a href="${path}/easUser/basicInformationIndex" target="middle">基本资料</a></dd>
                    <dd><a href="${path}/easUser/passwordRestIndex" target="middle">修改密码</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="javascript:void(0)" onclick="logout();">退了</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域(可配合layui已有的垂直导航) -->
            <ul class="layui-nav layui-nav-tree"  lay-filter="test">
                <c:forEach items="${sessionScope.user_pers}" var="parent">
                    <c:if test="${parent.parentid == null}">
                        <li class="layui-nav-item layui-nav-itemed">
                            <a class="" href="javascript:;">${parent.text}</a>
                            <dl class="layui-nav-child">
                                <c:forEach items="${sessionScope.user_pers}" var="child">
                                    <c:if test="${child.parentid != null && child.parentid == parent.id}">
                                    <dd><a href="${path}/${child.url}" target="middle">${child.text}</a></dd>
                                    </c:if>
                                </c:forEach>
                            </dl>
                        </li>
                    </c:if>
                </c:forEach>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <iframe src="${path}/main/homePage" name="middle" width="100%" height="100%" frameborder="0"></iframe>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © www.zhangqingeas.online - 底部固定区域
    </div>
</div>

<script>
    //JavaScript代码区域
    layui.use('element', function(){
        var element = layui.element;

    });
</script>


</body>
</html>

管理员主页面界面:

系统管理:

用户管理:

 角色管理:

权限管理:

 

通知管理:

 

信息管理:

学生信息:

 

教师信息:

 

基本课程信息:

 

班级信息:

 

课程信息(管理员): 

信息报表

成绩报表:

 

人数报表:

 

 数据库:

1). eas_base_course

序号

字段

说明

数据类型

长度

自增

主键

允许空

默认值

1

id

课程id

int

×

×

NULL

2

coursename

课程名

varchar

100

×

×

×

NULL

3

synopsis

课程简介

varchar

255

×

×

NULL

2). eas_class

序号

字段

说明

数据类型

长度

自增

主键

允许空

默认值

1

id

班级id

int

×

×

NULL

2

classes

班级

varchar

255

×

×

×

NULL

3). eas_course

序号

字段

说明

数据类型

长度

自增

主键

允许空

默认值

1

id

Id

int

×

×

NULL

2

start_date

开设日期

date

×

×

NULL

3

end_date

结束日期

date

×

×

NULL

4

class_hour

总课时

smallint

×

×

NULL

5

test_mode

考核方式

varchar

255

×

×

NULL

6

student_num

学生数量

int

×

×

NULL

7

choice_num

选课人数

int

×

×

0

8

complete

是否是完成的课程

int

×

×

0

9

t_id

外键-教师号

int

×

×

×

NULL

10

base_course_id

外键-课程号

int

×

×

×

NULL

4). eas_notice

序号

字段

说明

数据类型

长度

自增

主键

允许空

默认值

1

id

公告id

int

×

×

NULL

2

title

标题

varchar

255

×

×

×

NULL

3

author

作者

varchar

255

×

×

×

NULL

4

content

内容

varchar

1000

×

×

×

NULL

5

type

权限

int

×

×

×

3

6

releasedate

发布日期

date

×

×

×

NULL

5). eas_permission

序号

字段

说明

数据类型

长度

自增

主键

允许空

默认值

1

id

功能id

int

×

×

×

NULL

2

text

功能名称

varchar

255

×

×

×

NULL

3

type

功能类型

varchar

255

×

×

×

NULL

4

url

路径

varchar

255

×

×

NULL

5

percode

别名

varchar

255

×

×

×

NULL

6

parentid

父级编号

int

×

×

NULL

7

sortstring

进行排序

int

×

×

NULL

8

available

是否启用

int

×

×

NULL

6). eas_role

序号

字段

说明

数据类型

长度

自增

主键

允许空

默认值

1

id

角色id

int

×

×

NULL

2

name

角色名称

varchar

255

×

×

×

NULL

3

available

是否启用

int

×

×

×

0

7). eas_role_permission

序号

字段

说明

数据类型

长度

自增

主键

允许空

默认值

1

id

int

×

×

NULL

2

eas_role_id

角色id

int

×

×

×

NULL

3

eas_permission_id

功能id

int

×

×

×

NULL

8). eas_score

序号

字段

说明

数据类型

长度

自增

主键

允许空

默认值

1

id

分数id

int

×

×

NULL

2

score

考试分数

int

×

×

×

0

3

result

考试结果

varchar

255

×

×

NULL

4

s_id

学生id

int

×

×

×

NULL

5

c_id

课程id

int

×

×

×

NULL

9). eas_student

序号

字段

说明

数据类型

长度

自增

主键

允许空

默认值

1

id

学生id

int

×

×

NULL

2

username

账号

varchar

255

×

×

×

NULL

3

name

姓名

varchar

255

×

×

NULL

4

sex

性别

varchar

255

×

×

NULL

5

birthday

出生日期

date

×

×

NULL

6

phone

电话号码

varchar

255

×

×

NULL

7

class_id

班级id

int

×

×

NULL

8

motto

座右铭

varchar

255

×

×

NULL

10). eas_teacher

序号

字段

说明

数据类型

长度

自增

主键

允许空

默认值

1

id

教师id

int

×

×

NULL

2

username

用户名

varchar

255

×

×

×

NULL

3

name

教师姓名

varchar

255

×

×

NULL

4

sex

性别

varchar

255

×

×

NULL

5

birthday

出生年月

date

×

×

NULL

6

phone

电话

varchar

255

×

×

NULL

7

education

学历

varchar

255

×

×

NULL

8

motto

座右铭

varchar

255

×

×

NULL

11). eas_user

序号

字段

说明

数据类型

长度

自增

主键

允许空

默认值

1

id

用户id

int

×

×

NULL

2

username

账号

varchar

255

×

×

×

NULL

3

password

密码

varchar

255

×

×

×

NULL

4

salt

盐值

varchar

255

×

×

×

NULL

5

locked

是否锁定

varchar

255

×

×

×

NULL

12). eas_user_role

序号

字段

说明

数据类型

长度

自增

主键

允许空

默认值

1

id

int

×

×

NULL

2

eas_user_id

用户id

int

×

×

×

NULL

3

eas_role_id

角色id

int

×

×

×

1000

  • 2
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

在努力的前端小白

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值