| | |
| | | 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.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.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | 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> |
| | |
| | | * @author mitao |
| | | * @since 2024-08-21 |
| | | */ |
| | | @Api(tags = {"用户端-课程相关接口"}) |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping("/client/course/course") |
| | | public class ClientCourseController { |
| | | |
| | | private final CourseCategoryService courseCategoryService; |
| | | private final CourseService courseService; |
| | | private final RemoteBannerService remoteBannerService; |
| | | private final RemoteAppUserService appUserService; |
| | | @Resource |
| | | private CourseChapterService courseChapterService; |
| | | |
| | | /** |
| | | * 获取轮播图列表 |
| | | * |
| | | * @return 轮播图列表 |
| | | */ |
| | | @GetMapping("/getBannerList") |
| | | @ApiOperation(value = "获取轮播图列表") |
| | | public R<List<BannerVO>> getBannerList() { |
| | | return remoteBannerService.getBannerList(SecurityConstants.INNER); |
| | | } |
| | | |
| | | /** |
| | | * 获取课程分类列表 |
| | | * |
| | | * @return 课程分类列表 |
| | | */ |
| | | @GetMapping("/getCourseCategoryList") |
| | | @ApiOperation(value = "获取课程分类列表") |
| | | public R<List<ClientCourseCategoryVO>> getCourseCategoryList() { |
| | | return R.ok(courseCategoryService.getCourseCategoryList()); |
| | | } |
| | | /** |
| | | * 课程详情 |
| | | * |
| | | * @return 课程详情 |
| | | */ |
| | | @GetMapping("/getCourseInfoById") |
| | | @ApiOperation(value = "根据id获取课程详情-线下课程") |
| | | public R<Course> getCourseInfoById(String id) { |
| | | return R.ok(courseService.getById(id)); |
| | | } |
| | | /** |
| | | * 课程详情 |
| | | * |
| | | * @return 课程详情 |
| | | */ |
| | | @GetMapping("/getPayCourseInfoById") |
| | | @ApiOperation(value = "根据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(clientCourseVO); |
| | | } |
| | | |
| | | /** |
| | | * 获取课程列表-分页 |
| | | * |
| | | * @param courseTitle 课程标题 |
| | | * @param cateId 分类id |
| | | * @param pageCurr 分页参数,当前页码 |
| | | * @param pageSize 分页参数,每页数量 |
| | | * @return 课程分页列表 |
| | | */ |
| | | @PostMapping("/getCoursePageList") |
| | | @ApiOperation(value = "获取课程列表-分页") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "课程标题", name = "courseTitle", required = false, dataType = "String"), |
| | | @ApiImplicitParam(value = "课程分类id", name = "cateId", required = false, dataType = "Long"), |
| | | @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = true, dataType = "Integer"), |
| | | @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = true, dataType = "Integer") |
| | | }) |
| | | public R<PageDTO<ClientCourseVO>> getCourseList( |
| | | @RequestParam(defaultValue = "", value = "courseTitle", required = false) String courseTitle, |
| | | @RequestParam(required = false) Long cateId, |
| | | @RequestParam(value = "pageCurr", defaultValue = "1") Integer pageCurr, |
| | | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | return R.ok(courseService.getCoursePageList(courseTitle, cateId, pageCurr, pageSize)); |
| | | } |
| | | } |
| | | |