|
|
@@ -84,9 +84,15 @@ public class ProductServiceImpl implements ProductService {
|
|
|
condition=condition.concat("AND price <= :price");
|
|
|
}
|
|
|
Query query=entityManager.createQuery(condition);
|
|
|
- query.setParameter("name",name);
|
|
|
- query.setParameter("category",category);
|
|
|
- query.setParameter("price",price);
|
|
|
+ if (name!=null && name.length()>0){
|
|
|
+ query.setParameter("name",name);
|
|
|
+ }
|
|
|
+ if (category!=null){
|
|
|
+ query.setParameter("category",category);
|
|
|
+ }
|
|
|
+ if (price!=null && price>0){
|
|
|
+ query.setParameter("price",price);
|
|
|
+ }
|
|
|
List<Product> products=query.getResultList();
|
|
|
return products.stream().map(Product::toVO).collect(Collectors.toList());
|
|
|
}
|