package com.ruoyi.web.controller.ss;

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

import com.ruoyi.ss.deviceBindRecord.domain.DeviceBindRecordQuery;
import com.ruoyi.ss.deviceBindRecord.domain.DeviceBindRecordVO;
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.PathVariable;
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.ss.deviceBindRecord.service.DeviceBindRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备绑定记录Controller
 *
 * @author ruoyi
 * @date 2024-04-17
 */
@RestController
@RequestMapping("/system/bindRecord")
public class SmDeviceBindRecordController extends BaseController
{
    @Autowired
    private DeviceBindRecordService smDeviceBindRecordService;

    /**
     * 查询设备绑定记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:bindRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeviceBindRecordQuery deviceBindRecord)
    {
        startPage();
        List<DeviceBindRecordVO> list = smDeviceBindRecordService.selectSmDeviceBindRecordList(deviceBindRecord);
        return getDataTable(list);
    }

    /**
     * 导出设备绑定记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:bindRecord:export')")
    @Log(title = "设备绑定记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceBindRecordQuery deviceBindRecord)
    {
        List<DeviceBindRecordVO> list = smDeviceBindRecordService.selectSmDeviceBindRecordList(deviceBindRecord);
        ExcelUtil<DeviceBindRecordVO> util = new ExcelUtil<DeviceBindRecordVO>(DeviceBindRecordVO.class);
        util.exportExcel(response, list, "设备绑定记录数据");
    }

    /**
     * 获取设备绑定记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:bindRecord:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(smDeviceBindRecordService.selectSmDeviceBindRecordByRecordId(recordId));
    }
}
