Commit 696ab642 by shenjunjie

Merge branch 'feature' into 'dev'

Feature

See merge request !349
parents ae7cf13b 910d03b4
...@@ -100,20 +100,24 @@ public class AppHotController extends BaseController { ...@@ -100,20 +100,24 @@ public class AppHotController extends BaseController {
@RequestParam(value = "type", defaultValue = "weibo") String type, @RequestParam(value = "type", defaultValue = "weibo") String type,
@RequestParam(value = "sort", defaultValue = "endTime") String sort, @RequestParam(value = "sort", defaultValue = "endTime") String sort,
@RequestParam(value = "startTime", required = false) Long startTime, @RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime) { @RequestParam(value = "endTime", required = false) Long endTime,
JSONObject result = searchHotHandler(pageSize, page, type, sort, startTime, endTime); @RequestParam(value = "contendId", required = false) String contendId) {
JSONObject result = searchHotHandler(pageSize, page, type, sort, startTime, endTime, contendId);
if (Objects.isNull(result)) { if (Objects.isNull(result)) {
return ResponseResult.success(); return ResponseResult.success();
} }
// 查询在榜数据 // 查询在榜数据
ResponseEntity<JSONObject> responseEntity = restTemplate.getForEntity(trendsListUrl, JSONObject.class, null, type, null);
List<String> rankingIds = new ArrayList<>(); List<String> rankingIds = new ArrayList<>();
if (!allPlatform.equals(type)) {
ResponseEntity<JSONObject> responseEntity = restTemplate.getForEntity(trendsListUrl, JSONObject.class, null, type, null);
if (Objects.nonNull(responseEntity.getBody())) { if (Objects.nonNull(responseEntity.getBody())) {
rankingIds = responseEntity.getBody().getJSONArray("data").stream().map(obj -> ((JSONObject) obj).getString("_id")).collect(Collectors.toList()); rankingIds = responseEntity.getBody().getJSONArray("data").stream().map(obj -> ((JSONObject) obj).getString("_id")).collect(Collectors.toList());
} }
}
List<String> finalRankingIds = rankingIds; List<String> finalRankingIds = rankingIds;
// 对比补录词 // 对比补录词
List<Object> valueList = redisUtil.getMapValueAll(RedisKeyPrefix.supplementWordKey(UserThreadLocal.getProjectId())); String keyId = null == contendId ? UserThreadLocal.getProjectId() : contendId;
List<Object> valueList = redisUtil.getMapValueAll(RedisKeyPrefix.supplementWordKey(keyId));
List<String> supplementList = valueList.stream().map(word -> JSON.parseObject((String) word, SupplementWord.class).getTitle()).collect(Collectors.toList()); List<String> supplementList = valueList.stream().map(word -> JSON.parseObject((String) word, SupplementWord.class).getTitle()).collect(Collectors.toList());
List<JSONObject> list = result.getJSONArray("data").stream().map(obj -> { List<JSONObject> list = result.getJSONArray("data").stream().map(obj -> {
JSONObject json = (JSONObject) obj; JSONObject json = (JSONObject) obj;
...@@ -131,24 +135,28 @@ public class AppHotController extends BaseController { ...@@ -131,24 +135,28 @@ public class AppHotController extends BaseController {
@ApiOperation("热点库-品牌热点-关键词获取") @ApiOperation("热点库-品牌热点-关键词获取")
@GetMapping("/keyword") @GetMapping("/keyword")
public ResponseResult getKeyword() { public ResponseResult getKeyword(@ApiParam(name = "竞品id")@RequestParam(required = false) String contendId) {
String projectId = UserThreadLocal.getProjectId(); String keyId = null == contendId ? UserThreadLocal.getProjectId() : contendId;
String key = RedisKeyPrefix.hotKeywordKey(projectId); 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));
List<String> defaultKeyword = Collections.singletonList(projectService.getProjectById(projectId).getBrandName()); }
// 主品牌则默认返回并设置品牌名
if (null == contendId) {
List<String> defaultKeyword = Collections.singletonList(projectService.getProjectById(keyId).getBrandName());
redisUtil.set(key, JSON.toJSONString(defaultKeyword)); redisUtil.set(key, JSON.toJSONString(defaultKeyword));
return ResponseResult.success(defaultKeyword); return ResponseResult.success(defaultKeyword);
} }
return ResponseResult.success(JSONArray.parseArray(keywordStr)); return ResponseResult.success();
} }
@ApiOperation("热点库-品牌热点-关键词调整") @ApiOperation("热点库-品牌热点-关键词调整")
@PutMapping("/keyword/update") @PutMapping("/keyword/update")
public ResponseResult updateKeyword(@RequestBody JSONObject json) { public ResponseResult updateKeyword(@ApiParam(name = "json:{list:关键词数组,contendId:竞品id}") @RequestBody JSONObject json) {
JSONArray list = json.getJSONArray("list"); JSONArray list = json.getJSONArray("list");
redisUtil.set(RedisKeyPrefix.hotKeywordKey(UserThreadLocal.getProjectId()), list.toJSONString()); String contendId = json.getString("contendId");
redisUtil.set(RedisKeyPrefix.hotKeywordKey(null == contendId ? UserThreadLocal.getProjectId() : contendId), list.toJSONString());
return ResponseResult.success(); return ResponseResult.success();
} }
...@@ -200,9 +208,10 @@ public class AppHotController extends BaseController { ...@@ -200,9 +208,10 @@ public class AppHotController extends BaseController {
@ApiOperation("热点库-根据热搜平台和标题匹配查询条件") @ApiOperation("热点库-根据热搜平台和标题匹配查询条件")
@GetMapping("/match-criteria") @GetMapping("/match-criteria")
public ResponseResult matchSearchCriteria(@RequestParam String name, @RequestParam String type) { public ResponseResult matchSearchCriteria(@RequestParam String name, @RequestParam String type) {
Long[] timeRangeMonth = commonService.getTimeRangeMonth(); long endTime = System.currentTimeMillis();
long startTime = endTime - Constant.ONE_MONTH;
int defaultPageSize = 5; int defaultPageSize = 5;
JSONObject result = searchHotHandler(10000, 1, HotPlatformEnum.convertFromName2Eng(type), "endTime", timeRangeMonth[0], timeRangeMonth[1]); JSONObject result = searchHotHandler(10000, 1, HotPlatformEnum.convertFromName2Eng(type), "endTime", startTime, endTime);
int index = 0; int index = 0;
boolean matched = false; boolean matched = false;
List<JSONObject> data = result.getJSONArray("data").toJavaList(JSONObject.class); List<JSONObject> data = result.getJSONArray("data").toJavaList(JSONObject.class);
...@@ -369,13 +378,14 @@ public class AppHotController extends BaseController { ...@@ -369,13 +378,14 @@ public class AppHotController extends BaseController {
* @param endTime * @param endTime
* @return * @return
*/ */
private JSONObject searchHotHandler(int pageSize, int page, String type, String sort, Long startTime, Long endTime) { private JSONObject searchHotHandler(int pageSize, int page, String type, String sort, Long startTime, Long endTime,String contendId) {
String keywordStr = redisUtil.get(RedisKeyPrefix.hotKeywordKey(UserThreadLocal.getProjectId())); String keyId = null == contendId ? UserThreadLocal.getProjectId() : contendId;
String keywordStr = redisUtil.get(RedisKeyPrefix.hotKeywordKey(keyId));
if (null == keywordStr) { if (null == keywordStr) {
return null; return null;
} }
String accurateWord = null; String accurateWord = null;
List<Object> valueList = redisUtil.getMapValueAll(RedisKeyPrefix.supplementWordKey(UserThreadLocal.getProjectId())); List<Object> valueList = redisUtil.getMapValueAll(RedisKeyPrefix.supplementWordKey(keyId));
if (CollectionUtils.isNotEmpty(valueList)) { if (CollectionUtils.isNotEmpty(valueList)) {
List<String> collect = valueList.stream().map(word -> JSON.parseObject((String) word, SupplementWord.class).getTitle()).collect(Collectors.toList()); List<String> collect = valueList.stream().map(word -> JSON.parseObject((String) word, SupplementWord.class).getTitle()).collect(Collectors.toList());
accurateWord = StringUtils.join(collect, "|"); accurateWord = StringUtils.join(collect, "|");
...@@ -390,6 +400,10 @@ public class AppHotController extends BaseController { ...@@ -390,6 +400,10 @@ public class AppHotController extends BaseController {
return jsonObjectResponseEntity.getBody(); return jsonObjectResponseEntity.getBody();
} }
private JSONObject searchHotHandler(int pageSize, int page, String type, String sort, Long startTime, Long endTime) {
return searchHotHandler(pageSize, page, type, sort, startTime, endTime, null);
}
private JSONObject contrastReport(List<JSONObject> source, Long[] timeRange, Long space) { private JSONObject contrastReport(List<JSONObject> source, Long[] timeRange, Long space) {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
List<JSONObject> list = source.stream().filter(json -> json.getLong("startTime") >= timeRange[0]).collect(Collectors.toList()); List<JSONObject> list = source.stream().filter(json -> json.getLong("startTime") >= timeRange[0]).collect(Collectors.toList());
......
...@@ -166,6 +166,10 @@ public class CommonServiceImpl implements CommonService { ...@@ -166,6 +166,10 @@ public class CommonServiceImpl implements CommonService {
Date date = Tools.truncDate(new Date(), Constant.DAY_PATTERN); Date date = Tools.truncDate(new Date(), Constant.DAY_PATTERN);
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(date); calendar.setTime(date);
// 如果是周日
if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
calendar.add(Calendar.DAY_OF_YEAR, -1);
}
calendar.set(Calendar.DAY_OF_WEEK, 1); calendar.set(Calendar.DAY_OF_WEEK, 1);
startTime = calendar.getTime().getTime(); startTime = calendar.getTime().getTime();
calendar.set(Calendar.DAY_OF_WEEK, 7); calendar.set(Calendar.DAY_OF_WEEK, 7);
......
...@@ -171,12 +171,12 @@ public class UserServiceImpl implements UserService { ...@@ -171,12 +171,12 @@ public class UserServiceImpl implements UserService {
newUser.setNickname(userDTO.getNickname()); newUser.setNickname(userDTO.getNickname());
newUser.setRoles(Collections.singletonList(UserRole.createFromUserDto(userDTO))); newUser.setRoles(Collections.singletonList(UserRole.createFromUserDto(userDTO)));
newUser.setSuperAdmin(false); newUser.setSuperAdmin(false);
userDao.insertOne(newUser);
userCenterService.addProduct(newUser.getId());
} else { } else {
newUser = User.createFromUserDTO(userDTO, nickname); newUser = User.createFromUserDTO(userDTO, nickname);
userDao.insertOne(newUser);
} }
userDao.insertOne(newUser);
// 通知用户中心开通权限
userCenterService.addProduct(newUser.getId());
return ResponseResult.success(); return ResponseResult.success();
} }
List<UserRole> roles = user.getRoles(); List<UserRole> roles = user.getRoles();
......
...@@ -87,8 +87,8 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2} ...@@ -87,8 +87,8 @@ 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}&day={3} trends.longTimeInListSearchByInner.url=https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3}
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=http://192.168.0.192:9091/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5}&accurateWord={6} trends.getHotSearchFromEsInTimeAndTypeOrWord.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5\}&accurateWord={6}
trends.queryHotSearchTrendInner.url=http://192.168.27.203:9094/hotSearchTrend/inner/queryHotSearchTrendInner?name={1}&startTime={2}&type={3} trends.queryHotSearchTrendInner.url=https://trends.zhiweidata.com/hotSearchTrend/inner/queryHotSearchTrendInner?name={1}&startTime={2}&type={3}
trends.getHotSearchSnapshot.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchSnapshot?type={1}&time={2}&rank={3} trends.getHotSearchSnapshot.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchSnapshot?type={1}&time={2}&rank={3}
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3 #\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
......
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