pull/691/head
Ryan Wang 2020-03-17 23:56:01 +08:00 committed by GitHub
parent a77ebed299
commit d4cfc3ae7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -46,6 +46,9 @@ public class CategoryTagDirective implements TemplateDirectiveModel {
case "list":
env.setVariable("categories", builder.build().wrap(postCategoryService.listCategoryWithPostCountDto(Sort.by(DESC, "createTime"))));
break;
case "tree":
env.setVariable("categories", builder.build().wrap(categoryService.listAsTree(Sort.by(DESC, "createTime"))));
break;
case "listByPostId":
Integer postId = Integer.parseInt(params.get("postId").toString());
List<Category> categories = postCategoryService.listCategoriesBy(postId);

View File

@ -123,6 +123,21 @@ public class CategoryServiceImpl extends AbstractCrudService<Category, Integer>
if (parentCategory.getChildren() == null) {
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
parentCategory.getChildren().add(child);
});