-
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 #64 from DSM-Repo/feedback-confirm-service
pr: 피드백 수락 API 추가
- Loading branch information
Showing
8 changed files
with
71 additions
and
10 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
31 changes: 31 additions & 0 deletions
31
...ain/java/com/example/whopper/domain/feedback/application/impl/ConfirmFeedbackService.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,31 @@ | ||
package com.example.whopper.domain.feedback.application.impl; | ||
|
||
import com.example.whopper.domain.feedback.application.usecase.ConfirmFeedbackUseCase; | ||
import com.example.whopper.domain.feedback.dao.FeedbackMongoRepository; | ||
import com.example.whopper.domain.feedback.exception.FeedbackNotFoundException; | ||
import com.example.whopper.global.error.exception.ForbiddenException; | ||
import com.example.whopper.global.utils.current.CurrentStudent; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ConfirmFeedbackService implements ConfirmFeedbackUseCase { | ||
private final FeedbackMongoRepository feedbackMongoRepository; | ||
private final CurrentStudent currentStudent; | ||
|
||
@Override | ||
public void confirm(String id) { | ||
var feedback = feedbackMongoRepository.findById(id) | ||
.orElseThrow(() -> FeedbackNotFoundException.EXCEPTION); | ||
|
||
var currentDocument = currentStudent.getDocument(); | ||
|
||
if (!currentDocument.getId().equals(feedback.getDocumentId())) { | ||
throw ForbiddenException.EXCEPTION; | ||
} | ||
|
||
feedback.confirmed(); | ||
feedbackMongoRepository.save(feedback); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
.../java/com/example/whopper/domain/feedback/application/usecase/ConfirmFeedbackUseCase.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,5 @@ | ||
package com.example.whopper.domain.feedback.application.usecase; | ||
|
||
public interface ConfirmFeedbackUseCase { | ||
void confirm(String 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
6 changes: 3 additions & 3 deletions
6
src/main/java/com/example/whopper/domain/feedback/dto/FeedbackResponse.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,15 +1,15 @@ | ||
package com.example.whopper.domain.feedback.dto; | ||
|
||
import com.example.whopper.domain.document.domain.DocumentEntity; | ||
import com.example.whopper.domain.document.domain.element.type.DocumentElementType; | ||
import com.example.whopper.domain.feedback.domain.FeedbackEntity; | ||
|
||
public record FeedbackResponse( | ||
String id, | ||
DocumentElementType type, | ||
String comment | ||
String comment, | ||
String status | ||
) { | ||
public FeedbackResponse(FeedbackEntity feedback) { | ||
this(feedback.getId(), feedback.getType(), feedback.getComment()); | ||
this(feedback.getId(), feedback.getType(), feedback.getComment(), String.valueOf(feedback.getStatus())); | ||
} | ||
} |
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
9 changes: 9 additions & 0 deletions
9
src/main/java/com/example/whopper/global/error/exception/ForbiddenException.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,9 @@ | ||
package com.example.whopper.global.error.exception; | ||
|
||
public class ForbiddenException extends WhopperException { | ||
public static final WhopperException EXCEPTION = new ForbiddenException(); | ||
|
||
private ForbiddenException() { | ||
super(ErrorCode.FORBIDDEN); | ||
} | ||
} |