package cn.wise.sc.energy.power.plant.business.controller;

import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import cn.wise.sc.energy.power.plant.business.service.IEventInfoService;
import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description: 报警事件
 * @author: qh
 * @create: 2020-09-03 14:21
 **/
@CrossOrigin
@RestController
@RequestMapping("event/info/")
public class EventInfoController {

    final
    IEventInfoService iEventInfoService;

    public EventInfoController(IEventInfoService iEventInfoService) {
        this.iEventInfoService = iEventInfoService;
    }

    @GetMapping
    public BaseResponse<List<EntityVo>> listByState(Integer state) {
        List<EntityVo> entityVos = iEventInfoService.listByState(state);
        if (entityVos.size() == 0){
            return BaseResponse.errorMsg("没找着!");
        }else {
            return BaseResponse.okData(entityVos);
        }
    }

}
