| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.service.catalog;
|
1 |
package com.spice.profitmandi.service.catalog;
|
| 2 |
|
2 |
|
| 3 |
import java.util.List;
|
- |
|
| 4 |
import java.util.Map;
|
- |
|
| 5 |
import java.util.stream.Collectors;
|
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 6 |
|
- |
|
| 7 |
import com.spice.profitmandi.common.util.Utils;
|
4 |
import com.spice.profitmandi.common.util.Utils;
|
| 8 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 9 |
import org.springframework.stereotype.Component;
|
- |
|
| 10 |
|
- |
|
| 11 |
import com.spice.profitmandi.dao.entity.catalog.BrandCatalog;
|
5 |
import com.spice.profitmandi.dao.entity.catalog.BrandCatalog;
|
| 12 |
import com.spice.profitmandi.dao.entity.catalog.BrandCategory;
|
6 |
import com.spice.profitmandi.dao.entity.catalog.BrandCategory;
|
| 13 |
import com.spice.profitmandi.dao.repository.catalog.BrandCategoryRepository;
|
7 |
import com.spice.profitmandi.dao.repository.catalog.BrandCategoryRepository;
|
| 14 |
import com.spice.profitmandi.dao.repository.catalog.BrandsRepository;
|
8 |
import com.spice.profitmandi.dao.repository.catalog.BrandsRepository;
|
| 15 |
import com.spice.profitmandi.dao.repository.dtr.RetailerBlockBrandsRepository;
|
9 |
import com.spice.profitmandi.dao.repository.dtr.RetailerBlockBrandsRepository;
|
| - |
|
10 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
11 |
import org.springframework.stereotype.Component;
|
| - |
|
12 |
|
| - |
|
13 |
import java.util.List;
|
| - |
|
14 |
import java.util.Map;
|
| - |
|
15 |
import java.util.stream.Collectors;
|
| 16 |
|
16 |
|
| 17 |
@Component
|
17 |
@Component
|
| 18 |
public class BrandsServiceImpl implements BrandsService {
|
18 |
public class BrandsServiceImpl implements BrandsService {
|
| 19 |
|
19 |
|
| 20 |
@Autowired
|
20 |
@Autowired
|
| Line 25... |
Line 25... |
| 25 |
|
25 |
|
| 26 |
@Autowired
|
26 |
@Autowired
|
| 27 |
private RetailerBlockBrandsRepository retailerBlockBrandsRepository;
|
27 |
private RetailerBlockBrandsRepository retailerBlockBrandsRepository;
|
| 28 |
|
28 |
|
| 29 |
@Override
|
29 |
@Override
|
| 30 |
public List<BrandCatalog> getBrands(int fofoId, String email, int categoryId) {
|
30 |
public List<BrandCatalog> getBrands(int fofoId, String email, int categoryId) throws ProfitMandiBusinessException {
|
| 31 |
List<BrandCatalog> brandsDisplay = this.getBrandsToDisplay(categoryId);
|
31 |
List<BrandCatalog> brandsDisplay = this.getBrandsToDisplay(categoryId);
|
| 32 |
if (fofoId == Utils.SYSTEM_PARTNER_ID) {
|
32 |
if (fofoId == Utils.SYSTEM_PARTNER_ID) {
|
| 33 |
return brandsDisplay;
|
33 |
return brandsDisplay;
|
| 34 |
}
|
34 |
}
|
| 35 |
List<String> blockedBrands = retailerBlockBrandsRepository.selectAllByRetailer(fofoId).stream()
|
35 |
List<String> blockedBrands = retailerBlockBrandsRepository.selectAllByRetailer(fofoId).stream()
|
| Line 39... |
Line 39... |
| 39 |
|
39 |
|
| 40 |
return brandsDisplay;
|
40 |
return brandsDisplay;
|
| 41 |
}
|
41 |
}
|
| 42 |
|
42 |
|
| 43 |
@Override
|
43 |
@Override
|
| 44 |
public List<BrandCatalog> getBrandsToDisplay(int categoryId) {
|
44 |
public List<BrandCatalog> getBrandsToDisplay(int categoryId) throws ProfitMandiBusinessException {
|
| 45 |
List<BrandCategory> brandCategories = brandCategoryRepository.selectByCategoryId(categoryId).stream()
|
45 |
List<BrandCategory> brandCategories = brandCategoryRepository.selectByCategoryId(categoryId).stream()
|
| 46 |
.filter(x -> x.isActive()).collect(Collectors.toList());
|
46 |
.filter(x -> x.isActive()).collect(Collectors.toList());
|
| 47 |
|
47 |
|
| 48 |
Map<Integer, BrandCategory> brandCategoryMap = brandCategories.stream()
|
48 |
Map<Integer, BrandCategory> brandCategoryMap = brandCategories.stream()
|
| 49 |
.collect(Collectors.toMap(x -> x.getBrandId(), x -> x));
|
49 |
.collect(Collectors.toMap(x -> x.getBrandId(), x -> x));
|