package com.evobms.project.vehicledata.controller;

import java.util.List;
import javax.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.evobms.framework.aspectj.lang.annotation.Log;
import com.evobms.framework.aspectj.lang.enums.BusinessType;
import com.evobms.project.vehicledata.domain.VehicleData;
import com.evobms.project.vehicledata.service.IVehicleDataService;
import com.evobms.framework.web.controller.BaseController;
import com.evobms.framework.web.domain.AjaxResult;
import com.evobms.common.utils.poi.ExcelUtil;
import com.evobms.framework.web.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 整车数据Controller
 *
 * @author 田志阳
 * @date 2025-11-15
 */
@RestController
@RequestMapping("/VehicleData/VehicleData")
@Api(tags = "整车数据管理")
public class VehicleDataController extends BaseController
{
    @Autowired
    private IVehicleDataService vehicleDataService;

    /**
     * 查询整车数据列表
     */
    @PreAuthorize("@ss.hasPermi('VehicleData:VehicleData:list')")
    @GetMapping("/list")
    @ApiOperation("查询整车数据列表")
    public TableDataInfo list(VehicleData vehicleData)
    {
        startPage();
        List<VehicleData> list = vehicleDataService.selectVehicleDataList(vehicleData);
        return getDataTable(list);
    }

    /**
     * 导出整车数据列表
     */
    @PreAuthorize("@ss.hasPermi('VehicleData:VehicleData:export')")
    @Log(title = "整车数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出整车数据列表")
    public void export(HttpServletResponse response, VehicleData vehicleData)
    {
        List<VehicleData> list = vehicleDataService.selectVehicleDataList(vehicleData);
        ExcelUtil<VehicleData> util = new ExcelUtil<VehicleData>(VehicleData.class);
        util.exportExcel(response, list, "整车数据数据");
    }

    /**
     * 获取整车数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('VehicleData:VehicleData:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取整车数据详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(vehicleDataService.selectVehicleDataById(id));
    }

    /**
     * 新增整车数据
     */
    @PreAuthorize("@ss.hasPermi('VehicleData:VehicleData:add')")
    @Log(title = "整车数据", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增整车数据")
    public AjaxResult add(@RequestBody VehicleData vehicleData)
    {
        return toAjax(vehicleDataService.insertVehicleData(vehicleData));
    }

    /**
     * 修改整车数据
     */
    @PreAuthorize("@ss.hasPermi('VehicleData:VehicleData:edit')")
    @Log(title = "整车数据", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改整车数据")
    public AjaxResult edit(@RequestBody VehicleData vehicleData)
    {
        return toAjax(vehicleDataService.updateVehicleData(vehicleData));
    }

    /**
     * 删除整车数据
     */
    @PreAuthorize("@ss.hasPermi('VehicleData:VehicleData:remove')")
    @Log(title = "整车数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除整车数据")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vehicleDataService.deleteVehicleDataByIds(ids));
    }
}
