Add status and url filed into Post entity

pull/137/head
johnniang 2019-03-14 16:38:55 +08:00
parent ef3780369d
commit 58ba745973
6 changed files with 67 additions and 6 deletions

View File

@ -2,6 +2,7 @@ package cc.ryanc.halo.model.dto.post;
import cc.ryanc.halo.model.dto.base.OutputConverter; import cc.ryanc.halo.model.dto.base.OutputConverter;
import cc.ryanc.halo.model.entity.Post; import cc.ryanc.halo.model.entity.Post;
import cc.ryanc.halo.model.enums.PostStatus;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
@ -14,8 +15,11 @@ import lombok.ToString;
@Data @Data
@ToString @ToString
@EqualsAndHashCode @EqualsAndHashCode
public class PostWithTitleDTO implements OutputConverter<PostWithTitleDTO, Post> { public class PostMinimalOutputDTO implements OutputConverter<PostMinimalOutputDTO, Post> {
/**
* Post id.
*/
private Integer id; private Integer id;
/** /**
@ -23,4 +27,13 @@ public class PostWithTitleDTO implements OutputConverter<PostWithTitleDTO, Post>
*/ */
private String title; private String title;
/**
* Post status.
*/
private PostStatus status;
/**
* Post url.
*/
private String url;
} }

View File

@ -16,7 +16,7 @@ import java.util.Date;
@Data @Data
@ToString @ToString
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class PostSimpleOutputDTO extends PostWithTitleDTO { public class PostSimpleOutputDTO extends PostMinimalOutputDTO {
/** /**
* *

View File

@ -1,6 +1,7 @@
package cc.ryanc.halo.model.entity; package cc.ryanc.halo.model.entity;
import cc.ryanc.halo.model.enums.PostCreateFrom; import cc.ryanc.halo.model.enums.PostCreateFrom;
import cc.ryanc.halo.model.enums.PostStatus;
import cc.ryanc.halo.model.enums.PostType; import cc.ryanc.halo.model.enums.PostType;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -44,6 +45,18 @@ public class Post {
@Column(name = "type", columnDefinition = "int default 0") @Column(name = "type", columnDefinition = "int default 0")
private PostType type; 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;
/** /**
* *
*/ */

View File

@ -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;
}
}

View File

@ -1,7 +1,7 @@
package cc.ryanc.halo.model.vo; package cc.ryanc.halo.model.vo;
import cc.ryanc.halo.model.dto.CommentOutputDTO; 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.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
@ -16,5 +16,5 @@ import lombok.ToString;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class CommentVO extends CommentOutputDTO { public class CommentVO extends CommentOutputDTO {
private PostWithTitleDTO post; private PostMinimalOutputDTO post;
} }

View File

@ -1,6 +1,6 @@
package cc.ryanc.halo.service.impl; 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.Comment;
import cc.ryanc.halo.model.entity.Post; import cc.ryanc.halo.model.entity.Post;
import cc.ryanc.halo.model.vo.CommentVO; 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); CommentVO commentVO = new CommentVO().convertFrom(comment);
// Get post and set to the vo // 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; return commentVO;
}); });