|
|
@@ -43,6 +43,7 @@ import org.apache.log4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.dao.DataAccessException;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.jdbc.core.CallableStatementCallback;
|
|
|
@@ -162,13 +163,24 @@ public class ProductServiceImpl implements ProductService {
|
|
|
page.expression(logicalExpression2);
|
|
|
}
|
|
|
|
|
|
- return productDao.findAll(new Specification<Product>() {
|
|
|
+ Page<Product> productPage = productDao.findAll(new Specification<Product>() {
|
|
|
@Override
|
|
|
public Predicate toPredicate(Root<Product> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
|
|
query.where(page.getPredicates(root, query, cb));
|
|
|
return null;
|
|
|
}
|
|
|
}, page);
|
|
|
+ List<Product> productList = productPage.getContent();
|
|
|
+ for (Product product : productList) {
|
|
|
+ if ("ERP".equals(product.getSourceApp())) {
|
|
|
+ ProductDetail productDetail = productDetailDao.findByProductId(product.getId());
|
|
|
+ if (productDetail != null) {
|
|
|
+ product.setProductDetail(productDetail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return new PageImpl<Product>(productList, page, productPage.getTotalElements());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -703,8 +715,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- productDetailDao.save(productDetail);
|
|
|
- return null;
|
|
|
+ return productDetailDao.save(productDetail);
|
|
|
}
|
|
|
}
|
|
|
|