您好,欢迎来到华佗小知识。
搜索
您的当前位置:首页[Java毕设项目01]基于SpringBoot开发的教务管理系统

[Java毕设项目01]基于SpringBoot开发的教务管理系统

来源:华佗小知识

1、系统技术栈

  • 后端:Springboot、MyBatis、SpringMVC

  • 前端:html、css、JavaScript、bootstrap、Vue.js

  • JDK版本:1.8

  • 数据库:MySQL 5.7

  • 前后端:不分离

  • 编辑器:IDEA 2022

 2、数据表的设计(只展示管理员、教师、学生的表设计)

管理员信息表

教师信息表

学生信息表

3、 系统界面实现以及部分后台代码实现

  • 登录模块

    ✥界面

    @RestController
    @RequestMapping
    public class AccountController
    {
        @Resource
        private AdminInfoService adminInfoService;
        @Resource
        private TeacherInfoService teacherInfoService;
        @Resource
        private StudentInfoService studentInfoService;
    
        /**
         * 登录
         * @param user
         * @param request
         * @return
         */
        @PostMapping("/login")
        public Result login(@RequestBody Account user, HttpServletRequest request)
        {
            //检验数据有没有填写
            if (ObjectUtil.isEmpty(user.getAccountNum()) || ObjectUtil.isEmpty(user.getPassword()) || ObjectUtil.isEmpty(user.getLevel()))
            {
                return Result.error("-1","请完善登录信息");
            }
            //判断身份
            Integer level = user.getLevel();
           // System.out.println("权限为:"+level);
    
            Account loginUser = new Account();
            //管理员
            if (1 == level)
            {
                loginUser = adminInfoService.login(user.getAccountNum(),user.getPassword());
                //System.out.println("数据为:"+loginUser);
            }
            //老师
            if (2 == level)
            {
                loginUser = teacherInfoService.login(user.getAccountNum(),user.getPassword());
            }
            //学生
            if (3 == level)
            {
                loginUser = studentInfoService.login(user.getAccountNum(),user.getPassword());
            }
            //存一份在session里面
            request.getSession().setAttribute("user",loginUser);
            return Result.success(loginUser);
        }
    
      return Result.success();
        }

  • 管理员模块

    ✥界面

    public class AdminInfoController
    {
        @Resource
        private AdminInfoService adminInfoService;
    
        //添加管理员
        @PostMapping
        public Result add(@RequestBody AdminInfo adminInfo)
        {
            adminInfoService.add(adminInfo);
            return Result.success();
        }
        //更新管理员信息
        @PutMapping
        public Result update(@RequestBody AdminInfo adminInfo, HttpServletRequest request)
        {
            adminInfoService.update(adminInfo);
            return Result.success();
        }
        //根据id删除
        @DeleteMapping("/{id}")
        public Result deleteById(@PathVariable Long id)
        {
             adminInfoService.deleteById(id);
            return Result.success();
        }
        //分页查询
        @GetMapping("/page")
        public Result findPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize)
        {
            PageInfo<AdminInfo> info = adminInfoService.findPage(pageNum,pageSize);
            return Result.success(info);
        }
        //根据用户名模糊查询
        @GetMapping("/page/{name}")
        public Result findPageName(@RequestParam Integer pageNum, @RequestParam Integer pageSize, @PathVariable String name)
        {
            PageInfo<AdminInfo> info = adminInfoService.findPageName(pageNum,pageSize,name);
            return Result.success(info);
        }
    }
  • 教师模块

    ✥界面

    @PostMapping("/xuanke")
    public Result xuanke(@RequestBody ClassInfo classInfo, HttpServletRequest request)
    {
    
        //接收数据
        Account user = (Account) request.getSession().getAttribute("user");
        if (ObjectUtil.isEmpty(user))
        {
            throw new CustomException("-1","登录已失效,请重新登录!");
        }
        //判断是否已选
        XuankeInfo info = xuankeInfoService.find(classInfo.getName(), classInfo.getTeacherId(), user.getId());
        if(ObjectUtil.isNotEmpty(info))
        {
            throw new CustomException("-1","你选择过该课程,请选择其他课程!");
        }
        //判断课程是否选满
        if (classInfo.getKaiban().equals(classInfo.getYixuan()))
        {
            throw new CustomException("-1","该课程选课人数已满,请选择其他课程!");
        }
        //塞一份课程信息给选课表里
        XuankeInfo xuankeInfo = new XuankeInfo();
        BeanUtils.copyProperties(classInfo,xuankeInfo);
        xuankeInfo.setId(null);
        //补全选课表里剩下的字段
        xuankeInfo.setStudentId(user.getId());
        xuankeInfo.setStatus("待开课");
        xuankeInfoService.add(xuankeInfo);
        //选课表的已选人数加1
        classInfo.setYixuan(classInfo.getYixuan()+1);
        classInfoService.update(classInfo);
    
        return Result.success();
    }
    
    @PostMapping
    public Result add(@RequestBody ClassInfo classInfo)
    {
        classInfoService.add(classInfo);
        return Result.success();
    }
    
    @DeleteMapping("/{id}")
    public Result deleteById(@PathVariable Long id)
    {
        classInfoService.deleteById(id);
        return Result.success();
    }
    
    @PutMapping
    public Result update(@RequestBody ClassInfo classInfo)
    {
        classInfoService.update(classInfo);
        return Result.success();
    }
    
    @GetMapping("/page")
    public Result findPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize)
    {
        PageInfo<ClassInfo> info = classInfoService.findPage(pageNum,pageSize);
        return Result.success(info);
    }
    
    @GetMapping("/page/{name}")
    public Result findPageName(@RequestParam Integer pageNum, @RequestParam Integer pageSize, @PathVariable String name)
    {
        PageInfo<ClassInfo> info = classInfoService.findPageName(pageNum,pageSize,name);
        return Result.success(info);
    }
  • 学生模块

    ✥界面

@RestController
@RequestMapping("/xuankeInfo")
public class XuankeInfoController
{
    @Resource
    private XuankeInfoService xuankeInfoService;

    /**
     * 查询所有
     * @param request
     * @return
     */
    @GetMapping
    public Result findAll(HttpServletRequest request)
    {
        List<XuankeInfo> list =  xuankeInfoService.findAll(request);
        return Result.success(list);
    }

    /**
     * 根据id删除
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public Result deleteById(@PathVariable Long id)
    {
        xuankeInfoService.deleteById(id);
        return Result.success();
    }

    /**
     * 更新
     * @param xuankeInfo
     * @return
     */
    @PutMapping
    public Result update(@RequestBody XuankeInfo xuankeInfo)
    {
        xuankeInfoService.update(xuankeInfo);
        return Result.success();
    }
}

  • 学院模块

    ✥界面

    @RestController
    @RequestMapping("/collegeInfo")
    public class CollegeInfoController
    {
        @Resource
        private CollegeInfoService collegeInfoService;
    
        @GetMapping
        public Result findAll()
        {
           List<CollegeInfo> list =  collegeInfoService.findAll();
            return Result.success(list);
        }
    
        @PostMapping
        public Result add(@RequestBody CollegeInfo collegeInfo)
        {
            collegeInfoService.add(collegeInfo);
            return Result.success();
        }
    
        @DeleteMapping("/{id}")
        public Result deleteById(@PathVariable Long id)
        {
            collegeInfoService.deleteById(id);
            return Result.success();
        }
    
        @PutMapping
        public Result update(@RequestBody CollegeInfo collegeInfo)
        {
            collegeInfoService.update(collegeInfo);
            return Result.success();
        }
    
        @GetMapping("/page")
        public Result findPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize)
        {
            PageInfo<CollegeInfo> info = collegeInfoService.findPage(pageNum,pageSize);
            return Result.success(info);
        }
    
        //模糊查询
        @GetMapping("/page/{name}")
        public Result findPageName(@RequestParam Integer pageNum, @RequestParam Integer pageSize, @PathVariable String name)
        {
            PageInfo<CollegeInfo> info = collegeInfoService.findPageName(pageNum,pageSize,name);
            return Result.success(info);
        }
    }

  • 专业模块

    ✥界面

    ✥部分代码

    @RestController
    @RequestMapping("/specialityInfo")
    public class SpecialityInfoController
    {
        @Resource
        private SpecialityInfoService specialityInfoService;
    
        @GetMapping
        public Result findAll()
        {
            List<SpecialityInfo> list =  specialityInfoService.findAll();
            return Result.success(list);
        }
    
        @PostMapping
        public Result add(@RequestBody SpecialityInfo specialityInfo)
        {
            specialityInfoService.add(specialityInfo);
            return Result.success();
        }
    
        @DeleteMapping("/{id}")
        public Result deleteById(@PathVariable Long id)
        {
            specialityInfoService.deleteById(id);
            return Result.success();
        }
    
        @PutMapping
        public Result update(@RequestBody SpecialityInfo specialityInfo)
        {
            specialityInfoService.update(specialityInfo);
            return Result.success();
        }
    
        @GetMapping("/page")
        public Result findPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize)
        {
            PageInfo<SpecialityInfo> info = specialityInfoService.findPage(pageNum,pageSize);
            return Result.success(info);
        }
    
        @GetMapping("/page/{name}")
        public Result findPageName(@RequestParam Integer pageNum, @RequestParam Integer pageSize, @PathVariable String name)
        {
            PageInfo<SpecialityInfo> info = specialityInfoService.findPageName(pageNum,pageSize,name);
            return Result.success(info);
        }
    
    }

4、总结

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- huatuo0.cn 版权所有 湘ICP备2023017654号-2

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务