package com.ningdatech.carapi.analysis.controller;


import com.ningdatech.basic.model.PageVo;
import com.ningdatech.carapi.analysis.entity.req.VehicleAccidentEvalModReq;
import com.ningdatech.carapi.analysis.entity.req.VehicleOverSpeedEvalModReq;
import com.ningdatech.carapi.analysis.entity.req.VehicleServiceLifeListReq;
import com.ningdatech.carapi.analysis.entity.req.VehicleViolationEvalModReq;
import com.ningdatech.carapi.analysis.entity.vo.VehicleAccidentEvalListVo;
import com.ningdatech.carapi.analysis.entity.vo.VehicleOverSpeedEvalListVo;
import com.ningdatech.carapi.analysis.entity.vo.VehicleServiceLifeListVo;
import com.ningdatech.carapi.analysis.entity.vo.VehicleViolationEvalListVo;
import com.ningdatech.carapi.analysis.manage.InsuranceRiskEvalManage;
import com.ningdatech.carapi.sys.entity.enumeration.ImportTemplateEnum;
import com.ningdatech.log.annotation.WebLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;

/**
 * <p>
 * 分析评估-保险风险评估 前端控制器
 * </p>
 *
 * @author WendyYang
 * @since 2022-10-15
 */
@Validated
@RestController
@RequiredArgsConstructor
@Api(tags = "分析评估-保险风险评估")
@RequestMapping("/api/v1/insurance-risk-eval")
public class InsuranceRiskEvalController {

    private final InsuranceRiskEvalManage insuranceRiskEvalManage;

    @ApiOperation("车辆使用年限列表")
    @GetMapping("/vehicleServiceLifeList")
    public PageVo<VehicleServiceLifeListVo> vehicleServiceLifeList(@Valid VehicleServiceLifeListReq req) {
        return insuranceRiskEvalManage.vehicleServiceLifeList(req);
    }

    @ApiOperation("车辆违章情况列表")
    @GetMapping("/vehicleViolationList")
    public PageVo<VehicleViolationEvalListVo> vehicleViolationList(@Valid VehicleServiceLifeListReq req) {
        return insuranceRiskEvalManage.vehicleViolationEvalList(req);
    }

    @ApiOperation("车辆出险情况列表")
    @GetMapping("/vehicleAccidentList")
    public PageVo<VehicleAccidentEvalListVo> vehicleAccidentList(@Valid VehicleServiceLifeListReq req) {
        return insuranceRiskEvalManage.vehicleAccidentList(req);
    }

    @ApiOperation("车辆超速情况列表")
    @GetMapping("/vehicleOverSPeedList")
    public PageVo<VehicleOverSpeedEvalListVo> vehicleOverSpeedList(@Valid VehicleServiceLifeListReq req) {
        return insuranceRiskEvalManage.vehicleOverSpeedList(req);
    }

    @ApiOperation("车辆违章情况修改")
    @PutMapping("/modVehicleViolation")
    @WebLog(value = "车辆违章情况修改", modular = "分析评估-保险风险评估")
    public void modVehicleViolation(@Valid @RequestBody VehicleViolationEvalModReq req) {
        insuranceRiskEvalManage.vehicleViolationEvalMod(req);
    }

    @ApiOperation("车辆出险情况修改")
    @PutMapping("/modVehicleAccident")
    @WebLog(value = "车辆出险情况修改", modular = "分析评估-保险风险评估")
    public void modVehicleAccident(@Valid @RequestBody VehicleAccidentEvalModReq req) {
        insuranceRiskEvalManage.vehicleAccidentEvalMod(req);
    }

    @ApiOperation("车辆超速情况修改")
    @PutMapping("/modVehicleOverSpeed")
    @WebLog(value = "车辆超速情况修改", modular = "分析评估-保险风险评估")
    public void modVehicleOverSpeed(@Valid @RequestBody VehicleOverSpeedEvalModReq req) {
        insuranceRiskEvalManage.vehicleOverSpeedEvalMod(req);
    }

    @ApiOperation("车辆违章情况删除")
    @DeleteMapping("/delVehicleViolation/{id}")
    @WebLog(value = "车辆违章情况删除", modular = "分析评估-保险风险评估")
    public void delVehicleViolation(@PathVariable Integer id) {
        insuranceRiskEvalManage.vehicleViolationEvalDel(id);
    }

    @ApiOperation("车辆超速情况删除")
    @DeleteMapping("/delVehicleOverSpeed/{id}")
    @WebLog(value = "车辆超速情况删除", modular = "分析评估-保险风险评估")
    public void delVehicleOverSpeed(@PathVariable Integer id) {
        insuranceRiskEvalManage.vehicleOverSpeedEvalDel(id);
    }

    @ApiOperation("车辆出险情况删除")
    @DeleteMapping("/delVehicleAccident/{id}")
    @WebLog(value = "车辆出险情况删除", modular = "分析评估-保险风险评估")
    public void delVehicleAccident(@PathVariable Integer id) {
        insuranceRiskEvalManage.vehicleAccidentEvalDel(id);
    }

    @ApiOperation("模版数据导入")
    @PostMapping("/importTemplateData")
    @WebLog(value = "模版数据导入", modular = "分析评估-保险风险评估")
    public void importTemplateData(@RequestParam("template") ImportTemplateEnum template, MultipartFile file) {
        insuranceRiskEvalManage.importTemplateData(template, file);
    }
}
