mirror of https://github.com/halo-dev/halo
Support internal sheet list api.
parent
373c4ce285
commit
7c9f8b01f3
|
@ -5,6 +5,7 @@ import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
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.model.dto.InternalSheetDTO;
|
||||||
import run.halo.app.model.dto.post.BasePostDetailDTO;
|
import run.halo.app.model.dto.post.BasePostDetailDTO;
|
||||||
import run.halo.app.model.entity.Sheet;
|
import run.halo.app.model.entity.Sheet;
|
||||||
import run.halo.app.model.enums.PostStatus;
|
import run.halo.app.model.enums.PostStatus;
|
||||||
|
@ -13,6 +14,7 @@ import run.halo.app.model.vo.SheetListVO;
|
||||||
import run.halo.app.service.SheetService;
|
import run.halo.app.service.SheetService;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.springframework.data.domain.Sort.Direction.DESC;
|
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||||
|
|
||||||
|
@ -20,6 +22,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||||
* Sheet controller.
|
* Sheet controller.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @author ryanwang
|
||||||
* @date 19-4-24
|
* @date 19-4-24
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -46,6 +49,12 @@ public class SheetController {
|
||||||
return sheetService.convertToListVo(sheetPage);
|
return sheetService.convertToListVo(sheetPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("internal")
|
||||||
|
@ApiOperation("Lists internal sheets")
|
||||||
|
public List<InternalSheetDTO> internalSheets() {
|
||||||
|
return sheetService.listInternal();
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("Creates a sheet")
|
@ApiOperation("Creates a sheet")
|
||||||
public BasePostDetailDTO createBy(@RequestBody @Valid SheetParam sheetParam,
|
public BasePostDetailDTO createBy(@RequestBody @Valid SheetParam sheetParam,
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package run.halo.app.model.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Theme controller.
|
||||||
|
*
|
||||||
|
* @author ryanwang
|
||||||
|
* @date : 2019/5/4
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class InternalSheetDTO {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
private boolean status;
|
||||||
|
}
|
|
@ -2,15 +2,19 @@ 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.entity.Sheet;
|
import run.halo.app.model.entity.Sheet;
|
||||||
import run.halo.app.model.enums.PostStatus;
|
import run.halo.app.model.enums.PostStatus;
|
||||||
import run.halo.app.model.vo.SheetListVO;
|
import run.halo.app.model.vo.SheetListVO;
|
||||||
import run.halo.app.service.base.BasePostService;
|
import run.halo.app.service.base.BasePostService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sheet service interface.
|
* Sheet service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @author ryanwang
|
||||||
* @date 19-4-24
|
* @date 19-4-24
|
||||||
*/
|
*/
|
||||||
public interface SheetService extends BasePostService<Sheet> {
|
public interface SheetService extends BasePostService<Sheet> {
|
||||||
|
@ -72,6 +76,14 @@ public interface SheetService extends BasePostService<Sheet> {
|
||||||
@NonNull
|
@NonNull
|
||||||
String exportMarkdown(@NonNull Sheet sheet);
|
String exportMarkdown(@NonNull Sheet sheet);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List internal sheets.
|
||||||
|
*
|
||||||
|
* @return list of internal sheets
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
List<InternalSheetDTO> listInternal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts to list dto page.
|
* Converts to list dto page.
|
||||||
*
|
*
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import run.halo.app.event.logger.LogEvent;
|
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.model.dto.InternalSheetDTO;
|
||||||
import run.halo.app.model.entity.Sheet;
|
import run.halo.app.model.entity.Sheet;
|
||||||
import run.halo.app.model.enums.LogType;
|
import run.halo.app.model.enums.LogType;
|
||||||
import run.halo.app.model.enums.PostStatus;
|
import run.halo.app.model.enums.PostStatus;
|
||||||
|
@ -16,9 +17,11 @@ import run.halo.app.repository.SheetRepository;
|
||||||
import run.halo.app.service.OptionService;
|
import run.halo.app.service.OptionService;
|
||||||
import run.halo.app.service.SheetCommentService;
|
import run.halo.app.service.SheetCommentService;
|
||||||
import run.halo.app.service.SheetService;
|
import run.halo.app.service.SheetService;
|
||||||
|
import run.halo.app.service.ThemeService;
|
||||||
import run.halo.app.utils.MarkdownUtils;
|
import run.halo.app.utils.MarkdownUtils;
|
||||||
import run.halo.app.utils.ServiceUtils;
|
import run.halo.app.utils.ServiceUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -27,6 +30,7 @@ import java.util.Set;
|
||||||
* Sheet service implementation.
|
* Sheet service implementation.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @author ryanwang
|
||||||
* @date 19-4-24
|
* @date 19-4-24
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@ -38,14 +42,18 @@ public class SheetServiceImpl extends BasePostServiceImpl<Sheet> implements Shee
|
||||||
|
|
||||||
private final SheetCommentService sheetCommentService;
|
private final SheetCommentService sheetCommentService;
|
||||||
|
|
||||||
|
private final ThemeService themeService;
|
||||||
|
|
||||||
public SheetServiceImpl(SheetRepository sheetRepository,
|
public SheetServiceImpl(SheetRepository sheetRepository,
|
||||||
ApplicationEventPublisher eventPublisher,
|
ApplicationEventPublisher eventPublisher,
|
||||||
SheetCommentService sheetCommentService,
|
SheetCommentService sheetCommentService,
|
||||||
OptionService optionService) {
|
OptionService optionService,
|
||||||
|
ThemeService themeService) {
|
||||||
super(sheetRepository, optionService);
|
super(sheetRepository, optionService);
|
||||||
this.sheetRepository = sheetRepository;
|
this.sheetRepository = sheetRepository;
|
||||||
this.eventPublisher = eventPublisher;
|
this.eventPublisher = eventPublisher;
|
||||||
this.sheetCommentService = sheetCommentService;
|
this.sheetCommentService = sheetCommentService;
|
||||||
|
this.themeService = themeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -136,6 +144,39 @@ public class SheetServiceImpl extends BasePostServiceImpl<Sheet> implements Shee
|
||||||
return content.toString();
|
return content.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<InternalSheetDTO> listInternal() {
|
||||||
|
|
||||||
|
List<InternalSheetDTO> internalSheetDTOS = new ArrayList<>();
|
||||||
|
|
||||||
|
// links sheet
|
||||||
|
InternalSheetDTO linkSheet = new InternalSheetDTO();
|
||||||
|
linkSheet.setId(1);
|
||||||
|
linkSheet.setTitle("友情链接");
|
||||||
|
linkSheet.setUrl("/links");
|
||||||
|
linkSheet.setStatus(themeService.templateExists("links.ftl"));
|
||||||
|
|
||||||
|
// photos sheet
|
||||||
|
InternalSheetDTO photoSheet = new InternalSheetDTO();
|
||||||
|
photoSheet.setId(2);
|
||||||
|
photoSheet.setTitle("图库页面");
|
||||||
|
photoSheet.setUrl("/photos");
|
||||||
|
photoSheet.setStatus(themeService.templateExists("photos.ftl"));
|
||||||
|
|
||||||
|
// journals sheet
|
||||||
|
InternalSheetDTO journalSheet = new InternalSheetDTO();
|
||||||
|
journalSheet.setId(3);
|
||||||
|
journalSheet.setTitle("日志页面");
|
||||||
|
journalSheet.setUrl("/journals");
|
||||||
|
journalSheet.setStatus(themeService.templateExists("journals.ftl"));
|
||||||
|
|
||||||
|
internalSheetDTOS.add(linkSheet);
|
||||||
|
internalSheetDTOS.add(photoSheet);
|
||||||
|
internalSheetDTOS.add(journalSheet);
|
||||||
|
|
||||||
|
return internalSheetDTOS;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Sheet removeById(Integer id) {
|
public Sheet removeById(Integer id) {
|
||||||
Sheet sheet = super.removeById(id);
|
Sheet sheet = super.removeById(id);
|
||||||
|
|
Loading…
Reference in New Issue