Commit 1104f2b4 authored by xierz's avatar xierz

Merge remote-tracking branch 'origin/master'

parents e4747423 7d024091
This source diff could not be displayed because it is too large. You can view the blob instead.
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
...@@ -135,6 +135,7 @@ public class GeneraterAction extends BaseAction { ...@@ -135,6 +135,7 @@ public class GeneraterAction extends BaseAction {
if (!FileUtil.exist(ParserUtil.buildTempletPath())) { if (!FileUtil.exist(ParserUtil.buildTempletPath())) {
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();
} }
...@@ -225,14 +226,7 @@ public class GeneraterAction extends BaseAction { ...@@ -225,14 +226,7 @@ public class GeneraterAction extends BaseAction {
List<CategoryEntity> categoryList = new ArrayList<CategoryEntity>(); List<CategoryEntity> categoryList = new ArrayList<CategoryEntity>();
ContentBean contentBean = new ContentBean(); ContentBean contentBean = new ContentBean();
contentBean.setBeginTime(dateTime); 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)) { if ("0".equals(columnId)) {
categoryList = categoryBiz.list(Wrappers.<CategoryEntity>lambdaQuery() categoryList = categoryBiz.list(Wrappers.<CategoryEntity>lambdaQuery()
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
...@@ -128,11 +128,12 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -128,11 +128,12 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
map.put(ParserUtil.IS_DO, true); map.put(ParserUtil.IS_DO, true);
//设置动态请求的模块路径 //设置动态请求的模块路径
map.put(ParserUtil.MODEL_NAME, "mcms"); map.put(ParserUtil.MODEL_NAME, "mcms");
map.put(ParserUtil.HTML,htmlDir);
//解析后的内容 //解析后的内容
String content = ""; String content = "";
try { try {
//根据模板路径,参数生成 //根据模板路径,参数生成
content = CmsParserUtil.generate(ParserUtil.INDEX + ParserUtil.HTM_SUFFIX, map, htmlDir); content = ParserUtil.rendering(ParserUtil.INDEX + ParserUtil.HTM_SUFFIX, map);
} catch (TemplateNotFoundException e) { } catch (TemplateNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} catch (MalformedTemplateNameException e) { } catch (MalformedTemplateNameException e) {
...@@ -186,11 +187,12 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -186,11 +187,12 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
map.put(ParserUtil.IS_DO, true); map.put(ParserUtil.IS_DO, true);
//设置动态请求的模块路径 //设置动态请求的模块路径
map.put(ParserUtil.MODEL_NAME, "mcms"); map.put(ParserUtil.MODEL_NAME, "mcms");
map.put(ParserUtil.HTML, htmlDir);
//解析后的内容 //解析后的内容
String content = ""; String content = "";
try { try {
//根据模板路径,参数生成 //根据模板路径,参数生成
content = CmsParserUtil.generate(columnArticles.get(0).getCategoryListUrl(), map, htmlDir); content = ParserUtil.rendering(columnArticles.get(0).getCategoryListUrl(), map);
} catch (TemplateNotFoundException e) { } catch (TemplateNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} catch (MalformedTemplateNameException e) { } catch (MalformedTemplateNameException e) {
...@@ -243,6 +245,8 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -243,6 +245,8 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
map.put(ParserUtil.URL, BasicUtil.getUrl()); map.put(ParserUtil.URL, BasicUtil.getUrl());
map.put(ParserUtil.PAGE, page); map.put(ParserUtil.PAGE, page);
map.put(ParserUtil.ID, article.getId()); map.put(ParserUtil.ID, article.getId());
map.put(ParserUtil.HTML,htmlDir);
ContentBean contentBean = new ContentBean(); ContentBean contentBean = new ContentBean();
contentBean.setCategoryId(String.valueOf(typeId)); contentBean.setCategoryId(String.valueOf(typeId));
contentBean.setOrderBy(orderby); contentBean.setOrderBy(orderby);
...@@ -292,7 +296,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -292,7 +296,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
} }
try { try {
//根据模板路径,参数生成 //根据模板路径,参数生成
content = CmsParserUtil.generate(column.getCategoryUrl(), map, htmlDir); content = ParserUtil.rendering(column.getCategoryUrl(), map);
} catch (TemplateNotFoundException e) { } catch (TemplateNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} catch (MalformedTemplateNameException e) { } catch (MalformedTemplateNameException e) {
...@@ -340,12 +344,12 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -340,12 +344,12 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
//获取栏目信息 //获取栏目信息
int typeId = 0; String typeId = null;
String categoryIds = BasicUtil.getString("categoryIds"); String categoryIds = BasicUtil.getString("categoryIds");
List categoryIdList = CollectionUtil.newArrayList(); List categoryIdList = CollectionUtil.newArrayList();
//当传递了栏目编号,但不是栏目集合 //当传递了栏目编号,但不是栏目集合
if (StringUtils.isNotBlank(categoryIds) && !categoryIds.contains(",")) { if (StringUtils.isNotBlank(categoryIds) && !categoryIds.contains(",")) {
typeId = Integer.parseInt(categoryIds); typeId = categoryIds;
} else { } else {
//取出所有的子栏目 //取出所有的子栏目
String[] ids = categoryIds.split(","); String[] ids = categoryIds.split(",");
...@@ -366,12 +370,11 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -366,12 +370,11 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
//重新组织 ID //重新组织 ID
categoryIds = StringUtils.join(categoryIdList, ","); categoryIds = StringUtils.join(categoryIdList, ",");
//当前访问的项目地址
String url = BasicUtil.getUrl();
//根据栏目确定自定义模型 //根据栏目确定自定义模型
if (typeId > 0) { if (typeId != null) {
column = (CategoryEntity) categoryBiz.getEntity(typeId); column = (CategoryEntity) categoryBiz.getById(typeId);
// 获取表单类型的id // 获取表单类型的id
if (column != null && ObjectUtil.isNotNull(column.getMdiyModelId())) { if (column != null && ObjectUtil.isNotNull(column.getMdiyModelId())) {
contentModel = (ModelEntity) modelBiz.getEntity(column.getMdiyModelId()); contentModel = (ModelEntity) modelBiz.getEntity(column.getMdiyModelId());
...@@ -454,11 +457,18 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -454,11 +457,18 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
//查询数量 //查询数量
int count = contentBiz.getSearchCount(contentModel, fieldValueList, searchMap, BasicUtil.getApp().getAppId(), categoryIds); int count = contentBiz.getSearchCount(contentModel, fieldValueList, searchMap, BasicUtil.getApp().getAppId(), categoryIds);
page.setRcount(count); page.setRcount(count);
params.put(ParserUtil.URL, url);
params.put(SEARCH, searchMap); params.put(SEARCH, searchMap);
//站点编号
if (BasicUtil.getWebsiteApp() != null) { if (BasicUtil.getWebsiteApp() != null) {
params.put(ParserUtil.APP_DIR, BasicUtil.getWebsiteApp().getAppDir()); 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.PAGE, page);
params.put(ParserUtil.HTML, htmlDir); params.put(ParserUtil.HTML, htmlDir);
//动态解析 //动态解析
...@@ -481,6 +491,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -481,6 +491,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
page.setPageNo(pageNo); page.setPageNo(pageNo);
//设置分页的统一链接 //设置分页的统一链接
String url = params.get(ParserUtil.URL).toString();
url = url + request.getServletPath() + "?" + urlParams; url = url + request.getServletPath() + "?" + urlParams;
String pageNoStr = "size=" + page.getSize() + "&pageNo="; String pageNoStr = "size=" + page.getSize() + "&pageNo=";
//下一页 //下一页
...@@ -497,7 +508,6 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -497,7 +508,6 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
page.setPreUrl(preUrl); page.setPreUrl(preUrl);
page.setLastUrl(lastUrl); page.setLastUrl(lastUrl);
params.put(ParserUtil.URL, url);
params.put(SEARCH, searchMap); params.put(SEARCH, searchMap);
if (BasicUtil.getWebsiteApp() != null) { if (BasicUtil.getWebsiteApp() != null) {
params.put(ParserUtil.APP_DIR, BasicUtil.getWebsiteApp().getAppDir()); params.put(ParserUtil.APP_DIR, BasicUtil.getWebsiteApp().getAppDir());
...@@ -513,7 +523,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -513,7 +523,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
String content = ""; String content = "";
try { try {
//根据模板路径,参数生成 //根据模板路径,参数生成
content = CmsParserUtil.generate(SEARCH + ParserUtil.HTM_SUFFIX, params, htmlDir); content = ParserUtil.rendering(SEARCH + ParserUtil.HTM_SUFFIX, params);
} catch (TemplateNotFoundException e) { } catch (TemplateNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} catch (MalformedTemplateNameException e) { } catch (MalformedTemplateNameException e) {
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
...@@ -98,144 +98,5 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp ...@@ -98,144 +98,5 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
return contentDao.getSearchCount(null,null,whereMap, appId,categoryIds); 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);
}
} }
\ No newline at end of file
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
This diff is collapsed.
...@@ -391,19 +391,21 @@ ...@@ -391,19 +391,21 @@
that.model.form.linkId = data.data.id; that.model.form.linkId = data.data.id;
that.model.save(); that.model.save();
} }
that.$notify({ that.$notify({
title: '成功', title: '成功',
message: '保存成功', message: '保存成功',
type: 'success' type: 'success',
}); duration: 1000,
onClose: function () {
if (that.returnIsShow) { if (that.returnIsShow) {
javascript: history.go(-1); javascript: history.go(-1);
} else { } else {
//如果是顶级封面或封面,则重新拿到当前封面id,避免重复保存 //如果是顶级封面或封面,则重新加载,避免文章和自定义模型重复保存
that.list(that.form.categoryId); location.reload();
}
that.saveDisabled = false;
} }
});
} else { } else {
that.$notify({ that.$notify({
...@@ -411,9 +413,9 @@ ...@@ -411,9 +413,9 @@
message: data.msg, message: data.msg,
type: 'warning' type: 'warning'
}); });
that.saveDisabled = false;
} }
that.saveDisabled = false;
}); });
} else { } else {
_this.activeName = 'form'; _this.activeName = 'form';
...@@ -557,8 +559,8 @@ ...@@ -557,8 +559,8 @@
that.returnIsShow = false; that.returnIsShow = false;
} }
} }
that.changeModel();
} }
that.changeModel();
} else { } else {
that.$notify({ that.$notify({
title: '失败', title: '失败',
...@@ -584,7 +586,9 @@ ...@@ -584,7 +586,9 @@
}); });
that.contentCategoryIdOptions = ms.util.treeData(res.data.rows, 'id', 'categoryId', 'children'); that.contentCategoryIdOptions = ms.util.treeData(res.data.rows, 'id', 'categoryId', 'children');
that.categoryIdOptions = res.data.rows; that.categoryIdOptions = res.data.rows;
that.changeModel();
//获取到栏目数据之后再进行初始化
that.init();
} }
}).catch(function (err) { }).catch(function (err) {
console.log(err); console.log(err);
...@@ -664,25 +668,36 @@ ...@@ -664,25 +668,36 @@
}).catch(function (err) { }).catch(function (err) {
console.log(err); console.log(err);
}); });
}
}, },
created: function () { //只有在渲染完栏目数据之后才会初始化
this.contentCategoryIdOptionsGet(); init: function () {
this.contentTypeOptionsGet();
this.form.id = ms.util.getParameter("id"); 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"); this.type = ms.util.getParameter("type");
if (this.form.id) { //在指定栏目下新增或编辑文章时
this.get(this.form.id); if (ms.util.getParameter("categoryId")) {
} this.form.categoryId = ms.util.getParameter("categoryId");
//如果是封面栏目直接跳转
if (this.type) { if (this.type) {
this.getFromFengMian(this.form.categoryId); this.getFromFengMian(this.form.categoryId);
this.returnIsShow = false; 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();
} }
}); });
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment