5.1 查询课程数据
@RequestMapping(value = "/getByPage", method = RequestMethod.GET)
@ApiOperation(value = "查询课程")
public Result<IPage<Course>> getByPage(@ModelAttribute Course course ,@ModelAttribute PageVo page){
QueryWrapper<Course> qw = new QueryWrapper<>();
if(!ZwzNullUtils.isNull(course.getTitle())) {
qw.like("title",course.getTitle());
}
if(!ZwzNullUtils.isNull(course.getTeacherName())) {
qw.like("teacher_name",course.getTeacherName());
}
IPage<Course> data = iCourseService.page(PageUtil.initMpPage(page),qw);
return new ResultUtil<IPage<Course>>().setData(data);
}
5.2 新增课时
@RequestMapping(value = "/insert", method = RequestMethod.POST)
@ApiOperation(value = "新增课时")
public Result<ClassHour> insert(ClassHour classHour){
Course course = iCourseService.getById(classHour.getCourseId());
if(course == null) {
return ResultUtil.error("课程不存在");
}
classHour.setCourseName(course.getTitle());
iClassHourService.saveOrUpdate(classHour);
return new ResultUtil<ClassHour>().setData(classHour);
}
5.3 提交作业
@RequestMapping(value = "/upload", method = RequestMethod.GET)
@ApiOperation(value = "提交作业")
public Result<Task> upload(@RequestParam String id,@RequestParam String url){
Task task = iTaskService.getById(id);
if(task == null) {
return ResultUtil.error("作业不存在");
}
task.setUploadTime(DateUtil.now());
task.setTask(url);
iTaskService.saveOrUpdate(task);
return ResultUtil.success();
}
5.4 批阅作业
@RequestMapping(value = "/check", method = RequestMethod.GET)
@ApiOperation(value = "批阅作业")
public Result<Task> check(@RequestParam String id,@RequestParam BigDecimal grade){
Task task = iTaskService.getById(id);
if(task == null) {
return ResultUtil.error("作业不存在");
}
User currUser = securityUtil.getCurrUser();
task.setCheckId(currUser.getId());
task.setCheckName(currUser.getNickname());
task.setCheckTime(DateUtil.now());
task.setGrade(grade);
iTaskService.saveOrUpdate(task);
return ResultUtil.success();
}