| | |
| | | package com.xinquan.course.controller.client; |
| | | |
| | | |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.constant.SecurityConstants; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.page.BeanUtils; |
| | | import com.xinquan.common.core.utils.page.CollUtils; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.course.domain.Course; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.domain.CourseChapter; |
| | | import com.xinquan.course.domain.vo.ClientCourseCategoryVO; |
| | | import com.xinquan.course.domain.vo.ClientCourseVO; |
| | | import com.xinquan.course.service.CourseCategoryService; |
| | | import com.xinquan.course.service.CourseChapterService; |
| | | import com.xinquan.course.service.CourseService; |
| | | import com.xinquan.system.api.RemoteBannerService; |
| | | import com.xinquan.system.api.domain.vo.BannerVO; |
| | | import com.xinquan.user.api.feign.RemoteAppUserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | import io.swagger.models.auth.In; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private final CourseCategoryService courseCategoryService; |
| | | private final CourseService courseService; |
| | | private final RemoteBannerService remoteBannerService; |
| | | private final RemoteAppUserService appUserService; |
| | | @Resource |
| | | private CourseChapterService courseChapterService; |
| | | |
| | | /** |
| | | * 获取轮播图列表 |
| | |
| | | */ |
| | | @GetMapping("/getPayCourseInfoById") |
| | | @ApiOperation(value = "根据id获取课程详情-付费课程") |
| | | public R<Course> getPayCourseInfoById(String id) { |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "课程id", name = "id", required = true, dataType = "String"), |
| | | @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = true, dataType = "Integer"), |
| | | @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = true, dataType = "Integer") |
| | | }) |
| | | public R<ClientCourseVO> getPayCourseInfoById(@RequestParam(value = "id")Long id, |
| | | @RequestParam(value = "pageCurr", defaultValue = "1") Integer pageCurr, |
| | | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | Course byId = courseService.getById(id); |
| | | ClientCourseVO clientCourseVO = new ClientCourseVO(); |
| | | BeanUtils.copyProperties(byId, clientCourseVO); |
| | | // 查询章节 |
| | | Page<CourseChapter> page = courseChapterService.lambdaQuery() |
| | | .eq(CourseChapter::getCourseId, id) |
| | | .orderByDesc(CourseChapter::getSortNum) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | | PageDTO<CourseChapter> empty = PageDTO.empty(page); |
| | | clientCourseVO.setList(empty); |
| | | } |
| | | // 查询学习人数和头像列表 |
| | | List<String> data = appUserService.getUserByCourseId(id).getData(); |
| | | if (data!=null){ |
| | | clientCourseVO.setCount(data.size()); |
| | | } |
| | | clientCourseVO.setHeaders(data); |
| | | // 查询推荐课程 |
| | | |
| | | return R.ok(courseService.getById(id)); |
| | | return R.ok(clientCourseVO); |
| | | } |
| | | |
| | | /** |