diff --git a/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/ArticleCoreDataHandler.java b/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/ArticleCoreDataHandler.java index 7118e4cb..d58ef41f 100644 --- a/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/ArticleCoreDataHandler.java +++ b/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/ArticleCoreDataHandler.java @@ -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(); } diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/SiteImportContext.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/SiteImportContext.java index 3d77f804..25893ca5 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/SiteImportContext.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/SiteImportContext.java @@ -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(); } } diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/SiteThemeService.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/SiteThemeService.java index a2d26b59..8c8bbc17 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/SiteThemeService.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/SiteThemeService.java @@ -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()) {