package com.cusc.nirvana.user.rnr.fp.controller;

import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.rnr.fp.dto.VinCardDTO;
import com.cusc.nirvana.user.rnr.fp.dto.VinCardInfoDTO;
import com.cusc.nirvana.user.rnr.fp.dto.VinCardListRequestDTO;
import com.cusc.nirvana.user.rnr.fp.service.IVinCardService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * @author stayAnd
 * @date 2022/4/11
 */
@RestController
@RequestMapping("/vinCard")
@Slf4j
public class VinCardController {

    @Resource
    private IVinCardService vinCardService;

    @GetMapping("/queryVinCard/{vin}")
    public Response<VinCardInfoDTO> queryVinCard(@PathVariable("vin") String vin) {
        return Response.createSuccess(vinCardService.queryVinCard(vin));
    }

    @PostMapping("/queryVinCardList")
    public Response<List<VinCardInfoDTO>> queryVinCardList(@RequestBody VinCardListRequestDTO dto) {
        return Response.createSuccess(vinCardService.queryVinCardList(dto.getVinList()));
    }

    @PostMapping("/verifyVinCard")
    public Response queryVinCardList(@Valid @RequestBody List<VinCardDTO> verifyDTOs) {
        return vinCardService.verifyVinCard(verifyDTOs);
    }
}
