-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from jisung-in/feature/80-comment-image
[Feature] 의견 등록 시 이미지 업로드 기능 추가
- Loading branch information
Showing
11 changed files
with
275 additions
and
19 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
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
44 changes: 44 additions & 0 deletions
44
src/main/java/com/jisungin/domain/commentimage/CommentImage.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,44 @@ | ||
package com.jisungin.domain.commentimage; | ||
|
||
import com.jisungin.domain.comment.Comment; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Entity | ||
public class CommentImage { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(name = "image_url") | ||
private String imageUrl; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "comment_id") | ||
private Comment comment; | ||
|
||
@Builder | ||
private CommentImage(String imageUrl, Comment comment) { | ||
this.imageUrl = imageUrl; | ||
this.comment = comment; | ||
} | ||
|
||
public static CommentImage createImages(Comment comment, String imageUrl) { | ||
return CommentImage.builder() | ||
.comment(comment) | ||
.imageUrl(imageUrl) | ||
.build(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/jisungin/domain/commentimage/repository/CommentImageRepository.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,20 @@ | ||
package com.jisungin.domain.commentimage.repository; | ||
|
||
import com.jisungin.domain.comment.Comment; | ||
import com.jisungin.domain.commentimage.CommentImage; | ||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface CommentImageRepository extends JpaRepository<CommentImage, Long> { | ||
|
||
@Query( | ||
"select ci.imageUrl from CommentImage ci where ci.comment.id = :commentId" | ||
) | ||
List<String> findByCommentIdWithImageUrl(@Param("commentId") Long commentId); | ||
|
||
List<CommentImage> findByCommentAndImageUrl(Comment comment, String url); | ||
|
||
List<CommentImage> findByComment(Comment comment); | ||
} |
Oops, something went wrong.