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
e9aeeeca
Commit
e9aeeeca
authored
Dec 23, 2019
by
zhongyh
Browse files
更新文章点击数aop
parent
7f161244
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
src/main/java/net/mingsoft/cms/action/web/ContentAction.java
View file @
e9aeeeca
package
net.mingsoft.cms.action.web
;
package
net.mingsoft.cms.action.web
;
import
java.util.List
;
import
io.swagger.annotations.Api
;
import
java.io.File
;
import
io.swagger.annotations.ApiImplicitParam
;
import
java.util.ArrayList
;
import
io.swagger.annotations.ApiImplicitParams
;
import
java.util.Map
;
import
io.swagger.annotations.ApiOperation
;
import
java.util.regex.Matcher
;
import
net.mingsoft.base.entity.BaseEntity
;
import
java.util.regex.Pattern
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
com.alibaba.fastjson.JSON
;
import
net.mingsoft.base.entity.ResultData
;
import
net.mingsoft.base.entity.ResultData
;
import
org.apache.commons.lang3.StringUtils
;
import
net.mingsoft.basic.bean.EUListBean
;
import
org.springframework.validation.BindingResult
;
import
net.mingsoft.basic.util.BasicUtil
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
net.mingsoft.basic.util.StringUtil
;
import
org.springframework.ui.ModelMap
;
import
net.mingsoft.cms.biz.IContentBiz
;
import
net.mingsoft.cms.entity.ContentEntity
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.ui.ModelMap
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.GetMapping
;
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.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
net.mingsoft.cms.biz.IContentBiz
;
import
org.springframework.web.bind.annotation.ResponseBody
;
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
springfox.documentation.annotations.ApiIgnore
;
import
springfox.documentation.annotations.ApiIgnore
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
/**
/**
* 文章管理控制层
* 文章管理控制层
* @author 铭飞开发团队
* @author 铭飞开发团队
...
@@ -186,7 +172,7 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
...
@@ -186,7 +172,7 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
}
}
/**
/**
* @param content 文章实体
* @param content
s
文章实体
*/
*/
@ApiOperation
(
value
=
"批量删除文章列表接口"
)
@ApiOperation
(
value
=
"批量删除文章列表接口"
)
@PostMapping
(
"/delete"
)
@PostMapping
(
"/delete"
)
...
@@ -255,6 +241,26 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
...
@@ -255,6 +241,26 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
return
ResultData
.
build
().
success
(
content
);
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
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