package cn.iocoder.yudao.module.asset.controller.admin.vehicle;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo.VehiclePageReqVO;
import cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo.VehicleRespVO;
import cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo.VehicleSimpleRespVO;
import cn.iocoder.yudao.module.asset.service.vehicle.VehicleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
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 jakarta.validation.Valid;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 车辆管理")
@RestController
@RequestMapping("/asset/vehicle")
@Validated
public class VehicleController {

    @Autowired
    private VehicleService vehicleService;

    @GetMapping("/page")
    @Operation(summary = "获得车辆分页")
    @PreAuthorize("@ss.hasPermission('asset:vehicle:query')")
    public CommonResult<PageResult<VehicleRespVO>> getVehiclePage(@Valid VehiclePageReqVO pageReqVO) {
        PageResult<VehicleRespVO> pageResult = vehicleService.getVehiclePage(pageReqVO);
        return success(pageResult);
    }

    @GetMapping("/simple-list")
    @Operation(summary = "获得车辆精简列表")
    @PreAuthorize("@ss.hasPermission('asset:vehicle:query')")
    public CommonResult<List<VehicleSimpleRespVO>> getVehicleSimpleList(@Valid VehiclePageReqVO reqVO) {
        List<VehicleSimpleRespVO> list = vehicleService.getVehicleSimpleList(reqVO);
        return success(list);
    }

}
