package com.iailab.module.data.channel.http.collector;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2024年11月20日
|
*/
|
|
import com.iailab.framework.common.constant.CommonConstant;
|
import com.iailab.module.data.channel.http.collector.ihdb.HttpCollectorForIhd;
|
import com.iailab.module.data.channel.http.entity.HttpApiEntity;
|
import com.iailab.module.data.channel.http.service.HttpApiService;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
@Slf4j
|
@Component
|
public class HttpCollector {
|
|
@Autowired
|
private HttpApiService httpApiService;
|
|
@Autowired
|
private HttpCollectorForIhd httpCollectorForIhd;
|
|
public Object getTagValue(String apiId, String tag) {
|
HttpApiEntity httpApi = httpApiService.getFromCatch(apiId);
|
if (httpApi == null) {
|
return CommonConstant.BAD_VALUE;
|
}
|
List<String> tagNames = new ArrayList<>();
|
tagNames.add(tag);
|
Map<String, Object> valueMap = new HashMap<String, Object>();
|
if (SourceApiEnum.iHyperDB.getCode().equals(httpApi.getCode())) {
|
valueMap = httpCollectorForIhd.getLastValues(apiId, tagNames);
|
}
|
if (valueMap.get(tag) == null) {
|
return CommonConstant.BAD_VALUE;
|
}
|
return valueMap.get(tag);
|
}
|
}
|