Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
brandkbs2
Overview
Overview
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
shenjunjie
brandkbs2
Commits
3551ee37
Commit
3551ee37
authored
Sep 15, 2022
by
陈健智
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口访问日志记录
parent
79a94238
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
217 additions
and
28 deletions
+217
-28
src/main/java/com/zhiwei/brandkbs2/aop/AopLogRecord.java
+129
-0
src/main/java/com/zhiwei/brandkbs2/controller/admin/ArticleController.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/controller/admin/CustomTagController.java
+3
-3
src/main/java/com/zhiwei/brandkbs2/controller/admin/EventController.java
+10
-10
src/main/java/com/zhiwei/brandkbs2/controller/admin/ProjectController.java
+6
-6
src/main/java/com/zhiwei/brandkbs2/controller/admin/UserController.java
+5
-5
src/main/java/com/zhiwei/brandkbs2/controller/app/AppSearchController.java
+2
-0
src/main/java/com/zhiwei/brandkbs2/pojo/Behavior.java
+49
-1
src/main/java/com/zhiwei/brandkbs2/service/BehaviorService.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/service/impl/BehaviorServiceImpl.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
+10
-0
No files found.
src/main/java/com/zhiwei/brandkbs2/aop/AopLogRecord.java
0 → 100644
View file @
3551ee37
package
com
.
zhiwei
.
brandkbs2
.
aop
;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.common.GenericAttribute
;
import
com.zhiwei.brandkbs2.dao.BehaviorDao
;
import
com.zhiwei.brandkbs2.pojo.Behavior
;
import
com.zhiwei.brandkbs2.service.UserService
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
com.zhiwei.middleware.auth.util.JwtUtil
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Before
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.request.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.servlet.HandlerMapping
;
import
javax.annotation.Resource
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.*
;
import
static
java
.
util
.
Objects
.
nonNull
;
/**
* @author cjz
* @ClassName AopLogRecord
* @Description 接口访问日志记录
* @date 2022-09-13 15:25
*/
@Aspect
@Component
public
class
AopLogRecord
{
@Value
(
"${jwt.key}"
)
private
String
jwtKey
;
@Resource
(
name
=
"userServiceImpl"
)
private
UserService
userService
;
@Resource
(
name
=
"behaviorDao"
)
private
BehaviorDao
behaviorDao
;
private
static
final
List
<
String
>
URL_PATTERNS
=
Arrays
.
asList
(
"/getNewAll"
,
"/getNew"
,
"/schedule"
);
@Before
(
"execution(public * com..controller..*Controller.*(..)) && !execution(* com..controller..BaseController.*(..))"
)
private
void
beforeLog
(
JoinPoint
joinPoint
)
throws
UnknownHostException
{
long
now
=
System
.
currentTimeMillis
();
// RequestContextHolder是持有上下文的Request容器
ServletRequestAttributes
requestAttributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
// 获取request对象
HttpServletRequest
request
=
Objects
.
requireNonNull
(
requestAttributes
).
getRequest
();
// webRequest拿路径的uri和request拿的uri有区别
NativeWebRequest
webRequest
=
new
ServletWebRequest
(
request
);
Object
webRequestAttribute
=
webRequest
.
getAttribute
(
HandlerMapping
.
BEST_MATCHING_PATTERN_ATTRIBUTE
,
RequestAttributes
.
SCOPE_REQUEST
);
if
(
filterUrl
(
webRequestAttribute
))
{
// controller接口信息
String
httpMethod
=
request
.
getMethod
();
String
uri
=
request
.
getRequestURI
();
String
methodName
=
joinPoint
.
getSignature
().
getName
();
if
(!(
Tools
.
isNullOrUndefined
(
request
.
getHeader
(
jwtKey
))
||
Tools
.
isNullOrUndefined
(
request
.
getHeader
(
"pid"
))))
{
// 用户信息
String
userId
=
JwtUtil
.
unsign
(
request
.
getHeader
(
jwtKey
),
Map
.
class
).
get
(
GenericAttribute
.
USER_ID
).
toString
();
String
projectId
=
request
.
getHeader
(
"pid"
);
String
nickName
=
userService
.
queryUserInfo
(
userId
,
projectId
).
getNickname
();
// 请求地址和服务器地址
String
severAddress
=
InetAddress
.
getLocalHost
().
getHostAddress
();
String
ipAddress
=
Tools
.
getIpAddress
(
request
);
// 接口传参信息
List
<
Map
<
String
,
Object
>>
requestArguments
=
getRequestArguments
(
joinPoint
);
Behavior
behavior
=
Behavior
.
createBehaviorNew
(
userId
,
nickName
,
projectId
,
uri
,
methodName
,
httpMethod
,
requestArguments
,
now
,
now
,
severAddress
,
ipAddress
);
String
collectionName
=
behaviorDao
.
generateCollectionName
();
behaviorDao
.
insertOneWithoutId
(
behavior
,
collectionName
);
}
}
}
private
List
<
Map
<
String
,
Object
>>
getRequestArguments
(
JoinPoint
joinPoint
)
{
List
<
Map
<
String
,
Object
>>
arguments
=
new
ArrayList
<>();
// 获取参数名
MethodSignature
methodSignature
=
(
MethodSignature
)
joinPoint
.
getSignature
();
String
[]
parameterNames
=
methodSignature
.
getParameterNames
();
// 获取参数值
for
(
int
i
=
0
;
i
<
joinPoint
.
getArgs
().
length
;
i
++)
{
// 过滤HttpServletRequest参数
if
(
joinPoint
.
getArgs
()[
i
]
instanceof
ServletRequest
)
{
continue
;
}
// formdata文件类型判断
if
(
joinPoint
.
getArgs
()[
i
]
instanceof
MultipartFile
)
{
Map
<
String
,
Object
>
fileMap
=
new
HashMap
<>();
fileMap
.
put
(
"name"
,
parameterNames
[
i
]);
MultipartFile
file
=
(
MultipartFile
)
joinPoint
.
getArgs
()[
i
];
// 文件名
fileMap
.
put
(
"value"
,
file
.
getOriginalFilename
());
arguments
.
add
(
fileMap
);
continue
;
}
// 参数pathId、param、body
Map
<
String
,
Object
>
parameterMap
=
new
HashMap
<>();
parameterMap
.
put
(
"name"
,
parameterNames
[
i
]);
parameterMap
.
put
(
"value"
,
String
.
valueOf
(
joinPoint
.
getArgs
()[
i
]));
arguments
.
add
(
parameterMap
);
}
return
arguments
;
}
/**
* url过滤
* @param attribute url
* @return
*/
private
boolean
filterUrl
(
Object
attribute
){
if
(!
nonNull
(
attribute
))
{
return
false
;
}
String
requestURI
=
String
.
valueOf
(
attribute
);
for
(
String
urlPattern
:
URL_PATTERNS
)
{
if
(
requestURI
.
contains
(
urlPattern
))
{
return
false
;
}
}
return
true
;
}
}
src/main/java/com/zhiwei/brandkbs2/controller/admin/ArticleController.java
View file @
3551ee37
...
...
@@ -178,7 +178,7 @@ public class ArticleController extends BaseController {
requestMap
.
add
(
"projectId"
,
projectService
.
getProjectByContendId
(
UserThreadLocal
.
getProjectId
(),
contendId
).
getBrandLinkedGroupId
());
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
requestEntity
=
new
HttpEntity
<>(
requestMap
,
getHeadersForm
());
HttpEntity
<
JSONObject
>
entity
=
restTemplate
.
exchange
(
yuqingInterface
+
"/upload/form"
,
HttpMethod
.
POST
,
requestEntity
,
JSONObject
.
class
);
behaviorService
.
pushBehavior
(
OPERATION
,
"上传表格"
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"上传表格"
,
request
);
return
ResponseResult
.
convertFromYuQingInterface
(
entity
.
getBody
(),
null
);
}
catch
(
Exception
e
)
{
log
.
error
(
"稿件上传-上传表格异常"
,
e
);
...
...
src/main/java/com/zhiwei/brandkbs2/controller/admin/CustomTagController.java
View file @
3551ee37
...
...
@@ -53,7 +53,7 @@ public class CustomTagController extends BaseController {
public
ResponseResult
addCustomTag
(
@ApiIgnore
@RequestBody
JSONObject
json
)
{
customTagService
.
addCustomTag
(
json
.
getString
(
"tagName"
),
parseArray
(
json
.
getString
(
"sonTagNames"
),
String
.
class
));
// 添加用户行为
behaviorService
.
pushBehavior
(
OPERATION
,
"添加自定义标签"
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"添加自定义标签"
,
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -66,7 +66,7 @@ public class CustomTagController extends BaseController {
String
tagId
=
json
.
getString
(
"tagId"
);
customTagService
.
updateCustomTag
(
tagName
,
sonTagNames
,
tagId
);
// 添加用户行为
behaviorService
.
pushBehavior
(
OPERATION
,
"修改自定义标签"
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"修改自定义标签"
,
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -77,7 +77,7 @@ public class CustomTagController extends BaseController {
public
ResponseResult
deleteCustomTag
(
@PathVariable
String
tagId
)
{
customTagService
.
deleteCustomTagByTagId
(
tagId
);
// 添加用户行为
behaviorService
.
pushBehavior
(
OPERATION
,
"删除自定义标签"
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"删除自定义标签"
,
request
);
return
ResponseResult
.
success
();
}
}
src/main/java/com/zhiwei/brandkbs2/controller/admin/EventController.java
View file @
3551ee37
...
...
@@ -108,7 +108,7 @@ public class EventController extends BaseController {
@PutMapping
(
"/update"
)
public
ResponseResult
updateEvent
(
@RequestBody
EventVO
eventVO
)
{
eventService
.
updateEvent
(
eventVO
);
behaviorService
.
pushBehavior
(
OPERATION
,
"修改事件信息:"
+
eventVO
.
getId
(),
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"修改事件信息:"
+
eventVO
.
getId
(),
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -116,7 +116,7 @@ public class EventController extends BaseController {
@PutMapping
(
"/updateFirst"
)
public
ResponseResult
updateEventFirst
(
@RequestBody
EventDataDTO
eventDataDTO
)
{
eventService
.
updateEventFirst
(
eventDataDTO
);
behaviorService
.
pushBehavior
(
OPERATION
,
"修改事件首发信息:"
+
eventDataDTO
.
getEventId
(),
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"修改事件首发信息:"
+
eventDataDTO
.
getEventId
(),
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -125,7 +125,7 @@ public class EventController extends BaseController {
@PostMapping
(
"/analyze"
)
public
ResponseResult
analysisEvents
(
@RequestBody
JSONObject
info
)
{
eventService
.
analysisEvents
(
info
.
getJSONArray
(
"eventIds"
).
toJavaList
(
String
.
class
));
behaviorService
.
pushBehavior
(
OPERATION
,
"批量更新事件"
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"批量更新事件"
,
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -134,7 +134,7 @@ public class EventController extends BaseController {
@PutMapping
(
"/end/{eventId}"
)
public
ResponseResult
endEvent
(
@PathVariable
(
"eventId"
)
String
eventId
)
{
eventService
.
endEvent
(
eventId
);
behaviorService
.
pushBehavior
(
OPERATION
,
"结束事件:"
+
eventId
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"结束事件:"
+
eventId
,
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -143,7 +143,7 @@ public class EventController extends BaseController {
@DeleteMapping
(
"/delete/{eventId}"
)
public
ResponseResult
deleteEvent
(
@PathVariable
(
"eventId"
)
String
eventId
)
{
String
title
=
eventService
.
deleteEvent
(
eventId
);
behaviorService
.
pushBehavior
(
OPERATION
,
"删除事件:"
+
title
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"删除事件:"
+
title
,
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -154,7 +154,7 @@ public class EventController extends BaseController {
String
id
=
info
.
getString
(
"id"
);
String
eventId
=
info
.
getString
(
"eventId"
);
String
title
=
eventService
.
deleteEventData
(
id
,
eventId
);
behaviorService
.
pushBehavior
(
OPERATION
,
"删除事件单条数据,eventId:"
+
eventId
+
",数据id:"
+
id
+
",事件标题:"
+
title
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"删除事件单条数据,eventId:"
+
eventId
+
",数据id:"
+
id
+
",事件标题:"
+
title
,
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -225,7 +225,7 @@ public class EventController extends BaseController {
String
contendId
=
null
==
info
.
getString
(
"contendId"
)
?
"0"
:
info
.
getString
(
"contendId"
);
List
<
YqEventDTO
>
yqEventList
=
info
.
getJSONArray
(
"list"
).
toJavaList
(
YqEventDTO
.
class
);
eventService
.
addYqEvents
(
contendId
,
yqEventList
);
behaviorService
.
pushBehavior
(
OPERATION
,
"批量导入舆情事件数据"
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"批量导入舆情事件数据"
,
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -233,7 +233,7 @@ public class EventController extends BaseController {
@PutMapping
(
"/upload/yqAll"
)
public
ResponseResult
addEventAllByYq
(
@RequestBody
YqEventSearchVO
yqEventSearchVO
)
{
eventService
.
addYqEventAll
(
yqEventSearchVO
);
behaviorService
.
pushBehavior
(
OPERATION
,
"全部导入舆情事件数据"
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"全部导入舆情事件数据"
,
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -244,7 +244,7 @@ public class EventController extends BaseController {
@Auth
(
role
=
RoleEnum
.
SUPER_ADMIN
)
public
ResponseResult
addEventsByFile
(
@RequestParam
(
value
=
"contendId"
,
defaultValue
=
"0"
)
String
contendId
,
@RequestParam
(
"fileUrl"
)
String
fileUrl
)
{
eventService
.
addFileEvents
(
contendId
,
fileUrl
);
behaviorService
.
pushBehavior
(
OPERATION
,
"文件上传事件"
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"文件上传事件"
,
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -254,7 +254,7 @@ public class EventController extends BaseController {
@PostMapping
(
value
=
"/data/upload"
,
headers
=
"content-type=multipart/form-data"
)
public
ResponseResult
uploadEventDatas
(
@RequestParam
(
value
=
"contendId"
,
defaultValue
=
"0"
)
String
contendId
,
@RequestParam
(
"file"
)
MultipartFile
file
)
{
eventService
.
uploadEventDatas
(
contendId
,
file
);
behaviorService
.
pushBehavior
(
OPERATION
,
"事件数据上传"
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"事件数据上传"
,
request
);
return
ResponseResult
.
success
();
}
...
...
src/main/java/com/zhiwei/brandkbs2/controller/admin/ProjectController.java
View file @
3551ee37
...
...
@@ -76,7 +76,7 @@ public class ProjectController extends BaseController {
@PostMapping
(
"/add"
)
public
ResponseResult
addProject
(
@RequestBody
ProjectVO
projectVO
)
{
ProjectService
.
addProject
(
projectVO
);
behaviorService
.
pushBehavior
(
OPERATION
,
"添加项目配置:"
+
projectVO
.
getId
(),
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"添加项目配置:"
+
projectVO
.
getId
(),
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -93,7 +93,7 @@ public class ProjectController extends BaseController {
@PutMapping
(
"/update"
)
public
ResponseResult
updateProject
(
@RequestBody
ProjectVO
projectVO
)
{
ProjectService
.
updateProject
(
projectVO
);
behaviorService
.
pushBehavior
(
OPERATION
,
"修改项目:"
+
projectVO
.
getId
(),
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"修改项目:"
+
projectVO
.
getId
(),
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -102,7 +102,7 @@ public class ProjectController extends BaseController {
@DeleteMapping
(
"/delete/{pid}"
)
public
ResponseResult
deleteProject
(
@PathVariable
(
"pid"
)
String
pid
)
{
ProjectService
.
deleteProject
(
pid
,
UserThreadLocal
.
getProjectId
());
behaviorService
.
pushBehavior
(
OPERATION
,
"删除项目:"
+
pid
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"删除项目:"
+
pid
,
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -112,7 +112,7 @@ public class ProjectController extends BaseController {
public
ResponseResult
switchProjectShow
(
@PathVariable
String
pid
)
{
boolean
result
=
ProjectService
.
switchProjectShow
(
pid
);
if
(
result
)
{
behaviorService
.
pushBehavior
(
OPERATION
,
"切换项目展示状态:"
+
pid
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"切换项目展示状态:"
+
pid
,
request
);
return
ResponseResult
.
success
();
}
else
{
return
ResponseResult
.
failure
(
"启动状态下的项目,不允许调整展示状态"
);
...
...
@@ -124,7 +124,7 @@ public class ProjectController extends BaseController {
@PutMapping
(
"/switch/projectStart/{pid}"
)
public
ResponseResult
switchProjectStart
(
@PathVariable
String
pid
)
{
ProjectService
.
switchProjectStart
(
pid
);
behaviorService
.
pushBehavior
(
OPERATION
,
"切换项目状态:"
+
pid
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"切换项目状态:"
+
pid
,
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -139,7 +139,7 @@ public class ProjectController extends BaseController {
@PostMapping
(
value
=
"/upload/img"
,
headers
=
"content-type=multipart/form-data"
)
public
ResponseResult
uploadImg
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
ResponseResult
responseResult
=
Tools
.
uploadFile
(
file
,
brandkbsImgPath
,
brandkbsImageUrl
);
behaviorService
.
pushBehavior
(
OPERATION
,
"图片上传"
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"图片上传"
,
request
);
return
responseResult
;
}
...
...
src/main/java/com/zhiwei/brandkbs2/controller/admin/UserController.java
View file @
3551ee37
...
...
@@ -78,7 +78,7 @@ public class UserController extends BaseController {
@PostMapping
(
"/add"
)
public
ResponseResult
addUser
(
@RequestBody
UserDTO
userDTO
)
{
UserService
.
addUser
(
userDTO
);
behaviorService
.
pushBehavior
(
OPERATION
,
"添加用户:"
+
userDTO
.
getId
(),
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"添加用户:"
+
userDTO
.
getId
(),
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -90,7 +90,7 @@ public class UserController extends BaseController {
@Auth
(
role
=
RoleEnum
.
ADMIN
)
public
ResponseResult
deleteUser
(
@RequestParam
(
value
=
"uid"
)
String
userId
,
@RequestParam
(
value
=
"pid"
)
String
pid
)
{
UserService
.
deleteUser
(
userId
,
pid
);
behaviorService
.
pushBehavior
(
OPERATION
,
"删除用户:"
+
userId
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"删除用户:"
+
userId
,
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -98,7 +98,7 @@ public class UserController extends BaseController {
@PutMapping
(
"/update"
)
public
ResponseResult
updateUser
(
@RequestBody
UserDTO
userDTO
)
{
UserService
.
updateUser
(
userDTO
);
behaviorService
.
pushBehavior
(
OPERATION
,
"编辑用户:"
+
userDTO
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"编辑用户:"
+
userDTO
,
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -121,7 +121,7 @@ public class UserController extends BaseController {
@Auth
(
role
=
RoleEnum
.
SUPER_ADMIN
)
public
ResponseResult
addSuperAdmin
(
@RequestBody
UserDTO
userDTO
)
{
UserService
.
addSuperAdmin
(
userDTO
);
behaviorService
.
pushBehavior
(
OPERATION
,
"添加超级管理员:"
+
userDTO
.
getId
(),
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"添加超级管理员:"
+
userDTO
.
getId
(),
request
);
return
ResponseResult
.
success
();
}
...
...
@@ -132,7 +132,7 @@ public class UserController extends BaseController {
@Auth
(
role
=
RoleEnum
.
SUPER_ADMIN
)
public
ResponseResult
deleteSuperAdmin
(
@RequestParam
(
value
=
"uid"
)
String
userId
)
{
UserService
.
deleteSuperAdmin
(
userId
);
behaviorService
.
pushBehavior
(
OPERATION
,
"删除超级管理员:"
+
userId
,
request
);
behaviorService
.
pushBehavior
Old
(
OPERATION
,
"删除超级管理员:"
+
userId
,
request
);
return
ResponseResult
.
success
();
}
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppSearchController.java
View file @
3551ee37
...
...
@@ -129,10 +129,12 @@ public class AppSearchController extends BaseController {
public
ResponseResult
searchWholeNetwork
(
@RequestBody
SearchFilterDTO
dto
)
{
long
time
=
DateUtils
.
addDays
(
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
),
-
89
).
getTime
();
if
(
time
>
dto
.
getStartTime
())
{
// 仅对查商业数据库时限制时间,查舆情库时本质上无时间限制
return
ResponseResult
.
failure
(
"仅能搜索近3个月内信息"
);
}
Period
periodDay
=
new
Period
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
PeriodType
.
days
());
if
(
periodDay
.
getDays
()
>
30
)
{
// 仅对查商业数据库时限制时间,查舆情库时本质上无时间限制
return
ResponseResult
.
failure
(
"时间跨度不能超过30天"
);
}
return
ResponseResult
.
success
(
markDataService
.
searchWholeNetwork
(
dto
));
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/Behavior.java
View file @
3551ee37
...
...
@@ -3,6 +3,9 @@ package com.zhiwei.brandkbs2.pojo;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.util.List
;
import
java.util.Map
;
/**
* @ClassName: Behavior
* @Description 用户行为实体类
...
...
@@ -12,7 +15,6 @@ import lombok.Setter;
@Getter
@Setter
public
class
Behavior
extends
AbstractBaseMongo
{
/**
* 用户ID
*/
...
...
@@ -43,6 +45,36 @@ public class Behavior extends AbstractBaseMongo {
*/
private
boolean
backstage
;
/**
* nickName
*/
private
String
nickName
;
/**
* uri 访问路径
*/
private
String
uri
;
/**
* 方法名
*/
private
String
methodName
;
/**
* method HTTP 方法
*/
private
String
httpMethod
;
/**
* 方法传入参数
*/
private
List
<
Map
<
String
,
Object
>>
arguments
;
/**
* 更新时间
*/
private
Long
updateTime
;
/**
* 服务器地址
*/
private
String
severAddress
;
@Getter
public
static
class
Operation
{
...
...
@@ -54,4 +86,20 @@ public class Behavior extends AbstractBaseMongo {
this
.
backstage
=
backstage
;
}
}
public
static
Behavior
createBehaviorNew
(
String
userId
,
String
nickName
,
String
projectId
,
String
uri
,
String
methodName
,
String
httpMethod
,
List
<
Map
<
String
,
Object
>>
requestArguments
,
Long
CTime
,
Long
updateTime
,
String
severAddress
,
String
clientAddress
){
Behavior
behavior
=
new
Behavior
();
behavior
.
setUserId
(
userId
);
behavior
.
setNickName
(
nickName
);
behavior
.
setProjectId
(
projectId
);
behavior
.
setUri
(
uri
);
behavior
.
setMethodName
(
methodName
);
behavior
.
setHttpMethod
(
httpMethod
);
behavior
.
setArguments
(
requestArguments
);
behavior
.
setCTime
(
CTime
);
behavior
.
setUpdateTime
(
updateTime
);
behavior
.
setSeverAddress
(
severAddress
);
behavior
.
setIp
(
clientAddress
);
return
behavior
;
}
}
src/main/java/com/zhiwei/brandkbs2/service/BehaviorService.java
View file @
3551ee37
...
...
@@ -21,7 +21,7 @@ public interface BehaviorService {
* @param module 操作模块
* @param request 请求
*/
void
pushBehavior
(
Behavior
.
Operation
operation
,
String
module
,
HttpServletRequest
request
);
void
pushBehavior
Old
(
Behavior
.
Operation
operation
,
String
module
,
HttpServletRequest
request
);
/**
* 分页查询用户行为列表
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/BehaviorServiceImpl.java
View file @
3551ee37
...
...
@@ -52,7 +52,7 @@ public class BehaviorServiceImpl implements BehaviorService {
private
com
.
zhiwei
.
brandkbs2
.
util
.
MongoUtil
mongoUtil
;
@Override
public
void
pushBehavior
(
Behavior
.
Operation
operation
,
String
module
,
HttpServletRequest
request
)
{
public
void
pushBehavior
Old
(
Behavior
.
Operation
operation
,
String
module
,
HttpServletRequest
request
)
{
try
{
String
userId
=
UserThreadLocal
.
getUserId
();
String
projectId
=
UserThreadLocal
.
getProjectId
();
...
...
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
View file @
3551ee37
...
...
@@ -928,4 +928,13 @@ public class Tools {
return
null
;
}
/**
* 判断header中是否为空值
*
* @param o
* @return
*/
public
static
boolean
isNullOrUndefined
(
Object
o
)
{
return
(
isEmpty
(
o
)
||
Objects
.
equals
(
"undefined"
,
o
));
}
}
\ No newline at end of file
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