package com.wteam.controller.court;

import com.wteam.framework.common.vo.ResultMessage;
import com.wteam.framework.modules.book.entity.vo.StoreDetailsVo;
import com.wteam.framework.modules.book.service.StoreService;
import com.wteam.framework.modules.image.service.CbImageService;
import com.wteam.framework.modules.specialValue.service.CbSpecialValueService;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;

/**
 * @author doncic
 * @date 2023/9/16 22:54
 */
@Slf4j
@Tag(name = "门店相关接口管理")
@RestController
@RequestMapping("/v1/court")
public class CourtController {

    @Autowired
    private StoreService storeService;
    @Autowired
    private CbImageService cbImageService;
    @Autowired
    private CbSpecialValueService cbSpecialValueService;


//    /**
//     * 获取对应门店的轮播图信息
//     *
//     * @param id
//     * @return
//     */
//    @Operation(summary = "获取轮播图")
//    @GetMapping("/getPhoto/{id}")
//    public ResultMessage<List<String>> getPhoto(@ApiParam(value = "门店ID", required = true) @PathVariable("id") Long id) {
//        return storeService.getPhoto(id);
//    }


    /**
     * 获取门店信息
     * 先查缓存 有就直接返回
     *
     * @param id 门店id
     * @return
     */
    @Cacheable(value = "storeDetails", key = "#id")
    @Operation(summary = "门店信息")
    @GetMapping("/getCourtDetails/{id}")
    public ResultMessage<StoreDetailsVo> getCourtDetails(@ApiParam(value = "门店ID", required = true) @PathVariable("id") Long id) {
        return storeService.getDetails(id);
    }


    @Operation(summary = "获取轮播图")
    @GetMapping("/getPhoto")
    public ResultMessage getPhoto() {
        return cbImageService.getPhoto();
    }

    @Operation(summary = "获取特殊价格")
    @GetMapping("/getSpecialValue")
    public ResultMessage getSpecialValue() {
        return cbSpecialValueService.getSpecialValue();
    }
}
