Skip to content

Commit

Permalink
refactor: postLikes 필드 이름 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
enjay27 committed Jun 11, 2021
1 parent b775174 commit d905039
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/devin/dev/dto/post/PostInfoDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public PostInfoDto(Post post) {
this.title = post.getTitle();
this.tags = post.getPostTags();
this.statusAccept = post.getStatus() == PostStatus.SELECTED;
this.statusLike = post.getPostLikes().size() > 0;
this.statusLike = post.getLikes().size() > 0;
this.replyNum = post.getReplies().size();
this.likeNum = post.getPostLikes().size();
this.likeNum = post.getLikes().size();
this.createdDate = post.getCreatedDate();
this.userId = post.getUser().getId();
this.username = post.getUser().getName();
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/com/devin/dev/entity/post/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.devin.dev.entity.base.ModifiedCreated;
import com.devin.dev.entity.reply.Reply;
import com.devin.dev.entity.reply.ReplyLike;
import com.devin.dev.entity.user.User;
import lombok.AccessLevel;
import lombok.Getter;
Expand Down Expand Up @@ -36,7 +37,7 @@ public class Post extends ModifiedCreated {
private final List<PostTag> tags = new ArrayList<>();

@OneToMany(mappedBy = "post")
private final List<PostLike> postLikes = new ArrayList<>();
private final List<PostLike> likes = new ArrayList<>();

@OneToMany(mappedBy = "post")
private final List<PostImage> images = new ArrayList<>();
Expand Down Expand Up @@ -106,4 +107,10 @@ public void setPostImages(List<PostImage> postImages) {
public List<String> getPostTags() {
return this.tags.stream().map(tag -> tag.getTag().getName()).collect(Collectors.toList());
}

public PostLike like(User user, PostLike postLike) {
postLike.changePost(this);
postLike.setUser(user);
return postLike;
}
}

0 comments on commit d905039

Please sign in to comment.