package com.aucma.dms.controller;

import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult;
import com.aucma.common.core.page.TableDataInfo;
import com.aucma.common.utils.poi.ExcelUtil;
import com.aucma.dms.domain.DmsRealtimeStatus;
import com.aucma.dms.domain.DmsRealtimeStatusHistory;
import com.aucma.dms.service.IDmsRealtimeStatusService;
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 Yinq
 * @date 2024-09-02
 */
@RestController
@RequestMapping("/dms/dmsRealtimeStatus")
public class DmsRealtimeStatusController extends BaseController {

    @Autowired
    private IDmsRealtimeStatusService dmsRealtimeStatusService;

    /**
     * 查询设备实时状态列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsRealtimeStatus:list')" )
    @GetMapping("/list")
    public TableDataInfo list(DmsRealtimeStatus dmsRealtimeStatus) {
        startPage();
        List<DmsRealtimeStatus> list = dmsRealtimeStatusService.selectDmsRealtimeStatusList(dmsRealtimeStatus);
        return getDataTable(list);
    }
    @GetMapping("/history")
    public TableDataInfo history(DmsRealtimeStatusHistory history) {
        startPage();
        List<DmsRealtimeStatusHistory> list = dmsRealtimeStatusService.history(history);
        return getDataTable(list);
    }

    /**
     * 导出设备实时状态列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsRealtimeStatus:export')" )
    ////@Log(title = "设备实时状态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsRealtimeStatus dmsRealtimeStatus) {
        List<DmsRealtimeStatus> list = dmsRealtimeStatusService.selectDmsRealtimeStatusList(dmsRealtimeStatus);
        ExcelUtil<DmsRealtimeStatus> util = new ExcelUtil<DmsRealtimeStatus>(DmsRealtimeStatus.class);
        util.exportExcel(response, list, "设备实时状态数据");
    }

    /**
     * 获取设备实时状态详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsRealtimeStatus:query')" )
    @GetMapping(value = "/{statusId}")
    public AjaxResult getInfo(@PathVariable("statusId") Long statusId) {
        return success(dmsRealtimeStatusService.selectDmsRealtimeStatusByStatusId(statusId));
    }

    /**
     * 新增设备实时状态
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsRealtimeStatus:add')" )
    ////@Log(title = "设备实时状态", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsRealtimeStatus dmsRealtimeStatus) {
        return toAjax(dmsRealtimeStatusService.insertDmsRealtimeStatus(dmsRealtimeStatus));
    }

    /**
     * 修改设备实时状态
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsRealtimeStatus:edit')" )
    ////@Log(title = "设备实时状态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsRealtimeStatus dmsRealtimeStatus) {
        return toAjax(dmsRealtimeStatusService.updateDmsRealtimeStatus(dmsRealtimeStatus));
    }

    /**
     * 删除设备实时状态
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsRealtimeStatus:remove')" )
    ////@Log(title = "设备实时状态", businessType = BusinessType.DELETE)
    @DeleteMapping("/{statusIds}")
    public AjaxResult remove(@PathVariable Long[] statusIds) {
        return toAjax(dmsRealtimeStatusService.deleteDmsRealtimeStatusByStatusIds(statusIds));
    }
}
