提交 | 用户 | 时间
|
2f03e2
|
1 |
package com.iailab.module.data.channel.http.collector; |
潘 |
2 |
|
|
3 |
/** |
|
4 |
* @author PanZhibao |
|
5 |
* @Description |
|
6 |
* @createTime 2024年11月20日 |
|
7 |
*/ |
|
8 |
|
|
9 |
import com.iailab.framework.common.constant.CommonConstant; |
|
10 |
import com.iailab.module.data.channel.http.collector.ihdb.HttpCollectorForIhd; |
|
11 |
import com.iailab.module.data.channel.http.entity.HttpApiEntity; |
|
12 |
import com.iailab.module.data.channel.http.service.HttpApiService; |
|
13 |
import lombok.extern.slf4j.Slf4j; |
|
14 |
import org.springframework.beans.factory.annotation.Autowired; |
|
15 |
import org.springframework.stereotype.Component; |
|
16 |
|
|
17 |
import java.util.ArrayList; |
|
18 |
import java.util.HashMap; |
|
19 |
import java.util.List; |
|
20 |
import java.util.Map; |
|
21 |
|
|
22 |
@Slf4j |
|
23 |
@Component |
|
24 |
public class HttpCollector { |
|
25 |
|
|
26 |
@Autowired |
|
27 |
private HttpApiService httpApiService; |
|
28 |
|
|
29 |
@Autowired |
|
30 |
private HttpCollectorForIhd httpCollectorForIhd; |
|
31 |
|
|
32 |
public Object getTagValue(String apiId, String tag) { |
|
33 |
HttpApiEntity httpApi = httpApiService.getFromCatch(apiId); |
|
34 |
if (httpApi == null) { |
|
35 |
return CommonConstant.BAD_VALUE; |
|
36 |
} |
|
37 |
List<String> tagNames = new ArrayList<>(); |
|
38 |
tagNames.add(tag); |
|
39 |
Map<String, Object> valueMap = new HashMap<String, Object>(); |
|
40 |
if (SourceApiEnum.iHyperDB.getCode().equals(httpApi.getCode())) { |
|
41 |
valueMap = httpCollectorForIhd.getLastValues(apiId, tagNames); |
|
42 |
} |
|
43 |
if (valueMap.get(tag) == null) { |
|
44 |
return CommonConstant.BAD_VALUE; |
|
45 |
} |
|
46 |
return valueMap.get(tag); |
|
47 |
} |
|
48 |
} |