|
|
@@ -0,0 +1,59 @@
|
|
|
+package com.uas.platform.b2b.search;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import com.uas.platform.b2b.dao.PurchaseOrderDao;
|
|
|
+import com.uas.platform.b2b.model.PurchaseOrder;
|
|
|
+import com.uas.search.b2b.model.PageParams;
|
|
|
+import com.uas.search.b2b.model.SPage;
|
|
|
+import com.uas.search.b2b.service.SearchService.Table_name;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 搜索实现
|
|
|
+ *
|
|
|
+ * @author sunyj
|
|
|
+ * @since 2016年11月11日 上午10:43:25
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class SearchServiceImpl implements com.uas.platform.b2b.search.SearchService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private com.uas.search.b2b.service.SearchService searchService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PurchaseOrderDao purchaseOrderDao;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public SPage<PurchaseOrder> searchPurchaseOrderIds(String keyword, PageParams pageParams, Short status) {
|
|
|
+ SPage<Long> idsPage = searchService.searchIds(keyword, Table_name.PURC$ORDERS, pageParams, status);
|
|
|
+ return toSPage(idsPage, purchaseOrderDao.findAll(idsPage.getContent()));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将id的SPage信息、数据合并
|
|
|
+ *
|
|
|
+ * @param idsPage
|
|
|
+ * id的SPage信息
|
|
|
+ * @param content
|
|
|
+ * 数据
|
|
|
+ * @return 合并后的结果
|
|
|
+ */
|
|
|
+ private <T> SPage<T> toSPage(SPage<Long> idsPage, List<T> content) {
|
|
|
+ if (idsPage == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ SPage<T> result = new SPage<>();
|
|
|
+ result.setContent(content);
|
|
|
+ result.setFirst(idsPage.isFirst());
|
|
|
+ result.setLast(idsPage.isLast());
|
|
|
+ result.setPage(idsPage.getPage());
|
|
|
+ result.setSize(idsPage.getSize());
|
|
|
+ result.setTotalElement(idsPage.getTotalElement());
|
|
|
+ result.setTotalPage(idsPage.getTotalPage());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|