五、核心代码
5.1 查询课程
@RequestMapping(value = "/getByPage", method = RequestMethod.GET) @ApiOperation(value = "查询课程") public Result<IPage<Curriculum>> getByPage(@ModelAttribute Curriculum curriculum ,@ModelAttribute PageVo page){ QueryWrapper<Curriculum> qw = new QueryWrapper<>(); if(!ZwzNullUtils.isNull(curriculum.getTitle())) { qw.like("title",curriculum.getTitle()); } if(!ZwzNullUtils.isNull(curriculum.getType())) { qw.eq("type",curriculum.getType()); } if(!ZwzNullUtils.isNull(curriculum.getLevel())) { qw.eq("level",curriculum.getLevel()); } IPage<Curriculum> data = iCurriculumService.page(PageUtil.initMpPage(page),qw); return new ResultUtil<IPage<Curriculum>>().setData(data); }
5.2 新增学生选课
@RequestMapping(value = "/insert", method = RequestMethod.POST) @ApiOperation(value = "新增选课") public Result<CourseSelection> insert(CourseSelection courseSelection){ Curriculum curriculum = iCurriculumService.getById(courseSelection.getCurriculumId()); if(curriculum == null) { return ResultUtil.error("课程不存在"); } QueryWrapper<CourseSelection> oldQw = new QueryWrapper<>(); oldQw.eq("curriculum_id",courseSelection.getCurriculumId()); oldQw.eq("student_id",courseSelection.getStudentId()); if(iCourseSelectionService.count(oldQw) > 0L) { return ResultUtil.error("已完成选课"); } courseSelection.setTitle(curriculum.getTitle()); courseSelection.setType(curriculum.getType()); courseSelection.setContent(curriculum.getContent()); courseSelection.setKnowledgePoints(curriculum.getKnowledgePoints()); courseSelection.setWeeklyHours(curriculum.getWeeklyHours()); courseSelection.setLevel(curriculum.getLevel()); User student = iUserService.getById(courseSelection.getStudentId()); if(student == null) { return ResultUtil.error("学生不存在"); } courseSelection.setStudentName(student.getNickname()); courseSelection.setGrade(BigDecimal.ZERO); courseSelection.setGradeUser(""); courseSelection.setGradeTime(""); courseSelection.setMakeupExam(""); iCourseSelectionService.saveOrUpdate(courseSelection); return new ResultUtil<CourseSelection>().setData(courseSelection); }
5.3 编辑学生选课
@RequestMapping(value = "/update", method = RequestMethod.POST) @ApiOperation(value = "编辑选课") public Result<CourseSelection> update(CourseSelection courseSelection){ Curriculum curriculum = iCurriculumService.getById(courseSelection.getCurriculumId()); if(curriculum == null) { return ResultUtil.error("课程不存在"); } QueryWrapper<CourseSelection> oldQw = new QueryWrapper<>(); oldQw.eq("curriculum_id",courseSelection.getCurriculumId()); oldQw.eq("student_id",courseSelection.getStudentId()); if(iCourseSelectionService.count(oldQw) > 0L) { return ResultUtil.error("已完成选课"); } courseSelection.setTitle(curriculum.getTitle()); courseSelection.setType(curriculum.getType()); courseSelection.setContent(curriculum.getContent()); courseSelection.setKnowledgePoints(curriculum.getKnowledgePoints()); courseSelection.setWeeklyHours(curriculum.getWeeklyHours()); courseSelection.setLevel(curriculum.getLevel()); User student = iUserService.getById(courseSelection.getStudentId()); if(student == null) { return ResultUtil.error("学生不存在"); } courseSelection.setStudentName(student.getNickname()); iCourseSelectionService.saveOrUpdate(courseSelection); return new ResultUtil<CourseSelection>().setData(courseSelection); }
5.4 课程打分
@RequestMapping(value = "/check", method = RequestMethod.GET) @ApiOperation(value = "打分") public Result<CourseSelection> check(@RequestParam String id,@RequestParam BigDecimal grade){ CourseSelection cs = iCourseSelectionService.getById(id); if(cs == null) { return ResultUtil.error("选课不存在"); } User currUser = securityUtil.getCurrUser(); cs.setGrade(grade); cs.setGradeUser(currUser.getNickname()); cs.setGradeTime(DateUtil.now()); if(grade.compareTo(BigDecimal.valueOf(60)) >= 0) { cs.setMakeupExam("无需补考"); } else { cs.setMakeupExam("补考待安排"); } iCourseSelectionService.saveOrUpdate(cs); return ResultUtil.success(); }
5.5 安排补考
@RequestMapping(value = "/make", method = RequestMethod.GET) @ApiOperation(value = "安排补考") public Result<CourseSelection> make(@RequestParam String id,@RequestParam String makeupExam){ CourseSelection cs = iCourseSelectionService.getById(id); if(cs == null) { return ResultUtil.error("选课不存在"); } cs.setMakeupExam(makeupExam); iCourseSelectionService.saveOrUpdate(cs); return ResultUtil.success(); }
六、免责说明
- 本项目仅供个人学习使用,商用授权请联系博主,否则后果自负。
- 博主拥有本软件构建后的应用系统全部内容所有权及独立的知识产权,拥有最终解释权。
- 如有问题,欢迎在仓库 Issue 留言,看到后会第一时间回复,相关意见会酌情考虑,但没有一定被采纳的承诺或保证。
下载本系统代码或使用本系统的用户,必须同意以下内容,否则请勿下载!
- 出于自愿而使用/开发本软件,了解使用本软件的风险,且同意自己承担使用本软件的风险。
- 利用本软件构建的网站的任何信息内容以及导致的任何版权纠纷和法律争议及后果和博主无关,博主对此不承担任何责任。
- 在任何情况下,对于因使用或无法使用本软件而导致的任何难以合理预估的损失(包括但不仅限于商业利润损失、业务中断与业务信息丢失),博主概不承担任何责任。
- 必须了解使用本软件的风险,博主不承诺提供一对一的技术支持、使用担保,也不承担任何因本软件而产生的难以预料的问题的相关责任。