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
4befdfd8
Commit
4befdfd8
authored
Jun 29, 2023
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature' into 'release'
热点库-竞品模板上线 See merge request
!350
parents
371ecb2c
910d03b4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
20 deletions
+34
-20
src/main/java/com/zhiwei/brandkbs2/controller/app/AppHotController.java
+34
-20
No files found.
src/main/java/com/zhiwei/brandkbs2/controller/app/AppHotController.java
View file @
4befdfd8
...
...
@@ -100,20 +100,24 @@ public class AppHotController extends BaseController {
@RequestParam
(
value
=
"type"
,
defaultValue
=
"weibo"
)
String
type
,
@RequestParam
(
value
=
"sort"
,
defaultValue
=
"endTime"
)
String
sort
,
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
Long
endTime
)
{
JSONObject
result
=
searchHotHandler
(
pageSize
,
page
,
type
,
sort
,
startTime
,
endTime
);
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
Long
endTime
,
@RequestParam
(
value
=
"contendId"
,
required
=
false
)
String
contendId
)
{
JSONObject
result
=
searchHotHandler
(
pageSize
,
page
,
type
,
sort
,
startTime
,
endTime
,
contendId
);
if
(
Objects
.
isNull
(
result
))
{
return
ResponseResult
.
success
();
}
// 查询在榜数据
ResponseEntity
<
JSONObject
>
responseEntity
=
restTemplate
.
getForEntity
(
trendsListUrl
,
JSONObject
.
class
,
null
,
type
,
null
);
List
<
String
>
rankingIds
=
new
ArrayList
<>();
if
(
Objects
.
nonNull
(
responseEntity
.
getBody
()))
{
rankingIds
=
responseEntity
.
getBody
().
getJSONArray
(
"data"
).
stream
().
map
(
obj
->
((
JSONObject
)
obj
).
getString
(
"_id"
)).
collect
(
Collectors
.
toList
());
if
(!
allPlatform
.
equals
(
type
))
{
ResponseEntity
<
JSONObject
>
responseEntity
=
restTemplate
.
getForEntity
(
trendsListUrl
,
JSONObject
.
class
,
null
,
type
,
null
);
if
(
Objects
.
nonNull
(
responseEntity
.
getBody
()))
{
rankingIds
=
responseEntity
.
getBody
().
getJSONArray
(
"data"
).
stream
().
map
(
obj
->
((
JSONObject
)
obj
).
getString
(
"_id"
)).
collect
(
Collectors
.
toList
());
}
}
List
<
String
>
finalRankingIds
=
rankingIds
;
// 对比补录词
List
<
Object
>
valueList
=
redisUtil
.
getMapValueAll
(
RedisKeyPrefix
.
supplementWordKey
(
UserThreadLocal
.
getProjectId
()));
String
keyId
=
null
==
contendId
?
UserThreadLocal
.
getProjectId
()
:
contendId
;
List
<
Object
>
valueList
=
redisUtil
.
getMapValueAll
(
RedisKeyPrefix
.
supplementWordKey
(
keyId
));
List
<
String
>
supplementList
=
valueList
.
stream
().
map
(
word
->
JSON
.
parseObject
((
String
)
word
,
SupplementWord
.
class
).
getTitle
()).
collect
(
Collectors
.
toList
());
List
<
JSONObject
>
list
=
result
.
getJSONArray
(
"data"
).
stream
().
map
(
obj
->
{
JSONObject
json
=
(
JSONObject
)
obj
;
...
...
@@ -131,24 +135,28 @@ public class AppHotController extends BaseController {
@ApiOperation
(
"热点库-品牌热点-关键词获取"
)
@GetMapping
(
"/keyword"
)
public
ResponseResult
getKeyword
()
{
String
projectId
=
UserThreadLocal
.
getProjectId
()
;
String
key
=
RedisKeyPrefix
.
hotKeywordKey
(
project
Id
);
public
ResponseResult
getKeyword
(
@ApiParam
(
name
=
"竞品id"
)
@RequestParam
(
required
=
false
)
String
contendId
)
{
String
keyId
=
null
==
contendId
?
UserThreadLocal
.
getProjectId
()
:
contendId
;
String
key
=
RedisKeyPrefix
.
hotKeywordKey
(
key
Id
);
String
keywordStr
=
redisUtil
.
get
(
key
);
if
(
null
==
keywordStr
)
{
// 默认返回并设置品牌名
List
<
String
>
defaultKeyword
=
Collections
.
singletonList
(
projectService
.
getProjectById
(
projectId
).
getBrandName
());
if
(
null
!=
keywordStr
)
{
return
ResponseResult
.
success
(
JSONArray
.
parseArray
(
keywordStr
));
}
// 主品牌则默认返回并设置品牌名
if
(
null
==
contendId
)
{
List
<
String
>
defaultKeyword
=
Collections
.
singletonList
(
projectService
.
getProjectById
(
keyId
).
getBrandName
());
redisUtil
.
set
(
key
,
JSON
.
toJSONString
(
defaultKeyword
));
return
ResponseResult
.
success
(
defaultKeyword
);
}
return
ResponseResult
.
success
(
JSONArray
.
parseArray
(
keywordStr
)
);
return
ResponseResult
.
success
();
}
@ApiOperation
(
"热点库-品牌热点-关键词调整"
)
@PutMapping
(
"/keyword/update"
)
public
ResponseResult
updateKeyword
(
@RequestBody
JSONObject
json
)
{
public
ResponseResult
updateKeyword
(
@
ApiParam
(
name
=
"json:{list:关键词数组,contendId:竞品id}"
)
@
RequestBody
JSONObject
json
)
{
JSONArray
list
=
json
.
getJSONArray
(
"list"
);
redisUtil
.
set
(
RedisKeyPrefix
.
hotKeywordKey
(
UserThreadLocal
.
getProjectId
()),
list
.
toJSONString
());
String
contendId
=
json
.
getString
(
"contendId"
);
redisUtil
.
set
(
RedisKeyPrefix
.
hotKeywordKey
(
null
==
contendId
?
UserThreadLocal
.
getProjectId
()
:
contendId
),
list
.
toJSONString
());
return
ResponseResult
.
success
();
}
...
...
@@ -200,9 +208,10 @@ public class AppHotController extends BaseController {
@ApiOperation
(
"热点库-根据热搜平台和标题匹配查询条件"
)
@GetMapping
(
"/match-criteria"
)
public
ResponseResult
matchSearchCriteria
(
@RequestParam
String
name
,
@RequestParam
String
type
)
{
Long
[]
timeRangeMonth
=
commonService
.
getTimeRangeMonth
();
long
endTime
=
System
.
currentTimeMillis
();
long
startTime
=
endTime
-
Constant
.
ONE_MONTH
;
int
defaultPageSize
=
5
;
JSONObject
result
=
searchHotHandler
(
10000
,
1
,
HotPlatformEnum
.
convertFromName2Eng
(
type
),
"endTime"
,
timeRangeMonth
[
0
],
timeRangeMonth
[
1
]
);
JSONObject
result
=
searchHotHandler
(
10000
,
1
,
HotPlatformEnum
.
convertFromName2Eng
(
type
),
"endTime"
,
startTime
,
endTime
);
int
index
=
0
;
boolean
matched
=
false
;
List
<
JSONObject
>
data
=
result
.
getJSONArray
(
"data"
).
toJavaList
(
JSONObject
.
class
);
...
...
@@ -369,13 +378,14 @@ public class AppHotController extends BaseController {
* @param endTime
* @return
*/
private
JSONObject
searchHotHandler
(
int
pageSize
,
int
page
,
String
type
,
String
sort
,
Long
startTime
,
Long
endTime
)
{
String
keywordStr
=
redisUtil
.
get
(
RedisKeyPrefix
.
hotKeywordKey
(
UserThreadLocal
.
getProjectId
()));
private
JSONObject
searchHotHandler
(
int
pageSize
,
int
page
,
String
type
,
String
sort
,
Long
startTime
,
Long
endTime
,
String
contendId
)
{
String
keyId
=
null
==
contendId
?
UserThreadLocal
.
getProjectId
()
:
contendId
;
String
keywordStr
=
redisUtil
.
get
(
RedisKeyPrefix
.
hotKeywordKey
(
keyId
));
if
(
null
==
keywordStr
)
{
return
null
;
}
String
accurateWord
=
null
;
List
<
Object
>
valueList
=
redisUtil
.
getMapValueAll
(
RedisKeyPrefix
.
supplementWordKey
(
UserThreadLocal
.
getProjectId
()
));
List
<
Object
>
valueList
=
redisUtil
.
getMapValueAll
(
RedisKeyPrefix
.
supplementWordKey
(
keyId
));
if
(
CollectionUtils
.
isNotEmpty
(
valueList
))
{
List
<
String
>
collect
=
valueList
.
stream
().
map
(
word
->
JSON
.
parseObject
((
String
)
word
,
SupplementWord
.
class
).
getTitle
()).
collect
(
Collectors
.
toList
());
accurateWord
=
StringUtils
.
join
(
collect
,
"|"
);
...
...
@@ -390,6 +400,10 @@ public class AppHotController extends BaseController {
return
jsonObjectResponseEntity
.
getBody
();
}
private
JSONObject
searchHotHandler
(
int
pageSize
,
int
page
,
String
type
,
String
sort
,
Long
startTime
,
Long
endTime
)
{
return
searchHotHandler
(
pageSize
,
page
,
type
,
sort
,
startTime
,
endTime
,
null
);
}
private
JSONObject
contrastReport
(
List
<
JSONObject
>
source
,
Long
[]
timeRange
,
Long
space
)
{
JSONObject
result
=
new
JSONObject
();
List
<
JSONObject
>
list
=
source
.
stream
().
filter
(
json
->
json
.
getLong
(
"startTime"
)
>=
timeRange
[
0
]).
collect
(
Collectors
.
toList
());
...
...
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