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

import com.cusc.nirvana.common.result.PageResult;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.rnr.fp.dto.*;
import com.cusc.nirvana.user.rnr.fp.service.ISimVehicleRelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
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 java.util.List;

/**
 * 车卡关系管理
 */
@RestController
@RequestMapping("/simvehcilerel")
public class SimVehicleRelController {

    @Autowired
    private ISimVehicleRelService simVehicleRelService;

     /**
      * 导入车卡关系接口
      * @param bindingDTO
      * @return
      */
     @PostMapping("importSimVehicle")
     public Response<SimVehicleBindingResult> importSimVehicle(@RequestBody SimVehicleBindingDTO bindingDTO) {
         return simVehicleRelService.importSimVehicle(bindingDTO);
     }

    /**
     * 车卡关系绑定
     * @param requestDTO
     * @return
     */
    @PostMapping("unbind")
    public Response<SimVehicleDTO> unbind(@RequestBody @Validated BindRequestDTO requestDTO) {
        return simVehicleRelService.unbind(requestDTO);
//        return Response.createSuccess();
    }

    /**
     * 车辆绑卡查询
     * @param vin
     * @return
     */
    @GetMapping("getIccidByVin")
    public Response<List<VinIccidDTO>> getIccidByVin(String vin) {
        return simVehicleRelService.getIccidByVin(vin);
    }

    /**
     * 根据iccid查询车卡绑定信息
     * @param iccid
     * @return
     */
    @GetMapping("getVinByIccid")
    public Response<VinIccidDTO> getVinByIccid(String iccid) {
        return simVehicleRelService.getVinByIccid(iccid);
    }

    /**
     * 查看车卡绑定状态
     * @param iccid
     * @param vin
     * @return
     */
    @GetMapping("getBindingInfo")
    public Response<VinIccidDTO> getBindingInfo(String iccid, String vin) {
        return simVehicleRelService.getBindingInfo(iccid, vin);
    }

    /**
     * 获取车卡绑定分页信息列表
     * @param queryDTO
     * @return
     */
    @PostMapping("querySimVehiclePage")
    public Response<PageResult<SimVehicleResultDTO>> querySimVehiclePage(@RequestBody SimVehicleQueryDTO queryDTO) {
        return simVehicleRelService.queryBindingPage(queryDTO);
    }

    /**
     * 查询多个iccid的详细信息
     * @param listDTO
     * @return
     */
    @PostMapping("queryByIccids")
    public Response<List<IccidDetailDTO>> queryByIccids(@RequestBody @Validated IccidListDTO listDTO) {
        return simVehicleRelService.queryByIccids(listDTO);
    }

}
