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.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.annotation.Log;
import com.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.common.enums.BusinessType;
import com.fastbee.rechargecard.domain.NgIrrigationControllers;
import com.fastbee.rechargecard.service.INgIrrigationControllersService;
import com.fastbee.common.utils.poi.ExcelUtil;
import com.fastbee.common.core.page.TableDataInfo;

/**
 * 灌溉控制器信息Controller
 *
 * @author kerwincui
 * @date 2024-12-19
 */
@RestController
@RequestMapping("/rechargecard/controllers")
@Api(tags = "灌溉控制器信息")
public class NgIrrigationControllersController extends BaseController
{
    @Autowired
    private INgIrrigationControllersService ngIrrigationControllersService;

    /**
     * 查询灌溉控制器信息列表
     */
//    @PreAuthorize("@ss.hasPermi('rechargecard:controllers:list')")
    @GetMapping("/list")
    @ApiOperation("查询灌溉控制器信息列表")
    public TableDataInfo list(NgIrrigationControllers ngIrrigationControllers)
    {
        startPage();
        List<NgIrrigationControllers> list = ngIrrigationControllersService.selectNgIrrigationControllersList(ngIrrigationControllers);
        return getDataTable(list);
    }

    /**
     * 导出灌溉控制器信息列表
     */
    @ApiOperation("导出灌溉控制器信息列表")
//    @PreAuthorize("@ss.hasPermi('rechargecard:controllers:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, NgIrrigationControllers ngIrrigationControllers)
    {
        List<NgIrrigationControllers> list = ngIrrigationControllersService.selectNgIrrigationControllersList(ngIrrigationControllers);
        ExcelUtil<NgIrrigationControllers> util = new ExcelUtil<NgIrrigationControllers>(NgIrrigationControllers.class);
        util.exportExcel(response, list, "灌溉控制器信息数据");
    }

    /**
     * 获取灌溉控制器信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('rechargecard:controllers:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取灌溉控制器信息详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ngIrrigationControllersService.selectNgIrrigationControllersById(id));
    }

    /**
     * 新增灌溉控制器信息
     */
//    @PreAuthorize("@ss.hasPermi('rechargecard:controllers:add')")
    @PostMapping
    @ApiOperation("新增灌溉控制器信息")
    public AjaxResult add(@RequestBody NgIrrigationControllers ngIrrigationControllers)
    {
        return toAjax(ngIrrigationControllersService.insertNgIrrigationControllers(ngIrrigationControllers));
    }

    /**
     * 修改灌溉控制器信息
     */
//    @PreAuthorize("@ss.hasPermi('rechargecard:controllers:edit')")
    @PutMapping
    @ApiOperation("修改灌溉控制器信息")
    public AjaxResult edit(@RequestBody NgIrrigationControllers ngIrrigationControllers)
    {
        return toAjax(ngIrrigationControllersService.updateNgIrrigationControllers(ngIrrigationControllers));
    }

    /**
     * 删除灌溉控制器信息
     */
//    @PreAuthorize("@ss.hasPermi('rechargecard:controllers:remove')")
    @DeleteMapping("/{ids}")
    @ApiOperation("删除灌溉控制器信息")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ngIrrigationControllersService.deleteNgIrrigationControllersByIds(ids));
    }
}
