跳到主要内容

第十三天、公众号点播课程和直播管理

一、实现公众号点播课程相关功能

1、课程列表和详情

1.1、需求说明

(1)点击课程中的分类,根据分类查询课程列表

image-20220304100147378

image-20220304094032420

(2)点击 去看看,进入课程详情页面

image-20220304094143811

1.2、编写课程列表和详情接口

(1)创建CourseApiController

@Api(tags = "课程")
@RestController
@RequestMapping("/api/vod/course")
public class CourseApiController {

@Autowired
private CourseService courseService;

@Autowired
private ChapterService chapterService;

//根据课程分类查询课程列表(分页)
@ApiOperation("根据课程分类查询课程列表")
@GetMapping("{subjectParentId}/{page}/{limit}")
public Result findPageCourse(@ApiParam(value = "课程一级分类ID", required = true) @PathVariable Long subjectParentId,
@ApiParam(name = "page", value = "当前页码", required = true) @PathVariable Long page,
@ApiParam(name = "limit", value = "每页记录数", required = true) @PathVariable Long limit) {
//封装条件
CourseQueryVo courseQueryVo = new CourseQueryVo();
courseQueryVo.setSubjectParentId(subjectParentId);
//创建page对象
Page<Course> pageParam = new Page<>(page,limit);
Map<String,Object> map = courseService.findPage(pageParam,courseQueryVo);
return Result.ok(map);
}

//根据ID查询课程
@ApiOperation("根据ID查询课程")
@GetMapping("getInfo/{courseId}")
public Result getInfo(
@ApiParam(value = "课程ID", required = true)
@PathVariable Long courseId){
Map<String, Object> map = courseService.getInfoById(courseId);
return Result.ok(map);
}
}