refactor: independent sheet. (#697)

pull/705/head
Ryan Wang 2020-03-20 20:34:51 +08:00 committed by GitHub
parent d97f6f7fd2
commit 40f510f371
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 23 deletions

View File

@ -7,7 +7,7 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault; import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import run.halo.app.cache.AbstractStringCacheStore; import run.halo.app.cache.AbstractStringCacheStore;
import run.halo.app.model.dto.InternalSheetDTO; import run.halo.app.model.dto.IndependentSheetDTO;
import run.halo.app.model.dto.post.BasePostDetailDTO; import run.halo.app.model.dto.post.BasePostDetailDTO;
import run.halo.app.model.dto.post.BasePostMinimalDTO; import run.halo.app.model.dto.post.BasePostMinimalDTO;
import run.halo.app.model.entity.Sheet; import run.halo.app.model.entity.Sheet;
@ -67,10 +67,10 @@ public class SheetController {
return sheetService.convertToListVo(sheetPage); return sheetService.convertToListVo(sheetPage);
} }
@GetMapping("internal") @GetMapping("independent")
@ApiOperation("Lists internal sheets") @ApiOperation("Lists independent sheets")
public List<InternalSheetDTO> internalSheets() { public List<IndependentSheetDTO> independentSheets() {
return sheetService.listInternal(); return sheetService.listIndependentSheets();
} }
@PostMapping @PostMapping

View File

@ -9,13 +9,15 @@ import lombok.Data;
* @date 2019/5/4 * @date 2019/5/4
*/ */
@Data @Data
public class InternalSheetDTO { public class IndependentSheetDTO {
private Integer id; private Integer id;
private String title; private String title;
private String url; private String fullPath;
private Boolean status; private String routeName;
private Boolean available;
} }

View File

@ -2,7 +2,7 @@ package run.halo.app.service;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.lang.NonNull; import org.springframework.lang.NonNull;
import run.halo.app.model.dto.InternalSheetDTO; import run.halo.app.model.dto.IndependentSheetDTO;
import run.halo.app.model.entity.Sheet; import run.halo.app.model.entity.Sheet;
import run.halo.app.model.entity.SheetMeta; import run.halo.app.model.entity.SheetMeta;
import run.halo.app.model.enums.PostStatus; import run.halo.app.model.enums.PostStatus;
@ -100,12 +100,12 @@ public interface SheetService extends BasePostService<Sheet> {
String exportMarkdown(@NonNull Sheet sheet); String exportMarkdown(@NonNull Sheet sheet);
/** /**
* List internal sheets. * List independent sheets.
* *
* @return list of internal sheets * @return list of independent sheets
*/ */
@NonNull @NonNull
List<InternalSheetDTO> listInternal(); List<IndependentSheetDTO> listIndependentSheets();
/** /**
* Converts to list dto page. * Converts to list dto page.

View File

@ -13,7 +13,7 @@ import run.halo.app.event.logger.LogEvent;
import run.halo.app.event.post.SheetVisitEvent; import run.halo.app.event.post.SheetVisitEvent;
import run.halo.app.exception.AlreadyExistsException; import run.halo.app.exception.AlreadyExistsException;
import run.halo.app.exception.NotFoundException; import run.halo.app.exception.NotFoundException;
import run.halo.app.model.dto.InternalSheetDTO; import run.halo.app.model.dto.IndependentSheetDTO;
import run.halo.app.model.dto.post.BasePostMinimalDTO; import run.halo.app.model.dto.post.BasePostMinimalDTO;
import run.halo.app.model.entity.Sheet; import run.halo.app.model.entity.Sheet;
import run.halo.app.model.entity.SheetComment; import run.halo.app.model.entity.SheetComment;
@ -191,28 +191,35 @@ public class SheetServiceImpl extends BasePostServiceImpl<Sheet> implements Shee
} }
@Override @Override
public List<InternalSheetDTO> listInternal() { public List<IndependentSheetDTO> listIndependentSheets() {
String context = (optionService.isEnabledAbsolutePath() ? optionService.getBlogBaseUrl() : "") + "/";
// TODO 日后将重构该部分,提供接口用于拓展独立页面,以供插件系统使用。
// links sheet // links sheet
InternalSheetDTO linkSheet = new InternalSheetDTO(); IndependentSheetDTO linkSheet = new IndependentSheetDTO();
linkSheet.setId(1); linkSheet.setId(1);
linkSheet.setTitle("友情链接"); linkSheet.setTitle("友情链接");
linkSheet.setUrl((optionService.isEnabledAbsolutePath() ? optionService.getBlogBaseUrl() : "") + "/" + optionService.getLinksPrefix()); linkSheet.setFullPath(context + optionService.getLinksPrefix());
linkSheet.setStatus(themeService.templateExists("links.ftl")); linkSheet.setRouteName("LinkList");
linkSheet.setAvailable(themeService.templateExists("links.ftl"));
// photos sheet // photos sheet
InternalSheetDTO photoSheet = new InternalSheetDTO(); IndependentSheetDTO photoSheet = new IndependentSheetDTO();
photoSheet.setId(2); photoSheet.setId(2);
photoSheet.setTitle("图库页面"); photoSheet.setTitle("图库页面");
photoSheet.setUrl((optionService.isEnabledAbsolutePath() ? optionService.getBlogBaseUrl() : "") + "/" + optionService.getPhotosPrefix()); photoSheet.setFullPath(context + optionService.getPhotosPrefix());
photoSheet.setStatus(themeService.templateExists("photos.ftl")); photoSheet.setRouteName("PhotoList");
photoSheet.setAvailable(themeService.templateExists("photos.ftl"));
// journals sheet // journals sheet
InternalSheetDTO journalSheet = new InternalSheetDTO(); IndependentSheetDTO journalSheet = new IndependentSheetDTO();
journalSheet.setId(3); journalSheet.setId(3);
journalSheet.setTitle("日志页面"); journalSheet.setTitle("日志页面");
journalSheet.setUrl((optionService.isEnabledAbsolutePath() ? optionService.getBlogBaseUrl() : "") + "/" + optionService.getJournalsPrefix()); journalSheet.setFullPath(context + optionService.getJournalsPrefix());
journalSheet.setStatus(themeService.templateExists("journals.ftl")); journalSheet.setRouteName("JournalList");
journalSheet.setAvailable(themeService.templateExists("journals.ftl"));
return Arrays.asList(linkSheet, photoSheet, journalSheet); return Arrays.asList(linkSheet, photoSheet, journalSheet);
} }