Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
cms_sys
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
西魏
cms_sys
Commits
6d0f7093
Commit
6d0f7093
authored
Aug 09, 2019
by
铭飞
Committed by
Gitee
Aug 09, 2019
Browse files
Options
Browse Files
Download
Plain Diff
!176 修复动态解析
Merge pull request !176 from 灰色DT/4.7.1
parents
74bb9125
8206b442
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
144 additions
and
18 deletions
+144
-18
BaseAction.java
src/main/java/net/mingsoft/cms/action/BaseAction.java
+22
-0
MCmsAction.java
src/main/java/net/mingsoft/cms/action/web/MCmsAction.java
+70
-3
IArticleBiz.java
src/main/java/net/mingsoft/cms/biz/IArticleBiz.java
+11
-2
ArticleBizImpl.java
src/main/java/net/mingsoft/cms/biz/impl/ArticleBizImpl.java
+8
-2
Const.java
src/main/java/net/mingsoft/cms/constant/Const.java
+14
-0
IArticleDao.java
src/main/java/net/mingsoft/cms/dao/IArticleDao.java
+5
-2
IArticleDao.xml
src/main/java/net/mingsoft/cms/dao/IArticleDao.xml
+9
-5
resources_zh_CN.properties
...ava/net/mingsoft/cms/resources/resources_zh_CN.properties
+5
-4
No files found.
src/main/java/net/mingsoft/cms/action/BaseAction.java
0 → 100644
View file @
6d0f7093
package
net
.
mingsoft
.
cms
.
action
;
import
java.util.MissingResourceException
;
/**
* @Author: 铭飞开源团队--huise
* @Date: 2019/8/9 20:47
*/
public
class
BaseAction
extends
net
.
mingsoft
.
mdiy
.
action
.
BaseAction
{
@Override
protected
String
getResString
(
String
key
)
{
// TODO Auto-generated method stub
String
str
=
""
;
try
{
str
=
super
.
getResString
(
key
);
}
catch
(
MissingResourceException
e
)
{
str
=
net
.
mingsoft
.
cms
.
constant
.
Const
.
RESOURCES
.
getString
(
key
);
}
return
str
;
}
}
src/main/java/net/mingsoft/cms/action/web/MCmsAction.java
View file @
6d0f7093
/**
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
));
...
...
src/main/java/net/mingsoft/cms/biz/IArticleBiz.java
View file @
6d0f7093
/**
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
...
...
@@ -147,7 +147,16 @@ public interface IArticleBiz extends IBasicBiz {
* @return
*/
public
List
<
ColumnArticleIdBean
>
queryIdsByCategoryIdForParser
(
int
categoryId
,
String
beginTime
,
String
endTime
);
/**
* 查询文章编号集合
* @param categoryId 栏目编号
* @param beginTime 开始时间
* @param endTime 结束时间
* @param orderBy 排序字段
* @param order 排序方式
* @return
*/
public
List
<
ColumnArticleIdBean
>
queryIdsByCategoryIdForParser
(
int
categoryId
,
String
beginTime
,
String
endTime
,
String
orderBy
,
String
order
);
/**
* 根据页面栏目的id获取与其绑定的文章实体
*
...
...
src/main/java/net/mingsoft/cms/biz/impl/ArticleBizImpl.java
View file @
6d0f7093
/**
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
...
...
@@ -25,6 +25,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.Map
;
import
com.github.pagehelper.PageHelper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -212,6 +213,10 @@ public class ArticleBizImpl extends BasicBizImpl implements IArticleBiz {
@Override
public
List
<
ColumnArticleIdBean
>
queryIdsByCategoryIdForParser
(
int
categoryId
,
String
beginTime
,
String
endTime
)
{
return
this
.
articleDao
.
queryIdsByCategoryIdForParser
(
categoryId
,
BasicUtil
.
getAppId
(),
beginTime
,
endTime
);
return
this
.
articleDao
.
queryIdsByCategoryIdForParser
(
categoryId
,
BasicUtil
.
getAppId
(),
beginTime
,
endTime
,
null
,
null
);
}
@Override
public
List
<
ColumnArticleIdBean
>
queryIdsByCategoryIdForParser
(
int
categoryId
,
String
beginTime
,
String
endTime
,
String
orderBy
,
String
order
)
{
return
this
.
articleDao
.
queryIdsByCategoryIdForParser
(
categoryId
,
BasicUtil
.
getAppId
(),
beginTime
,
endTime
,
orderBy
,
order
);
}
}
\ No newline at end of file
src/main/java/net/mingsoft/cms/constant/Const.java
0 → 100644
View file @
6d0f7093
package
net
.
mingsoft
.
cms
.
constant
;
import
java.util.ResourceBundle
;
/**
* @Author: 铭飞开源团队--huise
* @Date: 2019/8/9 20:51
*/
public
class
Const
{
/**
* 资源文件
*/
public
final
static
ResourceBundle
RESOURCES
=
ResourceBundle
.
getBundle
(
"net.mingsoft.cms.resources.resources"
);
}
src/main/java/net/mingsoft/cms/dao/IArticleDao.java
View file @
6d0f7093
/**
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
...
...
@@ -163,5 +163,7 @@ public interface IArticleDao extends IBaseDao {
* @param endTime 结束时间
* @return
*/
public
List
<
ColumnArticleIdBean
>
queryIdsByCategoryIdForParser
(
@Param
(
"categoryId"
)
int
categoryId
,
@Param
(
"appId"
)
int
appId
,
@Param
(
"beginTime"
)
String
beginTime
,
@Param
(
"endTime"
)
String
endTime
);
public
List
<
ColumnArticleIdBean
>
queryIdsByCategoryIdForParser
(
@Param
(
"categoryId"
)
int
categoryId
,
@Param
(
"appId"
)
int
appId
,
@Param
(
"beginTime"
)
String
beginTime
,
@Param
(
"endTime"
)
String
endTime
,
@Param
(
"orderBy"
)
String
orderBy
,
@Param
(
"order"
)
String
order
);
}
\ No newline at end of file
src/main/java/net/mingsoft/cms/dao/IArticleDao.xml
View file @
6d0f7093
...
...
@@ -50,6 +50,7 @@
<result
column=
"ARTICLE_BASICID"
property=
"articleId"
/>
<result
column=
"column_path"
property=
"columnPath"
/>
<result
column=
"column_url"
property=
"columnUrl"
/>
<result
column=
"column_listurl"
property=
"columnListUrl"
/>
<result
column=
"category_title"
property=
"categoryTitle"
/>
<result
column=
"category_id"
property=
"categoryId"
/>
<result
column=
"COLUMN_CM_ID"
property=
"columnContentModelId"
/>
...
...
@@ -321,8 +322,8 @@
<select
id=
"queryIdsByCategoryIdForParser"
resultMap=
"resultMapBean"
>
select
ARTICLE_BASICID,cl.*,c.*
FROM cms_article a LEFT JOIN basic
b ON a.ARTICLE_BASICID = b.BASIC_ID
LEFT JOIN basic_column cl ON b
.BASIC_CATEGORYID = cl.COLUMN_CATEGORY_ID
FROM cms_article a LEFT JOIN basic
ON a.ARTICLE_BASICID = basic.BASIC_ID
LEFT JOIN basic_column cl ON b
asic.BASIC_CATEGORYID = cl.COLUMN_CATEGORY_ID
JOIN category c ON c.CATEGORY_ID = cl.COLUMN_CATEGORY_ID
where
<if
test=
"appId > 0"
>
...
...
@@ -330,14 +331,17 @@
</if>
<!-- 查询子栏目数据 -->
<if
test=
"categoryId > 0"
>
and (b
.basic_categoryid=#{categoryId} or b.basic_categoryid in
and (b
asic.basic_categoryid=#{categoryId} or basic.basic_categoryid in
(select category_id FROM category where
<include
refid=
"queryWhereCategoryId"
></include>
))
</if>
<if
test=
"beginTime!=null and beginTime!=''"
>
and b.basic_updatetime
>
= #{beginTime}
and b
asic
.basic_updatetime
>
= #{beginTime}
</if>
<if
test=
"endTime!=null and endTime!=''"
>
and b.basic_updatetime
>
= #{endTime}
and basic.basic_updatetime
>
= #{endTime}
</if>
<if
test=
"orderBy!=null and order!=null and orderBy!='' and order!=''"
>
ORDER BY `${orderBy}` ${order}
</if>
</select>
...
...
src/main/java/net/mingsoft/cms/resources/resources_zh_CN.properties
View file @
6d0f7093
#mcms\u7248\u672
c
#mcms\u7248\u672
C
version
=
d3a98fefcb242db78da5fc31608ff247
templet.file
=
\u
6a21
\u
677f
\u6587\u
4ef6
\u
4e0d
\u
5b58
\u5728
id
=
\u6587\u
7ae0
\u
7f16
\u
53f7
typeid
=
\u
680f
\u
76ee
\u
7f16
\u
53f7
templet.file
=
\u
6A21
\u
677F
\u6587\u
4EF6
\u
4E0D
\u
5B58
\u5728
id
=
\u6587\u
7AE0
\u
7F16
\u
53F7
typeid
=
\u
680F
\u
76EE
\u
7F16
\u
53F7
order
=
\u6392\u
5E8F
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment