Merge pull request #3633 from dataease/pr@dev@refactor_template-market-sort

refactor(模板市场): 增加模板市场分类排序
This commit is contained in:
xuwei-fit2cloud 2022-11-03 16:53:00 +08:00 committed by GitHub
commit c937bbd9ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -15,9 +15,9 @@ public class HttpClientConfig {
private Map<String, String> header = new HashMap<>(); private Map<String, String> header = new HashMap<>();
// 设置连接超时时间单位毫秒 // 设置连接超时时间单位毫秒
private int connectTimeout = 5000; private int connectTimeout = 30000;
// 设置从connect Manager获取Connection 超时时间单位毫秒这个属性是新加的属性因为目前版本是可以共享连接池的 // 设置从connect Manager获取Connection 超时时间单位毫秒这个属性是新加的属性因为目前版本是可以共享连接池的
private int connectionRequestTimeout = 5000; private int connectionRequestTimeout = 30000;
// 请求获取数据的超时时间单位毫秒 如果访问一个接口多少时间内无法返回数据就直接放弃此次调用 // 请求获取数据的超时时间单位毫秒 如果访问一个接口多少时间内无法返回数据就直接放弃此次调用
private int socketTimeout = 60000; private int socketTimeout = 60000;

View File

@ -14,4 +14,6 @@ public class TemplateCategory {
private String name; private String name;
private String slug; private String slug;
private Integer priority;
} }

View File

@ -17,6 +17,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -76,7 +77,7 @@ public class TemplateMarketService {
String resultStr = marketGet(basicInfo.getTemplateMarketUlr()+CATEGORIES_API,basicInfo.getTemplateAccessKey()); String resultStr = marketGet(basicInfo.getTemplateMarketUlr()+CATEGORIES_API,basicInfo.getTemplateAccessKey());
List<TemplateCategory> categories = JSONObject.parseObject(resultStr).getJSONArray("data").toJavaList(TemplateCategory.class); List<TemplateCategory> categories = JSONObject.parseObject(resultStr).getJSONArray("data").toJavaList(TemplateCategory.class);
if(CollectionUtils.isNotEmpty(categories)){ if(CollectionUtils.isNotEmpty(categories)){
return categories.stream().map(TemplateCategory :: getName).collect(Collectors.toList()); return categories.stream().sorted(Comparator.comparing(TemplateCategory::getPriority)).map(TemplateCategory :: getName).collect(Collectors.toList());
}else{ }else{
return null; return null;
} }