Commit 7c784a89 by shenjunjie

上线热点关键词

parent 11d18494
...@@ -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(":");
......
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;
...@@ -12,24 +13,24 @@ import com.zhiwei.brandkbs2.enmus.RoleEnum; ...@@ -12,24 +13,24 @@ import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult; import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.BaseMap; import com.zhiwei.brandkbs2.pojo.BaseMap;
import com.zhiwei.brandkbs2.service.MarkDataService; import com.zhiwei.brandkbs2.service.MarkDataService;
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;
import java.io.IOException; 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.CompletableFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -60,14 +61,61 @@ public class AppHotController extends BaseController { ...@@ -60,14 +61,61 @@ 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 = "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) {
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 热搜
* weibo-topic 话题 * weibo-topic 话题
......
...@@ -84,6 +84,7 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2} ...@@ -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.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.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
......
...@@ -87,6 +87,7 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2} ...@@ -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.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.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
......
...@@ -84,6 +84,7 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2} ...@@ -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.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.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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment