package com.ruoyi.web.dashboard;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.bst.areaJoin.domain.enums.AreaJoinPermission;
import com.ruoyi.bst.device.domain.dto.DeviceStatQuery;
import com.ruoyi.bst.device.service.DeviceDashboard;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/dashboard/device")
public class DashboardDeviceController extends BaseController {

    @Autowired
    private DeviceDashboard deviceDashboard;

    @ApiOperation("获取设备统计数据")
    @PreAuthorize("@ss.hasAnyPermi('dashboard:device:stat')")
    @GetMapping("/stat")
    public AjaxResult getStat(DeviceStatQuery query) {
        query.setScope(true);
        query.addAreaPermission(AreaJoinPermission.DEVICE_VIEW.getCode());
        return success(deviceDashboard.selectStat(query, query.getKeys()));
    }
}
