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
096d6f2b
"...src/main/git@ustchcs.com:gujinli1118/eladmin.git" did not exist on "3d53a3a0ec6d485171930f4f5cafbaee47b395b2"
Commit
096d6f2b
authored
Dec 03, 2020
by
guwd
Browse files
1、优化列表、封面枚举类型,原来是 1,2表示
2、优化搜索接口
parent
871245ee
Changes
13
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
096d6f2b
...
@@ -39,29 +39,6 @@
...
@@ -39,29 +39,6 @@
<artifactId>
ms-mpeople
</artifactId>
<artifactId>
ms-mpeople
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
net.mingsoft
</groupId>
<artifactId>
ms-ad
</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>net.mingsoft</groupId>-->
<!-- <artifactId>ms-clean</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>net.mingsoft</groupId>-->
<!-- <artifactId>ms-quartz</artifactId>-->
<!-- </dependency>-->
<!-- 此部分是铭飞平台MStroe的客户端(MStore不在铭飞开源产品范围),如果不需要使用MStore可以删除掉 -->
<dependency>
<groupId>
net.mingsoft
</groupId>
<artifactId>
store-client
</artifactId>
<version>
5.2-SNAPSHOT
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
src/main/java/net/mingsoft/cms/action/CategoryAction.java
View file @
096d6f2b
...
@@ -163,7 +163,7 @@ public class CategoryAction extends BaseAction {
...
@@ -163,7 +163,7 @@ public class CategoryAction extends BaseAction {
if
(!
StringUtil
.
checkLength
(
category
.
getCategoryPath
()+
""
,
1
,
100
)){
if
(!
StringUtil
.
checkLength
(
category
.
getCategoryPath
()+
""
,
1
,
100
)){
return
ResultData
.
build
().
error
(
getResString
(
"err.length"
,
this
.
getResString
(
"category.path"
),
"1"
,
"100"
));
return
ResultData
.
build
().
error
(
getResString
(
"err.length"
,
this
.
getResString
(
"category.path"
),
"1"
,
"100"
));
}
}
if
(!
StringUtil
.
checkLength
(
category
.
getCategoryParentId
()+
""
,
1
,
100
)){
if
(!
StringUtil
.
checkLength
(
category
.
getCategoryParentId
s
()+
""
,
1
,
100
)){
return
ResultData
.
build
().
error
(
getResString
(
"err.length"
,
this
.
getResString
(
"category.parent.id"
),
"1"
,
"100"
));
return
ResultData
.
build
().
error
(
getResString
(
"err.length"
,
this
.
getResString
(
"category.parent.id"
),
"1"
,
"100"
));
}
}
//判断拼音是否重复
//判断拼音是否重复
...
@@ -241,7 +241,7 @@ public class CategoryAction extends BaseAction {
...
@@ -241,7 +241,7 @@ public class CategoryAction extends BaseAction {
if
(!
StringUtil
.
checkLength
(
category
.
getCategoryPath
()+
""
,
0
,
100
)){
if
(!
StringUtil
.
checkLength
(
category
.
getCategoryPath
()+
""
,
0
,
100
)){
return
ResultData
.
build
().
error
(
getResString
(
"err.length"
,
this
.
getResString
(
"category.path"
),
"1"
,
"100"
));
return
ResultData
.
build
().
error
(
getResString
(
"err.length"
,
this
.
getResString
(
"category.path"
),
"1"
,
"100"
));
}
}
if
(!
StringUtil
.
checkLength
(
category
.
getCategoryParentId
()+
""
,
0
,
100
)){
if
(!
StringUtil
.
checkLength
(
category
.
getCategoryParentId
s
()+
""
,
0
,
100
)){
return
ResultData
.
build
().
error
(
getResString
(
"err.length"
,
this
.
getResString
(
"category.parent.id"
),
"1"
,
"100"
));
return
ResultData
.
build
().
error
(
getResString
(
"err.length"
,
this
.
getResString
(
"category.parent.id"
),
"1"
,
"100"
));
}
}
//判断拼音是否重复并且是否和原拼音相同
//判断拼音是否重复并且是否和原拼音相同
...
@@ -268,7 +268,7 @@ public class CategoryAction extends BaseAction {
...
@@ -268,7 +268,7 @@ public class CategoryAction extends BaseAction {
}
}
//判断是否选择子级为所属栏目
//判断是否选择子级为所属栏目
CategoryEntity
_category
=
new
CategoryEntity
();
CategoryEntity
_category
=
new
CategoryEntity
();
_category
.
setCategoryParentId
(
category
.
getId
());
_category
.
setCategoryParentId
s
(
category
.
getId
());
List
<
CategoryEntity
>
categoryList
=
categoryBiz
.
queryChilds
(
_category
);
List
<
CategoryEntity
>
categoryList
=
categoryBiz
.
queryChilds
(
_category
);
for
(
CategoryEntity
item:
categoryList
){
for
(
CategoryEntity
item:
categoryList
){
if
(
item
.
getId
().
equals
(
category
.
getCategoryId
())){
if
(
item
.
getId
().
equals
(
category
.
getCategoryId
())){
...
@@ -302,7 +302,7 @@ public class CategoryAction extends BaseAction {
...
@@ -302,7 +302,7 @@ public class CategoryAction extends BaseAction {
return
ResultData
.
build
().
error
(
getResString
(
"err.error"
,
this
.
getResString
(
"id"
)));
return
ResultData
.
build
().
error
(
getResString
(
"err.error"
,
this
.
getResString
(
"id"
)));
}
}
category
=
categoryBiz
.
getById
(
category
.
getId
());
category
=
categoryBiz
.
getById
(
category
.
getId
());
category
.
setCategoryParentId
(
null
);
category
.
setCategoryParentId
s
(
null
);
List
<
CategoryEntity
>
childs
=
categoryBiz
.
queryChilds
(
category
);
List
<
CategoryEntity
>
childs
=
categoryBiz
.
queryChilds
(
category
);
//更新与父节点相同类型的子栏目的模板内容
//更新与父节点相同类型的子栏目的模板内容
for
(
int
i
=
0
;
i
<
childs
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
childs
.
size
();
i
++)
{
...
...
src/main/java/net/mingsoft/cms/action/GeneraterAction.java
View file @
096d6f2b
...
@@ -36,6 +36,7 @@ import net.mingsoft.cms.bean.CategoryBean;
...
@@ -36,6 +36,7 @@ import net.mingsoft.cms.bean.CategoryBean;
import
net.mingsoft.cms.bean.ContentBean
;
import
net.mingsoft.cms.bean.ContentBean
;
import
net.mingsoft.cms.biz.ICategoryBiz
;
import
net.mingsoft.cms.biz.ICategoryBiz
;
import
net.mingsoft.cms.biz.IContentBiz
;
import
net.mingsoft.cms.biz.IContentBiz
;
import
net.mingsoft.cms.constant.e.CategoryTypeEnum
;
import
net.mingsoft.cms.entity.CategoryEntity
;
import
net.mingsoft.cms.entity.CategoryEntity
;
import
net.mingsoft.cms.util.CmsParserUtil
;
import
net.mingsoft.cms.util.CmsParserUtil
;
import
net.mingsoft.mdiy.bean.PageBean
;
import
net.mingsoft.mdiy.bean.PageBean
;
...
@@ -178,9 +179,9 @@ public class GeneraterAction extends BaseAction {
...
@@ -178,9 +179,9 @@ public class GeneraterAction extends BaseAction {
articleIdList
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
articleIdList
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
// 判断列表类型
// 判断列表类型
switch
(
column
.
getCategoryType
())
{
switch
(
CategoryTypeEnum
.
get
(
column
.
getCategoryType
())
)
{
//TODO 暂时先用字符串代替
//TODO 暂时先用字符串代替
case
"1"
:
// 列表
case
LIST
:
// 列表
// 判断模板文件是否存在
// 判断模板文件是否存在
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
column
.
getCategoryListUrl
())))
{
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
column
.
getCategoryListUrl
())))
{
...
@@ -190,7 +191,7 @@ public class GeneraterAction extends BaseAction {
...
@@ -190,7 +191,7 @@ public class GeneraterAction extends BaseAction {
CmsParserUtil
.
generateList
(
column
,
articleIdList
.
size
(),
htmlDir
);
CmsParserUtil
.
generateList
(
column
,
articleIdList
.
size
(),
htmlDir
);
break
;
break
;
case
"2"
:
// 单页
case
COVER
:
// 单页
if
(
articleIdList
.
size
()
==
0
)
{
if
(
articleIdList
.
size
()
==
0
)
{
CategoryBean
columnArticleIdBean
=
new
CategoryBean
();
CategoryBean
columnArticleIdBean
=
new
CategoryBean
();
CopyOptions
copyOptions
=
CopyOptions
.
create
();
CopyOptions
copyOptions
=
CopyOptions
.
create
();
...
@@ -235,7 +236,7 @@ public class GeneraterAction extends BaseAction {
...
@@ -235,7 +236,7 @@ public class GeneraterAction extends BaseAction {
// 生成所有栏目的文章
// 生成所有栏目的文章
if
(
"0"
.
equals
(
columnId
))
{
if
(
"0"
.
equals
(
columnId
))
{
categoryList
=
categoryBiz
.
list
(
Wrappers
.<
CategoryEntity
>
lambdaQuery
()
categoryList
=
categoryBiz
.
list
(
Wrappers
.<
CategoryEntity
>
lambdaQuery
()
.
isNull
(
CategoryEntity:
:
getCategoryParentId
));
.
isNull
(
CategoryEntity:
:
getCategoryParentId
s
));
}
else
{
}
else
{
CategoryEntity
category
=
(
CategoryEntity
)
categoryBiz
.
getById
(
columnId
);
CategoryEntity
category
=
(
CategoryEntity
)
categoryBiz
.
getById
(
columnId
);
categoryList
.
add
(
category
);
categoryList
.
add
(
category
);
...
@@ -246,13 +247,13 @@ public class GeneraterAction extends BaseAction {
...
@@ -246,13 +247,13 @@ public class GeneraterAction extends BaseAction {
//将文章列表标签中的中的参数
//将文章列表标签中的中的参数
articleIdList
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
articleIdList
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
// 分类是列表
// 分类是列表
if
(
category
.
getCategoryType
().
equals
(
"1"
))
{
if
(
category
.
getCategoryType
().
equals
(
CategoryTypeEnum
.
LIST
.
toString
()
))
{
// 判断模板文件是否存在
// 判断模板文件是否存在
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
;
}
}
}
else
if
(
category
.
getCategoryType
().
equals
(
"2"
))
{
}
else
if
(
category
.
getCategoryType
().
equals
(
CategoryTypeEnum
.
COVER
.
toString
()
))
{
CategoryBean
columnArticleIdBean
=
new
CategoryBean
();
CategoryBean
columnArticleIdBean
=
new
CategoryBean
();
CopyOptions
copyOptions
=
CopyOptions
.
create
();
CopyOptions
copyOptions
=
CopyOptions
.
create
();
copyOptions
.
setIgnoreError
(
true
);
copyOptions
.
setIgnoreError
(
true
);
...
...
src/main/java/net/mingsoft/cms/action/web/MCmsAction.java
View file @
096d6f2b
...
@@ -21,8 +21,12 @@
...
@@ -21,8 +21,12 @@
package
net.mingsoft.cms.action.web
;
package
net.mingsoft.cms.action.web
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.lang.Editor
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.PageUtil
;
import
cn.hutool.core.util.PageUtil
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
freemarker.core.ParseException
;
import
freemarker.core.ParseException
;
import
freemarker.template.MalformedTemplateNameException
;
import
freemarker.template.MalformedTemplateNameException
;
import
freemarker.template.TemplateException
;
import
freemarker.template.TemplateException
;
...
@@ -36,6 +40,7 @@ import net.mingsoft.cms.bean.CategoryBean;
...
@@ -36,6 +40,7 @@ import net.mingsoft.cms.bean.CategoryBean;
import
net.mingsoft.cms.bean.ContentBean
;
import
net.mingsoft.cms.bean.ContentBean
;
import
net.mingsoft.cms.biz.ICategoryBiz
;
import
net.mingsoft.cms.biz.ICategoryBiz
;
import
net.mingsoft.cms.biz.IContentBiz
;
import
net.mingsoft.cms.biz.IContentBiz
;
import
net.mingsoft.cms.constant.e.CategoryTypeEnum
;
import
net.mingsoft.cms.entity.CategoryEntity
;
import
net.mingsoft.cms.entity.CategoryEntity
;
import
net.mingsoft.cms.entity.ContentEntity
;
import
net.mingsoft.cms.entity.ContentEntity
;
import
net.mingsoft.cms.util.CmsParserUtil
;
import
net.mingsoft.cms.util.CmsParserUtil
;
...
@@ -45,6 +50,7 @@ import net.mingsoft.mdiy.biz.IPageBiz;
...
@@ -45,6 +50,7 @@ import net.mingsoft.mdiy.biz.IPageBiz;
import
net.mingsoft.mdiy.entity.ModelEntity
;
import
net.mingsoft.mdiy.entity.ModelEntity
;
import
net.mingsoft.mdiy.util.ParserUtil
;
import
net.mingsoft.mdiy.util.ParserUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.shiro.util.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
...
@@ -126,7 +132,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -126,7 +132,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
String
content
=
""
;
String
content
=
""
;
try
{
try
{
//根据模板路径,参数生成
//根据模板路径,参数生成
content
=
CmsParserUtil
.
generate
(
ParserUtil
.
INDEX
+
ParserUtil
.
HTM_SUFFIX
,
map
,
htmlDir
);
content
=
CmsParserUtil
.
generate
(
ParserUtil
.
INDEX
+
ParserUtil
.
HTM_SUFFIX
,
map
,
htmlDir
);
}
catch
(
TemplateNotFoundException
e
)
{
}
catch
(
TemplateNotFoundException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
MalformedTemplateNameException
e
)
{
}
catch
(
MalformedTemplateNameException
e
)
{
...
@@ -184,7 +190,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -184,7 +190,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
String
content
=
""
;
String
content
=
""
;
try
{
try
{
//根据模板路径,参数生成
//根据模板路径,参数生成
content
=
CmsParserUtil
.
generate
(
columnArticles
.
get
(
0
).
getCategoryListUrl
(),
map
,
htmlDir
);
content
=
CmsParserUtil
.
generate
(
columnArticles
.
get
(
0
).
getCategoryListUrl
(),
map
,
htmlDir
);
}
catch
(
TemplateNotFoundException
e
)
{
}
catch
(
TemplateNotFoundException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
MalformedTemplateNameException
e
)
{
}
catch
(
MalformedTemplateNameException
e
)
{
...
@@ -252,8 +258,8 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -252,8 +258,8 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
}
}
// 文章的栏目路径
// 文章的栏目路径
String
categoryParentId
=
articleIdList
.
get
(
artId
).
getId
();
String
categoryParentId
=
articleIdList
.
get
(
artId
).
getId
();
if
(
StringUtils
.
isNotBlank
(
articleIdList
.
get
(
artId
).
getCategoryParentId
()))
{
if
(
StringUtils
.
isNotBlank
(
articleIdList
.
get
(
artId
).
getCategoryParentId
s
()))
{
categoryParentId
+=
','
+
articleIdList
.
get
(
artId
).
getCategoryParentId
();
categoryParentId
+=
','
+
articleIdList
.
get
(
artId
).
getCategoryParentId
s
();
}
}
// 文章的栏目模型编号
// 文章的栏目模型编号
Integer
columnContentModelId
=
articleIdList
.
get
(
artId
).
getMdiyModelId
();
Integer
columnContentModelId
=
articleIdList
.
get
(
artId
).
getMdiyModelId
();
...
@@ -286,7 +292,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -286,7 +292,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
}
}
try
{
try
{
//根据模板路径,参数生成
//根据模板路径,参数生成
content
=
CmsParserUtil
.
generate
(
column
.
getCategoryUrl
(),
map
,
htmlDir
);
content
=
CmsParserUtil
.
generate
(
column
.
getCategoryUrl
(),
map
,
htmlDir
);
}
catch
(
TemplateNotFoundException
e
)
{
}
catch
(
TemplateNotFoundException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
MalformedTemplateNameException
e
)
{
}
catch
(
MalformedTemplateNameException
e
)
{
...
@@ -311,7 +317,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -311,7 +317,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
public
String
search
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
String
search
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
//设置分页类
//设置分页类
PageBean
page
=
new
PageBean
();
PageBean
page
=
new
PageBean
();
page
.
setSize
(
ParserUtil
.
getPageSize
(
SEARCH
+
ParserUtil
.
HTM_SUFFIX
,
20
));
page
.
setSize
(
ParserUtil
.
getPageSize
(
SEARCH
+
ParserUtil
.
HTM_SUFFIX
,
20
));
//参数集合,提供给解析使用
//参数集合,提供给解析使用
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
...
@@ -336,15 +342,33 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -336,15 +342,33 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
//获取栏目信息
//获取栏目信息
int
typeId
=
0
;
int
typeId
=
0
;
String
categoryIds
=
BasicUtil
.
getString
(
"categoryIds"
);
String
categoryIds
=
BasicUtil
.
getString
(
"categoryIds"
);
List
categoryIdList
=
CollectionUtil
.
newArrayList
();
//当传递了栏目编号,但不是栏目集合
//当传递了栏目编号,但不是栏目集合
if
(
StringUtils
.
isNotBlank
(
categoryIds
)
&&
!
categoryIds
.
contains
(
","
))
{
if
(
StringUtils
.
isNotBlank
(
categoryIds
)
&&
!
categoryIds
.
contains
(
","
))
{
typeId
=
Integer
.
parseInt
(
categoryIds
);
typeId
=
Integer
.
parseInt
(
categoryIds
);
}
else
{
//取出所有的子栏目
String
[]
ids
=
categoryIds
.
split
(
","
);
List
<
CategoryEntity
>
categoryList
=
categoryBiz
.
list
(
Wrappers
.<
CategoryEntity
>
lambdaQuery
().
ne
(
CategoryEntity:
:
getCategoryType
,
CategoryTypeEnum
.
LINK
.
toString
()));
categoryIdList
=
CollectionUtil
.
newArrayList
(
ids
);
for
(
CategoryEntity
c:
categoryList
)
{
if
(
StringUtils
.
isNotEmpty
(
c
.
getParentids
()))
{
for
(
String
id:
ids
)
{
if
(
c
.
getParentids
().
indexOf
(
id
)>-
1
)
{
categoryIdList
.
add
(
c
.
getId
());
break
;
}
}
}
}
}
}
//重新组织 ID
categoryIds
=
StringUtils
.
join
(
categoryIdList
,
","
);
//当前访问的项目地址
//当前访问的项目地址
String
url
=
BasicUtil
.
getUrl
();
String
url
=
BasicUtil
.
getUrl
();
//根据栏目确定自定义模型
//根据栏目确定自定义模型
if
(
typeId
>
0
)
{
if
(
typeId
>
0
)
{
column
=
(
CategoryEntity
)
categoryBiz
.
getEntity
(
typeId
);
column
=
(
CategoryEntity
)
categoryBiz
.
getEntity
(
typeId
);
...
@@ -413,6 +437,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -413,6 +437,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
Map
<
String
,
Object
>
searchMap
=
field
;
Map
<
String
,
Object
>
searchMap
=
field
;
searchMap
.
put
(
"categoryIds"
,
categoryIds
);
StringBuilder
urlParams
=
new
StringBuilder
();
StringBuilder
urlParams
=
new
StringBuilder
();
searchMap
.
forEach
((
k
,
v
)
->
{
searchMap
.
forEach
((
k
,
v
)
->
{
...
@@ -488,7 +513,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -488,7 +513,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
String
content
=
""
;
String
content
=
""
;
try
{
try
{
//根据模板路径,参数生成
//根据模板路径,参数生成
content
=
CmsParserUtil
.
generate
(
SEARCH
+
ParserUtil
.
HTM_SUFFIX
,
params
,
htmlDir
);
content
=
CmsParserUtil
.
generate
(
SEARCH
+
ParserUtil
.
HTM_SUFFIX
,
params
,
htmlDir
);
}
catch
(
TemplateNotFoundException
e
)
{
}
catch
(
TemplateNotFoundException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
MalformedTemplateNameException
e
)
{
}
catch
(
MalformedTemplateNameException
e
)
{
...
@@ -549,8 +574,8 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -549,8 +574,8 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
int
[]
a
=
PageUtil
.
rainbow
(
20
,
30
,
5
);
int
[]
a
=
PageUtil
.
rainbow
(
20
,
30
,
5
);
for
(
int
_a
:
a
)
{
for
(
int
_a
:
a
)
{
System
.
out
.
println
(
_a
);
System
.
out
.
println
(
_a
);
}
}
...
...
src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java
View file @
096d6f2b
...
@@ -117,13 +117,13 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
...
@@ -117,13 +117,13 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
if
(
StringUtils
.
isNotEmpty
(
categoryEntity
.
getCategoryId
())&&
Long
.
parseLong
(
categoryEntity
.
getCategoryId
())>
0
)
{
if
(
StringUtils
.
isNotEmpty
(
categoryEntity
.
getCategoryId
())&&
Long
.
parseLong
(
categoryEntity
.
getCategoryId
())>
0
)
{
CategoryEntity
category
=
(
CategoryEntity
)
getById
(
categoryEntity
.
getCategoryId
());
CategoryEntity
category
=
(
CategoryEntity
)
getById
(
categoryEntity
.
getCategoryId
());
path
=
category
.
getCategoryPath
();
path
=
category
.
getCategoryPath
();
if
(
StringUtils
.
isEmpty
(
category
.
getCategoryParentId
()))
{
if
(
StringUtils
.
isEmpty
(
category
.
getCategoryParentId
s
()))
{
categoryEntity
.
setCategoryParentId
(
category
.
getId
());
categoryEntity
.
setCategoryParentId
s
(
category
.
getId
());
}
else
{
}
else
{
categoryEntity
.
setCategoryParentId
(
category
.
getCategoryParentId
()+
","
+
category
.
getId
());
categoryEntity
.
setCategoryParentId
s
(
category
.
getCategoryParentId
s
()+
","
+
category
.
getId
());
}
}
}
else
{
}
else
{
categoryEntity
.
setCategoryParentId
(
null
);
categoryEntity
.
setCategoryParentId
s
(
null
);
}
}
//保存时先保存再修改链接地址,修改时直接修改
//保存时先保存再修改链接地址,修改时直接修改
if
(
StringUtils
.
isNotBlank
(
categoryEntity
.
getId
()))
{
if
(
StringUtils
.
isNotBlank
(
categoryEntity
.
getId
()))
{
...
@@ -136,10 +136,10 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
...
@@ -136,10 +136,10 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
category
.
setCategoryId
(
categoryEntity
.
getId
());
category
.
setCategoryId
(
categoryEntity
.
getId
());
List
<
CategoryEntity
>
list
=
categoryDao
.
query
(
category
);
List
<
CategoryEntity
>
list
=
categoryDao
.
query
(
category
);
list
.
forEach
(
x
->{
list
.
forEach
(
x
->{
if
(
StringUtils
.
isEmpty
(
categoryEntity
.
getCategoryParentId
()))
{
if
(
StringUtils
.
isEmpty
(
categoryEntity
.
getCategoryParentId
s
()))
{
x
.
setCategoryParentId
(
categoryEntity
.
getId
());
x
.
setCategoryParentId
s
(
categoryEntity
.
getId
());
}
else
{
}
else
{
x
.
setCategoryParentId
(
categoryEntity
.
getCategoryParentId
()+
","
+
categoryEntity
.
getId
());
x
.
setCategoryParentId
s
(
categoryEntity
.
getCategoryParentId
s
()+
","
+
categoryEntity
.
getId
());
}
}
String
path
=
categoryEntity
.
getCategoryPath
();
String
path
=
categoryEntity
.
getCategoryPath
();
//判断是否有parentIds
//判断是否有parentIds
...
@@ -181,7 +181,7 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
...
@@ -181,7 +181,7 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
CategoryEntity
category
=
(
CategoryEntity
)
categoryDao
.
selectById
(
categoryId
);
CategoryEntity
category
=
(
CategoryEntity
)
categoryDao
.
selectById
(
categoryId
);
//删除父类
//删除父类
if
(
category
!=
null
){
if
(
category
!=
null
){
category
.
setCategoryParentId
(
null
);
category
.
setCategoryParentId
s
(
null
);
List
<
CategoryEntity
>
childrenList
=
categoryDao
.
queryChildren
(
category
);
List
<
CategoryEntity
>
childrenList
=
categoryDao
.
queryChildren
(
category
);
List
<
String
>
ids
=
new
ArrayList
<>();
List
<
String
>
ids
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
childrenList
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
childrenList
.
size
();
i
++){
...
@@ -233,7 +233,7 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
...
@@ -233,7 +233,7 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
* @param entity
* @param entity
*/
*/
private
void
setTopId
(
CategoryEntity
entity
){
private
void
setTopId
(
CategoryEntity
entity
){
String
categoryParentId
=
entity
.
getCategoryParentId
();
String
categoryParentId
=
entity
.
getCategoryParentId
s
();
if
(
StrUtil
.
isNotBlank
(
categoryParentId
)){
if
(
StrUtil
.
isNotBlank
(
categoryParentId
)){
String
[]
ids
=
categoryParentId
.
split
(
","
);
String
[]
ids
=
categoryParentId
.
split
(
","
);
//如果有ParentId就取第一个
//如果有ParentId就取第一个
...
...
src/main/java/net/mingsoft/cms/biz/impl/ContentBizImpl.java
View file @
096d6f2b
...
@@ -30,6 +30,7 @@ import net.mingsoft.basic.holder.DataHolder;
...
@@ -30,6 +30,7 @@ import net.mingsoft.basic.holder.DataHolder;
import
net.mingsoft.basic.util.BasicUtil
;
import
net.mingsoft.basic.util.BasicUtil
;
import
net.mingsoft.cms.bean.CategoryBean
;
import
net.mingsoft.cms.bean.CategoryBean
;
import
net.mingsoft.cms.bean.ContentBean
;
import
net.mingsoft.cms.bean.ContentBean
;
import
net.mingsoft.cms.constant.e.CategoryTypeEnum
;
import
net.mingsoft.cms.dao.ICategoryDao
;
import
net.mingsoft.cms.dao.ICategoryDao
;
import
net.mingsoft.cms.entity.CategoryEntity
;
import
net.mingsoft.cms.entity.CategoryEntity
;
import
net.mingsoft.cms.entity.ContentEntity
;
import
net.mingsoft.cms.entity.ContentEntity
;
...
@@ -141,7 +142,7 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
...
@@ -141,7 +142,7 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
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
(
CategoryTypeEnum
.
LIST
.
toString
()
)){
// 判断模板文件是否存在
// 判断模板文件是否存在
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
());
...
@@ -172,7 +173,7 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
...
@@ -172,7 +173,7 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
ContentBean
contentBean
=
new
ContentBean
();
ContentBean
contentBean
=
new
ContentBean
();
contentBean
.
setCategoryId
(
column
.
getId
());
contentBean
.
setCategoryId
(
column
.
getId
());
// 分类是列表
// 分类是列表
if
(
column
.
getCategoryType
().
equals
(
"1"
))
{
if
(
column
.
getCategoryType
().
equals
(
CategoryTypeEnum
.
LIST
.
toString
()
))
{
// 判断模板文件是否存在
// 判断模板文件是否存在
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
column
.
getCategoryListUrl
())))
{
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
column
.
getCategoryListUrl
())))
{
LOG
.
error
(
"模板不存在:{}"
,
column
.
getCategoryUrl
());
LOG
.
error
(
"模板不存在:{}"
,
column
.
getCategoryUrl
());
...
@@ -191,12 +192,12 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
...
@@ -191,12 +192,12 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
}
}
articleIdList
=
contentDao
.
queryIdsByCategoryIdForParser
(
contentBean
);
articleIdList
=
contentDao
.
queryIdsByCategoryIdForParser
(
contentBean
);
// 判断列表类型
// 判断列表类型
switch
(
column
.
getCategoryType
())
{
switch
(
CategoryTypeEnum
.
get
(
column
.
getCategoryType
())
)
{
//TODO 暂时先用字符串代替
//TODO 暂时先用字符串代替
case
"1"
:
// 列表
case
LIST
:
// 列表
CmsParserUtil
.
generateList
(
column
,
articleIdList
.
size
(),
htmlDir
);
CmsParserUtil
.
generateList
(
column
,
articleIdList
.
size
(),
htmlDir
);
break
;
break
;
case
"2"
:
// 单页
case
COVER
:
// 单页
if
(
articleIdList
.
size
()==
0
){
if
(
articleIdList
.
size
()==
0
){
CategoryBean
columnArticleIdBean
=
new
CategoryBean
();
CategoryBean
columnArticleIdBean
=
new
CategoryBean
();
CopyOptions
copyOptions
=
CopyOptions
.
create
();
CopyOptions
copyOptions
=
CopyOptions
.
create
();
...
...
src/main/java/net/mingsoft/cms/constant/e/CategoryTypeEnum.java
0 → 100644
View file @
096d6f2b
/**
* The MIT License (MIT) * Copyright (c) 2020 铭软科技(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
* the Software without restriction, including without limitation the rights to
* 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,
* subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package
net.mingsoft.cms.constant.e
;
import
net.mingsoft.base.constant.e.BaseEnum
;
/**
* @Author: 铭飞团队
* @Description:
* @Date: Create in 2020/06/23 14:18
*/
public
enum
CategoryTypeEnum
implements
BaseEnum
{
/**
* 列表
*/
LIST
(
"1"
),
/**
* 封面
*/
COVER
(
"2"
),
/**
* 链接
*/
LINK
(
"3"
);
CategoryTypeEnum
(
String
type
)
{
this
.
type
=
type
;
}
private
String
type
;
public
static
CategoryTypeEnum
get
(
String
type
)
{
for
(
CategoryTypeEnum
e
:
CategoryTypeEnum
.
values
())
{
if
(
e
.
type
.
equals
(
type
))
{
return
e
;
}
}
return
null
;
}
@Override
public
int
toInt
()
{
return
Integer
.
parseInt
(
type
);
}
@Override
public
String
toString
()
{
return
type
;
}
}
src/main/java/net/mingsoft/cms/dao/ICategoryDao.xml
View file @
096d6f2b
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
<result
column=
"dict_id"
property=
"dictId"
/>
<!--字典对应编号 -->
<result
column=
"dict_id"
property=
"dictId"
/>
<!--字典对应编号 -->
<result
column=
"category_flag"
property=
"categoryFlag"
/>
<!--栏目属性 -->
<result
column=
"category_flag"
property=
"categoryFlag"
/>
<!--栏目属性 -->
<result
column=
"category_path"
property=
"categoryPath"
/>
<!--栏目路径 -->
<result
column=
"category_path"
property=
"categoryPath"
/>
<!--栏目路径 -->
<result
column=
"category_parent_id"
property=
"categoryParentId"
/>
<!--父类型编号 -->
<result
column=
"category_parent_id
s
"
property=
"categoryParentId
s
"
/>
<!--父类型编号 -->
<result
column=
"create_by"
property=
"createBy"
/>
<!--创建人 -->
<result
column=
"create_by"
property=
"createBy"
/>
<!--创建人 -->
<result
column=
"create_date"
property=
"createDate"
/>
<!--创建时间 -->
<result
column=
"create_date"
property=
"createDate"
/>
<!--创建时间 -->
<result
column=
"update_by"
property=
"updateBy"
/>
<!--修改人 -->
<result
column=
"update_by"
property=
"updateBy"
/>
<!--修改人 -->
...
@@ -49,7 +49,7 @@
...
@@ -49,7 +49,7 @@
<if
test=
"dictId != null"
>
dict_id,
</if>
<if
test=
"dictId != null"
>
dict_id,
</if>
<if
test=
"categoryFlag != null"
>
category_flag,
</if>
<if
test=
"categoryFlag != null"
>
category_flag,
</if>
<if
test=
"categoryPath != null and categoryPath != ''"
>
category_path,
</if>
<if
test=
"categoryPath != null and categoryPath != ''"
>
category_path,
</if>
<if
test=
"categoryParentId != null and categoryParentId != ''"
>
category_parent_id,
</if>
<if
test=
"categoryParentId
s
!= null and categoryParentId
s
!= ''"
>
category_parent_id
s
,
</if>
<if
test=
"createBy > 0"
>
create_by,
</if>
<if
test=
"createBy > 0"
>
create_by,
</if>
<if
test=
"createDate != null"
>
create_date,
</if>
<if
test=
"createDate != null"
>
create_date,
</if>
<if
test=
"updateBy > 0"
>
update_by,
</if>
<if
test=
"updateBy > 0"
>
update_by,
</if>
...
@@ -89,7 +89,7 @@
...
@@ -89,7 +89,7 @@
<if
test=
"categoryTitle != null and categoryTitle != ''"
>
category_title=#{categoryTitle},
</if>
<if
test=
"categoryTitle != null and categoryTitle != ''"
>
category_title=#{categoryTitle},
</if>
<if
test=
"categoryPinyin != null and categoryPinyin != ''"
>
category_pinyin=#{categoryPinyin},
</if>
<if
test=
"categoryPinyin != null and categoryPinyin != ''"
>
category_pinyin=#{categoryPinyin},
</if>
category_id=#{categoryId},
category_id=#{categoryId},
category_parent_id=#{categoryParentId},
category_parent_id
s
=#{categoryParentId
s
},
<if
test=
"categoryType != null and categoryType != ''"
>
category_type=#{categoryType},
</if>
<if
test=
"categoryType != null and categoryType != ''"
>
category_type=#{categoryType},
</if>
<if
test=
"categorySort != null"
>
category_sort=#{categorySort},
</if>
<if
test=
"categorySort != null"
>
category_sort=#{categorySort},
</if>
<if
test=
"categoryListUrl != null and categoryListUrl != ''"
>
category_list_url=#{categoryListUrl},
</if>
<if
test=
"categoryListUrl != null and categoryListUrl != ''"
>
category_list_url=#{categoryListUrl},
</if>
...
@@ -137,7 +137,7 @@
...
@@ -137,7 +137,7 @@
<if
test=
"dictId != null"
>
and dict_id=#{dictId}
</if>
<if
test=
"dictId != null"
>
and dict_id=#{dictId}
</if>
<if
test=
"categoryFlag != null and categoryFlag != ''"
>
and category_flag=#{categoryFlag}
</if>
<if
test=
"categoryFlag != null and categoryFlag != ''"
>
and category_flag=#{categoryFlag}
</if>
<if
test=
"categoryPath != null and categoryPath != ''"
>
and category_path=#{categoryPath}
</if>
<if
test=
"categoryPath != null and categoryPath != ''"
>
and category_path=#{categoryPath}
</if>
<if
test=
"categoryParentId != null and categoryParentId != ''"
>
and category_parent_id=#{categoryParentId}
</if>
<if
test=
"categoryParentId
s
!= null and categoryParentId
s
!= ''"
>
and category_parent_id
s
=#{categoryParentId
s
}
</if>
<if
test=
"createBy > 0"
>
and create_by=#{createBy}
</if>
<if
test=
"createBy > 0"
>
and create_by=#{createBy}
</if>
<if
test=
"createDate != null"
>
and create_date=#{createDate}
</if>
<if
test=
"createDate != null"
>
and create_date=#{createDate}
</if>
<if
test=
"updateBy > 0"
>
and update_by=#{updateBy}
</if>
<if
test=
"updateBy > 0"
>
and update_by=#{updateBy}
</if>
...
@@ -157,11 +157,11 @@
...
@@ -157,11 +157,11 @@
</if>
</if>
and
and
(
(
<if
test=
"categoryParentId != null and categoryParentId!=''"
>
<if
test=
"categoryParentId
s
!= null and categoryParentId
s
!=''"
>
find_in_set(#{categoryParentId},CATEGORY_PARENT_ID)
find_in_set(#{categoryParentId
s
},CATEGORY_PARENT_ID
S
)
</if>
</if>
<if
test=
"categoryParentId == null or categoryParentId ==''"
>
<if
test=
"categoryParentId
s
== null or categoryParentId
s
==''"
>
find_in_set('${id}',CATEGORY_PARENT_ID)
find_in_set('${id}',CATEGORY_PARENT_ID
S
)
</if>
</if>
<if
test=
"id != null"
>
<if
test=
"id != null"
>
or id=#{id}
or id=#{id}
...
@@ -209,7 +209,7 @@
...
@@ -209,7 +209,7 @@
<if
test=
"dictId != null"
>
and dict_id=#{dictId}
</if>
<if
test=
"dictId != null"
>
and dict_id=#{dictId}
</if>
<if
test=
"categoryFlag != null and categoryFlag != ''"
>
and category_flag=#{categoryFlag}
</if>
<if
test=
"categoryFlag != null and categoryFlag != ''"
>
and category_flag=#{categoryFlag}
</if>
<if
test=
"categoryPath != null and categoryPath != ''"
>
and category_path=#{categoryPath}
</if>
<if
test=
"categoryPath != null and categoryPath != ''"
>
and category_path=#{categoryPath}
</if>
<if
test=
"categoryParentId != null and categoryParentId != ''"
>
and find_in_set(#{categoryParentId},category_parent_id)
</if>
<if
test=
"categoryParentId
s
!= null and categoryParentId
s
!= ''"
>
and find_in_set(#{categoryParentId
s
},category_parent_id
s
)
</if>
<if
test=
"createBy > 0"
>
and create_by=#{createBy}
</if>
<if
test=
"createBy > 0"
>
and create_by=#{createBy}
</if>
<if
test=
"createDate != null"
>
and create_date=#{createDate}
</if>
<if
test=
"createDate != null"
>
and create_date=#{createDate}
</if>
<if
test=
"updateBy > 0"
>
and update_by=#{updateBy}
</if>
<if
test=
"updateBy > 0"
>
and update_by=#{updateBy}
</if>
...
...
src/main/java/net/mingsoft/cms/dao/IContentDao.xml
View file @
096d6f2b
...
@@ -67,7 +67,7 @@
...
@@ -67,7 +67,7 @@
<result
column=
"dict_id"
property=
"dictId"
/>
<!--字典对应编号 -->
<result
column=
"dict_id"
property=
"dictId"
/>
<!--字典对应编号 -->
<result
column=
"category_flag"
property=
"categoryFlag"
/>
<!--栏目属性 -->
<result
column=
"category_flag"
property=
"categoryFlag"
/>
<!--栏目属性 -->
<result
column=
"category_path"
property=
"categoryPath"
/>
<!--栏目路径 -->
<result
column=
"category_path"
property=
"categoryPath"
/>
<!--栏目路径 -->
<result
column=
"category_parent_id"
property=
"categoryParentId"
/>
<!--父类型编号 -->
<result
column=
"category_parent_id
s
"
property=
"categoryParentId
s
"
/>
<!--父类型编号 -->
<result
column=
"create_by"
property=
"createBy"
/>
<!--创建人 -->
<result
column=
"create_by"
property=
"createBy"
/>
<!--创建人 -->
<result
column=
"create_date"
property=
"createDate"
/>
<!--创建时间 -->
<result
column=
"create_date"
property=
"createDate"
/>
<!--创建时间 -->
<result
column=
"update_by"
property=
"updateBy"
/>
<!--修改人 -->
<result
column=
"update_by"
property=
"updateBy"
/>
<!--修改人 -->
...
@@ -219,7 +219,7 @@
...
@@ -219,7 +219,7 @@
ct.del=0
ct.del=0
<if
test=
"contentTitle != null and contentTitle != ''"
>
and content_title like CONCAT('%',#{contentTitle},'%')
</if>
<if
test=
"contentTitle != null and contentTitle != ''"
>
and content_title like CONCAT('%',#{contentTitle},'%')
</if>
<if
test=
"categoryId != null and categoryId != ''"
>
and (ct.category_id=#{categoryId} or ct.category_id in
<if
test=
"categoryId != null and categoryId != ''"
>
and (ct.category_id=#{categoryId} or ct.category_id in
(select id FROM cms_category where find_in_set('${categoryId}',CATEGORY_PARENT_ID)))
</if>
(select id FROM cms_category where find_in_set('${categoryId}',CATEGORY_PARENT_ID
S
)))
</if>
<if
test=
"contentType != null and contentType != ''"
>
and content_type LIKE CONCAT('%',#{contentType},'%')
</if>
<if
test=
"contentType != null and contentType != ''"
>
and content_type LIKE CONCAT('%',#{contentType},'%')
</if>
<if
test=
"contentDisplay != null and contentDisplay != ''"
>
and content_display=#{contentDisplay}
</if>
<if
test=
"contentDisplay != null and contentDisplay != ''"
>
and content_display=#{contentDisplay}
</if>
<if
test=
"contentAuthor != null and contentAuthor != ''"
>
and content_author=#{contentAuthor}
</if>
<if
test=
"contentAuthor != null and contentAuthor != ''"
>
and content_author=#{contentAuthor}
</if>
...
@@ -251,7 +251,7 @@
...
@@ -251,7 +251,7 @@
<!-- 查询子栏目数据 -->
<!-- 查询子栏目数据 -->
<if
test=
"categoryId > 0"
>
<if
test=
"categoryId > 0"
>
and (ct.category_id=#{categoryId} or ct.category_id in
and (ct.category_id=#{categoryId} or ct.category_id in
(select id FROM cms_category where find_in_set('${categoryId}',CATEGORY_PARENT_ID)))
(select id FROM cms_category where find_in_set('${categoryId}',CATEGORY_PARENT_ID
S
)))
</if>
</if>
<if
test=
"beginTime!=null and beginTime!=''"
>
<if
test=
"beginTime!=null and beginTime!=''"
>
and content_datetime
>
= #{beginTime}
and content_datetime
>
= #{beginTime}
...
...
src/main/java/net/mingsoft/cms/entity/CategoryEntity.java
View file @
096d6f2b
...
@@ -14,383 +14,403 @@ import org.springframework.format.annotation.DateTimeFormat;
...
@@ -14,383 +14,403 @@ import org.springframework.format.annotation.DateTimeFormat;
import
java.util.Date
;
import
java.util.Date
;
/**
/**
* 分类实体
* 分类实体
* @author 铭飞开发团队
*
* 创建日期:2019-11-28 15:12:32<br/>
* @author 铭飞开发团队
* 历史修订:<br/>
* 创建日期:2019-11-28 15:12:32<br/>
*/
* 历史修订:<br/>
*/
@TableName
(
"cms_category"
)
@TableName
(
"cms_category"
)
public
class
CategoryEntity
extends
BaseEntity
{
public
class
CategoryEntity
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1574925152750L
;
private
static
final
long
serialVersionUID
=
1574925152750L
;
/**
/**
* 栏目管理名称
* 栏目管理名称
*/
*/
private
String
categoryTitle
;
private
String
categoryTitle
;
/**
/**
* 栏目别名
* 栏目别名
*/
*/
private
String
categoryPinyin
;
private
String
categoryPinyin
;
/**
/**
* 所属栏目
* 所属栏目
*/
*/
@TableField
(
insertStrategy
=
FieldStrategy
.
NOT_EMPTY
,
updateStrategy
=
FieldStrategy
.
NOT_EMPTY
,
whereStrategy
=
FieldStrategy
.
NOT_EMPTY
)
@TableField
(
insertStrategy
=
FieldStrategy
.
NOT_EMPTY
,
updateStrategy
=
FieldStrategy
.
NOT_EMPTY
,
whereStrategy
=
FieldStrategy
.
NOT_EMPTY
)
private
String
categoryId
;
private
String
categoryId
;
/**
/**
* 栏目管理属性
* 栏目管理属性
*/
*/
private
String
categoryType
;
private
String
categoryType
;
/**
/**
* 自定义顺序
* 自定义顺序
*/
*/
private
Integer
categorySort
;
private
Integer
categorySort
;
/**
/**
* 列表模板
* 列表模板
*/
*/
private
String
categoryListUrl
;
private
String
categoryListUrl
;
/**
/**
* 内容模板
* 内容模板
*/
*/
private
String
categoryUrl
;
private
String
categoryUrl
;
/**
/**
* 栏目管理关键字
* 栏目管理关键字
*/
*/
private
String
categoryKeyword
;
private
String
categoryKeyword
;
/**
/**
* 栏目管理描述
* 栏目管理描述
*/
*/
private
String
categoryDescrip
;
private
String
categoryDescrip
;
/**
/**
* 缩略图
* 缩略图
*/
*/
private
String
categoryImg
;
private
String
categoryImg
;
/**
/**
* 自定义链接
* 自定义链接
*/
*/
private
String
categoryDiyUrl
;
private
String
categoryDiyUrl
;
/**
/**
* 栏目管理的内容模型id
* 栏目管理的内容模型id
*/
*/
private
Integer
mdiyModelId
;
private
Integer
mdiyModelId
;
/**
/**
* 类别发布时间
* 类别发布时间
*/
*/
@JSONField
(
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JSONField
(
format
=
"yyyy-MM-dd HH:mm:ss"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
timezone
=
"GMT+8"
,
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
timezone
=
"GMT+8"
,
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
categoryDatetime
;
private
Date
categoryDatetime
;
/**
/**
* 字典对应编号
* 字典对应编号
*/
*/
private
Integer
dictId
;
private
Integer
dictId
;
/**
/**
* 栏目属性
* 栏目属性
*/
*/
private
String
categoryFlag
;
private
String
categoryFlag
;
/**
/**
* 栏目路径
* 栏目路径
*/
*/
private
String
categoryPath
;
private
String
categoryPath
;
/**
/**
* 父类型编号
* 父类型编号
*/
*/
private
String
categoryParentId
;
private
String
categoryParentIds
;
/**
/**
* 叶子节点
* 叶子节点
*/
*/
private
Boolean
leaf
;
private
Boolean
leaf
;
/**
/**
* 顶级id
* 顶级id
*/
*/
private
String
topId
;
private
String
topId
;
public
Boolean
getLeaf
()
{
public
Boolean
getLeaf
()
{
return
leaf
;
return
leaf
;
}
}
public
void
setLeaf
(
Boolean
leaf
)
{
public
void
setLeaf
(
Boolean
leaf
)
{
this
.
leaf
=
leaf
;
this
.
leaf
=
leaf
;
}
}
public
String
getTopId
()
{
public
String
getTopId
()
{
return
topId
;
return
topId
;
}
}
public
void
setTopId
(
String
topId
)
{
public
void
setTopId
(
String
topId
)
{
this
.
topId
=
topId
;
this
.
topId
=
topId
;
}
}
/**
/**
* 设置栏目管理名称
* 设置栏目管理名称
*/
*/
public
void
setCategoryTitle
(
String
categoryTitle
)
{
public
void
setCategoryTitle
(
String
categoryTitle
)
{
this
.
categoryTitle
=
categoryTitle
;
this
.
categoryTitle
=
categoryTitle
;
}
}
/**
/**
* 获取栏目管理名称
* 获取栏目管理名称
*/
*/
public
String
getCategoryTitle
()
{
public
String
getCategoryTitle
()
{
return
this
.
categoryTitle
;
return
this
.
categoryTitle
;
}
}
/**
* 设置所属栏目
/**
*/
* 设置所属栏目
public
void
setCategoryId
(
String
categoryId
)
{
*/
this
.
categoryId
=
categoryId
;
public
void
setCategoryId
(
String
categoryId
)
{
}
this
.
categoryId
=
categoryId
;
}
public
String
getCategoryPinyin
()
{
return
categoryPinyin
;
public
String
getCategoryPinyin
()
{
}
return
categoryPinyin
;
}
public
void
setCategoryPinyin
(
String
categoryPinyin
)
{
this
.
categoryPinyin
=
categoryPinyin
;
public
void
setCategoryPinyin
(
String
categoryPinyin
)
{
}
this
.
categoryPinyin
=
categoryPinyin
;
}
/**
* 获取所属栏目
/**
*/
* 获取所属栏目
public
String
getCategoryId
()
{
*/
return
this
.
categoryId
;
public
String
getCategoryId
()
{
}
return
this
.
categoryId
;
/**
}
* 设置栏目管理属性
*/
/**
public
void
setCategoryType
(
String
categoryType
)
{
* 设置栏目管理属性
this
.
categoryType
=
categoryType
;
*/
}
public
void
setCategoryType
(
String
categoryType
)
{
this
.
categoryType
=
categoryType
;
/**
}
* 获取栏目管理属性
*/
/**
public
String
getCategoryType
()
{
* 获取栏目管理属性
return
this
.
categoryType
;
*/
}
public
String
getCategoryType
()
{
/**
return
this
.
categoryType
;
* 设置自定义顺序
}
*/
public
void
setCategorySort
(
Integer
categorySort
)
{
/**
this
.
categorySort
=
categorySort
;
* 设置自定义顺序
}
*/
public
void
setCategorySort
(
Integer
categorySort
)
{
/**
this
.
categorySort
=
categorySort
;
* 获取自定义顺序
}
*/
public
Integer
getCategorySort
()
{
/**
return
this
.
categorySort
;
* 获取自定义顺序
}
*/
/**
public
Integer
getCategorySort
()
{
* 设置列表模板
return
this
.
categorySort
;
*/
}
public
void
setCategoryListUrl
(
String
categoryListUrl
)
{
this
.
categoryListUrl
=
categoryListUrl
;
/**
}
* 设置列表模板
*/
/**
public
void
setCategoryListUrl
(
String
categoryListUrl
)
{
* 获取列表模板
this
.
categoryListUrl
=
categoryListUrl
;
*/
}
public
String
getCategoryListUrl
()
{
return
this
.
categoryListUrl
;
/**
}
* 获取列表模板
/**
*/
* 设置内容模板
public
String
getCategoryListUrl
()
{
*/
return
this
.
categoryListUrl
;
public
void
setCategoryUrl
(
String
categoryUrl
)
{
}
this
.
categoryUrl
=
categoryUrl
;
}
/**
* 设置内容模板
/**
*/
* 获取内容模板
public
void
setCategoryUrl
(
String
categoryUrl
)
{
*/
this
.
categoryUrl
=
categoryUrl
;
public
String
getCategoryUrl
()
{
}
return
this
.
categoryUrl
;
}
/**
/**
* 获取内容模板
* 设置栏目管理关键字
*/
*/
public
String
getCategoryUrl
()
{
public
void
setCategoryKeyword
(
String
categoryKeyword
)
{
return
this
.
categoryUrl
;
this
.
categoryKeyword
=
categoryKeyword
;
}
}
/**
/**
* 设置栏目管理关键字
* 获取栏目管理关键字
*/
*/
public
void
setCategoryKeyword
(
String
categoryKeyword
)
{
public
String
getCategoryKeyword
()
{
this
.
categoryKeyword
=
categoryKeyword
;
return
this
.
categoryKeyword
;
}
}
/**
/**
* 设置栏目管理描述
* 获取栏目管理关键字
*/
*/
public
void
setCategoryDescrip
(
String
categoryDescrip
)
{
public
String
getCategoryKeyword
()
{
this
.
categoryDescrip
=
categoryDescrip
;
return
this
.
categoryKeyword
;
}
}
/**
/**
* 获取栏目管理描述
* 设置栏目管理描述
*/
*/
public
String
getCategoryDescrip
()
{
public
void
setCategoryDescrip
(
String
categoryDescrip
)
{
return
this
.
categoryDescrip
;
this
.
categoryDescrip
=
categoryDescrip
;
}
}
/**
* 设置缩略图
/**
*/
* 获取栏目管理描述
public
void
setCategoryImg
(
String
categoryImg
)
{
*/
this
.
categoryImg
=
categoryImg
;
public
String
getCategoryDescrip
()
{
}
return
this
.
categoryDescrip
;
}
/**
* 获取缩略图
/**
*/
* 设置缩略图
public
String
getCategoryImg
()
{
*/
return
this
.
categoryImg
;
public
void
setCategoryImg
(
String
categoryImg
)
{
}
this
.
categoryImg
=
categoryImg
;
/**
}
* 设置自定义链接
*/
/**
public
void
setCategoryDiyUrl
(
String
categoryDiyUrl
)
{
* 获取缩略图
this
.
categoryDiyUrl
=
categoryDiyUrl
;
*/
}
public
String
getCategoryImg
()
{
return
this
.
categoryImg
;
/**
}
* 获取自定义链接
*/
/**
public
String
getCategoryDiyUrl
()
{
* 设置自定义链接
return
this
.
categoryDiyUrl
;
*/
}
public
void
setCategoryDiyUrl
(
String
categoryDiyUrl
)
{
this
.
categoryDiyUrl
=
categoryDiyUrl
;
public
Integer
getMdiyModelId
()
{
}
return
mdiyModelId
;
}
/**
* 获取自定义链接
public
void
setMdiyModelId
(
Integer
mdiyModelId
)
{
*/
this
.
mdiyModelId
=
mdiyModelId
;
public
String
getCategoryDiyUrl
()
{
}
return
this
.
categoryDiyUrl
;
}
/**
* 设置类别发布时间
public
Integer
getMdiyModelId
()
{
*/
return
mdiyModelId
;
public
void
setCategoryDatetime
(
Date
categoryDatetime
)
{
}
this
.
categoryDatetime
=
categoryDatetime
;
}
public
void
setMdiyModelId
(
Integer
mdiyModelId
)
{
this
.
mdiyModelId
=
mdiyModelId
;
/**
}
* 获取类别发布时间
*/
/**
public
Date
getCategoryDatetime
()
{
* 设置类别发布时间
return
this
.
categoryDatetime
;
*/
}
public
void
setCategoryDatetime
(
Date
categoryDatetime
)
{
this
.
categoryDatetime
=
categoryDatetime
;
/**
}
* 设置字典对应编号
*/
/**
public
void
setDictId
(
Integer
dictId
)
{
* 获取类别发布时间
this
.
dictId
=
dictId
;
*/
}
public
Date
getCategoryDatetime
()
{
return
this
.
categoryDatetime
;
/**
}
* 获取字典对应编号
*/
/**
public
Integer
getDictId
()
{
* 设置字典对应编号
return
this
.
dictId
;
*/
}
public
void
setDictId
(
Integer
dictId
)
{
/**
this
.
dictId
=
dictId
;
* 设置栏目属性
}
*/
public
void
setCategoryFlag
(
String
categoryFlag
)
{
/**
this
.
categoryFlag
=
categoryFlag
;
* 获取字典对应编号
}
*/
public
Integer
getDictId
()
{
/**
return
this
.
dictId
;
* 获取栏目属性
}
*/
public
String
getCategoryFlag
()
{
/**
return
this
.
categoryFlag
;
* 设置栏目属性
}
*/
/**
public
void
setCategoryFlag
(
String
categoryFlag
)
{
* 设置栏目路径
this
.
categoryFlag
=
categoryFlag
;
*/
}
public
void
setCategoryPath
(
String
categoryPath
)
{
this
.
categoryPath
=
categoryPath
;
/**
}
* 获取栏目属性
*/
/**
public
String
getCategoryFlag
()
{
* 获取栏目路径
return
this
.
categoryFlag
;
*/
}
public
String
getCategoryPath
()
{
return
this
.
categoryPath
;
/**
}
* 设置栏目路径
/**
*/
* 设置父类型编号
public
void
setCategoryPath
(
String
categoryPath
)
{
*/
this
.
categoryPath
=
categoryPath
;
public
void
setCategoryParentId
(
String
categoryParentId
)
{
}
this
.
categoryParentId
=
categoryParentId
;
}
/**
* 获取栏目路径
/**
*/
* 获取父类型编号
public
String
getCategoryPath
()
{
*/
return
this
.
categoryPath
;
public
String
getCategoryParentId
()
{
}
return
this
.
categoryParentId
;
}
/**
* 设置父类型编号
/**
*/
* 获取栏目标题 (标签使用)
public
void
setCategoryParentIds
(
String
categoryParentIds
)
{
*/
this
.
categoryParentIds
=
categoryParentIds
;
public
String
getTypetitle
()
{
}
return
this
.
categoryTitle
;
}
/**
/**
* 获取父类型编号
* 获取栏目链接 (标签使用,动态链接不考虑)
*/
*/
public
String
getCategoryParentIds
()
{
public
String
getTypelink
()
{
return
this
.
categoryParentIds
;
return
"3"
.
equals
(
this
.
categoryType
)?
this
.
categoryDiyUrl
:
this
.
categoryPath
+
"/index.html"
;
}
}
/**
/**
* 获取栏目关键字 (标签使用)
* 获取栏目标题 (标签使用)
*/
*/
public
String
getTypekeyword
()
{
public
String
getTypetitle
()
{
return
this
.
categoryKeyword
;
return
this
.
categoryTitle
;
}
}
/**
/**
* 获取栏目url (标签使用)
* 获取栏目链接 (标签使用,动态链接不考虑)
*/
*/
public
String
getTypeurl
()
{
public
String
getTypelink
()
{
return
this
.
categoryDiyUrl
;
return
"3"
.
equals
(
this
.
categoryType
)
?
this
.
categoryDiyUrl
:
this
.
categoryPath
+
"/index.html"
;
}
}
/**
* 获取栏目属性 (标签使用)
/**
*/
* 获取栏目关键字 (标签使用)
public
String
getFlag
()
{
*/
return
this
.
categoryFlag
;
public
String
getTypekeyword
()
{
}
return
this
.
categoryKeyword
;
/**
}
* 获取栏目父级Id (标签使用)
*/
/**
public
String
getParentid
()
{
* 获取栏目url (标签使用)
return
this
.
categoryParentId
;
*/
}
public
String
getTypeurl
()
{
/**
return
this
.
categoryDiyUrl
;
* 获取栏目描述(标签使用)
}
*/
public
String
getTypedescrip
()
{
/**
return
this
.
categoryDescrip
;
* 获取栏目属性 (标签使用)
}
*/
/**
public
String
getFlag
()
{
* 获取栏目Id(标签使用)
return
this
.
categoryFlag
;
*/
}
public
String
getTypeid
()
{
return
this
.
id
;
/**
}
* 获取栏目父级Id (标签使用)
/**
*/
* 获取栏目图片 (标签使用)
public
String
getParentids
()
{
*/
return
this
.
categoryParentIds
;
public
String
getTypelitpic
()
{
}
return
categoryImg
;
}
/**
* 获取栏目描述(标签使用)
*/
public
String
getTypedescrip
()
{
return
this
.
categoryDescrip
;
}
/**
* 获取栏目Id(标签使用)
*/
public
String
getTypeid
()
{
return
this
.
id
;
}
/**
* 获取栏目图片 (标签使用)
*/
public
String
getTypelitpic
()
{
return
categoryImg
;
}
}
}
src/main/java/net/mingsoft/cms/upgrade/Upgrade.java
View file @
096d6f2b
...
@@ -30,7 +30,7 @@ public class Upgrade {
...
@@ -30,7 +30,7 @@ public class Upgrade {
//将parentId第一行设为顶级节点
//将parentId第一行设为顶级节点
String
topId
=
"0"
;
String
topId
=
"0"
;
String
parentId
=
x
.
getParentid
();
String
parentId
=
x
.
getParentid
s
();
if
(
parentId
!=
null
)
{
if
(
parentId
!=
null
)
{
topId
=
parentId
.
split
(
","
)[
0
];
topId
=
parentId
.
split
(
","
)[
0
];
}
}
...
@@ -40,7 +40,7 @@ public class Upgrade {
...
@@ -40,7 +40,7 @@ public class Upgrade {
boolean
leaf
=
true
;
boolean
leaf
=
true
;
//判断是否叶子,循环查找,如果有节点的父节点中包含该节点的id则判断为否跳出循环
//判断是否叶子,循环查找,如果有节点的父节点中包含该节点的id则判断为否跳出循环
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
String
pId
=
list
.
get
(
i
).
getParentid
();
String
pId
=
list
.
get
(
i
).
getParentid
s
();
if
(
pId
==
null
)
{
if
(
pId
==
null
)
{
continue
;
continue
;
}
}
...
...
src/main/java/net/mingsoft/cms/util/CmsParserUtil.java
View file @
096d6f2b
...
@@ -10,6 +10,7 @@ import net.mingsoft.base.constant.Const;
...
@@ -10,6 +10,7 @@ import net.mingsoft.base.constant.Const;
import
net.mingsoft.basic.util.BasicUtil
;
import
net.mingsoft.basic.util.BasicUtil
;
import
net.mingsoft.basic.util.SpringUtil
;
import
net.mingsoft.basic.util.SpringUtil
;
import
net.mingsoft.cms.bean.CategoryBean
;
import
net.mingsoft.cms.bean.CategoryBean
;
import
net.mingsoft.cms.constant.e.CategoryTypeEnum
;
import
net.mingsoft.cms.entity.CategoryEntity
;
import
net.mingsoft.cms.entity.CategoryEntity
;
import
net.mingsoft.mdiy.bean.PageBean
;
import
net.mingsoft.mdiy.bean.PageBean
;
import
net.mingsoft.mdiy.biz.IModelBiz
;
import
net.mingsoft.mdiy.biz.IModelBiz
;
...
@@ -31,243 +32,238 @@ import java.util.concurrent.ExecutorService;
...
@@ -31,243 +32,238 @@ import java.util.concurrent.ExecutorService;
* 文章解析工具类
* 文章解析工具类
*/
*/
public
class
CmsParserUtil
extends
ParserUtil
{
public
class
CmsParserUtil
extends
ParserUtil
{
/**
* 封面
*/
private
static
int
COLUMN_TYPE_COVER
=
2
;
private
final
static
String
FIELD
=
"field"
;
/**
private
final
static
String
FIELD
=
"field"
;
* 指定模板,指定路径进行生成静态页面,会自定识别pc与移动端
*
* @param templatePath
* 模板路径
* @param targetPath
* 生成后的路径,默认生成的html文件,所以不能带.html后缀,
* @throws IOException
*/
public
static
void
generate
(
String
templatePath
,
String
targetPath
,
String
htmlDir
)
throws
IOException
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
IS_DO
,
false
);
CategoryEntity
column
=
new
CategoryEntity
();
//内容管理栏目编码
map
.
put
(
COLUMN
,
column
);
String
content
=
CmsParserUtil
.
generate
(
templatePath
,
map
,
htmlDir
);
FileUtil
.
writeString
(
content
,
ParserUtil
.
buildHtmlPath
(
targetPath
,
htmlDir
),
Const
.
UTF8
);
}
/**
/**
* 生成静态列表页
* 指定模板,指定路径进行生成静态页面,会自定识别pc与移动端
* @param column
*
* @param articleIdTotal
* @param templatePath 模板路径
* @throws TemplateNotFoundException
* @param targetPath 生成后的路径,默认生成的html文件,所以不能带.html后缀,
* @throws MalformedTemplateNameException
* @throws IOException
* @throws ParseException
*/
* @throws IOException
public
static
void
generate
(
String
templatePath
,
String
targetPath
,
String
htmlDir
)
throws
IOException
{
*/
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
public
static
void
generateList
(
CategoryEntity
column
,
int
articleIdTotal
,
String
htmlDir
)
map
.
put
(
IS_DO
,
false
);
throws
TemplateNotFoundException
,
MalformedTemplateNameException
,
ParseException
,
IOException
{
CategoryEntity
column
=
new
CategoryEntity
();
try
{
//内容管理栏目编码
// 文章的栏目模型编号
map
.
put
(
COLUMN
,
column
);
PageBean
page
=
new
PageBean
();
String
content
=
CmsParserUtil
.
generate
(
templatePath
,
map
,
htmlDir
);
FileUtil
.
writeString
(
content
,
ParserUtil
.
buildHtmlPath
(
targetPath
,
htmlDir
),
Const
.
UTF8
);
}
//获取列表中的size
/**
page
.
setSize
(
ParserUtil
.
getPageSize
(
column
.
getCategoryListUrl
(),
20
));
* 生成静态列表页
page
.
setRcount
(
articleIdTotal
);
*
* @param column
* @param articleIdTotal
* @throws TemplateNotFoundException
* @throws MalformedTemplateNameException
* @throws ParseException
* @throws IOException
*/
public
static
void
generateList
(
CategoryEntity
column
,
int
articleIdTotal
,
String
htmlDir
)
throws
TemplateNotFoundException
,
MalformedTemplateNameException
,
ParseException
,
IOException
{
try
{
// 文章的栏目模型编号
PageBean
page
=
new
PageBean
();
int
totalPageSize
=
PageUtil
.
totalPage
(
articleIdTotal
,
page
.
getSize
());
//获取列表中的size
page
.
setTotal
(
totalPageSize
);
page
.
setSize
(
ParserUtil
.
getPageSize
(
column
.
getCategoryListUrl
(),
20
));
page
.
setRcount
(
articleIdTotal
);
//获取模板中列表标签中的条件
int
totalPageSize
=
PageUtil
.
totalPage
(
articleIdTotal
,
page
.
getSize
());
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
page
.
setTotal
(
totalPageSize
);
if
(
BasicUtil
.
getWebsiteApp
()
!=
null
)
{
map
.
put
(
ParserUtil
.
APP_DIR
,
BasicUtil
.
getWebsiteApp
().
getAppDir
());
}
map
.
put
(
ParserUtil
.
HTML
,
htmlDir
);
//获取模板中列表标签中的条件
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
ParserUtil
.
PAGE
,
page
);
if
(
BasicUtil
.
getWebsiteApp
()
!=
null
)
{
map
.
put
(
ParserUtil
.
APP_DIR
,
BasicUtil
.
getWebsiteApp
().
getAppDir
());
}
String
columnListPath
;
map
.
put
(
ParserUtil
.
HTML
,
htmlDir
);
ModelEntity
contentModel
=
null
;
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
// 判断当前栏目是否有自定义模型
map
.
put
(
ParserUtil
.
PAGE
,
page
);
if
(
column
.
getMdiyModelId
()
!=
null
)
{
// 通过栏目模型编号获取自定义模型实体
contentModel
=
(
ModelEntity
)
SpringUtil
.
getBean
(
ModelBizImpl
.
class
).
getEntity
(
column
.
getMdiyModelId
());
}
//全局参数设置
String
columnListPath
;
Map
<
String
,
Object
>
parserParams
=
new
HashMap
<
String
,
Object
>();
ModelEntity
contentModel
=
null
;
parserParams
.
put
(
ParserUtil
.
PAGE
,
page
);
// 判断当前栏目是否有自定义模型
parserParams
.
put
(
COLUMN
,
column
);
if
(
column
.
getMdiyModelId
()
!=
null
)
{
//标签中使用field获取当前栏目
// 通过栏目模型编号获取自定义模型实体
parserParams
.
put
(
FIELD
,
column
);
contentModel
=
(
ModelEntity
)
SpringUtil
.
getBean
(
ModelBizImpl
.
class
).
getEntity
(
column
.
getMdiyModelId
());
parserParams
.
put
(
IS_DO
,
false
);
}
parserParams
.
put
(
HTML
,
htmlDir
);
if
(
BasicUtil
.
getWebsiteApp
()
!=
null
){
parserParams
.
put
(
APP_DIR
,
BasicUtil
.
getWebsiteApp
().
getAppDir
());
}
if
(
contentModel
!=
null
)
{
// 将自定义模型编号设置为key值
parserParams
.
put
(
TABLE_NAME
,
contentModel
.
getModelTableName
());
}
//如果单站点,就废弃站点地址
if
(
ParserUtil
.
IS_SINGLE
)
{
parserParams
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
}
int
pageNo
=
1
;
//全局参数设置
//文章列表页没有写文章列表标签,总数为0
Map
<
String
,
Object
>
parserParams
=
new
HashMap
<
String
,
Object
>();
if
(
totalPageSize
<=
0
)
{
parserParams
.
put
(
ParserUtil
.
PAGE
,
page
);
// 数据库中第一页是从开始0*size
parserParams
.
put
(
COLUMN
,
column
);
columnListPath
=
ParserUtil
.
buildHtmlPath
(
column
.
getCategoryPath
()
+
File
.
separator
+
ParserUtil
.
INDEX
,
htmlDir
);
//标签中使用field获取当前栏目
// 设置分页的起始位置
parserParams
.
put
(
FIELD
,
column
);
page
.
setPageNo
(
pageNo
);
parserParams
.
put
(
IS_DO
,
false
);
String
read
=
ParserUtil
.
rendering
(
File
.
separator
+
column
.
getCategoryListUrl
(),
parserParams
);
parserParams
.
put
(
HTML
,
htmlDir
);
FileUtil
.
writeString
(
read
,
columnListPath
,
Const
.
UTF8
);
if
(
BasicUtil
.
getWebsiteApp
()
!=
null
)
{
parserParams
.
put
(
APP_DIR
,
BasicUtil
.
getWebsiteApp
().
getAppDir
());
}
if
(
contentModel
!=
null
)
{
// 将自定义模型编号设置为key值
parserParams
.
put
(
TABLE_NAME
,
contentModel
.
getModelTableName
());
}
//如果单站点,就废弃站点地址
if
(
ParserUtil
.
IS_SINGLE
)
{
parserParams
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
}
}
else
{
int
pageNo
=
1
;
// 遍历分页
//文章列表页没有写文章列表标签,总数为0
for
(
int
i
=
0
;
i
<
totalPageSize
;
i
++)
{
if
(
totalPageSize
<=
0
)
{
if
(
i
==
0
)
{
// 数据库中第一页是从开始0*size
// 数据库中第一页是从开始0*size
columnListPath
=
ParserUtil
.
buildHtmlPath
(
column
.
getCategoryPath
()
+
File
.
separator
+
ParserUtil
.
INDEX
,
htmlDir
);
// 首页路径index.html
// 设置分页的起始位置
columnListPath
=
ParserUtil
page
.
setPageNo
(
pageNo
);
.
buildHtmlPath
(
column
.
getCategoryPath
()
+
File
.
separator
+
ParserUtil
.
INDEX
,
htmlDir
);
String
read
=
ParserUtil
.
rendering
(
File
.
separator
+
column
.
getCategoryListUrl
(),
parserParams
);
}
else
{
FileUtil
.
writeString
(
read
,
columnListPath
,
Const
.
UTF8
);
// 其他路径list-2.html
columnListPath
=
ParserUtil
.
buildHtmlPath
(
column
.
getCategoryPath
()
+
File
.
separator
+
ParserUtil
.
PAGE_LIST
+
pageNo
,
htmlDir
);
}
// 设置分页的起始位置
page
.
setPageNo
(
pageNo
);
String
read
=
ParserUtil
.
rendering
(
File
.
separator
+
column
.
getCategoryListUrl
(),
parserParams
);
FileUtil
.
writeString
(
read
,
columnListPath
,
Const
.
UTF8
);
pageNo
++;
}
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
/**
}
else
{
* 生成内容
// 遍历分页
*
for
(
int
i
=
0
;
i
<
totalPageSize
;
i
++)
{
* @param articleIdList
if
(
i
==
0
)
{
* 文章集合
// 数据库中第一页是从开始0*size
* @return
// 首页路径index.html
* @throws IOException
columnListPath
=
ParserUtil
* @throws ParseException
.
buildHtmlPath
(
column
.
getCategoryPath
()
+
File
.
separator
+
ParserUtil
.
INDEX
,
htmlDir
);
* @throws MalformedTemplateNameException
}
else
{
* @throws TemplateNotFoundException
// 其他路径list-2.html
*/
columnListPath
=
ParserUtil
public
static
void
generateBasic
(
List
<
CategoryBean
>
articleIdList
,
String
htmlDir
)
{
.
buildHtmlPath
(
column
.
getCategoryPath
()
+
File
.
separator
+
ParserUtil
.
PAGE_LIST
+
pageNo
,
htmlDir
);
}
// 设置分页的起始位置
page
.
setPageNo
(
pageNo
);
String
read
=
ParserUtil
.
rendering
(
File
.
separator
+
column
.
getCategoryListUrl
(),
parserParams
);
FileUtil
.
writeString
(
read
,
columnListPath
,
Const
.
UTF8
);
pageNo
++;
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
Map
<
Object
,
Object
>
contentModelMap
=
new
HashMap
<
Object
,
Object
>();
/**
ModelEntity
contentModel
=
null
;
* 生成内容
// 记录已经生成了文章编号
*
List
<
String
>
generateIds
=
new
ArrayList
<>();
* @param articleIdList 文章集合
ExecutorService
pool
=
SpringUtil
.
getBean
(
ExecutorService
.
class
);
* @return
// 生成文章
* @throws IOException
for
(
int
artId
=
0
;
artId
<
articleIdList
.
size
();)
{
* @throws ParseException
* @throws MalformedTemplateNameException
* @throws TemplateNotFoundException
*/
public
static
void
generateBasic
(
List
<
CategoryBean
>
articleIdList
,
String
htmlDir
)
{
Map
<
Object
,
Object
>
contentModelMap
=
new
HashMap
<
Object
,
Object
>();
ModelEntity
contentModel
=
null
;
// 记录已经生成了文章编号
List
<
String
>
generateIds
=
new
ArrayList
<>();
ExecutorService
pool
=
SpringUtil
.
getBean
(
ExecutorService
.
class
);
// 生成文章
for
(
int
artId
=
0
;
artId
<
articleIdList
.
size
();
)
{
String
writePath
=
null
;
CategoryBean
categoryBean
=
articleIdList
.
get
(
artId
);
//设置分页类
String
writePath
=
null
;
PageBean
page
=
new
PageBean
();
//设置分页类
// 文章编号
PageBean
page
=
new
PageBean
();
String
articleId
=
articleIdList
.
get
(
artId
).
getArticleId
();
// 文章编号
// 文章的栏目路径
String
articleId
=
categoryBean
.
getArticleId
();
String
articleColumnPath
=
articleIdList
.
get
(
artId
).
getCategoryPath
();
// 文章的栏目路径
// 该文章相关分类
String
articleColumnPath
=
categoryBean
.
getCategoryPath
();
String
categoryParentId
=
articleIdList
.
get
(
artId
).
getId
()
;
// 该文章相关分类
if
(
StringUtils
.
isNotBlank
(
articleIdList
.
get
(
artId
).
getCategoryParentId
())){
String
categoryParentId
=
categoryBean
.
getId
();
categoryParentId
+=
','
+
articleIdList
.
get
(
artId
).
getCategoryParentId
();
if
(
StringUtils
.
isNotBlank
(
categoryBean
.
getCategoryParentIds
()))
{
}
categoryParentId
+=
','
+
categoryBean
.
getCategoryParentIds
();
// 文章的模板路径
}
String
columnUrl
=
articleIdList
.
get
(
artId
).
getCategoryUrl
();
// 文章的模板路径
// 文章的栏目模型编号
String
columnUrl
=
categoryBean
.
getCategoryUrl
();
Integer
columnContentModelId
=
null
;
// 文章的栏目模型编号
if
(
articleIdList
.
get
(
artId
).
getMdiyModelId
()
!=
null
&&
articleIdList
.
get
(
artId
).
getMdiyModelId
()
>
0
){
Integer
columnContentModelId
=
null
;
columnContentModelId
=
articleIdList
.
get
(
artId
).
getMdiyModelId
();
if
(
articleIdList
.
get
(
artId
).
getMdiyModelId
()
!=
null
&&
categoryBean
.
getMdiyModelId
()
>
0
)
{
}
columnContentModelId
=
categoryBean
.
getMdiyModelId
();
}
// 文章是否已经生成了,生成了就跳过
// 文章是否已经生成了,生成了就跳过
if
(
generateIds
.
contains
(
articleId
))
{
if
(
generateIds
.
contains
(
articleId
))
{
artId
++;
artId
++;
continue
;
continue
;
}
}
// 判断文件是否存在,若不存在弹出返回信息
// 判断文件是否存在,若不存在弹出返回信息
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
columnUrl
))||
articleIdList
.
get
(
artId
)
.
getId
()==
null
||
articleIdList
.
get
(
artId
)
.
getCategoryType
()==
null
)
{
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
columnUrl
))
||
categoryBean
.
getId
()
==
null
||
categoryBean
.
getCategoryType
()
==
null
)
{
artId
++;
artId
++;
continue
;
continue
;
}
}
// 将
// 将
generateIds
.
add
(
articleId
);
generateIds
.
add
(
articleId
);
//如果是封面就生成index.html
//如果是封面就生成index.html
if
(
Integer
.
parseInt
(
articleIdList
.
get
(
artId
).
getCategoryType
())
==
COLUMN_TYPE_COVER
)
{
if
(
categoryBean
.
getCategoryType
().
equals
(
CategoryTypeEnum
.
COVER
.
toString
())
)
{
writePath
=
ParserUtil
.
buildHtmlPath
(
articleColumnPath
+
File
.
separator
+
ParserUtil
.
INDEX
,
htmlDir
);
writePath
=
ParserUtil
.
buildHtmlPath
(
articleColumnPath
+
File
.
separator
+
ParserUtil
.
INDEX
,
htmlDir
);
}
else
{
}
else
{
// 组合文章路径如:html/站点id/栏目id/文章id.html
// 组合文章路径如:html/站点id/栏目id/文章id.html
writePath
=
ParserUtil
.
buildHtmlPath
(
articleColumnPath
+
File
.
separator
+
articleId
,
htmlDir
);
writePath
=
ParserUtil
.
buildHtmlPath
(
articleColumnPath
+
File
.
separator
+
articleId
,
htmlDir
);
}
}
Map
<
String
,
Object
>
parserParams
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
parserParams
=
new
HashMap
<
String
,
Object
>();
parserParams
.
put
(
ParserUtil
.
COLUMN
,
articleIdList
.
get
(
artId
)
);
parserParams
.
put
(
ParserUtil
.
COLUMN
,
categoryBean
);
// 判断当前栏目是否有自定义模型
// 判断当前栏目是否有自定义模型
if
(
columnContentModelId
!=
null
)
{
if
(
columnContentModelId
!=
null
)
{
// 通过当前栏目的模型编号获取,自定义模型表名
// 通过当前栏目的模型编号获取,自定义模型表名
if
(
contentModelMap
.
containsKey
(
columnContentModelId
))
{
if
(
contentModelMap
.
containsKey
(
columnContentModelId
))
{
parserParams
.
put
(
TABLE_NAME
,
contentModel
.
getModelTableName
());
parserParams
.
put
(
TABLE_NAME
,
contentModel
.
getModelTableName
());
}
else
{
}
else
{
// 通过栏目模型编号获取自定义模型实体
// 通过栏目模型编号获取自定义模型实体
contentModel
=
(
ModelEntity
)
SpringUtil
.
getBean
(
IModelBiz
.
class
)
contentModel
=
(
ModelEntity
)
SpringUtil
.
getBean
(
IModelBiz
.
class
)
.
getEntity
(
columnContentModelId
);
.
getEntity
(
columnContentModelId
);
// 将自定义模型编号设置为key值
// 将自定义模型编号设置为key值
contentModelMap
.
put
(
columnContentModelId
,
contentModel
.
getModelTableName
());
contentModelMap
.
put
(
columnContentModelId
,
contentModel
.
getModelTableName
());
parserParams
.
put
(
TABLE_NAME
,
contentModel
.
getModelTableName
());
parserParams
.
put
(
TABLE_NAME
,
contentModel
.
getModelTableName
());
}
}
}
}
parserParams
.
put
(
ID
,
articleId
);
parserParams
.
put
(
ID
,
articleId
);
// 第一篇文章没有上一篇
// 第一篇文章没有上一篇
if
(
artId
>
0
)
{
if
(
artId
>
0
)
{
CategoryBean
preCaBean
=
articleIdList
.
get
(
artId
-
1
);
CategoryBean
preCaBean
=
articleIdList
.
get
(
artId
-
1
);
//判断当前文档是否与上一页文章在同一栏目下,并且不能使用父栏目字符串,因为父栏目中没有所属栏目编号
//判断当前文档是否与上一页文章在同一栏目下,并且不能使用父栏目字符串,因为父栏目中没有所属栏目编号
// if( categoryParentId.contains(preCaBean.getCategoryId()+"")){
// if( categoryParentId.contains(preCaBean.getCategoryId()+"")){
page
.
setPreId
(
preCaBean
.
getArticleId
());
page
.
setPreId
(
preCaBean
.
getArticleId
());
// }
// }
}
}
// 最后一篇文章没有下一篇
// 最后一篇文章没有下一篇
if
(
artId
+
1
<
articleIdList
.
size
())
{
if
(
artId
+
1
<
articleIdList
.
size
())
{
CategoryBean
nextCaBean
=
articleIdList
.
get
(
artId
+
1
);
CategoryBean
nextCaBean
=
articleIdList
.
get
(
artId
+
1
);
//判断当前文档是否与下一页文章在同一栏目下并且不能使用父栏目字符串,因为父栏目中没有所属栏目编号
//判断当前文档是否与下一页文章在同一栏目下并且不能使用父栏目字符串,因为父栏目中没有所属栏目编号
// if(categoryParentId.contains(nextCaBean.getCategoryId()+"")){
// if(categoryParentId.contains(nextCaBean.getCategoryId()+"")){
page
.
setNextId
(
nextCaBean
.
getArticleId
());
page
.
setNextId
(
nextCaBean
.
getArticleId
());
// }
// }
}
}
parserParams
.
put
(
IS_DO
,
false
);
parserParams
.
put
(
IS_DO
,
false
);
parserParams
.
put
(
ParserUtil
.
PAGE
,
page
);
parserParams
.
put
(
ParserUtil
.
PAGE
,
page
);
String
finalWritePath
=
writePath
;
String
finalWritePath
=
writePath
;
HashMap
<
Object
,
Object
>
cloneMap
=
CollUtil
.
newHashMap
();
HashMap
<
Object
,
Object
>
cloneMap
=
CollUtil
.
newHashMap
();
cloneMap
.
putAll
(
parserParams
);
cloneMap
.
putAll
(
parserParams
);
HttpServletRequest
request
=
SpringUtil
.
getRequest
();
HttpServletRequest
request
=
SpringUtil
.
getRequest
();
pool
.
execute
(()
->
{
pool
.
execute
(()
->
{
String
content
=
null
;
String
content
=
null
;
try
{
try
{
SpringUtil
.
setRequest
(
request
);
SpringUtil
.
setRequest
(
request
);
content
=
CmsParserUtil
.
generate
(
columnUrl
,
cloneMap
,
htmlDir
);
content
=
CmsParserUtil
.
generate
(
columnUrl
,
cloneMap
,
htmlDir
);
FileUtil
.
writeString
(
content
,
finalWritePath
,
Const
.
UTF8
);
FileUtil
.
writeString
(
content
,
finalWritePath
,
Const
.
UTF8
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
});
});
artId
++;
artId
++;
}
}
}
}
}
}
src/main/resources/application.yml
View file @
096d6f2b
...
@@ -12,6 +12,8 @@ logging:
...
@@ -12,6 +12,8 @@ logging:
name
:
mcms.log
#会在项目的根目录下生成对应的mcms.log文件,也可以根据实际情况写绝对路径,例如:d:/mcms.log
name
:
mcms.log
#会在项目的根目录下生成对应的mcms.log文件,也可以根据实际情况写绝对路径,例如:d:/mcms.log
path
:
log
#会在项目的根目录下生成log目录,里面会生成对应的日期目录,日期目录下面生成日志压缩包备份文件,默认按每10M分割一个日志文件,例如:log/2020-01/app-2020-01-03-18.1.log.gz(表示2020年1月3号下午六点的第一个备份),也可以根据实际情况写绝对路径,例如:d:/log
path
:
log
#会在项目的根目录下生成log目录,里面会生成对应的日期目录,日期目录下面生成日志压缩包备份文件,默认按每10M分割一个日志文件,例如:log/2020-01/app-2020-01-03-18.1.log.gz(表示2020年1月3号下午六点的第一个备份),也可以根据实际情况写绝对路径,例如:d:/log
ms
:
ms
:
diy
:
html-dir
:
html
mstore
:
mstore
:
http
:
http://store.i.mingsoft.net/
http
:
http://store.i.mingsoft.net/
host
:
store.i.mingsoft.net
host
:
store.i.mingsoft.net
...
...
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