|
@@ -1,25 +1,27 @@
|
|
|
package com.uas.ps.product.controller;
|
|
package com.uas.ps.product.controller;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.uas.ps.core.page.PageInfo;
|
|
import com.uas.ps.core.page.PageInfo;
|
|
|
-import com.uas.ps.core.page.criteria.CriterionExpression;
|
|
|
|
|
|
|
+import com.uas.ps.core.util.ContextUtils;
|
|
|
import com.uas.ps.entity.Product;
|
|
import com.uas.ps.entity.Product;
|
|
|
|
|
+import com.uas.ps.entity.ProductUsers;
|
|
|
|
|
+import com.uas.ps.product.search.SPageUtils;
|
|
|
import com.uas.ps.product.service.ProductService;
|
|
import com.uas.ps.product.service.ProductService;
|
|
|
|
|
+import com.uas.ps.product.search.model.SPage;
|
|
|
|
|
+import com.uas.ps.product.search.service.SearchService;
|
|
|
|
|
+import com.uas.ps.properties.UrlProperties;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
|
|
import org.springframework.data.domain.Sort;
|
|
import org.springframework.data.domain.Sort;
|
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
import java.net.URLDecoder;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 物料相关的查询接口
|
|
* 物料相关的查询接口
|
|
@@ -33,6 +35,9 @@ public class ProductGetController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ProductService productService;
|
|
private ProductService productService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SearchService searchService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 根据enUU和code查找企业物料
|
|
* 根据enUU和code查找企业物料
|
|
|
* @param enUU 企业UU
|
|
* @param enUU 企业UU
|
|
@@ -77,12 +82,34 @@ public class ProductGetController {
|
|
|
* @return 物料
|
|
* @return 物料
|
|
|
*/
|
|
*/
|
|
|
@RequestMapping(value = "/findByPageInfo", method = RequestMethod.GET)
|
|
@RequestMapping(value = "/findByPageInfo", method = RequestMethod.GET)
|
|
|
- public Page<Product> findByPageInfo(int pageNumber, int pageSize, String filters, Sort sort, String keyword) {
|
|
|
|
|
|
|
+ public SPage<Product> findByPageInfo(int pageNumber, int pageSize, String filters, Sort sort, String keyword) {
|
|
|
PageInfo pageInfo = new PageInfo(pageNumber, pageSize);
|
|
PageInfo pageInfo = new PageInfo(pageNumber, pageSize);
|
|
|
Map<String, Object> map = JSON.parseObject(filters);
|
|
Map<String, Object> map = JSON.parseObject(filters);
|
|
|
pageInfo.setFilters(map);
|
|
pageInfo.setFilters(map);
|
|
|
pageInfo.setSort(sort);
|
|
pageInfo.setSort(sort);
|
|
|
- return productService.findByPageInfo(pageInfo, keyword);
|
|
|
|
|
|
|
+ if (StringUtils.isEmpty(keyword)) {
|
|
|
|
|
+ return SPageUtils.covert(productService.findByPageInfo(pageInfo, keyword));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return searchService.searchProducts(keyword, pageInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据分页信息查找个人物料
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param pageNumber 页码
|
|
|
|
|
+ * @param pageSize 分页大小
|
|
|
|
|
+ * @param sort 排序
|
|
|
|
|
+ * @param keyword 关键词 不建议使用关键词搜索,jpa获取会很慢
|
|
|
|
|
+ * @return 物料
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping(value = "/findProductUsers", method = RequestMethod.GET)
|
|
|
|
|
+ public SPage<ProductUsers> findProductUsersByPageInfo(int pageNumber, int pageSize, String filters, Sort sort, String keyword) {
|
|
|
|
|
+ PageInfo pageInfo = new PageInfo(pageNumber, pageSize);
|
|
|
|
|
+ Map<String, Object> map = JSON.parseObject(filters);
|
|
|
|
|
+ pageInfo.setFilters(map);
|
|
|
|
|
+ pageInfo.setSort(sort);
|
|
|
|
|
+ return searchService.searchProductUsers(keyword, pageInfo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -186,4 +213,5 @@ public class ProductGetController {
|
|
|
public Long countByEnUU(@RequestParam("enUU") Long enUU) {
|
|
public Long countByEnUU(@RequestParam("enUU") Long enUU) {
|
|
|
return productService.countByEnUU(enUU);
|
|
return productService.countByEnUU(enUU);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|