mirror of
https://gitee.com/liweiyi/ChestnutCMS.git
synced 2025-12-06 08:28:23 +08:00
历史主题导入兼容处理
This commit is contained in:
parent
3c585dd6b7
commit
04bff30f2f
@ -31,6 +31,7 @@ import com.chestnut.contentcore.service.*;
|
||||
import com.chestnut.contentcore.util.CatalogUtils;
|
||||
import com.chestnut.contentcore.util.InternalUrlUtils;
|
||||
import com.chestnut.contentcore.util.SiteUtils;
|
||||
import com.chestnut.system.fixed.dict.YesOrNo;
|
||||
import jodd.io.ZipUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -103,7 +104,7 @@ public class SiteThemeService {
|
||||
data.createBy(context.getOperator());
|
||||
sitePropertyService.save(data);
|
||||
} catch (Exception e) {
|
||||
this.addErrorMessage("导入站点扩展属性数据失败:" + propertyId);
|
||||
this.addErrorMessage("导入站点扩展属性数据`" + propertyId + "`失败:" + e.getMessage());
|
||||
log.error("Import site property failed: {}", propertyId, e);
|
||||
}
|
||||
});
|
||||
@ -122,7 +123,7 @@ public class SiteThemeService {
|
||||
resourceService.save(data);
|
||||
context.getResourceIdMap().put(oldResource, data.getResourceId());
|
||||
} catch (Exception e) {
|
||||
this.addErrorMessage("导入素材资源数据失败:" + oldResource);
|
||||
this.addErrorMessage("导入素材资源数据`" + oldResource + "`失败:" + e.getMessage());
|
||||
log.error("Import site resource failed: {}", oldResource, e);
|
||||
}
|
||||
});
|
||||
@ -161,6 +162,9 @@ public class SiteThemeService {
|
||||
data.setParentId(0L);
|
||||
}
|
||||
}
|
||||
if (StringUtils.isEmpty(data.getTagIgnore())) {
|
||||
data.setTagIgnore(YesOrNo.NO); // 兼容历史主题包
|
||||
}
|
||||
data.createBy(context.getOperator());
|
||||
// 处理logo
|
||||
data.setLogo(context.dealInternalUrl(data.getLogo()));
|
||||
@ -170,7 +174,7 @@ public class SiteThemeService {
|
||||
linkCatalogs.add(data);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.addErrorMessage("导入栏目数据失败:" + data.getName());
|
||||
this.addErrorMessage("导入栏目`"+sourceCatalogId+"`数据失败:" + data.getName());
|
||||
log.error("Import catalog failed: {}", sourceCatalogId, e);
|
||||
}
|
||||
});
|
||||
@ -187,7 +191,7 @@ public class SiteThemeService {
|
||||
data.setCreateBy(operator.getUsername());
|
||||
publishPipeService.addPublishPipe(data);
|
||||
} catch (Exception e) {
|
||||
this.addErrorMessage("导入发布通道数据失败:" + data.getName());
|
||||
this.addErrorMessage("导入发布通道数据`"+data.getCode()+"`失败:" + e.getMessage());
|
||||
log.error("Import publish pipe failed: {}", oldPublishPipeId, e);
|
||||
}
|
||||
}
|
||||
@ -215,7 +219,7 @@ public class SiteThemeService {
|
||||
pageWidgetService.save(data);
|
||||
context.getPageWidgetIdMap().put(oldPageWidgetId, data.getPageWidgetId());
|
||||
} catch (Exception e) {
|
||||
this.addErrorMessage("导入页面部件数据失败:" + data.getName());
|
||||
this.addErrorMessage("导入页面部件数据`" + oldPageWidgetId + "`失败:" + e.getMessage());
|
||||
log.error("Import page widget failed: {}", oldPageWidgetId, e);
|
||||
}
|
||||
});
|
||||
@ -230,6 +234,9 @@ public class SiteThemeService {
|
||||
Long sourceContentId = content.getContentId();
|
||||
try {
|
||||
CmsCatalog catalog = catalogService.getCatalog(context.getCatalogIdMap().get(content.getCatalogId()));
|
||||
if (Objects.isNull(catalog)) {
|
||||
throw new RuntimeException("Catalog is missing.");
|
||||
}
|
||||
|
||||
content.setContentId(IdUtils.getSnowflakeId());
|
||||
content.setSiteId(site.getSiteId());
|
||||
@ -241,15 +248,20 @@ public class SiteThemeService {
|
||||
content.setDeptCode(StringUtils.EMPTY);
|
||||
content.createBy(operator.getUsername());
|
||||
// 处理logo
|
||||
content.setLogo(context.dealInternalUrl(content.getLogo()));
|
||||
if (StringUtils.isNotEmpty(content.getLogo()) && StringUtils.isEmpty(content.getImages())) {
|
||||
content.setImages(List.of(content.getLogo())); // 兼容老版本
|
||||
}
|
||||
if (StringUtils.isNotEmpty(content.getImages())) {
|
||||
content.setImages(content.getImages().stream().map(context::dealInternalUrl).toList());
|
||||
}
|
||||
contentService.dao().save(content);
|
||||
context.getContentIdMap().put(sourceContentId, content.getContentId());
|
||||
if (content.isLinkContent()) {
|
||||
linkContents.add(content);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.addErrorMessage("导入内容数据失败:" + sourceContentId);
|
||||
log.error("Import content failed: {}", sourceContentId, e);
|
||||
this.addErrorMessage("导入内容数据`" + sourceContentId + "`失败:" + e.getMessage());
|
||||
log.error("Import content `{}` failed: {}", sourceContentId, e.getMessage(), e);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -269,7 +281,7 @@ public class SiteThemeService {
|
||||
content.createBy(operator.getUsername());
|
||||
contentRelaService.save(content);
|
||||
} catch (Exception e) {
|
||||
this.addErrorMessage("导入关联内容数据失败:" + sourceContentId);
|
||||
this.addErrorMessage("导入关联内容数据`" + sourceContentId + "`失败:" + e.getMessage());
|
||||
log.error("Import content rela data failed: {}", sourceContentId, e);
|
||||
}
|
||||
});
|
||||
@ -377,9 +389,13 @@ public class SiteThemeService {
|
||||
offset = page.getRecords().get(page.getRecords().size() - 1).getContentId();
|
||||
fileIndex++;
|
||||
page.getRecords().forEach(content -> {
|
||||
InternalURL internalURL = InternalUrlUtils.parseInternalUrl(content.getLogo());
|
||||
if (Objects.nonNull(internalURL)) {
|
||||
context.getResourceIds().add(internalURL.getId());
|
||||
if (Objects.nonNull(content.getImages())) {
|
||||
content.getImages().forEach(img -> {
|
||||
InternalURL internalURL = InternalUrlUtils.parseInternalUrl(img);
|
||||
if (Objects.nonNull(internalURL)) {
|
||||
context.getResourceIds().add(internalURL.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (page.getRecords().size() < pageSize) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user