package com.xindazhou.vehicle.controller.admin.vehicle;

import com.xindazhou.framework.common.pojo.CommonResult;
import com.xindazhou.vehicle.controller.admin.vehicle.vo.CategoryModelCascaderRespVO;
import com.xindazhou.vehicle.service.archive.VehicleCategoryModelService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

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

/**
 * 管理后台 - 车辆分类和型号 Controller
 *
 * @author xindazhou
 */
@Tag(name = "管理后台 - 车辆分类和型号")
@RestController
@RequestMapping("/admin/vehicle/category-model")
@Validated
public class VehicleCategoryModelController {

    @Resource
    private VehicleCategoryModelService vehicleCategoryModelService;

    @GetMapping("/cascader")
    @Operation(summary = "获取分类和型号级联数据")
    @PreAuthorize("@ss.hasPermission('vehicle:archive:query')")
    public CommonResult<List<CategoryModelCascaderRespVO>> getCategoryModelCascader() {
        List<CategoryModelCascaderRespVO> result = vehicleCategoryModelService.getCategoryModelCascader();
        return success(result);
    }

}

