Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
MCMS
Commits
0f4dcbda
Commit
0f4dcbda
authored
Mar 13, 2019
by
他是超人他会飞
Committed by
铭飞
Mar 13, 2019
Browse files
!153 添加分页类
Merge pull request !153 from 他是超人他会飞/4.7.0
parents
a15269e6
1859f695
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
doc/4.6.5-to-4.7.0-mysql.sql
View file @
0f4dcbda
This diff is collapsed.
Click to expand it.
doc/db-mcms-mysql-4.7.0.sql
View file @
0f4dcbda
This diff is collapsed.
Click to expand it.
src/main/java/net/mingsoft/cms/action/web/MCmsAction.java
View file @
0f4dcbda
...
@@ -36,20 +36,20 @@ import org.springframework.web.bind.annotation.PathVariable;
...
@@ -36,20 +36,20 @@ import org.springframework.web.bind.annotation.PathVariable;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.PageUtil
;
import
freemarker.core.ParseException
;
import
freemarker.template.MalformedTemplateNameException
;
import
freemarker.template.TemplateNotFoundException
;
import
net.mingsoft.basic.biz.IColumnBiz
;
import
net.mingsoft.basic.biz.IColumnBiz
;
import
net.mingsoft.basic.entity.ColumnEntity
;
import
net.mingsoft.basic.entity.ColumnEntity
;
import
net.mingsoft.basic.util.BasicUtil
;
import
net.mingsoft.cms.bean.ColumnArticleIdBean
;
import
net.mingsoft.cms.bean.ColumnArticleIdBean
;
import
net.mingsoft.cms.biz.IArticleBiz
;
import
net.mingsoft.cms.biz.IArticleBiz
;
import
net.mingsoft.cms.constant.ModelCode
;
import
net.mingsoft.cms.entity.ArticleEntity
;
import
net.mingsoft.cms.entity.ArticleEntity
;
import
net.mingsoft.cms.util.CmsParserUtil
;
import
net.mingsoft.cms.util.CmsParserUtil
;
import
net.mingsoft.mdiy.bean.PageBean
;
import
net.mingsoft.mdiy.biz.IPageBiz
;
import
net.mingsoft.mdiy.biz.IPageBiz
;
import
net.mingsoft.mdiy.entity.PageEntity
;
import
net.mingsoft.mdiy.entity.PageEntity
;
import
freemarker.core.ParseException
;
import
freemarker.template.MalformedTemplateNameException
;
import
freemarker.template.TemplateNotFoundException
;
import
net.mingsoft.basic.util.BasicUtil
;
import
net.mingsoft.mdiy.util.ParserUtil
;
import
net.mingsoft.mdiy.util.ParserUtil
;
/**
/**
...
@@ -157,24 +157,27 @@ public class MCmsAction extends net.mingsoft.mdiy.action.BaseAction {
...
@@ -157,24 +157,27 @@ public class MCmsAction extends net.mingsoft.mdiy.action.BaseAction {
Map
map
=
BasicUtil
.
assemblyRequestMap
();
Map
map
=
BasicUtil
.
assemblyRequestMap
();
//获取栏目编号
//获取栏目编号
int
typeId
=
BasicUtil
.
getInt
(
ParserUtil
.
TYPE_ID
,
0
);
int
typeId
=
BasicUtil
.
getInt
(
ParserUtil
.
TYPE_ID
,
0
);
int
size
=
BasicUtil
.
getInt
(
ParserUtil
.
SIZE
,
10
);
//获取文章总数
//获取文章总数
List
<
ColumnArticleIdBean
>
columnArticles
=
articleBiz
.
queryIdsByCategoryIdForParser
(
typeId
,
null
,
null
);
List
<
ColumnArticleIdBean
>
columnArticles
=
articleBiz
.
queryIdsByCategoryIdForParser
(
typeId
,
null
,
null
);
//判断栏目下是否有文章
//判断栏目下是否有文章
if
(
columnArticles
.
size
()==
0
){
if
(
columnArticles
.
size
()==
0
){
this
.
outJson
(
resp
,
null
,
false
,
getResString
(
"err.empty"
,
this
.
getResString
(
"typeid"
)));
this
.
outJson
(
resp
,
false
);
return
;
}
}
//设置分页类
PageBean
page
=
new
PageBean
();
int
total
=
PageUtil
.
totalPage
(
columnArticles
.
size
(),
size
);
map
.
put
(
ParserUtil
.
COLUMN
,
columnArticles
.
get
(
0
));
map
.
put
(
ParserUtil
.
COLUMN
,
columnArticles
.
get
(
0
));
//获取总数
//获取总数
map
.
put
(
ParserUtil
.
TOTAL
,
columnArticles
.
size
());
page
.
setTotal
(
total
);
map
.
put
(
ParserUtil
.
RCOUNT
,
BasicUtil
.
getInt
(
ParserUtil
.
SIZE
,
10
));
//设置栏目编号
//设置栏目编号
map
.
put
(
ParserUtil
.
TYPE_ID
,
typeId
);
map
.
put
(
ParserUtil
.
TYPE_ID
,
typeId
);
//设置列表当前页
//设置列表当前页
map
.
put
(
ParserUtil
.
PAGE_NO
,
BasicUtil
.
getInt
(
ParserUtil
.
PAGE_NO
,
1
));
map
.
put
(
ParserUtil
.
PAGE_NO
,
BasicUtil
.
getInt
(
ParserUtil
.
PAGE_NO
,
1
));
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
PAGE
,
page
);
//动态解析
//动态解析
map
.
put
(
ParserUtil
.
IS_DO
,
true
);
map
.
put
(
ParserUtil
.
IS_DO
,
true
);
//设置动态请求的模块路径
//设置动态请求的模块路径
...
...
src/main/java/net/mingsoft/cms/action/web/SearchAction.java
View file @
0f4dcbda
...
@@ -40,30 +40,28 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -40,30 +40,28 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.PageUtil
;
import
freemarker.core.ParseException
;
import
freemarker.template.MalformedTemplateNameException
;
import
freemarker.template.TemplateNotFoundException
;
import
net.mingsoft.base.constant.Const
;
import
net.mingsoft.basic.action.BaseAction
;
import
net.mingsoft.basic.action.BaseAction
;
import
net.mingsoft.basic.biz.ICategoryBiz
;
import
net.mingsoft.basic.biz.ICategoryBiz
;
import
net.mingsoft.basic.biz.IColumnBiz
;
import
net.mingsoft.basic.biz.IColumnBiz
;
import
net.mingsoft.basic.biz.IModelBiz
;
import
net.mingsoft.basic.biz.IModelBiz
;
import
net.mingsoft.basic.entity.BaseEntity
;
import
net.mingsoft.basic.entity.ColumnEntity
;
import
net.mingsoft.basic.entity.ColumnEntity
;
import
net.mingsoft.basic.util.BasicUtil
;
import
net.mingsoft.basic.util.StringUtil
;
import
net.mingsoft.cms.biz.IArticleBiz
;
import
net.mingsoft.cms.biz.IArticleBiz
;
import
net.mingsoft.cms.util.CmsParserUtil
;
import
net.mingsoft.cms.util.CmsParserUtil
;
import
net.mingsoft.mdiy.bean.PageBean
;
import
net.mingsoft.mdiy.biz.IContentModelBiz
;
import
net.mingsoft.mdiy.biz.IContentModelBiz
;
import
net.mingsoft.mdiy.biz.IContentModelFieldBiz
;
import
net.mingsoft.mdiy.biz.IContentModelFieldBiz
;
import
net.mingsoft.mdiy.biz.ISearchBiz
;
import
net.mingsoft.mdiy.biz.ISearchBiz
;
import
net.mingsoft.mdiy.entity.ContentModelEntity
;
import
net.mingsoft.mdiy.entity.ContentModelEntity
;
import
net.mingsoft.mdiy.entity.ContentModelFieldEntity
;
import
net.mingsoft.mdiy.entity.ContentModelFieldEntity
;
import
net.mingsoft.mdiy.entity.SearchEntity
;
import
net.mingsoft.mdiy.entity.SearchEntity
;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.core.text.StrSpliter
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.PageUtil
;
import
freemarker.core.ParseException
;
import
freemarker.template.MalformedTemplateNameException
;
import
freemarker.template.TemplateNotFoundException
;
import
net.mingsoft.base.constant.Const
;
import
net.mingsoft.basic.util.BasicUtil
;
import
net.mingsoft.basic.util.StringUtil
;
import
net.mingsoft.mdiy.util.ParserUtil
;
import
net.mingsoft.mdiy.util.ParserUtil
;
/**
/**
...
@@ -225,17 +223,17 @@ public class SearchAction extends BaseAction {
...
@@ -225,17 +223,17 @@ public class SearchAction extends BaseAction {
Map
whereMap
=
this
.
searchMap
(
articleFieldName
,
diyFieldName
,
fieldList
);
Map
whereMap
=
this
.
searchMap
(
articleFieldName
,
diyFieldName
,
fieldList
);
// 获取符合条件的文章总数
// 获取符合条件的文章总数
int
count
=
articleBiz
.
getSearchCount
(
contentModel
,
whereMap
,
BasicUtil
.
getAppId
(),
null
);
int
count
=
articleBiz
.
getSearchCount
(
contentModel
,
whereMap
,
BasicUtil
.
getAppId
(),
null
);
//设置分页类
PageBean
page
=
new
PageBean
();
int
size
=
BasicUtil
.
getInt
(
ParserUtil
.
SIZE
,
10
);
int
size
=
BasicUtil
.
getInt
(
ParserUtil
.
SIZE
,
10
);
int
total
=
PageUtil
.
totalPage
(
count
,
size
);
int
total
=
PageUtil
.
totalPage
(
count
,
size
);
//获取总数
//获取总数
map
.
put
(
ParserUtil
.
TOTAL
,
total
);
page
.
setTotal
(
total
);
//设置页面显示数量
//设置页面显示数量
map
.
put
(
ParserUtil
.
RCOUNT
,
size
);
page
.
setSize
(
size
);
map
.
put
(
ParserUtil
.
SIZE
,
size
);
//设置列表当前页
//设置列表当前页
int
pageNo
=
BasicUtil
.
getInt
(
ParserUtil
.
PAGE_NO
,
1
);
int
pageNo
=
BasicUtil
.
getInt
(
ParserUtil
.
PAGE_NO
,
1
);
map
.
put
(
ParserUtil
.
PAGE_NO
,
pageNo
);
page
.
setPageNo
(
pageNo
);
int
next
,
pre
;
int
next
,
pre
;
if
(
StringUtil
.
isBlank
(
pageNo
)
||
pageNo
==
1
){
if
(
StringUtil
.
isBlank
(
pageNo
)
||
pageNo
==
1
){
//如果总页数等于1,下一页就是第一页,不等于就有第二页
//如果总页数等于1,下一页就是第一页,不等于就有第二页
...
@@ -257,16 +255,17 @@ public class SearchAction extends BaseAction {
...
@@ -257,16 +255,17 @@ public class SearchAction extends BaseAction {
String
lastUrl
=
url
+
pageNoStr
+
total
;
String
lastUrl
=
url
+
pageNoStr
+
total
;
//上一页
//上一页
String
preUrl
=
url
+
pageNoStr
+
pre
;
String
preUrl
=
url
+
pageNoStr
+
pre
;
page
.
setIndexUrl
(
indexUrl
);
map
.
put
(
ParserUtil
.
INDEX_URL
,
indexUrl
);
page
.
setNextUrl
(
nextUrl
);
map
.
put
(
ParserUtil
.
NEXT_URL
,
nextUrl
);
page
.
setPreUrl
(
preUrl
);
map
.
put
(
ParserUtil
.
PRE_URL
,
preUrl
);
page
.
setLastUrl
(
lastUrl
);
map
.
put
(
ParserUtil
.
LAST_URL
,
lastUrl
);
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
PAGE
,
page
);
Map
<
Object
,
Object
>
searchMap
=
new
HashMap
<>();
Map
<
Object
,
Object
>
searchMap
=
new
HashMap
<>();
searchMap
.
put
(
BASIC_TITLE
,
BasicUtil
.
getString
(
BASIC_TITLE
));
searchMap
.
put
(
BASIC_TITLE
,
BasicUtil
.
getString
(
BASIC_TITLE
));
searchMap
.
put
(
ParserUtil
.
PAGE_NO
,
BasicUtil
.
getInt
(
ParserUtil
.
PAGE_NO
,
1
)
);
searchMap
.
put
(
ParserUtil
.
PAGE_NO
,
pageNo
);
map
.
put
(
SEARCH
,
searchMap
);
map
.
put
(
SEARCH
,
searchMap
);
map
.
put
(
ParserUtil
.
PAGE
,
page
);
//动态解析
//动态解析
map
.
put
(
ParserUtil
.
IS_DO
,
false
);
map
.
put
(
ParserUtil
.
IS_DO
,
false
);
//设置动态请求的模块路径
//设置动态请求的模块路径
...
...
src/main/java/net/mingsoft/cms/dao/IArticleDao.xml
View file @
0f4dcbda
...
@@ -47,16 +47,14 @@
...
@@ -47,16 +47,14 @@
<!-- 获取表字段 结束 -->
<!-- 获取表字段 结束 -->
<!-- 通过视图查询返回结果集 开始 -->
<!-- 通过视图查询返回结果集 开始 -->
<resultMap
type=
"net.mingsoft.cms.bean.ColumnArticleIdBean"
id=
"resultMapBean"
>
<resultMap
type=
"net.mingsoft.cms.bean.ColumnArticleIdBean"
id=
"resultMapBean"
>
<result
column=
"ARTICLE_BASICID"
property=
"articleId"
/>
<result
column=
"ARTICLE_BASICID"
property=
"articleId"
/>
<result
column=
"column_listurl"
property=
"columnListUrl"
/>
<!-- 最终栏目列表地址 -->
<result
column=
"column_path"
property=
"columnPath"
/>
<result
column=
"column_path"
property=
"columnPath"
/>
<result
column=
"column_url"
property=
"columnUrl"
/>
<result
column=
"column_url"
property=
"columnUrl"
/>
<result
column=
"category_title"
property=
"categoryTitle"
/>
<result
column=
"category_title"
property=
"categoryTitle"
/>
<result
column=
"column_category_id"
property=
"categoryId"
/>
<!-- 与Category类别类绑定ID -->
<result
column=
"category_parent_id"
property=
"categoryParentId"
/>
<!-- 关联表category的父类型编号 -->
<result
column=
"category_id"
property=
"categoryId"
/>
<result
column=
"category_id"
property=
"categoryId"
/>
<result
column=
"COLUMN_CM_ID"
property=
"columnContentModelId"
/>
<result
column=
"COLUMN_CM_ID"
property=
"columnContentModelId"
/>
<result
column=
"COLUMN_TYPE"
property=
"columnType"
/>
<result
column=
"COLUMN_TYPE"
property=
"columnType"
/>
<result
column=
"category_parent_id"
property=
"categoryParentId"
/>
<!--关联表category的字典对应编号 -->
</resultMap>
</resultMap>
<!-- 通过视图查询返回结果集 结束 -->
<!-- 通过视图查询返回结果集 结束 -->
<!-- 通过视图查询返回结果集 开始 -->
<!-- 通过视图查询返回结果集 开始 -->
...
@@ -320,7 +318,7 @@
...
@@ -320,7 +318,7 @@
<!-- 根据站点编号、开始、结束时间和栏目编号查询文章编号集合 -->
<!-- 根据站点编号、开始、结束时间和栏目编号查询文章编号集合 -->
<select
id=
"queryIdsByCategoryIdForParser"
resultMap=
"resultMapBean"
>
<select
id=
"queryIdsByCategoryIdForParser"
resultMap=
"resultMapBean"
>
select
select
ARTICLE_BASICID,cl.*,c.
*
ARTICLE_BASICID,cl.*,c.
category_parent_id
FROM cms_article a LEFT JOIN basic b ON a.ARTICLE_BASICID = b.BASIC_ID
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
LEFT JOIN basic_column cl ON b.BASIC_CATEGORYID = cl.COLUMN_CATEGORY_ID
JOIN category c ON c.CATEGORY_ID = cl.COLUMN_CATEGORY_ID
JOIN category c ON c.CATEGORY_ID = cl.COLUMN_CATEGORY_ID
...
...
src/main/java/net/mingsoft/cms/util/CmsParserUtil.java
View file @
0f4dcbda
...
@@ -22,6 +22,7 @@ import net.mingsoft.basic.util.BasicUtil;
...
@@ -22,6 +22,7 @@ import net.mingsoft.basic.util.BasicUtil;
import
net.mingsoft.basic.util.SpringUtil
;
import
net.mingsoft.basic.util.SpringUtil
;
import
net.mingsoft.cms.bean.ColumnArticleIdBean
;
import
net.mingsoft.cms.bean.ColumnArticleIdBean
;
import
net.mingsoft.cms.constant.e.ColumnTypeEnum
;
import
net.mingsoft.cms.constant.e.ColumnTypeEnum
;
import
net.mingsoft.mdiy.bean.PageBean
;
import
net.mingsoft.mdiy.biz.IContentModelBiz
;
import
net.mingsoft.mdiy.biz.IContentModelBiz
;
import
net.mingsoft.mdiy.entity.ContentModelEntity
;
import
net.mingsoft.mdiy.entity.ContentModelEntity
;
import
net.mingsoft.mdiy.parser.TagParser
;
import
net.mingsoft.mdiy.parser.TagParser
;
...
@@ -75,21 +76,18 @@ public class CmsParserUtil extends ParserUtil {
...
@@ -75,21 +76,18 @@ public class CmsParserUtil extends ParserUtil {
BasicUtil
.
getApp
().
getAppMobileStyle
()
+
File
.
separator
+
column
.
getColumnListUrl
(),
Const
.
UTF8
);
BasicUtil
.
getApp
().
getAppMobileStyle
()
+
File
.
separator
+
column
.
getColumnListUrl
(),
Const
.
UTF8
);
// pc端模板
// pc端模板
Template
template
=
cfg
.
getTemplate
(
File
.
separator
+
column
.
getColumnListUrl
(),
Const
.
UTF8
);
Template
template
=
cfg
.
getTemplate
(
File
.
separator
+
column
.
getColumnListUrl
(),
Const
.
UTF8
);
// 文章的栏目模型编号
// 文章的栏目模型编号
int
columnContentModelId
=
column
.
getColumnContentModelId
();
int
columnContentModelId
=
column
.
getColumnContentModelId
();
StringWriter
writer
=
new
StringWriter
();
StringWriter
writer
=
new
StringWriter
();
try
{
try
{
// 为了分页添加column,判断栏目是否为父栏目
// 为了分页添加column,判断栏目是否为父栏目
template
.
process
(
null
,
writer
);
template
.
process
(
null
,
writer
);
String
content
=
writer
.
toString
();
String
content
=
writer
.
toString
();
//获取列表页显示的文章数量
//获取列表页显示的文章数量
int
pageSize
=
TagParser
.
getPageSize
(
content
);
int
pageSize
=
TagParser
.
getPageSize
(
content
);
//获取总数
//获取总数
int
totalPageSize
=
PageUtil
.
totalPage
(
articleIdTotal
,
pageSize
);
int
totalPageSize
=
PageUtil
.
totalPage
(
articleIdTotal
,
pageSize
);
String
columnListPath
;
String
columnListPath
;
String
mobilePath
;
String
mobilePath
;
...
@@ -100,57 +98,77 @@ public class CmsParserUtil extends ParserUtil {
...
@@ -100,57 +98,77 @@ public class CmsParserUtil extends ParserUtil {
contentModel
=
(
ContentModelEntity
)
SpringUtil
.
getBean
(
IContentModelBiz
.
class
).
getEntity
(
columnContentModelId
);
contentModel
=
(
ContentModelEntity
)
SpringUtil
.
getBean
(
IContentModelBiz
.
class
).
getEntity
(
columnContentModelId
);
}
}
int
pageNo
=
1
;
int
pageNo
=
1
;
// 遍历分页
PageBean
page
=
new
PageBean
();
for
(
int
i
=
0
;
i
<
totalPageSize
;
i
++)
{
page
.
setSize
(
pageSize
);
Map
parserParams
=
new
HashMap
();
//全局参数设置
parserParams
.
put
(
COLUMN
,
column
);
Map
parserParams
=
new
HashMap
();
parserParams
.
put
(
TOTAL
,
totalPageSize
);
parserParams
.
put
(
COLUMN
,
column
);
parserParams
.
put
(
RCOUNT
,
pageSize
);
page
.
setTotal
(
totalPageSize
);
parserParams
.
put
(
TYPE_ID
,
column
.
getCategoryId
());
parserParams
.
put
(
IS_DO
,
false
);
parserParams
.
put
(
IS_DO
,
false
);
parserParams
.
put
(
HTML
,
HTML
);
parserParams
.
put
(
HTML
,
HTML
);
if
(
contentModel
!=
null
)
{
if
(
contentModel
!=
null
)
{
// 将自定义模型编号设置为key值
// 将自定义模型编号设置为key值
parserParams
.
put
(
TABLE_NAME
,
contentModel
.
getCmTableName
());
parserParams
.
put
(
TABLE_NAME
,
contentModel
.
getCmTableName
());
}
}
//如果单站点,就废弃站点地址
//如果单站点,就废弃站点地址
if
(
ParserUtil
.
IS_SINGLE
)
{
if
(
ParserUtil
.
IS_SINGLE
)
{
parserParams
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
parserParams
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
}
}
if
(
i
==
0
)
{
//文章列表页没有写文章列表标签,总数为0
// 数据库中第一页是从开始0*size
if
(
totalPageSize
<=
0
)
{
// 首页路径index.html
// 数据库中第一页是从开始0*size
mobilePath
=
ParserUtil
// 首页路径index.html
.
buildMobileHtmlPath
(
column
.
getColumnPath
()
+
File
.
separator
+
ParserUtil
.
INDEX
);
mobilePath
=
ParserUtil
.
buildMobileHtmlPath
(
column
.
getColumnPath
()
+
File
.
separator
+
ParserUtil
.
INDEX
);
columnListPath
=
ParserUtil
columnListPath
=
ParserUtil
.
buildHtmlPath
(
column
.
getColumnPath
()
+
File
.
separator
+
ParserUtil
.
INDEX
);
.
buildHtmlPath
(
column
.
getColumnPath
()
+
File
.
separator
+
ParserUtil
.
INDEX
);
// 设置分页的起始位置
}
else
{
page
.
setPageNo
(
pageNo
);
// 其他路径list-2.html
parserParams
.
put
(
ParserUtil
.
PAGE
,
page
);
mobilePath
=
ParserUtil
.
buildMobileHtmlPath
(
column
.
getColumnPath
()
+
File
.
separator
+
ParserUtil
.
PAGE_LIST
+
pageNo
);
columnListPath
=
ParserUtil
.
buildHtmlPath
(
column
.
getColumnPath
()
+
File
.
separator
+
ParserUtil
.
PAGE_LIST
+
pageNo
);
}
// 设置分页的起始位置
parserParams
.
put
(
PAGE_NO
,
pageNo
);
TagParser
tag
=
new
TagParser
(
content
,
parserParams
);
TagParser
tag
=
new
TagParser
(
content
,
parserParams
);
FileUtil
.
writeString
(
tag
.
rendering
(),
columnListPath
,
Const
.
UTF8
);
FileUtil
.
writeString
(
tag
.
rendering
(),
columnListPath
,
Const
.
UTF8
);
// 判断是手机端生成还是pc端,防止重复生成
if
(
ParserUtil
.
hasMobileFile
(
column
.
getColumnListUrl
()))
{
// 判断是手机端生成还是pc端,防止重复生成
writer
=
new
StringWriter
();
if
(
ParserUtil
.
hasMobileFile
(
column
.
getColumnListUrl
()))
{
mobileTemplate
.
process
(
null
,
writer
);
tag
=
new
TagParser
(
writer
.
toString
(),
parserParams
);
// 将tag.getContent()写入路径
FileUtil
.
writeString
(
tag
.
rendering
(),
mobilePath
,
Const
.
UTF8
);
}
writer
=
new
StringWriter
();
}
else
{
// 遍历分页
for
(
int
i
=
0
;
i
<
totalPageSize
;
i
++)
{
if
(
i
==
0
)
{
// 数据库中第一页是从开始0*size
// 首页路径index.html
mobilePath
=
ParserUtil
.
buildMobileHtmlPath
(
column
.
getColumnPath
()
+
File
.
separator
+
ParserUtil
.
INDEX
);
columnListPath
=
ParserUtil
.
buildHtmlPath
(
column
.
getColumnPath
()
+
File
.
separator
+
ParserUtil
.
INDEX
);
}
else
{
// 其他路径list-2.html
mobilePath
=
ParserUtil
.
buildMobileHtmlPath
(
column
.
getColumnPath
()
+
File
.
separator
+
ParserUtil
.
PAGE_LIST
+
pageNo
);
columnListPath
=
ParserUtil
.
buildHtmlPath
(
column
.
getColumnPath
()
+
File
.
separator
+
ParserUtil
.
PAGE_LIST
+
pageNo
);
}
// 设置分页的起始位置
page
.
setPageNo
(
pageNo
);
parserParams
.
put
(
ParserUtil
.
PAGE
,
page
);
TagParser
tag
=
new
TagParser
(
content
,
parserParams
);
FileUtil
.
writeString
(
tag
.
rendering
(),
columnListPath
,
Const
.
UTF8
);
// 判断是手机端生成还是pc端,防止重复生成
if
(
ParserUtil
.
hasMobileFile
(
column
.
getColumnListUrl
()))
{
writer
=
new
StringWriter
();
mobileTemplate
.
process
(
null
,
writer
);
tag
=
new
TagParser
(
writer
.
toString
(),
parserParams
);
// 将tag.getContent()写入路径
FileUtil
.
writeString
(
tag
.
rendering
(),
mobilePath
,
Const
.
UTF8
);
}
writer
=
new
StringWriter
();
writer
=
new
StringWriter
();
mobileTemplate
.
process
(
null
,
writer
);
pageNo
++;
tag
=
new
TagParser
(
writer
.
toString
(),
parserParams
);
}
// 将tag.getContent()写入路径
}
FileUtil
.
writeString
(
tag
.
rendering
(),
mobilePath
,
Const
.
UTF8
);
}
writer
=
new
StringWriter
();
pageNo
++;
}
}
catch
(
TemplateException
e
)
{
}
catch
(
TemplateException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -176,24 +194,26 @@ public class CmsParserUtil extends ParserUtil {
...
@@ -176,24 +194,26 @@ public class CmsParserUtil extends ParserUtil {
// 记录已经生成了文章编号
// 记录已经生成了文章编号
List
<
Integer
>
generateIds
=
new
ArrayList
<>();
List
<
Integer
>
generateIds
=
new
ArrayList
<>();
// 生成文档
// 生成文档
for
(
int
ai
=
0
;
ai
<
articleIdList
.
size
();)
{
for
(
int
artId
=
0
;
artId
<
articleIdList
.
size
();)
{
//设置分页类
PageBean
page
=
new
PageBean
();
// 文章编号
// 文章编号
int
articleId
=
articleIdList
.
get
(
a
i
).
getArticleId
();
int
articleId
=
articleIdList
.
get
(
a
rtId
).
getArticleId
();
// 文章的栏目路径
// 文章的栏目路径
String
articleColumnPath
=
articleIdList
.
get
(
a
i
).
getColumnPath
();
String
articleColumnPath
=
articleIdList
.
get
(
a
rtId
).
getColumnPath
();
// 文章的模板路径
// 文章的模板路径
String
columnUrl
=
articleIdList
.
get
(
a
i
).
getColumnUrl
();
String
columnUrl
=
articleIdList
.
get
(
a
rtId
).
getColumnUrl
();
// 文章的栏目模型编号
// 文章的栏目模型编号
int
columnContentModelId
=
articleIdList
.
get
(
a
i
).
getColumnContentModelId
();
int
columnContentModelId
=
articleIdList
.
get
(
a
rtId
).
getColumnContentModelId
();
// 文章是否已经生成了,生成了就跳过
// 文章是否已经生成了,生成了就跳过
if
(
generateIds
.
contains
(
articleId
))
{
if
(
generateIds
.
contains
(
articleId
))
{
a
i
++;
a
rtId
++;
continue
;
continue
;
}
}
// 判断文件是否存在,若不存在弹出返回信息
// 判断文件是否存在,若不存在弹出返回信息
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
columnUrl
)))
{
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
columnUrl
)))
{
a
i
++;
a
rtId
++;
continue
;
continue
;
}
}
// 将
// 将
...
@@ -201,10 +221,11 @@ public class CmsParserUtil extends ParserUtil {
...
@@ -201,10 +221,11 @@ public class CmsParserUtil extends ParserUtil {
// 组合文章路径如:html/站点id/栏目id/文章id.html
// 组合文章路径如:html/站点id/栏目id/文章id.html
writePath
=
ParserUtil
.
buildHtmlPath
(
articleColumnPath
+
File
.
separator
+
articleId
);
writePath
=
ParserUtil
.
buildHtmlPath
(
articleColumnPath
+
File
.
separator
+
articleId
);
//如果是封面就生成index.html
//如果是封面就生成index.html
if
(
articleIdList
.
get
(
a
i
).
getColumnType
()
==
ColumnTypeEnum
.
COLUMN_TYPE_COVER
.
toInt
())
{
if
(
articleIdList
.
get
(
a
rtId
).
getColumnType
()
==
ColumnTypeEnum
.
COLUMN_TYPE_COVER
.
toInt
())
{
writePath
=
ParserUtil
.
buildHtmlPath
(
articleColumnPath
+
File
.
separator
+
ParserUtil
.
INDEX
);
writePath
=
ParserUtil
.
buildHtmlPath
(
articleColumnPath
+
File
.
separator
+
ParserUtil
.
INDEX
);
}
}
Map
<
String
,
Object
>
parserParams
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
parserParams
=
new
HashMap
<
String
,
Object
>();
parserParams
.
put
(
ParserUtil
.
COLUMN
,
articleIdList
.
get
(
artId
));
// 判断当前栏目是否有自定义模型
// 判断当前栏目是否有自定义模型
if
(
columnContentModelId
>
0
)
{
if
(
columnContentModelId
>
0
)
{
// 通过当前栏目的模型编号获取,自定义模型表名
// 通过当前栏目的模型编号获取,自定义模型表名
...
@@ -222,43 +243,43 @@ public class CmsParserUtil extends ParserUtil {
...
@@ -222,43 +243,43 @@ public class CmsParserUtil extends ParserUtil {
parserParams
.
put
(
ID
,
articleId
);
parserParams
.
put
(
ID
,
articleId
);
// 第一篇文章没有上一篇
// 第一篇文章没有上一篇
if
(
a
i
>
0
)
{
if
(
a
rtId
>
0
)
{
ColumnArticleIdBean
preCaBean
=
articleIdList
.
get
(
a
i
-
1
);
ColumnArticleIdBean
preCaBean
=
articleIdList
.
get
(
a
rtId
-
1
);
//判断当前文档是否与上一页文章在同一栏目下,并且不能使用父栏目字符串,因为父栏目中没有所属栏目编号
//判断当前文档是否与上一页文章在同一栏目下,并且不能使用父栏目字符串,因为父栏目中没有所属栏目编号
if
(
articleColumnPath
.
contains
(
preCaBean
.
getCategoryId
()+
""
)){
if
(
articleColumnPath
.
contains
(
preCaBean
.
getCategoryId
()+
""
)){
pa
rserParams
.
put
(
PRE_ID
,
preCaBean
.
getArticleId
());
pa
ge
.
setPreId
(
preCaBean
.
getArticleId
());
}
}
}
}
// 最后一篇文章没有下一篇
// 最后一篇文章没有下一篇
if
(
a
i
+
1
<
articleIdList
.
size
())
{
if
(
a
rtId
+
1
<
articleIdList
.
size
())
{
ColumnArticleIdBean
nextCaBean
=
articleIdList
.
get
(
a
i
+
1
);
ColumnArticleIdBean
nextCaBean
=
articleIdList
.
get
(
a
rtId
+
1
);
//判断当前文档是否与下一页文章在同一栏目下并且不能使用父栏目字符串,因为父栏目中没有所属栏目编号
//判断当前文档是否与下一页文章在同一栏目下并且不能使用父栏目字符串,因为父栏目中没有所属栏目编号
if
(
articleColumnPath
.
contains
(
nextCaBean
.
getCategoryId
()+
""
)){
if
(
articleColumnPath
.
contains
(
nextCaBean
.
getCategoryId
()+
""
)){
pa
rserParams
.
put
(
NEXT_ID
,
nextCaBean
.
getArticleId
());
pa
ge
.
setNextId
(
nextCaBean
.
getArticleId
());
}
}
}
}
parserParams
.
put
(
IS_DO
,
false
);
parserParams
.
put
(
IS_DO
,
false
);
parserParams
.
put
(
ParserUtil
.
PAGE
,
page
);
String
content
=
CmsParserUtil
.
generate
(
articleIdList
.
get
(
a
i
).
getColumnUrl
(),
parserParams
,
false
);
String
content
=
CmsParserUtil
.
generate
(
articleIdList
.
get
(
a
rtId
).
getColumnUrl
(),
parserParams
,
false
);
FileUtil
.
writeString
(
content
,
writePath
,
Const
.
UTF8
);
FileUtil
.
writeString
(
content
,
writePath
,
Const
.
UTF8
);
// 手机端
// 手机端
if
(
ParserUtil
.
hasMobileFile
(
columnUrl
))
{
if
(
ParserUtil
.
hasMobileFile
(
columnUrl
))
{
writePath
=
ParserUtil
.
buildMobileHtmlPath
(
articleColumnPath
+
File
.
separator
+
articleId
);
writePath
=
ParserUtil
.
buildMobileHtmlPath
(
articleColumnPath
+
File
.
separator
+
articleId
);
//如果是封面就生成index.html
//如果是封面就生成index.html
if
(
articleIdList
.
get
(
a
i
).
getColumnType
()
==
ColumnTypeEnum
.
COLUMN_TYPE_COVER
.
toInt
())
{
if
(
articleIdList
.
get
(
a
rtId
).
getColumnType
()
==
ColumnTypeEnum
.
COLUMN_TYPE_COVER
.
toInt
())
{
writePath
=
ParserUtil
.
buildMobileHtmlPath
(
articleColumnPath
+
File
.
separator
+
ParserUtil
.
INDEX
);
writePath
=
ParserUtil
.
buildMobileHtmlPath
(
articleColumnPath
+
File
.
separator
+
ParserUtil
.
INDEX
);
}
}
// 判断文件是否存在,若不存在弹出返回信息
// 判断文件是否存在,若不存在弹出返回信息
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
MOBILE
+
File
.
separator
+
columnUrl
)))
{
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
MOBILE
+
File
.
separator
+
columnUrl
)))
{
a
i
++;
a
rtId
++;
continue
;
continue
;
}
}
parserParams
.
put
(
MOBILE
,
BasicUtil
.
getApp
().
getAppMobileStyle
());
parserParams
.
put
(
MOBILE
,
BasicUtil
.
getApp
().
getAppMobileStyle
());
content
=
CmsParserUtil
.
generate
(
articleIdList
.
get
(
a
i
).
getColumnUrl
(),
parserParams
,
true
);
content
=
CmsParserUtil
.
generate
(
articleIdList
.
get
(
a
rtId
).
getColumnUrl
(),
parserParams
,
true
);
FileUtil
.
writeString
(
content
,
writePath
,
Const
.
UTF8
);
FileUtil
.
writeString
(
content
,
writePath
,
Const
.
UTF8
);
}
}
a
i
++;
a
rtId
++;
}
}
}
}
}
}
Write
Preview
Supports
Markdown
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