From 85c0fd73a5286de23ef5e579f4dfadfa63217d8b Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Tue, 12 Jul 2022 15:47:55 +0800
Subject: [PATCH] fix
---
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ReleaseServiceImpl.java | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 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 2c01d97..7b69fe1 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
@@ -1,9 +1,13 @@
package com.xcong.farmer.cms.modules.system.service.Impl;
import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.io.FileUtil;
+import com.xcong.farmer.cms.common.utils.FileUtils;
+import com.xcong.farmer.cms.configurations.properties.CmsProperties;
import com.xcong.farmer.cms.modules.core.service.ICmsCoreService;
import com.xcong.farmer.cms.modules.system.entity.ArticleEntity;
import com.xcong.farmer.cms.modules.system.entity.ColumnEntity;
+import com.xcong.farmer.cms.modules.system.entity.CompanyEntity;
import com.xcong.farmer.cms.modules.system.entity.WebSettingEntity;
import com.xcong.farmer.cms.modules.system.mapper.ArticleMapper;
import com.xcong.farmer.cms.modules.system.mapper.ColumnMapper;
@@ -41,6 +45,12 @@
@Autowired
private ICmsCoreService cmsCoreService;
+
+ @Autowired
+ private CmsProperties cmsProperties;
+
+ @Autowired
+ private CompanyMapper companyMapper;
@Autowired
private WebSetMapper webSetMapper;
@@ -85,6 +95,28 @@
ColumnEntity columnEntity = columnMapper.selectById(id);
Map<String, Object> map = buildColumnData(columnEntity);
+ if (columnEntity.getBeforeParentId() != -1 || !"-1".equals(columnEntity.getBeforeColumnCode())) {
+ CompanyEntity company = companyMapper.selectById(companyId);
+ if (!"-1".equals(columnEntity.getBeforeColumnCode())) {
+ String outputPath = FileUtils.path(cmsProperties.getOutputPath(), company.getCode()) + "/" + columnEntity.getBeforeColumnCode();
+ log.info("删除路径为:{}", outputPath);
+ FileUtil.del(outputPath);
+ }
+
+ if (columnEntity.getBeforeParentId() != -1) {
+ ColumnEntity parent = columnMapper.selectById(columnEntity.getBeforeParentId());
+ String path = cmsProperties.getOutputPath() + parent.getPath() + "/" + columnEntity.getColumnCode();
+ log.info("删除路径为:{}", path);
+ FileUtil.del(path);
+ }
+
+ columnEntity.setBeforeColumnCode("-1");
+ columnEntity.setBeforeParentId(-1L);
+ columnMapper.updateById(columnEntity);
+ releaseAll(companyId);
+ return;
+ }
+
executor.execute(() -> {
List<ArticleEntity> articles = articleMapper.selectArticleByColumnId(columnEntity.getId(), companyId, type);
if (CollUtil.isNotEmpty(articles)) {
@@ -102,6 +134,7 @@
}
map.put("id", columnEntity.getId());
+
cmsCoreService.columnProcess(map, columnEntity.getListTemplate());
if (columnEntity.getParentId() != 0L) {
ColumnEntity parentColumn = columnMapper.selectById(columnEntity.getParentId());
@@ -134,6 +167,10 @@
}
}
+
+ column.setBeforeColumnCode("-1");
+ column.setParentId(-1L);
+ columnMapper.updateById(column);
Map<String, Object> data = buildColumnData(column);
cmsCoreService.columnProcess(data, column.getListTemplate());
}
--
Gitblit v1.9.1