Commit 25c1b130 by shenjunjie

添加品牌热点-默认关键词

parent 7c784a89
......@@ -13,6 +13,7 @@ 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;
......@@ -27,10 +28,7 @@ import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
......@@ -63,6 +61,9 @@ public class AppHotController extends BaseController {
@Autowired
private MarkDataService markDataService;
@Resource(name = "projectServiceImpl")
ProjectService projectService;
@Resource(name = "esSearchExecutor")
ThreadPoolTaskExecutor executor;
......@@ -101,9 +102,14 @@ public class AppHotController extends BaseController {
@ApiOperation("热点库-品牌热点-关键词获取")
@GetMapping("/keyword")
public ResponseResult getKeyword() {
String keywordStr = redisUtil.get(RedisKeyPrefix.hotKeywordKey(UserThreadLocal.getProjectId()));
String projectId = UserThreadLocal.getProjectId();
String key = RedisKeyPrefix.hotKeywordKey(projectId);
String keywordStr = redisUtil.get(key);
if (null == keywordStr) {
return ResponseResult.success();
// 默认返回并设置品牌名
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));
}
......
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