package com.fastbee.data.controller.userRecharge;

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.iot.domain.NgFlowDeviceData;
import com.fastbee.iot.service.INgFlowDeviceDataService;
import com.fastbee.common.utils.poi.ExcelUtil;
import com.fastbee.common.core.page.TableDataInfo;

/**
 * 流量计设备数据Controller
 *
 * @author kerwincui
 * @date 2024-12-30
 */
@RestController
@RequestMapping("/rechargecard/flow/data")
@Api(tags = "流量计设备数据")
public class NgFlowDeviceDataController extends BaseController
{
    @Autowired
    private INgFlowDeviceDataService ngFlowDeviceDataService;

/**
 * 查询流量计设备数据列表
 */
// @PreAuthorize("@ss.hasPermi('rechargecard:data:list')")
@GetMapping("/list")
@ApiOperation("查询流量计设备数据列表")
    public TableDataInfo list(NgFlowDeviceData ngFlowDeviceData)
    {
        startPage();
        List<NgFlowDeviceData> list = ngFlowDeviceDataService.selectNgFlowDeviceDataList(ngFlowDeviceData);
        return getDataTable(list);
    }

    /**
     * 导出流量计设备数据列表
     */
    @ApiOperation("导出流量计设备数据列表")
    // @PreAuthorize("@ss.hasPermi('rechargecard:data:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, NgFlowDeviceData ngFlowDeviceData)
    {
        List<NgFlowDeviceData> list = ngFlowDeviceDataService.selectNgFlowDeviceDataList(ngFlowDeviceData);
        ExcelUtil<NgFlowDeviceData> util = new ExcelUtil<NgFlowDeviceData>(NgFlowDeviceData.class);
        util.exportExcel(response, list, "流量计设备数据数据");
    }

    /**
     * 获取流量计设备数据详细信息
     */
    // @PreAuthorize("@ss.hasPermi('rechargecard:data:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取流量计设备数据详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ngFlowDeviceDataService.selectNgFlowDeviceDataById(id));
    }

    /**
     * 新增流量计设备数据
     */
    // @PreAuthorize("@ss.hasPermi('rechargecard:data:add')")
    @PostMapping
    @ApiOperation("新增流量计设备数据")
    public AjaxResult add(@RequestBody NgFlowDeviceData ngFlowDeviceData)
    {
        return toAjax(ngFlowDeviceDataService.insertNgFlowDeviceData(ngFlowDeviceData));
    }

    /**
     * 修改流量计设备数据
     */
    // @PreAuthorize("@ss.hasPermi('rechargecard:data:edit')")
    @PutMapping
    @ApiOperation("修改流量计设备数据")
    public AjaxResult edit(@RequestBody NgFlowDeviceData ngFlowDeviceData)
    {
        return toAjax(ngFlowDeviceDataService.updateNgFlowDeviceData(ngFlowDeviceData));
    }

    /**
     * 删除流量计设备数据
     */
    // @PreAuthorize("@ss.hasPermi('rechargecard:data:remove')")
    @DeleteMapping("/{ids}")
    @ApiOperation("删除流量计设备数据")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ngFlowDeviceDataService.deleteNgFlowDeviceDataByIds(ids));
    }
}
