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