mirror of
https://gitee.com/liweiyi/ChestnutCMS.git
synced 2025-12-06 16:38:24 +08:00
修正站点主题导入资源iurl转换错误
This commit is contained in:
parent
7c4f76f7b9
commit
49f6c943d3
@ -8,7 +8,6 @@ import com.chestnut.common.async.AsyncTaskManager;
|
||||
import com.chestnut.common.utils.JacksonUtils;
|
||||
import com.chestnut.common.utils.StringUtils;
|
||||
import com.chestnut.contentcore.core.ICoreDataHandler;
|
||||
import com.chestnut.contentcore.core.InternalURL;
|
||||
import com.chestnut.contentcore.core.SiteExportContext;
|
||||
import com.chestnut.contentcore.core.SiteImportContext;
|
||||
import com.chestnut.contentcore.util.InternalUrlUtils;
|
||||
@ -17,7 +16,6 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
/**
|
||||
@ -83,18 +81,8 @@ public class ArticleCoreDataHandler implements ICoreDataHandler {
|
||||
while (matcher.find()) {
|
||||
String tagStr = matcher.group();
|
||||
String iurl = matcher.group(1);
|
||||
// begin
|
||||
try {
|
||||
InternalURL internalUrl = InternalUrlUtils.parseInternalUrl(iurl);
|
||||
if (Objects.nonNull(internalUrl)) {
|
||||
Long resourceId = context.getResourceIdMap().get(internalUrl.getId());
|
||||
internalUrl.setId(resourceId);
|
||||
tagStr = StringUtils.replaceEx(tagStr, iurl, internalUrl.toIUrl());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// end
|
||||
String newIurl = context.dealInternalUrl(iurl);
|
||||
tagStr = StringUtils.replaceEx(tagStr, iurl, newIurl);
|
||||
html.append(contentHtml, index, matcher.start()).append(tagStr);
|
||||
index = matcher.end();
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import com.chestnut.common.utils.IdUtils;
|
||||
import com.chestnut.contentcore.config.CMSConfig;
|
||||
import com.chestnut.contentcore.core.impl.InternalDataType_Catalog;
|
||||
import com.chestnut.contentcore.core.impl.InternalDataType_Content;
|
||||
import com.chestnut.contentcore.core.impl.InternalDataType_Resource;
|
||||
import com.chestnut.contentcore.domain.CmsSite;
|
||||
import com.chestnut.contentcore.util.InternalUrlUtils;
|
||||
import com.chestnut.contentcore.util.SiteUtils;
|
||||
@ -83,10 +84,14 @@ public class SiteImportContext implements ISiteThemeContext {
|
||||
Long id = switch (internalURL.getType()) {
|
||||
case InternalDataType_Catalog.ID -> catalogIdMap.get(internalURL.getId());
|
||||
case InternalDataType_Content.ID -> contentIdMap.get(internalURL.getId());
|
||||
case InternalDataType_Resource.ID -> resourceIdMap.get(internalURL.getId());
|
||||
default -> null;
|
||||
};
|
||||
if (IdUtils.validate(id)) {
|
||||
internalURL.setId(id);
|
||||
if (InternalDataType_Resource.ID.equals(internalURL.getType())) {
|
||||
internalURL.setParams(Map.of("sid", site.getSiteId().toString()));
|
||||
}
|
||||
return internalURL.toIUrl();
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,16 +147,7 @@ public class SiteThemeService {
|
||||
}
|
||||
data.createBy(context.getOperator());
|
||||
// 处理logo
|
||||
InternalURL internalURL = InternalUrlUtils.parseInternalUrl(data.getLogo());
|
||||
if (Objects.nonNull(internalURL)) {
|
||||
Long resourceId = context.getResourceIdMap().get(internalURL.getId());
|
||||
if (IdUtils.validate(resourceId)) {
|
||||
internalURL.setId(resourceId);
|
||||
data.setLogo(internalURL.toIUrl());
|
||||
} else {
|
||||
data.setLogo(StringUtils.EMPTY);
|
||||
}
|
||||
}
|
||||
data.setLogo(context.dealInternalUrl(data.getLogo()));
|
||||
catalogService.save(data);
|
||||
context.getCatalogIdMap().put(sourceCatalogId, data.getCatalogId());
|
||||
if (CatalogType_Link.ID.equals(data.getCatalogType())) {
|
||||
@ -199,6 +190,8 @@ public class SiteThemeService {
|
||||
if (Objects.nonNull(catalog)) {
|
||||
data.setCatalogId(catalog.getCatalogId());
|
||||
data.setCatalogAncestors(catalog.getAncestors());
|
||||
} else {
|
||||
this.addErrorMessage("页面部件栏目关联失败:" + data.getName());
|
||||
}
|
||||
}
|
||||
data.createBy(context.getOperator());
|
||||
@ -231,16 +224,7 @@ public class SiteThemeService {
|
||||
content.setDeptCode(StringUtils.EMPTY);
|
||||
content.createBy(operator.getUsername());
|
||||
// 处理logo
|
||||
InternalURL internalURL = InternalUrlUtils.parseInternalUrl(catalog.getLogo());
|
||||
if (Objects.nonNull(internalURL)) {
|
||||
Long resourceId = context.getResourceIdMap().get(internalURL.getId());
|
||||
if (IdUtils.validate(resourceId)) {
|
||||
internalURL.setId(resourceId);
|
||||
catalog.setLogo(internalURL.toIUrl());
|
||||
} else {
|
||||
catalog.setLogo(StringUtils.EMPTY);
|
||||
}
|
||||
}
|
||||
content.setLogo(context.dealInternalUrl(content.getLogo()));
|
||||
contentService.save(content);
|
||||
context.getContentIdMap().put(sourceContentId, content.getContentId());
|
||||
if (content.isLinkContent()) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user