From 9b51a62597487073b54aa27cdd059828ebfcb2ac Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Fri, 08 Jul 2022 19:19:47 +0800 Subject: [PATCH] ĺ synchronized --- src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ReleaseServiceImpl.java | 49 ++++++++++++++++++++++++++++--------------------- 1 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ReleaseServiceImpl.java b/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ReleaseServiceImpl.java index bd1a0ed..58513fb 100644 --- a/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ReleaseServiceImpl.java +++ b/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ReleaseServiceImpl.java @@ -13,6 +13,7 @@ import org.springframework.stereotype.Service; import java.util.HashMap; +import java.util.Hashtable; import java.util.List; import java.util.Map; import java.util.concurrent.Executor; @@ -44,7 +45,7 @@ ArticleEntity article = articleMapper.selectById(id); ColumnEntity column = columnMapper.selectById(article.getColumnId()); - Map<String, Object> data = new HashMap<>(); + Map<String, Object> data = new Hashtable<>(); data.put("id", article.getId()); data.put("companyId", companyId); @@ -62,29 +63,24 @@ @Override public void releaseColumn(Long id, int type, Long companyId) { ColumnEntity columnEntity = columnMapper.selectById(id); - Map<String, Object> map = new HashMap<>(); - map.put("id", columnEntity.getId()); - map.put("code", columnEntity.getColumnCode()); - if (columnEntity.getParentId() == 0L) { - map.put("parentCode", columnEntity.getColumnCode()); - } else { - ColumnEntity parent = columnMapper.selectById(columnEntity.getParentId()); - map.put("parentCode", parent.getColumnCode()); - } - map.put("templatePath", columnEntity.getPath()); - map.put("companyId", companyId); + Map<String, Object> map = buildColumnData(columnEntity); + + executor.execute(() -> { + cmsCoreService.columnProcess(map, columnEntity.getListTemplate()); + releaseIndex(companyId); + }); if (type != 1) { executor.execute(() -> { if (columnEntity.getParentId() == 0L) { - List<ColumnEntity> columns = columnMapper.selectColumnByParentId(columnEntity.getParentId(), companyId, 2); + List<ColumnEntity> columns = columnMapper.selectColumnByParentId(columnEntity.getId(), companyId, 2); if (CollUtil.isNotEmpty(columns)) { for (ColumnEntity column : columns) { - map.put("id", column.getId()); - cmsCoreService.columnProcess(map, column.getListTemplate()); + Map<String, Object> data = buildColumnData(column); + cmsCoreService.columnProcess(data, column.getListTemplate()); List<Long> ids = articleMapper.selectArticleIdsByColumnId(column.getId(), companyId,type); - cmsCoreService.articlesProcess(map, ids, column.getArticleTemplate(), column.getPath()); + cmsCoreService.articlesProcess(data, ids, column.getArticleTemplate(), column.getPath()); } } } @@ -94,14 +90,25 @@ releaseIndex(companyId); }); - - executor.execute(() -> { - cmsCoreService.columnProcess(map, columnEntity.getListTemplate()); - releaseIndex(companyId); - }); } } + private Map<String, Object> buildColumnData(ColumnEntity columnEntity) { + Map<String, Object> map = new Hashtable<>(); + map.put("id", columnEntity.getId()); + map.put("code", columnEntity.getColumnCode()); + if (columnEntity.getParentId() == 0L) { + map.put("parentCode", columnEntity.getColumnCode()); + } else { + ColumnEntity parent = columnMapper.selectById(columnEntity.getParentId()); + map.put("parentCode", parent.getColumnCode()); + } + map.put("columnTitle", columnEntity.getColumnName()); + map.put("templatePath", columnEntity.getPath()); + map.put("companyId", columnEntity.getCompanyId()); + return map; + } + @Override public void releaseIndex(Long companyId) { Map<String, Object> map = new HashMap<>(); -- Gitblit v1.9.1