-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: HOT_POST_LIKES_THRESHOLD MagicNumber 등록 * fix: 익명유저일 때 ssafyInfo에 데이터가 들어있는 문제 수정 * fix: GetPostReqDto build추가 * test: report 관련 repository 삭제 * test: 정상적인 BoardId, Cursor, Size가 주어졌다면 게시글 목록 조회가 성공합니다. * test: 존재하지 않은 boardId가 주어졌다면 게시글 목록 조회 실패하는 테스트 코드 구현 * test: 로그인 시 유효한 postId와 loginMemberId가 주어졌다면 게시글 상세 보기가 성공합니다. * test: 비 로그인 시 유효한 postId가 주어졌다면 게시글 상세 보기가 성공합니다. * test: 유효하지 않은 postId가 주어졌다면 게시글 상세보기에 예외를 발생합니다. * test: 로그인 시 유효하지 않은 loginMemberId가 주어졌다면 게시글 상세보기에 예외를 발생합니다. * fix: 유효하지 않은 게시글을 좋아요 하면 예외 처리 추가 * fix: Hot게시글이 중복되어 등록되는 버그 수정 * test: 게시글을 좋아요 하지 않았다면 좋아요가 저장됩니다. * test: 게시글을 이미 좋아요 했다면 좋아요가 취소됩니다. * test: 좋아요가 특정 개수를 달성했다면 Hot 게시글로 등록됩니다. * test: 좋아요가 특정 개수를 달성했지만 이미 Hot 게시글이라면 등록되지 않습니다. * test: 유효하지 않은 postId 또는 loginMemberId가 주어졌다면 게시글 좋아요에 예외를 발생합니다. * fix: 유효하지 않은 게시글을 스크랩했을 때 예외 처리 추가 * test: 게시글을 스크랩 하지 않았다면 스크랩이 저장됩니다. * test: 게시글을 이미 스크랩 했다면 스크랩이 취소됩니다. * test: 유효하지 않은 loginMemberId가 주어졌다면 게시글 스크랩에 예외를 발생합니다. * test: 유효하지 않은 postId가 주어졌다면 게시글 스크랩에 예외를 발생합니다. * fix: commentGroup 수정하는 로직 NativeQuery로 수정
- Loading branch information
Showing
15 changed files
with
910 additions
and
343 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
1 change: 1 addition & 0 deletions
1
src/main/java/com/ssafy/ssafsound/domain/comment/domain/Comment.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
28 changes: 18 additions & 10 deletions
28
src/main/java/com/ssafy/ssafsound/domain/comment/repository/CommentRepository.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,21 +1,29 @@ | ||
package com.ssafy.ssafsound.domain.comment.repository; | ||
|
||
import com.ssafy.ssafsound.domain.comment.domain.Comment; | ||
import org.springframework.data.domain.Pageable; | ||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
import com.ssafy.ssafsound.domain.comment.domain.Comment; | ||
|
||
@Repository | ||
public interface CommentRepository extends JpaRepository<Comment, Long> { | ||
@Query("SELECT c FROM comment c " + | ||
"JOIN FETCH c.commentNumber " + | ||
"JOIN FETCH c.member " + | ||
"JOIN FETCH c.commentGroup g " + | ||
"WHERE c.post.id = :postId " + | ||
"ORDER BY g.id ") | ||
List<Comment> findAllPostIdWithDetailsFetchOrderByCommentGroupId(@Param("postId") Long postId); | ||
@Query("SELECT c FROM comment c " + | ||
"JOIN FETCH c.commentNumber " + | ||
"JOIN FETCH c.member " + | ||
"JOIN FETCH c.commentGroup g " + | ||
"WHERE c.post.id = :postId " + | ||
"ORDER BY g.id ") | ||
List<Comment> findAllPostIdWithDetailsFetchOrderByCommentGroupId(@Param("postId") Long postId); | ||
|
||
@Modifying | ||
@Query(value = "update comment " | ||
+ "set comment_group = :id " | ||
+ "where comment_id = :id", nativeQuery = true) | ||
void updateByCommentGroup(@Param("id") Long id); | ||
|
||
} |
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: 23 additions & 10 deletions
33
src/main/java/com/ssafy/ssafsound/domain/post/domain/HotPost.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,26 +1,39 @@ | ||
package com.ssafy.ssafsound.domain.post.domain; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.OneToOne; | ||
|
||
import com.ssafy.ssafsound.domain.BaseTimeEntity; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity(name="hot_post") | ||
@Entity(name = "hot_post") | ||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class HotPost extends BaseTimeEntity { | ||
|
||
@Id | ||
@Column(name = "hot_post_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@Id | ||
@Column(name = "hot_post_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@OneToOne | ||
@JoinColumn(name = "post_id") | ||
private Post post; | ||
|
||
@OneToOne | ||
@JoinColumn(name = "post_id") | ||
private Post post; | ||
public static HotPost from(Post post) { | ||
return HotPost.builder() | ||
.post(post) | ||
.build(); | ||
} | ||
} |
41 changes: 28 additions & 13 deletions
41
src/main/java/com/ssafy/ssafsound/domain/post/domain/PostLike.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,31 +1,46 @@ | ||
package com.ssafy.ssafsound.domain.post.domain; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
|
||
import com.ssafy.ssafsound.domain.BaseTimeEntity; | ||
import com.ssafy.ssafsound.domain.member.domain.Member; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity(name="post_like") | ||
@Entity(name = "post_like") | ||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class PostLike extends BaseTimeEntity { | ||
|
||
@Id | ||
@Column(name = "post_like_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@Id | ||
@Column(name = "post_like_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "post_id") | ||
private Post post; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "post_id") | ||
private Post post; | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
public static PostLike of(Post post, Member member) { | ||
return PostLike.builder() | ||
.post(post) | ||
.member(member) | ||
.build(); | ||
} | ||
} |
41 changes: 28 additions & 13 deletions
41
src/main/java/com/ssafy/ssafsound/domain/post/domain/PostScrap.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,30 +1,45 @@ | ||
package com.ssafy.ssafsound.domain.post.domain; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
|
||
import com.ssafy.ssafsound.domain.member.domain.Member; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity(name="post_scrap") | ||
@Entity(name = "post_scrap") | ||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class PostScrap { | ||
|
||
@Id | ||
@Column(name = "post_scrap_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@Id | ||
@Column(name = "post_scrap_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "post_id") | ||
private Post post; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "post_id") | ||
private Post post; | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
public static PostScrap of(Post post, Member member) { | ||
return PostScrap.builder() | ||
.post(post) | ||
.member(member) | ||
.build(); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
src/main/java/com/ssafy/ssafsound/domain/post/dto/GetPostReqDto.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
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
14 changes: 14 additions & 0 deletions
14
src/main/java/com/ssafy/ssafsound/domain/post/service/PostConstantProvider.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,14 @@ | ||
package com.ssafy.ssafsound.domain.post.service; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.context.properties.ConstructorBinding; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
@ConfigurationProperties(prefix = "spring.constant.post") | ||
@ConstructorBinding | ||
public class PostConstantProvider { | ||
private final Long HOT_POST_LIKES_THRESHOLD; | ||
} |
Oops, something went wrong.