mirror of https://github.com/halo-dev/halo
Add Post output dtos
parent
06e5c18cc7
commit
015fb3c399
|
@ -0,0 +1,57 @@
|
||||||
|
package cc.ryanc.halo.model.dto;
|
||||||
|
|
||||||
|
import cc.ryanc.halo.model.domain.*;
|
||||||
|
import cc.ryanc.halo.model.dto.base.AbstractOutputConverter;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post detail output dto.
|
||||||
|
*
|
||||||
|
* @author johnniang
|
||||||
|
*/
|
||||||
|
public class PostDetailOutputDTO extends AbstractOutputConverter<PostDetailOutputDTO, Post> {
|
||||||
|
|
||||||
|
private Long postId;
|
||||||
|
|
||||||
|
private User user;
|
||||||
|
|
||||||
|
private String postTitle;
|
||||||
|
|
||||||
|
private String postType;
|
||||||
|
|
||||||
|
private String postContent;
|
||||||
|
|
||||||
|
private String postUrl;
|
||||||
|
|
||||||
|
private String postSummary;
|
||||||
|
|
||||||
|
private List<Category> categories;
|
||||||
|
|
||||||
|
private List<Tag> tags;
|
||||||
|
|
||||||
|
private List<Comment> comments;
|
||||||
|
|
||||||
|
private String postThumbnail;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
|
||||||
|
private Date postDate;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
|
||||||
|
private Date postUpdate;
|
||||||
|
|
||||||
|
private Integer postStatus;
|
||||||
|
|
||||||
|
private Long postViews;
|
||||||
|
|
||||||
|
private Integer allowComment;
|
||||||
|
|
||||||
|
private String postPassword;
|
||||||
|
|
||||||
|
private String customTpl;
|
||||||
|
|
||||||
|
private Integer postPriority;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package cc.ryanc.halo.model.dto;
|
||||||
|
|
||||||
|
import cc.ryanc.halo.model.domain.*;
|
||||||
|
import cc.ryanc.halo.model.dto.base.AbstractOutputConverter;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post output dto without markdown and content.
|
||||||
|
*
|
||||||
|
* @author johnniang
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PostSimpleOutputDTO extends AbstractOutputConverter<PostSimpleOutputDTO, Post> {
|
||||||
|
|
||||||
|
private Long postId;
|
||||||
|
|
||||||
|
private String postTitle;
|
||||||
|
|
||||||
|
private String postType;
|
||||||
|
|
||||||
|
private String postUrl;
|
||||||
|
|
||||||
|
private String postSummary;
|
||||||
|
|
||||||
|
private List<Category> categories;
|
||||||
|
|
||||||
|
private List<Tag> tags;
|
||||||
|
|
||||||
|
private String postThumbnail;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
|
||||||
|
private Date postDate;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
|
||||||
|
private Date postUpdate;
|
||||||
|
|
||||||
|
private Integer postStatus;
|
||||||
|
|
||||||
|
private Long postViews;
|
||||||
|
|
||||||
|
private Integer allowComment;
|
||||||
|
|
||||||
|
private String postPassword;
|
||||||
|
|
||||||
|
private String customTpl;
|
||||||
|
|
||||||
|
private Integer postPriority;
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package cc.ryanc.halo.web.controller.api;
|
package cc.ryanc.halo.web.controller.api;
|
||||||
|
|
||||||
import cc.ryanc.halo.model.domain.Post;
|
import cc.ryanc.halo.model.domain.Post;
|
||||||
|
import cc.ryanc.halo.model.dto.PostDetailOutputDTO;
|
||||||
import cc.ryanc.halo.model.params.JournalParam;
|
import cc.ryanc.halo.model.params.JournalParam;
|
||||||
import cc.ryanc.halo.service.PostService;
|
import cc.ryanc.halo.service.PostService;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -32,11 +33,11 @@ public class ApiJournalController {
|
||||||
*/
|
*/
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ResponseStatus(HttpStatus.CREATED)
|
@ResponseStatus(HttpStatus.CREATED)
|
||||||
public Post save(@RequestBody JournalParam journalParam) {
|
public PostDetailOutputDTO save(@RequestBody JournalParam journalParam) {
|
||||||
// TODO need to validate token
|
// TODO need to validate token
|
||||||
|
|
||||||
Post post = journalParam.convertTo();
|
Post post = journalParam.convertTo();
|
||||||
|
|
||||||
return postService.create(post);
|
return new PostDetailOutputDTO().convertFrom(postService.create(post));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue