package com.ycwl.basic.controller.mobile;

import com.github.pagehelper.PageInfo;
import com.ycwl.basic.annotation.IgnoreToken;
import com.ycwl.basic.model.jwt.JwtInfo;
import com.ycwl.basic.model.mobile.scenic.ScenicAppVO;
import com.ycwl.basic.model.mobile.scenic.ScenicDeviceCountVO;
import com.ycwl.basic.model.mobile.scenic.content.ContentPageVO;
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
import com.ycwl.basic.model.pc.scenic.resp.ScenicConfigResp;
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
import com.ycwl.basic.repository.ScenicRepository;
import com.ycwl.basic.service.mobile.AppScenicService;
import com.ycwl.basic.service.pc.FaceService;
import com.ycwl.basic.utils.ApiResponse;
import com.ycwl.basic.utils.JwtTokenUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author：longbinbin
 * @Date：2024/12/5 10:22
 */
@Slf4j
@Deprecated
@RestController
@RequestMapping("/api/mobile/scenic/v1")
@Api(tags = "景区相关接口")
public class AppScenicController {

    @Autowired
    private FaceService faceService;
    @Autowired
    private AppScenicService appScenicService;
    @Autowired
    private ScenicRepository scenicRepository;

    @ApiOperation("分页查询景区列表")
    @PostMapping("/page")
    public ApiResponse<PageInfo<ScenicAppVO>> pageQuery(@RequestBody ScenicReqQuery scenicReqQuery){
        return appScenicService.pageQuery(scenicReqQuery);
    }
    @ApiOperation("根据id查询景区详情")
    @IgnoreToken
    @GetMapping("/{id}")
    public ApiResponse<ScenicRespVO> getDetails(@PathVariable Long id){
        return appScenicService.getDetails(id);
    }

    @GetMapping("/{id}/config")
    @IgnoreToken
    public ApiResponse<ScenicConfigResp> getConfig(@PathVariable Long id){
        ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(id);
        ScenicConfigResp resp = new ScenicConfigResp();
        resp.setBookRoutine(scenicConfig.getBookRoutine());
        resp.setForceFinishTime(scenicConfig.getForceFinishTime());
        resp.setTourTime(scenicConfig.getTourTime());
        resp.setSampleStoreDay(scenicConfig.getSampleStoreDay());
        resp.setFaceStoreDay(scenicConfig.getFaceStoreDay());
        resp.setVideoStoreDay(scenicConfig.getVideoStoreDay());
        resp.setAllFree(scenicConfig.getAllFree());
        resp.setDisableSourceVideo(scenicConfig.getDisableSourceVideo());
        resp.setDisableSourceImage(scenicConfig.getDisableSourceImage());
        resp.setAntiScreenRecordType(scenicConfig.getAntiScreenRecordType());
        resp.setVideoSourceStoreDay(scenicConfig.getVideoSourceStoreDay());
        resp.setImageSourceStoreDay(scenicConfig.getImageSourceStoreDay());
        resp.setUserSourceExpireDay(scenicConfig.getUserSourceExpireDay());
        resp.setBrokerDirectRate(scenicConfig.getBrokerDirectRate());
        resp.setVideoSourcePackHint(scenicConfig.getVideoSourcePackHint());
        resp.setImageSourcePackHint(scenicConfig.getImageSourcePackHint());
        return ApiResponse.success(resp);
    }

    @ApiOperation("查询景区设备总数和拍到用户的机位数量")
    @GetMapping("/{scenicId}/deviceCount/")
    public ApiResponse<ScenicDeviceCountVO> deviceCountByScenicId(@PathVariable Long scenicId){
        return appScenicService.deviceCountByScenicId(scenicId);
    }

    @ApiOperation("景区视频源素材列表")
    @GetMapping("/contentList/")
    public ApiResponse<List<ContentPageVO>> contentList() {
        return faceService.contentListUseDefaultFace();
    }

    @ApiOperation("景区视频源素材列表")
    @GetMapping("/face/{faceId}/contentList")
    public ApiResponse<List<ContentPageVO>> contentList(@PathVariable Long faceId) {
        List<ContentPageVO> contentPageVOS = faceService.faceContentList(faceId);
        return  ApiResponse.success(contentPageVOS);
    }
}
