| Line 177... |
Line 177... |
| 177 |
|
177 |
|
| 178 |
@Autowired
|
178 |
@Autowired
|
| 179 |
private BrandsService brandsService;
|
179 |
private BrandsService brandsService;
|
| 180 |
|
180 |
|
| 181 |
@Autowired
|
181 |
@Autowired
|
| - |
|
182 |
private BrandsRepository brandsRepository;
|
| - |
|
183 |
|
| - |
|
184 |
@Autowired
|
| 182 |
private WebListingRepository webListingRepository;
|
185 |
private WebListingRepository webListingRepository;
|
| 183 |
|
186 |
|
| 184 |
@Autowired
|
187 |
@Autowired
|
| 185 |
private WebProductListingRepository webProductListingRepository;
|
188 |
private WebProductListingRepository webProductListingRepository;
|
| 186 |
|
189 |
|
| Line 351... |
Line 354... |
| 351 |
|
354 |
|
| 352 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
355 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 353 |
@RequestMapping(value = "/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
356 |
@RequestMapping(value = "/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 354 |
public ResponseEntity<?> getFofo(HttpServletRequest request, @RequestParam(value = "categoryId", required = false, defaultValue = "3") String categoryId, @RequestParam(value = "offset") int offset,
|
357 |
public ResponseEntity<?> getFofo(HttpServletRequest request, @RequestParam(value = "categoryId", required = false, defaultValue = "3") String categoryId, @RequestParam(value = "offset") int offset,
|
| 355 |
@RequestParam(value = "limit") int limit, @RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "brand", required = false) String brand, @RequestParam(value = "subCategoryId", required = false) int subCategoryId, @RequestParam(value = "q", required = false) String queryTerm, @RequestParam(value = "hotDeal", required = false) boolean hotDeal, @RequestParam(value = "endPoint", required = false) String endPoint,@RequestParam(value = "group", required = false) boolean group) throws Throwable {
|
358 |
@RequestParam(value = "limit") int limit, @RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "brand", required = false) String brand, @RequestParam(value = "subCategoryId", required = false) int subCategoryId, @RequestParam(value = "q", required = false) String queryTerm, @RequestParam(value = "hotDeal", required = false) boolean hotDeal, @RequestParam(value = "endPoint", required = false) String endPoint,@RequestParam(value = "group", required = false) boolean group) throws Throwable {
|
| - |
|
359 |
// Band-aid for URL '+' decode issue on brand names.
|
| - |
|
360 |
// Front-end sends `brand=Ai+`. Depending on where along the request path the
|
| - |
|
361 |
// '+' is decoded, the servlet may receive "Ai " (trailing space) or just "Ai"
|
| - |
|
362 |
// (plus dropped entirely by the SPA before the request goes out).
|
| - |
|
363 |
// Strategy: if the received value doesn't exist as a real brand in catalog.brand,
|
| - |
|
364 |
// try appending '+' and see if THAT exists — if so, use it. Zero regression risk
|
| - |
|
365 |
// for real brand names because the fallback only fires on unknown values.
|
| - |
|
366 |
logger.info("getFofo received brand='{}' (len={})",
|
| - |
|
367 |
brand, brand == null ? -1 : brand.length());
|
| - |
|
368 |
if (brand != null && !brand.trim().isEmpty()) {
|
| - |
|
369 |
String probe = brand.replaceAll("\\s+$", "");
|
| - |
|
370 |
try {
|
| - |
|
371 |
if (brandsRepository.selectByBrand(brand) == null
|
| - |
|
372 |
&& (probe.equals(brand) || brandsRepository.selectByBrand(probe) == null)) {
|
| - |
|
373 |
String withPlus = probe + "+";
|
| - |
|
374 |
if (brandsRepository.selectByBrand(withPlus) != null) {
|
| - |
|
375 |
logger.info("getFofo brand fallback: '{}' -> '{}'", brand, withPlus);
|
| - |
|
376 |
brand = withPlus;
|
| - |
|
377 |
}
|
| - |
|
378 |
}
|
| - |
|
379 |
} catch (Exception e) {
|
| - |
|
380 |
logger.warn("getFofo brand fallback lookup failed for '{}': {}", brand, e.getMessage());
|
| - |
|
381 |
}
|
| - |
|
382 |
}
|
| 356 |
List<FofoCatalogResponse> dealResponse;
|
383 |
List<FofoCatalogResponse> dealResponse;
|
| 357 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
384 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 358 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
|
385 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
|
| 359 |
sort = "w" + fs.getWarehouseId() + "_i desc";
|
386 |
sort = "w" + fs.getWarehouseId() + "_i desc";
|
| 360 |
|
387 |
|