use of com.topcom.cms.domain.SearchWord in project topcom-cloud by 545314690.
the class SearchWordController method findByType.
/**
* 热词查询 查询排名前 limit 的word
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "/findByType", produces = "application/json")
@ResponseBody
public List<SearchWord> findByType(@CurrentUser User user, @ApiParam("limit") @RequestParam(required = true) Integer limit, @ApiParam("type") @RequestParam(required = true) Integer type) {
Sort sort = new Sort(new Sort.Order(Sort.Direction.DESC, "wordCount"));
Pageable page = new PageRequest(0, limit, sort);
User user1 = this.userManager.findById(user.getId());
Set<Group> groups = user1.getGroups();
String groupId = SearchWord.groupIdBySet(groups);
List<String> groupIdList = new ArrayList<>();
groupIdList.add(groupId);
if (groupId.indexOf(",") != -1) {
String[] split = groupId.split(",");
for (String s : split) {
groupIdList.add(s);
}
}
Page<SearchWord> searchWords = this.searchWordManager.findByTypeAndGroupIdIn(page, type, groupIdList);
return filterNull(searchWords);
}
use of com.topcom.cms.domain.SearchWord in project topcom-cloud by 545314690.
the class SearchWordManagerImpl method addClickCount.
@Override
public SearchWord addClickCount(Set<Group> groups, String word, Integer type) {
String groupId = SearchWord.groupIdBySet(groups);
SearchWord result = new SearchWord();
List<SearchWord> searchWords = searchWordDao.findByWordAndTypeAndGroupId(word, type, groupId);
if (searchWords != null && searchWords.size() > 0) {
if (searchWords.size() > 1) {
for (int i = 1; i < searchWords.size(); i++) {
this.delete(searchWords.get(i).getId());
}
}
result = searchWords.get(0);
long wordCount = result.getWordCount();
result.setWordCount(++wordCount);
result.setDateModified(new Date());
} else {
result.setType(type);
result.setWord(word);
result.setGroupId(groupId);
result.setWordCount(1);
}
return this.save(result);
}
use of com.topcom.cms.domain.SearchWord in project topcom-cloud by 545314690.
the class SearchWordController method filterNull.
private List<SearchWord> filterNull(Page<SearchWord> searchWords) {
List<SearchWord> result = new ArrayList<>();
Set<String> s_set = new HashSet<>();
for (int i = 0; i < searchWords.getContent().size(); i++) {
SearchWord searchWord = searchWords.getContent().get(i);
if (!StringUtils.isEmpty(searchWord.getWord())) {
if (!result.contains(searchWord)) {
result.add(searchWord);
}
}
}
return result;
}
use of com.topcom.cms.domain.SearchWord in project topcom-cloud by 545314690.
the class SearchWordController method findByWord.
@RequestMapping(method = RequestMethod.GET, value = "/findByWord", produces = "application/json")
@ResponseBody
public List<SearchWord> findByWord(@CurrentUser User user, @ApiParam("limit") @RequestParam(required = true) Integer limit, @ApiParam("word") @RequestParam(required = true) String word) {
Sort sort = new Sort(new Sort.Order(Sort.Direction.DESC, "wordCount"));
Pageable page = new PageRequest(0, limit, sort);
User user1 = this.userManager.findById(user.getId());
Set<Group> groups = user1.getGroups();
String groupId = SearchWord.groupIdBySet(groups);
List<String> groupIdList = new ArrayList<>();
groupIdList.add(groupId);
if (groupId.indexOf(",") != -1) {
String[] split = groupId.split(",");
for (String s : split) {
groupIdList.add(s);
}
}
Page<SearchWord> searchWords = this.searchWordManager.findByWordAndGroupIdIn(page, word, groupIdList);
return filterNull(searchWords);
}
Aggregations