package com.ruoyi.custclient.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.custclient.domain.VehiclePhoto;
import com.ruoyi.custclient.service.IVehiclePhotoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 车辆影像化资料Controller
 * 
 * @author wuyufei
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/vehiclePhoto")
public class VehiclePhotoController extends BaseController
{
    @Autowired
    private IVehiclePhotoService vehiclePhotoService;

    /**
     * 查询车辆影像化资料列表
     */
    @RequiresPermissions("vehiclePhoto:vehiclePhoto:list")
    @GetMapping("/list")
    public TableDataInfo list(VehiclePhoto vehiclePhoto)
    {
        startPage();
        List<VehiclePhoto> list = vehiclePhotoService.selectVehiclePhotoList(vehiclePhoto);
        return getDataTable(list);
    }

    /**
     * 导出车辆影像化资料列表
     */
    @RequiresPermissions("vehiclePhoto:vehiclePhoto:export")
    @Log(title = "车辆影像化资料", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VehiclePhoto vehiclePhoto)
    {
        List<VehiclePhoto> list = vehiclePhotoService.selectVehiclePhotoList(vehiclePhoto);
        ExcelUtil<VehiclePhoto> util = new ExcelUtil<VehiclePhoto>(VehiclePhoto.class);
        util.exportExcel(response, list, "车辆影像化资料数据");
    }

    /**
     * 获取车辆影像化资料详细信息
     */
    @RequiresPermissions("vehiclePhoto:vehiclePhoto:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(vehiclePhotoService.selectVehiclePhotoById(id));
    }

    /**
     * 新增车辆影像化资料
     */
    @RequiresPermissions("vehiclePhoto:vehiclePhoto:add")
    @Log(title = "车辆影像化资料", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VehiclePhoto vehiclePhoto)
    {
        return toAjax(vehiclePhotoService.insertVehiclePhoto(vehiclePhoto));
    }

    /**
     * 修改车辆影像化资料
     */
    @RequiresPermissions("vehiclePhoto:vehiclePhoto:edit")
    @Log(title = "车辆影像化资料", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VehiclePhoto vehiclePhoto)
    {
        return toAjax(vehiclePhotoService.updateVehiclePhoto(vehiclePhoto));
    }

    /**
     * 删除车辆影像化资料
     */
    @RequiresPermissions("vehiclePhoto:vehiclePhoto:remove")
    @Log(title = "车辆影像化资料", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vehiclePhotoService.deleteVehiclePhotoByIds(ids));
    }
}
