五、核心代码
5.1 新增课程评价
@RequestMapping(value = "/addOne", method = RequestMethod.GET) @ApiOperation(value = "添加课程评价") public Result<Object> addOne(@RequestParam String id,@RequestParam String content){ Curriculum curriculum = iCurriculumService.getById(id); if(curriculum == null) { return ResultUtil.error("课程不存在"); } User currUser = securityUtil.getCurrUser(); Appraise a = new Appraise(); a.setCurriculumId(curriculum.getId()); a.setCurriculumName(curriculum.getTitle()); a.setUserId(currUser.getId()); a.setUserName(currUser.getNickname()); a.setContent(content); a.setTime(DateUtil.now()); iAppraiseService.saveOrUpdate(a); return ResultUtil.success(); }
5.2 生成课程作业
@RequestMapping(value = "/create", method = RequestMethod.GET) @ApiOperation(value = "生成课程作业") public Result<Assignment> create(@RequestParam String id,@RequestParam String title,@RequestParam String file){ Curriculum curriculum = iCurriculumService.getById(id); if(curriculum == null) { return ResultUtil.error("课程不存在"); } // 删除原作业 QueryWrapper<Assignment> assQw = new QueryWrapper<>(); assQw.eq("curriculum_id",curriculum.getId()); iAssignmentService.remove(assQw); // 查询所有授课 QueryWrapper<Timetable> tQw = new QueryWrapper<>(); tQw.eq("curriculum_id",curriculum.getId()); List<Timetable> timetableList = iTimetableService.list(tQw); for (Timetable t : timetableList) { Assignment a = new Assignment(); a.setCurriculumId(curriculum.getId()); a.setCurriculumName(curriculum.getTitle()); a.setTitle(title); a.setFile1(file); a.setFile2(""); a.setUserId(t.getUserId()); a.setUserName(t.getUserName()); iAssignmentService.saveOrUpdate(a); } return ResultUtil.success(); }
5.3 新增课程资源
@RequestMapping(value = "/insert", method = RequestMethod.POST) @ApiOperation(value = "新增资源") public Result<CourseResources> insert(CourseResources courseResources){ Curriculum c = iCurriculumService.getById(courseResources.getCurriculumId()); if(c == null) { return ResultUtil.error("课程不存在"); } courseResources.setCurriculumName(c.getTitle()); iCourseResourcesService.saveOrUpdate(courseResources); return new ResultUtil<CourseResources>().setData(courseResources); }
5.4 查询课程
@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.getContent())) { qw.like("content",curriculum.getContent()); } if(!ZwzNullUtils.isNull(curriculum.getStatus())) { qw.eq("status",curriculum.getStatus()); } IPage<Curriculum> data = iCurriculumService.page(PageUtil.initMpPage(page),qw); return new ResultUtil<IPage<Curriculum>>().setData(data); }
5.5 新增课表
@RequestMapping(value = "/insert", method = RequestMethod.POST) @ApiOperation(value = "新增课表") public Result<Timetable> insert(Timetable timetable){ Curriculum c = iCurriculumService.getById(timetable.getCurriculumId()); if(c == null) { return ResultUtil.error("课程不存在"); } timetable.setCurriculumName(c.getTitle()); User u = iUserService.getById(timetable.getUserId()); if(u == null) { return ResultUtil.error("学生不存在"); } timetable.setUserName(u.getNickname()); User currUser = securityUtil.getCurrUser(); timetable.setWorkUser(currUser.getNickname()); iTimetableService.saveOrUpdate(timetable); return new ResultUtil<Timetable>().setData(timetable); }
五、免责说明
- 本项目仅供个人学习使用,商用授权请联系博主,否则后果自负。
- 博主拥有本软件构建后的应用系统全部内容所有权及独立的知识产权,拥有最终解释权。
- 如有问题,欢迎在仓库 Issue 留言,看到后会第一时间回复,相关意见会酌情考虑,但没有一定被采纳的承诺或保证。
下载本系统代码或使用本系统的用户,必须同意以下内容,否则请勿下载!
- 出于自愿而使用/开发本软件,了解使用本软件的风险,且同意自己承担使用本软件的风险。
- 利用本软件构建的网站的任何信息内容以及导致的任何版权纠纷和法律争议及后果和博主无关,博主对此不承担任何责任。
- 在任何情况下,对于因使用或无法使用本软件而导致的任何难以合理预估的损失(包括但不仅限于商业利润损失、业务中断与业务信息丢失),博主概不承担任何责任。
- 必须了解使用本软件的风险,博主不承诺提供一对一的技术支持、使用担保,也不承担任何因本软件而产生的难以预料的问题的相关责任。