package com.inspur.web.controller.work;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.inspur.domain.ElevatorGatewayInfo;
import com.inspur.service.IElevatorGatewayInfoService;
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.inspur.common.annotation.Log;
import com.inspur.common.core.controller.BaseController;
import com.inspur.common.core.domain.AjaxResult;
import com.inspur.common.enums.BusinessType;
import com.inspur.common.utils.poi.ExcelUtil;
import com.inspur.common.core.page.TableDataInfo;

/**
 * 语音网关Controller
 *
 * @author inspur
 * @date 2024-09-30
 */
@RestController
@RequestMapping("/gateway/info")
public class ElevatorGatewayInfoController extends BaseController
{
    @Autowired
    private IElevatorGatewayInfoService elevatorGatewayInfoService;

    /**
     * 查询语音网关列表
     */
    @PreAuthorize("@ss.hasPermi('gateway:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(ElevatorGatewayInfo elevatorGatewayInfo)
    {
        startPage();
        List<ElevatorGatewayInfo> list = elevatorGatewayInfoService.selectElevatorGatewayInfoList(elevatorGatewayInfo);
        return getDataTable(list);
    }

    /**
     * 导出语音网关列表
     */
    @PreAuthorize("@ss.hasPermi('gateway:info:export')")
    @Log(title = "语音网关", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElevatorGatewayInfo elevatorGatewayInfo)
    {
        List<ElevatorGatewayInfo> list = elevatorGatewayInfoService.selectElevatorGatewayInfoList(elevatorGatewayInfo);
        ExcelUtil<ElevatorGatewayInfo> util = new ExcelUtil<ElevatorGatewayInfo>(ElevatorGatewayInfo.class);
        util.exportExcel(response, list, "语音网关数据");
    }

    /**
     * 获取语音网关详细信息
     */
    @PreAuthorize("@ss.hasPermi('gateway:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(elevatorGatewayInfoService.selectElevatorGatewayInfoById(id));
    }

    /**
     * 新增语音网关
     */
    @PreAuthorize("@ss.hasPermi('gateway:info:add')")
    @Log(title = "语音网关", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElevatorGatewayInfo elevatorGatewayInfo)
    {
        return toAjax(elevatorGatewayInfoService.insertElevatorGatewayInfo(elevatorGatewayInfo));
    }

    /**
     * 修改语音网关
     */
    @PreAuthorize("@ss.hasPermi('gateway:info:edit')")
    @Log(title = "语音网关", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElevatorGatewayInfo elevatorGatewayInfo)
    {
        return toAjax(elevatorGatewayInfoService.updateElevatorGatewayInfo(elevatorGatewayInfo));
    }

    /**
     * 删除语音网关
     */
    @PreAuthorize("@ss.hasPermi('gateway:info:remove')")
    @Log(title = "语音网关", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(elevatorGatewayInfoService.deleteElevatorGatewayInfoByIds(ids));
    }
}
