Commit 2a2699ac by shenjunjie

Merge branch 'feature' into 'release'

竞品库保留默认关键词修复

See merge request !354
parents 555a4b05 69acfe91
......@@ -18,7 +18,9 @@ import com.zhiwei.brandkbs2.service.CommonService;
import com.zhiwei.brandkbs2.service.MarkDataService;
import com.zhiwei.brandkbs2.service.ProjectService;
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.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
......@@ -136,14 +138,21 @@ public class AppHotController extends BaseController {
@ApiOperation("热点库-品牌热点-关键词获取")
@GetMapping("/keyword")
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 keywordStr = redisUtil.get(key);
if (null != 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));
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