基于javaweb+mysql的springboot教务管理系统(java+springboot+thymeleaf+layui+html+mysql)

基于javaweb+mysql的springboot教务管理系统(java+springboot+thymeleaf+layui+html+mysql)

运行环境

Java≥8、MySQL≥5.7

开发工具

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

适用

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

功能说明

基于javaweb+mysql的SpringBoot教务管理系统(java+springboot+thymeleaf+layui+html+mysql)

项目介绍

1.系统默认超级管理员账号为admin,默认密码为123456 系统配置:用户管理、角色管理、权限管理 默认已配置好基本数据:用户默认只有一个超级管理员,角色有三种:管理员、教师、学生,权限已按照角色分配完成。 2.系统建设 a.建设简介: 学校建设需要按照系部 > 专业 > 年级 > 班级的顺序进行建设。每项管理均提供精确/条件查询,可快速定位所需信息。 b.系部建设 c.专业建设 d.年级建设 3,课目建设 a.课目介绍 b.添加必修课目 c.添加选修课目 d.课目启动与暂停 4.教师管理 a.教师授课管理 b.录入教师 c.教师信息查询 5.学生管理: a,退学信息 b.录入学生 c.学生信息查询 6.成绩管理 a.学生成绩管理 b.教师成绩管理 7.校园新闻: a,新闻管理

b.发布新闻

环境需要

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

6.是否Maven项目:是;

技术栈

  1. 后端:SpringBoot+Thymeleaf

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

使用说明

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

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

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

  1. 将项目中application.yml配置文件中的数据库配置改为自己的配置;注:要修改最下方profiles:dev相关的配置; 4. 运行项目,输入localhost:8080/home 登录 管理员账号/密码:admin/123456 教师账号/密码:2020001/123456 学生账号/密码:15020002/123456
        Subject s = SecurityUtils.getSubject();
        attributes.addFlashAttribute(LOGIN_TYPE, LoginTypeEnum.ADMIN);
        if(s.isAuthenticated()) {
            return "redirect:index";
        }
        return "redirect:toLogin";
    }

    @RequestMapping(value = "toLogin")
    public String adminToLogin(HttpSession session, @ModelAttribute(LOGIN_TYPE) String loginType) {
        if(StringUtils.isBlank(loginType)) {
            LoginTypeEnum attribute = (LoginTypeEnum) session.getAttribute(LOGIN_TYPE);
            loginType = attribute == null ? loginType : attribute.name();
        }

        if(LoginTypeEnum.ADMIN.name().equals(loginType)) {
            session.setAttribute(LOGIN_TYPE,LoginTypeEnum.ADMIN);
            return "admin/login";
        }else {
            session.setAttribute(LOGIN_TYPE,LoginTypeEnum.PAGE);
            return "login";
        }
    }

    @RequestMapping(value = "index")
    public String index(HttpSession session, @ModelAttribute(LOGIN_TYPE) String loginType) {
        if(StringUtils.isBlank(loginType)) {
            LoginTypeEnum attribute = (LoginTypeEnum) session.getAttribute(LOGIN_TYPE);
            loginType = attribute == null ? loginType : attribute.name();
        }
        if(LoginTypeEnum.ADMIN.name().equals(loginType)) {
            AuthRealm.ShiroUser principal = (AuthRealm.ShiroUser) SecurityUtils.getSubject().getPrincipal();
            session.setAttribute("icon",StringUtils.isBlank(principal.getIcon()) ? "/static/admin/img/face.jpg" : principal.getIcon());
            return "admin/index";
        }else {
            return "admin/index";
        }

    }

    @RequestMapping("/getCaptcha")
    public void getCaptcha(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //设置页面不缓存
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
        String verifyCode = captchaProducer.createText();
        //将验证码放到HttpSession里面

@Controller
public class TeacherController {
    @Autowired
    private TeacherService lxxTeacherService;
    @Autowired
    private StudentService lxxStudentService;
    @Autowired
    private DeleteService deleteService;

    // 跳转教师查询页面
    @RequestMapping("/selectTeacher")
    public String selectTeacher(){
        return "view/teacher/selTeacher";
    }

    //  查询教师信息
    @RequestMapping("selTeacher")
    @ResponseBody
    public LayuiResult<Map> selTeacher(TeacherDB teacherDB, pageCount pageCount){
        LayuiResult<Map> result = new LayuiResult<>();
        //  查询所有教师信息/模糊查询教师信息
        List<Map> list = lxxTeacherService.selTeacher(teacherDB,pageCount);
        //  查询符合条件的教师数量
        int count = lxxTeacherService.selTeacherCount(teacherDB);
        /**
         * 重载equals,只计算loginName;
         */
        @Override
        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            ShiroUser other = (ShiroUser) obj;
            if (loginName == null) {
                return other.loginName == null;
            } else return loginName.equals(other.loginName);
        }
    }
}

    @Before("webLog()")
    public void doBefore(JoinPoint joinPoint) {
        startTime.set(System.currentTimeMillis());
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();
        HttpSession session = (HttpSession) attributes.resolveReference(RequestAttributes.REFERENCE_SESSION);
        logger.info("classMethod:======>" + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
        logger.info("method:======>" + request.getMethod());
        //获取传入目标方法的参数
        Object[] args = joinPoint.getArgs();
        for (int i = 0; i < args.length; i++) {
            Object o = args[i];
            if(o instanceof ServletRequest || (o instanceof ServletResponse) || o instanceof MultipartFile){
                args[i] = o.toString();
            }
        }

        String str = JSONObject.toJSONString(args);
        str = str.length() > 2000 ? str.substring(2000) : str;
        logger.info("params:======>" + str);

        if(session != null){
            logger.info("session id :======>" + session.getId());
        }

        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        Method method = signature.getMethod();
        SysLog mylog = method.getAnnotation(com.nsapi.niceschoolapi.common.annotation.SysLog.class);
        if(mylog != null){
            //注解上的描述
            logger.info("mylog:======>" + mylog.value());
        }

        if(MySysUser.ShiroUser() != null) {
            String username = StringUtils.isNotBlank(MySysUser.nickName()) ? MySysUser.nickName() : MySysUser.loginName();
            logger.info("user:======>" + username);
        }
    }

    @Around("webLog()")
    public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        try {
            Object obj = proceedingJoinPoint.proceed();
            return obj;
        } catch (Exception e) {
            logger.error("exception message :======>" + e.getMessage());
            throw e;
        }
    }

    @AfterReturning(returning = "ret", pointcut = "webLog()")
    public void doAfterReturning(Object ret) {
        Integer teacount = addTeacherService.selTeacherCount();
        if(teacount == 0){
            //  添加一条分割线
            Integer aa = addTeacherService.teaSegmentation();
        }
        //  判断是否要插入新一年分割工号 1要插入,0不用插入
        Integer year = addTeacherService.selectYear();
        if(year>0){
            //  添加一条分割线
            Integer aa = addTeacherService.teaSegmentation();
        }
        //  生成教师工号
        String tchid = addTeacherService.selTchid();
        teacherDB.setTchid(tchid);
        teacherDB.setTid(Integer.valueOf(tchid));
        //  添加教师
        Integer addTeacher = addTeacherService.addTeacher(teacherDB);

        //  根据教师工号查询信息
        List<TeacherDB> tea = addTeacherService.selTeaMessage(teacherDB.getTchid());

        //  查询sys_role角色id
        String id = addTeacherService.selectTeaRole();
        result.setData(tea);
        result.setMsg(id);
        return result;
    }
}

                int r = tchCourseService.addOneTchCourse(tchCourseVO);
                if(r>0){
                    int r2 = tchCourseService.addOneTchClass(tchCourseVO);
                    if(r2>0){
                        return true;
                    }else{
                        return false;
                    }
                }else{
                    return false;
                }
            }

        }

    }

    /**
     * 查询指定老师教授所有课程
     */
    @RequestMapping("findcoursebytch")
    @ResponseBody
    public Object findCourseByTch(TchCourseVO tchCourseVO,Integer page, Integer limit){
        PageHelper.startPage(page, limit);
        List<TchCourseVO> listAll = tchCourseService.findCourseByTch(tchCourseVO);
        PageInfo pageInfo = new PageInfo(listAll);
        Map<String, Object> sData = new HashMap<String, Object>();
        sData.put("code", 0);
        sData.put("msg", "");
        sData.put("count", pageInfo.getTotal());
        sData.put("data", pageInfo.getList());
        return sData;
    }

    /**
     * 教师授课及班级删除
     */

    @RequestMapping("deltchcourse")
    @ResponseBody
    public Object delTchCourse(TchCourseVO tchCourseVO){
        int flag = tchCourseService.delTchCourse(tchCourseVO);
        if(flag>0){
            return true;
        }else {
            return false;
        }

    }
    return  msg;
}
}

@Controller
public class AddTeacherController {
    @Autowired
    private StudentService studentService;
    @Autowired
    private AddTeacherService addTeacherService;

    @RequestMapping("/addTeacherPage")
    public String addTeacherPage(Model model){
        //  查询政治面貌表
        List<PoliticsTypeDB> stupol = studentService.selPolitics();
        model.addAttribute("stupol",stupol);
        return "view/teacher/addTeacher";
    }

    //  添加教师
    @RequestMapping("addTeacher")
    @ResponseBody
    public LayuiResult<TeacherDB> addTeacher(TeacherDB teacherDB, String birthday, String tertime) throws Exception{
        LayuiResult<TeacherDB> result= new LayuiResult<>();
        //  将接收到的时间进行类型转换

@Controller
@RequestMapping("appraise")
public class AppraiseController extends BaseController {
    @Autowired
    private AppraiseService appraiseService;

    /**
     * 进入查询教评教师页面
     */
    @RequestMapping("seltch")
    public String seltch() {
        return "view/appraise/seltch";
    }

    /**
     * 进入教评问题管理页面
     */
    @RequestMapping("evlistcontrol")
    public String evListControl() {
        return "view/appraise/evlistcontrol";
    }

    /**
     * 添加问题
     */
    @RequestMapping("addoneev")
    @ResponseBody
    public Object addOneEv(EvaluateListDB evaluateListDB){
        int r = appraiseService.addOneEv(evaluateListDB);
        if(r==1){
            return true;
        }else{
            return false;
        }
    }

    /**
     * 删除问题
        return coursetype;
    }
    @RequestMapping("update")
    @ResponseBody
    public Object update(coursel coursel){
         int update = courselService.update(coursel);
        if(update==1){
            return "修改成功";
        }else{
            return "修改失败";
        }

    }
    @RequestMapping("addcou")
    @ResponseBody
    public Object addcou(coursel coursel){
        int addcou = courselService.addcou(coursel);
        if(addcou==1){
            return "添加成功";
        }else{
            return "添加失败";
        }

    }
    @RequestMapping("delcou")
    @ResponseBody
    public Object delcou(Integer cid){

        int delercou = courselService.delercou(cid);
        //System.out.println(delercou);
        if(delercou>0){
            return "✖  该课程有人在读不可删除";
        }else {
            int add = courselService.delcou(cid);
            if(add==1){
                //return sys.succ;
                return "删除成功";
            }else{
                return "删除失败";
            }
        }

    }

    @RequestMapping("hfcou")
    @ResponseBody
    public Object hfcou(Integer cid){
        int add = courselService.hfcou(cid);
        if(add==1){
            return "恢复成功";
        }
        for (Role r : roles){
            roleService.deleteRole(r);
        }
        return ResponseEntity.success("操作成功");
    }
}

@Controller
@RequestMapping("admin/system/menu")
public class MenuController {

    @Autowired
    MenuService menuService;

    @RequestMapping("list")
    @SysLog("跳转菜单列表")
    public String list(){
        return "admin/menu/list";
    }

    @RequiresPermissions("sys:menu:list")
    @RequestMapping("treeList")
    @ResponseBody
    public ResponseEntity treeList(){
        ResponseEntity responseEntity = ResponseEntity.success("操作成功");
        responseEntity.setAny("code",0);
        List<ClassinfoDB> classinfoDBS = studentExamService.selClasss(gid);
        // System.out.println(classinfoDBS);
        return classinfoDBS;
    }
    @ResponseBody
    @RequestMapping("selmessage")
    public Object selmessage(StuExamVO stuExamVO){
        String msg="";
        int i = studentExamService.selExam(stuExamVO);
        if(i==1){
           msg="请不要重复导入成绩";
        }else{
        int num = studentExamService.add(stuExamVO);
        if (num==1){
            msg="添加成功";
        }
        else {
            msg="添加失败";
        }
        }
        return msg;
    }
    @ResponseBody
    @RequestMapping("saveupdate")
    public  Object saveupdate(StuExamDB stuExamDB){
        String msg="";
        int nums = studentExamService.updateExam(stuExamDB);
        if(nums==1){
            msg="修改成功";
        }
        return msg;
    }
}

@Controller
@RequestMapping("course")
            return "admin/index";
        }

    }

    @RequestMapping("/getCaptcha")
    public void getCaptcha(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //设置页面不缓存
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
        String verifyCode = captchaProducer.createText();
        //将验证码放到HttpSession里面
        request.getSession().setAttribute(Constants.VALIDATE_CODE, verifyCode);
        LOGGER.info("本次生成的验证码为[" + verifyCode + "],已存放到HttpSession中");
        //设置输出的内容的类型为JPEG图像
        response.setContentType("image/jpeg");
        BufferedImage bufferedImage = captchaProducer.createImage(verifyCode);
        //写给浏览器
        ImageIO.write(bufferedImage, "JPEG", response.getOutputStream());
    }

    @PostMapping("admin/login")
    @SysLog("用户登录")
    @ResponseBody
    public ResponseEntity adminLogin(HttpServletRequest request) {
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String rememberMe = request.getParameter("rememberMe");
        String code = request.getParameter("code");
        String driver = request.getParameter("driver");
        String errorMsg = null;
        //判断登陆设备
        if(StringUtils.isBlank(driver)){
            //电脑登录
            if(StringUtils.isBlank(username) || StringUtils.isBlank(password)){
                return ResponseEntity.failure("用户名或者密码不能为空");
            }else if(StringUtils.isBlank(code)){
                return ResponseEntity.failure("验证码不能为空");
            }
            HttpSession session = request.getSession();
            if(session == null){
                return ResponseEntity.failure("session超时");
            }
            String trueCode = (String)session.getAttribute(Constants.VALIDATE_CODE);
            if(StringUtils.isBlank(trueCode)){
        if(StringUtils.isBlank(role.getName())){
            return ResponseEntity.failure("角色名称不能为空");
        }
        if(roleService.getRoleNameCount(role.getName())>0){
            return ResponseEntity.failure("角色名称已存在");
        }
        roleService.saveRole(role);
        return ResponseEntity.success("操作成功");
    }

    @RequestMapping("edit")
    public String edit(String id,ModelMap modelMap){
        Role role = roleService.getRoleById(id);
        String menuIds = null;
        if(role != null) {
            menuIds  = role.getMenuSet().stream().map(menu -> menu.getId()).collect(Collectors.joining(","));
        }
        Map<String,Object> map = new HashMap();
        map.put("parentId",null);
        map.put("isShow",Boolean.FALSE);
        List<Menu> menuList = menuService.selectAllMenus(map);
        modelMap.put("role",role);
        modelMap.put("menuList",menuList);
        modelMap.put("menuIds",menuIds);
        return "admin/role/edit";
    }

    @RequiresPermissions("sys:role:edit")
    @PostMapping("edit")
    @ResponseBody
    @SysLog("保存编辑角色数据")
    public ResponseEntity edit(@RequestBody Role role){
        if(StringUtils.isBlank(role.getId())){
            return ResponseEntity.failure("角色ID不能为空");
        }
        if(StringUtils.isBlank(role.getName())){
            return ResponseEntity.failure("角色名称不能为空");
        }
        Role oldRole = roleService.getRoleById(role.getId());
        if(!oldRole.getName().equals(role.getName())){
            if(roleService.getRoleNameCount(role.getName())>0){
                return ResponseEntity.failure("角色名称已存在");

@Controller
public class LonginController {

    private final static Logger LOGGER = LoggerFactory.getLogger(LonginController.class);

    public final static String LOGIN_TYPE = "loginType";

    @Autowired
    @Qualifier("captchaProducer")
    DefaultKaptcha captchaProducer;

    @Autowired
    UserService userService;
        csData.put("count", pageInfo.getTotal());
        csData.put("data", pageInfo.getList());
        return csData;
    }
    /**
     * 查询教师授课中级联班级
     */
    @RequestMapping("findtchcourseclassname")
    @ResponseBody
    public Object findTchCourseClassName(ClassinfoDB classinfoDB,Integer page, Integer limit){
        PageHelper.startPage(page, limit);
        List<TeacherDB> listAll = tchCourseService.findTchCourseClassName(classinfoDB);
        PageInfo pageInfo = new PageInfo(listAll);
        Map<String, Object> cnData = new HashMap<String, Object>();
        cnData.put("code", 0);
        cnData.put("msg", "");
        cnData.put("count", pageInfo.getTotal());
        cnData.put("data", pageInfo.getList());
        return cnData;
    }

    /**
     * 查询周
     */
    @RequestMapping("findallweeks")
    @ResponseBody
    public Object findAllWeeks(Integer page, Integer limit){
        PageHelper.startPage(page, limit);
        List<WeeksDB> listAll = tchCourseService.findAllWeeks();
        PageInfo pageInfo = new PageInfo(listAll);
        Map<String, Object> wData = new HashMap<String, Object>();
        wData.put("code", 0);
        wData.put("msg", "");
        wData.put("count", pageInfo.getTotal());
        wData.put("data", pageInfo.getList());
        return wData;
    }
    /**
     * 查询节段
     */
    @RequestMapping("findallschedule")
    @ResponseBody
    public Object findAllSchedule(Integer page, Integer limit){
        PageHelper.startPage(page, limit);
        List<ScheduleDB> listAll = tchCourseService.findAllSchedule();
        PageInfo pageInfo = new PageInfo(listAll);
        Map<String, Object> sData = new HashMap<String, Object>();
            return "恢复成功";
        }else{
            return "恢复失败";
        }
    }
}

@Controller
public class StuExamController {
    @Autowired
    private StudentExamService studentExamService;
    @RequestMapping("selstudentExam")
    public String selCourses(){
        return "StudentExam";
    }
    @RequestMapping("selScs")
    @ResponseBody
    public Object selSc(Integer page, Integer limit, StuExamVO stuExamVO){
        stuExamVO.setTid(Integer.valueOf(MySysUser.loginName()));
        PageHelper.startPage(page, limit);
        List<StuExamVO> stuCourseVOS = studentExamService.selScs(stuExamVO);
        PageInfo pageInfo = new PageInfo(stuCourseVOS);
        Map<String, Object> tableData = new HashMap<String, Object>();
        //这是layui要求返回的json数据格式
        tableData.put("code", 0);
        tableData.put("msg", "");
        //将全部数据的条数作为count传给前台(一共多少条)
        tableData.put("count", pageInfo.getTotal());

@Controller
public class StudentController extends BaseController {
    @Autowired
    private StudentService studentService;

    // 跳转学生查询页面
    @RequestMapping("/selectStudent")
    public String selectStudent(){
        return "view/student/selStudent";
    }

    //  查询所有学生
    @RequestMapping("selStudent")
    @ResponseBody
    public LayuiResult<Map> selectStu(pageCount pageCount, StudentVO studentVO){
        LayuiResult<Map> result = new LayuiResult<>();
        List<Map> list = studentService.selStudent(studentVO,pageCount);
        int count = studentService.selCount(studentVO);
        result.setData(list);
        result.setCount(count);
        return result;
    }

    //  查询所有专业
    @RequestMapping("selDepartment")
    @ResponseBody
    public LayuiResult<Map> selDepartment(){
        List<DepartmentDB> selDepartment = studentService.selDepartment();
        LayuiResult result = new LayuiResult();
        result.setData(selDepartment);
        return result;
    }

    //  根据系部查询专业
    @RequestMapping("selectdid")
    @ResponseBody
    public LayuiResult<Map> selMajorDB(Integer did){
        List<MajorDB> major  =studentService.selMajorDB(did);
        LayuiResult result = new LayuiResult();
        result.setData(major);
        return result;
    }
    }
    @RequestMapping("selCo")
    @ResponseBody
    public Object selCo(){
        //System.out.println(classid);
        List<CourseDB> courseDBS = selCourseManageService.selCo();
        // System.out.println(studentDBS);
        return courseDBS;
    }
    //退课
    @RequestMapping("dropCous")
    @ResponseBody
    public Object dropCous(Integer sid,Integer cid){

        int dropcou = selCourseManageService.dropcou(sid, cid);
        int updatecou = selCourseManageService.updatecou(cid);
        if(dropcou>0 && updatecou>0){
            return "退课成功";
        }else{
            return "退课失败,请稍后再试或联系管理员";
        }
    }
    //换课
    @RequestMapping("changesCou")
    @ResponseBody
    public Object changesCou( Integer ccd,  Integer sid,Integer cid) {
        /*System.out.println(ccd+"8888888");
        System.out.println(sid+"-----"+cid);*/
        int i = selCourseManageService.selStc(ccd, sid);

        if (i > 0) {
            return "该学生已经选过这门课";
        } else {
            int dropcou = selCourseManageService.changesCou(ccd, sid, cid);
            if (dropcou > 0) {
                return "换课成功";
            } else {
                return "退课失败,请稍后再试或联系管理员";
            }
        }
    }
}

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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值