package com.xindazhou.vehicle.api;

import com.xindazhou.framework.common.pojo.CommonResult;
import com.xindazhou.vehicle.api.dto.VehicleRespDTO;
import com.xindazhou.vehicle.service.VehicleService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import java.util.List;

import static com.xindazhou.framework.common.pojo.CommonResult.success;

/**
 * 车辆信息 API 实现类
 *
 * @author xindazhou
 */
@RestController
@Validated
public class VehicleApiImpl implements VehicleApi {

    @Resource
    private VehicleService vehicleService;

    @Override
    public CommonResult<VehicleRespDTO> getVehicle(Long id) {
        VehicleRespDTO vehicle = vehicleService.getVehicle(id);
        return success(vehicle);
    }

    @Override
    public CommonResult<VehicleRespDTO> getVehicleByVin(String vin) {
        VehicleRespDTO vehicle = vehicleService.getVehicleByVin(vin);
        return success(vehicle);
    }

    @Override
    public CommonResult<List<VehicleRespDTO>> listVehicleByUserId(Long userId, Integer userType) {
        List<VehicleRespDTO> vehicles = vehicleService.listVehicleByUserId(userId, userType);
        return success(vehicles);
    }

}

