package org.jeecg.modules.app.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.app.service.IDetailService;
import org.jeecg.modules.app.vo.CourseInfoVO;
import org.jeecg.modules.app.vo.PlaceInfoVO;
import org.jeecg.modules.app.vo.course.CourseRequestVo;
import org.jeecg.modules.app.vo.course.CourseResponseVo;
import org.jeecg.modules.system.app.entity.AppCategory;
import org.springframework.web.bind.annotation.GetMapping;
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;
import java.util.List;
@Slf4j
@Tag(name = "App详情相关接口")
@RestController
@RequestMapping("/app/detail")
public class AppDetailController {
    @Resource
    private IDetailService detailService;
    /**
     * @Author SheepHy
     * @Description 门店详情信息查询
     * @Date 19:41 2025/7/7
     * @Param id 门店id
     * @return PlaceInfoVO {@link PlaceInfoVO}
     **/
    @GetMapping("/getPlaceInfo")
    @Operation(summary = "门店详情信息查询 ")
    public Result<PlaceInfoVO> getPlaceInfo(@RequestParam @Schema(description="门店ID") String id){
        return Result.ok(detailService.getPlaceInfo(id));
    }

    /**
     * @Author SheepHy
     * @Description 课程详情
     * @Date 13:36 2025/7/8
     * @Param id 课程id
     * @return CourseInfoVO {@link CourseInfoVO}
     **/
    @GetMapping("/getCourseInfo")
    @Operation(summary = "课程详情")
    public Result<CourseInfoVO> getCourseInfo(@RequestParam @Schema(description="课程ID")String id,
                                              @RequestParam(required = false) double latitude,
                                              @RequestParam(required = false) double longitude){
        return Result.ok(detailService.getCourseInfo(id, latitude, longitude));
    }

    /**
     * @Author SheepHy
     * @Description 根据课程类型查询课程列表
     * @Date 9:52 2025/7/9
     * @return List<PlaceInfoVO.CourseInfoVO>
     **/
    @GetMapping("/courseInfoVOList")
    @Operation(summary = "根据课程类型查询课程列表")
    public Result<List<PlaceInfoVO.CourseInfoVO>> courseInfoVOList(@RequestParam @Schema(description="类目id")String categoryId, @RequestParam @Schema(description="店铺ID")String id,@RequestParam @Schema(description="经度")double longitude,@RequestParam @Schema(description="纬度")double latitude){
        return Result.ok(detailService.courseInfoVOList(categoryId,id,longitude,latitude));
    }

    /**
     * @Author SheepHy
     * @Description 根据类目类型查询体育馆场地空闲时间段(包场 -门店详情页使用)
     * @Date 10:14 2025/7/9
     * @Param id, categoryId
     * @return PlaceInfoVO.theGymnasiumIsCharteredVO
     **/
    @GetMapping("/getPlaceInfoNoFixation")
    @Operation(summary = "根据类目类型查询体育馆场地空闲时间段(包场 -门店详情页使用)")
    public Result<PlaceInfoVO.theGymnasiumIsCharteredVO> getPlaceInfoNoFixation(@RequestParam @Schema(description="门店ID")String id, @RequestParam @Schema(description="类目")String categoryId){
        return Result.ok(detailService.getPlaceInfoNoFixation(id, categoryId));
    }

    /**
     * @Author SheepHy
     * @Description 获取所有类目
     * @Date 10:14 2025/7/9
     **/
    @GetMapping("/getAllCategory")
    @Operation(summary = "获取所有类目")
    public Result<List<AppCategory>> getAllCategory(@RequestParam @Schema(description="门店ID")String id){
        return Result.ok(detailService.getAllCategory(id));
    }

    /**
     * @Author SheepHy
     * @Description 获取所有课程类目
     * @Date 10:14 2025/7/9
     **/
    @GetMapping("/getAllCourseCategory")
    @Operation(summary = "获取所有类目")
    public Result<List<AppCategory>> getAllCourseCategory(@RequestParam @Schema(description="门店ID")String id){
        return Result.ok(detailService.getAllCourseCategory(id));
    }

    /**
     * @Author zx
     * @Description 查询课时列表封装
     * @Date 10:14 2025/7/9
     **/
    @GetMapping("/findByCourseList")
    @Operation(summary = "查询课程列表封装")
    public Result<IPage<CourseResponseVo>> findByCourseList(CourseRequestVo courseRequestVo){
        return Result.ok(detailService.findByCourseList(courseRequestVo));
    }
}
