package com.iailab.module.data.http.service.impl;
|
|
import com.iailab.module.data.http.dto.TagCommonCurrentDto;
|
import com.iailab.module.data.http.service.HttpTagService;
|
import javax.annotation.Resource;
|
import org.springframework.stereotype.Component;
|
import org.springframework.util.CollectionUtils;
|
|
import java.math.BigDecimal;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
@Component
|
public class HttpTagCollector {
|
|
@Resource
|
private HttpTagService httpTagService;
|
|
|
public Map<String, Object> collect(String httpApiCode, List<String> tagIds) {
|
Map<String, Object> result = new HashMap<>();
|
if (CollectionUtils.isEmpty(tagIds)) {
|
return null;
|
}
|
List<TagCommonCurrentDto> tags = new ArrayList<>();
|
for (String tagId : tagIds) {
|
String[] parts = tagId.split("_");
|
TagCommonCurrentDto dto=new TagCommonCurrentDto();
|
dto.setTagType(parts[0]);
|
dto.setTagCode(tagId);
|
tags.add(dto);
|
}
|
Map<String, BigDecimal> tagsValues = httpTagService.getTagsValues(httpApiCode, tags);
|
if (!CollectionUtils.isEmpty(tagsValues)) {
|
tagsValues.forEach((k, v) -> {
|
result.put(k, v);
|
});
|
}
|
return result;
|
}
|
|
}
|