|
|
@@ -78,14 +78,9 @@ public class SearchServiceImpl implements SearchService {
|
|
|
}
|
|
|
|
|
|
public PageList<VideoCard> searchByKeyword1(String keyword, String nextIdStr, int pageNumber) {
|
|
|
+ //processKeywordAsync(keyword);
|
|
|
List<Integer> scopes = contentPermission.getUserScopes();
|
|
|
SearchCriteria searchCriteria = new SearchCriteria.Builder().scope(scopes).title(keyword).build();
|
|
|
- /*int total = getTotal(keyword);
|
|
|
- if (total == 0) {
|
|
|
- total = videoPostMapper.countBySearchCriteria(searchCriteria);
|
|
|
- saveKeywordAsync(keyword);
|
|
|
- setTotal(keyword, total);
|
|
|
- }*/
|
|
|
int total = videoPostMapper.countBySearchCriteria(searchCriteria);
|
|
|
Page page = new Page(pageNumber, pageSize);
|
|
|
List<VideoPost> list = videoPostMapper.findSearchCriteriaByPage(page, searchCriteria);
|
|
|
@@ -122,6 +117,14 @@ public class SearchServiceImpl implements SearchService {
|
|
|
return PageList.pageList(pageNumber, pageSize, (int) pageList.getTotalSize(), list1);
|
|
|
}
|
|
|
|
|
|
+ private void processKeywordAsync(String keyword) {
|
|
|
+ int total = getTotal(keyword);
|
|
|
+ if (total == 0) {
|
|
|
+ saveKeyword(keyword);
|
|
|
+ setTotal(keyword, total);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private int getTotal(String keyword) {
|
|
|
String key = String.format("tnb:search:total:%s", keyword);
|
|
|
String value = redisString.get(key);
|
|
|
@@ -133,11 +136,12 @@ public class SearchServiceImpl implements SearchService {
|
|
|
redisString.setWithTimeout(key, total+"", 600);
|
|
|
}
|
|
|
|
|
|
- private void saveKeywordAsync(String keyword) {
|
|
|
+ private void saveKeyword(String keyword) {
|
|
|
long userId = UserContext.getUser();
|
|
|
searchRecordMapper.save(new SearchRecord(userId, keyword));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public List<HotSearch> getHotSearch() {
|
|
|
return searchRecordMapper.findHotSearch();
|
|
|
}
|