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
a196b04a
Commit
a196b04a
authored
May 18, 2023
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release' into 'master'
Release See merge request
!330
parents
5fe98ca2
89f68172
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
24 deletions
+97
-24
src/main/java/com/zhiwei/brandkbs2/common/RedisKeyPrefix.java
+5
-0
src/main/java/com/zhiwei/brandkbs2/controller/app/AppHotController.java
+86
-21
src/main/resources/application-dev.properties
+2
-1
src/main/resources/application-local.properties
+2
-1
src/main/resources/application-prod.properties
+2
-1
No files found.
src/main/java/com/zhiwei/brandkbs2/common/RedisKeyPrefix.java
View file @
a196b04a
...
@@ -62,6 +62,7 @@ public class RedisKeyPrefix {
...
@@ -62,6 +62,7 @@ public class RedisKeyPrefix {
*/
*/
public
static
final
String
HOT_RANK_LIST
=
"BRANDKBS:HOT:RANK_LIST:"
;
public
static
final
String
HOT_RANK_LIST
=
"BRANDKBS:HOT:RANK_LIST:"
;
public
static
final
String
HOT_LIST
=
"BRANDKBS:HOT:LIST:"
;
public
static
final
String
HOT_LIST
=
"BRANDKBS:HOT:LIST:"
;
public
static
final
String
HOT_KEYWORD
=
"BRANDKBS:HOT:KEYWORD:"
;
/**
/**
* 项目简报报相关缓存KEY
* 项目简报报相关缓存KEY
...
@@ -120,6 +121,10 @@ public class RedisKeyPrefix {
...
@@ -120,6 +121,10 @@ public class RedisKeyPrefix {
return
RedisKeyPrefix
.
generateRedisKey
(
RedisKeyPrefix
.
EVENT_DATA_UPLOAD_PROGRESS
,
UserThreadLocal
.
getProjectId
(),
ticket
);
return
RedisKeyPrefix
.
generateRedisKey
(
RedisKeyPrefix
.
EVENT_DATA_UPLOAD_PROGRESS
,
UserThreadLocal
.
getProjectId
(),
ticket
);
}
}
public
static
String
hotKeywordKey
(
String
projectId
)
{
return
RedisKeyPrefix
.
generateRedisKey
(
RedisKeyPrefix
.
HOT_KEYWORD
,
projectId
);
}
private
static
String
generateRedisKey
(
String
...
keys
)
{
private
static
String
generateRedisKey
(
String
...
keys
)
{
Objects
.
requireNonNull
(
keys
);
Objects
.
requireNonNull
(
keys
);
boolean
contains
=
keys
[
0
].
endsWith
(
":"
);
boolean
contains
=
keys
[
0
].
endsWith
(
":"
);
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppHotController.java
View file @
a196b04a
package
com
.
zhiwei
.
brandkbs2
.
controller
.
app
;
package
com
.
zhiwei
.
brandkbs2
.
controller
.
app
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.aop.LogRecord
;
import
com.zhiwei.brandkbs2.aop.LogRecord
;
import
com.zhiwei.brandkbs2.auth.Auth
;
import
com.zhiwei.brandkbs2.auth.Auth
;
...
@@ -16,15 +17,13 @@ import com.zhiwei.brandkbs2.service.ProjectService;
...
@@ -16,15 +17,13 @@ import com.zhiwei.brandkbs2.service.ProjectService;
import
com.zhiwei.brandkbs2.util.RedisUtil
;
import
com.zhiwei.brandkbs2.util.RedisUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -60,14 +59,89 @@ public class AppHotController extends BaseController {
...
@@ -60,14 +59,89 @@ public class AppHotController extends BaseController {
private
RedisUtil
redisUtil
;
private
RedisUtil
redisUtil
;
@Autowired
@Autowired
private
ProjectService
projectService
;
@Autowired
private
MarkDataService
markDataService
;
private
MarkDataService
markDataService
;
@Resource
(
name
=
"projectServiceImpl"
)
ProjectService
projectService
;
@Resource
(
name
=
"esSearchExecutor"
)
@Resource
(
name
=
"esSearchExecutor"
)
ThreadPoolTaskExecutor
executor
;
ThreadPoolTaskExecutor
executor
;
@Value
(
"${trends.getHotSearchFromEsInTimeAndTypeOrWord.url}"
)
private
String
hotSearchUrl
;
/**
* weibo 热搜
* weibo-topic 话题
* weibo-rise 预热
* zhihu 知乎
* toutiao 头条
* douyin 抖音
* bilibili-ranking B站
*/
@ApiOperation
(
"热点库-品牌热点-搜索"
)
@GetMapping
(
"/keyword/search"
)
public
ResponseResult
search
(
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"5"
)
Integer
pageSize
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@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
)
{
String
keywordStr
=
redisUtil
.
get
(
RedisKeyPrefix
.
hotKeywordKey
(
UserThreadLocal
.
getProjectId
()));
if
(
null
==
keywordStr
)
{
return
ResponseResult
.
success
();
}
String
keyword
=
StringUtils
.
join
(
JSONArray
.
parseArray
(
keywordStr
,
String
.
class
),
"|"
);
ResponseEntity
<
JSONObject
>
jsonObjectResponseEntity
;
if
(
null
!=
startTime
&&
null
!=
endTime
)
{
jsonObjectResponseEntity
=
restTemplate
.
getForEntity
(
hotSearchUrl
+
"&startTime={6}&endTime={7}"
,
JSONObject
.
class
,
pageSize
,
page
,
type
,
keyword
,
sort
,
startTime
,
endTime
);
}
else
{
jsonObjectResponseEntity
=
restTemplate
.
getForEntity
(
hotSearchUrl
,
JSONObject
.
class
,
pageSize
,
page
,
type
,
keyword
,
sort
);
}
JSONObject
result
=
jsonObjectResponseEntity
.
getBody
();
if
(
Objects
.
isNull
(
result
))
{
return
ResponseResult
.
failure
(
"响应超时"
);
}
// 查询在榜数据
ResponseEntity
<
JSONObject
>
responseEntity
=
restTemplate
.
getForEntity
(
trendsListUrl
,
JSONObject
.
class
,
null
,
type
,
null
);
if
(
Objects
.
isNull
(
responseEntity
.
getBody
()))
{
return
ResponseResult
.
success
(
result
);
}
List
<
String
>
rankingIds
=
responseEntity
.
getBody
().
getJSONArray
(
"data"
).
stream
().
map
(
obj
->
((
JSONObject
)
obj
).
getString
(
"_id"
)).
collect
(
Collectors
.
toList
());
List
<
JSONObject
>
list
=
result
.
getJSONArray
(
"data"
).
stream
().
map
(
obj
->
{
JSONObject
json
=
(
JSONObject
)
obj
;
if
(
rankingIds
.
contains
(
json
.
getString
(
"id"
)))
{
json
.
put
(
"inTheList"
,
true
);
}
return
json
;
}).
collect
(
Collectors
.
toList
());
result
.
put
(
"data"
,
list
);
return
ResponseResult
.
success
(
result
);
}
@ApiOperation
(
"热点库-品牌热点-关键词获取"
)
@GetMapping
(
"/keyword"
)
public
ResponseResult
getKeyword
()
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
key
=
RedisKeyPrefix
.
hotKeywordKey
(
projectId
);
String
keywordStr
=
redisUtil
.
get
(
key
);
if
(
null
==
keywordStr
)
{
// 默认返回并设置品牌名
List
<
String
>
defaultKeyword
=
Collections
.
singletonList
(
projectService
.
getProjectById
(
projectId
).
getBrandName
());
redisUtil
.
set
(
key
,
JSON
.
toJSONString
(
defaultKeyword
));
return
ResponseResult
.
success
(
defaultKeyword
);
}
return
ResponseResult
.
success
(
JSONArray
.
parseArray
(
keywordStr
));
}
@ApiOperation
(
"热点库-品牌热点-关键词调整"
)
@PutMapping
(
"/keyword/update"
)
public
ResponseResult
updateKeyword
(
@RequestBody
JSONObject
json
)
{
JSONArray
list
=
json
.
getJSONArray
(
"list"
);
redisUtil
.
set
(
RedisKeyPrefix
.
hotKeywordKey
(
UserThreadLocal
.
getProjectId
()),
list
.
toJSONString
());
return
ResponseResult
.
success
();
}
/**
/**
* weibo 热搜
* weibo 热搜
* weibo-topic 话题
* weibo-topic 话题
...
@@ -81,23 +155,14 @@ public class AppHotController extends BaseController {
...
@@ -81,23 +155,14 @@ public class AppHotController extends BaseController {
@LogRecord
(
description
=
"热点库"
)
@LogRecord
(
description
=
"热点库"
)
@GetMapping
(
"/getHotList"
)
@GetMapping
(
"/getHotList"
)
public
ResponseResult
getHotList
(
@RequestParam
(
value
=
"sortType"
,
defaultValue
=
"realTime"
)
String
sortType
,
public
ResponseResult
getHotList
(
@RequestParam
(
value
=
"sortType"
,
defaultValue
=
"realTime"
)
String
sortType
,
@RequestParam
(
value
=
"type"
,
defaultValue
=
"weibo"
)
String
type
)
{
@RequestParam
(
value
=
"type"
,
defaultValue
=
"weibo"
)
String
type
,
ResponseEntity
<
JSONObject
>
jsonObjectResponseEntity
=
restTemplate
.
getForEntity
(
trendsListUrl
,
JSONObject
.
class
,
sortType
,
type
);
@RequestParam
(
value
=
"day"
,
required
=
false
)
String
day
)
{
Object
data
=
jsonObjectResponseEntity
.
getBody
().
get
(
"data"
);
ResponseEntity
<
JSONObject
>
jsonObjectResponseEntity
=
restTemplate
.
getForEntity
(
trendsListUrl
,
JSONObject
.
class
,
sortType
,
type
,
day
);
String
redisKey
=
RedisKeyPrefix
.
HOT_LIST
+
type
;
Object
data
=
Objects
.
requireNonNull
(
jsonObjectResponseEntity
.
getBody
()).
get
(
"data"
);
String
result
=
redisUtil
.
get
(
redisKey
);
// 当舆论场崩溃时从缓存里获取
if
(
Objects
.
nonNull
(
data
))
{
if
(
Objects
.
nonNull
(
data
))
{
if
(
Objects
.
isNull
(
result
))
{
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
data
),
ONE_HOUR
,
TimeUnit
.
HOURS
);
}
return
ResponseResult
.
success
(
data
);
return
ResponseResult
.
success
(
data
);
}
else
{
if
(
Objects
.
nonNull
(
result
))
{
return
ResponseResult
.
success
(
result
);
}
return
ResponseResult
.
failure
(
"响应超时"
);
}
}
return
ResponseResult
.
failure
(
"响应超时"
);
}
}
@ApiOperation
(
"热点库-热点榜单"
)
@ApiOperation
(
"热点库-热点榜单"
)
...
...
src/main/resources/application-dev.properties
View file @
a196b04a
...
@@ -81,9 +81,10 @@ crisis.list.url=https://crisis.zhiweidata.com/app/brandkbs/crisisList?page={1}&s
...
@@ -81,9 +81,10 @@ crisis.list.url=https://crisis.zhiweidata.com/app/brandkbs/crisisList?page={1}&s
crisis.share.url
=
https://crisis.zhiweidata.com/app/brandkbs/share/{1}
crisis.share.url
=
https://crisis.zhiweidata.com/app/brandkbs/share/{1}
crisis.event.url
=
https://crisis.zhiweidata.com/event/{1}/general?share={2}
crisis.event.url
=
https://crisis.zhiweidata.com/event/{1}/general?share={2}
#\u70ED\u70B9\u5E93\u5916\u90E8\u63A5\u53E3
#\u70ED\u70B9\u5E93\u5916\u90E8\u63A5\u53E3
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}
&day={3}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.longTimeInListSearch.url
=
https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.longTimeInListSearch.url
=
https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.getHotSearchFromEsInTimeAndTypeOrWord.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5}
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
ef.search.url
=
https://ef.zhiweidata.com/external/search.do?name={1}&page={2}
ef.search.url
=
https://ef.zhiweidata.com/external/search.do?name={1}&page={2}
ef.searchCriteria.url
=
https://ef.zhiweidata.com/index/getSearchKey.do
ef.searchCriteria.url
=
https://ef.zhiweidata.com/index/getSearchKey.do
...
...
src/main/resources/application-local.properties
View file @
a196b04a
...
@@ -84,9 +84,10 @@ crisis.list.url=https://crisis.zhiweidata.com/app/brandkbs/crisisList?page={1}&s
...
@@ -84,9 +84,10 @@ crisis.list.url=https://crisis.zhiweidata.com/app/brandkbs/crisisList?page={1}&s
crisis.share.url
=
https://crisis.zhiweidata.com/app/brandkbs/share/{1}
crisis.share.url
=
https://crisis.zhiweidata.com/app/brandkbs/share/{1}
crisis.event.url
=
https://crisis.zhiweidata.com/event/{1}/general?share={2}
crisis.event.url
=
https://crisis.zhiweidata.com/event/{1}/general?share={2}
#\u70ED\u70B9\u5E93\u5916\u90E8\u63A5\u53E3
#\u70ED\u70B9\u5E93\u5916\u90E8\u63A5\u53E3
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}
&day={3}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.longTimeInListSearch.url
=
https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.longTimeInListSearch.url
=
https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.getHotSearchFromEsInTimeAndTypeOrWord.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5}
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
ef.search.url
=
https://ef.zhiweidata.com/external/search.do?name={1}&page={2}&size={3}
ef.search.url
=
https://ef.zhiweidata.com/external/search.do?name={1}&page={2}&size={3}
ef.searchCriteria.url
=
https://ef.zhiweidata.com/index/getSearchKey.do
ef.searchCriteria.url
=
https://ef.zhiweidata.com/index/getSearchKey.do
...
...
src/main/resources/application-prod.properties
View file @
a196b04a
...
@@ -81,9 +81,10 @@ crisis.list.url=https://crisis.zhiweidata.com/app/brandkbs/crisisList?page={1}&s
...
@@ -81,9 +81,10 @@ crisis.list.url=https://crisis.zhiweidata.com/app/brandkbs/crisisList?page={1}&s
crisis.share.url
=
https://crisis.zhiweidata.com/app/brandkbs/share/{1}
crisis.share.url
=
https://crisis.zhiweidata.com/app/brandkbs/share/{1}
crisis.event.url
=
https://crisis.zhiweidata.com/event/{1}/general?share={2}
crisis.event.url
=
https://crisis.zhiweidata.com/event/{1}/general?share={2}
#\u70ED\u70B9\u5E93\u5916\u90E8\u63A5\u53E3
#\u70ED\u70B9\u5E93\u5916\u90E8\u63A5\u53E3
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}
&day={3}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.longTimeInListSearch.url
=
https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.longTimeInListSearch.url
=
https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.getHotSearchFromEsInTimeAndTypeOrWord.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5}
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
ef.search.url
=
https://ef.zhiweidata.com/external/search.do?name={1}&page={2}
ef.search.url
=
https://ef.zhiweidata.com/external/search.do?name={1}&page={2}
ef.searchCriteria.url
=
https://ef.zhiweidata.com/index/getSearchKey.do
ef.searchCriteria.url
=
https://ef.zhiweidata.com/index/getSearchKey.do
...
...
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