|
|
package com.yoho.search.consumer.suggests.discover;
|
|
|
|
|
|
import com.yoho.search.consumer.service.base.StyleService;
|
|
|
import com.yoho.search.consumer.suggests.common.KeywordType;
|
|
|
import com.yoho.search.consumer.suggests.common.SuggestionConstants;
|
|
|
import com.yoho.search.dal.model.Style;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
* Created by ginozhang on 2016/11/25.
|
|
|
*/
|
|
|
@Component
|
|
|
public class StyleNameSuggestionDiscoverer extends AbstractSuggestionDiscoverer {
|
|
|
|
|
|
@Autowired
|
|
|
private StyleService styleService;
|
|
|
|
|
|
@Override
|
|
|
public int count() {
|
|
|
return styleService.count();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Set<String> getSuggestWordSet(int pageNo, int batchSize) {
|
|
|
Set<String> styleNameSet = new HashSet<>(batchSize);
|
|
|
int start = (pageNo - 1) * batchSize;
|
|
|
List<Style> styleList = styleService.getStylePageLists(start, batchSize);
|
|
|
if (CollectionUtils.isNotEmpty(styleList)) {
|
|
|
for (Style style : styleList) {
|
|
|
if (style.getStyleName() != null && style.getStyleName().length() > 1) {
|
|
|
if (!SuggestionConstants.IGNORE_KEYWORDS.contains(style.getStyleName())) {
|
|
|
styleNameSet.add(style.getStyleName());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return styleNameSet;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public KeywordType getKeywordType() {
|
|
|
return KeywordType.StyleName;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|