package com.ruoyi.web.controller.camera;

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.system.domain.EquipmentConfiguration;
import com.ruoyi.system.service.IEquipmentConfigurationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备配置（控制抓拍一体机）Controller
 *
 * @author ruoyi
 * @date 2024-08-13
 */
@RestController
@RequestMapping("/system/configuration")
public class EquipmentConfigurationController extends BaseController {
    @Autowired
    private IEquipmentConfigurationService equipmentConfigurationService;

    /**
     * 查询设备配置（控制抓拍一体机）列表
     */
    @PreAuthorize("@ss.hasPermi('system:configuration:list')")
    @GetMapping("/list")
    public TableDataInfo list(EquipmentConfiguration equipmentConfiguration) {
        startPage();
        List<EquipmentConfiguration> list = equipmentConfigurationService.selectEquipmentConfigurationList(equipmentConfiguration);
        return getDataTable(list);
    }

    /**
     * 导出设备配置（控制抓拍一体机）列表
     */
    @PreAuthorize("@ss.hasPermi('system:configuration:export')")
    @Log(title = "设备配置（控制抓拍一体机）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EquipmentConfiguration equipmentConfiguration) {
        List<EquipmentConfiguration> list = equipmentConfigurationService.selectEquipmentConfigurationList(equipmentConfiguration);
        ExcelUtil<EquipmentConfiguration> util = new ExcelUtil<EquipmentConfiguration>(EquipmentConfiguration.class);
        util.exportExcel(response, list, "设备配置（控制抓拍一体机）数据");
    }

    /**
     * 获取设备配置（控制抓拍一体机）详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:configuration:query')")
    @GetMapping(value = "/{equipmentId}")
    public AjaxResult getInfo(@PathVariable("equipmentId") Long equipmentId) {
        return success(equipmentConfigurationService.selectEquipmentConfigurationByEquipmentId(equipmentId));
    }

    /**
     * 新增设备配置（控制抓拍一体机）
     */
    @PreAuthorize("@ss.hasPermi('system:configuration:add')")
    @Log(title = "设备配置（控制抓拍一体机）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EquipmentConfiguration equipmentConfiguration) {
        return toAjax(equipmentConfigurationService.insertEquipmentConfiguration(equipmentConfiguration));
    }

    /**
     * 修改设备配置（控制抓拍一体机）
     */
    @PreAuthorize("@ss.hasPermi('system:configuration:edit')")
    @Log(title = "设备配置（控制抓拍一体机）", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody EquipmentConfiguration equipmentConfiguration) {
        return toAjax(equipmentConfigurationService.updateEquipmentConfiguration(equipmentConfiguration));
    }

    /**
     * 删除设备配置（控制抓拍一体机）
     */
    @PreAuthorize("@ss.hasPermi('system:configuration:remove')")
    @Log(title = "设备配置（控制抓拍一体机）", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{equipmentIds}")
    public AjaxResult remove(@PathVariable Long[] equipmentIds) {
        return toAjax(equipmentConfigurationService.deleteEquipmentConfigurationByEquipmentIds(equipmentIds));
    }
}
