|
|
@@ -705,10 +705,20 @@ public class StoreInServiceImpl implements StoreInService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<StoreIn> findBySimilarName(PageParams params, String keyword, HttpServletRequest request) {
|
|
|
- Page<StoreIn> storeInPage = null;
|
|
|
+ public Page<StoreIn> findBySimilarName(PageParams params, String keyword, String type, 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);
|
|
|
+ typeLogicalEx = PredicateUtils.in("type", typeSet.toArray(new StoreType[]{}), true);
|
|
|
+ }
|
|
|
+ // 搜索店铺名称
|
|
|
if (!StringUtils.isEmpty(keyword)) {
|
|
|
- final PageInfo pageInfo = new PageInfo(params);
|
|
|
+ nameSimpleEx = PredicateUtils.like("storeName", keyword, true);
|
|
|
+ // 搜索器件、品牌、类目
|
|
|
PageParams pageParams = new PageParams();
|
|
|
pageParams.setCount(20);
|
|
|
pageParams.setPage(1);
|
|
|
@@ -716,30 +726,46 @@ public class StoreInServiceImpl implements StoreInService {
|
|
|
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());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- SimpleExpression keywordSimpleExpression = PredicateUtils.like("storeName", keyword, true);
|
|
|
-
|
|
|
if (CollectionUtils.isNotEmpty(storeIds)) {
|
|
|
- LogicalExpression storIdList = PredicateUtils.in("id", storeIds, true);
|
|
|
- pageInfo.expression(PredicateUtils.or(keywordSimpleExpression, storIdList));
|
|
|
- } else {
|
|
|
- pageInfo.expression(keywordSimpleExpression);
|
|
|
+ keywordLogicalEx = PredicateUtils.in("uuid", storeIds, true);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- storeInPage = storeDao.findAll(new Specification<StoreIn>() {
|
|
|
- @Override
|
|
|
- public Predicate toPredicate(Root<StoreIn> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
|
|
- criteriaQuery.where(pageInfo.getPredicates(root, criteriaQuery, criteriaBuilder));
|
|
|
- return null;
|
|
|
+ if (nameSimpleEx != null) {
|
|
|
+ if (keywordLogicalEx != null) {
|
|
|
+ keywordLogicalEx = PredicateUtils.or(nameSimpleEx, keywordLogicalEx);
|
|
|
+ if (typeLogicalEx != null) {
|
|
|
+ pageInfo.expression(PredicateUtils.and(keywordLogicalEx, typeLogicalEx));
|
|
|
+ } else {
|
|
|
+ pageInfo.expression(keywordLogicalEx);
|
|
|
}
|
|
|
- }, pageInfo);
|
|
|
+ } else if (typeLogicalEx != null) {
|
|
|
+ pageInfo.expression(PredicateUtils.and(nameSimpleEx, typeLogicalEx));
|
|
|
+ } else {
|
|
|
+ pageInfo.expression(nameSimpleEx);
|
|
|
+ }
|
|
|
+ } else if (keywordLogicalEx != null) {
|
|
|
+ if (typeLogicalEx != null) {
|
|
|
+ pageInfo.expression(PredicateUtils.and(keywordLogicalEx, typeLogicalEx));
|
|
|
+ } else {
|
|
|
+ pageInfo.expression(keywordLogicalEx);
|
|
|
+ }
|
|
|
+ } else if (typeLogicalEx != null) {
|
|
|
+ pageInfo.expression(typeLogicalEx);
|
|
|
}
|
|
|
- return storeInPage;
|
|
|
+
|
|
|
+ return storeDao.findAll(new Specification<StoreIn>() {
|
|
|
+ @Override
|
|
|
+ public Predicate toPredicate(Root<StoreIn> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
|
|
+ criteriaQuery.where(pageInfo.getPredicates(root, criteriaQuery, criteriaBuilder));
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }, pageInfo);
|
|
|
}
|
|
|
}
|