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

/**
 * 墒情设备基础信息Controller
 *
 * @author kerwincui
 * @date 2024-11-27
 */
@RestController
@RequestMapping("/deviceInfo/moisture")
@Api(tags = "墒情设备基础信息")
public class DeviceInformationMoistureController extends BaseController
{
    @Autowired
    private IDeviceInformationMoistureService deviceInformationMoistureService;

/**
 * 查询墒情设备基础信息列表
 */
@PreAuthorize("@ss.hasPermi('deviceInfo:moisture:list')")
@GetMapping("/list")
@ApiOperation("查询墒情设备基础信息列表")
    public TableDataInfo list(DeviceInformationMoisture deviceInformationMoisture)
    {
        startPage();
        List<DeviceInformationMoisture> list = deviceInformationMoistureService.selectDeviceInformationMoistureList(deviceInformationMoisture);
        return getDataTable(list);
    }
    /**
     * 导出墒情设备基础信息列表
     */
    @ApiOperation("导出墒情设备基础信息列表")
    @PreAuthorize("@ss.hasPermi('deviceInfo:moisture:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceInformationMoisture deviceInformationMoisture)
    {
        List<DeviceInformationMoisture> list = deviceInformationMoistureService.selectDeviceInformationMoistureList(deviceInformationMoisture);
        ExcelUtil<DeviceInformationMoisture> util = new ExcelUtil<DeviceInformationMoisture>(DeviceInformationMoisture.class);
        util.exportExcel(response, list, "墒情设备基础信息数据");
    }



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

    /**
     * 新增墒情设备基础信息
     */
    @PreAuthorize("@ss.hasPermi('deviceInfo:moisture:add')")
    @PostMapping
    @ApiOperation("新增墒情设备基础信息")
    public AjaxResult add(@RequestBody DeviceInformationMoisture deviceInformationMoisture)
    {
        return toAjax(deviceInformationMoistureService.insertDeviceInformationMoisture(deviceInformationMoisture));
    }

    /**
     * 修改墒情设备基础信息
     */
    @PreAuthorize("@ss.hasPermi('deviceInfo:moisture:edit')")
    @PutMapping
    @ApiOperation("修改墒情设备基础信息")
    public AjaxResult edit(@RequestBody DeviceInformationMoisture deviceInformationMoisture)
    {
        return toAjax(deviceInformationMoistureService.updateDeviceInformationMoisture(deviceInformationMoisture));
    }

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