Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/master' into test

lwhhszx 1 anno fa
parent
commit
ca062acf2c
21 ha cambiato i file con 703 aggiunte e 54 eliminazioni
  1. 14 0
      src/main/java/com/example/xiaoshiweixinback/business/exception/ExceptionEnum.java
  2. 67 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/CollectionKit.java
  3. 45 2
      src/main/java/com/example/xiaoshiweixinback/controller/ProductCategoryController.java
  4. 30 0
      src/main/java/com/example/xiaoshiweixinback/controller/ProductController.java
  5. 10 6
      src/main/java/com/example/xiaoshiweixinback/entity/dto/GetProductDTO.java
  6. 5 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/ProductCategoryDTO.java
  7. 28 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/productCategory/AddCategoryDTO.java
  8. 9 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/productCategory/CategoryIdDTO.java
  9. 12 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/productCategory/CategoryIdsDTO.java
  10. 27 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/productCategory/EditCategoryDTO.java
  11. 55 0
      src/main/java/com/example/xiaoshiweixinback/entity/product/HotProductAddDTO.java
  12. 4 0
      src/main/java/com/example/xiaoshiweixinback/entity/product/ProductDTO.java
  13. 12 0
      src/main/java/com/example/xiaoshiweixinback/entity/product/UpdateProductShowDTO.java
  14. 10 23
      src/main/java/com/example/xiaoshiweixinback/entity/vo/ProductCategoryVO.java
  15. 15 0
      src/main/java/com/example/xiaoshiweixinback/entity/vo/productCategory/SelectCategoryLevelVO.java
  16. 35 0
      src/main/java/com/example/xiaoshiweixinback/entity/vo/productCategory/SelectCategoryVO.java
  17. 6 5
      src/main/java/com/example/xiaoshiweixinback/service/AssoProductFileService.java
  18. 225 6
      src/main/java/com/example/xiaoshiweixinback/service/ProductCategoryService.java
  19. 68 9
      src/main/java/com/example/xiaoshiweixinback/service/ProductService.java
  20. 6 3
      src/main/java/com/example/xiaoshiweixinback/service/TicketService.java
  21. 20 0
      src/main/resources/mapper/ProductMapper.xml

+ 14 - 0
src/main/java/com/example/xiaoshiweixinback/business/exception/ExceptionEnum.java

@@ -21,6 +21,20 @@ public enum ExceptionEnum {
     THE_PARAMETER_EXCEPTION("20001", "参数异常,请传入数据"),
     THE_GET_INFORMATION_TOKEN_INVALID("20002", "获取用信息token失效"),
     THE_FAIL_TO_DELETE("20003", "删除失败"),
+
+    //业务异常
+    THE_PRODUCT_CATEGORY_NAME_IS_EXIST("608", "产品类别名称已存在"),
+
+
+
+
+
+
+
+
+
+
+
     SYSTEM_ERROR("999999", "系统异常");
 
     private String code;// 异常代码

+ 67 - 0
src/main/java/com/example/xiaoshiweixinback/business/utils/CollectionKit.java

@@ -5,6 +5,7 @@ import cn.hutool.core.collection.BoundedPriorityQueue;
 import java.lang.reflect.Array;
 import java.util.*;
 import java.util.Map.Entry;
+import java.util.stream.Collectors;
 
 /**
  * 集合相关工具类,包括数组
@@ -797,4 +798,70 @@ public class CollectionKit {
 		}
 		return obj.toString();
 	}
+
+	/**
+	 * 交集
+	 * @param list1
+	 * @param list2
+	 * @return
+	 */
+	public List<String> intersection(List<String> list1, List<String> list2) {
+		return list1.stream().filter(item -> list2.contains(item)).collect(Collectors.toList());
+	}
+
+	/**
+	 * 去重交集
+	 * @param list1
+	 * @param list2
+	 * @return
+	 */
+	public List<String> intersectionDistinct(List<String> list1, List<String> list2) {
+		return list1.stream().filter(item -> list2.contains(item)).distinct().collect(Collectors.toList());
+	}
+
+	/**
+	 * 差集 (list1 - list2)
+	 * @param list1
+	 * @param list2
+	 * @return
+	 */
+	public List<String> reduce1(List<String> list1, List<String> list2) {
+		return list1.stream().filter(item -> !list2.contains(item)).collect(Collectors.toList());
+	}
+
+	/**
+	 * 差集 (list2 - list1)
+	 * @param list1
+	 * @param list2
+	 * @return
+	 */
+	public List<String> reduce2(List<String> list1, List<String> list2) {
+		return list2.stream().filter(item -> !list1.contains(item)).collect(Collectors.toList());
+	}
+
+	/**
+	 * 并集 listAll
+	 * @param list1
+	 * @param list2
+	 * @return
+	 */
+	public List<String> listAll(List<String> list1, List<String> list2) {
+		List<String> listAll = new ArrayList<>();
+		listAll.addAll(list1);
+		listAll.addAll(list2);
+		return listAll;
+	}
+
+	/**
+	 * 去重并集
+	 * @param list1
+	 * @param list2
+	 * @return
+	 */
+	public List<String> listAllDistinct(List<String> list1, List<String> list2) {
+		List<String> listAll = new ArrayList<>();
+		listAll.addAll(list1);
+		listAll.addAll(list2);
+		return listAll.stream().distinct().collect(Collectors.toList());
+	}
 }

+ 45 - 2
src/main/java/com/example/xiaoshiweixinback/controller/ProductCategoryController.java

@@ -8,9 +8,15 @@ import com.example.xiaoshiweixinback.checkLogin.checkLogin;
 import com.example.xiaoshiweixinback.domain.AssoCategoryFile;
 import com.example.xiaoshiweixinback.entity.dto.ConcernCategoryDTO;
 import com.example.xiaoshiweixinback.entity.dto.ProductCategoryDTO;
+import com.example.xiaoshiweixinback.entity.dto.productCategory.AddCategoryDTO;
+import com.example.xiaoshiweixinback.entity.dto.productCategory.CategoryIdDTO;
+import com.example.xiaoshiweixinback.entity.dto.productCategory.CategoryIdsDTO;
+import com.example.xiaoshiweixinback.entity.dto.productCategory.EditCategoryDTO;
+import com.example.xiaoshiweixinback.entity.vo.productCategory.SelectCategoryVO;
 import com.example.xiaoshiweixinback.service.AssoPersonCategoryService;
 import com.example.xiaoshiweixinback.service.ProductCategoryService;
 import io.swagger.v3.oas.annotations.Operation;
+import jakarta.validation.Valid;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 
@@ -30,13 +36,51 @@ public class ProductCategoryController {
     private final ProductCategoryService productCategoryService;
     private final AssoPersonCategoryService assoPersonCategoryService;
 
-    @Operation(summary = "查询产品类别")
+    @Operation(summary = "查询产品类别列表")
     @PostMapping("/queryCategory")
     public Response queryProductCategory(@RequestBody ProductCategoryDTO productCategoryDTO) {
         Records records = productCategoryService.queryProductCategory(productCategoryDTO);
         return Response.success(records);
     }
 
+    @Operation(summary = "添加产品类别")
+    @PostMapping("/addCategory")
+    public Response addCategory(@RequestBody @Valid AddCategoryDTO categoryDTO) {
+        Integer categoryId = null;
+        try {
+            categoryId = productCategoryService.addCategory(categoryDTO);
+        } catch (Exception e) {
+            return Response.error(e.getMessage());
+        }
+        return Response.success(categoryId);
+    }
+
+    @Operation(summary = "编辑产品类别")
+    @PostMapping("/editCategory")
+    public Response editCategory(@RequestBody EditCategoryDTO categoryDTO) {
+        Integer categoryId = null;
+        try {
+            categoryId = productCategoryService.editCategory(categoryDTO);
+        } catch (Exception e) {
+            return Response.error(e.getMessage());
+        }
+        return Response.success(categoryId);
+    }
+
+    @Operation(summary = "查询产品类别详情")
+    @PostMapping("/selectCategoryDetail")
+    public Response selectCategoryDetail(@RequestBody CategoryIdDTO categoryIdDTO) {
+        SelectCategoryVO categoryVO = productCategoryService.selectCategoryDetail(categoryIdDTO);
+        return Response.success(categoryVO);
+    }
+
+    @Operation(summary = "删除产品类别")
+    @PostMapping("/deleteCategory")
+    public Response deleteCategory(@RequestBody CategoryIdsDTO categoryIdsDTO) {
+        boolean b = productCategoryService.deleteCategory(categoryIdsDTO);
+        return Response.success(b);
+    }
+
     @Operation(summary = "查询关注的产品类别")
     @PostMapping("/queryConcernedCategory")
     public Response queryConcernedCategory(@RequestBody ProductCategoryDTO productCategoryDTO) {
@@ -45,7 +89,6 @@ public class ProductCategoryController {
         return Response.success(records);
     }
 
-
     @checkLogin
     @Operation(summary = "关注产品类别")
     @PostMapping("/concernCategory")

+ 30 - 0
src/main/java/com/example/xiaoshiweixinback/controller/ProductController.java

@@ -8,8 +8,10 @@ import com.example.xiaoshiweixinback.business.exception.BusinessException;
 import com.example.xiaoshiweixinback.checkLogin.checkLogin;
 import com.example.xiaoshiweixinback.domain.AssoPersonProduct;
 import com.example.xiaoshiweixinback.entity.dto.AssoPersonProductDTO;
+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.vo.ProductVO;
 import com.example.xiaoshiweixinback.service.AssoPersonProductService;
 import com.example.xiaoshiweixinback.service.ProductService;
 import io.swagger.v3.oas.annotations.Operation;
@@ -87,4 +89,32 @@ public class ProductController {
     }
 
 
+    @checkLogin
+    @Operation(summary = "添加或更新爆款产品")
+    @PostMapping("/addOrUpdateHotProduct")
+    public Response addOrUpdateHotProduct(@RequestBody HotProductAddDTO hotProductAddDTO) {
+        Integer id = productService.addOrUpdateHotProduct(hotProductAddDTO);
+        return Response.success(id);
+    }
+
+    @checkLogin
+    @Operation(summary = "查看单个产品详情")
+    @PostMapping("/queryHotProductDetail")
+    public Response queryHotProductDetail(Integer id) {
+        ProductVO productVO = productService.queryHotProductDetail(id);
+        Records records =new Records();
+        records.setData(productVO);
+        return Response.success(records);
+    }
+
+
+    @checkLogin
+    @Operation(summary = "查看单个产品详情")
+    @PostMapping("/updateProductIfShow")
+    public Response updateProductIfShow(Integer id) {
+        ProductVO productVO = productService.updateProductIfShow(id);
+        Records records =new Records();
+        records.setData(productVO);
+        return Response.success(records);
+    }
 }

+ 10 - 6
src/main/java/com/example/xiaoshiweixinback/entity/dto/GetProductDTO.java

@@ -6,10 +6,14 @@ import java.util.List;
 
 @Data
 public class GetProductDTO {
-private List<Integer> categoryIds;
-private String name;
-private Long size;
-private Long current;
-private String personUuid;
-private List<Integer> concernTypes;
+    private List<Integer> categoryIds;
+    private String name;
+    private Long size;
+    private Long current;
+    private String personUuid;
+    private List<Integer> concernTypes;
+    private Boolean ifShow;
+    List<Integer> productCategoryIds;
+    private String sourceFrom;
+    private String bestSellingBrand;
 }

+ 5 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/ProductCategoryDTO.java

@@ -4,9 +4,14 @@ import lombok.Data;
 
 @Data
 public class ProductCategoryDTO {
+
     private String name;
+
     private Long current;
+
     private Long size;
+
     private Integer parentId;
+
     private Boolean ifConcern;
 }

+ 28 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/productCategory/AddCategoryDTO.java

@@ -0,0 +1,28 @@
+package com.example.xiaoshiweixinback.entity.dto.productCategory;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class AddCategoryDTO {
+
+    //类别描述
+    @NotBlank
+    private String description;
+
+    //产品类别名称
+    @NotBlank
+    private String name;
+
+    //上级产品类别
+    private Integer parentId;
+
+    //关键词/检索条件
+    @NotBlank
+    private String searchCondition;
+
+    //图s
+    private List<String> fileGuids;
+}

+ 9 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/productCategory/CategoryIdDTO.java

@@ -0,0 +1,9 @@
+package com.example.xiaoshiweixinback.entity.dto.productCategory;
+
+import lombok.Data;
+
+@Data
+public class CategoryIdDTO {
+
+    private Integer id;
+}

+ 12 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/productCategory/CategoryIdsDTO.java

@@ -0,0 +1,12 @@
+package com.example.xiaoshiweixinback.entity.dto.productCategory;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class CategoryIdsDTO {
+
+    private List<Integer> ids;
+
+}

+ 27 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/productCategory/EditCategoryDTO.java

@@ -0,0 +1,27 @@
+package com.example.xiaoshiweixinback.entity.dto.productCategory;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class EditCategoryDTO {
+
+    private Integer id;
+
+    //类别描述
+    private String description;
+
+    //产品类别名称
+    private String name;
+
+    //上级产品类别
+    private Integer parentId;
+
+    //关键词/检索条件
+    private String searchCondition;
+
+    //图s
+    private List<String> fileGuids;
+}

+ 55 - 0
src/main/java/com/example/xiaoshiweixinback/entity/product/HotProductAddDTO.java

@@ -0,0 +1,55 @@
+package com.example.xiaoshiweixinback.entity.product;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class HotProductAddDTO {
+
+    /**
+     * ID
+     */
+    private Integer id;
+
+    /**
+     *
+     */
+    private String name;
+
+    /**
+     *
+     */
+    private String description;
+
+    /**
+     * 检索条件
+     */
+    private String searchCondition;
+
+    /**
+     * 来源
+     */
+    private String sourceFrom;
+
+    /**
+     * 售卖平台
+     */
+    private String sellPlatform;
+
+    /**
+     * 平台链接
+     */
+    private String platformLink;
+    /**
+     * 价格
+     */
+    private  Double price;
+    /**
+     * 品牌
+     */
+    private String bestSellingBrand;
+    private List<String> fileGuids;
+    private Boolean ifShow;
+    private Integer productCategoryId;
+}

+ 4 - 0
src/main/java/com/example/xiaoshiweixinback/entity/product/ProductDTO.java

@@ -10,4 +10,8 @@ public class ProductDTO {
     private Long current;
     private Long size;
     private List<Integer> concernTypes;
+    private  Boolean ifShow;
+   List<Integer> productCategoryIds;
+    private String sourceFrom;
+    private  String bestSellingBrand;
 }

+ 12 - 0
src/main/java/com/example/xiaoshiweixinback/entity/product/UpdateProductShowDTO.java

@@ -0,0 +1,12 @@
+package com.example.xiaoshiweixinback.entity.product;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class UpdateProductShowDTO {
+    private List<Integer> ids;
+    private Boolean ifShow;
+
+}

+ 10 - 23
src/main/java/com/example/xiaoshiweixinback/entity/vo/ProductCategoryVO.java

@@ -3,6 +3,7 @@ package com.example.xiaoshiweixinback.entity.vo;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.example.xiaoshiweixinback.business.common.base.SystemFile;
+import com.example.xiaoshiweixinback.entity.vo.productCategory.SelectCategoryLevelVO;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import org.joda.time.DateTime;
@@ -13,44 +14,30 @@ import java.util.List;
 @Data
 public class ProductCategoryVO {
 
-    /**
-     * ID
-     */
-    @TableId(type = IdType.AUTO)
     private Integer id;
 
-    /**
-     *
-     */
     private String description;
 
-    /**
-     *
-     */
     private String name;
 
-
-    /**
-     * 检索条件
-     */
     private String searchCondition;
 
-    /**
-     *
-     */
     private String path;
 
+    private Integer level;  //层级
 
-    /**
-     *
-     */
     private String createName;
 
-    /**
-     *
-     */
     private DateTime createTime;
+
     private String createId;
+
+    private List<String> fileGuids; //图s
+
+    private SelectCategoryLevelVO categoryLevelVo;  //父类类别信息
+
+    private Boolean ifChild = false;
+
     @Schema(description = "文件信息")
     private List<SystemFile> systemFileList;
 }

+ 15 - 0
src/main/java/com/example/xiaoshiweixinback/entity/vo/productCategory/SelectCategoryLevelVO.java

@@ -0,0 +1,15 @@
+package com.example.xiaoshiweixinback.entity.vo.productCategory;
+
+import lombok.Data;
+
+@Data
+public class SelectCategoryLevelVO {
+
+    private Integer id;
+
+    private String name;   //类别名称
+
+    private Integer level;  //层级
+
+    private String path;   //路径
+}

+ 35 - 0
src/main/java/com/example/xiaoshiweixinback/entity/vo/productCategory/SelectCategoryVO.java

@@ -0,0 +1,35 @@
+package com.example.xiaoshiweixinback.entity.vo.productCategory;
+
+import lombok.Data;
+import org.joda.time.DateTime;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class SelectCategoryVO {
+
+    private Integer id;
+
+    private String description;   //描述
+
+    private String name;   //类别名称
+
+    private Integer parentId;  //父级类别id
+
+    private String searchCondition;   //关键词/检索条件
+
+    private String path;   //路径
+
+    private Integer level;  //层级
+
+    private String createId;  //创建者id
+
+    private DateTime createTime;  //创建时间
+
+    private List<String> fileGuids; //图s
+
+    private SelectCategoryLevelVO categoryLevelVo;  //父类类别信息
+
+    private Boolean ifChild = false;  //是否有子集
+}

+ 6 - 5
src/main/java/com/example/xiaoshiweixinback/service/AssoProductFileService.java

@@ -2,10 +2,13 @@ package com.example.xiaoshiweixinback.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.xiaoshiweixinback.business.utils.CacheUtil;
+import com.example.xiaoshiweixinback.business.utils.LoginUtils;
 import com.example.xiaoshiweixinback.domain.AssoPersonCategory;
 import com.example.xiaoshiweixinback.domain.AssoProductFile;
 import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
 import com.example.xiaoshiweixinback.mapper.AssoProductFileMapper;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -20,16 +23,14 @@ import java.util.stream.Collectors;
  */
 @Service
 public class AssoProductFileService extends ServiceImpl<AssoProductFileMapper, AssoProductFile> {
+
+   @Autowired
+    private CacheUtil cacheUtil;
     @Transactional
     public void addOrUpdateProductFile(Integer productId, List<String> guids) {
         if(guids==null){
             guids=new ArrayList<>();
         }
-        //PersonnelVO personnelVO =cacheUtil.getLoginUser(loginUtils.getId());
-        PersonnelVO personnelVO = new PersonnelVO();
-        personnelVO.setId(1);
-        personnelVO.setUuid("123");
-
         LambdaQueryWrapper<AssoProductFile> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(AssoProductFile::getProductId, productId);
         List<AssoProductFile> assoProductFiles = this.list(queryWrapper);

+ 225 - 6
src/main/java/com/example/xiaoshiweixinback/service/ProductCategoryService.java

@@ -7,19 +7,34 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.example.xiaoshiweixinback.business.common.base.Records;
 import com.example.xiaoshiweixinback.business.common.base.SystemFile;
+import com.example.xiaoshiweixinback.business.exception.BusinessException;
+import com.example.xiaoshiweixinback.business.exception.ExceptionEnum;
+import com.example.xiaoshiweixinback.business.utils.BeanUtil;
 import com.example.xiaoshiweixinback.business.utils.CacheUtil;
 import com.example.xiaoshiweixinback.business.utils.LoginUtils;
 import com.example.xiaoshiweixinback.domain.*;
 import com.example.xiaoshiweixinback.entity.dto.ProductCategoryDTO;
+import com.example.xiaoshiweixinback.entity.dto.productCategory.AddCategoryDTO;
+import com.example.xiaoshiweixinback.entity.dto.productCategory.CategoryIdDTO;
+import com.example.xiaoshiweixinback.entity.dto.productCategory.CategoryIdsDTO;
+import com.example.xiaoshiweixinback.entity.dto.productCategory.EditCategoryDTO;
 import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
 import com.example.xiaoshiweixinback.entity.vo.ProductCategoryVO;
 import com.example.xiaoshiweixinback.entity.vo.ProductVO;
+import com.example.xiaoshiweixinback.entity.vo.productCategory.SelectCategoryLevelVO;
+import com.example.xiaoshiweixinback.entity.vo.productCategory.SelectCategoryVO;
+import com.example.xiaoshiweixinback.mapper.AssoCategoryFileMapper;
 import com.example.xiaoshiweixinback.mapper.ProductCategoryMapper;
 import com.example.xiaoshiweixinback.service.common.FileManagerService;
 import io.swagger.v3.oas.models.security.SecurityScheme;
 import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -37,6 +52,9 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
     private final AssoCategoryFileService assoCategoryFileService;
     private final PersonService personService;
     private final FileManagerService fileManagerService;
+    private final ProductCategoryMapper productCategoryMapper;
+    @Autowired
+    private AssoCategoryFileMapper assoCategoryFileMapper;
 
     /**
      * 查询产品类别
@@ -46,33 +64,35 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
      */
     public Records queryProductCategory(ProductCategoryDTO productCategoryDTO) {
         Boolean ifConcern = productCategoryDTO.getIfConcern();
-        Records records = new Records();
         Long size = productCategoryDTO.getSize();
         Long current = productCategoryDTO.getCurrent();
         String name = productCategoryDTO.getName();
         Integer parentId = productCategoryDTO.getParentId();
+        Records records = new Records();
         records.setCurrent(current);
         records.setSize(size);
 
 
         LambdaQueryWrapper<ProductCategory> queryWrapper = new LambdaQueryWrapper<>();
-        if (name != null && !name.trim().equals("")) {
+        if (StringUtils.isNotEmpty(name)) {
             queryWrapper.like(ProductCategory::getName, name);
         }
+
         if (parentId == null) {
             queryWrapper.isNull(ProductCategory::getParentId);
         } else {
             queryWrapper.eq(ProductCategory::getParentId, parentId);
         }
+
         if (ifConcern != null && ifConcern) {
             //获取关注的
             List<Integer> ids = assoPersonCategoryService.getChoosedProductCategoryIds();
-            if(ids.size()==0){
+            if (ids.size() == 0) {
                 ids.add(0);
             }
             queryWrapper.in(ProductCategory::getId, ids);
-
         }
+
         List<ProductCategory> productCategoryList = new ArrayList<>();
         if (size != null && current != null) {
             IPage<ProductCategory> productCategoryIPage = this.page(new Page<>(current, size), queryWrapper);
@@ -104,7 +124,6 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
             queryWrapper.in(AssoCategoryFile::getProductCategoryId, ids);
             assoCategoryFiles = assoCategoryFileService.list(queryWrapper);
             guids = assoCategoryFiles.stream().map(AssoCategoryFile::getFileGuid).collect(Collectors.toList());
-
         }
 
         //查询创建人名称
@@ -130,7 +149,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
         for (ProductCategory productCategory : productCategorys) {
             ProductCategoryVO productCategoryVO = new ProductCategoryVO();
             BeanUtils.copyProperties(productCategory, productCategoryVO);
-            Person personnel = personList.stream().filter(item -> item.getUuid().toString().equals(productCategoryVO.getCreateId())).findFirst().orElse(null);
+            Person personnel = personList.stream().filter(item -> item.getUuid().equals(productCategoryVO.getCreateId())).findFirst().orElse(null);
             if (personnel != null) {
                 productCategoryVO.setCreateName(personnel.getName());
             }
@@ -145,11 +164,211 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
                     }
                 }
             }
+            //装载父类产品类别
+            if (productCategory.getParentId() != null) {
+                ProductCategory parentCategory = this.getById(productCategory.getParentId());
+                SelectCategoryLevelVO levelVO = new SelectCategoryLevelVO();
+                levelVO.setId(parentCategory.getId());
+                levelVO.setName(parentCategory.getName());
+                levelVO.setPath(parentCategory.getPath());
+                levelVO.setLevel(parentCategory.getLevel());
+                productCategoryVO.setCategoryLevelVo(levelVO);
+            }
+            //装载产品图
+            productCategoryVO.setFileGuids(guids);
+            //判断是否有子集
+            Long count = productCategoryMapper.selectCount(new LambdaQueryWrapper<ProductCategory>()
+                    .eq(ProductCategory::getParentId, productCategory.getId()));
+            if (count > 0) {
+                productCategoryVO.setIfChild(true);
+            }
             productCategoryVOS.add(productCategoryVO);
         }
         return productCategoryVOS;
     }
 
+    /**
+     * 添加产品类别
+     *
+     * @param categoryDTO
+     * @return
+     */
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
+    public Integer addCategory(AddCategoryDTO categoryDTO) {
+        Long count = productCategoryMapper.selectCount(new LambdaQueryWrapper<ProductCategory>()
+                .eq(ProductCategory::getName, categoryDTO.getName()));
+        if (count > 0) {
+            throw new BusinessException(ExceptionEnum.THE_PRODUCT_CATEGORY_NAME_IS_EXIST);
+        }
+        ProductCategory category = new ProductCategory();
+        category.setName(categoryDTO.getName());
+        category.setDescription(categoryDTO.getDescription());
+        category.setSearchCondition(categoryDTO.getSearchCondition());
+        if (categoryDTO.getParentId() != null) {
+            category.setParentId(categoryDTO.getParentId());
+            ProductCategory parentCategory = this.getById(categoryDTO.getParentId());
+            Integer level = parentCategory.getLevel();
+            category.setLevel(level + 1);
+            category.setPath(this.getPath(level));
+        } else {
+            category.setLevel(1);
+        }
+        category.insert();
+        Integer categoryId = category.getId();
+        if (!CollectionUtils.isEmpty(categoryDTO.getFileGuids())) {
+            for (String fileGuid : categoryDTO.getFileGuids()) {
+                AssoCategoryFile categoryFile = new AssoCategoryFile();
+                categoryFile.setProductCategoryId(categoryId);
+                categoryFile.setFileGuid(fileGuid);
+                categoryFile.insert();
+            }
+        }
+        return categoryId;
+    }
+
+    /**
+     * 编辑产品类别
+     *
+     * @param categoryDTO
+     * @return
+     */
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
+    public Integer editCategory(EditCategoryDTO categoryDTO) {
+        Long count = productCategoryMapper.selectCount(new LambdaQueryWrapper<ProductCategory>()
+                .eq(ProductCategory::getName, categoryDTO.getName()));
+        if (count > 0) {
+            throw new BusinessException(ExceptionEnum.THE_PRODUCT_CATEGORY_NAME_IS_EXIST);
+        }
+        Integer categoryId = categoryDTO.getId();
+        ProductCategory category = this.getById(categoryId);
+        if (StringUtils.isNotEmpty(categoryDTO.getName())) {
+            category.setName(categoryDTO.getName());
+        }
+        if (StringUtils.isNotEmpty(categoryDTO.getDescription())) {
+            category.setDescription(categoryDTO.getDescription());
+        }
+        if (StringUtils.isNotEmpty(categoryDTO.getSearchCondition())) {
+            category.setSearchCondition(categoryDTO.getSearchCondition());
+        }
+        if (categoryDTO.getParentId() != null) {
+            category.setParentId(categoryDTO.getParentId());
+            ProductCategory parentCategory = this.getById(categoryDTO.getParentId());
+            Integer level = parentCategory.getLevel();
+            category.setLevel(level + 1);
+            category.setPath(this.getPath(level));
+        }
+        category.updateById();
+
+        if (!CollectionUtils.isEmpty(categoryDTO.getFileGuids())) {
+            List<AssoCategoryFile> assoCategoryFiles = assoCategoryFileMapper.selectList(new LambdaQueryWrapper<AssoCategoryFile>()
+                    .eq(AssoCategoryFile::getProductCategoryId, categoryId));
+            if (!CollectionUtils.isEmpty(assoCategoryFiles)) {
+                List<Integer> categoryIds = assoCategoryFiles.stream().map(AssoCategoryFile::getId).collect(Collectors.toList());
+                assoCategoryFileMapper.deleteBatchIds(categoryIds);
+            }
+
+            for (String fileGuid : categoryDTO.getFileGuids()) {
+                AssoCategoryFile categoryFile = new AssoCategoryFile();
+                categoryFile.setProductCategoryId(categoryId);
+                categoryFile.setFileGuid(fileGuid);
+                categoryFile.insert();
+            }
+        }
+        return categoryId;
+    }
+
+    /**
+     * 查询产品类别详情
+     *
+     * @param categoryIdDTO
+     * @return
+     */
+    public SelectCategoryVO selectCategoryDetail(CategoryIdDTO categoryIdDTO) {
+        Integer categoryId = categoryIdDTO.getId();
+        SelectCategoryVO categoryVO = new SelectCategoryVO();
+        ProductCategory category = productCategoryMapper.selectById(categoryId);
+        BeanUtil.copy(category, categoryVO);
+        //获取父类产品类别
+        Integer parentId = category.getParentId();
+        if (parentId != null) {
+            ProductCategory parentCategory = this.getById(parentId);
+            SelectCategoryLevelVO levelVO = new SelectCategoryLevelVO();
+            levelVO.setId(parentCategory.getId());
+            levelVO.setName(parentCategory.getName());
+            levelVO.setPath(parentCategory.getPath());
+            levelVO.setLevel(parentCategory.getLevel());
+            categoryVO.setCategoryLevelVo(levelVO);
+        }
+        //获取guids
+        List<AssoCategoryFile> assoCategoryFiles = assoCategoryFileMapper.selectList(new LambdaQueryWrapper<AssoCategoryFile>()
+                .eq(AssoCategoryFile::getProductCategoryId, categoryId));
+        List<String> fileGuids = new ArrayList<>();
+        if (!CollectionUtils.isEmpty(assoCategoryFiles)) {
+            fileGuids = assoCategoryFiles.stream().map(AssoCategoryFile::getFileGuid).collect(Collectors.toList());
+        }
+        categoryVO.setFileGuids(fileGuids);
+        //判断是否有子集
+        Long count = productCategoryMapper.selectCount(new LambdaQueryWrapper<ProductCategory>()
+                .eq(ProductCategory::getParentId, categoryId));
+        if (count > 0) {
+            categoryVO.setIfChild(true);
+        }
+        return categoryVO;
+    }
+
+    /**
+     * 删除产品类别
+     *
+     * @param categoryIdsDTO
+     * @return
+     */
+    public boolean deleteCategory(CategoryIdsDTO categoryIdsDTO) {
+        List<Integer> ids = categoryIdsDTO.getIds();
+        for (Integer id : ids) {
+            List<Integer> productCategoryIds = this.getProductCategoryIds(id);
+            ids.addAll(productCategoryIds);
+        }
+        List<AssoCategoryFile> assoCategoryFiles = assoCategoryFileMapper.selectList(new LambdaQueryWrapper<AssoCategoryFile>()
+                .in(AssoCategoryFile::getProductCategoryId, ids));
+        if (!CollectionUtils.isEmpty(assoCategoryFiles)) {
+            List<Integer> fileIds = assoCategoryFiles.stream().map(AssoCategoryFile::getId).collect(Collectors.toList());
+            assoCategoryFileMapper.deleteBatchIds(fileIds);
+        }
+        return this.removeBatchByIds(ids);
+    }
+
+    public List<Integer> getProductCategoryIds(Integer id) {
+        List<Integer> list = new ArrayList<>();
+        List<ProductCategory> categories = productCategoryMapper.selectList(new LambdaQueryWrapper<ProductCategory>()
+                .eq(ProductCategory::getParentId, id));
+        if (!CollectionUtils.isEmpty(categories)) {
+            List<Integer> ids = categories.stream().map(ProductCategory::getId).collect(Collectors.toList());
+            list.addAll(ids);
+            for (ProductCategory category : categories) {
+                List<Integer> categoryIds = this.getProductCategoryIds(category.getId());
+                list.addAll(categoryIds);
+            }
+        }
+        return list;
+    }
+
+    /**
+     * 获取路径
+     *
+     * @param level
+     * @return
+     */
+    public String getPath(Integer level) {
+        String s = "";
+        for (int i = 1; i < level; i++) {
+            if (i != level - 1) {
+                s = s + i + "/";
+            } else {
+                s = s + i;
+            }
+        }
+        return s;
+    }
 }
 
 

+ 68 - 9
src/main/java/com/example/xiaoshiweixinback/service/ProductService.java

@@ -15,6 +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.vo.PersonnelVO;
@@ -66,6 +67,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
         List<Integer> ids = assoPersonCategoryService.getChoosedProductCategoryIds();
 
         GetProductDTO getProductDTO = new GetProductDTO();
+        BeanUtils.copyProperties(productDTO,getProductDTO);
         getProductDTO.setName(name);
         getProductDTO.setCurrent(current);
         getProductDTO.setSize(size);
@@ -156,14 +158,14 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
             assoPersonProductDTO.setConcernType(productAddDTO.getConcernType());
             Integer flag = assoPersonProductService.addAsso(assoPersonProductDTO);
         } else {
-            product = this.updateProduct(productAddDTO);
+            product = this.updateProduct(productAddDTO,productAddDTO.getId());
         }
         assoProductFileService.addOrUpdateProductFile(product.getId(), productAddDTO.getFileGuids());
         return product.getId();
     }
 
     @Transactional(rollbackFor = Exception.class)
-    public Product addProduct(ProductAddDTO productAddDTO) {
+    public Product addProduct(Object productAddDTO) {
         Product product = new Product();
         BeanUtils.copyProperties(productAddDTO, product);
         PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
@@ -174,14 +176,15 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
     }
 
     @Transactional(rollbackFor = Exception.class)
-    public Product updateProduct(ProductAddDTO productAddDTO) {
+    public Product updateProduct(Object productAddDTO,Integer id) {
         Product product = new Product();
-        product = this.getById(productAddDTO.getId());
-        product.setName(productAddDTO.getName());
-        product.setDescription(productAddDTO.getDescription());
-        product.setSearchCondition(productAddDTO.getSearchCondition());
-        product.setSellPlatform(productAddDTO.getSellPlatform());
-        product.setSourceFrom(productAddDTO.getSourceFrom());
+        Product orgProduct = this.getById(id);
+        BeanUtils.copyProperties(productAddDTO, product);
+        product.setId(orgProduct.getId());
+        product.setIfHot(orgProduct.getIfHot());
+        product.setIfCustomized(orgProduct.getIfCustomized());
+        product.setCreateId(orgProduct.getCreateId());
+        product.setCreateTime(orgProduct.getCreateTime());
         product.updateById();
         return product;
     }
@@ -217,6 +220,62 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
         records.setTotal(count);
         return records;
     }
+
+
+
+    @Transactional(rollbackFor = Exception.class)
+    public Integer addOrUpdateHotProduct(HotProductAddDTO hotProductAddDTO) {
+        Product product = new Product();
+        if (hotProductAddDTO.getId() == null) {
+            assoPersonProductService.checkAdmin();
+            product = this.addProduct(hotProductAddDTO);
+        } else {
+            product = this.updateProduct(hotProductAddDTO,hotProductAddDTO.getId());
+        }
+        assoProductFileService.addOrUpdateProductFile(product.getId(), hotProductAddDTO.getFileGuids());
+        return product.getId();
+    }
+
+
+
+    /**
+     * 根据id查询爆款专利
+     *
+     * @param id
+     * @return
+     */
+    public ProductVO queryHotProductDetail(Integer id) {
+        ProductVO productVO =new ProductVO();
+        Product product =this.getById(id);
+        if(product ==null){
+            return  productVO;
+        }
+        BeanUtils.copyProperties(product,productVO);
+        List<ProductVO> productVOS =new ArrayList<>();
+        productVOS.add(productVO);
+        this.loadProduct(productVOS);
+        return productVO;
+    }
+
+
+    /**
+     * 根据id查询爆款专利
+     *
+     * @param id
+     * @return
+     */
+    public ProductVO updateProductIfShow(Integer id) {
+        ProductVO productVO =new ProductVO();
+        Product product =this.getById(id);
+        if(product ==null){
+            return  productVO;
+        }
+        BeanUtils.copyProperties(product,productVO);
+        List<ProductVO> productVOS =new ArrayList<>();
+        productVOS.add(productVO);
+        this.loadProduct(productVOS);
+        return productVO;
+    }
 }
 
 

+ 6 - 3
src/main/java/com/example/xiaoshiweixinback/service/TicketService.java

@@ -267,6 +267,9 @@ public class TicketService extends ServiceImpl<TicketMapper, Ticket> {
         }
         ticket.setTicketProgress(process);
         ticket.updateById();
+        if (process.equals(4)) {
+            ticketFlowService.addTicketFlow(ticket, "工单已确认", false, null, 4,ticket.getCreateId());
+        }
         return ticket.getId();
     }
 
@@ -341,10 +344,10 @@ public class TicketService extends ServiceImpl<TicketMapper, Ticket> {
         ticket.setPrice(price);
 
         if (ticket.getTicketProgress() == 2) {
-            ticketFlowService.addTicketFlow(ticket, "修改工单价格为" + price, false, null, 1);
+            ticketFlowService.addTicketFlow(ticket, "修改工单价格为" + price, false, null, 2);
         } else {
             ticket.setTicketProgress(2);
-            ticketFlowService.addTicketFlow(ticket, "受理工单并且修改价格为" + price, false, null, 1);
+            ticketFlowService.addTicketFlow(ticket, "受理工单并且修改价格为" + price, false, null, 2);
         }
         ticket.updateById();
 
@@ -374,7 +377,7 @@ public class TicketService extends ServiceImpl<TicketMapper, Ticket> {
         }
 
         //添加工单流程
-        TicketFlow ticketFlow = ticketFlowService.addTicketFlow(ticket, "添加工单结果", true, description, 3);
+        TicketFlow ticketFlow = ticketFlowService.addTicketFlow(ticket, "添加工单结果", true, description, 6);
 
         //添加结果
         assoTicketFileService.addTicketFile(fileGuids, 1, ticket, ticketFlow.getId());

+ 20 - 0
src/main/resources/mapper/ProductMapper.xml

@@ -23,6 +23,26 @@
             <if test="getProductDTO.current!=null and getProductDTO.size!=null">
                 limit ${(getProductDTO.current -1)*getProductDTO.size},${getProductDTO.size}
             </if>
+            <if test="getProductDTO.ifShow!=null">
+                and p.if_show =#{getProductDTO.ifShow}
+            </if>
+            <if test="getProductDTO.ifShow!=null">
+                and p.if_show =#{getProductDTO.ifShow}
+            </if>
+
+            <if test="getProductDTO.productCategoryIds!=null and getProductDTO.productCategoryIds.size()>0">
+                and apc.product_category_id in
+                <foreach collection="getProductDTO.productCategoryIds" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="getProductDTO.sourceFrom!=null and getProductDTO.sourceFrom!=''">
+                and p.source_from like CONCAT('%',#{getProductDTO.sourceFrom},'%')
+            </if>
+            <if test="getProductDTO.bestSellingBrand!=null and getProductDTO.bestSellingBrand!=''">
+                and p.best_selling_brand like CONCAT('%',#{getProductDTO.bestSellingBrand},'%')
+            </if>
+
         </where>
 
     </select>