Commit 0f0b778d authored by guwd's avatar guwd
Browse files

5.2.0版本同步

No related merge requests found
Showing with 703 additions and 714 deletions
+703 -714
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 {
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()
......
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 {
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) {
......
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
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
Supports Markdown
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