package com.ruoyi.ems.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
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.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.ems.domain.AdmBoxElecEqpt;
import com.ruoyi.ems.service.IAdmBoxElecEqptService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 动力箱柜电气设备Controller
 *
 * @author ruoyi
 * @date 2024-09-03
 */
@RestController
@RequestMapping("/eqpt")
public class AdmBoxElecEqptController extends BaseController
{
    @Autowired
    private IAdmBoxElecEqptService admBoxElecEqptService;

    /**
     * 查询动力箱柜电气设备列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AdmBoxElecEqpt admBoxElecEqpt)
    {
        startPage();
        List<AdmBoxElecEqpt> list = admBoxElecEqptService.selectAdmBoxElecEqptList(admBoxElecEqpt);
        return getDataTable(list);
    }

    /**
     * 导出动力箱柜电气设备列表
     */
    @Log(title = "动力箱柜电气设备", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AdmBoxElecEqpt admBoxElecEqpt)
    {
        List<AdmBoxElecEqpt> list = admBoxElecEqptService.selectAdmBoxElecEqptList(admBoxElecEqpt);
        ExcelUtil<AdmBoxElecEqpt> util = new ExcelUtil<AdmBoxElecEqpt>(AdmBoxElecEqpt.class);
        util.exportExcel(response, list, "动力箱柜电气设备数据");
    }

    /**
     * 获取动力箱柜电气设备详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(admBoxElecEqptService.selectAdmBoxElecEqptById(id));
    }

    /**
     * 新增动力箱柜电气设备
     */
    @Log(title = "动力箱柜电气设备", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdmBoxElecEqpt admBoxElecEqpt)
    {
        return toAjax(admBoxElecEqptService.insertAdmBoxElecEqpt(admBoxElecEqpt));
    }

    /**
     * 修改动力箱柜电气设备
     */
    @Log(title = "动力箱柜电气设备", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdmBoxElecEqpt admBoxElecEqpt)
    {
        return toAjax(admBoxElecEqptService.updateAdmBoxElecEqpt(admBoxElecEqpt));
    }

    /**
     * 删除动力箱柜电气设备
     */
    @Log(title = "动力箱柜电气设备", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(admBoxElecEqptService.deleteAdmBoxElecEqptByIds(ids));
    }
}
