Parcourir la source

产品分类添加组级id过滤

yzc il y a 1 an
Parent
commit
583b11d45d

+ 5 - 0
hx-item/src/main/java/com/fjhx/item/entity/product/dto/ProductClassifyDto.java

@@ -19,4 +19,9 @@ public class ProductClassifyDto extends ProductClassify {
      */
     private Integer isNeRawMaterial;
 
+    /**
+     * 祖级id过滤
+     */
+    private Long ancestors;
+
 }

+ 5 - 1
hx-item/src/main/java/com/fjhx/item/service/product/impl/ProductClassifyServiceImpl.java

@@ -44,7 +44,7 @@ public class ProductClassifyServiceImpl extends ServiceImpl<ProductClassifyMappe
         if (Objects.equals(isNeRawMaterial, 1)) {
             pcIds = this.listObject(ProductClassify::getId, q -> q
                     .eq(ProductClassify::getId, 100)
-                    .or().apply("FIND_IN_SET(parent_id_set, 100)")
+                    .or().apply("FIND_IN_SET(100,parent_id_set)")
             );
         }
 
@@ -53,6 +53,10 @@ public class ProductClassifyServiceImpl extends ServiceImpl<ProductClassifyMappe
                 .eq(ProductClassify::getDefinition, productClassify.getDefinition())
                 .like(ObjectUtil.isNotEmpty(name), ProductClassify::getName, name)
                 .notIn(ObjectUtil.isNotEmpty(pcIds), ProductClassify::getId, pcIds)
+                .and(ObjectUtil.isNotEmpty(productClassify.getAncestors()), q -> q
+                        .eq(ProductClassify::getId, productClassify.getAncestors())
+                        .or().apply("FIND_IN_SET({0},parent_id_set)", productClassify.getAncestors())
+                )
                 .orderByAsc(ProductClassify::getSort)
                 .list();