package com.ruoyi.powerdistribution.controller;

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

import com.ruoyi.powerdistribution.domain.vo.PdmBranchLineComplete;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.powerdistribution.domain.PdmBranchLine;
import com.ruoyi.powerdistribution.service.IPdmBranchLineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 可靠性分支线Controller
 *
 * @author ruoyi
 * @date 2024-12-24
 */
@Api(value = "PdmBranchLineController", tags = "分支线查询")
@RestController
@RequestMapping("/power/branchLine")
public class PdmBranchLineController extends BaseController
{
    @Autowired
    private IPdmBranchLineService pdmBranchLineService;

    /**
     * 查询可靠性分支线列表
     */
    @PreAuthorize("@ss.hasPermi('system:line:list')")
    @GetMapping("/list")
    public TableDataInfo list(PdmBranchLine pdmBranchLine)
    {
        startPage();
        List<PdmBranchLine> list = pdmBranchLineService.selectPdmBranchLineList(pdmBranchLine);
        return getDataTable(list);
    }

    /**
     * 导出可靠性分支线列表
     */
    @PreAuthorize("@ss.hasPermi('system:line:export')")
    @Log(title = "可靠性分支线", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PdmBranchLine pdmBranchLine)
    {
        List<PdmBranchLine> list = pdmBranchLineService.selectPdmBranchLineList(pdmBranchLine);
        ExcelUtil<PdmBranchLine> util = new ExcelUtil<PdmBranchLine>(PdmBranchLine.class);
        util.exportExcel(response, list, "可靠性分支线数据");
    }

    /**
     * 获取可靠性分支线详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:line:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pdmBranchLineService.selectPdmBranchLineById(id));
    }

    /**
     * 新增可靠性分支线
     */
    @PreAuthorize("@ss.hasPermi('system:line:add')")
    @Log(title = "可靠性分支线", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PdmBranchLine pdmBranchLine)
    {
        return toAjax(pdmBranchLineService.insertPdmBranchLine(pdmBranchLine));
    }

    /**
     * 修改可靠性分支线
     */
    @PreAuthorize("@ss.hasPermi('system:line:edit')")
    @Log(title = "可靠性分支线", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PdmBranchLine pdmBranchLine)
    {
        return toAjax(pdmBranchLineService.updatePdmBranchLine(pdmBranchLine));
    }

    /**
     * 删除可靠性分支线
     */
    @PreAuthorize("@ss.hasPermi('system:line:remove')")
    @Log(title = "可靠性分支线", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pdmBranchLineService.deletePdmBranchLineByIds(ids));
    }

    /**
     * 查询可靠性分支线完成情况
     */
    @ApiOperation(value = "查询可靠性分支线完成情况")
    @GetMapping("/selectBranchLineCompleteList")
    public TableDataInfo selectBranchLineCompleteList(PdmBranchLineComplete pdmBranchLine)
    {
        startPage();
        List<PdmBranchLineComplete> list = pdmBranchLineService.selectBranchLineCompleteList(pdmBranchLine);
        return getDataTable(list);
    }

}
