解决文章与栏目生成时候,封面页面冲突问题

This commit is contained in:
guwd 2020-12-01 16:05:44 +08:00
parent 1f64d605b2
commit 5a74a045ea
2 changed files with 31 additions and 38 deletions

View File

@ -24,6 +24,8 @@ package net.mingsoft.cms.action;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import net.mingsoft.base.entity.ResultData;
import net.mingsoft.basic.annotation.LogAnn;
import net.mingsoft.basic.biz.IModelBiz;
@ -61,12 +63,10 @@ import java.util.List;
import java.util.Map;
/**
*
* @ClassName: GeneraterAction
* @Description:TODO 生成器
* @author: 铭飞开发团队
* @date: 2018年1月31日 下午2:52:07
*
* @Copyright: 2018 www.mingsoft.net Inc. All rights reserved.
*/
@Controller("cmsGenerater")
@ -101,10 +101,7 @@ public class GeneraterAction extends BaseAction {
private String managerPath;
/**
/**
* /**
* 更新主页
*
* @return
@ -221,7 +218,7 @@ public class GeneraterAction extends BaseAction {
String dateTime = request.getParameter("dateTime");
// 网站风格物理路径
List<CategoryBean> articleIdList = null;
List<CategoryEntity> categoryList = null;
List<CategoryEntity> categoryList = new ArrayList<CategoryEntity>();
ContentBean contentBean = new ContentBean();
contentBean.setBeginTime(dateTime);
Map<String, Object> map = new HashMap<>();
@ -234,10 +231,17 @@ public class GeneraterAction extends BaseAction {
map.put(ParserUtil.PAGE, page);
// 生成所有栏目的文章
if ("0".equals(columnId)) {
CategoryEntity categoryEntity = new CategoryEntity();
categoryList = categoryBiz.query(categoryEntity);
categoryList = categoryBiz.list(Wrappers.<CategoryEntity>lambdaQuery()
.isNull(CategoryEntity::getCategoryParentId));
} else {
CategoryEntity category = (CategoryEntity) categoryBiz.getById(columnId);
categoryList.add(category);
}
for (CategoryEntity category : categoryList) {
contentBean.setCategoryId(category.getId());
//将文章列表标签中的中的参数
articleIdList = contentBiz.queryIdsByCategoryIdForParser(contentBean);
// 分类是列表
if (category.getCategoryType().equals("1")) {
// 判断模板文件是否存在
@ -245,33 +249,20 @@ public class GeneraterAction extends BaseAction {
LOG.error("模板不存在:{}", category.getCategoryUrl());
continue;
}
} else if (category.getCategoryType().equals("2")) {
CategoryBean columnArticleIdBean = new CategoryBean();
CopyOptions copyOptions = CopyOptions.create();
copyOptions.setIgnoreError(true);
BeanUtil.copyProperties(category, columnArticleIdBean, copyOptions);
articleIdList.add(columnArticleIdBean);
}
// 有符合条件的就更新
if (articleIdList.size() > 0) {
CmsParserUtil.generateBasic(articleIdList);
}
}
}
//将文章列表标签中的中的参数
articleIdList = contentBiz.queryIdsByCategoryIdForParser(contentBean);
// 有符合条件的就更新
if (articleIdList.size() > 0) {
CmsParserUtil.generateBasic(articleIdList);
}
}
} else {
CategoryEntity category = (CategoryEntity) categoryBiz.getById(columnId);
contentBean.setCategoryId(columnId);
// 分类是列表
if (category.getCategoryType().equals("1")) {
// 获取文章列表表属性
// 判断模板文件是否存在
if (!FileUtil.exist(ParserUtil.buildTempletPath(category.getCategoryUrl()))) {
LOG.error("模板不存在:{}", category.getCategoryUrl());
return ResultData.build().error(getResString("templet.file"));
}
}
articleIdList = contentBiz.queryIdsByCategoryIdForParser(contentBean);
// 有符合条件的就更新
if (articleIdList.size() > 0) {
CmsParserUtil.generateBasic(articleIdList);
}
}
return ResultData.build().success();
}

View File

@ -192,6 +192,7 @@ public class CmsParserUtil extends ParserUtil {
if(articleIdList.get(artId).getMdiyModelId() != null && articleIdList.get(artId).getMdiyModelId() > 0){
columnContentModelId = articleIdList.get(artId).getMdiyModelId();
}
// 文章是否已经生成了生成了就跳过
if (generateIds.contains(articleId)) {
artId++;
@ -208,10 +209,11 @@ public class CmsParserUtil extends ParserUtil {
//如果是封面就生成index.html
if(Integer.parseInt(articleIdList.get(artId).getCategoryType()) == COLUMN_TYPE_COVER) {
writePath = ParserUtil.buildHtmlPath(articleColumnPath + File.separator + ParserUtil.INDEX);
}else {
} else {
// 组合文章路径如:html/站点id/栏目id/文章id.html
writePath = ParserUtil.buildHtmlPath(articleColumnPath + File.separator + articleId);
}
Map<String, Object> parserParams = new HashMap<String, Object>();
parserParams.put(ParserUtil.COLUMN, articleIdList.get(artId));
// 判断当前栏目是否有自定义模型