From e6bb96b8c12282458ca096074cc41a63be7097ec Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Thu, 28 Jan 2021 00:20:46 +0800 Subject: [PATCH] fix: unable to access custom sheet. (#1246) --- .../content/ContentContentController.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/run/halo/app/controller/content/ContentContentController.java b/src/main/java/run/halo/app/controller/content/ContentContentController.java index d15ec95877..f33088ed7f 100644 --- a/src/main/java/run/halo/app/controller/content/ContentContentController.java +++ b/src/main/java/run/halo/app/controller/content/ContentContentController.java @@ -93,10 +93,6 @@ public ContentContentController(PostModel postModel, public String content(@PathVariable("prefix") String prefix, @RequestParam(value = "token", required = false) String token, Model model) { - if (optionService.getSheetPermalinkType().equals(SheetPermalinkType.ROOT)) { - Sheet sheet = sheetService.getBySlug(prefix); - return sheetModel.content(sheet, token, model); - } if (optionService.getArchivesPrefix().equals(prefix)) { return postModel.archives(1, model); } @@ -115,7 +111,11 @@ public String content(@PathVariable("prefix") String prefix, if (optionService.getLinksPrefix().equals(prefix)) { return linkModel.list(model); } - return null; + if (optionService.getSheetPermalinkType().equals(SheetPermalinkType.ROOT)) { + Sheet sheet = sheetService.getBySlug(prefix); + return sheetModel.content(sheet, token, model); + } + throw new NotFoundException("Not Found"); } @GetMapping("{prefix}/page/{page:\\d+}") @@ -155,12 +155,6 @@ public String content(@PathVariable("prefix") String prefix, } } - if (optionService.getSheetPermalinkType().equals(SheetPermalinkType.SECONDARY) - && optionService.getSheetPrefix().equals(prefix)) { - Sheet sheet = sheetService.getBySlug(slug); - return sheetModel.content(sheet, token, model); - } - if (optionService.getCategoriesPrefix().equals(prefix)) { return categoryModel.listPost(model, slug, 1); } @@ -175,6 +169,12 @@ public String content(@PathVariable("prefix") String prefix, return postModel.content(post, token, model); } + if (optionService.getSheetPermalinkType().equals(SheetPermalinkType.SECONDARY) + && optionService.getSheetPrefix().equals(prefix)) { + Sheet sheet = sheetService.getBySlug(slug); + return sheetModel.content(sheet, token, model); + } + throw new NotFoundException("Not Found"); }