|
|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
/** |
|
|
|
|
The MIT License (MIT) * Copyright (c) 2016 铭飞科技(mingsoft.net) |
|
|
|
|
The MIT License (MIT) * Copyright (c) 2016 铭飞科技(mingsoft.net) |
|
|
|
|
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of |
|
|
|
|
* this software and associated documentation files (the "Software"), to deal in |
|
|
|
|
@ -21,13 +21,23 @@ The MIT License (MIT) * Copyright (c) 2016 铭飞科技(mingsoft.net) |
|
|
|
|
|
|
|
|
|
package net.mingsoft.cms.action.web; |
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil; |
|
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
|
import net.mingsoft.base.constant.Const; |
|
|
|
|
import net.mingsoft.basic.util.SpringUtil; |
|
|
|
|
import net.mingsoft.cms.constant.e.ColumnTypeEnum; |
|
|
|
|
import net.mingsoft.mdiy.biz.IContentModelBiz; |
|
|
|
|
import net.mingsoft.mdiy.entity.ContentModelEntity; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler; |
|
|
|
|
@ -60,7 +70,7 @@ import net.mingsoft.mdiy.util.ParserUtil; |
|
|
|
|
*/ |
|
|
|
|
@Controller("dynamicPageAction") |
|
|
|
|
@RequestMapping("/mcms") |
|
|
|
|
public class MCmsAction extends net.mingsoft.mdiy.action.BaseAction { |
|
|
|
|
public class MCmsAction extends net.mingsoft.cms.action.BaseAction { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 自定义页面业务层 |
|
|
|
|
@ -204,13 +214,21 @@ public class MCmsAction extends net.mingsoft.mdiy.action.BaseAction { |
|
|
|
|
* @param id 文章编号 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/view.do") |
|
|
|
|
public void view(HttpServletRequest req, HttpServletResponse resp) { |
|
|
|
|
public void view(String orderby,String order,HttpServletRequest req, HttpServletResponse resp) { |
|
|
|
|
//参数文章编号
|
|
|
|
|
ArticleEntity article = (ArticleEntity) articleBiz.getEntity(BasicUtil.getInt(ParserUtil.ID)); |
|
|
|
|
if(ObjectUtil.isNull(article)){ |
|
|
|
|
this.outJson(resp, null,false,getResString("err.empty", this.getResString("id"))); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if(StringUtils.isNotBlank(order)){ |
|
|
|
|
//防注入
|
|
|
|
|
if(!order.toLowerCase().equals("asc")&&!order.toLowerCase().equals("desc")){ |
|
|
|
|
this.outJson(resp, null,false,getResString("err.error", this.getResString("order"))); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
PageBean page = new PageBean(); |
|
|
|
|
//根据文章编号查询栏目详情模版
|
|
|
|
|
ColumnEntity column = (ColumnEntity) columnBiz.getEntity(article.getBasicCategoryId()); |
|
|
|
|
//解析后的内容
|
|
|
|
|
@ -221,6 +239,55 @@ public class MCmsAction extends net.mingsoft.mdiy.action.BaseAction { |
|
|
|
|
//设置动态请求的模块路径
|
|
|
|
|
map.put(ParserUtil.MODEL_NAME, "mcms"); |
|
|
|
|
map.put(ParserUtil.URL, BasicUtil.getUrl()); |
|
|
|
|
map.put(ParserUtil.PAGE, page); |
|
|
|
|
map.put(ParserUtil.ID, article.getArticleID()); |
|
|
|
|
List<ColumnArticleIdBean> articleIdList = articleBiz.queryIdsByCategoryIdForParser(column.getCategoryCategoryId(), null, null,orderby,order); |
|
|
|
|
Map<Object, Object> contentModelMap = new HashMap<Object, Object>(); |
|
|
|
|
ContentModelEntity contentModel = null; |
|
|
|
|
for (int artId = 0; artId < articleIdList.size();) { |
|
|
|
|
//如果不是当前文章则跳过
|
|
|
|
|
if(articleIdList.get(artId).getArticleId() != article.getArticleID()){ |
|
|
|
|
artId++; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
// 文章的栏目路径
|
|
|
|
|
String articleColumnPath = articleIdList.get(artId).getColumnPath(); |
|
|
|
|
// 文章的栏目模型编号
|
|
|
|
|
int columnContentModelId = articleIdList.get(artId).getColumnContentModelId(); |
|
|
|
|
Map<String, Object> parserParams = new HashMap<String, Object>(); |
|
|
|
|
parserParams.put(ParserUtil.COLUMN, articleIdList.get(artId)); |
|
|
|
|
// 判断当前栏目是否有自定义模型
|
|
|
|
|
if (columnContentModelId > 0) { |
|
|
|
|
// 通过当前栏目的模型编号获取,自定义模型表名
|
|
|
|
|
if (contentModelMap.containsKey(columnContentModelId)) { |
|
|
|
|
parserParams.put(ParserUtil.TABLE_NAME, contentModel.getCmTableName()); |
|
|
|
|
} else { |
|
|
|
|
// 通过栏目模型编号获取自定义模型实体
|
|
|
|
|
contentModel = (ContentModelEntity) SpringUtil.getBean(IContentModelBiz.class) |
|
|
|
|
.getEntity(columnContentModelId); |
|
|
|
|
// 将自定义模型编号设置为key值
|
|
|
|
|
contentModelMap.put(columnContentModelId, contentModel.getCmTableName()); |
|
|
|
|
parserParams.put(ParserUtil.TABLE_NAME, contentModel.getCmTableName()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 第一篇文章没有上一篇
|
|
|
|
|
if (artId > 0) { |
|
|
|
|
ColumnArticleIdBean preCaBean = articleIdList.get(artId - 1); |
|
|
|
|
//判断当前文档是否与上一页文章在同一栏目下,并且不能使用父栏目字符串,因为父栏目中没有所属栏目编号
|
|
|
|
|
if(articleColumnPath.contains(preCaBean.getCategoryId()+"")){ |
|
|
|
|
page.setPreId(preCaBean.getArticleId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 最后一篇文章没有下一篇
|
|
|
|
|
if (artId + 1 < articleIdList.size()) { |
|
|
|
|
ColumnArticleIdBean nextCaBean = articleIdList.get(artId + 1); |
|
|
|
|
//判断当前文档是否与下一页文章在同一栏目下并且不能使用父栏目字符串,因为父栏目中没有所属栏目编号
|
|
|
|
|
if(articleColumnPath.contains(nextCaBean.getCategoryId()+"")){ |
|
|
|
|
page.setNextId(nextCaBean.getArticleId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
//根据模板路径,参数生成
|
|
|
|
|
content = CmsParserUtil.generate(column.getColumnUrl(), map, isMobileDevice(req)); |
|
|
|
|
|