package com.ruoyi.base.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.base.domain.BaseBusbarInfo;
import com.ruoyi.base.service.IBaseBusbarInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 母排信息Controller
 * 
 * @author zangch
 * @date 2024-10-31
 */
@RestController
@RequestMapping("/base/baseBusbarInfo")
public class BaseBusbarInfoController extends BaseController
{
    @Autowired
    private IBaseBusbarInfoService baseBusbarInfoService;

    /**
     * 查询母排信息列表
     */
    @PreAuthorize("@ss.hasPermi('base:baseBusbarInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseBusbarInfo baseBusbarInfo)
    {
        startPage();
        List<BaseBusbarInfo> list = baseBusbarInfoService.selectBaseBusbarInfoList(baseBusbarInfo);
        return getDataTable(list);
    }

    /**
     * 导出母排信息列表
     */
    @PreAuthorize("@ss.hasPermi('base:baseBusbarInfo:export')")
    @Log(title = "母排信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseBusbarInfo baseBusbarInfo)
    {
        List<BaseBusbarInfo> list = baseBusbarInfoService.selectBaseBusbarInfoList(baseBusbarInfo);
        ExcelUtil<BaseBusbarInfo> util = new ExcelUtil<BaseBusbarInfo>(BaseBusbarInfo.class);
        util.exportExcel(response, list, "母排信息数据");
    }

    /**
     * 获取母排信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:baseBusbarInfo:query')")
    @GetMapping(value = "/{objId}")
    public AjaxResult getInfo(@PathVariable("objId") Long objId)
    {
        return success(baseBusbarInfoService.selectBaseBusbarInfoByObjId(objId));
    }

    /**
     * 新增母排信息
     */
    @PreAuthorize("@ss.hasPermi('base:baseBusbarInfo:add')")
    @Log(title = "母排信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseBusbarInfo baseBusbarInfo)
    {
        return toAjax(baseBusbarInfoService.insertBaseBusbarInfo(baseBusbarInfo));
    }

    /**
     * 修改母排信息
     */
    @PreAuthorize("@ss.hasPermi('base:baseBusbarInfo:edit')")
    @Log(title = "母排信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseBusbarInfo baseBusbarInfo)
    {
        return toAjax(baseBusbarInfoService.updateBaseBusbarInfo(baseBusbarInfo));
    }

    /**
     * 删除母排信息
     */
    @PreAuthorize("@ss.hasPermi('base:baseBusbarInfo:remove')")
    @Log(title = "母排信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{objIds}")
    public AjaxResult remove(@PathVariable Long[] objIds)
    {
        return toAjax(baseBusbarInfoService.deleteBaseBusbarInfoByObjIds(objIds));
    }
}
