package com.muyu.server.controller;

import com.muyu.common.core.domain.Result;
import com.muyu.common.domain.CarType;
import com.muyu.server.service.CarTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 车辆类型管理
 * @author  liuxingue
 * @package com.muyu.server.controller
 * @name CarTypeController
 * @Date 2024/9/29 12:06
 */



@RestController
@RequestMapping("/carType")
@AllArgsConstructor
@Tag(name = "车辆类型管理",description = "车辆类型管理")
@Log4j2
public class CarTypeController {
    @Autowired
    private CarTypeService carTypeService;

    /**
     * 车辆类型列表
     * @return
     */
    @GetMapping("/selectCarTypeList")
    @Operation(summary = "车辆类型列表",description = "车辆类型列表")
    public Result selectCarTypeList(){
     return Result.success(carTypeService.selectCarTypeList());
    }

    /**
     * 车辆类型列表
     * @param id 参数
     * @return
     */
    @GetMapping("/selectCarTypeRespList/{id}")
    @Operation(summary = "根据车辆ID查询车辆列表",description ="根据车辆ID查询车辆列表" )
    public Result selectCarTypeRespList(@PathVariable("id") Long id) {
        return Result.success(carTypeService.selectCarTypeRespList(id));
    }

    /**
     * 根据类型ID获取车辆类型
     * @param carTypeId
     * @return
     */
    @PostMapping("/findCarTypeById")
    @Operation(summary = "根据类型ID获取车辆类型",description = "根据类型ID获取车辆类型")
    public Result<CarType> findCarTypeById(@RequestParam Long carTypeId) {
        return Result.success(carTypeService.findCarTypeById(carTypeId));
    }

}
