package com.evobms.project.system.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.evobms.framework.aspectj.lang.annotation.Log;
import com.evobms.framework.aspectj.lang.enums.BusinessType;
import com.evobms.project.system.domain.BmsDevices;
import com.evobms.project.system.service.IBmsDevicesService;
import com.evobms.framework.web.controller.BaseController;
import com.evobms.framework.web.domain.AjaxResult;
import com.evobms.common.utils.poi.ExcelUtil;
import com.evobms.framework.web.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * BBOX管理Controller
 *
 * @author 田志阳
 * @date 2025-11-15
 */
@RestController
@RequestMapping("/devices/devices")
@Api(tags = "BBOX设备管理")
public class BmsDevicesController extends BaseController
{
    @Autowired
    private IBmsDevicesService bmsDevicesService;

    /**
     * 查询BBOX管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:devices:list')")
    @GetMapping("/list")
    @ApiOperation("查询BBOX设备列表")
    public TableDataInfo list(BmsDevices bmsDevices)
    {
        startPage();
        List<BmsDevices> list = bmsDevicesService.selectBmsDevicesList(bmsDevices);
        return getDataTable(list);
    }

    /**
     * 导出BBOX管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:devices:export')")
    @Log(title = "BBOX管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出BBOX设备列表")
    public void export(HttpServletResponse response, BmsDevices bmsDevices)
    {
        List<BmsDevices> list = bmsDevicesService.selectBmsDevicesList(bmsDevices);
        ExcelUtil<BmsDevices> util = new ExcelUtil<BmsDevices>(BmsDevices.class);
        util.exportExcel(response, list, "BBOX管理数据");
    }

    /**
     * 获取BBOX管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:devices:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取BBOX设备详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(bmsDevicesService.selectBmsDevicesById(id));
    }

    /**
     * 新增BBOX管理
     */
    @PreAuthorize("@ss.hasPermi('system:devices:add')")
    @Log(title = "BBOX管理", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增BBOX设备")
    public AjaxResult add(@RequestBody BmsDevices bmsDevices)
    {
        return toAjax(bmsDevicesService.insertBmsDevices(bmsDevices));
    }

    /**
     * 修改BBOX管理
     */
    @PreAuthorize("@ss.hasPermi('system:devices:edit')")
    @Log(title = "BBOX管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改BBOX设备")
    public AjaxResult edit(@RequestBody BmsDevices bmsDevices)
    {
        return toAjax(bmsDevicesService.updateBmsDevices(bmsDevices));
    }

    /**
     * 删除BBOX管理
     */
    @PreAuthorize("@ss.hasPermi('system:devices:remove')")
    @Log(title = "BBOX管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除BBOX设备")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(bmsDevicesService.deleteBmsDevicesByIds(ids));
    }
}
