package com.qaup.web.controller.system;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qaup.common.annotation.Log;
import com.qaup.common.core.controller.BaseController;
import com.qaup.common.core.domain.AjaxResult;
import com.qaup.common.enums.BusinessType;
import com.qaup.system.domain.SysVehicleInfo;
import com.qaup.system.service.ISysVehicleInfoService;
import com.qaup.common.utils.poi.ExcelUtil;
import com.qaup.common.core.page.TableDataInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;

/**
 * 车辆信息Controller
 * 
 * @author tellme
 * @date 2025-07-01
 */
@Tag(name = "车辆信息管理")
@RestController
@RequestMapping("/system/vehicle_info")
public class SysVehicleInfoController extends BaseController
{
    @Autowired
    private ISysVehicleInfoService sysVehicleInfoService;

    /**
     * 查询车辆信息列表
     */
    //@PreAuthorize("@ss.hasPermi('system:vehicle_info:list')")
    @Operation(summary = "查询车辆信息列表")
    @GetMapping("/list")
    public TableDataInfo list(SysVehicleInfo sysVehicleInfo)
    {
        startPage();
        List<SysVehicleInfo> list = sysVehicleInfoService.selectSysVehicleInfoList(sysVehicleInfo);
        return getDataTable(list);
    }

    /**
     * 导出车辆信息列表
     */
    //@PreAuthorize("@ss.hasPermi('system:vehicle_info:export')")
    @Operation(summary = "导出车辆信息列表")
    @Log(title = "车辆信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysVehicleInfo sysVehicleInfo)
    {
        List<SysVehicleInfo> list = sysVehicleInfoService.selectSysVehicleInfoList(sysVehicleInfo);
        ExcelUtil<SysVehicleInfo> util = new ExcelUtil<SysVehicleInfo>(SysVehicleInfo.class);
        util.exportExcel(response, list, "车辆信息数据");
    }

    /**
     * 获取车辆信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:vehicle_info:query')")
    @Operation(summary = "获取车辆信息详细信息")
    @Parameter(name = "vehicleId", description = "车辆ID", required = true)
    @GetMapping(value = "/{vehicleId}")
    public AjaxResult getInfo(@PathVariable("vehicleId") Long vehicleId)
    {
        return success(sysVehicleInfoService.selectSysVehicleInfoByVehicleId(vehicleId));
    }

    /**
     * 新增车辆信息
     */
    //@PreAuthorize("@ss.hasPermi('system:vehicle_info:add')")
    @Operation(summary = "新增车辆信息")
    @Log(title = "车辆信息", businessType = BusinessType.INSERT)
    @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "车辆信息对象", required = true, content = @Content(mediaType = "application/json", schema = @Schema(implementation = SysVehicleInfo.class)))
    @PostMapping
    public AjaxResult add(@RequestBody SysVehicleInfo sysVehicleInfo)
    {
        return toAjax(sysVehicleInfoService.insertSysVehicleInfo(sysVehicleInfo));
    }

    /**
     * 修改车辆信息
     */
    //@PreAuthorize("@ss.hasPermi('system:vehicle_info:edit')")
    @Operation(summary = "修改车辆信息")
    @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "车辆信息对象", required = true, content = @Content(mediaType = "application/json", schema = @Schema(implementation = SysVehicleInfo.class)))
    @Log(title = "车辆信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysVehicleInfo sysVehicleInfo)
    {
        return toAjax(sysVehicleInfoService.updateSysVehicleInfo(sysVehicleInfo));
    }

    /**
     * 删除车辆信息
     */
    //@PreAuthorize("@ss.hasPermi('system:vehicle_info:remove')")
    @Operation(summary = "删除车辆信息")
    @Log(title = "车辆信息", businessType = BusinessType.DELETE)
    @Parameter(name = "vehicleIds", description = "车辆ID", required = true)
	@DeleteMapping("/{vehicleIds}")
    public AjaxResult remove(@PathVariable Long[] vehicleIds)
    {
        return toAjax(sysVehicleInfoService.deleteSysVehicleInfoByVehicleIds(vehicleIds));
    }
}
