开发者学堂课程【微服务+全栈在线教育实战项目演练(SpringCloud Alibaba+SpringBoot):课程详情功能接口(2)】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/667/detail/11479
课程详情功能接口(2)
内容介绍:
一、创建一个类作为封装
二、根据课程 id 查询
一、创建一个类作为封装
Public class CourseWebVo {
private static final long serialVersionUID = 1L;
private String id:
@ApiModelProperty(value =“课程标题")
private String title;
@ApiModelProperty(value = 课程销售价格,设置为0则可免费观看")
private BigDepimal price;
@ApiModelProperty(value = "总课时")
private Integer lessonNum;
@ApiModelProperty(value ="课程封面图片路径")
private String cover;
@ApiModelProperty(value ="销售数量")
private Long buyCount;
@ApiModelProperty(value ="浏览数量")
private Long viewCount;
@ApiMlodelProperty(value -“课程简介")
private String description;
@ApiMlodelProperty(value =“讲师ID")
private String teacherId;
@ApiModelProperty(value =“讲师姓名")
private String teacherName;
@ApiMlodelProperty(value =“讲师资历,一句话说明讲师")
private String intro;
@ApiModelProperty(value =“讲师头像")
private String avatar;
@ApiModelProperty(value =“类别名称")
private String subjectLevelOne;
@ApiModelProperty(value =“课程类别ID”)
private String subjectLevelTwoId;
@ApiModelProperty(value =“类别名称")
private String subjectLevelTvo;
}
二、根据课程 id 查询
代码实现:
//课程详情的方法
@GetMapping("getFrontCourseInfo/ {courseId}")
public R getFrontCourseInfo(@PathVariable String courseId){
//根据课程id,编写sql语句查询课程信息
CourseWebVocourseWebVo= courseService.getBaseCourseInfo(courseId);
//根据课程id查询章节和小节
List<ChapterVo> chapterVideoList = chapterService
.getChapterVideoByCourseId(courseId) ;
return R. ok(). data("courseWebVo", courseWebVo). data("chapterVideoList", chapterVideoList)
刷新页面后即可实现功能。