package com.xiaoniu.system.platformusers.vehicle.controller;

import com.xiaoniu.common.core.resdata.Result;
import com.xiaoniu.common.core.resdata.RowsData;
import com.xiaoniu.common.core.vo.LabelAndValueVO;
import com.xiaoniu.system.platformusers.vehicle.dto.UserCarQueryDTO;
import com.xiaoniu.system.platformusers.vehicle.service.ITbVehicleInfoService;
import com.xiaoniu.system.platformusers.vehicle.vo.UserCarListVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 我的车辆信息表 前端控制器
 * </p>
 *
 * @author haoxuyang
 * @since 2024-10-15 10:21:02
 */
@Tag(name = "用户车辆管理")
@RestController
@RequestMapping("/userCar")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class TbVehicleInfoController {
    private final ITbVehicleInfoService tbVehicleInfoService;

    @Operation(summary = "用户车库列表")
    @PostMapping("/list")
    public Result<RowsData<UserCarListVO>> list(@RequestBody UserCarQueryDTO dto) {
        return Result.success("查询成功", tbVehicleInfoService.getUserCarList(dto));
    }

    @Operation(summary = "获取车型列表")
    @GetMapping("/getCarBrandList")
    public Result<List<LabelAndValueVO>> getCarBrandList(@RequestParam(required = false) Long carBrandId) {
        return Result.success("查询成功", tbVehicleInfoService.getCarBrandList(carBrandId));
    }

}
