package com.xinda.iot.controller;

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.xinda.common.annotation.Log;
import com.xinda.common.core.controller.BaseController;
import com.xinda.common.core.domain.AjaxResult;
import com.xinda.common.enums.BusinessType;
import com.xinda.iot.domain.Pip;
import com.xinda.iot.service.IPipService;
import com.xinda.common.utils.poi.ExcelUtil;
import com.xinda.common.core.page.TableDataInfo;

/**
 * 机构管网Controller
 *
 * @author kerwincui
 * @date 2025-04-18
 */
@RestController
@RequestMapping("/iot/pip")
@Api(tags = "机构管网")
public class PipController extends BaseController
{
    @Autowired
    private IPipService pipService;

/**
 * 查询机构管网列表
 */
@PreAuthorize("@ss.hasPermi('iot:pip:list')")
@GetMapping("/list")
@ApiOperation("查询机构管网列表")
    public TableDataInfo list(Pip pip)
    {
        startPage();
        List<Pip> list = pipService.selectPipList(pip);
        return getDataTable(list);
    }

//    /**
//     * 导出机构管网列表
//     */
//    @ApiOperation("导出机构管网列表")
//    @PreAuthorize("@ss.hasPermi('iot:pip:export')")
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, Pip pip)
//    {
//        List<Pip> list = pipService.selectPipList(pip);
//        ExcelUtil<Pip> util = new ExcelUtil<Pip>(Pip.class);
//        util.exportExcel(response, list, "机构管网数据");
//    }

    /**
     * 获取机构管网详细信息
     */
//    @PreAuthorize("@ss.hasPermi('iot:pip:query')")
    @GetMapping(value = "/{deptId}")
    @ApiOperation("获取机构管网详细信息")
    public AjaxResult getInfo(@PathVariable("deptId") Long deptId)
    {
        return success(pipService.selectPipByDeptId(deptId));
    }

    /**
     * 新增机构管网
     */
//    @PreAuthorize("@ss.hasPermi('iot:pip:add')")
//    @PostMapping
//    @ApiOperation("新增机构管网")
//    public AjaxResult add(@RequestBody Pip pip)
//    {
//        return toAjax(pipService.insertPip(pip));
//    }

    /**
     * 修改机构管网
     */
//    @PreAuthorize("@ss.hasPermi('iot:pip:edit')")
    @PutMapping
    @ApiOperation("修改机构管网")
    public AjaxResult edit(@RequestBody Pip pip)
    {
        return toAjax(pipService.updatePip(pip));
    }

//    /**
//     * 删除机构管网
//     */
//    @PreAuthorize("@ss.hasPermi('iot:pip:remove')")
//    @DeleteMapping("/{deptIds}")
//    @ApiOperation("删除机构管网")
//    public AjaxResult remove(@PathVariable Long[] deptIds)
//    {
//        return toAjax(pipService.deletePipByDeptIds(deptIds));
//    }
}
