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
4aacdabf
Commit
4aacdabf
authored
Sep 16, 2020
by
guwd
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
7cc07281
d4b7b2b8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
18 deletions
+98
-18
GeneraterAction.java
src/main/java/net/mingsoft/cms/action/GeneraterAction.java
+15
-18
CategoryEntity.java
src/main/java/net/mingsoft/cms/entity/CategoryEntity.java
+67
-0
CmsParserUtil.java
src/main/java/net/mingsoft/cms/util/CmsParserUtil.java
+4
-0
index.ftl
src/main/webapp/WEB-INF/manager/cms/generate/index.ftl
+12
-0
No files found.
src/main/java/net/mingsoft/cms/action/GeneraterAction.java
View file @
4aacdabf
...
...
@@ -24,7 +24,10 @@ package net.mingsoft.cms.action;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.copier.CopyOptions
;
import
cn.hutool.core.io.FileUtil
;
import
net.mingsoft.base.entity.ResultData
;
import
net.mingsoft.basic.annotation.LogAnn
;
import
net.mingsoft.basic.biz.IModelBiz
;
import
net.mingsoft.basic.constant.e.BusinessTypeEnum
;
import
net.mingsoft.basic.entity.AppEntity
;
import
net.mingsoft.basic.util.BasicUtil
;
import
net.mingsoft.cms.bean.CategoryBean
;
...
...
@@ -120,8 +123,9 @@ public class GeneraterAction extends BaseAction {
*/
@RequestMapping
(
"/generateIndex"
)
@RequiresPermissions
(
"cms:generate:index"
)
@LogAnn
(
title
=
"生成主页"
,
businessType
=
BusinessTypeEnum
.
UPDATE
)
@ResponseBody
public
void
generateIndex
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
ResultData
generateIndex
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
// 模版文件名称
String
tmpFileName
=
request
.
getParameter
(
"url"
);
// 生成后的文件名称
...
...
@@ -129,15 +133,10 @@ public class GeneraterAction extends BaseAction {
// 获取文件所在路径 首先判断用户输入的模版文件是否存在
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
()))
{
this
.
outJson
(
response
,
false
,
getResString
(
"templet.file"
));
return
ResultData
.
build
().
error
(
getResString
(
"templet.file"
));
}
else
{
try
{
CmsParserUtil
.
generate
(
tmpFileName
,
generateFileName
);
this
.
outJson
(
response
,
true
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
this
.
outJson
(
response
,
false
);
}
return
ResultData
.
build
().
success
();
}
}
...
...
@@ -151,9 +150,10 @@ public class GeneraterAction extends BaseAction {
* @param CategoryId
*/
@RequestMapping
(
"/{CategoryId}/genernateColumn"
)
@LogAnn
(
title
=
"生成栏目"
,
businessType
=
BusinessTypeEnum
.
UPDATE
)
@RequiresPermissions
(
"cms:generate:column"
)
@ResponseBody
public
void
genernateColumn
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
int
CategoryId
)
{
public
ResultData
genernateColumn
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
int
CategoryId
)
throws
IOException
{
// 获取站点id
AppEntity
app
=
BasicUtil
.
getApp
();
List
<
CategoryEntity
>
columns
=
new
ArrayList
<
CategoryEntity
>();
...
...
@@ -170,7 +170,6 @@ public class GeneraterAction extends BaseAction {
columns
=
categoryBiz
.
query
(
categoryEntity
);
}
List
<
CategoryBean
>
articleIdList
=
null
;
try
{
// 1、设置模板文件夹路径
// 获取栏目列表模版
for
(
CategoryEntity
column
:
columns
)
{
...
...
@@ -217,11 +216,8 @@ public class GeneraterAction extends BaseAction {
break
;
}
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
this
.
outJson
(
response
,
false
);
}
this
.
outJson
(
response
,
true
);
return
ResultData
.
build
().
success
();
}
/**
...
...
@@ -233,8 +229,9 @@ public class GeneraterAction extends BaseAction {
*/
@RequestMapping
(
"/{columnId}/generateArticle"
)
@RequiresPermissions
(
"cms:generate:article"
)
@LogAnn
(
title
=
"生成文章"
,
businessType
=
BusinessTypeEnum
.
UPDATE
)
@ResponseBody
public
void
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"
);
// 网站风格物理路径
List
<
CategoryBean
>
articleIdList
=
null
;
...
...
@@ -282,7 +279,7 @@ public class GeneraterAction extends BaseAction {
// 判断模板文件是否存在
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
(
category
.
getCategoryUrl
())))
{
LOG
.
error
(
"模板不存在:{}"
,
category
.
getCategoryUrl
());
return
;
return
ResultData
.
build
().
error
(
getResString
(
"templet.file"
))
;
}
ParserUtil
.
read
(
category
.
getCategoryListUrl
(),
map
,
page
,
attributeBean
);
contentBean
.
setFlag
(
attributeBean
.
getFlag
());
...
...
@@ -296,7 +293,7 @@ public class GeneraterAction extends BaseAction {
CmsParserUtil
.
generateBasic
(
articleIdList
);
}
}
this
.
outJson
(
response
,
true
);
return
ResultData
.
build
().
success
(
);
}
...
...
src/main/java/net/mingsoft/cms/entity/CategoryEntity.java
View file @
4aacdabf
package
net
.
mingsoft
.
cms
.
entity
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
...
...
@@ -338,4 +341,68 @@ private static final long serialVersionUID = 1574925152750L;
public
String
getCategoryParentId
()
{
return
this
.
categoryParentId
;
}
/**
* 获取栏目标题 (标签使用)
*/
public
String
getTypetitle
()
{
return
this
.
categoryTitle
;
}
/**
* 获取栏目链接 (标签使用,动态链接不考虑)
*/
public
String
getTypelink
()
{
return
"3"
.
equals
(
this
.
categoryType
)?
this
.
categoryDiyUrl
:
this
.
categoryPath
+
"/index.html"
;
}
/**
* 获取栏目关键字 (标签使用)
*/
public
String
getTypekeyword
()
{
return
this
.
categoryKeyword
;
}
/**
* 获取栏目url (标签使用)
*/
public
String
getTypeurl
()
{
return
this
.
categoryDiyUrl
;
}
/**
* 获取栏目属性 (标签使用)
*/
public
String
getFlag
()
{
return
this
.
categoryFlag
;
}
/**
* 获取栏目父级Id (标签使用)
*/
public
String
getParentid
()
{
return
this
.
categoryParentId
;
}
/**
* 获取栏目描述(标签使用)
*/
public
String
getTypedescrip
()
{
return
this
.
categoryDescrip
;
}
/**
* 获取栏目Id(标签使用)
*/
public
String
getTypeid
()
{
return
this
.
id
;
}
/**
* 获取栏目图片 (标签使用)
*/
public
String
getTypelitpic
()
{
if
(
StrUtil
.
isNotBlank
(
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 @
4aacdabf
...
...
@@ -38,6 +38,8 @@ public class CmsParserUtil extends ParserUtil {
*/
private
static
int
COLUMN_TYPE_COVER
=
2
;
private
final
static
String
FIELD
=
"field"
;
/**
* 指定模板,指定路径进行生成静态页面,会自定识别pc与移动端
*
...
...
@@ -90,6 +92,8 @@ public class CmsParserUtil extends ParserUtil {
//全局参数设置
Map
<
String
,
Object
>
parserParams
=
new
HashMap
<
String
,
Object
>();
parserParams
.
put
(
COLUMN
,
column
);
//标签中使用field获取当前栏目
parserParams
.
put
(
FIELD
,
column
);
parserParams
.
put
(
IS_DO
,
false
);
parserParams
.
put
(
HTML
,
HTML
);
parserParams
.
put
(
APP_ID
,
BasicUtil
.
getAppId
());
...
...
src/main/webapp/WEB-INF/manager/cms/generate/index.ftl
View file @
4aacdabf
...
...
@@ -212,6 +212,12 @@
title
:
'更新成功!'
,
type
:
'success'
});
}
else
{
that
.
$notify
({
title
:
'生成失败'
,
message
:
data
.
msg
,
type
:
'error'
});
}
}).
catch
(
function
(
err
)
{
that
.
$notify
({
...
...
@@ -236,6 +242,12 @@
title
:
'更新成功!'
,
type
:
'success'
});
}
else
{
that
.
$notify
({
title
:
'生成失败!'
,
message
:
data
.
msg
,
type
:
'error'
});
}
}).
catch
(
function
(
err
)
{
that
.
$notify
({
...
...
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