|
@@ -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;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|