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
a0c6f997
Commit
a0c6f997
authored
Sep 27, 2020
by
wujj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口规范
parent
92867835
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
26 deletions
+23
-26
ContentAction.java
src/main/java/net/mingsoft/cms/action/web/ContentAction.java
+7
-13
MCmsAction.java
src/main/java/net/mingsoft/cms/action/web/MCmsAction.java
+16
-13
No files found.
src/main/java/net/mingsoft/cms/action/web/ContentAction.java
View file @
a0c6f997
...
@@ -103,10 +103,9 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
...
@@ -103,10 +103,9 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
@ApiImplicitParam
(
name
=
"contentId"
,
value
=
"文章编号"
,
required
=
true
,
paramType
=
"path"
)
@ApiImplicitParam
(
name
=
"contentId"
,
value
=
"文章编号"
,
required
=
true
,
paramType
=
"path"
)
@GetMapping
(
value
=
"/{contentId}/hit"
)
@GetMapping
(
value
=
"/{contentId}/hit"
)
@ResponseBody
@ResponseBody
public
void
hit
(
@PathVariable
@ApiIgnore
int
contentId
,
HttpServletRequest
request
,
HttpServletResponse
response
){
public
String
hit
(
@PathVariable
@ApiIgnore
int
contentId
,
HttpServletRequest
request
,
HttpServletResponse
response
){
if
(
contentId
<=
0
){
if
(
contentId
<=
0
){
this
.
outString
(
response
,
"document.write(0)"
);
return
"document.write(0)"
;
return
;
}
}
//获取ip
//获取ip
String
ip
=
BasicUtil
.
getIp
();
String
ip
=
BasicUtil
.
getIp
();
...
@@ -114,11 +113,13 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
...
@@ -114,11 +113,13 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
boolean
isMobileDevice
=
BasicUtil
.
isMobileDevice
();
boolean
isMobileDevice
=
BasicUtil
.
isMobileDevice
();
ContentEntity
content
=
(
ContentEntity
)
contentBiz
.
getEntity
(
contentId
);
ContentEntity
content
=
(
ContentEntity
)
contentBiz
.
getEntity
(
contentId
);
if
(
content
==
null
){
return
"document.write(0)"
;
}
//浏览数+1
//浏览数+1
content
.
setContentHit
(
content
.
getContentHit
()+
1
);
content
.
setContentHit
(
content
.
getContentHit
()+
1
);
contentBiz
.
updateEntity
(
content
);
contentBiz
.
updateEntity
(
content
);
// cms_history 增加相应记录
// cms_history 增加相应记录
HistoryLogEntity
entity
=
new
HistoryLogEntity
();
HistoryLogEntity
entity
=
new
HistoryLogEntity
();
entity
.
setHlIsMobile
(
isMobileDevice
);
entity
.
setHlIsMobile
(
isMobileDevice
);
...
@@ -126,17 +127,10 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
...
@@ -126,17 +127,10 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
entity
.
setContentId
(
content
.
getId
());
entity
.
setContentId
(
content
.
getId
());
entity
.
setCreateDate
(
new
Date
());
entity
.
setCreateDate
(
new
Date
());
historyLogBiz
.
saveEntity
(
entity
);
historyLogBiz
.
saveEntity
(
entity
);
if
(
content
==
null
){
this
.
outString
(
response
,
"document.write(0)"
);
return
;
}
if
(
content
.
getAppId
()
==
null
||
content
.
getAppId
()
!=
BasicUtil
.
getAppId
()){
if
(
content
.
getAppId
()
==
null
||
content
.
getAppId
()
!=
BasicUtil
.
getAppId
()){
this
.
outString
(
response
,
"document.write(0)"
);
return
"document.write(0)"
;
return
;
}
}
this
.
outString
(
response
,
"document.write("
+
content
.
getContentHit
()
+
")"
);
return
"document.write("
+
content
.
getContentHit
()
+
")"
;
return
;
}
}
}
}
src/main/java/net/mingsoft/cms/action/web/MCmsAction.java
View file @
a0c6f997
...
@@ -26,7 +26,9 @@ import cn.hutool.core.util.PageUtil;
...
@@ -26,7 +26,9 @@ 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.TemplateNotFoundException
;
import
freemarker.template.TemplateNotFoundException
;
import
net.bytebuddy.implementation.bytecode.Throw
;
import
net.mingsoft.base.constant.Const
;
import
net.mingsoft.base.constant.Const
;
import
net.mingsoft.basic.exception.BusinessException
;
import
net.mingsoft.basic.util.BasicUtil
;
import
net.mingsoft.basic.util.BasicUtil
;
import
net.mingsoft.basic.util.StringUtil
;
import
net.mingsoft.basic.util.StringUtil
;
import
net.mingsoft.cms.bean.CategoryBean
;
import
net.mingsoft.cms.bean.CategoryBean
;
...
@@ -105,7 +107,8 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -105,7 +107,8 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
* 动态列表页
* 动态列表页
*/
*/
@GetMapping
(
"/index.do"
)
@GetMapping
(
"/index.do"
)
public
void
index
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
{
@ResponseBody
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"
));
...
@@ -129,7 +132,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -129,7 +132,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
this
.
outString
(
resp
,
content
)
;
return
content
;
}
}
/**
/**
...
@@ -137,8 +140,9 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -137,8 +140,9 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
* @param req
* @param req
* @param resp
* @param resp
*/
*/
@ResponseBody
@GetMapping
(
"/list.do"
)
@GetMapping
(
"/list.do"
)
public
void
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"
));
...
@@ -152,7 +156,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -152,7 +156,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
List
<
CategoryBean
>
columnArticles
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
List
<
CategoryBean
>
columnArticles
=
contentBiz
.
queryIdsByCategoryIdForParser
(
contentBean
);
//判断栏目下是否有文章
//判断栏目下是否有文章
if
(
columnArticles
.
size
()==
0
){
if
(
columnArticles
.
size
()==
0
){
this
.
outJson
(
resp
,
false
)
;
return
""
;
}
}
//设置分页类
//设置分页类
PageBean
page
=
new
PageBean
();
PageBean
page
=
new
PageBean
();
...
@@ -185,7 +189,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -185,7 +189,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
this
.
outString
(
resp
,
content
)
;
return
content
;
}
}
/**
/**
...
@@ -193,18 +197,17 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -193,18 +197,17 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
* @param id 文章编号
* @param id 文章编号
*/
*/
@GetMapping
(
"/view.do"
)
@GetMapping
(
"/view.do"
)
public
void
view
(
String
orderby
,
String
order
,
HttpServletRequest
req
,
HttpServletResponse
resp
)
{
@ResponseBody
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
)){
this
.
outJson
(
resp
,
null
,
false
,
getResString
(
"err.empty"
,
this
.
getResString
(
"id"
)));
throw
new
BusinessException
(
this
.
getResString
(
"err.empty"
,
this
.
getResString
(
"id"
)))
;
return
;
}
}
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"
)){
this
.
outJson
(
resp
,
null
,
false
,
getResString
(
"err.error"
,
this
.
getResString
(
"order"
)));
throw
new
BusinessException
(
this
.
getResString
(
"err.error"
,
this
.
getResString
(
"order"
)));
return
;
}
}
}
}
...
@@ -289,7 +292,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -289,7 +292,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
this
.
outString
(
resp
,
content
)
;
return
content
;
}
}
...
@@ -303,7 +306,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -303,7 +306,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
*/
*/
@RequestMapping
(
value
=
"search"
)
@RequestMapping
(
value
=
"search"
)
@ResponseBody
@ResponseBody
public
void
search
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
public
String
search
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
// 读取请求字段
// 读取请求字段
...
@@ -447,7 +450,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -447,7 +450,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
this
.
outString
(
response
,
content
)
;
return
content
;
}
}
// 清除路径中的转义字符
// 清除路径中的转义字符
...
...
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