Subversion Repositories SmartDukaan

Rev

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

Rev 33122 Rev 33127
Line 2... Line 2...
2
 
2
 
3
import java.util.List;
3
import java.util.List;
4
import java.util.Map;
4
import java.util.Map;
5
import java.util.stream.Collectors;
5
import java.util.stream.Collectors;
6
 
6
 
-
 
7
import com.spice.profitmandi.common.util.Utils;
7
import org.springframework.beans.factory.annotation.Autowired;
8
import org.springframework.beans.factory.annotation.Autowired;
8
import org.springframework.stereotype.Component;
9
import org.springframework.stereotype.Component;
9
 
10
 
10
import com.spice.profitmandi.dao.entity.catalog.BrandCatalog;
11
import com.spice.profitmandi.dao.entity.catalog.BrandCatalog;
11
import com.spice.profitmandi.dao.entity.catalog.BrandCategory;
12
import com.spice.profitmandi.dao.entity.catalog.BrandCategory;
Line 24... Line 25...
24
 
25
 
25
	@Autowired
26
	@Autowired
26
	private RetailerBlockBrandsRepository retailerBlockBrandsRepository;
27
	private RetailerBlockBrandsRepository retailerBlockBrandsRepository;
27
 
28
 
28
	@Override
29
	@Override
29
	public List<BrandCatalog> getBrands(int categoryId) {
30
	public List<BrandCatalog> getBrands(int fofoId, String email, int categoryId) {
30
		List<BrandCategory> brandCategories = brandCategoryRepository.selectByCategoryId(categoryId);
31
		List<BrandCatalog> brandsDisplay = this.getBrandsToDisplay(categoryId);
31
		List<Integer> brandIds = brandCategories.stream().map(x->x.getBrandId()).collect(Collectors.toList());
-
 
32
		Map<Integer, BrandCategory> brandCategoryMap = brandCategories.stream()
-
 
33
				.collect(Collectors.toMap(x -> x.getBrandId(), x -> x));
-
 
34
 
-
 
35
		List<BrandCatalog> brandCatalogList = brandCatalogRepository.selectByIds(brandIds);
-
 
36
		for (BrandCatalog brand : brandCatalogList) {
32
		if (fofoId == Utils.SYSTEM_PARTNER_ID) {
37
			brand.setBrandCategory(brandCategoryMap.get(brand.getId()));
33
			return brandsDisplay;
38
		}
34
		}
-
 
35
		List<String> blockedBrands = retailerBlockBrandsRepository.selectAllByRetailer(fofoId).stream()
-
 
36
				.map(x -> x.getBlockBrands()).collect(Collectors.toList());
-
 
37
		brandsDisplay = brandsDisplay.stream().filter(x -> !blockedBrands.contains(x.getName()))
-
 
38
				.collect(Collectors.toList());
-
 
39
 
39
		return brandCatalogList;
40
		return brandsDisplay;
40
	}
41
	}
41
 
42
 
42
	@Override
43
	@Override
43
	public List<BrandCatalog> getBrandsToDisplay(int categoryId) {
44
	public List<BrandCatalog> getBrandsToDisplay(int categoryId) {
44
		List<BrandCategory> brandCategories = brandCategoryRepository.selectByCategoryId(categoryId).stream()
45
		List<BrandCategory> brandCategories = brandCategoryRepository.selectByCategoryId(categoryId).stream()