Subversion Repositories SmartDukaan

Rev

Rev 28405 | Rev 28426 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 28405 Rev 28423
Line 224... Line 224...
224
	@ApiImplicitParams({
224
	@ApiImplicitParams({
225
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
225
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
226
	@ApiOperation(value = "Get unit deal object")
226
	@ApiOperation(value = "Get unit deal object")
227
	public ResponseEntity<?> getUnitFocoDeal(HttpServletRequest request, @PathVariable(value = "id") long id)
227
	public ResponseEntity<?> getUnitFocoDeal(HttpServletRequest request, @PathVariable(value = "id") long id)
228
			throws ProfitMandiBusinessException {
228
			throws ProfitMandiBusinessException {
229
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
229
		List<FofoCatalogResponse> dealResponses = new ArrayList<>();
230
		List<Integer> tagIds = Arrays.asList(4);
230
		List<Integer> tagIds = Arrays.asList(4);
-
 
231
		FofoCatalogResponse fofoCatalogResponse = null;
231
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
232
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
232
		if (roleManagerService.isPartner(userInfo.getRoleIds())) {
233
		if (roleManagerService.isPartner(userInfo.getRoleIds())) {
233
			String categoryId = "(3 OR 6)";
234
			String categoryId = "(3 OR 6)";
234
 
235
 
235
			RestClient rc = new RestClient();
236
			RestClient rc = new RestClient();
Line 250... Line 251...
250
			} catch (HttpHostConnectException e) {
251
			} catch (HttpHostConnectException e) {
251
				throw new ProfitMandiBusinessException("", "", "Could not connect to host");
252
				throw new ProfitMandiBusinessException("", "", "Could not connect to host");
252
			}
253
			}
253
			JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
254
			JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
254
			JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
255
			JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
255
			dealResponse = getCatalogResponse(docs, false, userInfo.getRetailerId());
256
			dealResponses = getCatalogResponse(docs, false, userInfo.getRetailerId());
-
 
257
			fofoCatalogResponse = dealResponses.get(0);
-
 
258
			fofoCatalogResponse.setWebOffers(webOfferRepository.selectAllActiveOffers().get(fofoCatalogResponse.getCatalogId()));
-
 
259
			
256
		} else {
260
		} else {
257
			return responseSender.badRequest(
261
			return responseSender.badRequest(
258
					new ProfitMandiBusinessException("Retailer id", userInfo.getUserId(), "NOT_FOFO_RETAILER"));
262
					new ProfitMandiBusinessException("Retailer id", userInfo.getUserId(), "NOT_FOFO_RETAILER"));
259
		}
263
		}
260
		return responseSender.ok(dealResponse.get(0));
264
		return responseSender.ok(dealResponses.get(0));
261
	}
265
	}
262
 
266
 
263
	private Object toDealObject(JsonObject jsonObject) {
267
	private Object toDealObject(JsonObject jsonObject) {
264
		if (jsonObject.get("dealObject") != null && jsonObject.get("dealObject").asInt() == 1) {
268
		if (jsonObject.get("dealObject") != null && jsonObject.get("dealObject").asInt() == 1) {
265
			return new Gson().fromJson(jsonObject.toString(), DealObjectResponse.class);
269
			return new Gson().fromJson(jsonObject.toString(), DealObjectResponse.class);