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

/**
 * 气象设备基础信息Controller
 *
 * @author kerwincui
 * @date 2024-11-27
 */
@RestController
@RequestMapping("/deviceInfo/meteorology")
@Api(tags = "气象设备基础信息")
public class DeviceInformationMeteorologyController extends BaseController
{
    @Autowired
    private IDeviceInformationMeteorologyService deviceInformationMeteorologyService;

/**
 * 查询气象设备基础信息列表
 */
@PreAuthorize("@ss.hasPermi('deviceInfo:meteorology:list')")
@GetMapping("/list")
@ApiOperation("查询气象设备基础信息列表")
    public TableDataInfo list(DeviceInformationMeteorology deviceInformationMeteorology)
    {
        startPage();
        List<DeviceInformationMeteorology> list = deviceInformationMeteorologyService.selectDeviceInformationMeteorologyList(deviceInformationMeteorology);
        return getDataTable(list);
    }

    /**
     * 导出气象设备基础信息列表
     */
    @ApiOperation("导出气象设备基础信息列表")
    @PreAuthorize("@ss.hasPermi('deviceInfo:meteorology:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceInformationMeteorology deviceInformationMeteorology)
    {
        List<DeviceInformationMeteorology> list = deviceInformationMeteorologyService.selectDeviceInformationMeteorologyList(deviceInformationMeteorology);
        ExcelUtil<DeviceInformationMeteorology> util = new ExcelUtil<DeviceInformationMeteorology>(DeviceInformationMeteorology.class);
        util.exportExcel(response, list, "气象设备基础信息数据");
    }

    /**
     * 获取气象设备基础信息详细信息
     */
    @GetMapping(value = "deviceEncoding")
    @ApiOperation("获取气象设备基础信息详细信息")
    public AjaxResult getInfo(String deviceEncoding)
    {
        return success(deviceInformationMeteorologyService.selectDeviceInformationMeteorologyById(deviceEncoding));
    }

    /**
     * 新增气象设备基础信息
     */
    @PreAuthorize("@ss.hasPermi('deviceInfo:meteorology:add')")
    @PostMapping
    @ApiOperation("新增气象设备基础信息")
    public AjaxResult add(@RequestBody DeviceInformationMeteorology deviceInformationMeteorology)
    {
        return toAjax(deviceInformationMeteorologyService.insertDeviceInformationMeteorology(deviceInformationMeteorology));
    }

    /**
     * 修改气象设备基础信息
     */
    @PreAuthorize("@ss.hasPermi('deviceInfo:meteorology:edit')")
    @PutMapping
    @ApiOperation("修改气象设备基础信息")
    public AjaxResult edit(@RequestBody DeviceInformationMeteorology deviceInformationMeteorology)
    {
        return toAjax(deviceInformationMeteorologyService.updateDeviceInformationMeteorology(deviceInformationMeteorology));
    }

    /**
     * 删除气象设备基础信息
     */
    @PreAuthorize("@ss.hasPermi('deviceInfo:meteorology:remove')")
    @DeleteMapping("/{ids}")
    @ApiOperation("删除气象设备基础信息")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(deviceInformationMeteorologyService.deleteDeviceInformationMeteorologyByIds(ids));
    }
}
