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.BaseCabinetInfo;
import com.ruoyi.base.service.IBaseCabinetInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 电柜信息Controller
 * 
 * @author ruoyi
 * @date 2024-10-31
 */
@RestController
@RequestMapping("/base/baseCabinetInfo")
public class BaseCabinetInfoController extends BaseController
{
    @Autowired
    private IBaseCabinetInfoService baseCabinetInfoService;

    /**
     * 查询电柜信息列表
     */
    @PreAuthorize("@ss.hasPermi('base:baseCabinetInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseCabinetInfo baseCabinetInfo)
    {
        startPage();
        List<BaseCabinetInfo> list = baseCabinetInfoService.selectBaseCabinetInfoList(baseCabinetInfo);
        return getDataTable(list);
    }

    /**
     * 导出电柜信息列表
     */
    @PreAuthorize("@ss.hasPermi('base:baseCabinetInfo:export')")
    @Log(title = "电柜信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseCabinetInfo baseCabinetInfo)
    {
        List<BaseCabinetInfo> list = baseCabinetInfoService.selectBaseCabinetInfoList(baseCabinetInfo);
        ExcelUtil<BaseCabinetInfo> util = new ExcelUtil<BaseCabinetInfo>(BaseCabinetInfo.class);
        util.exportExcel(response, list, "电柜信息数据");
    }

    /**
     * 获取电柜信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:baseCabinetInfo:query')")
    @GetMapping(value = "/{objId}")
    public AjaxResult getInfo(@PathVariable("objId") Long objId)
    {
        return success(baseCabinetInfoService.selectBaseCabinetInfoByObjId(objId));
    }

    /**
     * 新增电柜信息
     */
    @PreAuthorize("@ss.hasPermi('base:baseCabinetInfo:add')")
    @Log(title = "电柜信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseCabinetInfo baseCabinetInfo)
    {
        return toAjax(baseCabinetInfoService.insertBaseCabinetInfo(baseCabinetInfo));
    }

    /**
     * 修改电柜信息
     */
    @PreAuthorize("@ss.hasPermi('base:baseCabinetInfo:edit')")
    @Log(title = "电柜信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseCabinetInfo baseCabinetInfo)
    {
        return toAjax(baseCabinetInfoService.updateBaseCabinetInfo(baseCabinetInfo));
    }

    /**
     * 删除电柜信息
     */
    @PreAuthorize("@ss.hasPermi('base:baseCabinetInfo:remove')")
    @Log(title = "电柜信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{objIds}")
    public AjaxResult remove(@PathVariable Long[] objIds)
    {
        return toAjax(baseCabinetInfoService.deleteBaseCabinetInfoByObjIds(objIds));
    }
}
