package com.yihu.hos.controllers;

import com.yihu.hos.services.ServerEnvironmentService;
import com.yihu.hos.web.framework.model.Result;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/10/26.
 */
@Controller
@RequestMapping("/serverEnv")
public class ServerEnvironmentController {

    @Resource(name = ServerEnvironmentService.BEAN_ID)
    private ServerEnvironmentService serverEnvironmentService;

    @RequestMapping(value = "/usage", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取服务器使用率", produces = "application/json", notes = "获取服务器硬件使用率")
    public Result usage(
            @ApiParam(name = "type", value = "类型", required = true)
            @RequestParam(value = "type") String type,
            @ApiParam(name = "beginTime", value = "开始时间", required = true)
            @RequestParam(value = "beginTime") String beginTime,
            @ApiParam(name = "endTime", value = "结束时间", required = true)
            @RequestParam(value = "endTime") String endTime) {
        return serverEnvironmentService.getMonitorInfo(type, beginTime, endTime);
    }

}
