|
@@ -15,9 +15,7 @@ import com.example.xiaoshiweixinback.domain.AssoProductFile;
|
|
|
import com.example.xiaoshiweixinback.domain.Product;
|
|
|
import com.example.xiaoshiweixinback.entity.dto.AssoPersonProductDTO;
|
|
|
import com.example.xiaoshiweixinback.entity.dto.GetProductDTO;
|
|
|
-import com.example.xiaoshiweixinback.entity.product.HotProductAddDTO;
|
|
|
-import com.example.xiaoshiweixinback.entity.product.ProductAddDTO;
|
|
|
-import com.example.xiaoshiweixinback.entity.product.ProductDTO;
|
|
|
+import com.example.xiaoshiweixinback.entity.product.*;
|
|
|
import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
|
|
|
import com.example.xiaoshiweixinback.entity.vo.ProductVO;
|
|
|
import com.example.xiaoshiweixinback.mapper.ProductMapper;
|
|
@@ -67,7 +65,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
|
List<Integer> ids = assoPersonCategoryService.getChoosedProductCategoryIds();
|
|
|
|
|
|
GetProductDTO getProductDTO = new GetProductDTO();
|
|
|
- BeanUtils.copyProperties(productDTO,getProductDTO);
|
|
|
+ BeanUtils.copyProperties(productDTO, getProductDTO);
|
|
|
getProductDTO.setName(name);
|
|
|
getProductDTO.setCurrent(current);
|
|
|
getProductDTO.setSize(size);
|
|
@@ -158,7 +156,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
|
assoPersonProductDTO.setConcernType(productAddDTO.getConcernType());
|
|
|
Integer flag = assoPersonProductService.addAsso(assoPersonProductDTO);
|
|
|
} else {
|
|
|
- product = this.updateProduct(productAddDTO,productAddDTO.getId());
|
|
|
+ product = this.updateProduct(productAddDTO, productAddDTO.getId());
|
|
|
}
|
|
|
assoProductFileService.addOrUpdateProductFile(product.getId(), productAddDTO.getFileGuids());
|
|
|
return product.getId();
|
|
@@ -176,7 +174,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Product updateProduct(Object productAddDTO,Integer id) {
|
|
|
+ public Product updateProduct(Object productAddDTO, Integer id) {
|
|
|
Product product = new Product();
|
|
|
Product orgProduct = this.getById(id);
|
|
|
BeanUtils.copyProperties(productAddDTO, product);
|
|
@@ -222,7 +220,6 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Integer addOrUpdateHotProduct(HotProductAddDTO hotProductAddDTO) {
|
|
|
Product product = new Product();
|
|
@@ -230,14 +227,13 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
|
assoPersonProductService.checkAdmin();
|
|
|
product = this.addProduct(hotProductAddDTO);
|
|
|
} else {
|
|
|
- product = this.updateProduct(hotProductAddDTO,hotProductAddDTO.getId());
|
|
|
+ product = this.updateProduct(hotProductAddDTO, hotProductAddDTO.getId());
|
|
|
}
|
|
|
assoProductFileService.addOrUpdateProductFile(product.getId(), hotProductAddDTO.getFileGuids());
|
|
|
return product.getId();
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 根据id查询爆款专利
|
|
|
*
|
|
@@ -245,13 +241,13 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
|
* @return
|
|
|
*/
|
|
|
public ProductVO queryHotProductDetail(Integer id) {
|
|
|
- ProductVO productVO =new ProductVO();
|
|
|
- Product product =this.getById(id);
|
|
|
- if(product ==null){
|
|
|
- return productVO;
|
|
|
+ ProductVO productVO = new ProductVO();
|
|
|
+ Product product = this.getById(id);
|
|
|
+ if (product == null) {
|
|
|
+ return productVO;
|
|
|
}
|
|
|
- BeanUtils.copyProperties(product,productVO);
|
|
|
- List<ProductVO> productVOS =new ArrayList<>();
|
|
|
+ BeanUtils.copyProperties(product, productVO);
|
|
|
+ List<ProductVO> productVOS = new ArrayList<>();
|
|
|
productVOS.add(productVO);
|
|
|
this.loadProduct(productVOS);
|
|
|
return productVO;
|
|
@@ -259,22 +255,41 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 根据id查询爆款专利
|
|
|
+ * 上下架产品
|
|
|
*
|
|
|
- * @param id
|
|
|
+ * @param updateProductShowDTO
|
|
|
* @return
|
|
|
*/
|
|
|
- public ProductVO updateProductIfShow(Integer id) {
|
|
|
- ProductVO productVO =new ProductVO();
|
|
|
- Product product =this.getById(id);
|
|
|
- if(product ==null){
|
|
|
- return productVO;
|
|
|
+ public List<Integer> updateProductIfShow(UpdateProductShowDTO updateProductShowDTO) {
|
|
|
+ List<Integer> ids = updateProductShowDTO.getIds();
|
|
|
+ Boolean ifShow = updateProductShowDTO.getIfShow();
|
|
|
+ if (ids == null || ids.size() == 0) {
|
|
|
+ return ids;
|
|
|
}
|
|
|
- BeanUtils.copyProperties(product,productVO);
|
|
|
- List<ProductVO> productVOS =new ArrayList<>();
|
|
|
- productVOS.add(productVO);
|
|
|
- this.loadProduct(productVOS);
|
|
|
- return productVO;
|
|
|
+ LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(Product::getId, ids);
|
|
|
+ List<Product> products = this.list(queryWrapper);
|
|
|
+ if (products.size() != 0) {
|
|
|
+ products.forEach(item -> item.setIfShow(ifShow));
|
|
|
+ this.updateBatchById(products);
|
|
|
+ }
|
|
|
+ return ids;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除产品
|
|
|
+ *
|
|
|
+ * @param hotProductDeleteDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<Integer> deleteHotProduct(HotProductDeleteDTO hotProductDeleteDTO) {
|
|
|
+ List<Integer> ids = hotProductDeleteDTO.getIds();
|
|
|
+ if (ids == null || ids.size() == 0) {
|
|
|
+ return ids;
|
|
|
+ }
|
|
|
+ this.removeBatchByIds(ids);
|
|
|
+ return ids;
|
|
|
}
|
|
|
}
|
|
|
|