Subversion Repositories SmartDukaan

Rev

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

Rev 24975 Rev 24995
Line 103... Line 103...
103
 
103
 
104
	@Autowired
104
	@Autowired
105
	private RoleManager roleManagerService;
105
	private RoleManager roleManagerService;
106
 
106
 
107
	List<String> filterableParams = Arrays.asList("brand");
107
	List<String> filterableParams = Arrays.asList("brand");
108
	public static final Map<String, List<String>> EMAIL_BLOCKED_BRANDS = new HashMap<>();
-
 
109
 
-
 
110
	static {
-
 
111
		EMAIL_BLOCKED_BRANDS.put("sachinindri2006@gmail.com", Arrays.asList("Vivo"));
-
 
112
		EMAIL_BLOCKED_BRANDS.put("akamboj828@gmail.com", Arrays.asList("Vivo"));
-
 
113
		EMAIL_BLOCKED_BRANDS.put("babitaranirk@gmail.com", Arrays.asList("Vivo"));
-
 
114
		EMAIL_BLOCKED_BRANDS.put("testpxps@gmail.com", Arrays.asList("Gionee"));
-
 
115
	}
-
 
116
 
108
 
117
	@RequestMapping(value = ProfitMandiConstants.URL_DEALS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
109
	@RequestMapping(value = ProfitMandiConstants.URL_DEALS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
118
	@ApiImplicitParams({
110
	@ApiImplicitParams({
119
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
111
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
120
	@ApiOperation(value = "Get deals")
112
	@ApiOperation(value = "Get deals")
Line 219... Line 211...
219
				mandatoryQ.add(
211
				mandatoryQ.add(
220
						String.format("+{!parent which=\"id:catalog*\"} tagId_i:(%s)", StringUtils.join(tagIds, " ")));
212
						String.format("+{!parent which=\"id:catalog*\"} tagId_i:(%s)", StringUtils.join(tagIds, " ")));
221
			}
213
			}
222
			params.put("q", StringUtils.join(mandatoryQ, " "));
214
			params.put("q", StringUtils.join(mandatoryQ, " "));
223
			params.put("fl", "*, [child parentFilter=id:catalog*]");
215
			params.put("fl", "*, [child parentFilter=id:catalog*]");
224
			if(queryTerm==null) {
216
			if (queryTerm == null) {
225
				params.put("sort", "create_s desc");
217
				params.put("sort", "create_s desc");
226
			}
218
			}
227
			params.put("start", String.valueOf(offset));
219
			params.put("start", String.valueOf(offset));
228
			params.put("rows", String.valueOf(limit));
220
			params.put("rows", String.valueOf(limit));
229
			params.put("wt", "json");
221
			params.put("wt", "json");
Line 234... Line 226...
234
				throw new ProfitMandiBusinessException("", "", "Could not connect to host");
226
				throw new ProfitMandiBusinessException("", "", "Could not connect to host");
235
			}
227
			}
236
			JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
228
			JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
237
			JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
229
			JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
238
			dealResponse = getCatalogResponse(docs, hotDeal);
230
			dealResponse = getCatalogResponse(docs, hotDeal);
239
			if (EMAIL_BLOCKED_BRANDS.containsKey(userInfo.getEmail())) {
231
			if (Mongo.EMAIL_BLOCKED_BRANDS.containsKey(userInfo.getEmail())) {
240
				dealResponse.stream().filter(x -> EMAIL_BLOCKED_BRANDS.get(userInfo.getEmail()).contains(x.getBrand()));
232
				dealResponse.stream().filter(x -> Mongo.EMAIL_BLOCKED_BRANDS.get(userInfo.getEmail()).contains(x.getBrand()));
241
			}
233
			}
242
		} else {
234
		} else {
243
			return responseSender.badRequest(
235
			return responseSender.badRequest(
244
					new ProfitMandiBusinessException("Retailer id", userInfo.getUserId(), "NOT_FOFO_RETAILER"));
236
					new ProfitMandiBusinessException("Retailer id", userInfo.getUserId(), "NOT_FOFO_RETAILER"));
245
		}
237
		}
Line 427... Line 419...
427
 
419
 
428
	@RequestMapping(value = "/fofo/brands", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
420
	@RequestMapping(value = "/fofo/brands", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
429
	public ResponseEntity<?> getBrandsToDisplay(HttpServletRequest request,
421
	public ResponseEntity<?> getBrandsToDisplay(HttpServletRequest request,
430
			@RequestParam(required = false, defaultValue = "0") int categoryId) {
422
			@RequestParam(required = false, defaultValue = "0") int categoryId) {
431
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
423
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
432
		List<DBObject> brandsDisplay = mongoClient.getBrandsToDisplay(categoryId);
424
		List<DBObject> brandsDisplay = mongoClient.getMongoBrands(userInfo.getRetailerId(), userInfo.getEmail(), categoryId);
433
		if (EMAIL_BLOCKED_BRANDS.containsKey(userInfo.getEmail())) {
-
 
434
			List<String> blockedBrands = EMAIL_BLOCKED_BRANDS.get(userInfo.getEmail());
-
 
435
			brandsDisplay = brandsDisplay.stream().filter(x -> !blockedBrands.contains(x.get("name")))
-
 
436
					.collect(Collectors.toList());
-
 
437
		}
-
 
438
		return new ResponseEntity<>(brandsDisplay, HttpStatus.OK);
425
		return new ResponseEntity<>(brandsDisplay, HttpStatus.OK);
439
	}
426
	}
440
 
427
 
441
	@RequestMapping(value = "/banners/{bannerType}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
428
	@RequestMapping(value = "/banners/{bannerType}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
442
	public ResponseEntity<?> getBanners(@PathVariable String bannerType) {
429
	public ResponseEntity<?> getBanners(@PathVariable String bannerType) {