package com.gyee.runeconomy.controller.monitor;/*
@author   谢生杰
@date   2023/4/4-9:50
*/

import com.gyee.common.model.StringUtils;
import com.gyee.common.vo.monitor.StatusVo;
import com.gyee.runeconomy.dto.R;
import com.gyee.runeconomy.dto.ResultMsg;
import com.gyee.runeconomy.service.monitor.StatusService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/status")
@Api(value = "状态监视", tags = "状态监视")
public class StatusController {

    @Resource
    private StatusService statusService;

    /**
     * 状态监视
     *
     * @return
     */
    @GetMapping("/monitor")
    @ResponseBody
    @ApiOperation(value = "状态监视", notes = "状态监视")
    public R monitor(@RequestParam(value = "type", required = true) String type,
                     @RequestParam(value = "company", required = true) String company) throws Exception {

        List<StatusVo> resultList = statusService.monitor(company, type);
        if (StringUtils.isNotNull(resultList)) {
            return R.data(ResultMsg.ok(resultList, resultList.size()));
        } else {
            return R.error(ResultMsg.error());
        }
    }
}
