mirror of https://github.com/halo-dev/halo
parent
a77ebed299
commit
d4cfc3ae7f
|
@ -46,6 +46,9 @@ public class CategoryTagDirective implements TemplateDirectiveModel {
|
||||||
case "list":
|
case "list":
|
||||||
env.setVariable("categories", builder.build().wrap(postCategoryService.listCategoryWithPostCountDto(Sort.by(DESC, "createTime"))));
|
env.setVariable("categories", builder.build().wrap(postCategoryService.listCategoryWithPostCountDto(Sort.by(DESC, "createTime"))));
|
||||||
break;
|
break;
|
||||||
|
case "tree":
|
||||||
|
env.setVariable("categories", builder.build().wrap(categoryService.listAsTree(Sort.by(DESC, "createTime"))));
|
||||||
|
break;
|
||||||
case "listByPostId":
|
case "listByPostId":
|
||||||
Integer postId = Integer.parseInt(params.get("postId").toString());
|
Integer postId = Integer.parseInt(params.get("postId").toString());
|
||||||
List<Category> categories = postCategoryService.listCategoriesBy(postId);
|
List<Category> categories = postCategoryService.listCategoriesBy(postId);
|
||||||
|
|
|
@ -123,6 +123,21 @@ public class CategoryServiceImpl extends AbstractCrudService<Category, Integer>
|
||||||
if (parentCategory.getChildren() == null) {
|
if (parentCategory.getChildren() == null) {
|
||||||
parentCategory.setChildren(new LinkedList<>());
|
parentCategory.setChildren(new LinkedList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringBuilder fullPath = new StringBuilder();
|
||||||
|
|
||||||
|
if (optionService.isEnabledAbsolutePath()) {
|
||||||
|
fullPath.append(optionService.getBlogBaseUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
fullPath.append("/")
|
||||||
|
.append(optionService.getCategoriesPrefix())
|
||||||
|
.append("/")
|
||||||
|
.append(child.getSlug())
|
||||||
|
.append(optionService.getPathSuffix());
|
||||||
|
|
||||||
|
child.setFullPath(fullPath.toString());
|
||||||
|
|
||||||
// Add child
|
// Add child
|
||||||
parentCategory.getChildren().add(child);
|
parentCategory.getChildren().add(child);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue