Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
cms_sys
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
西魏
cms_sys
Commits
50b1dd92
Commit
50b1dd92
authored
Nov 28, 2020
by
wujj
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
527f2b27
fd764fdb
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
707 additions
and
699 deletions
+707
-699
ContentAction.java
src/main/java/net/mingsoft/cms/action/ContentAction.java
+2
-2
GeneraterAction.java
src/main/java/net/mingsoft/cms/action/GeneraterAction.java
+191
-217
MCmsAction.java
src/main/java/net/mingsoft/cms/action/web/MCmsAction.java
+479
-426
ContentBean.java
src/main/java/net/mingsoft/cms/bean/ContentBean.java
+1
-7
ContentBizImpl.java
src/main/java/net/mingsoft/cms/biz/impl/ContentBizImpl.java
+3
-16
CategoryEntity.java
src/main/java/net/mingsoft/cms/entity/CategoryEntity.java
+1
-9
CmsParserUtil.java
src/main/java/net/mingsoft/cms/util/CmsParserUtil.java
+23
-16
form.ftl
src/main/webapp/WEB-INF/manager/cms/content/form.ftl
+3
-3
index.ftl
src/main/webapp/WEB-INF/manager/cms/content/index.ftl
+1
-1
main.ftl
src/main/webapp/WEB-INF/manager/cms/content/main.ftl
+1
-1
index.ftl
src/main/webapp/WEB-INF/manager/index.ftl
+2
-1
No files found.
src/main/java/net/mingsoft/cms/action/ContentAction.java
View file @
50b1dd92
...
@@ -123,9 +123,9 @@ public class ContentAction extends BaseAction {
...
@@ -123,9 +123,9 @@ public class ContentAction extends BaseAction {
*/
*/
@ApiOperation
(
value
=
"根据封面获取文章列表接口"
)
@ApiOperation
(
value
=
"根据封面获取文章列表接口"
)
@ApiImplicitParam
(
name
=
"categoryId"
,
value
=
"分类编号"
,
required
=
true
,
paramType
=
"query"
)
@ApiImplicitParam
(
name
=
"categoryId"
,
value
=
"分类编号"
,
required
=
true
,
paramType
=
"query"
)
@GetMapping
(
"/get
By
FengMian"
)
@GetMapping
(
"/get
From
FengMian"
)
@ResponseBody
@ResponseBody
public
ResultData
get
By
FengMian
(
@ModelAttribute
@ApiIgnore
ContentEntity
content
){
public
ResultData
get
From
FengMian
(
@ModelAttribute
@ApiIgnore
ContentEntity
content
){
if
(
content
.
getCategoryId
()
==
null
)
{
if
(
content
.
getCategoryId
()
==
null
)
{
return
ResultData
.
build
().
error
();
return
ResultData
.
build
().
error
();
}
}
...
...
src/main/java/net/mingsoft/cms/action/GeneraterAction.java
View file @
50b1dd92
/**
/**
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
...
@@ -36,7 +36,6 @@ import net.mingsoft.cms.biz.ICategoryBiz;
...
@@ -36,7 +36,6 @@ import net.mingsoft.cms.biz.ICategoryBiz;
import
net.mingsoft.cms.biz.IContentBiz
;
import
net.mingsoft.cms.biz.IContentBiz
;
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.AttributeBean
;
import
net.mingsoft.mdiy.bean.PageBean
;
import
net.mingsoft.mdiy.bean.PageBean
;
import
net.mingsoft.mdiy.util.ParserUtil
;
import
net.mingsoft.mdiy.util.ParserUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -75,245 +74,220 @@ import java.util.Map;
...
@@ -75,245 +74,220 @@ import java.util.Map;
@Scope
(
"request"
)
@Scope
(
"request"
)
public
class
GeneraterAction
extends
BaseAction
{
public
class
GeneraterAction
extends
BaseAction
{
/*
/*
* log4j日志记录
* log4j日志记录
*/
*/
protected
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
protected
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
/**
/**
* 文章管理业务层
* 文章管理业务层
*/
*/
@Autowired
@Autowired
private
IContentBiz
contentBiz
;
private
IContentBiz
contentBiz
;
/**
/**
* 栏目管理业务层
* 栏目管理业务层
*/
*/
@Autowired
@Autowired
private
ICategoryBiz
categoryBiz
;
private
ICategoryBiz
categoryBiz
;
/**
/**
* 模块管理业务层
* 模块管理业务层
*/
*/
@Autowired
@Autowired
private
IModelBiz
modelBiz
;
private
IModelBiz
modelBiz
;
@Value
(
"${ms.manager.path}"
)
@Value
(
"${ms.manager.path}"
)
private
String
managerPath
;
private
String
managerPath
;
/**
/**
/**
/**
* 更新主页
* 更新主页
*
*
* @return
* @return
*/
*/
@RequestMapping
(
"/index"
)
@RequestMapping
(
"/index"
)
public
String
index
(
HttpServletRequest
request
,
ModelMap
model
)
{
public
String
index
(
HttpServletRequest
request
,
ModelMap
model
)
{
return
"/cms/generate/index"
;
return
"/cms/generate/index"
;
}
}
/**
/**
* 生成主页
* 生成主页
*
*
* @param request
* @param request
* @param response
* @param response
*/
*/
@RequestMapping
(
"/generateIndex"
)
@RequestMapping
(
"/generateIndex"
)
@RequiresPermissions
(
"cms:generate:index"
)
@RequiresPermissions
(
"cms:generate:index"
)
@LogAnn
(
title
=
"生成主页"
,
businessType
=
BusinessTypeEnum
.
UPDATE
)
@LogAnn
(
title
=
"生成主页"
,
businessType
=
BusinessTypeEnum
.
UPDATE
)
@ResponseBody
@ResponseBody
public
ResultData
generateIndex
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
public
ResultData
generateIndex
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
// 模版文件名称
// 模版文件名称
String
tmpFileName
=
request
.
getParameter
(
"url"
);
String
tmpFileName
=
request
.
getParameter
(
"url"
);
// 生成后的文件名称
// 生成后的文件名称
String
generateFileName
=
request
.
getParameter
(
"position"
);
String
generateFileName
=
request
.
getParameter
(
"position"
);
// 获取文件所在路径 首先判断用户输入的模版文件是否存在
// 获取文件所在路径 首先判断用户输入的模版文件是否存在
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
()))
{
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
()))
{
return
ResultData
.
build
().
error
(
getResString
(
"templet.file"
));
return
ResultData
.
build
().
error
(
getResString
(
"templet.file"
));
}
else
{
}
else
{
CmsParserUtil
.
generate
(
tmpFileName
,
generateFileName
);
CmsParserUtil
.
generate
(
tmpFileName
,
generateFileName
);
return
ResultData
.
build
().
success
();
return
ResultData
.
build
().
success
();
}
}
}
}
/**
/**
* 生成列表的静态页面
* 生成列表的静态页面
*
*
* @param request
* @param request
* @param response
* @param response
* @param categoryId
* @param categoryId
*/
*/
@RequestMapping
(
"/{categoryId}/genernateColumn"
)
@RequestMapping
(
"/{categoryId}/genernateColumn"
)
@LogAnn
(
title
=
"生成栏目"
,
businessType
=
BusinessTypeEnum
.
UPDATE
)
@LogAnn
(
title
=
"生成栏目"
,
businessType
=
BusinessTypeEnum
.
UPDATE
)
@RequiresPermissions
(
"cms:generate:column"
)
@RequiresPermissions
(
"cms:generate:column"
)
@ResponseBody
@ResponseBody
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
>();
// 如果栏目id小于0则更新所有的栏目,否则只更新选中的栏目
//栏目列表
if
(!
"0"
.
equals
(
categoryId
))
{
List
<
CategoryEntity
>
columns
=
new
ArrayList
<
CategoryEntity
>();
CategoryEntity
categoryEntity
=
new
CategoryEntity
();
categoryEntity
.
setId
(
categoryId
);
if
(
"0"
.
equals
(
categoryId
))
{
// 0更新所有栏目
columns
=
categoryBiz
.
queryChilds
(
categoryEntity
);
CategoryEntity
categoryEntity
=
new
CategoryEntity
();
}
else
{
columns
=
categoryBiz
.
query
(
categoryEntity
);
// 获取所有的内容管理栏目
}
else
{
//选择栏目更新
CategoryEntity
categoryEntity
=
new
CategoryEntity
();
CategoryEntity
categoryEntity
=
new
CategoryEntity
();
columns
=
categoryBiz
.
query
(
categoryEntity
);
categoryEntity
.
setId
(
categoryId
);
}
columns
=
categoryBiz
.
queryChilds
(
categoryEntity
);
List
<
CategoryBean
>
articleIdList
=
null
;
}
// 1、设置模板文件夹路径
// 获取栏目列表模版
//文章列表
for
(
CategoryEntity
column
:
columns
)
{
List
<
CategoryBean
>
articleIdList
=
null
;
ContentBean
contentBean
=
new
ContentBean
();
contentBean
.
setCategoryId
(
column
.
getId
());
// 获取栏目列表模版
// 分类是列表
for
(
CategoryEntity
column
:
columns
)
{
if
(
column
.
getCategoryType
().
equals
(
"1"
))
{
ContentBean
contentBean
=
new
ContentBean
();
contentBean
.
setCategoryId
(
column
.
getId
());
articleIdList
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
// 判断列表类型
switch
(
column
.
getCategoryType
())
{
//TODO 暂时先用字符串代替
case
"1"
:
// 列表
// 判断模板文件是否存在
// 判断模板文件是否存在
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
column
.
getCategoryListUrl
())))
{
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
column
.
getCategoryListUrl
())))
{
LOG
.
error
(
"模板不存在:{}"
,
column
.
getCategoryUrl
());
LOG
.
error
(
"模板不存在:{}"
,
column
.
getCategoryUrl
());
continue
;
continue
;
}
}
//获取模板中列表标签中的条件
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
CmsParserUtil
.
generateList
(
column
,
articleIdList
.
size
());
if
(
BasicUtil
.
getWebsiteApp
()
!=
null
){
break
;
map
.
put
(
ParserUtil
.
APP_ID
,
BasicUtil
.
getWebsiteApp
().
getAppId
());
case
"2"
:
// 单页
}
if
(
articleIdList
.
size
()
==
0
)
{
PageBean
page
=
new
PageBean
();
CategoryBean
columnArticleIdBean
=
new
CategoryBean
();
map
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
CopyOptions
copyOptions
=
CopyOptions
.
create
();
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
copyOptions
.
setIgnoreError
(
true
);
map
.
put
(
ParserUtil
.
PAGE
,
page
);
BeanUtil
.
copyProperties
(
column
,
columnArticleIdBean
,
copyOptions
);
AttributeBean
attributeBean
=
new
AttributeBean
();
articleIdList
.
add
(
columnArticleIdBean
);
// 获取文章列表模板标签属性
}
ParserUtil
.
read
(
column
.
getCategoryListUrl
(),
map
,
page
,
attributeBean
);
CmsParserUtil
.
generateBasic
(
articleIdList
);
contentBean
.
setFlag
(
attributeBean
.
getFlag
());
break
;
contentBean
.
setNoflag
(
attributeBean
.
getNoflag
());
}
contentBean
.
setOrder
(
attributeBean
.
getOrder
());
}
contentBean
.
setOrderBy
(
attributeBean
.
getOrderby
());
}
articleIdList
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
// 判断列表类型
switch
(
column
.
getCategoryType
())
{
//TODO 暂时先用字符串代替
case
"1"
:
// 列表
CmsParserUtil
.
generateList
(
column
,
articleIdList
.
size
());
break
;
case
"2"
:
// 单页
if
(
articleIdList
.
size
()==
0
){
CategoryBean
columnArticleIdBean
=
new
CategoryBean
();
CopyOptions
copyOptions
=
CopyOptions
.
create
();
copyOptions
.
setIgnoreError
(
true
);
BeanUtil
.
copyProperties
(
column
,
columnArticleIdBean
,
copyOptions
);
articleIdList
.
add
(
columnArticleIdBean
);
}
CmsParserUtil
.
generateBasic
(
articleIdList
);
break
;
}
}
return
ResultData
.
build
().
success
();
return
ResultData
.
build
().
success
();
}
}
/**
/**
* 根据栏目id更新所有的文章
* 根据栏目id更新所有的文章
*
*
* @param request
* @param request
* @param response
* @param response
* @param columnId
* @param columnId
*/
*/
@RequestMapping
(
"/{columnId}/generateArticle"
)
@RequestMapping
(
"/{columnId}/generateArticle"
)
@RequiresPermissions
(
"cms:generate:article"
)
@RequiresPermissions
(
"cms:generate:article"
)
@LogAnn
(
title
=
"生成文章"
,
businessType
=
BusinessTypeEnum
.
UPDATE
)
@LogAnn
(
title
=
"生成文章"
,
businessType
=
BusinessTypeEnum
.
UPDATE
)
@ResponseBody
@ResponseBody
public
ResultData
generateArticle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
columnId
)
throws
IOException
{
public
ResultData
generateArticle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
columnId
)
throws
IOException
{
String
dateTime
=
request
.
getParameter
(
"dateTime"
);
String
dateTime
=
request
.
getParameter
(
"dateTime"
);
// 网站风格物理路径
// 网站风格物理路径
List
<
CategoryBean
>
articleIdList
=
null
;
List
<
CategoryBean
>
articleIdList
=
null
;
List
<
CategoryEntity
>
categoryList
=
null
;
List
<
CategoryEntity
>
categoryList
=
null
;
AttributeBean
attributeBean
=
new
AttributeBean
();
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
();
map
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
map
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
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
;
}
}
// 获取文章列表表属性
}
ParserUtil
.
read
(
category
.
getCategoryListUrl
(),
map
,
page
,
attributeBean
);
//将文章列表标签中的中的参数
contentBean
.
setFlag
(
attributeBean
.
getFlag
());
articleIdList
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
contentBean
.
setNoflag
(
attributeBean
.
getNoflag
());
// 有符合条件的就更新
contentBean
.
setOrder
(
attributeBean
.
getOrder
());
if
(
articleIdList
.
size
()
>
0
)
{
contentBean
.
setOrderBy
(
attributeBean
.
getOrderby
());
CmsParserUtil
.
generateBasic
(
articleIdList
);
}
}
//将文章列表标签中的中的参数
}
articleIdList
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
}
else
{
// 有符合条件的就更新
CategoryEntity
category
=
(
CategoryEntity
)
categoryBiz
.
getById
(
columnId
);
if
(
articleIdList
.
size
()
>
0
)
{
contentBean
.
setCategoryId
(
columnId
);
CmsParserUtil
.
generateBasic
(
articleIdList
);
// 分类是列表
}
if
(
category
.
getCategoryType
().
equals
(
"1"
))
{
}
// 获取文章列表表属性
}
else
{
// 判断模板文件是否存在
CategoryEntity
category
=
(
CategoryEntity
)
categoryBiz
.
getById
(
columnId
);
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
category
.
getCategoryUrl
())))
{
contentBean
.
setCategoryId
(
columnId
);
LOG
.
error
(
"模板不存在:{}"
,
category
.
getCategoryUrl
());
// 分类是列表
if
(
category
.
getCategoryType
().
equals
(
"1"
)){
// 获取文章列表表属性
// 判断模板文件是否存在
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
category
.
getCategoryUrl
())))
{
LOG
.
error
(
"模板不存在:{}"
,
category
.
getCategoryUrl
());
return
ResultData
.
build
().
error
(
getResString
(
"templet.file"
));
return
ResultData
.
build
().
error
(
getResString
(
"templet.file"
));
}
}
ParserUtil
.
read
(
category
.
getCategoryListUrl
(),
map
,
page
,
attributeBean
);
}
contentBean
.
setFlag
(
attributeBean
.
getFlag
());
articleIdList
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
contentBean
.
setNoflag
(
attributeBean
.
getNoflag
());
// 有符合条件的就更新
contentBean
.
setOrder
(
attributeBean
.
getOrder
());
if
(
articleIdList
.
size
()
>
0
)
{
contentBean
.
setOrderBy
(
attributeBean
.
getOrderby
());
CmsParserUtil
.
generateBasic
(
articleIdList
);
}
}
articleIdList
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
}
// 有符合条件的就更新
if
(
articleIdList
.
size
()
>
0
)
{
CmsParserUtil
.
generateBasic
(
articleIdList
);
}
}
return
ResultData
.
build
().
success
();
return
ResultData
.
build
().
success
();
}
}
/**
/**
* 用户预览主页
* 用户预览主页
*
*
* @param request
* @param request
* @return
* @return
*/
*/
@RequestMapping
(
"/{position}/viewIndex"
)
@RequestMapping
(
"/{position}/viewIndex"
)
public
String
viewIndex
(
HttpServletRequest
request
,
@PathVariable
String
position
,
HttpServletResponse
response
)
{
public
String
viewIndex
(
HttpServletRequest
request
,
@PathVariable
String
position
,
HttpServletResponse
response
)
{
AppEntity
app
=
BasicUtil
.
getApp
();
AppEntity
app
=
BasicUtil
.
getApp
();
// 组织主页预览地址
// 组织主页预览地址
String
indexPosition
=
app
.
getAppHostUrl
()
+
File
.
separator
+
ParserUtil
.
HTML
+
File
.
separator
+
app
.
getAppId
()
String
indexPosition
=
app
.
getAppHostUrl
()
+
File
.
separator
+
ParserUtil
.
HTML
+
File
.
separator
+
app
.
getAppId
()
+
File
.
separator
+
position
+
ParserUtil
.
HTML_SUFFIX
;
+
File
.
separator
+
position
+
ParserUtil
.
HTML_SUFFIX
;
return
"redirect:"
+
indexPosition
;
return
"redirect:"
+
indexPosition
;
}
}
}
}
src/main/java/net/mingsoft/cms/action/web/MCmsAction.java
View file @
50b1dd92
/**
/**
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
...
@@ -25,6 +25,7 @@ import cn.hutool.core.util.ObjectUtil;
...
@@ -25,6 +25,7 @@ import cn.hutool.core.util.ObjectUtil;
import
cn.hutool.core.util.PageUtil
;
import
cn.hutool.core.util.PageUtil
;
import
freemarker.core.ParseException
;
import
freemarker.core.ParseException
;
import
freemarker.template.MalformedTemplateNameException
;
import
freemarker.template.MalformedTemplateNameException
;
import
freemarker.template.TemplateException
;
import
freemarker.template.TemplateNotFoundException
;
import
freemarker.template.TemplateNotFoundException
;
import
net.bytebuddy.implementation.bytecode.Throw
;
import
net.bytebuddy.implementation.bytecode.Throw
;
import
net.mingsoft.base.constant.Const
;
import
net.mingsoft.base.constant.Const
;
...
@@ -38,7 +39,6 @@ import net.mingsoft.cms.biz.IContentBiz;
...
@@ -38,7 +39,6 @@ import net.mingsoft.cms.biz.IContentBiz;
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
;
import
net.mingsoft.mdiy.bean.AttributeBean
;
import
net.mingsoft.mdiy.bean.PageBean
;
import
net.mingsoft.mdiy.bean.PageBean
;
import
net.mingsoft.mdiy.biz.IModelBiz
;
import
net.mingsoft.mdiy.biz.IModelBiz
;
import
net.mingsoft.mdiy.biz.IPageBiz
;
import
net.mingsoft.mdiy.biz.IPageBiz
;
...
@@ -71,431 +71,484 @@ import java.util.Map;
...
@@ -71,431 +71,484 @@ import java.util.Map;
@RequestMapping
(
"/mcms"
)
@RequestMapping
(
"/mcms"
)
public
class
MCmsAction
extends
net
.
mingsoft
.
cms
.
action
.
BaseAction
{
public
class
MCmsAction
extends
net
.
mingsoft
.
cms
.
action
.
BaseAction
{
/**
/**
* 自定义页面业务层
* 自定义页面业务层
*/
*/
@Autowired
@Autowired
private
IPageBiz
pageBiz
;
private
IPageBiz
pageBiz
;
/**
/**
* 文章管理业务处理层
* 文章管理业务处理层
*/
*/
@Autowired
@Autowired
private
IContentBiz
contentBiz
;
private
IContentBiz
contentBiz
;
/**
/**
* 栏目业务层
* 栏目业务层
*/
*/
@Autowired
@Autowired
private
ICategoryBiz
categoryBiz
;
private
ICategoryBiz
categoryBiz
;
/**
/**
* 搜索标签;
* 搜索标签;
*/
*/
public
static
final
String
SEARCH
=
"search"
;
public
static
final
String
SEARCH
=
"search"
;
/**
/**
* 自定义模型
* 自定义模型
*/
*/
@Autowired
@Autowired
private
IModelBiz
modelBiz
;
private
IModelBiz
modelBiz
;
/**
/**
* 动态列表页
* 动态列表页
*/
*/
@GetMapping
(
"/index.do"
)
@GetMapping
(
"/index.do"
)
@ResponseBody
@ResponseBody
public
String
index
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
{
public
String
index
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
{
Map
map
=
BasicUtil
.
assemblyRequestMap
();
Map
map
=
BasicUtil
.
assemblyRequestMap
();
map
.
forEach
((
k
,
v
)
->
{
map
.
forEach
((
k
,
v
)->{
map
.
put
(
k
,
v
.
toString
().
replaceAll
(
"('|\"|\\\\)"
,
"\\\\$1"
));
map
.
put
(
k
,
v
.
toString
().
replaceAll
(
"('|\"|\\\\)"
,
"\\\\$1"
));
});
});
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
//动态解析
//动态解析
map
.
put
(
ParserUtil
.
IS_DO
,
true
);
map
.
put
(
ParserUtil
.
IS_DO
,
true
);
//设置动态请求的模块路径
//设置动态请求的模块路径
map
.
put
(
ParserUtil
.
MODEL_NAME
,
"mcms"
);
map
.
put
(
ParserUtil
.
MODEL_NAME
,
"mcms"
);
//解析后的内容
//解析后的内容
String
content
=
""
;
String
content
=
""
;
try
{
try
{
//根据模板路径,参数生成
//根据模板路径,参数生成
content
=
CmsParserUtil
.
generate
(
ParserUtil
.
INDEX
+
ParserUtil
.
HTM_SUFFIX
,
map
);
content
=
CmsParserUtil
.
generate
(
ParserUtil
.
INDEX
+
ParserUtil
.
HTM_SUFFIX
,
map
);
}
catch
(
TemplateNotFoundException
e
)
{
}
catch
(
TemplateNotFoundException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
MalformedTemplateNameException
e
)
{
}
catch
(
MalformedTemplateNameException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
ParseException
e
)
{
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
return
content
;
return
content
;
}
}
/**
/**
* 动态列表页
* 动态列表页
*
* @param req
* @param req
* @param resp
* @param resp
*/
*/
@ResponseBody
@ResponseBody
@GetMapping
(
"/list.do"
)
@GetMapping
(
"/list.do"
)
public
String
list
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
{
public
String
list
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
{
Map
map
=
BasicUtil
.
assemblyRequestMap
();
Map
map
=
BasicUtil
.
assemblyRequestMap
();
map
.
forEach
((
k
,
v
)->{
map
.
forEach
((
k
,
v
)
->
{
map
.
put
(
k
,
v
.
toString
().
replaceAll
(
"('|\"|\\\\)"
,
"\\\\$1"
));
map
.
put
(
k
,
v
.
toString
().
replaceAll
(
"('|\"|\\\\)"
,
"\\\\$1"
));
});
});
//获取栏目编号
//获取栏目编号
int
typeId
=
BasicUtil
.
getInt
(
ParserUtil
.
TYPE_ID
,
0
);
int
typeId
=
BasicUtil
.
getInt
(
ParserUtil
.
TYPE_ID
,
0
);
int
size
=
BasicUtil
.
getInt
(
ParserUtil
.
SIZE
,
10
);
int
size
=
BasicUtil
.
getInt
(
"size"
,
10
);
ContentBean
contentBean
=
new
ContentBean
();
ContentBean
contentBean
=
new
ContentBean
();
contentBean
.
setCategoryId
(
String
.
valueOf
(
typeId
));
contentBean
.
setCategoryId
(
String
.
valueOf
(
typeId
));
//获取文章总数
//获取文章总数
List
<
CategoryBean
>
columnArticles
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
List
<
CategoryBean
>
columnArticles
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
//判断栏目下是否有文章
//判断栏目下是否有文章
if
(
columnArticles
.
size
()==
0
){
if
(
columnArticles
.
size
()
==
0
)
{
return
""
;
return
""
;
}
}
//设置分页类
//设置分页类
PageBean
page
=
new
PageBean
();
PageBean
page
=
new
PageBean
();
int
total
=
PageUtil
.
totalPage
(
columnArticles
.
size
(),
size
);
page
.
setPageNo
(
BasicUtil
.
getPageNo
());
map
.
put
(
ParserUtil
.
COLUMN
,
columnArticles
.
get
(
0
));
int
total
=
PageUtil
.
totalPage
(
columnArticles
.
size
(),
size
);
//获取总数
map
.
put
(
ParserUtil
.
COLUMN
,
columnArticles
.
get
(
0
));
page
.
setTotal
(
total
);
//获取总数
//设置栏目编号
page
.
setTotal
(
total
);
map
.
put
(
ParserUtil
.
TYPE_ID
,
typeId
);
//设置列表当前页
//设置栏目编号
map
.
put
(
ParserUtil
.
PAGE_NO
,
BasicUtil
.
getInt
(
ParserUtil
.
PAGE_NO
,
1
));
map
.
put
(
ParserUtil
.
TYPE_ID
,
typeId
);
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
PAGE
,
page
);
map
.
put
(
ParserUtil
.
PAGE
,
page
);
//动态解析
//动态解析
map
.
put
(
ParserUtil
.
IS_DO
,
true
);
map
.
put
(
ParserUtil
.
IS_DO
,
true
);
//设置动态请求的模块路径
//设置动态请求的模块路径
map
.
put
(
ParserUtil
.
MODEL_NAME
,
"mcms"
);
map
.
put
(
ParserUtil
.
MODEL_NAME
,
"mcms"
);
//解析后的内容
//解析后的内容
String
content
=
""
;
String
content
=
""
;
try
{
try
{
//根据模板路径,参数生成
//根据模板路径,参数生成
content
=
CmsParserUtil
.
generate
(
columnArticles
.
get
(
0
).
getCategoryListUrl
(),
map
);
content
=
CmsParserUtil
.
generate
(
columnArticles
.
get
(
0
).
getCategoryListUrl
(),
map
);
}
catch
(
TemplateNotFoundException
e
)
{
}
catch
(
TemplateNotFoundException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
MalformedTemplateNameException
e
)
{
}
catch
(
MalformedTemplateNameException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
ParseException
e
)
{
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
return
content
;
return
content
;
}
}
/**
/**
* 动态详情页
* 动态详情页
* @param id 文章编号
*/
*/
@GetMapping
(
"/view.do"
)
@GetMapping
(
"/view.do"
)
@ResponseBody
@ResponseBody
public
String
view
(
String
orderby
,
String
order
,
HttpServletRequest
req
,
HttpServletResponse
resp
)
{
public
String
view
(
String
orderby
,
String
order
,
HttpServletRequest
req
,
HttpServletResponse
resp
)
{
//参数文章编号
//参数文章编号
ContentEntity
article
=
(
ContentEntity
)
contentBiz
.
getEntity
(
BasicUtil
.
getInt
(
ParserUtil
.
ID
));
ContentEntity
article
=
(
ContentEntity
)
contentBiz
.
getEntity
(
BasicUtil
.
getInt
(
ParserUtil
.
ID
));
if
(
ObjectUtil
.
isNull
(
article
))
{
if
(
ObjectUtil
.
isNull
(
article
)){
throw
new
BusinessException
(
this
.
getResString
(
"err.empty"
,
this
.
getResString
(
"id"
)));
throw
new
BusinessException
(
this
.
getResString
(
"err.empty"
,
this
.
getResString
(
"id"
)))
;
}
}
if
(
StringUtils
.
isNotBlank
(
order
))
{
if
(
StringUtils
.
isNotBlank
(
order
)){
//防注入
//防注入
if
(!
order
.
toLowerCase
().
equals
(
"asc"
)
&&
!
order
.
toLowerCase
().
equals
(
"desc"
))
{
if
(!
order
.
toLowerCase
().
equals
(
"asc"
)&&!
order
.
toLowerCase
().
equals
(
"desc"
)){
throw
new
BusinessException
(
this
.
getResString
(
"err.error"
,
this
.
getResString
(
"order"
)));
throw
new
BusinessException
(
this
.
getResString
(
"err.error"
,
this
.
getResString
(
"order"
)));
}
}
}
}
orderby
=
orderby
.
replaceAll
(
"('|\"|\\\\)"
,
"\\\\$1"
);
orderby
=
orderby
.
replaceAll
(
"('|\"|\\\\)"
,
"\\\\$1"
);
PageBean
page
=
new
PageBean
();
PageBean
page
=
new
PageBean
();
//用于详情上下页获取当前文章列表对应的分类,根据文章查询只能获取自身分类
//用于详情上下页获取当前文章列表对应的分类,根据文章查询只能获取自身分类
String
typeId
=
BasicUtil
.
getString
(
ParserUtil
.
TYPE_ID
,
article
.
getCategoryId
());
String
typeId
=
BasicUtil
.
getString
(
ParserUtil
.
TYPE_ID
,
article
.
getCategoryId
());
//根据文章编号查询栏目详情模版
//根据文章编号查询栏目详情模版
CategoryEntity
column
=
(
CategoryEntity
)
categoryBiz
.
getEntity
(
Integer
.
parseInt
(
typeId
));
CategoryEntity
column
=
(
CategoryEntity
)
categoryBiz
.
getEntity
(
Integer
.
parseInt
(
typeId
));
//解析后的内容
//解析后的内容
String
content
=
""
;
String
content
=
""
;
Map
map
=
BasicUtil
.
assemblyRequestMap
();
Map
map
=
BasicUtil
.
assemblyRequestMap
();
map
.
forEach
((
k
,
v
)
->
{
map
.
forEach
((
k
,
v
)->{
//sql注入过滤
//sql注入过滤
map
.
put
(
k
,
v
.
toString
().
replaceAll
(
"('|\"|\\\\)"
,
"\\\\$1"
));
map
.
put
(
k
,
v
.
toString
().
replaceAll
(
"('|\"|\\\\)"
,
"\\\\$1"
));
});
});
//动态解析
//动态解析
map
.
put
(
ParserUtil
.
IS_DO
,
true
);
map
.
put
(
ParserUtil
.
IS_DO
,
true
);
//设置栏目编号
//设置栏目编号
map
.
put
(
ParserUtil
.
TYPE_ID
,
typeId
);
map
.
put
(
ParserUtil
.
TYPE_ID
,
typeId
);
//设置动态请求的模块路径
//设置动态请求的模块路径
map
.
put
(
ParserUtil
.
MODEL_NAME
,
"mcms"
);
map
.
put
(
ParserUtil
.
MODEL_NAME
,
"mcms"
);
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
PAGE
,
page
);
map
.
put
(
ParserUtil
.
PAGE
,
page
);
map
.
put
(
ParserUtil
.
ID
,
article
.
getId
());
map
.
put
(
ParserUtil
.
ID
,
article
.
getId
());
ContentBean
contentBean
=
new
ContentBean
();
ContentBean
contentBean
=
new
ContentBean
();
contentBean
.
setCategoryId
(
String
.
valueOf
(
typeId
));
contentBean
.
setCategoryId
(
String
.
valueOf
(
typeId
));
contentBean
.
setOrderBy
(
orderby
);
contentBean
.
setOrderBy
(
orderby
);
contentBean
.
setOrder
(
order
);
contentBean
.
setOrder
(
order
);
List
<
CategoryBean
>
articleIdList
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
List
<
CategoryBean
>
articleIdList
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
Map
<
Object
,
Object
>
contentModelMap
=
new
HashMap
<
Object
,
Object
>();
Map
<
Object
,
Object
>
contentModelMap
=
new
HashMap
<
Object
,
Object
>();
ModelEntity
contentModel
=
null
;
ModelEntity
contentModel
=
null
;
for
(
int
artId
=
0
;
artId
<
articleIdList
.
size
();
)
{
for
(
int
artId
=
0
;
artId
<
articleIdList
.
size
();)
{
//如果不是当前文章则跳过
//如果不是当前文章则跳过
if
(
articleIdList
.
get
(
artId
).
getArticleId
().
equals
(
article
.
getId
()))
{
if
(
articleIdList
.
get
(
artId
).
getArticleId
().
equals
(
article
.
getId
())){
artId
++;
artId
++;
continue
;
continue
;
}
}
// 文章的栏目路径
// 文章的栏目路径
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
())){
categoryParentId
+=
','
+
articleIdList
.
get
(
artId
).
getCategoryParentId
();
categoryParentId
+=
','
+
articleIdList
.
get
(
artId
).
getCategoryParentId
();
}
}
// 文章的栏目模型编号
// 文章的栏目模型编号
Integer
columnContentModelId
=
articleIdList
.
get
(
artId
).
getMdiyModelId
();
Integer
columnContentModelId
=
articleIdList
.
get
(
artId
).
getMdiyModelId
();
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
,
articleIdList
.
get
(
artId
));
// 判断当前栏目是否有自定义模型
// 判断当前栏目是否有自定义模型
if
(
columnContentModelId
!=
null
&&
columnContentModelId
>
0
)
{
if
(
columnContentModelId
!=
null
&&
columnContentModelId
>
0
)
{
// 通过当前栏目的模型编号获取,自定义模型表名
// 通过当前栏目的模型编号获取,自定义模型表名
if
(
contentModelMap
.
containsKey
(
columnContentModelId
))
{
if
(
contentModelMap
.
containsKey
(
columnContentModelId
))
{
parserParams
.
put
(
ParserUtil
.
TABLE_NAME
,
contentModel
.
getModelTableName
());
parserParams
.
put
(
ParserUtil
.
TABLE_NAME
,
contentModel
.
getModelTableName
());
}
else
{
}
else
{
// 通过栏目模型编号获取自定义模型实体
// 通过栏目模型编号获取自定义模型实体
contentModel
=
(
ModelEntity
)
modelBiz
.
getEntity
(
columnContentModelId
);
contentModel
=(
ModelEntity
)
modelBiz
.
getEntity
(
columnContentModelId
);
// 将自定义模型编号设置为key值
// 将自定义模型编号设置为key值
contentModelMap
.
put
(
columnContentModelId
,
contentModel
.
getModelTableName
());
contentModelMap
.
put
(
columnContentModelId
,
contentModel
.
getModelTableName
());
parserParams
.
put
(
ParserUtil
.
TABLE_NAME
,
contentModel
.
getModelTableName
());
parserParams
.
put
(
ParserUtil
.
TABLE_NAME
,
contentModel
.
getModelTableName
());
}
}
// 第一篇文章没有上一篇
if
(
artId
>
0
)
{
CategoryBean
preCaBean
=
articleIdList
.
get
(
artId
-
1
);
page
.
setPreId
(
preCaBean
.
getArticleId
());
}
// 最后一篇文章没有下一篇
if
(
artId
+
1
<
articleIdList
.
size
())
{
CategoryBean
nextCaBean
=
articleIdList
.
get
(
artId
+
1
);
page
.
setNextId
(
nextCaBean
.
getArticleId
());
}
break
;
}
try
{
//根据模板路径,参数生成
content
=
CmsParserUtil
.
generate
(
column
.
getCategoryUrl
(),
map
);
}
catch
(
TemplateNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
MalformedTemplateNameException
e
)
{
e
.
printStackTrace
();
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
content
;
}
/**
* 实现前端页面的文章搜索
*
* @param request
* 搜索id
* @param response
*/
@RequestMapping
(
value
=
"search"
)
@ResponseBody
public
String
search
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
// 读取请求字段
Map
<
String
,
Object
>
field
=
BasicUtil
.
assemblyRequestMap
();
// 自定义字段集合
Map
<
String
,
String
>
diyFieldName
=
new
HashMap
<
String
,
String
>();
CategoryEntity
column
=
null
;
// 当前栏目
ModelEntity
contentModel
=
null
;
// 栏目对应模型
List
<
DiyModelMap
>
fieldValueList
=
new
ArrayList
<
DiyModelMap
>();
// 栏目对应字段的值
int
typeId
=
0
;
String
categoryIds
=
BasicUtil
.
getString
(
"categoryId"
);
//当传递了栏目编号,但不是栏目集合
if
(!
StringUtil
.
isBlank
(
categoryIds
)
&&
!
categoryIds
.
contains
(
","
)){
typeId
=
Integer
.
parseInt
(
categoryIds
);
}
String
url
=
BasicUtil
.
getUrl
();
//记录自定义模型字段名
List
filedStr
=
new
ArrayList
<>();
//根据栏目确定自定义模型
if
(
typeId
>
0
){
column
=
(
CategoryEntity
)
categoryBiz
.
getEntity
(
Integer
.
parseInt
(
typeId
+
""
));
// 获取表单类型的id
if
(
column
!=
null
&&
ObjectUtil
.
isNotNull
(
column
.
getMdiyModelId
()))
{
contentModel
=
(
ModelEntity
)
modelBiz
.
getEntity
(
column
.
getMdiyModelId
());
if
(
contentModel
!=
null
)
{
Map
<
String
,
String
>
fieldMap
=
contentModel
.
getFieldMap
();
for
(
String
s
:
fieldMap
.
keySet
())
{
filedStr
.
add
(
fieldMap
.
get
(
s
));
}
map
.
put
(
ParserUtil
.
TABLE_NAME
,
contentModel
.
getModelTableName
());
}
}
map
.
put
(
ParserUtil
.
COLUMN
,
column
);
}
// 遍历取字段集合
if
(
field
!=
null
)
{
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
field
.
entrySet
())
{
if
(
entry
!=
null
)
{
if
(
ObjectUtil
.
isNull
(
entry
.
getValue
()))
{
continue
;
}
String
value
=
entry
.
getValue
().
toString
().
replaceAll
(
"('|\"|\\\\)"
,
"\\\\$1"
);
// 处理由get方法请求中文乱码问题
value
=
clearXss
(
value
);
if
(
request
.
getMethod
().
equals
(
RequestMethod
.
GET
))
{
// 如果是get方法需要将请求地址参数转码
try
{
value
=
new
String
(
value
.
getBytes
(
"ISO-8859-1"
),
Const
.
UTF8
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
}
// 保存至自定义字段集合
if
(!
StringUtil
.
isBlank
(
value
))
{
diyFieldName
.
put
(
entry
.
getKey
(),
value
);
//判断请求中的是否是自定义模型中的字段
if
(
filedStr
.
contains
(
entry
.
getKey
())){
//设置自定义模型字段和值
DiyModelMap
diyMap
=
new
DiyModelMap
();
diyMap
.
setKey
(
entry
.
getKey
());
diyMap
.
setValue
(
value
);
fieldValueList
.
add
(
diyMap
);
}
}
}
}
}
//添加自定义模型的字段和值
if
(
fieldValueList
.
size
()>
0
){
map
.
put
(
"diyModel"
,
fieldValueList
);
}
//设置分页类
PageBean
page
=
new
PageBean
();
Map
<
String
,
Object
>
searchMap
=
field
;
StringBuilder
urlParams
=
new
StringBuilder
();
searchMap
.
forEach
((
k
,
v
)->{
//sql注入过滤
if
(
v
!=
null
){
searchMap
.
put
(
k
,
v
.
toString
().
replaceAll
(
"('|\"|\\\\)"
,
"\\\\$1"
));
searchMap
.
put
(
k
,
clearXss
(
searchMap
.
get
(
k
).
toString
()));
if
(!
ParserUtil
.
SIZE
.
equals
(
k
)&&!
ParserUtil
.
PAGE_NO
.
equals
(
k
)){
urlParams
.
append
(
k
).
append
(
"="
).
append
(
searchMap
.
get
(
k
)).
append
(
"&"
);
}
}
}
}
});
// 第一篇文章没有上一篇
if
(
artId
>
0
)
{
//查询数量
CategoryBean
preCaBean
=
articleIdList
.
get
(
artId
-
1
);
int
count
=
contentBiz
.
getSearchCount
(
contentModel
,
fieldValueList
,
searchMap
,
BasicUtil
.
getApp
().
getAppId
(),
categoryIds
);
page
.
setPreId
(
preCaBean
.
getArticleId
());
map
.
put
(
ParserUtil
.
URL
,
url
);
}
map
.
put
(
SEARCH
,
searchMap
);
// 最后一篇文章没有下一篇
if
(
BasicUtil
.
getWebsiteApp
()
!=
null
){
if
(
artId
+
1
<
articleIdList
.
size
())
{
map
.
put
(
ParserUtil
.
APP_ID
,
BasicUtil
.
getWebsiteApp
().
getAppId
());
CategoryBean
nextCaBean
=
articleIdList
.
get
(
artId
+
1
);
}
page
.
setNextId
(
nextCaBean
.
getArticleId
());
map
.
put
(
ParserUtil
.
PAGE
,
page
);
}
map
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
break
;
//动态解析
}
map
.
put
(
ParserUtil
.
IS_DO
,
false
);
try
{
//设置动态请求的模块路径
//根据模板路径,参数生成
map
.
put
(
ParserUtil
.
MODEL_NAME
,
"mcms"
);
content
=
CmsParserUtil
.
generate
(
column
.
getCategoryUrl
(),
map
);
searchMap
.
put
(
ParserUtil
.
PAGE_NO
,
0
);
}
catch
(
TemplateNotFoundException
e
)
{
AttributeBean
attributeBean
=
new
AttributeBean
();
e
.
printStackTrace
();
ParserUtil
.
read
(
SEARCH
+
ParserUtil
.
HTM_SUFFIX
,
map
,
page
,
attributeBean
);
}
catch
(
MalformedTemplateNameException
e
)
{
int
total
=
PageUtil
.
totalPage
(
count
,
page
.
getSize
());
e
.
printStackTrace
();
int
pageNo
=
BasicUtil
.
getInt
(
ParserUtil
.
PAGE_NO
,
1
);
}
catch
(
ParseException
e
)
{
if
(
pageNo
>=
total
&&
total
!=
0
)
{
e
.
printStackTrace
();
pageNo
=
total
;
}
catch
(
IOException
e
)
{
}
e
.
printStackTrace
();
//获取总数
}
page
.
setTotal
(
total
);
return
content
;
}
page
.
setPageNo
(
pageNo
);
//设置分页的统一链接
/**
url
=
url
+
request
.
getServletPath
()
+
"?"
+
urlParams
;
* 实现前端页面的文章搜索
String
pageNoStr
=
ParserUtil
.
SIZE
+
"="
+
page
.
getSize
()+
"&"
+
ParserUtil
.
PAGE_NO
+
"="
;
*
//下一页
* @param request 搜索id
String
nextUrl
=
url
+
pageNoStr
+((
pageNo
+
1
>
total
)?
total:
pageNo
+
1
);
* @param response
//首页
*/
String
indexUrl
=
url
+
pageNoStr
+
1
;
@RequestMapping
(
value
=
"search"
)
//尾页
@ResponseBody
String
lastUrl
=
url
+
pageNoStr
+
total
;
public
String
search
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
//上一页 当前页为1时,上一页就是1
//设置分页类
String
preUrl
=
url
+
pageNoStr
+
((
pageNo
==
1
)
?
1
:
pageNo
-
1
);
PageBean
page
=
new
PageBean
();
page
.
setSize
(
ParserUtil
.
getPageSize
(
SEARCH
+
ParserUtil
.
HTM_SUFFIX
,
20
));
page
.
setIndexUrl
(
indexUrl
);
page
.
setNextUrl
(
nextUrl
);
//参数集合,提供给解析使用
page
.
setPreUrl
(
preUrl
);
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
page
.
setLastUrl
(
lastUrl
);
// 读取请求字段
//解析后的内容
Map
<
String
,
Object
>
field
=
BasicUtil
.
assemblyRequestMap
();
String
content
=
""
;
try
{
// 自定义字段集合
//根据模板路径,参数生成
Map
<
String
,
String
>
diyFieldName
=
new
HashMap
<
String
,
String
>();
content
=
CmsParserUtil
.
generate
(
SEARCH
+
ParserUtil
.
HTM_SUFFIX
,
map
);
}
catch
(
TemplateNotFoundException
e
)
{
//记录自定义模型字段名
e
.
printStackTrace
();
List
filedStr
=
new
ArrayList
<>();
}
catch
(
MalformedTemplateNameException
e
)
{
// 栏目对应字段的值
e
.
printStackTrace
();
List
<
DiyModelMap
>
fieldValueList
=
new
ArrayList
<
DiyModelMap
>();
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
// 当前栏目
}
catch
(
IOException
e
)
{
CategoryEntity
column
=
null
;
e
.
printStackTrace
();
// 栏目对应模型
}
ModelEntity
contentModel
=
null
;
return
content
;
}
//获取栏目信息
// 清除路径中的转义字符
int
typeId
=
0
;
private
String
clearXss
(
String
value
)
{
String
categoryIds
=
BasicUtil
.
getString
(
"categoryId"
);
//当传递了栏目编号,但不是栏目集合
if
(
value
==
null
||
""
.
equals
(
value
))
{
if
(!
StringUtil
.
isBlank
(
categoryIds
)
&&
!
categoryIds
.
contains
(
","
))
{
return
value
;
typeId
=
Integer
.
parseInt
(
categoryIds
);
}
}
value
=
value
.
replaceAll
(
"<"
,
"<"
).
replaceAll
(
">"
,
">"
);
//当前访问的项目地址
value
=
value
.
replaceAll
(
"\\("
,
"("
).
replace
(
"\\)"
,
")"
);
String
url
=
BasicUtil
.
getUrl
();
value
=
value
.
replaceAll
(
"'"
,
"'"
);
value
=
value
.
replaceAll
(
"eval\\((.*)\\)"
,
""
);
value
=
value
.
replaceAll
(
"[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']"
,
//根据栏目确定自定义模型
"\"\""
);
if
(
typeId
>
0
)
{
value
=
value
.
replace
(
"script"
,
""
);
column
=
(
CategoryEntity
)
categoryBiz
.
getEntity
(
typeId
);
// 获取表单类型的id
return
value
;
if
(
column
!=
null
&&
ObjectUtil
.
isNotNull
(
column
.
getMdiyModelId
()))
{
}
contentModel
=
(
ModelEntity
)
modelBiz
.
getEntity
(
column
.
getMdiyModelId
());
if
(
contentModel
!=
null
)
{
/**
// 保存自定义模型的数据
* 存储自定义模型字段和接口参数
Map
<
String
,
String
>
fieldMap
=
contentModel
.
getFieldMap
();
* @author 铭飞开源团队
for
(
String
s
:
fieldMap
.
keySet
())
{
* @date 2019年3月5日
filedStr
.
add
(
fieldMap
.
get
(
s
));
*/
}
public
class
DiyModelMap
{
// 设置自定义模型表名,方便解析的时候关联表查询
String
key
;
params
.
put
(
ParserUtil
.
TABLE_NAME
,
contentModel
.
getModelTableName
());
Object
value
;
}
public
String
getKey
()
{
}
return
key
;
}
// 设置栏目,方便解析的时候关联表查询
public
void
setKey
(
String
key
)
{
params
.
put
(
ParserUtil
.
COLUMN
,
column
);
this
.
key
=
key
;
}
}
public
Object
getValue
()
{
// 处理读取请求字段
return
value
;
if
(
field
!=
null
)
{
}
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
field
.
entrySet
())
{
public
void
setValue
(
Object
value
)
{
if
(
entry
!=
null
)
{
this
.
value
=
value
;
//空值不处理
}
if
(
ObjectUtil
.
isNull
(
entry
.
getValue
()))
{
}
continue
;
}
// 对值进行安全处理
// 处理由get方法请求中文乱码问题
String
value
=
entry
.
getValue
().
toString
().
replaceAll
(
"('|\"|\\\\)"
,
"\\\\$1"
);
//Xss过滤
value
=
clearXss
(
value
);
// 如果是get方法需要将请求地址参数转码
if
(
request
.
getMethod
().
equals
(
RequestMethod
.
GET
))
{
try
{
value
=
new
String
(
value
.
getBytes
(
"ISO-8859-1"
),
Const
.
UTF8
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
}
// 保存至自定义字段集合
if
(!
StringUtil
.
isBlank
(
value
))
{
diyFieldName
.
put
(
entry
.
getKey
(),
value
);
//判断请求中的是否是自定义模型中的字段
if
(
filedStr
.
contains
(
entry
.
getKey
()))
{
//设置自定义模型字段和值
DiyModelMap
diyMap
=
new
DiyModelMap
();
diyMap
.
setKey
(
entry
.
getKey
());
diyMap
.
setValue
(
value
);
fieldValueList
.
add
(
diyMap
);
}
}
}
}
}
//添加自定义模型的字段和值
if
(
fieldValueList
.
size
()
>
0
)
{
params
.
put
(
"diyModel"
,
fieldValueList
);
}
Map
<
String
,
Object
>
searchMap
=
field
;
StringBuilder
urlParams
=
new
StringBuilder
();
searchMap
.
forEach
((
k
,
v
)
->
{
//sql注入过滤
if
(
v
!=
null
)
{
searchMap
.
put
(
k
,
v
.
toString
().
replaceAll
(
"('|\"|\\\\)"
,
"\\\\$1"
));
searchMap
.
put
(
k
,
clearXss
(
searchMap
.
get
(
k
).
toString
()));
if
(!
"size"
.
equals
(
k
)
&&
!
"pageNo"
.
equals
(
k
))
{
urlParams
.
append
(
k
).
append
(
"="
).
append
(
searchMap
.
get
(
k
)).
append
(
"&"
);
}
}
});
//查询数量
int
count
=
contentBiz
.
getSearchCount
(
contentModel
,
fieldValueList
,
searchMap
,
BasicUtil
.
getApp
().
getAppId
(),
categoryIds
);
page
.
setRcount
(
count
);
params
.
put
(
ParserUtil
.
URL
,
url
);
params
.
put
(
SEARCH
,
searchMap
);
if
(
BasicUtil
.
getWebsiteApp
()
!=
null
)
{
params
.
put
(
ParserUtil
.
APP_ID
,
BasicUtil
.
getWebsiteApp
().
getAppId
());
}
params
.
put
(
ParserUtil
.
PAGE
,
page
);
params
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
//动态解析
params
.
put
(
ParserUtil
.
IS_DO
,
false
);
//设置动态请求的模块路径
params
.
put
(
ParserUtil
.
MODEL_NAME
,
"mcms"
);
searchMap
.
put
(
"pageNo"
,
0
);
// ParserUtil.read(SEARCH + ParserUtil.HTM_SUFFIX, map, page);
int
total
=
PageUtil
.
totalPage
(
count
,
page
.
getSize
());
int
pageNo
=
BasicUtil
.
getInt
(
"pageNo"
,
1
);
if
(
pageNo
>=
total
&&
total
!=
0
)
{
pageNo
=
total
;
}
//获取总数
page
.
setTotal
(
total
);
page
.
setPageNo
(
pageNo
);
//设置分页的统一链接
url
=
url
+
request
.
getServletPath
()
+
"?"
+
urlParams
;
String
pageNoStr
=
"size="
+
page
.
getSize
()
+
"&pageNo="
;
//下一页
String
nextUrl
=
url
+
pageNoStr
+
((
pageNo
+
1
>
total
)
?
total
:
pageNo
+
1
);
//首页
String
indexUrl
=
url
+
pageNoStr
+
1
;
//尾页
String
lastUrl
=
url
+
pageNoStr
+
total
;
//上一页 当前页为1时,上一页就是1
String
preUrl
=
url
+
pageNoStr
+
((
pageNo
==
1
)
?
1
:
pageNo
-
1
);
page
.
setIndexUrl
(
indexUrl
);
page
.
setNextUrl
(
nextUrl
);
page
.
setPreUrl
(
preUrl
);
page
.
setLastUrl
(
lastUrl
);
params
.
put
(
ParserUtil
.
URL
,
url
);
params
.
put
(
SEARCH
,
searchMap
);
if
(
BasicUtil
.
getWebsiteApp
()
!=
null
)
{
params
.
put
(
ParserUtil
.
APP_ID
,
BasicUtil
.
getWebsiteApp
().
getAppId
());
}
params
.
put
(
ParserUtil
.
PAGE
,
page
);
params
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
//动态解析
params
.
put
(
ParserUtil
.
IS_DO
,
false
);
//设置动态请求的模块路径
params
.
put
(
ParserUtil
.
MODEL_NAME
,
"mcms"
);
//解析后的内容
String
content
=
""
;
try
{
//根据模板路径,参数生成
content
=
CmsParserUtil
.
generate
(
SEARCH
+
ParserUtil
.
HTM_SUFFIX
,
params
);
}
catch
(
TemplateNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
MalformedTemplateNameException
e
)
{
e
.
printStackTrace
();
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
content
;
}
// 清除路径中的转义字符
private
String
clearXss
(
String
value
)
{
if
(
value
==
null
||
""
.
equals
(
value
))
{
return
value
;
}
value
=
value
.
replaceAll
(
"<"
,
"<"
).
replaceAll
(
">"
,
">"
);
value
=
value
.
replaceAll
(
"\\("
,
"("
).
replace
(
"\\)"
,
")"
);
value
=
value
.
replaceAll
(
"'"
,
"'"
);
value
=
value
.
replaceAll
(
"eval\\((.*)\\)"
,
""
);
value
=
value
.
replaceAll
(
"[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']"
,
"\"\""
);
value
=
value
.
replace
(
"script"
,
""
);
return
value
;
}
/**
* 存储自定义模型字段和接口参数
*
* @author 铭飞开源团队
* @date 2019年3月5日
*/
class
DiyModelMap
{
String
key
;
Object
value
;
public
String
getKey
()
{
return
key
;
}
public
void
setKey
(
String
key
)
{
this
.
key
=
key
;
}
public
Object
getValue
()
{
return
value
;
}
public
void
setValue
(
Object
value
)
{
this
.
value
=
value
;
}
}
public
static
void
main
(
String
[]
args
)
{
int
[]
a
=
PageUtil
.
rainbow
(
20
,
30
,
5
);
for
(
int
_a:
a
)
{
System
.
out
.
println
(
_a
);
}
}
}
}
src/main/java/net/mingsoft/cms/bean/ContentBean.java
View file @
50b1dd92
...
@@ -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 @
50b1dd92
...
@@ -34,7 +34,6 @@ import net.mingsoft.cms.dao.ICategoryDao;
...
@@ -34,7 +34,6 @@ 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
;
import
net.mingsoft.cms.util.CmsParserUtil
;
import
net.mingsoft.cms.util.CmsParserUtil
;
import
net.mingsoft.mdiy.bean.AttributeBean
;
import
net.mingsoft.mdiy.bean.PageBean
;
import
net.mingsoft.mdiy.bean.PageBean
;
import
net.mingsoft.mdiy.entity.ModelEntity
;
import
net.mingsoft.mdiy.entity.ModelEntity
;
import
net.mingsoft.mdiy.util.ParserUtil
;
import
net.mingsoft.mdiy.util.ParserUtil
;
...
@@ -122,7 +121,6 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
...
@@ -122,7 +121,6 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
// 网站风格物理路径
// 网站风格物理路径
List
<
CategoryBean
>
articleIdList
=
null
;
List
<
CategoryBean
>
articleIdList
=
null
;
List
<
CategoryEntity
>
categoryList
=
null
;
List
<
CategoryEntity
>
categoryList
=
null
;
AttributeBean
attributeBean
=
new
AttributeBean
();
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
<>();
...
@@ -145,12 +143,7 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
...
@@ -145,12 +143,7 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
LOG
.
error
(
"模板不存在:{}"
,
category
.
getCategoryUrl
());
LOG
.
error
(
"模板不存在:{}"
,
category
.
getCategoryUrl
());
continue
;
continue
;
}
}
// 获取文章列表表属性
ParserUtil
.
read
(
category
.
getCategoryListUrl
(),
map
,
page
,
attributeBean
);
contentBean
.
setFlag
(
attributeBean
.
getFlag
());
contentBean
.
setNoflag
(
attributeBean
.
getNoflag
());
contentBean
.
setOrder
(
attributeBean
.
getOrder
());
contentBean
.
setOrderBy
(
attributeBean
.
getOrderby
());
}
}
articleIdList
=
queryIdsByCategoryIdForParser
(
contentBean
);
articleIdList
=
queryIdsByCategoryIdForParser
(
contentBean
);
// 有符合条件的就更新
// 有符合条件的就更新
...
@@ -190,13 +183,7 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
...
@@ -190,13 +183,7 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
map
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
map
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
PAGE
,
page
);
map
.
put
(
ParserUtil
.
PAGE
,
page
);
AttributeBean
attributeBean
=
new
AttributeBean
();
// 获取文章列表模板标签属性
ParserUtil
.
read
(
column
.
getCategoryListUrl
(),
map
,
page
,
attributeBean
);
contentBean
.
setFlag
(
attributeBean
.
getFlag
());
contentBean
.
setNoflag
(
attributeBean
.
getNoflag
());
contentBean
.
setOrder
(
attributeBean
.
getOrder
());
contentBean
.
setOrderBy
(
attributeBean
.
getOrderby
());
}
}
articleIdList
=
contentDao
.
queryIdsByCategoryIdForParser
(
contentBean
);
articleIdList
=
contentDao
.
queryIdsByCategoryIdForParser
(
contentBean
);
// 判断列表类型
// 判断列表类型
...
@@ -242,7 +229,7 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
...
@@ -242,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/entity/CategoryEntity.java
View file @
50b1dd92
...
@@ -391,14 +391,6 @@ private static final long serialVersionUID = 1574925152750L;
...
@@ -391,14 +391,6 @@ private static final long serialVersionUID = 1574925152750L;
* 获取栏目图片 (标签使用)
* 获取栏目图片 (标签使用)
*/
*/
public
String
getTypelitpic
()
{
public
String
getTypelitpic
()
{
if
(
StrUtil
.
isNotBlank
(
categoryImg
)){
return
categoryImg
;
try
{
JSONArray
objects
=
JSON
.
parseArray
(
categoryImg
);
return
objects
.
getJSONObject
(
0
).
getString
(
"path"
);
}
catch
(
Exception
e
){
}
}
return
""
;
}
}
}
}
src/main/java/net/mingsoft/cms/util/CmsParserUtil.java
View file @
50b1dd92
...
@@ -11,7 +11,6 @@ import net.mingsoft.basic.util.BasicUtil;
...
@@ -11,7 +11,6 @@ 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.entity.CategoryEntity
;
import
net.mingsoft.cms.entity.CategoryEntity
;
import
net.mingsoft.mdiy.bean.AttributeBean
;
import
net.mingsoft.mdiy.bean.PageBean
;
import
net.mingsoft.mdiy.bean.PageBean
;
import
net.mingsoft.mdiy.biz.IModelBiz
;
import
net.mingsoft.mdiy.biz.IModelBiz
;
import
net.mingsoft.mdiy.biz.impl.ModelBizImpl
;
import
net.mingsoft.mdiy.biz.impl.ModelBizImpl
;
...
@@ -72,25 +71,36 @@ public class CmsParserUtil extends ParserUtil {
...
@@ -72,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
ContentModelId
!=
null
)
{
if
(
column
.
getMdiyModelId
()
!=
null
)
{
// 通过栏目模型编号获取自定义模型实体
// 通过栏目模型编号获取自定义模型实体
contentModel
=
(
ModelEntity
)
SpringUtil
.
getBean
(
ModelBizImpl
.
class
).
getEntity
(
column
ContentModelId
);
contentModel
=
(
ModelEntity
)
SpringUtil
.
getBean
(
ModelBizImpl
.
class
).
getEntity
(
column
.
getMdiyModelId
()
);
}
}
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
);
...
@@ -107,18 +117,15 @@ public class CmsParserUtil extends ParserUtil {
...
@@ -107,18 +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
);
AttributeBean
attributeBean
=
new
AttributeBean
();
int
pageNo
=
1
;
ParserUtil
.
read
(
File
.
separator
+
column
.
getCategoryListUrl
(),
parserParams
,
page
,
attributeBean
);
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
{
...
@@ -136,7 +143,7 @@ public class CmsParserUtil extends ParserUtil {
...
@@ -136,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
++;
}
}
...
...
src/main/webapp/WEB-INF/manager/cms/content/form.ftl
View file @
50b1dd92
...
@@ -525,9 +525,9 @@
...
@@ -525,9 +525,9 @@
});
});
},
},
//根据封面获取当前文章
//根据封面获取当前文章
get
By
FengMian
:
function
(
categoryId
)
{
get
From
FengMian
:
function
(
categoryId
)
{
var
that
=
this
;
var
that
=
this
;
ms
.
http
.
get
(
ms
.
manager
+
"/cms/content/get
By
FengMian.do"
,
{
ms
.
http
.
get
(
ms
.
manager
+
"/cms/content/get
From
FengMian.do"
,
{
"categoryId"
:
categoryId
"categoryId"
:
categoryId
}).
then
(
function
(
res
)
{
}).
then
(
function
(
res
)
{
if
(
res
.
result
)
{
if
(
res
.
result
)
{
...
@@ -680,7 +680,7 @@
...
@@ -680,7 +680,7 @@
this
.
get
(
this
.
form
.
id
);
this
.
get
(
this
.
form
.
id
);
}
}
if
(
this
.
type
)
{
if
(
this
.
type
)
{
this
.
get
By
FengMian
(
this
.
form
.
categoryId
);
this
.
get
From
FengMian
(
this
.
form
.
categoryId
);
this
.
returnIsShow
=
false
;
this
.
returnIsShow
=
false
;
}
}
}
}
...
...
src/main/webapp/WEB-INF/manager/cms/content/index.ftl
View file @
50b1dd92
...
@@ -122,7 +122,7 @@
...
@@ -122,7 +122,7 @@
#index
.left-tree
{
#index
.left-tree
{
min-height
:
100vh
;
min-height
:
100vh
;
background
:
#fff
;
background
:
#fff
;
width
:
18
0px
;
width
:
22
0px
;
border-right
:
solid
1px
#e6e6e6
;
border-right
:
solid
1px
#e6e6e6
;
}
}
...
...
src/main/webapp/WEB-INF/manager/cms/content/main.ftl
View file @
50b1dd92
...
@@ -68,7 +68,7 @@
...
@@ -68,7 +68,7 @@
</el-popover>
</el-popover>
</template>
</template>
</el-table-column>
</el-table-column>
<el-table-column
label=
"栏目名"
align=
"left"
prop=
"categoryId"
:formatter=
"contentCategoryIdFormat"
width=
"1
0
0"
>
<el-table-column
label=
"栏目名"
align=
"left"
prop=
"categoryId"
:formatter=
"contentCategoryIdFormat"
width=
"1
8
0"
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"文章标题"
align=
"left"
prop=
"contentTitle"
show-overflow-tooltip
>
<el-table-column
label=
"文章标题"
align=
"left"
prop=
"contentTitle"
show-overflow-tooltip
>
</el-table-column>
</el-table-column>
...
...
src/main/webapp/WEB-INF/manager/index.ftl
View file @
50b1dd92
...
@@ -328,7 +328,8 @@
...
@@ -328,7 +328,8 @@
})
})
if
(
sub
.
syncStoreUrl
)
{
if
(
sub
.
syncStoreUrl
)
{
sub
.
modelUrl
=
sub
.
syncStoreUrl
//sub.modelUrl = "http://store.web.i.mingsoft.net/#/?client=localhost:8080//ms";
sub
.
modelUrl
=
sub
.
syncStoreUrl
;
sub
.
modelTitle
=
'mstore'
;
sub
.
modelTitle
=
'mstore'
;
sub
.
isStore
=
true
;
sub
.
isStore
=
true
;
!
result
?
this
.
editableTabs
.
push
(
sub
)
:
""
!
result
?
this
.
editableTabs
.
push
(
sub
)
:
""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment