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
2c81df78
Commit
2c81df78
authored
Apr 07, 2023
by
陈健智
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户操作记录调整
parent
37655beb
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
60 additions
and
19 deletions
+60
-19
src/main/java/com/zhiwei/brandkbs2/aop/AopLogRecord.java
+16
-5
src/main/java/com/zhiwei/brandkbs2/controller/app/AppArticleController.java
+1
-0
src/main/java/com/zhiwei/brandkbs2/controller/app/AppSearchController.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/dao/UserLogRecordDao.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/dao/impl/UserLogRecordDaoImpl.java
+14
-2
src/main/java/com/zhiwei/brandkbs2/pojo/UserLogRecord.java
+0
-1
src/main/java/com/zhiwei/brandkbs2/service/impl/BehaviorServiceImpl.java
+23
-6
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
+4
-3
No files found.
src/main/java/com/zhiwei/brandkbs2/aop/AopLogRecord.java
View file @
2c81df78
...
...
@@ -108,7 +108,8 @@ public class AopLogRecord {
uri
,
methodName
,
httpMethod
,
arguments
,
now
,
severAddress
,
null
);
UserLogRecord
userLogRecord
=
userLogRecord
(
projectId
,
userInfo
,
joinPoint
,
methodSignature
,
ResponseResult
);
if
(
Objects
.
nonNull
(
userLogRecord
))
{
userLogRecordDao
.
insertOne
(
userLogRecord
);
String
collectionName
=
userLogRecordDao
.
generateCollectionName
();
userLogRecordDao
.
insertOne
(
userLogRecord
,
collectionName
);
}
String
collectionName
=
behaviorDao
.
generateCollectionName
();
behaviorDao
.
insertOneWithoutId
(
behavior
,
collectionName
);
...
...
@@ -142,12 +143,22 @@ public class AopLogRecord {
JSONObject
jsonObject
=
(
JSONObject
)
JSON
.
toJSON
(
args
[
0
]);
List
<
Object
>
res
=
new
ArrayList
<>(
value
.
length
);
for
(
String
v
:
value
)
{
if
(
v
.
contains
(
":"
)){
String
[]
fatherSplit
=
v
.
split
(
":"
,
2
);
JSONObject
object
=
jsonObject
.
getJSONObject
(
fatherSplit
[
0
]);
if
(
Objects
.
nonNull
(
object
)){
Object
o
=
object
.
get
(
fatherSplit
[
1
]);
if
(
Objects
.
nonNull
(
o
)
&&
StringUtils
.
isNotBlank
(
o
.
toString
()))
{
res
.
add
(
o
);
}
}
}
Object
o
=
jsonObject
.
get
(
v
);
if
(
Objects
.
nonNull
(
o
))
{
if
(
Objects
.
nonNull
(
o
)
&&
StringUtils
.
isNotBlank
(
o
.
toString
())
)
{
res
.
add
(
o
);
}
}
String
suffix
=
CollectionUtils
.
isNotEmpty
(
res
)
?
"-"
+
Tools
.
concat
(
res
)
:
""
;
String
suffix
=
CollectionUtils
.
isNotEmpty
(
res
)
?
"-"
+
Tools
.
concat
WithMinus
(
res
)
:
""
;
return
new
UserLogRecord
(
projectId
,
userInfo
.
getUserId
(),
userInfo
.
getNickname
(),
prefix
+
suffix
,
userInfo
.
getRoleId
(),
now
,
now
);
}
// 获取接口传参(value为获取传参的具体字段)并与操作描述description拼接返回,传参值不为实体
...
...
@@ -161,7 +172,7 @@ public class AopLogRecord {
}
}
}
String
suffix
=
CollectionUtils
.
isNotEmpty
(
res
)
?
"-"
+
Tools
.
concat
(
res
)
:
""
;
String
suffix
=
CollectionUtils
.
isNotEmpty
(
res
)
?
"-"
+
Tools
.
concat
WithMinus
(
res
)
:
""
;
return
new
UserLogRecord
(
projectId
,
userInfo
.
getUserId
(),
userInfo
.
getNickname
(),
prefix
+
suffix
,
userInfo
.
getRoleId
(),
now
,
now
);
}
// 获取接口返回值(value为获取返回值的具体字段)并与操作描述description拼接返回,返回值为实体
...
...
@@ -174,7 +185,7 @@ public class AopLogRecord {
res
.
add
(
s
);
}
}
String
suffix
=
CollectionUtils
.
isNotEmpty
(
res
)
?
"-"
+
Tools
.
concat
(
res
)
:
""
;
String
suffix
=
CollectionUtils
.
isNotEmpty
(
res
)
?
"-"
+
Tools
.
concat
WithMinus
(
res
)
:
""
;
return
new
UserLogRecord
(
projectId
,
userInfo
.
getUserId
(),
userInfo
.
getNickname
(),
prefix
+
suffix
,
userInfo
.
getRoleId
(),
now
,
now
);
}
return
new
UserLogRecord
(
projectId
,
userInfo
.
getUserId
(),
userInfo
.
getNickname
(),
prefix
,
userInfo
.
getRoleId
(),
now
,
now
);
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppArticleController.java
View file @
2c81df78
...
...
@@ -121,6 +121,7 @@ public class AppArticleController extends BaseController {
@ApiOperation
(
"舆情列表-生成聚合"
)
@PostMapping
(
"/mark/aggree"
)
@LogRecord
(
description
=
"舆情库-舆情列表-聚合"
)
public
ResponseResult
generateYuqingMarkAggreeList
(
@RequestBody
JSONObject
info
)
{
Long
startTime
=
info
.
getLong
(
"startTime"
);
Long
endTime
=
info
.
getLong
(
"endTime"
);
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppSearchController.java
View file @
2c81df78
...
...
@@ -135,7 +135,7 @@ public class AppSearchController extends BaseController {
}
@ApiOperation
(
"搜索-全网搜"
)
@LogRecord
(
values
=
{
"keyword"
,
"search"
},
description
=
"全网搜"
,
arguments
=
true
,
entity
=
true
)
@LogRecord
(
values
=
{
"
fans"
,
"sensitiveChannels:father"
,
"
keyword"
,
"search"
},
description
=
"全网搜"
,
arguments
=
true
,
entity
=
true
)
@PostMapping
(
"/searchWhole"
)
public
ResponseResult
searchWholeNetwork
(
@RequestBody
SearchFilterDTO
dto
)
{
// 针对商业数据库做限制
...
...
src/main/java/com/zhiwei/brandkbs2/dao/UserLogRecordDao.java
View file @
2c81df78
...
...
@@ -8,5 +8,5 @@ import com.zhiwei.brandkbs2.pojo.UserLogRecord;
* @author: cjz
* @date: 2023-03-22 10:46
*/
public
interface
UserLogRecordDao
extends
BaseMongoDao
<
UserLogRecord
>{
public
interface
UserLogRecordDao
extends
BaseMongoDao
<
UserLogRecord
>
,
ShardingMongo
{
}
src/main/java/com/zhiwei/brandkbs2/dao/impl/UserLogRecordDaoImpl.java
View file @
2c81df78
...
...
@@ -7,9 +7,21 @@ import org.springframework.stereotype.Component;
@Component
(
"UserLogRecordDao"
)
public
class
UserLogRecordDaoImpl
extends
BaseMongoDaoImpl
<
UserLogRecord
>
implements
UserLogRecordDao
{
private
static
final
String
COLLECTION_NAME
=
"brandkbs_user_log_record"
;
private
static
final
String
COLLECTION_PREFIX
=
"brandkbs_user_log_record"
;
private
static
final
String
TIME_PATTERN
=
"yyyy"
;
public
UserLogRecordDaoImpl
()
{
super
(
COLLECTION_NAME
);
super
(
null
);
}
@Override
public
String
collectionPrefix
()
{
return
COLLECTION_PREFIX
;
}
@Override
public
String
timePattern
()
{
return
TIME_PATTERN
;
}
}
src/main/java/com/zhiwei/brandkbs2/pojo/UserLogRecord.java
View file @
2c81df78
...
...
@@ -14,7 +14,6 @@ import org.springframework.data.mongodb.core.mapping.Document;
@Getter
@Setter
@AllArgsConstructor
@Document
(
collection
=
"brandkbs_user_log_record"
)
public
class
UserLogRecord
extends
AbstractBaseMongo
{
/**
* 项目id
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/BehaviorServiceImpl.java
View file @
2c81df78
...
...
@@ -175,26 +175,43 @@ public class BehaviorServiceImpl implements BehaviorService {
return
;
}
UserLogRecord
userLogRecord
=
new
UserLogRecord
(
projectId
,
userInfo
.
getUserId
(),
userInfo
.
getNickname
(),
description
,
userInfo
.
getRoleId
(),
now
,
now
);
userLogRecordDao
.
insertOne
(
userLogRecord
);
String
collectionName
=
userLogRecordDao
.
generateCollectionName
();
userLogRecordDao
.
insertOne
(
userLogRecord
,
collectionName
);
}
}
@Override
public
PageVO
<
UserLogRecord
>
findLogRecordList
(
int
page
,
int
size
,
long
startTime
,
long
endTime
,
String
nickname
)
{
Date
start
=
new
Date
(
startTime
);
Date
end
=
new
Date
(
endTime
);
String
projectId
=
UserThreadLocal
.
getProjectId
();
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"cTime"
).
gte
(
startTime
).
lt
(
endTime
));
query
.
addCriteria
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
));
String
[]
collectionNames
=
userLogRecordDao
.
generateCollectionNames
(
start
,
end
);
userLogRecordDao
.
addSort
(
query
,
"{\"cTime\":\"descend\"}"
);
if
(
StringUtils
.
isNotEmpty
(
nickname
))
{
userDao
.
addKeywordFuzz
(
query
,
nickname
,
"nickname"
);
}
long
count
=
userLogRecordDao
.
count
(
query
);
List
<
UserLogRecord
>
behaviorList
=
new
ArrayList
<>();
int
pageSizeFlag
=
size
;
int
skipCount
=
(
page
-
1
)
*
size
;
query
.
limit
(
size
);
query
.
skip
(
skipCount
);
List
<
UserLogRecord
>
resList
=
userLogRecordDao
.
findList
(
query
);
return
PageVO
.
createPageVo
(
count
,
page
,
size
,
resList
);
if
(
0
!=
collectionNames
.
length
)
{
for
(
int
i
=
collectionNames
.
length
-
1
;
i
>=
0
;
i
--)
{
if
(
behaviorList
.
size
()
>=
size
)
{
break
;
}
else
{
query
.
limit
(
pageSizeFlag
);
query
.
skip
(
skipCount
);
List
<
UserLogRecord
>
list
=
userLogRecordDao
.
findList
(
query
,
collectionNames
[
i
]);
behaviorList
.
addAll
(
list
);
}
skipCount
=
0
;
pageSizeFlag
=
size
-
behaviorList
.
size
();
}
}
long
count
=
userLogRecordDao
.
count
(
query
);
return
PageVO
.
createPageVo
(
count
,
page
,
size
,
behaviorList
);
}
@Override
...
...
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
View file @
2c81df78
...
...
@@ -526,15 +526,16 @@ public class Tools {
}
/**
* 拼接字符串,以
_
隔开
* 拼接字符串,以
-
隔开
*
* @param objects 可变参数
* @return 拼接后的字符串
*/
public
static
String
concat
(
List
<
Object
>
objects
)
{
public
static
String
concatWithMinus
(
List
<
Object
>
objects
)
{
String
separator
=
"-"
;
StringBuilder
sb
=
new
StringBuilder
();
for
(
Object
obj
:
objects
)
{
sb
.
append
(
obj
).
append
(
Constant
.
DEFAULT_SEPARATOR
);
sb
.
append
(
obj
).
append
(
separator
);
}
String
resultStr
=
sb
.
toString
();
return
resultStr
.
substring
(
0
,
resultStr
.
length
()
-
1
);
...
...
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