Subversion Repositories SmartDukaan

Rev

Rev 36404 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36404 Rev 37184
Line 15... Line 15...
15
import com.spice.profitmandi.dao.entity.fofo.PrintResourceRegion;
15
import com.spice.profitmandi.dao.entity.fofo.PrintResourceRegion;
16
import com.spice.profitmandi.dao.entity.user.User;
16
import com.spice.profitmandi.dao.entity.user.User;
17
import com.spice.profitmandi.dao.enumuration.inventory.CatalogMovingEnum;
17
import com.spice.profitmandi.dao.enumuration.inventory.CatalogMovingEnum;
18
import com.spice.profitmandi.dao.model.*;
18
import com.spice.profitmandi.dao.model.*;
19
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
19
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
20
import com.spice.profitmandi.dao.repository.catalog.CatalogMonitorTypeRepository;
-
 
21
import com.spice.profitmandi.dao.repository.catalog.CatalogRepository;
-
 
22
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
-
 
23
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
20
import com.spice.profitmandi.dao.repository.catalog.*;
24
import com.spice.profitmandi.dao.repository.catalog.SuperCatalogRepository;
-
 
25
import com.spice.profitmandi.dao.repository.cs.BulletinRepository;
21
import com.spice.profitmandi.dao.repository.cs.BulletinRepository;
26
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
22
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
27
import com.spice.profitmandi.dao.repository.cs.RegionRepository;
23
import com.spice.profitmandi.dao.repository.cs.RegionRepository;
28
import com.spice.profitmandi.dao.repository.dtr.DocumentUrlRepository;
24
import com.spice.profitmandi.dao.repository.dtr.DocumentUrlRepository;
29
import com.spice.profitmandi.dao.repository.dtr.Mongo;
25
import com.spice.profitmandi.dao.repository.dtr.Mongo;
Line 356... Line 352...
356
		}
352
		}
357
		ep.setDefaultImageIndex(defaultIndex);
353
		ep.setDefaultImageIndex(defaultIndex);
358
		return ep;
354
		return ep;
359
	}
355
	}
360
 
356
 
-
 
357
	/**
-
 
358
	 * Band-aid for URL '+' decode issue: when the front-end sends `brand=Ai+` the servlet
-
 
359
	 * decodes the plus as a space and we receive "Ai " with a trailing space, missing the
-
 
360
	 * real "Ai+" brand. Restore trailing whitespace back to "+" so lookups match.
-
 
361
	 * Front-end should URL-encode with %2B (encodeURIComponent) — this is a temporary
-
 
362
	 * safety net until the mobile team ships that fix.
-
 
363
	 */
-
 
364
	private List<String> normalizeBrandNames(List<String> brands) {
-
 
365
		if (brands == null || brands.isEmpty()) return brands;
-
 
366
		return brands.stream()
-
 
367
				.map(b -> (b != null && b.endsWith(" ")) ? b.replaceAll("\\s+$", "") + "+" : b)
-
 
368
				.collect(Collectors.toList());
-
 
369
	}
-
 
370
 
361
	@GetMapping(value = "/entity")
371
	@GetMapping(value = "/entity")
362
	public String searchEntity(HttpServletRequest request, @RequestParam(defaultValue = "null") String query,
372
	public String searchEntity(HttpServletRequest request, @RequestParam(defaultValue = "null") String query,
363
			@RequestParam(defaultValue = "0") int categoryId, @RequestParam(defaultValue = "") List<String> brands,
373
			@RequestParam(defaultValue = "0") int categoryId, @RequestParam(defaultValue = "") List<String> brands,
364
			@RequestParam(defaultValue = "30") int limit, @RequestParam(defaultValue = "true") boolean activeOnly,
374
			@RequestParam(defaultValue = "30") int limit, @RequestParam(defaultValue = "true") boolean activeOnly,
365
			Model model) throws Exception {
375
			Model model) throws Exception {
-
 
376
		brands = normalizeBrandNames(brands);
366
		model.addAttribute("response1", solrService.getContent(query, categoryId > 0 ? Arrays.asList(categoryId) : null,
377
		model.addAttribute("response1", solrService.getContent(query, categoryId > 0 ? Arrays.asList(categoryId) : null,
367
				brands, limit, false));
378
				brands, limit, false));
368
		return "response";
379
		return "response";
369
	}
380
	}
370
 
381
 
Line 372... Line 383...
372
	public String focusedEntity(HttpServletRequest request, @RequestParam(defaultValue = "null") String query,
383
	public String focusedEntity(HttpServletRequest request, @RequestParam(defaultValue = "null") String query,
373
			@RequestParam(defaultValue = "0") int categoryId, @RequestParam(defaultValue = "") List<String> brands,
384
			@RequestParam(defaultValue = "0") int categoryId, @RequestParam(defaultValue = "") List<String> brands,
374
			@RequestParam(defaultValue = "30") int limit, @RequestParam(defaultValue = "true") boolean activeOnly,
385
			@RequestParam(defaultValue = "30") int limit, @RequestParam(defaultValue = "true") boolean activeOnly,
375
			Model model) throws Exception {
386
			Model model) throws Exception {
376
 
387
 
-
 
388
		brands = normalizeBrandNames(brands);
377
		List<Integer> catalogIds = focusedModelRepository.selectAll().stream().map(x -> x.getCatalogId())
389
		List<Integer> catalogIds = focusedModelRepository.selectAll().stream().map(x -> x.getCatalogId())
378
				.collect(Collectors.toList());
390
				.collect(Collectors.toList());
379
		JSONArray docA = solrService.getContentDocs(query, categoryId > 0 ? Arrays.asList(categoryId) : null, brands,
391
		JSONArray docA = solrService.getContentDocs(query, categoryId > 0 ? Arrays.asList(categoryId) : null, brands,
380
				limit, activeOnly);
392
				limit, activeOnly);
381
 
393
 
Line 398... Line 410...
398
	public String statusWiseCatalogs(HttpServletRequest request, @RequestParam(defaultValue = "null") String query,
410
	public String statusWiseCatalogs(HttpServletRequest request, @RequestParam(defaultValue = "null") String query,
399
									 @RequestParam(defaultValue = "0") int categoryId, @RequestParam(defaultValue = "") List<String> brands,
411
									 @RequestParam(defaultValue = "0") int categoryId, @RequestParam(defaultValue = "") List<String> brands,
400
									 @RequestParam(defaultValue = "30") int limit, @RequestParam(defaultValue = "true") boolean activeOnly,
412
									 @RequestParam(defaultValue = "30") int limit, @RequestParam(defaultValue = "true") boolean activeOnly,
401
									 Model model) throws Exception {
413
									 Model model) throws Exception {
402
 
414
 
-
 
415
		brands = normalizeBrandNames(brands);
403
		List<CatalogMovingEnum> catalogMovingEnums = Arrays.asList(CatalogMovingEnum.HID, CatalogMovingEnum.FASTMOVING, CatalogMovingEnum.RUNNING);
416
		List<CatalogMovingEnum> catalogMovingEnums = Arrays.asList(CatalogMovingEnum.HID, CatalogMovingEnum.FASTMOVING, CatalogMovingEnum.RUNNING);
404
 
417
 
405
		List<Integer> catalogIds = catalogRepository.selectAllStatusAndBrandWise(brands, catalogMovingEnums);
418
		List<Integer> catalogIds = catalogRepository.selectAllStatusAndBrandWise(brands, catalogMovingEnums);
406
 
419
 
407
		JSONArray docA = solrService.getContentDocs(query, categoryId > 0 ? Arrays.asList(categoryId) : null, brands,
420
		JSONArray docA = solrService.getContentDocs(query, categoryId > 0 ? Arrays.asList(categoryId) : null, brands,