package com.ningdatech.carapi.road.controller;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.carapi.road.manage.RoadMonitorManage;
import com.ningdatech.carapi.road.model.req.RoadMonitorHandleReq;
import com.ningdatech.carapi.road.model.req.RoadMonitorReq;
import com.ningdatech.carapi.road.model.req.VideoDownloadReq;
import com.ningdatech.carapi.road.model.vo.*;
import com.ningdatech.carapi.road.model.vo.RoadDangerBehaviorVO;
import com.ningdatech.carapi.road.model.vo.VehicleGpsDataVO;
import com.ningdatech.log.annotation.WebLog;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author PoffyZhang
 * @since 2022-10-09
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/road-monitor")
@RequiredArgsConstructor
public class RoadMonitorController {

    private final RoadMonitorManage roadMonitorManage;

    @ApiOperation(value = "综合态势数据", notes = "综合态势数据")
    @GetMapping("/get-comprehensive-situation-data")
    public ComprehensiveSituationVO getComSitData(RoadMonitorReq req) {
        return roadMonitorManage.getComSitData(req);
    }

    @ApiOperation(value = "危险行为数据", notes = "危险行为数据")
    @GetMapping("/get-road-danger-behavior-data")
    public PageVo<RoadDangerBehaviorVO> getRoadDangerBehaviorData(RoadMonitorReq req) {
        return roadMonitorManage.getRoadDangerBehaviorData(req);
    }

    @ApiOperation(value = "违法违章与预警记录数据", notes = "违法违章与预警记录列表")
    @GetMapping("/get-violation-warn-record-data")
    public List<RoadDangerBehaviorVO> getViolationWarnRecordData(RoadMonitorReq req) {
        return roadMonitorManage.getViolationWarnRecordData(req);
    }

    @ApiOperation(value = "危险行为数据处理", notes = "危险行为数据处理")
    @PostMapping("/handle-violation-record")
    public String handleViolationRecord(@Valid @RequestBody RoadMonitorHandleReq req) {
        return roadMonitorManage.handleViolationRecord(req);
    }

    @ApiOperation(value = "数据驾驶舱GPS数据", notes = "数据驾驶舱GPS数据")
    @GetMapping("/vehicle-gps-data")
    public List<VehicleGpsDataVO> getVehicleGpsData(RoadMonitorReq req) {
        return roadMonitorManage.getVehicleGpsData(req);
    }


    @GetMapping("/video/download")
    @ApiOperation("视频下载")
    @WebLog("视频下载")
    public void videoDownload(VideoDownloadReq req, HttpServletResponse response){
        roadMonitorManage.videoDownload(req,response);
    }

    @GetMapping("/picture/download")
    @ApiOperation("图片下载")
    @WebLog("图片下载")
    public void pictureDownload(VideoDownloadReq req, HttpServletResponse response){
        roadMonitorManage.pictureDownload(req,response);
    }

    @ApiOperation(value = "实施综合态势数据", notes = "实时综合态势数据")
    @GetMapping("/get-real-time-comprehensive-situation-data")
    public List<RoadScoreVO> getRealTimeComSitData(RoadMonitorReq req){
        return roadMonitorManage.getRealTimeComSitData(req);
    }

    @ApiOperation(value = "实时车流量数据", notes = "实时车流量数据")
    @GetMapping("/get-real-time-traffic-flow-data")
    public List<TrafficFlowVO> getRealTimeTrafficFlowData(RoadMonitorReq req){
        return roadMonitorManage.getRealTimeTrafficFlowData(req);
    }

}
