package com.fastbee.data.controller.aaScreenAgricultural.deviceBaseInfo;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.deviceInfo.domain.DeviceInformationTargetpests;
import com.fastbee.deviceInfo.service.IDeviceInformationTargetpestsService;
import com.fastbee.common.utils.poi.ExcelUtil;
import com.fastbee.common.core.page.TableDataInfo;

/**
 * 靶标害虫设备基础信息Controller
 *
 * @author kerwincui
 * @date 2024-11-27
 */
@RestController
@RequestMapping("/deviceInfo/targetPests")
@Api(tags = "靶标害虫设备基础信息")
public class DeviceInformationTargetpestsController extends BaseController
{
    @Autowired
    private IDeviceInformationTargetpestsService deviceInformationTargetpestsService;

/**
 * 查询靶标害虫设备基础信息列表
 */
@PreAuthorize("@ss.hasPermi('deviceInfo:targetPests:list')")
@GetMapping("/list")
@ApiOperation("查询靶标害虫设备基础信息列表")
    public TableDataInfo list(DeviceInformationTargetpests deviceInformationTargetpests)
    {
        startPage();
        List<DeviceInformationTargetpests> list = deviceInformationTargetpestsService.selectDeviceInformationTargetpestsList(deviceInformationTargetpests);
        return getDataTable(list);
    }

    /**
     * 导出靶标害虫设备基础信息列表
     */
    @ApiOperation("导出靶标害虫设备基础信息列表")
    @PreAuthorize("@ss.hasPermi('deviceInfo:targetPests:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceInformationTargetpests deviceInformationTargetpests)
    {
        List<DeviceInformationTargetpests> list = deviceInformationTargetpestsService.selectDeviceInformationTargetpestsList(deviceInformationTargetpests);
        ExcelUtil<DeviceInformationTargetpests> util = new ExcelUtil<DeviceInformationTargetpests>(DeviceInformationTargetpests.class);
        util.exportExcel(response, list, "靶标害虫设备基础信息数据");
    }

    /**
     * 获取靶标害虫设备基础信息详细信息
     */
    @GetMapping(value = "/deviceEncoding")
    @ApiOperation("获取靶标害虫设备基础信息详细信息")
    public AjaxResult getInfo(String deviceEncoding)
    {
        return success(deviceInformationTargetpestsService.selectDeviceInformationTargetpestsById(deviceEncoding));
    }

    /**
     * 新增靶标害虫设备基础信息
     */
    @PreAuthorize("@ss.hasPermi('deviceInfo:targetPests:add')")
    @PostMapping
    @ApiOperation("新增靶标害虫设备基础信息")
    public AjaxResult add(@RequestBody DeviceInformationTargetpests deviceInformationTargetpests)
    {
        return toAjax(deviceInformationTargetpestsService.insertDeviceInformationTargetpests(deviceInformationTargetpests));
    }

    /**
     * 修改靶标害虫设备基础信息
     */
    @PreAuthorize("@ss.hasPermi('deviceInfo:targetPests:edit')")
    @PutMapping
    @ApiOperation("修改靶标害虫设备基础信息")
    public AjaxResult edit(@RequestBody DeviceInformationTargetpests deviceInformationTargetpests)
    {
        return toAjax(deviceInformationTargetpestsService.updateDeviceInformationTargetpests(deviceInformationTargetpests));
    }

    /**
     * 删除靶标害虫设备基础信息
     */
    @PreAuthorize("@ss.hasPermi('deviceInfo:targetPests:remove')")
    @DeleteMapping("/{ids}")
    @ApiOperation("删除靶标害虫设备基础信息")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(deviceInformationTargetpestsService.deleteDeviceInformationTargetpestsByIds(ids));
    }
}
