-
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.
✨: feat 나만 보기 답변에 대해 답변 소유권 검증 로직 추가 #28
- Loading branch information
Showing
4 changed files
with
31 additions
and
4 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
21 changes: 21 additions & 0 deletions
21
plu-api/src/main/kotlin/com/th/plu/api/service/answer/AnswerValidator.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,21 @@ | ||
package com.th.plu.api.service.answer | ||
|
||
import com.th.plu.common.exception.code.ErrorCode | ||
import com.th.plu.common.exception.model.ValidationException | ||
import com.th.plu.domain.domain.answer.explorer.AnswerExplorer | ||
import com.th.plu.domain.domain.answer.repository.AnswerRepository | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class AnswerValidator( | ||
private val answerExplorer: AnswerExplorer, | ||
private val answerRepository: AnswerRepository | ||
) { | ||
fun validateIsMemberOwnerOfAnswer(answerId: Long, memberId: Long) { | ||
val answer = answerExplorer.findAnswerById(answerId) | ||
if (answer.member.id != memberId) { | ||
throw ValidationException(ErrorCode.INVALID_ANSWER_OWNER, | ||
"멤버 (ID: ${memberId})는 답변 (ID: ${answerId})의 답변자가 아니기 때문에 답변 정보에 접근할 수 없습니다.") | ||
} | ||
} | ||
} |
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