package com.agri.system.controller;

import com.agri.common.annotation.Log;
import com.agri.common.core.controller.BaseController;
import com.agri.common.core.domain.AjaxResult;
import com.agri.common.core.page.TableDataInfo;
import com.agri.common.enums.BusinessType;
import com.agri.common.utils.poi.ExcelUtil;
import com.agri.system.domain.SysSpecialDtuData;
import com.agri.system.service.ISysSpecialDtuDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * 无线传输线管数据Controller
 * 
 * @author lld
 * @date 2026-01-11
 */
@RestController
@RequestMapping("/data/specialData")
public class SysSpecialDtuDataController extends BaseController
{
    @Autowired
    private ISysSpecialDtuDataService sysSpecialDtuDataService;

    /**
     * 查询无线传输线管数据列表
     */
    @PreAuthorize("@ss.hasPermi('data:specialData:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysSpecialDtuData sysSpecialDtuData)
    {
        startPage();
        List<SysSpecialDtuData> list = sysSpecialDtuDataService.selectSysSpecialDtuDataList(sysSpecialDtuData);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('data:specialData:list')")
    @GetMapping("/getNewSpecialData")
    public AjaxResult getNewSpecialData()
    {
        SysSpecialDtuData specialDtuData = sysSpecialDtuDataService
                .lambdaQuery().orderByDesc(SysSpecialDtuData::getTs).last("limit 1").one();
        return AjaxResult.success(specialDtuData);
    }
    /**
     * 导出无线传输线管数据列表
     */
    @PreAuthorize("@ss.hasPermi('data:specialData:export')")
    @Log(title = "无线传输线管数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysSpecialDtuData sysSpecialDtuData)
    {
        List<SysSpecialDtuData> list = sysSpecialDtuDataService.selectSysSpecialDtuDataList(sysSpecialDtuData);
        ExcelUtil<SysSpecialDtuData> util = new ExcelUtil<SysSpecialDtuData>(SysSpecialDtuData.class);
        util.exportExcel(response, list, "无线传输线管数据数据");
    }

    /**
     * 获取无线传输线管数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('data:specialData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysSpecialDtuDataService.selectSysSpecialDtuDataById(id));
    }

    /**
     * 新增无线传输线管数据
     */
    @PreAuthorize("@ss.hasPermi('data:specialData:add')")
    @Log(title = "无线传输线管数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysSpecialDtuData sysSpecialDtuData)
    {
        return toAjax(sysSpecialDtuDataService.insertSysSpecialDtuData(sysSpecialDtuData));
    }

    /**
     * 修改无线传输线管数据
     */
    @PreAuthorize("@ss.hasPermi('data:specialData:edit')")
    @Log(title = "无线传输线管数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSpecialDtuData sysSpecialDtuData)
    {
        return toAjax(sysSpecialDtuDataService.updateSysSpecialDtuData(sysSpecialDtuData));
    }

    /**
     * 删除无线传输线管数据
     */
    @PreAuthorize("@ss.hasPermi('data:specialData:remove')")
    @Log(title = "无线传输线管数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysSpecialDtuDataService.deleteSysSpecialDtuDataByIds(ids));
    }
}
