package com.ningdatech.carapi.open.controller;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.carapi.car.position.model.po.ReqDataPO;
import com.ningdatech.carapi.driver.manage.DriverArchivesManage;
import com.ningdatech.carapi.driver.model.po.ReqArchivalInfoSearchPO;
import com.ningdatech.carapi.driver.model.vo.ResArchivalInfoDetailVO;
import com.ningdatech.carapi.driver.model.vo.ResArchivalInfoSearchListVO;
import com.ningdatech.carapi.open.model.OpenApiTestReq;
import com.ningdatech.carapi.safe.model.vo.NdVehicleAccidentAnalysisVO;
import com.ningdatech.carapi.safe.model.vo.NdVehicleAccidentDeadVO;
import com.ningdatech.carapi.safe.model.vo.NdVehicleAccidentVO;
import com.ningdatech.carapi.safe.model.vo.NdVehicleViolationVO;
import com.ningdatech.openapi.signature.annatation.OpenApiSignature;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author liuxinxin
 * @date 2022/10/31 下午3:09
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/open/api/v1/driver/archives")
@Api(tags = "外部调用驾驶员详情接口")
@RequiredArgsConstructor
public class OpenApiDriverArchivesController {

    private final DriverArchivesManage driverArchivesManage;

    @PostMapping("/archival-info/search")
    @ApiOperation("驾驶员档案管理查询")
    public PageVo<ResArchivalInfoSearchListVO> archivalInfoSearch(@Valid @RequestBody ReqArchivalInfoSearchPO po) {
        return driverArchivesManage.archivalInfoSearchOpen(po);
    }

    @PostMapping("/archival-info/detail/{driverId}")
    @ApiOperation("获取驾驶员档案详情")
    public ResArchivalInfoDetailVO getArchivalInfoReviewDetail(@PathVariable("driverId") Long driverId) {
        return driverArchivesManage.getDriverArchivalInfo(driverId);
    }

    /**
     * 查询驾驶员违章记录档案
     *
     * @param driverId,violationType
     * @return
     */
    @ApiOperation(value = "查询驾驶员违章记录档案", notes = "查询驾驶员违章记录档案")
    @GetMapping("/violation")
    public List<NdVehicleViolationVO> getViolation(@Valid @RequestParam Long driverId, @Valid @RequestParam Integer violationType) {
        return driverArchivesManage.getViolation(driverId,violationType);
    }

    /**
     * 查询驾驶员事故记录档案
     *
     * @param driverId
     * @return
     */
    @ApiOperation(value = "查询驾驶员事故记录档案", notes = "查询驾驶员事故记录档案")
    @GetMapping("/accident-driver/{driverId}")
    public List<NdVehicleAccidentVO> getAccidentVehicle(@Valid @PathVariable Long driverId) {
        return driverArchivesManage.getAccidentVehicleOpen(driverId);
    }

    /**
     * 查询驾驶员死亡事故记录档案
     *
     * @param driverId
     * @return
     */
    @ApiOperation(value = "查询驾驶员死亡事故记录档案", notes = "查询驾驶员死亡事故记录档案")
    @GetMapping("/accident-dead/{driverId}")
    public List<NdVehicleAccidentDeadVO> getAccidentDead(@Valid @PathVariable Long driverId) {
        return driverArchivesManage.getAccidentDeadOpen(driverId);
    }

    /**
     * 查询驾驶员事故分析记录档案
     *
     * @param driverId
     * @return
     */
    @ApiOperation(value = "查询驾驶员事故分析记录档案", notes = "查询驾驶员事故分析记录档案")
    @GetMapping("/accident-analysis/{driverId}")
    public List<NdVehicleAccidentAnalysisVO> getAccidentAnalysis(@Valid @PathVariable Long driverId) {
        return driverArchivesManage.getAccidentAnalysisOpen(driverId);
    }

    @PostMapping("/archival-info/search-batch")
    @ApiOperation("驾驶员档案管理批量查询")
    public List<ResArchivalInfoSearchListVO> archivalInfoSearchBatch(@Valid @RequestBody ReqDataPO po) {
        return driverArchivesManage.archivalInfoSearchBatchOpen(po);
    }
}
