| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- package com.uas.search.console.controller;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.Set;
- import org.apache.commons.collections.CollectionUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
- import com.uas.search.console.dao.ComponentSimpleInfoDao;
- import com.uas.search.console.model.ComponentSimpleInfo;
- import com.uas.search.model.PageParams;
- import com.uas.search.service.SearchService;
- /**
- * 搜索请求
- *
- * @author suntg
- * @since 2016年8月1日上午9:18:05
- */
- @Controller
- @RequestMapping("/search")
- public class SearchController {
- @Autowired
- private SearchService searchService;
- /**
- * 搜索产品类目
- *
- * @param keyword
- * @return
- */
- @RequestMapping("/kindIds")
- @ResponseBody
- public List<Long> seachKindIds(String keyword) {
- return searchService.getKindIds(keyword);
- }
- /**
- * 搜索产品类目
- *
- * @param keyword
- * @return
- */
- @RequestMapping("/kinds")
- @ResponseBody
- public List<Map<String, Object>> seachKinds(String keyword) {
- return searchService.getKinds(keyword);
- }
- /**
- * 搜索产品品牌id
- *
- * @param keyword
- * @return
- */
- @RequestMapping("/brandIds")
- @ResponseBody
- public List<Long> searchBrandIds(String keyword) {
- return searchService.getBrandIds(keyword);
- }
- /**
- * 搜索产品品牌
- *
- * @param keyword
- * @return
- */
- @RequestMapping("/brands")
- @ResponseBody
- public List<Map<String, Object>> searchBrand(String keyword) {
- return searchService.getBrands(keyword);
- }
- /**
- * 搜索产品id
- *
- * @param keyword
- * @return
- */
- @RequestMapping("/componentIds")
- @ResponseBody
- public Map<String, Object> searchComponentIds(String keyword) {
- return searchService.getComponentIds(keyword, new PageParams());
- }
- /**
- * 搜索产品
- *
- * @param keyword
- * @return
- */
- @Autowired
- private ComponentSimpleInfoDao componentDao;
- @RequestMapping("/components")
- @ResponseBody
- public List<ComponentSimpleInfo> searchComponents(String keyword) {
- PageParams pageParams = new PageParams();
- Map<String, Object> filters = new HashMap<>();
- // filters.put("pr_329", "HRC");
- // filters.put("20", "Fast Blow");
- pageParams.setFilters(filters);
- @SuppressWarnings("unchecked")
- List<Long> ids = (List<Long>) searchService.getComponentIds(keyword, pageParams).get("componentIds");
- if (CollectionUtils.isEmpty(ids)) {
- return new ArrayList<ComponentSimpleInfo>();
- }
- Long[] idsLong = new Long[ids.size()];
- int i = 0;
- for (Long id : ids) {
- idsLong[i++] = id;
- }
- return componentDao.findByIdsInOrder(idsLong);
- }
- /**
- * 统计器件的类目id
- *
- * @param keyword
- * @param brandId
- * @return
- */
- @RequestMapping("/kindIdsByComponent")
- @ResponseBody
- public Set<Long> searchKindIdsBySearchComponent(String keyword, String brandId) {
- return searchService.getKindIdsBySearchComponent(keyword, brandId);
- }
- /**
- * 统计器件的类目
- *
- * @param keyword
- * @param brandId
- * @return
- */
- @RequestMapping("/kindsByComponent")
- @ResponseBody
- public List<Map<String, Object>> searchKindsBySearchComponent(String keyword, String brandId) {
- return searchService.getKindsBySearchComponent(keyword, brandId);
- }
- /**
- * 统计器件的品牌id
- *
- * @param keyword
- * @param brandId
- * @return
- */
- @RequestMapping("/brandIdsByComponent")
- @ResponseBody
- public Set<Long> searchBrandIdsBySearchComponent(String keyword, String kindId) {
- return searchService.getBrandIdsBySearchComponent(keyword, kindId);
- }
- /**
- * 统计器件的品牌
- *
- * @param keyword
- * @param brandId
- * @return
- */
- @RequestMapping("/brandsByComponent")
- @ResponseBody
- public List<Map<String, Object>> searchBrandsBySearchComponent(String keyword, String kindId) {
- return searchService.getBrandsBySearchComponent(keyword, kindId);
- }
- /**
- * 联想词
- *
- * @param keyword
- * @return
- */
- @RequestMapping("/similarKeywords")
- @ResponseBody
- public List<String> getSimilarKeywords(String keyword) {
- return searchService.getSimilarKeywords(keyword);
- }
- /**
- * 器件原厂型号联想词
- *
- * @param componentCode
- * @return
- */
- @RequestMapping("/similarComponents")
- @ResponseBody
- public List<Map<String, Object>> getSimilarComponents(String componentCode) {
- return searchService.getSimilarComponents(componentCode);
- }
- /**
- * 器件品牌联想词
- *
- * @param componentCode
- * @return
- */
- @RequestMapping("/similarBrands")
- @ResponseBody
- public List<Map<String, Object>> getSimilarBrands(String brandName) {
- return searchService.getSimilarBrands(brandName);
- }
- }
|