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.VehicleLocation;
import com.evobms.project.vehicledata.service.IVehicleLocationService;
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 ruoyi
 * @date 2025-11-15
 */
@RestController
@RequestMapping("/location/location")
@Api(tags = "车辆位置管理")
public class VehicleLocationController extends BaseController
{
    @Autowired
    private IVehicleLocationService vehicleLocationService;

    /**
     * 查询车辆位置数据列表
     */
    @PreAuthorize("@ss.hasPermi('location:location:list')")
    @GetMapping("/list")
    @ApiOperation("查询车辆位置列表")
    public TableDataInfo list(VehicleLocation vehicleLocation)
    {
        startPage();
        List<VehicleLocation> list = vehicleLocationService.selectVehicleLocationList(vehicleLocation);
        return getDataTable(list);
    }

    /**
     * 导出车辆位置数据列表
     */
    @PreAuthorize("@ss.hasPermi('location:location:export')")
    @Log(title = "车辆位置数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出车辆位置列表")
    public void export(HttpServletResponse response, VehicleLocation vehicleLocation)
    {
        List<VehicleLocation> list = vehicleLocationService.selectVehicleLocationList(vehicleLocation);
        ExcelUtil<VehicleLocation> util = new ExcelUtil<VehicleLocation>(VehicleLocation.class);
        util.exportExcel(response, list, "车辆位置数据数据");
    }

    /**
     * 获取车辆位置数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('location:location:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取车辆位置详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(vehicleLocationService.selectVehicleLocationById(id));
    }

    /**
     * 新增车辆位置数据
     */
    @PreAuthorize("@ss.hasPermi('location:location:add')")
    @Log(title = "车辆位置数据", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增车辆位置")
    public AjaxResult add(@RequestBody VehicleLocation vehicleLocation)
    {
        return toAjax(vehicleLocationService.insertVehicleLocation(vehicleLocation));
    }

    /**
     * 修改车辆位置数据
     */
    @PreAuthorize("@ss.hasPermi('location:location:edit')")
    @Log(title = "车辆位置数据", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改车辆位置")
    public AjaxResult edit(@RequestBody VehicleLocation vehicleLocation)
    {
        return toAjax(vehicleLocationService.updateVehicleLocation(vehicleLocation));
    }

    /**
     * 删除车辆位置数据
     */
    @PreAuthorize("@ss.hasPermi('location:location:remove')")
    @Log(title = "车辆位置数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除车辆位置")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vehicleLocationService.deleteVehicleLocationByIds(ids));
    }
}
