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
7c784a89
Commit
7c784a89
authored
May 16, 2023
by
shenjunjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上线热点关键词
parent
11d18494
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
9 deletions
+65
-9
src/main/java/com/zhiwei/brandkbs2/common/RedisKeyPrefix.java
+5
-0
src/main/java/com/zhiwei/brandkbs2/controller/app/AppHotController.java
+57
-9
src/main/resources/application-dev.properties
+1
-0
src/main/resources/application-local.properties
+1
-0
src/main/resources/application-prod.properties
+1
-0
No files found.
src/main/java/com/zhiwei/brandkbs2/common/RedisKeyPrefix.java
View file @
7c784a89
...
...
@@ -62,6 +62,7 @@ public class RedisKeyPrefix {
*/
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_KEYWORD
=
"BRANDKBS:HOT:KEYWORD:"
;
/**
* 项目简报报相关缓存KEY
...
...
@@ -120,6 +121,10 @@ public class RedisKeyPrefix {
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
)
{
Objects
.
requireNonNull
(
keys
);
boolean
contains
=
keys
[
0
].
endsWith
(
":"
);
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppHotController.java
View file @
7c784a89
package
com
.
zhiwei
.
brandkbs2
.
controller
.
app
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.aop.LogRecord
;
import
com.zhiwei.brandkbs2.auth.Auth
;
...
...
@@ -12,24 +13,24 @@ import com.zhiwei.brandkbs2.enmus.RoleEnum;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.BaseMap
;
import
com.zhiwei.brandkbs2.service.MarkDataService
;
import
com.zhiwei.brandkbs2.service.ProjectService
;
import
com.zhiwei.brandkbs2.util.RedisUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.web.bind.annotation.GetMapping
;
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.bind.annotation.*
;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
...
...
@@ -60,14 +61,61 @@ public class AppHotController extends BaseController {
private
RedisUtil
redisUtil
;
@Autowired
private
ProjectService
projectService
;
@Autowired
private
MarkDataService
markDataService
;
@Resource
(
name
=
"esSearchExecutor"
)
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
)
{
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
=
restTemplate
.
getForEntity
(
hotSearchUrl
,
JSONObject
.
class
,
pageSize
,
page
,
type
,
keyword
,
sort
);
JSONObject
result
=
jsonObjectResponseEntity
.
getBody
();
if
(
Objects
.
nonNull
(
result
))
{
return
ResponseResult
.
success
(
result
);
}
else
{
return
ResponseResult
.
failure
(
"响应超时"
);
}
}
@ApiOperation
(
"热点库-品牌热点-关键词获取"
)
@GetMapping
(
"/keyword"
)
public
ResponseResult
getKeyword
()
{
String
keywordStr
=
redisUtil
.
get
(
RedisKeyPrefix
.
hotKeywordKey
(
UserThreadLocal
.
getProjectId
()));
if
(
null
==
keywordStr
)
{
return
ResponseResult
.
success
();
}
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-topic 话题
...
...
src/main/resources/application-dev.properties
View file @
7c784a89
...
...
@@ -84,6 +84,7 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2}
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}
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.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
ef.search.url
=
https://ef.zhiweidata.com/external/search.do?name={1}&page={2}
ef.searchCriteria.url
=
https://ef.zhiweidata.com/index/getSearchKey.do
...
...
src/main/resources/application-local.properties
View file @
7c784a89
...
...
@@ -87,6 +87,7 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2}
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}
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.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
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
...
...
src/main/resources/application-prod.properties
View file @
7c784a89
...
...
@@ -84,6 +84,7 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2}
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}
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.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
ef.search.url
=
https://ef.zhiweidata.com/external/search.do?name={1}&page={2}
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