-
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.
Browse files
Browse the repository at this point in the history
[FEAT] 답변 공감 기능
- Loading branch information
Showing
10 changed files
with
125 additions
and
20 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
20 changes: 20 additions & 0 deletions
20
plu-api/src/main/kotlin/com/th/plu/api/service/like/LikeValidator.kt
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.th.plu.api.service.like | ||
|
||
import com.th.plu.common.exception.code.ErrorCode | ||
import com.th.plu.common.exception.model.ConflictException | ||
import com.th.plu.domain.domain.answer.Answer | ||
import com.th.plu.domain.domain.like.repository.LikeRepository | ||
import com.th.plu.domain.domain.member.Member | ||
import com.th.plu.domain.domain.question.Question | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class LikeValidator( | ||
private val likeRepository: LikeRepository | ||
) { | ||
fun validateNotExistLike(member: Member, answer: Answer, question: Question) { | ||
if (likeRepository.existByMemberAndAnswerAndQuestion(member = member, answer = answer, question = question)) { | ||
throw ConflictException(ErrorCode.CONFLICT_LIKE_EXCEPTION, "이미 회원(ID: ${member.id}은 해당 답변(ID: ${answer.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
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
20 changes: 20 additions & 0 deletions
20
plu-domain/src/main/kotlin/com/th/plu/domain/domain/like/explorer/LikeExplorer.kt
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.th.plu.domain.domain.like.explorer | ||
|
||
import com.th.plu.common.exception.code.ErrorCode | ||
import com.th.plu.common.exception.model.NotFoundException | ||
import com.th.plu.domain.domain.answer.Answer | ||
import com.th.plu.domain.domain.like.Like | ||
import com.th.plu.domain.domain.like.repository.LikeRepository | ||
import com.th.plu.domain.domain.member.Member | ||
import com.th.plu.domain.domain.question.Question | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class LikeExplorer( | ||
private val likeRepository: LikeRepository | ||
) { | ||
fun findLikeByMemberAndAnswerAndQuestion(member: Member, answer: Answer, question: Question): Like { | ||
return likeRepository.findLikeByMemberAndAnswerAndQuestion(member = member, answer = answer, question = question) | ||
?: throw NotFoundException(ErrorCode.NOT_FOUND_LIKE_EXCEPTION, "존재하지 않는 공감 입니다") | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
plu-domain/src/main/kotlin/com/th/plu/domain/domain/like/repository/LikeRepository.kt
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,7 +1,7 @@ | ||
package com.th.plu.domain.domain.like.repository | ||
|
||
import com.th.plu.domain.domain.member.Member | ||
import com.th.plu.domain.domain.like.Like | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
|
||
interface LikeRepository : JpaRepository<Member, Long>, LikeRepositoryCustom { | ||
interface LikeRepository : JpaRepository<Like, Long>, LikeRepositoryCustom { | ||
} |
7 changes: 7 additions & 0 deletions
7
plu-domain/src/main/kotlin/com/th/plu/domain/domain/like/repository/LikeRepositoryCustom.kt
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 com.th.plu.domain.domain.like.repository | ||
|
||
import com.th.plu.domain.domain.answer.Answer | ||
import com.th.plu.domain.domain.like.Like | ||
import com.th.plu.domain.domain.member.Member | ||
import com.th.plu.domain.domain.question.Question | ||
|
||
interface LikeRepositoryCustom { | ||
|
||
fun findLikeById(id: Long): Like? | ||
|
||
fun existByMemberAndAnswerAndQuestion(member: Member, answer: Answer, question: Question): Boolean | ||
|
||
fun findLikeByMemberAndAnswerAndQuestion(member: Member, answer: Answer, question: Question): Like? | ||
} |
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