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
fd764fdb
"src/main/java/vscode:/vscode.git/clone" did not exist on "5f1131639e7a50675229faff953d260ce64fd9e5"
Commit
fd764fdb
authored
Nov 28, 2020
by
guwd
Browse files
1、优化解析过程,分页size的获取方式采用正则
2、移除不需要的业务流程,提高解析效率
parent
631574fe
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
src/main/java/net/mingsoft/cms/action/GeneraterAction.java
View file @
fd764fdb
/**
/**
The MIT License (MIT) * Copyright (c) 2016 铭飞科技(mingsoft.net)
*
The MIT License (MIT) * Copyright (c) 2016 铭飞科技(mingsoft.net)
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* 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
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
* subject to the following conditions:
* <p>
* The above copyright notice and this permission notice shall be included in all
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* copies or substantial portions of the Software.
* <p>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
...
@@ -140,7 +140,6 @@ public class GeneraterAction extends BaseAction {
...
@@ -140,7 +140,6 @@ public class GeneraterAction extends BaseAction {
}
}
/**
/**
* 生成列表的静态页面
* 生成列表的静态页面
*
*
...
@@ -155,54 +154,48 @@ public class GeneraterAction extends BaseAction {
...
@@ -155,54 +154,48 @@ public class GeneraterAction extends BaseAction {
public
ResultData
genernateColumn
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
categoryId
)
throws
IOException
{
public
ResultData
genernateColumn
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
categoryId
)
throws
IOException
{
// 获取站点id
// 获取站点id
AppEntity
app
=
BasicUtil
.
getApp
();
AppEntity
app
=
BasicUtil
.
getApp
();
//栏目列表
List
<
CategoryEntity
>
columns
=
new
ArrayList
<
CategoryEntity
>();
List
<
CategoryEntity
>
columns
=
new
ArrayList
<
CategoryEntity
>();
// 如果栏目id小于0则更新所有的栏目,否则只更新选中的栏目
if
(!
"0"
.
equals
(
categoryId
))
{
if
(
"0"
.
equals
(
categoryId
))
{
// 0更新所有栏目
CategoryEntity
categoryEntity
=
new
CategoryEntity
();
columns
=
categoryBiz
.
query
(
categoryEntity
);
}
else
{
//选择栏目更新
CategoryEntity
categoryEntity
=
new
CategoryEntity
();
CategoryEntity
categoryEntity
=
new
CategoryEntity
();
categoryEntity
.
setId
(
categoryId
);
categoryEntity
.
setId
(
categoryId
);
columns
=
categoryBiz
.
queryChilds
(
categoryEntity
);
columns
=
categoryBiz
.
queryChilds
(
categoryEntity
);
}
else
{
// 获取所有的内容管理栏目
CategoryEntity
categoryEntity
=
new
CategoryEntity
();
columns
=
categoryBiz
.
query
(
categoryEntity
);
}
}
//文章列表
List
<
CategoryBean
>
articleIdList
=
null
;
List
<
CategoryBean
>
articleIdList
=
null
;
// 1、设置模板文件夹路径
// 获取栏目列表模版
// 获取栏目列表模版
for
(
CategoryEntity
column
:
columns
)
{
for
(
CategoryEntity
column
:
columns
)
{
ContentBean
contentBean
=
new
ContentBean
();
ContentBean
contentBean
=
new
ContentBean
();
contentBean
.
setCategoryId
(
column
.
getId
());
contentBean
.
setCategoryId
(
column
.
getId
());
// 分类是列表
if
(
column
.
getCategoryType
().
equals
(
"1"
))
{
// 判断模板文件是否存在
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_ID
,
BasicUtil
.
getWebsiteApp
().
getAppId
());
}
PageBean
page
=
new
PageBean
();
map
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
PAGE
,
page
);
}
articleIdList
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
articleIdList
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
// 判断列表类型
// 判断列表类型
switch
(
column
.
getCategoryType
())
{
switch
(
column
.
getCategoryType
())
{
//TODO 暂时先用字符串代替
//TODO 暂时先用字符串代替
case
"1"
:
// 列表
case
"1"
:
// 列表
// 判断模板文件是否存在
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
column
.
getCategoryListUrl
())))
{
LOG
.
error
(
"模板不存在:{}"
,
column
.
getCategoryUrl
());
continue
;
}
CmsParserUtil
.
generateList
(
column
,
articleIdList
.
size
());
CmsParserUtil
.
generateList
(
column
,
articleIdList
.
size
());
break
;
break
;
case
"2"
:
// 单页
case
"2"
:
// 单页
if
(
articleIdList
.
size
()==
0
){
if
(
articleIdList
.
size
()
==
0
)
{
CategoryBean
columnArticleIdBean
=
new
CategoryBean
();
CategoryBean
columnArticleIdBean
=
new
CategoryBean
();
CopyOptions
copyOptions
=
CopyOptions
.
create
();
CopyOptions
copyOptions
=
CopyOptions
.
create
();
copyOptions
.
setIgnoreError
(
true
);
copyOptions
.
setIgnoreError
(
true
);
BeanUtil
.
copyProperties
(
column
,
columnArticleIdBean
,
copyOptions
);
BeanUtil
.
copyProperties
(
column
,
columnArticleIdBean
,
copyOptions
);
articleIdList
.
add
(
columnArticleIdBean
);
articleIdList
.
add
(
columnArticleIdBean
);
}
}
CmsParserUtil
.
generateBasic
(
articleIdList
);
CmsParserUtil
.
generateBasic
(
articleIdList
);
...
@@ -232,7 +225,7 @@ public class GeneraterAction extends BaseAction {
...
@@ -232,7 +225,7 @@ public class GeneraterAction extends BaseAction {
ContentBean
contentBean
=
new
ContentBean
();
ContentBean
contentBean
=
new
ContentBean
();
contentBean
.
setBeginTime
(
dateTime
);
contentBean
.
setBeginTime
(
dateTime
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
if
(
BasicUtil
.
getWebsiteApp
()
!=
null
){
if
(
BasicUtil
.
getWebsiteApp
()
!=
null
)
{
map
.
put
(
ParserUtil
.
APP_ID
,
BasicUtil
.
getWebsiteApp
().
getAppId
());
map
.
put
(
ParserUtil
.
APP_ID
,
BasicUtil
.
getWebsiteApp
().
getAppId
());
}
}
PageBean
page
=
new
PageBean
();
PageBean
page
=
new
PageBean
();
...
@@ -240,16 +233,16 @@ public class GeneraterAction extends BaseAction {
...
@@ -240,16 +233,16 @@ public class GeneraterAction extends BaseAction {
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
PAGE
,
page
);
map
.
put
(
ParserUtil
.
PAGE
,
page
);
// 生成所有栏目的文章
// 生成所有栏目的文章
if
(
"0"
.
equals
(
columnId
)){
if
(
"0"
.
equals
(
columnId
))
{
CategoryEntity
categoryEntity
=
new
CategoryEntity
();
CategoryEntity
categoryEntity
=
new
CategoryEntity
();
categoryList
=
categoryBiz
.
query
(
categoryEntity
);
categoryList
=
categoryBiz
.
query
(
categoryEntity
);
for
(
CategoryEntity
category
:
categoryList
){
for
(
CategoryEntity
category
:
categoryList
)
{
contentBean
.
setCategoryId
(
category
.
getId
());
contentBean
.
setCategoryId
(
category
.
getId
());
// 分类是列表
// 分类是列表
if
(
category
.
getCategoryType
().
equals
(
"1"
)){
if
(
category
.
getCategoryType
().
equals
(
"1"
))
{
// 判断模板文件是否存在
// 判断模板文件是否存在
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
category
.
getCategoryListUrl
()))
||
StringUtils
.
isEmpty
(
category
.
getCategoryListUrl
()))
{
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
category
.
getCategoryListUrl
()))
||
StringUtils
.
isEmpty
(
category
.
getCategoryListUrl
()))
{
LOG
.
error
(
"模板不存在:{}"
,
category
.
getCategoryUrl
());
LOG
.
error
(
"模板不存在:{}"
,
category
.
getCategoryUrl
());
continue
;
continue
;
}
}
...
@@ -261,15 +254,15 @@ public class GeneraterAction extends BaseAction {
...
@@ -261,15 +254,15 @@ public class GeneraterAction extends BaseAction {
CmsParserUtil
.
generateBasic
(
articleIdList
);
CmsParserUtil
.
generateBasic
(
articleIdList
);
}
}
}
}
}
else
{
}
else
{
CategoryEntity
category
=
(
CategoryEntity
)
categoryBiz
.
getById
(
columnId
);
CategoryEntity
category
=
(
CategoryEntity
)
categoryBiz
.
getById
(
columnId
);
contentBean
.
setCategoryId
(
columnId
);
contentBean
.
setCategoryId
(
columnId
);
// 分类是列表
// 分类是列表
if
(
category
.
getCategoryType
().
equals
(
"1"
)){
if
(
category
.
getCategoryType
().
equals
(
"1"
))
{
// 获取文章列表表属性
// 获取文章列表表属性
// 判断模板文件是否存在
// 判断模板文件是否存在
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
category
.
getCategoryUrl
())))
{
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
category
.
getCategoryUrl
())))
{
LOG
.
error
(
"模板不存在:{}"
,
category
.
getCategoryUrl
());
LOG
.
error
(
"模板不存在:{}"
,
category
.
getCategoryUrl
());
return
ResultData
.
build
().
error
(
getResString
(
"templet.file"
));
return
ResultData
.
build
().
error
(
getResString
(
"templet.file"
));
}
}
}
}
...
@@ -283,7 +276,6 @@ public class GeneraterAction extends BaseAction {
...
@@ -283,7 +276,6 @@ public class GeneraterAction extends BaseAction {
}
}
/**
/**
* 用户预览主页
* 用户预览主页
*
*
...
...
src/main/java/net/mingsoft/cms/action/web/MCmsAction.java
View file @
fd764fdb
This diff is collapsed.
Click to expand it.
src/main/java/net/mingsoft/cms/bean/ContentBean.java
View file @
fd764fdb
...
@@ -37,13 +37,7 @@ public class ContentBean extends ContentEntity {
...
@@ -37,13 +37,7 @@ public class ContentBean extends ContentEntity {
*/
*/
private
String
noflag
;
private
String
noflag
;
// public String getStaticUrl() {
// return staticUrl;
// }
//
// public void setStaticUrl(String staticUrl) {
// this.staticUrl = staticUrl;
// }
public
String
getBeginTime
()
{
public
String
getBeginTime
()
{
return
beginTime
;
return
beginTime
;
...
...
src/main/java/net/mingsoft/cms/biz/impl/ContentBizImpl.java
View file @
fd764fdb
...
@@ -229,7 +229,7 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
...
@@ -229,7 +229,7 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
if
(
BasicUtil
.
getWebsiteApp
()
!=
null
){
if
(
BasicUtil
.
getWebsiteApp
()
!=
null
){
map
.
put
(
ParserUtil
.
APP_ID
,
BasicUtil
.
getWebsiteApp
().
getAppId
());
map
.
put
(
ParserUtil
.
APP_ID
,
BasicUtil
.
getWebsiteApp
().
getAppId
());
}
}
String
read
=
ParserUtil
.
re
ad
(
templatePath
,
map
);
String
read
=
ParserUtil
.
re
ndering
(
templatePath
,
map
);
FileUtil
.
writeString
(
read
,
ParserUtil
.
buildHtmlPath
(
targetPath
),
net
.
mingsoft
.
base
.
constant
.
Const
.
UTF8
);
FileUtil
.
writeString
(
read
,
ParserUtil
.
buildHtmlPath
(
targetPath
),
net
.
mingsoft
.
base
.
constant
.
Const
.
UTF8
);
}
}
...
...
src/main/java/net/mingsoft/cms/util/CmsParserUtil.java
View file @
fd764fdb
...
@@ -71,25 +71,36 @@ public class CmsParserUtil extends ParserUtil {
...
@@ -71,25 +71,36 @@ public class CmsParserUtil extends ParserUtil {
throws
TemplateNotFoundException
,
MalformedTemplateNameException
,
ParseException
,
IOException
{
throws
TemplateNotFoundException
,
MalformedTemplateNameException
,
ParseException
,
IOException
{
try
{
try
{
// 文章的栏目模型编号
// 文章的栏目模型编号
Integer
columnContentModelId
=
column
.
getMdiyModelId
();
PageBean
page
=
new
PageBean
();
PageBean
page
=
new
PageBean
();
page
.
setSize
(
10
);
//获取分页数量
//获取列表页显示的文章数量
//获取列表中的size
//获取总数
page
.
setSize
(
ParserUtil
.
getPageSize
(
column
.
getCategoryListUrl
(),
20
));
page
.
setRcount
(
articleIdTotal
);
int
totalPageSize
=
PageUtil
.
totalPage
(
articleIdTotal
,
page
.
getSize
());
page
.
setTotal
(
totalPageSize
);
//获取模板中列表标签中的条件
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
if
(
BasicUtil
.
getWebsiteApp
()
!=
null
)
{
map
.
put
(
ParserUtil
.
APP_ID
,
BasicUtil
.
getWebsiteApp
().
getAppId
());
}
map
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
PAGE
,
page
);
String
columnListPath
;
String
columnListPath
;
ModelEntity
contentModel
=
null
;
ModelEntity
contentModel
=
null
;
// 判断当前栏目是否有自定义模型
// 判断当前栏目是否有自定义模型
if
(
column
Content
ModelId
!=
null
)
{
if
(
column
.
getMdiy
ModelId
()
!=
null
)
{
// 通过栏目模型编号获取自定义模型实体
// 通过栏目模型编号获取自定义模型实体
contentModel
=
(
ModelEntity
)
SpringUtil
.
getBean
(
ModelBizImpl
.
class
).
getEntity
(
column
Content
ModelId
);
contentModel
=
(
ModelEntity
)
SpringUtil
.
getBean
(
ModelBizImpl
.
class
).
getEntity
(
column
.
getMdiy
ModelId
()
);
}
}
int
pageNo
=
1
;
//全局参数设置
//全局参数设置
Map
<
String
,
Object
>
parserParams
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
parserParams
=
new
HashMap
<
String
,
Object
>();
parserParams
.
put
(
ParserUtil
.
PAGE
,
page
);
parserParams
.
put
(
COLUMN
,
column
);
parserParams
.
put
(
COLUMN
,
column
);
//标签中使用field获取当前栏目
//标签中使用field获取当前栏目
parserParams
.
put
(
FIELD
,
column
);
parserParams
.
put
(
FIELD
,
column
);
...
@@ -106,17 +117,15 @@ public class CmsParserUtil extends ParserUtil {
...
@@ -106,17 +117,15 @@ public class CmsParserUtil extends ParserUtil {
if
(
ParserUtil
.
IS_SINGLE
)
{
if
(
ParserUtil
.
IS_SINGLE
)
{
parserParams
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
parserParams
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
}
}
parserParams
.
put
(
ParserUtil
.
PAGE
,
page
);
ParserUtil
.
read
(
File
.
separator
+
column
.
getCategoryListUrl
(),
parserParams
,
page
);
int
pageNo
=
1
;
int
totalPageSize
=
PageUtil
.
totalPage
(
articleIdTotal
,
page
.
getSize
());
page
.
setTotal
(
totalPageSize
);
//文章列表页没有写文章列表标签,总数为0
//文章列表页没有写文章列表标签,总数为0
if
(
totalPageSize
<=
0
)
{
if
(
totalPageSize
<=
0
)
{
// 数据库中第一页是从开始0*size
// 数据库中第一页是从开始0*size
columnListPath
=
ParserUtil
.
buildHtmlPath
(
column
.
getCategoryPath
()
+
File
.
separator
+
ParserUtil
.
INDEX
);
columnListPath
=
ParserUtil
.
buildHtmlPath
(
column
.
getCategoryPath
()
+
File
.
separator
+
ParserUtil
.
INDEX
);
// 设置分页的起始位置
// 设置分页的起始位置
page
.
setPageNo
(
pageNo
);
page
.
setPageNo
(
pageNo
);
String
read
=
ParserUtil
.
re
ad
(
File
.
separator
+
column
.
getCategoryListUrl
(),
parserParams
);
String
read
=
ParserUtil
.
re
ndering
(
File
.
separator
+
column
.
getCategoryListUrl
(),
parserParams
);
FileUtil
.
writeString
(
read
,
columnListPath
,
Const
.
UTF8
);
FileUtil
.
writeString
(
read
,
columnListPath
,
Const
.
UTF8
);
}
else
{
}
else
{
...
@@ -134,7 +143,7 @@ public class CmsParserUtil extends ParserUtil {
...
@@ -134,7 +143,7 @@ public class CmsParserUtil extends ParserUtil {
}
}
// 设置分页的起始位置
// 设置分页的起始位置
page
.
setPageNo
(
pageNo
);
page
.
setPageNo
(
pageNo
);
String
read
=
ParserUtil
.
re
ad
(
File
.
separator
+
column
.
getCategoryListUrl
(),
parserParams
);
String
read
=
ParserUtil
.
re
ndering
(
File
.
separator
+
column
.
getCategoryListUrl
(),
parserParams
);
FileUtil
.
writeString
(
read
,
columnListPath
,
Const
.
UTF8
);
FileUtil
.
writeString
(
read
,
columnListPath
,
Const
.
UTF8
);
pageNo
++;
pageNo
++;
}
}
...
...
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