-
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.
* fix : 게시글 좋아요 오류 수정 * update : Idea 좋아요 복합키 -> 기본키로 변경
- Loading branch information
Showing
9 changed files
with
63 additions
and
78 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 was deleted.
Oops, something went wrong.
17 changes: 12 additions & 5 deletions
17
src/main/java/kr/co/conceptbe/idea/domain/persistence/IdeaLikesRepository.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,16 +1,23 @@ | ||
package kr.co.conceptbe.idea.domain.persistence; | ||
|
||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import kr.co.conceptbe.idea.domain.IdeaLikeID; | ||
import kr.co.conceptbe.idea.domain.Idea; | ||
import kr.co.conceptbe.idea.domain.IdeaLike; | ||
import kr.co.conceptbe.member.domain.Member; | ||
|
||
@Repository | ||
public interface IdeaLikesRepository extends JpaRepository<IdeaLike, IdeaLikeID> { | ||
public interface IdeaLikesRepository extends JpaRepository<IdeaLike, Long> { | ||
|
||
Optional<IdeaLike> findByMemberAndIdea(Member member, Idea idea); | ||
|
||
void deleteByMemberAndIdea(Member member, Idea idea); | ||
|
||
default IdeaLike getById(IdeaLikeID ideaLikeID) { | ||
return findById(ideaLikeID).orElseThrow( | ||
() -> new IllegalArgumentException("Not Found ID : " + ideaLikeID)); | ||
default IdeaLike getById(Long id) { | ||
return findById(id).orElseThrow( | ||
() -> new IllegalArgumentException("Not Found ID : " + id)); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/kr/co/conceptbe/idea/exception/AlreadyIdeaLikeException.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 kr.co.conceptbe.idea.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
import kr.co.conceptbe.common.exception.ConceptBeException; | ||
import kr.co.conceptbe.common.exception.ErrorCode; | ||
|
||
public class AlreadyIdeaLikeException extends ConceptBeException { | ||
|
||
public AlreadyIdeaLikeException() { super(new ErrorCode(HttpStatus.CONFLICT, "해당 게시글을 이미 '좋아요'했습니다.")); } | ||
} |
11 changes: 0 additions & 11 deletions
11
src/main/java/kr/co/conceptbe/idea/exception/IdeaLikeException.java
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
src/main/java/kr/co/conceptbe/idea/exception/NotFoundIdeaLikeException.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,13 @@ | ||
package kr.co.conceptbe.idea.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
import kr.co.conceptbe.common.exception.ConceptBeException; | ||
import kr.co.conceptbe.common.exception.ErrorCode; | ||
|
||
public class NotFoundIdeaLikeException extends ConceptBeException { | ||
|
||
public NotFoundIdeaLikeException() { | ||
super(new ErrorCode(HttpStatus.NOT_FOUND, "해당 게시글은 '좋아요'하지 않았습니다.")); | ||
} | ||
} |
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