mirror of https://github.com/halo-dev/halo
Add status and url filed into Post entity
parent
ef3780369d
commit
58ba745973
|
@ -2,6 +2,7 @@ package cc.ryanc.halo.model.dto.post;
|
|||
|
||||
import cc.ryanc.halo.model.dto.base.OutputConverter;
|
||||
import cc.ryanc.halo.model.entity.Post;
|
||||
import cc.ryanc.halo.model.enums.PostStatus;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
@ -14,8 +15,11 @@ import lombok.ToString;
|
|||
@Data
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public class PostWithTitleDTO implements OutputConverter<PostWithTitleDTO, Post> {
|
||||
public class PostMinimalOutputDTO implements OutputConverter<PostMinimalOutputDTO, Post> {
|
||||
|
||||
/**
|
||||
* Post id.
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
|
@ -23,4 +27,13 @@ public class PostWithTitleDTO implements OutputConverter<PostWithTitleDTO, Post>
|
|||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* Post status.
|
||||
*/
|
||||
private PostStatus status;
|
||||
|
||||
/**
|
||||
* Post url.
|
||||
*/
|
||||
private String url;
|
||||
}
|
|
@ -16,7 +16,7 @@ import java.util.Date;
|
|||
@Data
|
||||
@ToString
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PostSimpleOutputDTO extends PostWithTitleDTO {
|
||||
public class PostSimpleOutputDTO extends PostMinimalOutputDTO {
|
||||
|
||||
/**
|
||||
* 文章类型
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package cc.ryanc.halo.model.entity;
|
||||
|
||||
import cc.ryanc.halo.model.enums.PostCreateFrom;
|
||||
import cc.ryanc.halo.model.enums.PostStatus;
|
||||
import cc.ryanc.halo.model.enums.PostType;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -44,6 +45,18 @@ public class Post {
|
|||
@Column(name = "type", columnDefinition = "int default 0")
|
||||
private PostType type;
|
||||
|
||||
/**
|
||||
* Post status.
|
||||
*/
|
||||
@Column(name = "status", columnDefinition = "int default 1")
|
||||
private PostStatus status;
|
||||
|
||||
/**
|
||||
* Post url.
|
||||
*/
|
||||
@Column(name = "url", columnDefinition = "varchar(255) not null")
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 源内容
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package cc.ryanc.halo.model.enums;
|
||||
|
||||
/**
|
||||
* Post status.
|
||||
*
|
||||
* @author johnniang
|
||||
*/
|
||||
public enum PostStatus implements ValueEnum<Integer> {
|
||||
|
||||
/**
|
||||
* Published status.
|
||||
*/
|
||||
PUBLISHED(0),
|
||||
|
||||
/**
|
||||
* Draft status.
|
||||
*/
|
||||
DRAFT(1),
|
||||
|
||||
/**
|
||||
* Recycle status.
|
||||
*/
|
||||
RECYCLE(2);
|
||||
|
||||
private final int value;
|
||||
|
||||
PostStatus(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package cc.ryanc.halo.model.vo;
|
||||
|
||||
import cc.ryanc.halo.model.dto.CommentOutputDTO;
|
||||
import cc.ryanc.halo.model.dto.post.PostWithTitleDTO;
|
||||
import cc.ryanc.halo.model.dto.post.PostMinimalOutputDTO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
@ -16,5 +16,5 @@ import lombok.ToString;
|
|||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CommentVO extends CommentOutputDTO {
|
||||
|
||||
private PostWithTitleDTO post;
|
||||
private PostMinimalOutputDTO post;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package cc.ryanc.halo.service.impl;
|
||||
|
||||
import cc.ryanc.halo.model.dto.post.PostWithTitleDTO;
|
||||
import cc.ryanc.halo.model.dto.post.PostMinimalOutputDTO;
|
||||
import cc.ryanc.halo.model.entity.Comment;
|
||||
import cc.ryanc.halo.model.entity.Post;
|
||||
import cc.ryanc.halo.model.vo.CommentVO;
|
||||
|
@ -59,7 +59,7 @@ public class CommentServiceImpl extends AbstractCrudService<Comment, Long> imple
|
|||
CommentVO commentVO = new CommentVO().convertFrom(comment);
|
||||
|
||||
// Get post and set to the vo
|
||||
commentVO.setPost(new PostWithTitleDTO().convertFrom(postMap.get(comment.getPostId())));
|
||||
commentVO.setPost(new PostMinimalOutputDTO().convertFrom(postMap.get(comment.getPostId())));
|
||||
|
||||
return commentVO;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue