Subversion Repositories SmartDukaan

Rev

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

Rev 24149 Rev 24163
Line 33... Line 33...
33
import com.eclipsesource.json.JsonArray;
33
import com.eclipsesource.json.JsonArray;
34
import com.eclipsesource.json.JsonObject;
34
import com.eclipsesource.json.JsonObject;
35
import com.eclipsesource.json.JsonValue;
35
import com.eclipsesource.json.JsonValue;
36
import com.google.gson.Gson;
36
import com.google.gson.Gson;
37
import com.google.gson.reflect.TypeToken;
37
import com.google.gson.reflect.TypeToken;
-
 
38
import com.mongodb.DBObject;
38
import com.spice.profitmandi.common.enumuration.SchemeType;
39
import com.spice.profitmandi.common.enumuration.SchemeType;
39
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
40
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
40
import com.spice.profitmandi.common.model.ProfitMandiConstants;
41
import com.spice.profitmandi.common.model.ProfitMandiConstants;
41
import com.spice.profitmandi.common.model.UserInfo;
42
import com.spice.profitmandi.common.model.UserInfo;
42
import com.spice.profitmandi.common.web.client.RestClient;
43
import com.spice.profitmandi.common.web.client.RestClient;
Line 102... Line 103...
102
 
103
 
103
	@Autowired
104
	@Autowired
104
	private RoleManager roleManagerService;
105
	private RoleManager roleManagerService;
105
 
106
 
106
	List<String> filterableParams = Arrays.asList("brand");
107
	List<String> filterableParams = Arrays.asList("brand");
-
 
108
	static 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
	}
107
 
114
 
108
	@RequestMapping(value = ProfitMandiConstants.URL_DEALS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
115
	@RequestMapping(value = ProfitMandiConstants.URL_DEALS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
109
	@ApiImplicitParams({
116
	@ApiImplicitParams({
110
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
117
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
111
	@ApiOperation(value = "Get deals")
118
	@ApiOperation(value = "Get deals")
Line 399... Line 406...
399
		}
406
		}
400
		return responseSender.ok(dealResponse.get(0));
407
		return responseSender.ok(dealResponse.get(0));
401
	}
408
	}
402
 
409
 
403
	@RequestMapping(value = "/fofo/brands", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
410
	@RequestMapping(value = "/fofo/brands", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
404
	public ResponseEntity<?> getBrandsToDisplay(@RequestParam(required = false, defaultValue = "0") int categoryId) {
411
	public ResponseEntity<?> getBrandsToDisplay(HttpServletRequest request,  @RequestParam(required = false, defaultValue = "0") int categoryId) {
-
 
412
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
-
 
413
		List<DBObject> brandsDisplay = mongoClient.getBrandsToDisplay(categoryId);
-
 
414
		if(EMAIL_BLOCKED_BRANDS.containsKey(userInfo.getEmail())) {
-
 
415
			List<String> blockedBrands = EMAIL_BLOCKED_BRANDS.get(userInfo.getEmail());
-
 
416
			brandsDisplay.stream().filter(x->{
-
 
417
				return blockedBrands.contains(x.get("name").toString());
-
 
418
			});
-
 
419
		}
405
		return new ResponseEntity<>(mongoClient.getBrandsToDisplay(categoryId), HttpStatus.OK);
420
		return new ResponseEntity<>(brandsDisplay, HttpStatus.OK);
406
	}
421
	}
407
 
422
 
408
	@RequestMapping(value = "/banners/{bannerType}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
423
	@RequestMapping(value = "/banners/{bannerType}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
409
	public ResponseEntity<?> getBanners(@PathVariable String bannerType) {
424
	public ResponseEntity<?> getBanners(@PathVariable String bannerType) {
410
		return new ResponseEntity<>(mongoClient.getBannersByType(bannerType), HttpStatus.OK);
425
		return new ResponseEntity<>(mongoClient.getBannersByType(bannerType), HttpStatus.OK);