package com.ruoyi.web.controller.manage;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.manage.domain.EquipmentManage;
import com.ruoyi.manage.service.IEquipmentManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 设备管理Controller
 *
 * @author boman
 * @date 2025-05-07
 */
@RestController
@RequestMapping("/manage/equipmentManage")
public class EquipmentManageController extends BaseController
{
    @Autowired
    private IEquipmentManageService equipmentManageService;

/**
 * 查询设备管理列表
 */
@PreAuthorize("@ss.hasPermi('manage:equipmentManage:list')")
@GetMapping("/list")
    public TableDataInfo list(EquipmentManage equipmentManage)
    {
        startPage();
        List<EquipmentManage> list = equipmentManageService.selectEquipmentManageList(equipmentManage);
        return getDataTable(list);
    }

    /**
     * 导出设备管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:equipmentManage:export')")
    @Log(title = "设备管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EquipmentManage equipmentManage)
    {
        List<EquipmentManage> list = equipmentManageService.selectEquipmentManageList(equipmentManage);
        ExcelUtil<EquipmentManage> util = new ExcelUtil<EquipmentManage>(EquipmentManage.class);
        util.exportExcel(response, list, "设备管理数据");
    }

    /**
     * 获取设备管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:equipmentManage:query')")
    @GetMapping(value = "/{equipmentId}")
    public AjaxResult getInfo(@PathVariable("equipmentId") Long equipmentId)
    {
        return success(equipmentManageService.selectEquipmentManageByEquipmentId(equipmentId));
    }

    /**
     * 新增设备管理
     */
    @PreAuthorize("@ss.hasPermi('manage:equipmentManage:add')")
    @Log(title = "设备管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EquipmentManage equipmentManage)
    {
        return toAjax(equipmentManageService.insertEquipmentManage(equipmentManage));
    }

    /**
     * 修改设备管理
     */
    @PreAuthorize("@ss.hasPermi('manage:equipmentManage:edit')")
    @Log(title = "设备管理", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody EquipmentManage equipmentManage)
    {
        return toAjax(equipmentManageService.updateEquipmentManage(equipmentManage));
    }

    /**
     * 删除设备管理
     */
    @PreAuthorize("@ss.hasPermi('manage:equipmentManage:remove')")
    @Log(title = "设备管理", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{equipmentIds}")
    public AjaxResult remove(@PathVariable Long[] equipmentIds)
    {
        return toAjax(equipmentManageService.deleteEquipmentManageByEquipmentIds(equipmentIds));
    }
}
