package com.bicloud.controller;

import com.bicloud.common.result.PageResult;
import com.bicloud.common.result.Result;
import com.bicloud.pojo.dto.CoursePageQueryDto;
import com.bicloud.pojo.vo.CourseCardVo;
import com.bicloud.pojo.vo.CourseCatVo;
import com.bicloud.service.CourseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@CrossOrigin //跨域
@RestController
@RequestMapping("/course")
@Tag(name = "课程中心", description = "课程中心相关接口")
@Slf4j
public class CourseController {
    private final CourseService courseService;

    public CourseController(CourseService courseService) {
        this.courseService = courseService;
    }

    // 获取课程分类列表
    @GetMapping("/cats")
    @Operation(summary = "获取分类列表")
    public Result<List<CourseCatVo>> listCourseCats() {
        List<CourseCatVo> cats = courseService.listCourseCats();
        return Result.success(cats);
    }

    // 课程中心分页查询
    @GetMapping("/page")
    @Operation(summary = "课程条件查询")
    public Result<PageResult<CourseCardVo>> pageQuery(CoursePageQueryDto queryDTO) {
        return Result.success(courseService.pageQuery(queryDTO));
    }

}
