package com.dcs.hnyz.controller;

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

import com.dcs.hnyz.domain.vo.PipeLineInstanceFormVO;
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.dcs.common.annotation.Log;
import com.dcs.common.core.controller.BaseController;
import com.dcs.common.core.domain.AjaxResult;
import com.dcs.common.enums.BusinessType;
import com.dcs.hnyz.domain.PipelineInstance;
import com.dcs.hnyz.service.IPipelineInstanceService;
import com.dcs.common.utils.poi.ExcelUtil;
import com.dcs.common.core.page.TableDataInfo;

/**
 * 管道实例管理Controller
 * 
 * @author hmy
 * @date 2025-07-04
 */
@RestController
@RequestMapping("/hnyz/pipelineInstance")
public class PipelineInstanceController extends BaseController
{
    @Autowired
    private IPipelineInstanceService pipelineInstanceService;

    /**
     * 查询管道实例管理列表
     */
    @PreAuthorize("@ss.hasPermi('hnyz:pipelineInstance:list')")
    @GetMapping("/list")
    public TableDataInfo list(PipelineInstance pipelineInstance)
    {
        startPage();
        List<PipeLineInstanceFormVO> list = pipelineInstanceService.selectPipelineInstanceList(pipelineInstance);
        return getDataTable(list);
    }

    /**
     * 导出管道实例管理列表
     */
    @PreAuthorize("@ss.hasPermi('hnyz:pipelineInstance:export')")
    @Log(title = "管道实例管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PipelineInstance pipelineInstance)
    {
        List<PipeLineInstanceFormVO> list = pipelineInstanceService.selectPipelineInstanceList(pipelineInstance);
        ExcelUtil<PipeLineInstanceFormVO> util = new ExcelUtil<PipeLineInstanceFormVO>(PipeLineInstanceFormVO.class);
        util.exportExcel(response, list, "管道实例管理数据");
    }

    /**
     * 获取管道实例管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('hnyz:pipelineInstance:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pipelineInstanceService.selectPipelineInstanceById(id));
    }

    /**
     * 新增管道实例管理
     */
    @PreAuthorize("@ss.hasPermi('hnyz:pipelineInstance:add')")
    @Log(title = "管道实例管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PipelineInstance pipelineInstance)
    {
        return toAjax(pipelineInstanceService.insertPipelineInstance(pipelineInstance));
    }

    /**
     * 修改管道实例管理
     */
    @PreAuthorize("@ss.hasPermi('hnyz:pipelineInstance:edit')")
    @Log(title = "管道实例管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PipelineInstance pipelineInstance)
    {
        return toAjax(pipelineInstanceService.updatePipelineInstance(pipelineInstance));
    }

    /**
     * 删除管道实例管理
     */
    @PreAuthorize("@ss.hasPermi('hnyz:pipelineInstance:remove')")
    @Log(title = "管道实例管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pipelineInstanceService.deletePipelineInstanceByIds(ids));
    }
}
