Ejemplo n.º 1
0
 @Override
 public List<ProductCategoryDTO> getRecentlyUsedProductCategoryDTOList(Long shopId, Long userId) {
   List<ProductCategoryDTO> productCategoryDTOList = new ArrayList<ProductCategoryDTO>();
   if (shopId == null) return productCategoryDTOList;
   IRecentlyUsedDataService recentlyUsedDataService =
       ServiceManager.getService(IRecentlyUsedDataService.class);
   int maxSize = ConfigUtils.getRecentlyUsedProductCategoryNum();
   List<RecentlyUsedDataDTO> recentlyUsedDataDTOList =
       recentlyUsedDataService.getRecentlyUsedDataDTOList(
           shopId, userId, RecentlyUsedDataType.USED_PRODUCT_CATEGORY, maxSize);
   if (CollectionUtils.isNotEmpty(recentlyUsedDataDTOList)) {
     Set<Long> prouctCategoryIdSet = new HashSet<Long>();
     for (RecentlyUsedDataDTO recentlyUsedDataDTO : recentlyUsedDataDTOList) {
       prouctCategoryIdSet.add(recentlyUsedDataDTO.getDataId());
     }
     List<ProductCategoryDTO> productCategoryDTOs =
         getProductCategoryDTOByIds(prouctCategoryIdSet);
     fillProductCategoryDTOListInfo(productCategoryDTOs);
     Map<Long, ProductCategoryDTO> productCategoryDTOMap = new HashMap<Long, ProductCategoryDTO>();
     for (ProductCategoryDTO productCategoryDTO : productCategoryDTOs) {
       productCategoryDTOMap.put(productCategoryDTO.getId(), productCategoryDTO);
     }
     ProductCategoryDTO productCategoryDTO = null;
     for (RecentlyUsedDataDTO recentlyUsedDataDTO : recentlyUsedDataDTOList) {
       productCategoryDTO = productCategoryDTOMap.get(recentlyUsedDataDTO.getDataId());
       if (productCategoryDTO != null) {
         productCategoryDTOList.add(productCategoryDTO);
       }
     }
   }
   return productCategoryDTOList;
 }
Ejemplo n.º 2
0
 @Override
 public void saveOrUpdateRecentlyUsedProductCategory(
     Long shopId, Long userId, Long productCategoryId) {
   if (shopId == null || productCategoryId == null) return;
   IRecentlyUsedDataService recentlyUsedDataService =
       ServiceManager.getService(IRecentlyUsedDataService.class);
   recentlyUsedDataService.saveOrUpdateRecentlyUsedData(
       shopId, userId, RecentlyUsedDataType.USED_PRODUCT_CATEGORY, productCategoryId);
 }