|
|
@@ -705,11 +705,12 @@ public class StoreInServiceImpl implements StoreInService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<StoreIn> findBySimilarName(PageParams params, String keyword, String type, HttpServletRequest request) {
|
|
|
+ public Page<StoreIn> findBySimilarName(PageParams params, String keyword, String type, String field, HttpServletRequest request) {
|
|
|
LogicalExpression typeLogicalEx = null;
|
|
|
LogicalExpression keywordLogicalEx = null;
|
|
|
SimpleExpression nameSimpleEx = null;
|
|
|
final PageInfo pageInfo = new PageInfo(params);
|
|
|
+
|
|
|
// 搜索店铺类型
|
|
|
if (!StringUtils.isEmpty(type)) {
|
|
|
Set<StoreType> typeSet = getTypesFromString(type);
|
|
|
@@ -717,48 +718,40 @@ public class StoreInServiceImpl implements StoreInService {
|
|
|
}
|
|
|
// 搜索店铺名称
|
|
|
if (!StringUtils.isEmpty(keyword)) {
|
|
|
- nameSimpleEx = PredicateUtils.like("storeName", keyword, true);
|
|
|
- // 搜索器件、品牌、类目
|
|
|
- PageParams pageParams = new PageParams();
|
|
|
- pageParams.setCount(20);
|
|
|
- pageParams.setPage(1);
|
|
|
-
|
|
|
- ModelMap map = searcherService.searchComponentGoods(keyword, pageParams, request);
|
|
|
- List<ComponentGoods> components = (List<ComponentGoods>) map.get("components");
|
|
|
- Set<String> storeIds = new HashSet<>();
|
|
|
- for (ComponentGoods componentGood : components) {
|
|
|
- if (componentGood.getStoreId() != null) {
|
|
|
- storeIds.add(componentGood.getStoreId());
|
|
|
- }
|
|
|
- }
|
|
|
+ if ("similar".equals(field)) {
|
|
|
+ // 搜索器件、品牌、类目
|
|
|
+ PageParams pageParams = new PageParams();
|
|
|
+ pageParams.setCount(20);
|
|
|
+ pageParams.setPage(1);
|
|
|
+
|
|
|
+ ModelMap map = searcherService.searchComponentGoods(keyword, pageParams, request);
|
|
|
+ List<ComponentGoods> components = (List<ComponentGoods>) map.get("components");
|
|
|
+ Set<String> storeIds = new HashSet<>();
|
|
|
+ for (ComponentGoods componentGood : components) {
|
|
|
+ if (componentGood.getStoreId() != null) {
|
|
|
+ storeIds.add(componentGood.getStoreId());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(storeIds)) {
|
|
|
- keywordLogicalEx = PredicateUtils.in("uuid", storeIds, true);
|
|
|
- }
|
|
|
+ if (CollectionUtils.isNotEmpty(storeIds)) {
|
|
|
+ keywordLogicalEx = PredicateUtils.in("uuid", storeIds, true);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ nameSimpleEx = PredicateUtils.like("storeName", keyword, true);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (nameSimpleEx != null) {
|
|
|
- if (keywordLogicalEx != null) {
|
|
|
- keywordLogicalEx = PredicateUtils.or(nameSimpleEx, keywordLogicalEx);
|
|
|
- if (typeLogicalEx != null) {
|
|
|
- pageInfo.expression(PredicateUtils.and(keywordLogicalEx, typeLogicalEx));
|
|
|
- } else {
|
|
|
- pageInfo.expression(keywordLogicalEx);
|
|
|
- }
|
|
|
- } else if (typeLogicalEx != null) {
|
|
|
- pageInfo.expression(PredicateUtils.and(nameSimpleEx, typeLogicalEx));
|
|
|
- } else {
|
|
|
- pageInfo.expression(nameSimpleEx);
|
|
|
- }
|
|
|
- } else if (keywordLogicalEx != null) {
|
|
|
- if (typeLogicalEx != null) {
|
|
|
+ if (typeLogicalEx != null) {
|
|
|
+ pageInfo.expression(PredicateUtils.and(nameSimpleEx, typeLogicalEx));
|
|
|
+ } else {
|
|
|
+ pageInfo.expression(nameSimpleEx);
|
|
|
+ }
|
|
|
+ } else if (typeLogicalEx != null) {
|
|
|
pageInfo.expression(PredicateUtils.and(keywordLogicalEx, typeLogicalEx));
|
|
|
} else {
|
|
|
pageInfo.expression(keywordLogicalEx);
|
|
|
}
|
|
|
- } else if (typeLogicalEx != null) {
|
|
|
- pageInfo.expression(typeLogicalEx);
|
|
|
- }
|
|
|
|
|
|
return storeDao.findAll(new Specification<StoreIn>() {
|
|
|
@Override
|