提交 | 用户 | 时间
|
a6de49
|
1 |
package com.iailab.module.data.http.service.impl; |
H |
2 |
|
|
3 |
import com.iailab.module.data.http.dto.TagCommonCurrentDto; |
|
4 |
import com.iailab.module.data.http.service.HttpTagService; |
|
5 |
import javax.annotation.Resource; |
|
6 |
import org.springframework.stereotype.Component; |
|
7 |
import org.springframework.util.CollectionUtils; |
|
8 |
|
|
9 |
import java.math.BigDecimal; |
|
10 |
import java.util.ArrayList; |
|
11 |
import java.util.HashMap; |
|
12 |
import java.util.List; |
|
13 |
import java.util.Map; |
|
14 |
|
|
15 |
@Component |
|
16 |
public class HttpTagCollector { |
|
17 |
|
|
18 |
@Resource |
|
19 |
private HttpTagService httpTagService; |
|
20 |
|
|
21 |
|
|
22 |
public Map<String, Object> collect(String httpApiCode, List<String> tagIds) { |
|
23 |
Map<String, Object> result = new HashMap<>(); |
|
24 |
if (CollectionUtils.isEmpty(tagIds)) { |
|
25 |
return null; |
|
26 |
} |
|
27 |
List<TagCommonCurrentDto> tags = new ArrayList<>(); |
|
28 |
for (String tagId : tagIds) { |
|
29 |
String[] parts = tagId.split("_"); |
|
30 |
TagCommonCurrentDto dto=new TagCommonCurrentDto(); |
|
31 |
dto.setTagType(parts[0]); |
|
32 |
dto.setTagCode(tagId); |
|
33 |
tags.add(dto); |
|
34 |
} |
|
35 |
Map<String, BigDecimal> tagsValues = httpTagService.getTagsValues(httpApiCode, tags); |
|
36 |
if (!CollectionUtils.isEmpty(tagsValues)) { |
|
37 |
tagsValues.forEach((k, v) -> { |
|
38 |
result.put(k, v); |
|
39 |
}); |
|
40 |
} |
|
41 |
return result; |
|
42 |
} |
|
43 |
|
|
44 |
} |