package com.muyu.enterprise.controller;

import com.muyu.common.core.domain.Result;
import com.muyu.enterprise.domain.CarType;
import com.muyu.enterprise.service.CarTypeService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 车辆类型控制层
 * @ClassName CarController
 * @Description 车辆类型Controller层
 * @Author YiBo.Liu
 * @Date 2024/9/22 16:52
 */
@RestController
@RequestMapping("/carType")
@Tag(name = "CarTypeController",description = "车辆类型")
public class CarTypeController {

    @Autowired
    private CarTypeService carTypeService;

    /**
     * 查询所有规则
     * @return carTypeList
     */
    @GetMapping("/carTypeList")
    private Result<List<CarType>> carTypeList() {
        List<CarType> carTypeList = carTypeService.list();
        return Result.success(carTypeList);
    }

    /**
     * 通过id查询类型对象
     * @param catTypeId
     * @return
     */
    @PostMapping("/catTypeId")
    private Result<CarType> catTypeId(@RequestParam("catTypeId") Integer catTypeId) {
        CarType carType = carTypeService.findById(catTypeId);
        return Result.success(carType);
    }


}
