package com.mosty.sjzx.remote;

import com.alibaba.fastjson.JSON;
import com.mosty.base.model.dto.sjzx.TbJqDTO;
import com.mosty.base.feign.service.MostySjzxFeignService;
import com.mosty.common.base.domain.ResponseResult;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

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

@Slf4j
@Service
@AllArgsConstructor
public class TbSjzxAdaptRemoteService {

    private final MostySjzxFeignService mostySjzxFeignService;

    /**
     * 查询预警数据
     * @param nr 内容
     * @return
     */
    public List<TbJqDTO> selectVigilant(String nr) {
        ResponseResult<List<TbJqDTO>> responseResult = mostySjzxFeignService.selectVigilant(nr);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("查询预警数据异常Result = {}", JSON.toJSONString(responseResult));
            return new ArrayList<>();
        }
        return responseResult.getData();
    }
}
