mirror of
https://github.com/dataease/dataease.git
synced 2025-02-24 19:42:56 +08:00
refactor(工作台): 优化从模版市场获取模版方式支持模版市场记录下载数量,修复模板市场中的部分模板使用时报“解析错误” #12039
This commit is contained in:
parent
aef0629df0
commit
5766367390
@ -5,7 +5,9 @@ import io.dataease.api.template.dto.TemplateManageFileDTO;
|
|||||||
import io.dataease.api.template.dto.TemplateMarketDTO;
|
import io.dataease.api.template.dto.TemplateMarketDTO;
|
||||||
import io.dataease.api.template.dto.TemplateMarketPreviewInfoDTO;
|
import io.dataease.api.template.dto.TemplateMarketPreviewInfoDTO;
|
||||||
import io.dataease.api.template.response.*;
|
import io.dataease.api.template.response.*;
|
||||||
|
import io.dataease.api.template.vo.MarketApplicationMetaDataVO;
|
||||||
import io.dataease.api.template.vo.MarketApplicationSpecVO;
|
import io.dataease.api.template.vo.MarketApplicationSpecVO;
|
||||||
|
import io.dataease.api.template.vo.MarketLatestReleaseVO;
|
||||||
import io.dataease.api.template.vo.MarketMetaDataVO;
|
import io.dataease.api.template.vo.MarketMetaDataVO;
|
||||||
import io.dataease.constant.CommonConstants;
|
import io.dataease.constant.CommonConstants;
|
||||||
import io.dataease.exception.DEException;
|
import io.dataease.exception.DEException;
|
||||||
@ -36,6 +38,7 @@ import java.util.stream.Collectors;
|
|||||||
public class TemplateCenterManage {
|
public class TemplateCenterManage {
|
||||||
private final static String POSTS_API_V2 = "/apis/api.store.halo.run/v1alpha1/applications?keyword=&priceMode=&sort=latestReleaseTimestamp%2Cdesc&type=THEME&deVersion=V2&templateType=&label=&page=1&size=2000";
|
private final static String POSTS_API_V2 = "/apis/api.store.halo.run/v1alpha1/applications?keyword=&priceMode=&sort=latestReleaseTimestamp%2Cdesc&type=THEME&deVersion=V2&templateType=&label=&page=1&size=2000";
|
||||||
private final static String TEMPLATE_META_DATA_URL = "/upload/meta_data.json";
|
private final static String TEMPLATE_META_DATA_URL = "/upload/meta_data.json";
|
||||||
|
private final static String TEMPLATE_BASE_INFO_URL = "/apis/api.store.halo.run/v1alpha1/applications/";
|
||||||
@Resource
|
@Resource
|
||||||
private SysParameterManage sysParameterManage;
|
private SysParameterManage sysParameterManage;
|
||||||
|
|
||||||
@ -64,6 +67,25 @@ public class TemplateCenterManage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param templateUrl template url
|
||||||
|
* @Description Get template file from template market
|
||||||
|
*/
|
||||||
|
public TemplateManageFileDTO getTemplateFromMarketV2(String templateName) {
|
||||||
|
if (StringUtils.isNotEmpty(templateName)) {
|
||||||
|
String sufUrl = sysParameterManage.groupVal("template.").get("template.url");
|
||||||
|
String templateBaseInfo = HttpClientUtil.get(sufUrl + TEMPLATE_BASE_INFO_URL + templateName, null);
|
||||||
|
MarketTemplateV2ItemResult baseItemInfo = JsonUtil.parseObject(templateBaseInfo, MarketTemplateV2ItemResult.class);
|
||||||
|
String templateUrl = sufUrl + "/store/apps/" + templateName +
|
||||||
|
"/releases/download/" + baseItemInfo.getLatestRelease().getRelease().getMetadata().getName()
|
||||||
|
+ "/assets/" + baseItemInfo.getLatestRelease().getAssets().getFirst().getMetadata().getName();
|
||||||
|
String templateInfo = HttpClientUtil.get(templateUrl, null);
|
||||||
|
return JsonUtil.parseObject(templateInfo, TemplateManageFileDTO.class);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param url content api url
|
* @param url content api url
|
||||||
* @Description Get info from template market content api
|
* @Description Get info from template market content api
|
||||||
@ -181,8 +203,9 @@ public class TemplateCenterManage {
|
|||||||
if (v2BaseResponse != null) {
|
if (v2BaseResponse != null) {
|
||||||
v2BaseResponse.getItems().stream().forEach(marketTemplateV2ItemResult -> {
|
v2BaseResponse.getItems().stream().forEach(marketTemplateV2ItemResult -> {
|
||||||
MarketApplicationSpecVO spec = marketTemplateV2ItemResult.getApplication().getSpec();
|
MarketApplicationSpecVO spec = marketTemplateV2ItemResult.getApplication().getSpec();
|
||||||
|
MarketApplicationMetaDataVO metadata = marketTemplateV2ItemResult.getApplication().getMetadata();
|
||||||
if ("Y".equalsIgnoreCase(spec.getSuggest())) {
|
if ("Y".equalsIgnoreCase(spec.getSuggest())) {
|
||||||
contents.add(new TemplateMarketDTO(spec.getReadmeName(), spec.getDisplayName(), spec.getScreenshots().get(0).getUrl(), spec.getLinks().get(0).getUrl(), categoriesMap.get(spec.getLabel()), spec.getTemplateType(), useTime.get(spec.getReadmeName()), "Y"));
|
contents.add(new TemplateMarketDTO(metadata.getName(), spec.getDisplayName(), spec.getScreenshots().get(0).getUrl(), spec.getLinks().get(0).getUrl(), categoriesMap.get(spec.getLabel()), spec.getTemplateType(), useTime.get(spec.getReadmeName()), "Y"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -221,7 +244,8 @@ public class TemplateCenterManage {
|
|||||||
if (v2BaseResponse != null) {
|
if (v2BaseResponse != null) {
|
||||||
v2BaseResponse.getItems().stream().forEach(marketTemplateV2ItemResult -> {
|
v2BaseResponse.getItems().stream().forEach(marketTemplateV2ItemResult -> {
|
||||||
MarketApplicationSpecVO spec = marketTemplateV2ItemResult.getApplication().getSpec();
|
MarketApplicationSpecVO spec = marketTemplateV2ItemResult.getApplication().getSpec();
|
||||||
contents.add(new TemplateMarketDTO(spec.getReadmeName(), spec.getDisplayName(), spec.getScreenshots().get(0).getUrl(), spec.getLinks().get(0).getUrl(), categoriesMap.get(spec.getLabel()), spec.getTemplateType(), useTime.get(spec.getReadmeName()), spec.getSuggest()));
|
MarketApplicationMetaDataVO metadata = marketTemplateV2ItemResult.getApplication().getMetadata();
|
||||||
|
contents.add(new TemplateMarketDTO(metadata.getName(), spec.getDisplayName(), spec.getScreenshots().get(0).getUrl(), spec.getLinks().get(0).getUrl(), categoriesMap.get(spec.getLabel()), spec.getTemplateType(), useTime.get(spec.getReadmeName()), spec.getSuggest()));
|
||||||
if (categoriesMap.get(spec.getLabel()) != null) {
|
if (categoriesMap.get(spec.getLabel()) != null) {
|
||||||
activeCategoriesName.add(categoriesMap.get(spec.getLabel()));
|
activeCategoriesName.add(categoriesMap.get(spec.getLabel()));
|
||||||
}
|
}
|
||||||
|
@ -571,7 +571,7 @@ public class DataVisualizationServer implements DataVisualizationApi {
|
|||||||
name = request.getName();
|
name = request.getName();
|
||||||
dvType = request.getType();
|
dvType = request.getType();
|
||||||
} else if (DataVisualizationConstants.NEW_PANEL_FROM.NEW_MARKET_TEMPLATE.equals(newFrom)) {
|
} else if (DataVisualizationConstants.NEW_PANEL_FROM.NEW_MARKET_TEMPLATE.equals(newFrom)) {
|
||||||
TemplateManageFileDTO templateFileInfo = templateCenterManage.getTemplateFromMarket(request.getTemplateUrl());
|
TemplateManageFileDTO templateFileInfo = templateCenterManage.getTemplateFromMarketV2(request.getResourceName());
|
||||||
if (templateFileInfo == null) {
|
if (templateFileInfo == null) {
|
||||||
DEException.throwException("Can't find the template's info from market,please check");
|
DEException.throwException("Can't find the template's info from market,please check");
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package io.dataease.api.template.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MarketLatestRelease {
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package io.dataease.api.template.response;
|
package io.dataease.api.template.response;
|
||||||
|
|
||||||
import io.dataease.api.template.vo.MarketApplicationVO;
|
import io.dataease.api.template.vo.MarketApplicationVO;
|
||||||
|
import io.dataease.api.template.vo.MarketLatestReleaseVO;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,4 +13,6 @@ public class MarketTemplateV2ItemResult {
|
|||||||
|
|
||||||
private MarketApplicationVO application;
|
private MarketApplicationVO application;
|
||||||
|
|
||||||
|
private MarketLatestReleaseVO latestRelease;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package io.dataease.api.template.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MarketApplicationMetaDataVO {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
}
|
@ -9,5 +9,8 @@ import lombok.Data;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class MarketApplicationVO {
|
public class MarketApplicationVO {
|
||||||
|
|
||||||
private MarketApplicationSpecVO spec;
|
private MarketApplicationSpecVO spec;
|
||||||
|
|
||||||
|
private MarketApplicationMetaDataVO metadata;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package io.dataease.api.template.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MarketLatestReleaseVO {
|
||||||
|
|
||||||
|
private MarketReleaseVO release;
|
||||||
|
|
||||||
|
private List<MarketReleaseAssetVO> assets;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package io.dataease.api.template.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MarketReleaseAssetVO {
|
||||||
|
|
||||||
|
private MarketReleaseMetaDataVO metadata;
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package io.dataease.api.template.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MarketReleaseMetaDataVO {
|
||||||
|
private String name;
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package io.dataease.api.template.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MarketReleaseVO {
|
||||||
|
|
||||||
|
private MarketReleaseMetaDataVO metadata;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user