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
e9aeeeca
Commit
e9aeeeca
authored
Dec 23, 2019
by
zhongyh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新文章点击数aop
parent
7f161244
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
124 additions
and
36 deletions
+124
-36
ContentAction.java
src/main/java/net/mingsoft/cms/action/web/ContentAction.java
+43
-36
CotentAop.java
src/main/java/net/mingsoft/cms/aop/CotentAop.java
+81
-0
vue-ueditor-wrap.min.js
...p/static/plugins/vue-ueditor-wrap/vue-ueditor-wrap.min.js
+0
-0
No files found.
src/main/java/net/mingsoft/cms/action/web/ContentAction.java
View file @
e9aeeeca
package
net
.
mingsoft
.
cms
.
action
.
web
;
import
java.util.List
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
com.alibaba.fastjson.JSON
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
net.mingsoft.base.entity.BaseEntity
;
import
net.mingsoft.base.entity.ResultData
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.validation.BindingResult
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.ui.ModelMap
;
import
net.mingsoft.basic.bean.EUListBean
;
import
net.mingsoft.basic.util.BasicUtil
;
import
net.mingsoft.basic.util.StringUtil
;
import
net.mingsoft.cms.biz.IContentBiz
;
import
net.mingsoft.cms.entity.ContentEntity
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.ui.ModelMap
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
net.mingsoft.cms.biz.IContentBiz
;
import
net.mingsoft.cms.entity.ContentEntity
;
import
net.mingsoft.base.util.JSONObject
;
import
net.mingsoft.base.entity.BaseEntity
;
import
net.mingsoft.basic.util.BasicUtil
;
import
net.mingsoft.basic.util.StringUtil
;
import
net.mingsoft.base.filter.DateValueFilter
;
import
net.mingsoft.base.filter.DoubleValueFilter
;
import
net.mingsoft.basic.bean.EUListBean
;
import
net.mingsoft.basic.annotation.LogAnn
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
springfox.documentation.annotations.ApiIgnore
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
/**
* 文章管理控制层
* @author 铭飞开发团队
...
...
@@ -186,7 +172,7 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
}
/**
* @param content 文章实体
* @param content
s
文章实体
*/
@ApiOperation
(
value
=
"批量删除文章列表接口"
)
@PostMapping
(
"/delete"
)
...
...
@@ -255,6 +241,26 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
return
ResultData
.
build
().
success
(
content
);
}
@ApiOperation
(
value
=
"查看文章点击数"
)
@ApiImplicitParam
(
name
=
"contentId"
,
value
=
"文章编号"
,
required
=
true
,
paramType
=
"path"
)
@GetMapping
(
value
=
"/{contentId}/hit"
)
@ResponseBody
public
void
hit
(
@PathVariable
@ApiIgnore
int
contentId
,
HttpServletRequest
request
,
HttpServletResponse
response
){
if
(
contentId
<=
0
){
this
.
outString
(
response
,
"document.write(0)"
);
return
;
}
ContentEntity
content
=
(
ContentEntity
)
contentBiz
.
getEntity
(
contentId
);
if
(
content
==
null
){
this
.
outString
(
response
,
"document.write(0)"
);
return
;
}
if
(
content
.
getAppId
()
==
null
||
content
.
getAppId
()
!=
BasicUtil
.
getAppId
()){
this
.
outString
(
response
,
"document.write(0)"
);
return
;
}
this
.
outString
(
response
,
"document.write("
+
content
.
getContentHit
()
+
")"
);
return
;
}
}
\ No newline at end of file
src/main/java/net/mingsoft/cms/aop/CotentAop.java
0 → 100644
View file @
e9aeeeca
package
net
.
mingsoft
.
cms
.
aop
;
import
net.mingsoft.basic.aop.BaseAop
;
import
net.mingsoft.basic.util.BasicUtil
;
import
net.mingsoft.cms.biz.IContentBiz
;
import
net.mingsoft.cms.biz.IHistoryLogBiz
;
import
net.mingsoft.cms.entity.ContentEntity
;
import
net.mingsoft.cms.entity.HistoryLogEntity
;
import
org.apache.commons.lang3.StringUtils
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author 铭飞开源团队
* @date 2019/12/23
*/
@Component
@Aspect
public
class
CotentAop
extends
BaseAop
{
/**
* 注入文章业务
*/
@Autowired
private
IContentBiz
contentBiz
;
/**
* 注入浏览记录业务
*/
@Autowired
private
IHistoryLogBiz
historyLogBiz
;
/**
* 文章浏览记录,
* 如果该文章该ip已经记录过,则不在重复记录
* @param pjp
* @return
* @throws Throwable
*/
@Around
(
"execution(* net.mingsoft.cms.action.web.ContentAction.get(..))"
)
public
Object
get
(
ProceedingJoinPoint
pjp
)
throws
Throwable
{
// 获取方法参数
ContentEntity
content
=
getType
(
pjp
,
ContentEntity
.
class
);
// 如果id为空则直接发行
if
(
content
.
getId
()==
null
)
{
return
pjp
.
proceed
();
}
content
=
(
ContentEntity
)
contentBiz
.
getEntity
(
Integer
.
parseInt
(
content
.
getId
()));
//如果文章不存在则直接发行
if
(
content
==
null
){
return
pjp
.
proceed
();
}
//查询判断该ip是否已经有浏览记录了
HistoryLogEntity
historyLog
=
new
HistoryLogEntity
();
historyLog
.
setContentId
(
content
.
getId
());
historyLog
.
setHlIp
(
BasicUtil
.
getIp
());
historyLog
.
setHlIsMobile
(
BasicUtil
.
isMobileDevice
());
HistoryLogEntity
_historyLog
=
(
HistoryLogEntity
)
historyLogBiz
.
getEntity
(
historyLog
);
//如果该ip该文章没有浏览记录则保存浏览记录
//并且更新点击数
if
(
_historyLog
==
null
||
StringUtils
.
isBlank
(
_historyLog
.
getId
())){
historyLogBiz
.
saveEntity
(
historyLog
);
//更新点击数
ContentEntity
updateContent
=
new
ContentEntity
();
updateContent
.
setId
(
content
.
getId
());
if
(
content
.
getContentHit
()
==
null
){
updateContent
.
setContentHit
(
1
);
}
else
{
updateContent
.
setContentHit
(
content
.
getContentHit
()+
1
);
}
contentBiz
.
updateEntity
(
updateContent
);
}
return
pjp
.
proceed
();
}
}
src/main/webapp/static/plugins/vue-ueditor-wrap/vue-ueditor-wrap.min.js
View file @
e9aeeeca
This diff is collapsed.
Click to expand it.
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