| | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.io.FileUtil; |
| | | import com.xcong.farmer.cms.common.contants.AppContants; |
| | | 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; |
| | |
| | | @Override |
| | | public void releaseColumn(Long id, int type, Long companyId) { |
| | | 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); |
| | | } |
| | | AppContants.EXECUTOR.execute(() -> { |
| | | Map<String, Object> map = buildColumnData(columnEntity); |
| | | |
| | | if (columnEntity.getBeforeParentId() != -1) { |
| | | ColumnEntity parent = columnMapper.selectById(columnEntity.getBeforeParentId()); |
| | | String path = FileUtils.path(cmsProperties.getOutputPath(), company.getCode()) + parent.getPath() + "/" + columnEntity.getColumnCode(); |
| | | log.info("删除路径为:{}", path); |
| | | FileUtil.del(path); |
| | | } |
| | | |
| | | columnEntity.setBeforeColumnCode("-1"); |
| | | columnEntity.setBeforeParentId(-1L); |
| | | columnMapper.updateById(columnEntity); |
| | | releaseAll(companyId); |
| | | return; |
| | | } |
| | | |
| | | List<ArticleEntity> articles = articleMapper.selectArticleByColumnId(columnEntity.getId(), companyId, type); |
| | | if (CollUtil.isNotEmpty(articles)) { |
| | | for (ArticleEntity article : articles) { |
| | | if (article.getReleaseStatus() == 0) { |
| | | article.setReleaseStatus(1); |
| | | articleMapper.updateById(article); |
| | | // 判断栏目是否编辑了栏目编码或者修改了父级栏目 |
| | | 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 (article.getType() == 1) { |
| | | Map<String, Object> articleMap = new HashMap<>(); |
| | | BeanUtil.copyProperties(map, articleMap); |
| | | articleMap.put("id", article.getId()); |
| | | cmsCoreService.articleProcess(articleMap, columnEntity.getArticleTemplate(), columnEntity.getPath()); |
| | | if (columnEntity.getBeforeParentId() != -1) { |
| | | ColumnEntity parent = columnMapper.selectById(columnEntity.getBeforeParentId()); |
| | | String path = FileUtils.path(cmsProperties.getOutputPath(), company.getCode()) + parent.getPath() + "/" + columnEntity.getColumnCode(); |
| | | log.info("删除路径为:{}", path); |
| | | FileUtil.del(path); |
| | | } |
| | | |
| | | columnEntity.setBeforeColumnCode("-1"); |
| | | columnEntity.setBeforeParentId(-1L); |
| | | columnMapper.updateById(columnEntity); |
| | | releaseAll(companyId); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | map.put("id", columnEntity.getId()); |
| | | List<ArticleEntity> articles = articleMapper.selectArticleByColumnId(columnEntity.getId(), companyId, type); |
| | | if (CollUtil.isNotEmpty(articles)) { |
| | | for (ArticleEntity article : articles) { |
| | | if (article.getReleaseStatus() == 0) { |
| | | article.setReleaseStatus(1); |
| | | articleMapper.updateById(article); |
| | | } |
| | | |
| | | cmsCoreService.columnProcess(map, columnEntity.getListTemplate()); |
| | | if (columnEntity.getParentId() != 0L) { |
| | | ColumnEntity parentColumn = columnMapper.selectById(columnEntity.getParentId()); |
| | | Map<String, Object> parentMap = buildColumnData(parentColumn); |
| | | parentMap.put("id", parentColumn.getId()); |
| | | cmsCoreService.columnProcess(parentMap, parentColumn.getListTemplate()); |
| | | } |
| | | |
| | | releaseIndex(companyId, false); |
| | | |
| | | if (type != 1) { |
| | | if (columnEntity.getParentId() == 0L) { |
| | | List<ColumnEntity> columns = columnMapper.selectColumnByParentId(columnEntity.getId(), companyId, 2); |
| | | if (CollUtil.isNotEmpty(columns)) { |
| | | for (ColumnEntity column : columns) { |
| | | List<ArticleEntity> articleList = articleMapper.selectArticleByColumnId(column.getId(), companyId, type); |
| | | if (CollUtil.isNotEmpty(articleList)) { |
| | | for (ArticleEntity article : articleList) { |
| | | if (article.getReleaseStatus() == 0) { |
| | | article.setReleaseStatus(1); |
| | | articleMapper.updateById(article); |
| | | } |
| | | |
| | | if (article.getType() == 1) { |
| | | Map<String, Object> articleMap = new HashMap<>(); |
| | | BeanUtil.copyProperties(map, articleMap); |
| | | articleMap.put("id", article.getId()); |
| | | cmsCoreService.articleProcess(articleMap, column.getArticleTemplate(), column.getPath()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Map<String, Object> data = buildColumnData(column); |
| | | cmsCoreService.columnProcess(data, column.getListTemplate()); |
| | | if (article.getType() == 1) { |
| | | Map<String, Object> articleMap = new HashMap<>(); |
| | | BeanUtil.copyProperties(map, articleMap); |
| | | articleMap.put("id", article.getId()); |
| | | cmsCoreService.articleProcess(articleMap, columnEntity.getArticleTemplate(), columnEntity.getPath()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | map.put("id", columnEntity.getId()); |
| | | |
| | | cmsCoreService.columnProcess(map, columnEntity.getListTemplate()); |
| | | if (columnEntity.getParentId() != 0L) { |
| | | ColumnEntity parentColumn = columnMapper.selectById(columnEntity.getParentId()); |
| | | Map<String, Object> parentMap = buildColumnData(parentColumn); |
| | | parentMap.put("id", parentColumn.getId()); |
| | | cmsCoreService.columnProcess(parentMap, parentColumn.getListTemplate()); |
| | | } |
| | | |
| | | releaseIndex(companyId, false); |
| | | } |
| | | |
| | | if (type != 1) { |
| | | if (columnEntity.getParentId() == 0L) { |
| | | List<ColumnEntity> columns = columnMapper.selectColumnByParentId(columnEntity.getId(), companyId, 2); |
| | | if (CollUtil.isNotEmpty(columns)) { |
| | | for (ColumnEntity column : columns) { |
| | | List<ArticleEntity> articleList = articleMapper.selectArticleByColumnId(column.getId(), companyId, type); |
| | | if (CollUtil.isNotEmpty(articleList)) { |
| | | for (ArticleEntity article : articleList) { |
| | | if (article.getReleaseStatus() == 0) { |
| | | article.setReleaseStatus(1); |
| | | articleMapper.updateById(article); |
| | | } |
| | | |
| | | if (article.getType() == 1) { |
| | | Map<String, Object> articleMap = new HashMap<>(); |
| | | BeanUtil.copyProperties(map, articleMap); |
| | | articleMap.put("id", article.getId()); |
| | | cmsCoreService.articleProcess(articleMap, column.getArticleTemplate(), column.getPath()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Map<String, Object> data = buildColumnData(column); |
| | | cmsCoreService.columnProcess(data, column.getListTemplate()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | releaseIndex(companyId, false); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return; |
| | | } |
| | | |
| | | for (ColumnEntity column : columns) { |
| | | releaseColumn(column.getId(), type, companyId); |
| | | } |
| | | AppContants.EXECUTOR.execute(() -> { |
| | | for (ColumnEntity column : columns) { |
| | | releaseColumn(column.getId(), type, companyId); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private Map<String, Object> buildColumnData(ColumnEntity columnEntity) { |