Prechádzať zdrojové kódy

20240712 邀请会员

lwhhszx 1 rok pred
rodič
commit
342c7768c1

+ 1 - 1
src/main/java/com/example/xiaoshiweixinback/controller/TemplateController.java

@@ -29,7 +29,7 @@ public class TemplateController {
 
     @Operation(summary = "导入产品")
     @PostMapping("/getTemplate")
-    private Response importProduct(@RequestBody TemplateDTO templateDTO) throws Exception {
+    public Response importProduct(@RequestBody TemplateDTO templateDTO) throws Exception {
        List<TemplateVO> templateVOList= templateService.getTemplate(templateDTO);
         Records records =new Records();
         records.setData(templateVOList);

+ 17 - 22
src/main/java/com/example/xiaoshiweixinback/service/ProductCategoryService.java

@@ -213,11 +213,8 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
                 level = parentCategory.getLevel();
             }
             category.setLevel(level + 1);
-            if (parentCategory.getParentId() != 0) {
-                category.setPath(this.getPath(parentCategory.getParentId()) + "/" + parentCategory.getId() + "/");
-            } else {
-                category.setPath(parentCategory.getId() + "/");
-            }
+            category.setPath(this.getPath(parentCategory));
+
         } else {
             category.setParentId(0);
             category.setLevel(1);
@@ -272,11 +269,9 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
                 level = parentCategory.getLevel();
             }
             category.setLevel(level + 1);
-            if (parentCategory.getParentId() != 0) {
-                category.setPath(this.getPath(parentCategory.getParentId()) + "/" + parentCategory.getId() + "/");
-            } else {
-                category.setPath(parentCategory.getId() + "/");
-            }
+
+                category.setPath(this.getPath(parentCategory));
+
             this.getParentPath(category.getId(), category.getPath(), category.getLevel());
         } else {
             Integer parentId = category.getParentId();
@@ -496,21 +491,21 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
     /**
      * 获取路径
      *
-     * @param parentId
+     * @param
      * @return
      */
-    public String getPath(Integer parentId) {
-        String s = "";
-        ProductCategory parentCategory = this.getById(parentId);
-        if (ToolUtil.isNotEmpty(parentCategory)) {
-            if (parentCategory.getParentId() != 0) {
-                String pathId = this.getPath(parentCategory.getParentId());
-                s = s + "/" + pathId;
-            } else {
-                s = parentCategory.getId().toString();
+    public String getPath(ProductCategory parentCategory) {
+            String s = "";
+            if (ToolUtil.isNotEmpty(parentCategory)) {
+                if (parentCategory.getParentId() != 0) {
+                    String pathId = parentCategory.getPath()+parentCategory.getId()+"/";
+                    s=pathId;
+                } else {
+                    s = parentCategory.getId().toString()+"/";
+                }
             }
-        }
-        return s;
+            return s;
+
     }
 
     /**