-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔨 Refactor: 커뮤니티 중 게시글 목록 반환과 게시글 이미지 관련 리팩토링
- Loading branch information
Showing
24 changed files
with
205 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/java/cotato/growingpain/comment/dto/response/CommentListResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
package cotato.growingpain.comment.dto.response; | ||
|
||
import cotato.growingpain.comment.domain.entity.Comment; | ||
import java.util.List; | ||
|
||
public record CommentListResponse( | ||
List<CommentResponse> commentList | ||
) { | ||
public static CommentListResponse from(List<Comment> comments) { | ||
List<CommentResponse> commentResponses = comments.stream() | ||
.map(CommentResponse::from) | ||
.toList(); | ||
return new CommentListResponse(commentResponses); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/cotato/growingpain/post/domain/entity/PostImage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package cotato.growingpain.post.domain.entity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class PostImage { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "post_image_id") | ||
private Long id; | ||
|
||
|
||
@Column(name = "post_id", nullable = false) | ||
private Long postId; | ||
|
||
@Column(name = "post_image_url", nullable = false) | ||
private String imageUrl; | ||
|
||
public PostImage(Long postId, String imageUrl) { | ||
this.postId = postId; | ||
this.imageUrl = imageUrl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/cotato/growingpain/post/dto/response/PostImageListResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package cotato.growingpain.post.dto.response; | ||
|
||
import cotato.growingpain.post.domain.entity.PostImage; | ||
import java.util.List; | ||
|
||
public record PostImageListResponse ( | ||
List <PostImageResponse> postImages | ||
) { | ||
public static PostImageListResponse from(List<PostImage> postImages) { | ||
List <PostImageResponse> postImageResponses = postImages.stream() | ||
.map(PostImageResponse::from) | ||
.toList(); | ||
return new PostImageListResponse(postImageResponses); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/cotato/growingpain/post/dto/response/PostImageResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package cotato.growingpain.post.dto.response; | ||
|
||
import cotato.growingpain.post.domain.entity.PostImage; | ||
|
||
public record PostImageResponse( | ||
|
||
Long postImageId, | ||
String imageUrl | ||
) { | ||
public static PostImageResponse from(PostImage postImage) { | ||
return new PostImageResponse( | ||
postImage.getId(), | ||
postImage.getImageUrl() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/cotato/growingpain/post/repository/PostImageRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package cotato.growingpain.post.repository; | ||
|
||
import cotato.growingpain.post.domain.entity.PostImage; | ||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface PostImageRepository extends JpaRepository<PostImage, Long> { | ||
void deleteAllByPostId(Long postId); | ||
|
||
List<PostImage> findAllByPostId(Long postId); | ||
} |
Oops, something went wrong.