package com.agri.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.agri.system.domain.SysAgriLimit;
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.agri.common.annotation.Log;
import com.agri.common.core.controller.BaseController;
import com.agri.common.core.domain.AjaxResult;
import com.agri.common.enums.BusinessType;
import com.agri.system.domain.SysAgriLimitBak;
import com.agri.system.service.ISysAgriLimitBakService;
import com.agri.common.utils.poi.ExcelUtil;
import com.agri.common.core.page.TableDataInfo;

/**
 * 大棚功能执行时间限位Controller
 * 
 * @author lld
 * @date 2026-03-17
 */
@RestController
@RequestMapping("/assets/limit_bak")
public class SysAgriLimitBakController extends BaseController
{
    @Autowired
    private ISysAgriLimitBakService sysAgriLimitBakService;

    /**
     * 查询大棚功能执行时间限位列表
     */
    @PreAuthorize("@ss.hasPermi('assets:limit_bak:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysAgriLimitBak sysAgriLimitBak)
    {
        startPage();
        List<SysAgriLimitBak> list = sysAgriLimitBakService.selectSysAgriLimitBakList(sysAgriLimitBak);
        return getDataTable(list);
    }

    /**
     * 导出大棚功能执行时间限位列表
     */
    @PreAuthorize("@ss.hasPermi('assets:limit_bak:export')")
    @Log(title = "大棚功能执行时间限位", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysAgriLimitBak sysAgriLimitBak)
    {
        List<SysAgriLimitBak> list = sysAgriLimitBakService.selectSysAgriLimitBakList(sysAgriLimitBak);
        ExcelUtil<SysAgriLimitBak> util = new ExcelUtil<SysAgriLimitBak>(SysAgriLimitBak.class);
        util.exportExcel(response, list, "大棚功能执行时间限位数据");
    }

    /**
     * 获取大棚功能执行时间限位详细信息
     */
    @PreAuthorize("@ss.hasPermi('assets:limit_bak:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(sysAgriLimitBakService.selectSysAgriLimitBakById(id));
    }

    /**
     * 新增大棚功能执行时间限位
     */
    @PreAuthorize("@ss.hasPermi('assets:limit_bak:add')")
    @Log(title = "大棚功能执行时间限位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysAgriLimitBak sysAgriLimitBak)
    {
        return toAjax(sysAgriLimitBakService.insertSysAgriLimitBak(sysAgriLimitBak));
    }

    /**
     * 修改大棚功能执行时间限位
     */
    @PreAuthorize("@ss.hasPermi('assets:limit_bak:edit')")
    @Log(title = "大棚功能执行时间限位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysAgriLimitBak sysAgriLimitBak)
    {
        return toAjax(sysAgriLimitBakService.updateSysAgriLimitBak(sysAgriLimitBak));
    }

    /**
     * 删除大棚功能执行时间限位
     */
    @PreAuthorize("@ss.hasPermi('assets:limit_bak:remove')")
    @Log(title = "大棚功能执行时间限位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(sysAgriLimitBakService.deleteSysAgriLimitBakByIds(ids));
    }


    @Log(title = "大棚运行时间限位查询", businessType = BusinessType.SELECT)
    @GetMapping("/getAgriLimitByImei/{imei}")
    public AjaxResult getAgriLimitByImei(@PathVariable String imei)
    {
        SysAgriLimitBak agriLimit = sysAgriLimitBakService.getAgriLimitByImei(imei);
        return success(agriLimit);
    }


    @PreAuthorize("@ss.hasPermi('assets:limit_bak:add')")
    @Log(title = "大棚功能执行时间限位", businessType = BusinessType.INSERT)
    @PostMapping("/saveAgriLimit")
    public AjaxResult saveAgriLimit(@RequestBody SysAgriLimitBak sysAgriLimitBak)
    {
        return toAjax(sysAgriLimitBakService.saveAgriLimit(sysAgriLimitBak));
    }
}
