Пример #1
0
  public List<ProductCategoryDTO> getProductCategoryByNameOrId(
      Long productCategoryId, String name, Long shopId, Pager pager) {
    ProductWriter productWriter = productDaoManager.getWriter();
    List<ProductCategory> productCategoryList = null;

    if (productCategoryId == null && StringUtil.isEmpty(name)) {
      productCategoryList = productWriter.getProductCategoryFuzzyName(shopId, null, pager);
      List<ProductCategoryDTO> productCategoryDTOList = new ArrayList<ProductCategoryDTO>();
      if (CollectionUtils.isNotEmpty(productCategoryList)) {
        for (ProductCategory productCategory : productCategoryList) {
          productCategoryDTOList.add(productCategory.toDTO());
        }
      }
      return productCategoryDTOList;
    }

    if (StringUtil.isNotEmpty(name)) {
      productCategoryList = productWriter.getProductCategoryFuzzyName(shopId, name, pager);
      List<ProductCategoryDTO> productCategoryDTOList = new ArrayList<ProductCategoryDTO>();
      if (CollectionUtils.isNotEmpty(productCategoryList)) {
        for (ProductCategory productCategory : productCategoryList) {
          productCategoryDTOList.add(productCategory.toDTO());
        }
      }
      return productCategoryDTOList;
    }

    if (productCategoryId != null) {
      List<ProductCategoryDTO> productCategoryDTOList =
          this.getProductCategoryDTOByParentId(shopId, productCategoryId, pager);
      return productCategoryDTOList;
    }

    return null;
  }
Пример #2
0
 @Override
 public List<ProductCategoryDTO> getProductCategoryDTOByIds(Set<Long> ids) {
   List<ProductCategoryDTO> productCategoryDTOList = new ArrayList<ProductCategoryDTO>();
   if (CollectionUtils.isEmpty(ids)) return productCategoryDTOList;
   ProductWriter productWriter = productDaoManager.getWriter();
   List<ProductCategory> entityList = productWriter.getProductCategoryByIds(ids);
   for (ProductCategory entity : entityList) {
     productCategoryDTOList.add(entity.toDTO());
   }
   return productCategoryDTOList;
 }
Пример #3
0
 public List<ProductCategoryDTO> getProductCategoryDTOByShopId(Long shopId) {
   List<ProductCategoryDTO> productCategoryDTOList = new ArrayList<ProductCategoryDTO>();
   ProductWriter productWriter = productDaoManager.getWriter();
   List<ProductCategory> productCategoryList = productWriter.getProductCategoryByShopId(shopId);
   if (CollectionUtils.isNotEmpty(productCategoryList)) {
     for (ProductCategory productCategory : productCategoryList) {
       productCategoryDTOList.add(productCategory.toDTO());
     }
   }
   return productCategoryDTOList;
 }
Пример #4
0
  public List<ProductCategoryDTO> getThirdProductCategoryDTOByName(Long shopId, String name) {
    ProductWriter productWriter = productDaoManager.getWriter();
    List<ProductCategory> productCategoryList =
        productWriter.getThirdProductCategoryByName(shopId, name);
    List<ProductCategoryDTO> productCategoryDTOList = new ArrayList<ProductCategoryDTO>();

    if (CollectionUtils.isEmpty(productCategoryList)) {
      return productCategoryDTOList;
    }
    for (ProductCategory productCategory : productCategoryList) {
      ProductCategoryDTO productCategoryDTO = productCategory.toDTO();

      ProductCategoryDTO secondProductCategory =
          ProductCategoryCache.getProductCategoryDTOById(productCategoryDTO.getParentId());
      if (secondProductCategory != null) {
        productCategoryDTO.setSecondCategoryName(secondProductCategory.getName());
        productCategoryDTO.setSecondCategoryId(secondProductCategory.getId());
      }
      productCategoryDTOList.add(productCategoryDTO);
    }
    return productCategoryDTOList;
  }
Пример #5
0
 public ProductCategoryDTO saveOrUpdateProductCategoryDTO(ProductCategoryDTO productCategoryDTO) {
   if (productCategoryDTO == null) {
     return productCategoryDTO;
   }
   ProductWriter writer = productDaoManager.getWriter();
   Object status = writer.begin();
   ProductCategory productCategory = null;
   try {
     if (productCategoryDTO.getId() == null) {
       productCategory = new ProductCategory(productCategoryDTO);
       writer.save(productCategory);
     } else {
       productCategory = writer.getById(ProductCategory.class, productCategoryDTO.getId());
       productCategory = productCategory.fromDTO(productCategoryDTO, false);
       writer.saveOrUpdate(productCategory);
     }
     writer.commit(status);
     productCategoryDTO = productCategory.toDTO();
   } finally {
     writer.rollback(status);
   }
   return productCategoryDTO;
 }