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.DeviceInformationWorms;
import com.fastbee.deviceInfo.service.IDeviceInformationWormsService;
import com.fastbee.common.utils.poi.ExcelUtil;
import com.fastbee.common.core.page.TableDataInfo;

/**
 * 虫情设备基础信息Controller
 *
 * @author kerwincui
 * @date 2024-11-27
 */
@RestController
@RequestMapping("/deviceInfo/worms")
@Api(tags = "虫情设备基础信息")
public class DeviceInformationWormsController extends BaseController
{
    @Autowired
    private IDeviceInformationWormsService deviceInformationWormsService;

/**
 * 查询虫情设备基础信息列表
 */
@PreAuthorize("@ss.hasPermi('deviceInfo:worms:list')")
@GetMapping("/list")
@ApiOperation("查询虫情设备基础信息列表")
    public TableDataInfo list(DeviceInformationWorms deviceInformationWorms)
    {
        startPage();
        List<DeviceInformationWorms> list = deviceInformationWormsService.selectDeviceInformationWormsList(deviceInformationWorms);
        return getDataTable(list);
    }

    /**
     * 导出虫情设备基础信息列表
     */
    @ApiOperation("导出虫情设备基础信息列表")
    @PreAuthorize("@ss.hasPermi('deviceInfo:worms:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceInformationWorms deviceInformationWorms)
    {
        List<DeviceInformationWorms> list = deviceInformationWormsService.selectDeviceInformationWormsList(deviceInformationWorms);
        ExcelUtil<DeviceInformationWorms> util = new ExcelUtil<DeviceInformationWorms>(DeviceInformationWorms.class);
        util.exportExcel(response, list, "虫情设备基础信息数据");
    }

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

    /**
     * 新增虫情设备基础信息
     */
    @PreAuthorize("@ss.hasPermi('deviceInfo:worms:add')")
    @PostMapping
    @ApiOperation("新增虫情设备基础信息")
    public AjaxResult add(@RequestBody DeviceInformationWorms deviceInformationWorms)
    {
        return toAjax(deviceInformationWormsService.insertDeviceInformationWorms(deviceInformationWorms));
    }

    /**
     * 修改虫情设备基础信息
     */
    @PreAuthorize("@ss.hasPermi('deviceInfo:worms:edit')")
    @PutMapping
    @ApiOperation("修改虫情设备基础信息")
    public AjaxResult edit(@RequestBody DeviceInformationWorms deviceInformationWorms)
    {
        return toAjax(deviceInformationWormsService.updateDeviceInformationWorms(deviceInformationWorms));
    }

    /**
     * 删除虫情设备基础信息
     */
    @PreAuthorize("@ss.hasPermi('deviceInfo:worms:remove')")
    @DeleteMapping("/{ids}")
    @ApiOperation("删除虫情设备基础信息")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(deviceInformationWormsService.deleteDeviceInformationWormsByIds(ids));
    }
}
