package com.ningdatech.carapi.irs.controller;

import java.io.FileNotFoundException;
import java.util.List;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ningdatech.carapi.irs.manage.DataInitManage;
import com.ningdatech.carapi.irs.service.AccidentService;

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

/**
 * 事故查询
 *
 * @author CMM
 * @since 2023/04/23 14:25
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/open/api/accident/query")
@RequiredArgsConstructor
public class AccidentQueryController {

    private final AccidentService accidentService;

    private final DataInitManage dataInitManage;

    @ApiOperation(value = "事故查询 测试", notes = "事故查询 测试")
    @GetMapping("/test")
    public List<String> test() {
        return accidentService.accidentQuery();
    }


    @ApiOperation(value = "事故查询数据初始化", notes = "事故查询数据初始化")
    @GetMapping("/accidentQueryDataInit")
    public String dataInit() {
        return dataInitManage.dataInit();
    }

    @ApiOperation(value = "事故查询数据批量保存", notes = "事故查询数据批量保存")
    @GetMapping("/accidentQueryDataSave")
    public void dataSave() throws InterruptedException {
        dataInitManage.accidentQueryDataSave();
    }

    @ApiOperation(value = "事故查询数据逐个保存", notes = "事故查询数据逐个保存")
    @GetMapping("/accidentQueryDataSingleSave")
    public void dataSingleSave() {
        dataInitManage.accidentQueryDataSingleSave();
    }

    @ApiOperation(value = "事故查询数据逐个保存", notes = "事故查询数据逐个保存")
    @GetMapping("/dataSingleSave")
    public void singleSave() throws FileNotFoundException {
        dataInitManage.singleSave();
    }

    @ApiOperation(value = "事故查询数据更新", notes = "事故查询数据更新")
    @GetMapping("/updateAccidentData")
    public void updateAccidentData() throws FileNotFoundException {
        dataInitManage.updateAccidentData();
    }
}
