Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a7cfdb2f10
1228
doc/mcms-5.2.sql
1228
doc/mcms-5.2.sql
File diff suppressed because one or more lines are too long
|
@ -135,6 +135,7 @@ public class GeneraterAction extends BaseAction {
|
|||
if (!FileUtil.exist(ParserUtil.buildTempletPath())) {
|
||||
return ResultData.build().error(getResString("templet.file"));
|
||||
} else {
|
||||
|
||||
CmsParserUtil.generate(tmpFileName, generateFileName,htmlDir);
|
||||
return ResultData.build().success();
|
||||
}
|
||||
|
@ -225,14 +226,7 @@ public class GeneraterAction extends BaseAction {
|
|||
List<CategoryEntity> categoryList = new ArrayList<CategoryEntity>();
|
||||
ContentBean contentBean = new ContentBean();
|
||||
contentBean.setBeginTime(dateTime);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (BasicUtil.getWebsiteApp() != null) {
|
||||
map.put(ParserUtil.APP_DIR, BasicUtil.getWebsiteApp().getAppDir());
|
||||
}
|
||||
PageBean page = new PageBean();
|
||||
map.put(ParserUtil.HTML, htmlDir);
|
||||
map.put(ParserUtil.URL, BasicUtil.getUrl());
|
||||
map.put(ParserUtil.PAGE, page);
|
||||
|
||||
// 生成所有栏目的文章
|
||||
if ("0".equals(columnId)) {
|
||||
categoryList = categoryBiz.list(Wrappers.<CategoryEntity>lambdaQuery()
|
||||
|
|
|
@ -128,11 +128,12 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
|
|||
map.put(ParserUtil.IS_DO, true);
|
||||
//设置动态请求的模块路径
|
||||
map.put(ParserUtil.MODEL_NAME, "mcms");
|
||||
map.put(ParserUtil.HTML,htmlDir);
|
||||
//解析后的内容
|
||||
String content = "";
|
||||
try {
|
||||
//根据模板路径,参数生成
|
||||
content = CmsParserUtil.generate(ParserUtil.INDEX + ParserUtil.HTM_SUFFIX, map, htmlDir);
|
||||
content = ParserUtil.rendering(ParserUtil.INDEX + ParserUtil.HTM_SUFFIX, map);
|
||||
} catch (TemplateNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (MalformedTemplateNameException e) {
|
||||
|
@ -186,11 +187,12 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
|
|||
map.put(ParserUtil.IS_DO, true);
|
||||
//设置动态请求的模块路径
|
||||
map.put(ParserUtil.MODEL_NAME, "mcms");
|
||||
map.put(ParserUtil.HTML, htmlDir);
|
||||
//解析后的内容
|
||||
String content = "";
|
||||
try {
|
||||
//根据模板路径,参数生成
|
||||
content = CmsParserUtil.generate(columnArticles.get(0).getCategoryListUrl(), map, htmlDir);
|
||||
content = ParserUtil.rendering(columnArticles.get(0).getCategoryListUrl(), map);
|
||||
} catch (TemplateNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (MalformedTemplateNameException e) {
|
||||
|
@ -243,6 +245,8 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
|
|||
map.put(ParserUtil.URL, BasicUtil.getUrl());
|
||||
map.put(ParserUtil.PAGE, page);
|
||||
map.put(ParserUtil.ID, article.getId());
|
||||
map.put(ParserUtil.HTML,htmlDir);
|
||||
|
||||
ContentBean contentBean = new ContentBean();
|
||||
contentBean.setCategoryId(String.valueOf(typeId));
|
||||
contentBean.setOrderBy(orderby);
|
||||
|
@ -292,7 +296,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
|
|||
}
|
||||
try {
|
||||
//根据模板路径,参数生成
|
||||
content = CmsParserUtil.generate(column.getCategoryUrl(), map, htmlDir);
|
||||
content = ParserUtil.rendering(column.getCategoryUrl(), map);
|
||||
} catch (TemplateNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (MalformedTemplateNameException e) {
|
||||
|
@ -340,12 +344,12 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
|
|||
|
||||
|
||||
//获取栏目信息
|
||||
int typeId = 0;
|
||||
String typeId = null;
|
||||
String categoryIds = BasicUtil.getString("categoryIds");
|
||||
List categoryIdList = CollectionUtil.newArrayList();
|
||||
//当传递了栏目编号,但不是栏目集合
|
||||
if (StringUtils.isNotBlank(categoryIds) && !categoryIds.contains(",")) {
|
||||
typeId = Integer.parseInt(categoryIds);
|
||||
typeId = categoryIds;
|
||||
} else {
|
||||
//取出所有的子栏目
|
||||
String[] ids = categoryIds.split(",");
|
||||
|
@ -366,12 +370,11 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
|
|||
|
||||
//重新组织 ID
|
||||
categoryIds = StringUtils.join(categoryIdList, ",");
|
||||
//当前访问的项目地址
|
||||
String url = BasicUtil.getUrl();
|
||||
|
||||
|
||||
//根据栏目确定自定义模型
|
||||
if (typeId > 0) {
|
||||
column = (CategoryEntity) categoryBiz.getEntity(typeId);
|
||||
if (typeId != null) {
|
||||
column = (CategoryEntity) categoryBiz.getById(typeId);
|
||||
// 获取表单类型的id
|
||||
if (column != null && ObjectUtil.isNotNull(column.getMdiyModelId())) {
|
||||
contentModel = (ModelEntity) modelBiz.getEntity(column.getMdiyModelId());
|
||||
|
@ -454,11 +457,18 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
|
|||
//查询数量
|
||||
int count = contentBiz.getSearchCount(contentModel, fieldValueList, searchMap, BasicUtil.getApp().getAppId(), categoryIds);
|
||||
page.setRcount(count);
|
||||
params.put(ParserUtil.URL, url);
|
||||
params.put(SEARCH, searchMap);
|
||||
|
||||
//站点编号
|
||||
if (BasicUtil.getWebsiteApp() != null) {
|
||||
params.put(ParserUtil.APP_DIR, BasicUtil.getWebsiteApp().getAppDir());
|
||||
params.put(ParserUtil.URL, BasicUtil.getWebsiteApp().getAppHostUrl());
|
||||
params.put(ParserUtil.APP_ID, BasicUtil.getWebsiteApp().getAppId());
|
||||
} else {
|
||||
params.put(ParserUtil.URL, BasicUtil.getUrl());
|
||||
params.put(ParserUtil.APP_DIR, BasicUtil.getApp().getAppDir());
|
||||
}
|
||||
|
||||
params.put(ParserUtil.PAGE, page);
|
||||
params.put(ParserUtil.HTML, htmlDir);
|
||||
//动态解析
|
||||
|
@ -481,6 +491,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
|
|||
page.setPageNo(pageNo);
|
||||
|
||||
//设置分页的统一链接
|
||||
String url = params.get(ParserUtil.URL).toString();
|
||||
url = url + request.getServletPath() + "?" + urlParams;
|
||||
String pageNoStr = "size=" + page.getSize() + "&pageNo=";
|
||||
//下一页
|
||||
|
@ -497,7 +508,6 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
|
|||
page.setPreUrl(preUrl);
|
||||
page.setLastUrl(lastUrl);
|
||||
|
||||
params.put(ParserUtil.URL, url);
|
||||
params.put(SEARCH, searchMap);
|
||||
if (BasicUtil.getWebsiteApp() != null) {
|
||||
params.put(ParserUtil.APP_DIR, BasicUtil.getWebsiteApp().getAppDir());
|
||||
|
@ -513,7 +523,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
|
|||
String content = "";
|
||||
try {
|
||||
//根据模板路径,参数生成
|
||||
content = CmsParserUtil.generate(SEARCH + ParserUtil.HTM_SUFFIX, params, htmlDir);
|
||||
content = ParserUtil.rendering(SEARCH + ParserUtil.HTM_SUFFIX, params);
|
||||
} catch (TemplateNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (MalformedTemplateNameException e) {
|
||||
|
|
|
@ -98,144 +98,5 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
|
|||
return contentDao.getSearchCount(null,null,whereMap, appId,categoryIds);
|
||||
}
|
||||
|
||||
/*
|
||||
* 任务调度静态化任务
|
||||
*/
|
||||
public void staticizeTask(Integer appId, String tmpFileName, String generateFileName) {
|
||||
LOG.info("定时静态化任务", new Date());
|
||||
try {
|
||||
//将任务采集传过来的appId导入到线程变量中
|
||||
//当前线程使用appId时优先使用此数据
|
||||
DataHolder.set(ParserUtil.APP_ID, appId);
|
||||
//调用三种静态化
|
||||
genernateColumn();
|
||||
generaterIndex(tmpFileName, generateFileName);
|
||||
//生成文章日期默认为执行日期的上一天
|
||||
generateArticle(DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd"));
|
||||
LOG.info("静态化完成", new Date());
|
||||
} catch (IOException e) {
|
||||
LOG.info("静态化失败", new Date());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 生成文章逻辑
|
||||
*/
|
||||
private void generateArticle(String dateTime) throws IOException {
|
||||
// 网站风格物理路径
|
||||
List<CategoryBean> articleIdList = null;
|
||||
List<CategoryEntity> categoryList = null;
|
||||
ContentBean contentBean = new ContentBean();
|
||||
contentBean.setBeginTime(dateTime);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if(BasicUtil.getWebsiteApp() != null){
|
||||
map.put(ParserUtil.APP_DIR, BasicUtil.getWebsiteApp().getAppDir());
|
||||
}
|
||||
PageBean page = new PageBean();
|
||||
map.put(ParserUtil.HTML, htmlDir);
|
||||
map.put(ParserUtil.URL, BasicUtil.getUrl());
|
||||
map.put(ParserUtil.PAGE, page);
|
||||
|
||||
CategoryEntity categoryEntity = new CategoryEntity();
|
||||
categoryList = categoryDao.query(categoryEntity);
|
||||
for(CategoryEntity category : categoryList){
|
||||
contentBean.setCategoryId(category.getId());
|
||||
// 分类是列表
|
||||
if(category.getCategoryType().equals(CategoryTypeEnum.LIST.toString())){
|
||||
// 判断模板文件是否存在
|
||||
if (!FileUtil.exist(ParserUtil.buildTempletPath(category.getCategoryListUrl())) || StringUtils.isEmpty(category.getCategoryListUrl())) {
|
||||
LOG.error("模板不存在:{}",category.getCategoryUrl());
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
articleIdList = queryIdsByCategoryIdForParser(contentBean);
|
||||
// 有符合条件的就更新
|
||||
if (articleIdList.size() > 0) {
|
||||
CmsParserUtil.generateBasic(articleIdList,htmlDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 生成栏目逻辑
|
||||
*/
|
||||
private void genernateColumn() throws IOException {
|
||||
List<CategoryEntity> columns = new ArrayList<>();
|
||||
// 获取所有的内容管理栏目
|
||||
CategoryEntity categoryEntity=new CategoryEntity();
|
||||
columns = categoryDao.query(categoryEntity);
|
||||
List<CategoryBean> articleIdList = null;
|
||||
// 1、设置模板文件夹路径
|
||||
// 获取栏目列表模版
|
||||
for (CategoryEntity column : columns) {
|
||||
ContentBean contentBean = new ContentBean();
|
||||
contentBean.setCategoryId(column.getId());
|
||||
// 分类是列表
|
||||
if(column.getCategoryType().equals(CategoryTypeEnum.LIST.toString())) {
|
||||
// 判断模板文件是否存在
|
||||
if (!FileUtil.exist(ParserUtil.buildTempletPath(column.getCategoryListUrl()))) {
|
||||
LOG.error("模板不存在:{}", column.getCategoryUrl());
|
||||
continue;
|
||||
}
|
||||
//获取模板中列表标签中的条件
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if(BasicUtil.getWebsiteApp() != null){
|
||||
map.put(ParserUtil.APP_DIR, BasicUtil.getWebsiteApp().getAppDir());
|
||||
}
|
||||
PageBean page = new PageBean();
|
||||
map.put(ParserUtil.HTML, htmlDir);
|
||||
map.put(ParserUtil.URL, BasicUtil.getUrl());
|
||||
map.put(ParserUtil.PAGE, page);
|
||||
|
||||
}
|
||||
articleIdList = contentDao.queryIdsByCategoryIdForParser(contentBean);
|
||||
// 判断列表类型
|
||||
switch (CategoryTypeEnum.get(column.getCategoryType())) {
|
||||
//TODO 暂时先用字符串代替
|
||||
case LIST: // 列表
|
||||
CmsParserUtil.generateList(column, articleIdList.size(),htmlDir);
|
||||
break;
|
||||
case COVER:// 单页
|
||||
if(articleIdList.size()==0){
|
||||
CategoryBean columnArticleIdBean=new CategoryBean();
|
||||
CopyOptions copyOptions=CopyOptions.create();
|
||||
copyOptions.setIgnoreError(true);
|
||||
BeanUtil.copyProperties(column,columnArticleIdBean,copyOptions);
|
||||
articleIdList.add(columnArticleIdBean);
|
||||
}
|
||||
CmsParserUtil.generateBasic(articleIdList,htmlDir);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 生成主页逻辑
|
||||
*/
|
||||
private void generaterIndex(String templatePath, String targetPath) throws IOException {
|
||||
if (!FileUtil.exist(ParserUtil.buildTempletPath())) {
|
||||
LOG.info("模板文件不存在");
|
||||
return;
|
||||
}
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put(ParserUtil.IS_DO, false);
|
||||
CategoryEntity column = new CategoryEntity();
|
||||
//内容管理栏目编码
|
||||
map.put(ParserUtil.COLUMN, column);
|
||||
//如果单站点,就废弃站点地址
|
||||
if (ParserUtil.IS_SINGLE) {
|
||||
map.put(ParserUtil.URL, BasicUtil.getUrl());
|
||||
}
|
||||
//设置生成的路径
|
||||
map.put(ParserUtil.HTML, htmlDir);
|
||||
//设置站点编号
|
||||
if(BasicUtil.getWebsiteApp() !=null){
|
||||
map.put(ParserUtil.APP_DIR, BasicUtil.getWebsiteApp().getAppDir());
|
||||
}
|
||||
String read = ParserUtil.rendering(templatePath, map);
|
||||
FileUtil.writeString(read, ParserUtil.buildHtmlPath(targetPath,htmlDir), net.mingsoft.base.constant.Const.UTF8);
|
||||
}
|
||||
|
||||
}
|
|
@ -7,6 +7,7 @@ import freemarker.core.ParseException;
|
|||
import freemarker.template.MalformedTemplateNameException;
|
||||
import freemarker.template.TemplateNotFoundException;
|
||||
import net.mingsoft.base.constant.Const;
|
||||
import net.mingsoft.basic.holder.DataHolder;
|
||||
import net.mingsoft.basic.util.BasicUtil;
|
||||
import net.mingsoft.basic.util.SpringUtil;
|
||||
import net.mingsoft.cms.bean.CategoryBean;
|
||||
|
@ -31,7 +32,7 @@ import java.util.concurrent.ExecutorService;
|
|||
/**
|
||||
* 文章解析工具类
|
||||
*/
|
||||
public class CmsParserUtil extends ParserUtil {
|
||||
public class CmsParserUtil {
|
||||
|
||||
|
||||
private final static String FIELD = "field";
|
||||
|
@ -45,12 +46,24 @@ public class CmsParserUtil extends ParserUtil {
|
|||
*/
|
||||
public static void generate(String templatePath, String targetPath, String htmlDir) throws IOException {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put(IS_DO, false);
|
||||
map.put(ParserUtil.IS_DO, false);
|
||||
CategoryEntity column = new CategoryEntity();
|
||||
//内容管理栏目编码
|
||||
map.put(COLUMN, column);
|
||||
String content = CmsParserUtil.generate(templatePath, map, htmlDir);
|
||||
FileUtil.writeString(content, ParserUtil.buildHtmlPath(targetPath, htmlDir), Const.UTF8);
|
||||
map.put(ParserUtil.COLUMN, column);
|
||||
map.put(ParserUtil.HTML, htmlDir);
|
||||
|
||||
//站点编号
|
||||
if (BasicUtil.getWebsiteApp() != null) {
|
||||
map.put(ParserUtil.APP_DIR, BasicUtil.getWebsiteApp().getAppDir());
|
||||
map.put(ParserUtil.URL, BasicUtil.getWebsiteApp().getAppHostUrl());
|
||||
map.put(ParserUtil.APP_ID, BasicUtil.getWebsiteApp().getAppId());
|
||||
} else {
|
||||
map.put(ParserUtil.URL, BasicUtil.getUrl());
|
||||
map.put(ParserUtil.APP_DIR, BasicUtil.getApp().getAppDir());
|
||||
}
|
||||
|
||||
String content = ParserUtil.rendering(templatePath, map);
|
||||
FileUtil.writeString(content, ParserUtil.buildHtmlPath(targetPath, htmlDir, map.get(ParserUtil.APP_DIR).toString()), Const.UTF8);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,15 +89,26 @@ public class CmsParserUtil extends ParserUtil {
|
|||
int totalPageSize = PageUtil.totalPage(articleIdTotal, page.getSize());
|
||||
page.setTotal(totalPageSize);
|
||||
|
||||
//获取模板中列表标签中的条件
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
//全局参数设置
|
||||
Map<String, Object> parserParams = new HashMap<String, Object>();
|
||||
parserParams.put(ParserUtil.IS_DO, false);
|
||||
parserParams.put(ParserUtil.HTML, htmlDir);
|
||||
parserParams.put(ParserUtil.PAGE, page);
|
||||
|
||||
//站点编号
|
||||
if (BasicUtil.getWebsiteApp() != null) {
|
||||
map.put(ParserUtil.APP_DIR, BasicUtil.getWebsiteApp().getAppDir());
|
||||
parserParams.put(ParserUtil.APP_DIR, BasicUtil.getWebsiteApp().getAppDir());
|
||||
parserParams.put(ParserUtil.URL, BasicUtil.getWebsiteApp().getAppHostUrl());
|
||||
parserParams.put(ParserUtil.APP_ID, BasicUtil.getWebsiteApp().getAppId());
|
||||
} else {
|
||||
parserParams.put(ParserUtil.URL, BasicUtil.getUrl());
|
||||
parserParams.put(ParserUtil.APP_DIR, BasicUtil.getApp().getAppDir());
|
||||
}
|
||||
|
||||
map.put(ParserUtil.HTML, htmlDir);
|
||||
map.put(ParserUtil.URL, BasicUtil.getUrl());
|
||||
map.put(ParserUtil.PAGE, page);
|
||||
parserParams.put(ParserUtil.COLUMN, column);
|
||||
//标签中使用field获取当前栏目
|
||||
parserParams.put(ParserUtil.FIELD, column);
|
||||
|
||||
|
||||
String columnListPath;
|
||||
ModelEntity contentModel = null;
|
||||
|
@ -94,31 +118,16 @@ public class CmsParserUtil extends ParserUtil {
|
|||
contentModel = (ModelEntity) SpringUtil.getBean(ModelBizImpl.class).getEntity(column.getMdiyModelId());
|
||||
}
|
||||
|
||||
//全局参数设置
|
||||
Map<String, Object> parserParams = new HashMap<String, Object>();
|
||||
parserParams.put(ParserUtil.PAGE, page);
|
||||
parserParams.put(COLUMN, column);
|
||||
//标签中使用field获取当前栏目
|
||||
parserParams.put(FIELD, column);
|
||||
parserParams.put(IS_DO, false);
|
||||
parserParams.put(HTML, htmlDir);
|
||||
if (BasicUtil.getWebsiteApp() != null) {
|
||||
parserParams.put(APP_DIR, BasicUtil.getWebsiteApp().getAppDir());
|
||||
}
|
||||
if (contentModel != null) {
|
||||
// 将自定义模型编号设置为key值
|
||||
parserParams.put(TABLE_NAME, contentModel.getModelTableName());
|
||||
}
|
||||
//如果单站点,就废弃站点地址
|
||||
if (ParserUtil.IS_SINGLE) {
|
||||
parserParams.put(ParserUtil.URL, BasicUtil.getUrl());
|
||||
parserParams.put(ParserUtil.TABLE_NAME, contentModel.getModelTableName());
|
||||
}
|
||||
|
||||
int pageNo = 1;
|
||||
//文章列表页没有写文章列表标签,总数为0
|
||||
if (totalPageSize <= 0) {
|
||||
// 数据库中第一页是从开始0*size
|
||||
columnListPath = ParserUtil.buildHtmlPath(column.getCategoryPath() + File.separator + ParserUtil.INDEX, htmlDir);
|
||||
columnListPath = ParserUtil.buildHtmlPath(column.getCategoryPath() + File.separator + ParserUtil.INDEX, htmlDir, parserParams.get(ParserUtil.APP_DIR).toString());
|
||||
// 设置分页的起始位置
|
||||
page.setPageNo(pageNo);
|
||||
String read = ParserUtil.rendering(File.separator + column.getCategoryListUrl(), parserParams);
|
||||
|
@ -131,11 +140,11 @@ public class CmsParserUtil extends ParserUtil {
|
|||
// 数据库中第一页是从开始0*size
|
||||
// 首页路径index.html
|
||||
columnListPath = ParserUtil
|
||||
.buildHtmlPath(column.getCategoryPath() + File.separator + ParserUtil.INDEX, htmlDir);
|
||||
.buildHtmlPath(column.getCategoryPath() + File.separator + ParserUtil.INDEX, htmlDir, parserParams.get(ParserUtil.APP_DIR).toString());
|
||||
} else {
|
||||
// 其他路径list-2.html
|
||||
columnListPath = ParserUtil
|
||||
.buildHtmlPath(column.getCategoryPath() + File.separator + ParserUtil.PAGE_LIST + pageNo, htmlDir);
|
||||
.buildHtmlPath(column.getCategoryPath() + File.separator + ParserUtil.PAGE_LIST + pageNo, htmlDir, parserParams.get(ParserUtil.APP_DIR).toString());
|
||||
}
|
||||
// 设置分页的起始位置
|
||||
page.setPageNo(pageNo);
|
||||
|
@ -161,11 +170,24 @@ public class CmsParserUtil extends ParserUtil {
|
|||
*/
|
||||
public static void generateBasic(List<CategoryBean> articleIdList, String htmlDir) {
|
||||
|
||||
Map<String, Object> parserParams = new HashMap<String, Object>();
|
||||
parserParams.put(ParserUtil.IS_DO, false);
|
||||
if (BasicUtil.getWebsiteApp() != null) {
|
||||
parserParams.put(ParserUtil.APP_DIR, BasicUtil.getWebsiteApp().getAppDir());
|
||||
parserParams.put(ParserUtil.URL, BasicUtil.getWebsiteApp().getAppHostUrl());
|
||||
parserParams.put(ParserUtil.APP_ID, BasicUtil.getWebsiteApp().getAppId());
|
||||
} else {
|
||||
parserParams.put(ParserUtil.URL, BasicUtil.getUrl());
|
||||
parserParams.put(ParserUtil.APP_DIR, BasicUtil.getApp().getAppDir());
|
||||
}
|
||||
|
||||
parserParams.put(ParserUtil.HTML, htmlDir);
|
||||
|
||||
|
||||
Map<Object, Object> contentModelMap = new HashMap<Object, Object>();
|
||||
ModelEntity contentModel = null;
|
||||
// 记录已经生成了文章编号
|
||||
List<String> generateIds = new ArrayList<>();
|
||||
ExecutorService pool = SpringUtil.getBean(ExecutorService.class);
|
||||
// 生成文章
|
||||
for (int artId = 0; artId < articleIdList.size(); ) {
|
||||
|
||||
|
@ -206,30 +228,32 @@ public class CmsParserUtil extends ParserUtil {
|
|||
generateIds.add(articleId);
|
||||
//如果是封面就生成index.html
|
||||
if (categoryBean.getCategoryType().equals(CategoryTypeEnum.COVER.toString())) {
|
||||
writePath = ParserUtil.buildHtmlPath(articleColumnPath + File.separator + ParserUtil.INDEX, htmlDir);
|
||||
writePath = ParserUtil.buildHtmlPath(articleColumnPath + File.separator + ParserUtil.INDEX, htmlDir, parserParams.get(ParserUtil.APP_DIR).toString());
|
||||
} else {
|
||||
// 组合文章路径如:html/站点id/栏目id/文章id.html
|
||||
writePath = ParserUtil.buildHtmlPath(articleColumnPath + File.separator + articleId, htmlDir);
|
||||
writePath = ParserUtil.buildHtmlPath(articleColumnPath + File.separator + articleId, htmlDir, parserParams.get(ParserUtil.APP_DIR).toString());
|
||||
}
|
||||
|
||||
Map<String, Object> parserParams = new HashMap<String, Object>();
|
||||
|
||||
parserParams.put(ParserUtil.COLUMN, categoryBean);
|
||||
|
||||
|
||||
// 判断当前栏目是否有自定义模型
|
||||
if (columnContentModelId != null) {
|
||||
// 通过当前栏目的模型编号获取,自定义模型表名
|
||||
if (contentModelMap.containsKey(columnContentModelId)) {
|
||||
parserParams.put(TABLE_NAME, contentModel.getModelTableName());
|
||||
parserParams.put(ParserUtil.TABLE_NAME, contentModel.getModelTableName());
|
||||
} else {
|
||||
// 通过栏目模型编号获取自定义模型实体
|
||||
contentModel = (ModelEntity) SpringUtil.getBean(IModelBiz.class)
|
||||
.getEntity(columnContentModelId);
|
||||
// 将自定义模型编号设置为key值
|
||||
contentModelMap.put(columnContentModelId, contentModel.getModelTableName());
|
||||
parserParams.put(TABLE_NAME, contentModel.getModelTableName());
|
||||
parserParams.put(ParserUtil.TABLE_NAME, contentModel.getModelTableName());
|
||||
}
|
||||
}
|
||||
|
||||
parserParams.put(ID, articleId);
|
||||
parserParams.put(ParserUtil.ID, articleId);
|
||||
// 第一篇文章没有上一篇
|
||||
if (artId > 0) {
|
||||
CategoryBean preCaBean = articleIdList.get(artId - 1);
|
||||
|
@ -247,22 +271,19 @@ public class CmsParserUtil extends ParserUtil {
|
|||
// }
|
||||
}
|
||||
|
||||
parserParams.put(IS_DO, false);
|
||||
|
||||
parserParams.put(ParserUtil.PAGE, page);
|
||||
String finalWritePath = writePath;
|
||||
HashMap<Object, Object> cloneMap = CollUtil.newHashMap();
|
||||
cloneMap.putAll(parserParams);
|
||||
HttpServletRequest request = SpringUtil.getRequest();
|
||||
pool.execute(() -> {
|
||||
String content = null;
|
||||
try {
|
||||
SpringUtil.setRequest(request);
|
||||
content = CmsParserUtil.generate(columnUrl, cloneMap, htmlDir);
|
||||
FileUtil.writeString(content, finalWritePath, Const.UTF8);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
String content = null;
|
||||
try {
|
||||
content = ParserUtil.rendering(columnUrl, cloneMap);
|
||||
FileUtil.writeString(content, finalWritePath, Const.UTF8);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
artId++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -391,29 +391,31 @@
|
|||
that.model.form.linkId = data.data.id;
|
||||
that.model.save();
|
||||
}
|
||||
|
||||
that.$notify({
|
||||
title: '成功',
|
||||
message: '保存成功',
|
||||
type: 'success'
|
||||
type: 'success',
|
||||
duration: 1000,
|
||||
onClose: function () {
|
||||
if (that.returnIsShow) {
|
||||
javascript: history.go(-1);
|
||||
} else {
|
||||
//如果是顶级封面或封面,则重新加载,避免文章和自定义模型重复保存
|
||||
location.reload();
|
||||
}
|
||||
that.saveDisabled = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (that.returnIsShow) {
|
||||
javascript: history.go(-1);
|
||||
} else {
|
||||
//如果是顶级封面或封面,则重新拿到当前封面id,避免重复保存
|
||||
that.list(that.form.categoryId);
|
||||
}
|
||||
|
||||
} else {
|
||||
that.$notify({
|
||||
title: '失败',
|
||||
message: data.msg,
|
||||
type: 'warning'
|
||||
});
|
||||
that.saveDisabled = false;
|
||||
}
|
||||
|
||||
that.saveDisabled = false;
|
||||
});
|
||||
} else {
|
||||
_this.activeName = 'form';
|
||||
|
@ -557,8 +559,8 @@
|
|||
that.returnIsShow = false;
|
||||
}
|
||||
}
|
||||
that.changeModel();
|
||||
}
|
||||
that.changeModel();
|
||||
} else {
|
||||
that.$notify({
|
||||
title: '失败',
|
||||
|
@ -584,7 +586,9 @@
|
|||
});
|
||||
that.contentCategoryIdOptions = ms.util.treeData(res.data.rows, 'id', 'categoryId', 'children');
|
||||
that.categoryIdOptions = res.data.rows;
|
||||
that.changeModel();
|
||||
|
||||
//获取到栏目数据之后再进行初始化
|
||||
that.init();
|
||||
}
|
||||
}).catch(function (err) {
|
||||
console.log(err);
|
||||
|
@ -664,25 +668,36 @@
|
|||
}).catch(function (err) {
|
||||
console.log(err);
|
||||
});
|
||||
},
|
||||
//只有在渲染完栏目数据之后才会初始化
|
||||
init: function () {
|
||||
this.form.id = ms.util.getParameter("id");
|
||||
this.type = ms.util.getParameter("type");
|
||||
|
||||
//在指定栏目下新增或编辑文章时
|
||||
if (ms.util.getParameter("categoryId")) {
|
||||
this.form.categoryId = ms.util.getParameter("categoryId");
|
||||
//如果是封面栏目直接跳转
|
||||
if (this.type) {
|
||||
this.getFromFengMian(this.form.categoryId);
|
||||
this.returnIsShow = false;
|
||||
//指定非封面栏目编辑文章
|
||||
}else if (this.form.id) {
|
||||
this.get(this.form.id);
|
||||
//指定栏目新增文章渲染自定义模型
|
||||
}else {
|
||||
this.changeModel();
|
||||
}
|
||||
//不指定栏目编辑文章
|
||||
}else if (this.form.id) {
|
||||
this.get(this.form.id);
|
||||
}//else 如果即不指定栏目新增文章,又不是编辑文章就不渲染自定义模型
|
||||
|
||||
}
|
||||
},
|
||||
created: function () {
|
||||
this.contentCategoryIdOptionsGet();
|
||||
this.contentTypeOptionsGet();
|
||||
|
||||
this.form.id = ms.util.getParameter("id");
|
||||
if (ms.util.getParameter("categoryId")) {
|
||||
this.form.categoryId = ms.util.getParameter("categoryId");
|
||||
}
|
||||
this.type = ms.util.getParameter("type");
|
||||
|
||||
if (this.form.id) {
|
||||
this.get(this.form.id);
|
||||
}
|
||||
if (this.type) {
|
||||
this.getFromFengMian(this.form.categoryId);
|
||||
this.returnIsShow = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue