Commit 34a865de by shenjunjie

Merge branch 'release' into 'master'

Release

See merge request !355
parents 79db4c45 2a2699ac
...@@ -18,7 +18,9 @@ import com.zhiwei.brandkbs2.service.CommonService; ...@@ -18,7 +18,9 @@ import com.zhiwei.brandkbs2.service.CommonService;
import com.zhiwei.brandkbs2.service.MarkDataService; import com.zhiwei.brandkbs2.service.MarkDataService;
import com.zhiwei.brandkbs2.service.ProjectService; import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.util.RedisUtil; import com.zhiwei.brandkbs2.util.RedisUtil;
import io.swagger.annotations.*; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
...@@ -136,14 +138,21 @@ public class AppHotController extends BaseController { ...@@ -136,14 +138,21 @@ public class AppHotController extends BaseController {
@ApiOperation("热点库-品牌热点-关键词获取") @ApiOperation("热点库-品牌热点-关键词获取")
@GetMapping("/keyword") @GetMapping("/keyword")
public ResponseResult getKeyword(@ApiParam(name = "竞品id")@RequestParam(required = false) String contendId) { public ResponseResult getKeyword(@ApiParam(name = "竞品id")@RequestParam(required = false) String contendId) {
String keyId = null == contendId ? UserThreadLocal.getProjectId() : contendId; boolean primary = null == contendId;
String keyId = primary ? UserThreadLocal.getProjectId() : contendId;
String key = RedisKeyPrefix.hotKeywordKey(keyId); String key = RedisKeyPrefix.hotKeywordKey(keyId);
String keywordStr = redisUtil.get(key); String keywordStr = redisUtil.get(key);
if (null != keywordStr) { if (null != keywordStr) {
return ResponseResult.success(JSONArray.parseArray(keywordStr)); return ResponseResult.success(JSONArray.parseArray(keywordStr));
} }
// 默认返回并设置品牌名 // 默认返回并设置品牌名
List<String> defaultKeyword = Collections.singletonList(projectService.getProjectById(keyId).getBrandName()); List<String> defaultKeyword;
if(primary){
defaultKeyword = Collections.singletonList(projectService.getProjectById(UserThreadLocal.getProjectId()).getBrandName());
}else{
String brandName = projectService.getProjectById(UserThreadLocal.getProjectId()).getContendList().stream().filter(contend -> contend.getId().equals(keyId)).findFirst().get().getBrandName();
defaultKeyword = Collections.singletonList(brandName);
}
redisUtil.set(key, JSON.toJSONString(defaultKeyword)); redisUtil.set(key, JSON.toJSONString(defaultKeyword));
return ResponseResult.success(defaultKeyword); return ResponseResult.success(defaultKeyword);
} }
......
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