Subversion Repositories SmartDukaan

Rev

Rev 34196 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34196 Rev 37144
Line 79... Line 79...
79
	private ItemRepository itemRepository;
79
	private ItemRepository itemRepository;
80
 
80
 
81
	@Autowired
81
	@Autowired
82
	private SaholicCISTableRepository saholicCISTableRepository;
82
	private SaholicCISTableRepository saholicCISTableRepository;
83
 
83
 
-
 
84
	@Autowired
-
 
85
	private PartnerSolrClient partnerSolrClient;
-
 
86
 
84
	private static final String limit ="20";
87
	private static final String limit ="20";
85
	private static final String groupLimit = "10";
88
	private static final String groupLimit = "10";
86
	private static final String autoSuggestField = "title,subCategoryId,category_id,category,subCategory,score";
89
	private static final String autoSuggestField = "title,subCategoryId,category_id,category,subCategory,score";
87
	private static final String searchResultsField = "title,skuBundleId,id,thumbnail,ids";
90
	private static final String searchResultsField = "title,skuBundleId,id,thumbnail,ids";
88
	private static final String outputFormat = "json";
91
	private static final String outputFormat = "json";
Line 133... Line 136...
133
		return jsonString; 
136
		return jsonString; 
134
	}
137
	}
135
 
138
 
136
	public List<FofoCatalogResponse> dealResponse (Set<Integer> catalogIds, int fofoId) throws Exception {
139
	public List<FofoCatalogResponse> dealResponse (Set<Integer> catalogIds, int fofoId) throws Exception {
137
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
140
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
138
		RestClient rc = new RestClient();
-
 
139
		Map<String, String> params = new HashMap<>();
141
		Map<String, String> params = new HashMap<>();
140
		List<String> mandatoryQ = new ArrayList<>();
142
		List<String> mandatoryQ = new ArrayList<>();
141
		mandatoryQ.add(String.format("+catalogId_i:(%s) +{!parent which=\"id:catalog*\"}", StringUtils.join(catalogIds, " ")));
143
		mandatoryQ.add(String.format("+catalogId_i:(%s) +{!parent which=\"id:catalog*\"}", StringUtils.join(catalogIds, " ")));
142
		params.put("start", "0");
144
		params.put("start", "0");
143
		params.put("rows", "100");
145
		params.put("rows", "100");
144
		params.put("q", StringUtils.join(mandatoryQ, " "));
146
		params.put("q", StringUtils.join(mandatoryQ, " "));
145
		params.put("fl", "*, [child parentFilter=id:catalog*]");
147
		params.put("fl", "*, [child parentFilter=id:catalog*]");
146
 
148
 
147
		params.put("wt", "json");
149
		params.put("wt", "json");
148
		String response = null;
-
 
149
		try {
-
 
150
			response = rc.get(SchemeType.HTTP, solrUrl, 8984, "solr/demo/select", params);
-
 
151
		} catch (HttpHostConnectException e) {
-
 
152
			throw new ProfitMandiBusinessException("", "", "Could not connect to host");
-
 
153
		}
-
 
154
		JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
-
 
155
		JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
150
		JSONArray docs = partnerSolrClient.selectDocs(params, fofoId);
156
		dealResponse = getCatalogResponse(docs, false, fofoId);
151
		dealResponse = getCatalogResponse(docs, false, fofoId);
157
 
152
 
158
		return dealResponse;
153
		return dealResponse;
159
 
154
 
160
	}
155
	}