5.2.6 修复单篇生成问题

master
msgroup 4 years ago committed by mingsoft
parent 500dc51bd1
commit ecd245b793
  1. 39
      src/main/java/net/mingsoft/cms/action/GeneraterAction.java

@ -119,7 +119,7 @@ public class GeneraterAction extends BaseAction {
* @param request * @param request
* @param response * @param response
*/ */
@RequestMapping(value="/generateIndex",method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/generateIndex", method = {RequestMethod.GET, RequestMethod.POST})
@RequiresPermissions("cms:generate:index") @RequiresPermissions("cms:generate:index")
@LogAnn(title = "生成主页", businessType = BusinessTypeEnum.UPDATE) @LogAnn(title = "生成主页", businessType = BusinessTypeEnum.UPDATE)
@ResponseBody @ResponseBody
@ -134,7 +134,7 @@ public class GeneraterAction extends BaseAction {
return ResultData.build().error(getResString("templet.file")); return ResultData.build().error(getResString("templet.file"));
} else { } else {
CmsParserUtil.generate(tmpFileName, generateFileName,htmlDir); CmsParserUtil.generate(tmpFileName, generateFileName, htmlDir);
return ResultData.build().success(); return ResultData.build().success();
} }
} }
@ -147,7 +147,7 @@ public class GeneraterAction extends BaseAction {
* @param response * @param response
* @param categoryId * @param categoryId
*/ */
@RequestMapping(value="/{categoryId}/genernateColumn",method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/{categoryId}/genernateColumn", method = {RequestMethod.GET, RequestMethod.POST})
@LogAnn(title = "生成栏目", businessType = BusinessTypeEnum.UPDATE) @LogAnn(title = "生成栏目", businessType = BusinessTypeEnum.UPDATE)
@RequiresPermissions("cms:generate:column") @RequiresPermissions("cms:generate:column")
@ResponseBody @ResponseBody
@ -173,7 +173,7 @@ public class GeneraterAction extends BaseAction {
// 获取栏目列表模版 // 获取栏目列表模版
for (CategoryEntity column : columns) { for (CategoryEntity column : columns) {
//如果是链接就跳过生成 //如果是链接就跳过生成
if(column.getCategoryType().equals(CategoryTypeEnum.LINK.toString())) { if (column.getCategoryType().equals(CategoryTypeEnum.LINK.toString())) {
continue; continue;
} }
ContentBean contentBean = new ContentBean(); ContentBean contentBean = new ContentBean();
@ -187,17 +187,17 @@ public class GeneraterAction extends BaseAction {
// 判断模板文件是否存在 // 判断模板文件是否存在
if (StringUtils.isEmpty(column.getCategoryListUrl()) || !FileUtil.exist(ParserUtil.buildTemplatePath(column.getCategoryListUrl()))) { if (StringUtils.isEmpty(column.getCategoryListUrl()) || !FileUtil.exist(ParserUtil.buildTemplatePath(column.getCategoryListUrl()))) {
LOG.error("{} 模板不存在:{}", column.getCategoryTitle(),column.getCategoryUrl()); LOG.error("{} 模板不存在:{}", column.getCategoryTitle(), column.getCategoryUrl());
continue; continue;
} }
CmsParserUtil.generateList(column, articleIdList.size(),htmlDir); CmsParserUtil.generateList(column, articleIdList.size(), htmlDir);
break; break;
case COVER:// 单页 case COVER:// 单页
// 判断模板文件是否存在 // 判断模板文件是否存在
if (StringUtils.isEmpty(column.getCategoryUrl()) || !FileUtil.exist(ParserUtil.buildTemplatePath(column.getCategoryUrl()))) { if (StringUtils.isEmpty(column.getCategoryUrl()) || !FileUtil.exist(ParserUtil.buildTemplatePath(column.getCategoryUrl()))) {
LOG.error("{} 模板不存在:{}", column.getCategoryTitle(),column.getCategoryUrl()); LOG.error("{} 模板不存在:{}", column.getCategoryTitle(), column.getCategoryUrl());
continue; continue;
} }
@ -208,7 +208,7 @@ public class GeneraterAction extends BaseAction {
BeanUtil.copyProperties(column, columnArticleIdBean, copyOptions); BeanUtil.copyProperties(column, columnArticleIdBean, copyOptions);
articleIdList.add(columnArticleIdBean); articleIdList.add(columnArticleIdBean);
} }
CmsParserUtil.generateBasic(articleIdList,htmlDir); CmsParserUtil.generateBasic(articleIdList, htmlDir);
break; break;
} }
} }
@ -223,7 +223,7 @@ public class GeneraterAction extends BaseAction {
* @param response * @param response
* @param columnId * @param columnId
*/ */
@RequestMapping(value="/{columnId}/generateArticle",method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/{columnId}/generateArticle", method = {RequestMethod.GET, RequestMethod.POST})
@RequiresPermissions("cms:generate:article") @RequiresPermissions("cms:generate:article")
@LogAnn(title = "生成文章", businessType = BusinessTypeEnum.UPDATE) @LogAnn(title = "生成文章", businessType = BusinessTypeEnum.UPDATE)
@ResponseBody @ResponseBody
@ -245,7 +245,7 @@ public class GeneraterAction extends BaseAction {
for (CategoryEntity category : categoryList) { for (CategoryEntity category : categoryList) {
//如果是链接就跳过生成 //如果是链接就跳过生成
if(category.getCategoryType().equals(CategoryTypeEnum.LINK.toString())) { if (category.getCategoryType().equals(CategoryTypeEnum.LINK.toString())) {
continue; continue;
} }
contentBean.setCategoryId(category.getId()); contentBean.setCategoryId(category.getId());
@ -256,24 +256,15 @@ public class GeneraterAction extends BaseAction {
if (category.getCategoryType().equals(CategoryTypeEnum.LIST.toString())) { if (category.getCategoryType().equals(CategoryTypeEnum.LIST.toString())) {
// 判断模板文件是否存在 // 判断模板文件是否存在
if (!FileUtil.exist(ParserUtil.buildTemplatePath(category.getCategoryListUrl())) || StringUtils.isEmpty(category.getCategoryListUrl())) { if (!FileUtil.exist(ParserUtil.buildTemplatePath(category.getCategoryListUrl())) || StringUtils.isEmpty(category.getCategoryListUrl())) {
LOG.error("{} 模板不存在:{}", category.getCategoryTitle(),category.getCategoryListUrl()); LOG.error("{} 模板不存在:{}", category.getCategoryTitle(), category.getCategoryListUrl());
continue; continue;
} }
} else if (category.getCategoryType().equals(CategoryTypeEnum.COVER.toString())) { } else if (category.getCategoryType().equals(CategoryTypeEnum.COVER.toString())) {
// 判断模板文件是否存在 continue;
if (!FileUtil.exist(ParserUtil.buildTemplatePath(category.getCategoryListUrl())) || StringUtils.isEmpty(category.getCategoryListUrl())) {
LOG.error("{} 模板不存在:{}", category.getCategoryTitle(),category.getCategoryListUrl());
continue;
}
CategoryBean columnArticleIdBean = new CategoryBean();
CopyOptions copyOptions = CopyOptions.create();
copyOptions.setIgnoreError(true);
BeanUtil.copyProperties(category, columnArticleIdBean, copyOptions);
articleIdList.add(columnArticleIdBean);
} }
// 有符合条件的就更新 // 有符合条件的就更新
if (articleIdList.size() > 0) { if (articleIdList.size() > 0) {
CmsParserUtil.generateBasic(articleIdList,htmlDir); CmsParserUtil.generateBasic(articleIdList, htmlDir);
} }
} }
@ -288,11 +279,11 @@ public class GeneraterAction extends BaseAction {
* @param request * @param request
* @return * @return
*/ */
@RequestMapping(value="/{position}/viewIndex",method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/{position}/viewIndex", method = {RequestMethod.GET, RequestMethod.POST})
public String viewIndex(HttpServletRequest request, @PathVariable String position, HttpServletResponse response) { public String viewIndex(HttpServletRequest request, @PathVariable String position, HttpServletResponse response) {
AppEntity app = BasicUtil.getApp(); AppEntity app = BasicUtil.getApp();
// 组织主页预览地址 // 组织主页预览地址
String indexPosition = app.getAppHostUrl() + htmlDir+ File.separator + app.getAppDir() String indexPosition = app.getAppHostUrl() + htmlDir + File.separator + app.getAppDir()
+ File.separator + position + ParserUtil.HTML_SUFFIX; + File.separator + position + ParserUtil.HTML_SUFFIX;
return "redirect:" + indexPosition; return "redirect:" + indexPosition;
} }

Loading…
Cancel
Save