| Line 187... |
Line 187... |
| 187 |
public ResponseEntity<?> getFofo(HttpServletRequest request,
|
187 |
public ResponseEntity<?> getFofo(HttpServletRequest request,
|
| 188 |
@RequestParam(value = "categoryId", required = false, defaultValue = "(3 OR 6)") String categoryId,
|
188 |
@RequestParam(value = "categoryId", required = false, defaultValue = "(3 OR 6)") String categoryId,
|
| 189 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
189 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
| 190 |
@RequestParam(value = "sort", required = false) String sort,
|
190 |
@RequestParam(value = "sort", required = false) String sort,
|
| 191 |
@RequestParam(value = "brand", required = false) String brand,
|
191 |
@RequestParam(value = "brand", required = false) String brand,
|
| 192 |
@RequestParam(value = "subCategoryId", required = false) String subCategoryId,
|
192 |
@RequestParam(value = "subCategoryId", required = false) int subCategoryId,
|
| 193 |
@RequestParam(value = "q", required = false) String queryTerm,
|
193 |
@RequestParam(value = "q", required = false) String queryTerm,
|
| 194 |
@RequestParam(value = "hotDeal", required = false) boolean hotDeal) throws Throwable {
|
194 |
@RequestParam(value = "hotDeal", required = false) boolean hotDeal) throws Throwable {
|
| 195 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
195 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 196 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
196 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 197 |
if (roleManagerService.isPartner(userInfo.getRoleIds())) {
|
197 |
if (roleManagerService.isPartner(userInfo.getRoleIds())) {
|
| Line 203... |
Line 203... |
| 203 |
if (queryTerm != null && !queryTerm.equals("null")) {
|
203 |
if (queryTerm != null && !queryTerm.equals("null")) {
|
| 204 |
mandatoryQ.add(String.format("+(%s)", queryTerm));
|
204 |
mandatoryQ.add(String.format("+(%s)", queryTerm));
|
| 205 |
} else {
|
205 |
} else {
|
| 206 |
queryTerm = null;
|
206 |
queryTerm = null;
|
| 207 |
}
|
207 |
}
|
| 208 |
if (brand != null) {
|
208 |
if (StringUtils.isNotBlank(brand)) {
|
| 209 |
|
- |
|
| 210 |
mandatoryQ.add(
|
209 |
mandatoryQ.add(
|
| 211 |
String.format("+(categoryId_i:%s) +(brand_ss:%s) +{!parent which=\"brand_ss:%s\"} tagId_i:(%s)",
|
210 |
String.format("+(categoryId_i:%s) +(brand_ss:%s) +{!parent which=\"brand_ss:%s\"} tagId_i:(%s)",
|
| 212 |
categoryId, brand, brand, StringUtils.join(tagIds, " ")));
|
211 |
categoryId, brand, brand, StringUtils.join(tagIds, " ")));
|
| 213 |
} else if (subCategoryId != null) {
|
212 |
} else if (subCategoryId != 0) {
|
| 214 |
mandatoryQ
|
213 |
mandatoryQ
|
| 215 |
.add(String.format("+(subCategoryId_i:%s) +{!parent which=\"subCategoryId_i:%s\"} tagId_i:(%s)",
|
214 |
.add(String.format("+(subCategoryId_i:%s) +{!parent which=\"subCategoryId_i:%s\"} tagId_i:(%s)",
|
| 216 |
subCategoryId, subCategoryId, StringUtils.join(tagIds, " ")));
|
215 |
subCategoryId, subCategoryId, StringUtils.join(tagIds, " ")));
|
| 217 |
|
216 |
|
| 218 |
} else if (hotDeal) {
|
217 |
} else if (hotDeal) {
|
| Line 436... |
Line 435... |
| 436 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
435 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 437 |
List<DBObject> brandsDisplay = null;
|
436 |
List<DBObject> brandsDisplay = null;
|
| 438 |
if (categoryId == 3) {
|
437 |
if (categoryId == 3) {
|
| 439 |
brandsDisplay = mongoClient.getMongoBrands(userInfo.getRetailerId(), userInfo.getEmail(), categoryId);
|
438 |
brandsDisplay = mongoClient.getMongoBrands(userInfo.getRetailerId(), userInfo.getEmail(), categoryId);
|
| 440 |
} else {
|
439 |
} else {
|
| 441 |
brandsDisplay = this.getAccessories();
|
440 |
brandsDisplay = this.getSubCategoriesToDisplay();
|
| 442 |
}
|
441 |
}
|
| 443 |
return new ResponseEntity<>(brandsDisplay, HttpStatus.OK);
|
442 |
return new ResponseEntity<>(brandsDisplay, HttpStatus.OK);
|
| 444 |
}
|
443 |
}
|
| 445 |
|
444 |
|
| 446 |
private List<DBObject> getAccessories() throws Exception {
|
445 |
private List<DBObject> getSubCategoriesToDisplay() throws Exception {
|
| 447 |
List<DBObject> subCategories = new ArrayList<>();
|
446 |
List<DBObject> subCategories = new ArrayList<>();
|
| 448 |
RestClient rc = new RestClient();
|
447 |
RestClient rc = new RestClient();
|
| 449 |
Map<String, String> params = new HashMap<>();
|
448 |
Map<String, String> params = new HashMap<>();
|
| 450 |
params.put("q", "categoryId_i:6");
|
449 |
params.put("q", "categoryId_i:6");
|
| 451 |
params.put("group", "true");
|
450 |
params.put("group", "true");
|
| Line 467... |
Line 466... |
| 467 |
}
|
466 |
}
|
| 468 |
|
467 |
|
| 469 |
List<Category> categories = categoryRepository.selectByIds(categoryIds);
|
468 |
List<Category> categories = categoryRepository.selectByIds(categoryIds);
|
| 470 |
AtomicInteger i= new AtomicInteger(0);
|
469 |
AtomicInteger i= new AtomicInteger(0);
|
| 471 |
categories.forEach(x->{
|
470 |
categories.forEach(x->{
|
| 472 |
DBObject object = new BasicDBObject();
|
471 |
DBObject dbObject = new BasicDBObject();
|
| 473 |
object.put("name", x.getLabel());
|
472 |
dbObject.put("name", x.getLabel());
|
| - |
|
473 |
dbObject.put("subCategoryId", x.getId());
|
| 474 |
object.put("rank", i.incrementAndGet());
|
474 |
dbObject.put("rank", i.incrementAndGet());
|
| 475 |
object.put("categoryId", 6);
|
475 |
dbObject.put("categoryId", 6);
|
| 476 |
object.put("url", "http://api.profittill.com/uploads/campaigns/" + x.getId() + ".png");
|
476 |
dbObject.put("url", "http://api.profittill.com/uploads/campaigns/" + x.getId() + ".png");
|
| - |
|
477 |
subCategories.add(dbObject);
|
| 477 |
});
|
478 |
});
|
| 478 |
|
479 |
|
| - |
|
480 |
return subCategories;
|
| - |
|
481 |
|
| 479 |
}
|
482 |
}
|
| 480 |
|
483 |
|
| 481 |
@RequestMapping(value = "/banners/{bannerType}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
484 |
@RequestMapping(value = "/banners/{bannerType}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 482 |
public ResponseEntity<?> getBanners(@PathVariable String bannerType) {
|
485 |
public ResponseEntity<?> getBanners(@PathVariable String bannerType) {
|
| 483 |
return new ResponseEntity<>(mongoClient.getBannersByType(bannerType), HttpStatus.OK);
|
486 |
return new ResponseEntity<>(mongoClient.getBannersByType(bannerType), HttpStatus.OK);
|