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

/**
 * 苗情设备基础信息Controller
 *
 * @author kerwincui
 * @date 2024-11-27
 */
@RestController
@RequestMapping("/deviceInfo/miaoQing1")
@Api(tags = "苗情设备基础信息")
public class DeviceInformationMiaoqing1Controller extends BaseController
{
    @Autowired
    private IDeviceInformationMiaoqingService deviceInformationMiaoqingService;

/**
 * 查询苗情设备基础信息列表
 */
@GetMapping("/list")
@ApiOperation("查询苗情设备基础信息列表")
    public TableDataInfo list(DeviceInformationMiaoqing deviceInformationMiaoqing)
    {
        startPage();
        List<DeviceInformationMiaoqing> list = deviceInformationMiaoqingService.selectDeviceInformationMiaoqingList(deviceInformationMiaoqing);
        return getDataTable(list);
    }

    /**
     * 导出苗情设备基础信息列表
     */
    @ApiOperation("导出苗情设备基础信息列表")
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceInformationMiaoqing deviceInformationMiaoqing)
    {
        List<DeviceInformationMiaoqing> list = deviceInformationMiaoqingService.selectDeviceInformationMiaoqingList(deviceInformationMiaoqing);
        ExcelUtil<DeviceInformationMiaoqing> util = new ExcelUtil<DeviceInformationMiaoqing>(DeviceInformationMiaoqing.class);
        util.exportExcel(response, list, "苗情设备基础信息数据");
    }

    /**
     * 获取苗情设备基础信息详细信息
     */
    @GetMapping(value = "/deviceEncoding")
    @ApiOperation("根据device_encoding获取苗情设备基础信息详细信息")
    public AjaxResult getInfo(String deviceEncoding)
    {
        return success(deviceInformationMiaoqingService.selectDeviceInformationMiaoqingById(deviceEncoding));
    }

    /**
     * 新增苗情设备基础信息
     */
    @PostMapping
    @ApiOperation("新增苗情设备基础信息")
    public AjaxResult add(@RequestBody DeviceInformationMiaoqing deviceInformationMiaoqing)
    {
        return toAjax(deviceInformationMiaoqingService.insertDeviceInformationMiaoqing(deviceInformationMiaoqing));
    }

    /**
     * 修改苗情设备基础信息
     */
    @PutMapping
    @ApiOperation("修改苗情设备基础信息")
    public AjaxResult edit(@RequestBody DeviceInformationMiaoqing deviceInformationMiaoqing)
    {
        return toAjax(deviceInformationMiaoqingService.updateDeviceInformationMiaoqing(deviceInformationMiaoqing));
    }

    /**
     * 删除苗情设备基础信息
     */
    @DeleteMapping("/{ids}")
    @ApiOperation("删除苗情设备基础信息")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(deviceInformationMiaoqingService.deleteDeviceInformationMiaoqingByIds(ids));
    }
}
