-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/woowacourse-teams/2024-corea
- Loading branch information
Showing
151 changed files
with
4,813 additions
and
1,947 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
45 changes: 45 additions & 0 deletions
45
backend/src/main/java/corea/feedback/domain/DevelopFeedbackReader.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,45 @@ | ||
package corea.feedback.domain; | ||
|
||
import corea.exception.CoreaException; | ||
import corea.exception.ExceptionType; | ||
import corea.feedback.dto.FeedbackOutput; | ||
import corea.feedback.repository.DevelopFeedbackRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class DevelopFeedbackReader { | ||
|
||
private final DevelopFeedbackRepository developFeedbackRepository; | ||
|
||
public Map<Long, List<FeedbackOutput>> collectDeliverDevelopFeedback(long feedbackDeliverId) { | ||
return developFeedbackRepository.findAllByDeliverId(feedbackDeliverId) | ||
.stream() | ||
.map(FeedbackOutput::fromDeliver) | ||
.collect(Collectors.groupingBy(FeedbackOutput::roomId)); | ||
} | ||
|
||
public Map<Long, List<FeedbackOutput>> collectReceivedDevelopFeedback(long feedbackReceiverId) { | ||
return developFeedbackRepository.findAllByReceiverId(feedbackReceiverId) | ||
.stream() | ||
.map(FeedbackOutput::fromReceiver) | ||
.collect(Collectors.groupingBy(FeedbackOutput::roomId)); | ||
} | ||
|
||
public DevelopFeedback findById(long feedbackId) { | ||
return developFeedbackRepository.findById(feedbackId) | ||
.orElseThrow(() -> new CoreaException(ExceptionType.FEEDBACK_NOT_FOUND)); | ||
} | ||
|
||
public DevelopFeedback findDevelopFeedback(long roomId, long deliverId, String username) { | ||
return developFeedbackRepository.findByRoomIdAndDeliverIdAndReceiverUsername(roomId, deliverId, username) | ||
.orElseThrow(() -> new CoreaException(ExceptionType.FEEDBACK_NOT_FOUND)); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
backend/src/main/java/corea/feedback/domain/DevelopFeedbackWriter.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,50 @@ | ||
package corea.feedback.domain; | ||
|
||
import corea.exception.CoreaException; | ||
import corea.exception.ExceptionType; | ||
import corea.feedback.dto.DevelopFeedbackUpdateInput; | ||
import corea.feedback.repository.DevelopFeedbackRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class DevelopFeedbackWriter { | ||
|
||
private final DevelopFeedbackRepository developFeedbackRepository; | ||
|
||
public DevelopFeedback create(DevelopFeedback developFeedback, long roomId, long deliverId, long receiverId) { | ||
validateAlreadyExist(roomId, deliverId, receiverId); | ||
log.info("개발 피드백 작성 [방 ID={}, 작성자 ID={}, 수신자 ID={}]", roomId, deliverId, receiverId); | ||
|
||
return developFeedbackRepository.save(developFeedback); | ||
} | ||
|
||
private void validateAlreadyExist(long roomId, long deliverId, long receiverId) { | ||
if (developFeedbackRepository.existsByRoomIdAndDeliverIdAndReceiverId(roomId, deliverId, receiverId)) { | ||
throw new CoreaException(ExceptionType.ALREADY_COMPLETED_FEEDBACK); | ||
} | ||
} | ||
|
||
public void update(DevelopFeedback developFeedback, long deliverId, DevelopFeedbackUpdateInput input) { | ||
validateUpdateAuthority(developFeedback, deliverId); | ||
log.info("개발 피드백 업데이트 [피드백 ID={}, 작성자 ID={}, 요청값={}]", developFeedback.getId(), developFeedback, input); | ||
|
||
developFeedback.update( | ||
input.evaluationPoint(), | ||
input.feedbackKeywords(), | ||
input.feedbackText(), | ||
input.recommendationPoint() | ||
); | ||
} | ||
|
||
private void validateUpdateAuthority(DevelopFeedback developFeedback, long deliverId) { | ||
if (developFeedback.isNotMatchingDeliver(deliverId)) { | ||
throw new CoreaException(ExceptionType.FEEDBACK_UPDATE_AUTHORIZATION_ERROR); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
backend/src/main/java/corea/feedback/domain/SocialFeedbackReader.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,33 @@ | ||
package corea.feedback.domain; | ||
|
||
import corea.feedback.dto.FeedbackOutput; | ||
import corea.feedback.repository.SocialFeedbackRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class SocialFeedbackReader { | ||
|
||
private final SocialFeedbackRepository socialFeedbackRepository; | ||
|
||
public Map<Long, List<FeedbackOutput>> collectDeliverSocialFeedback(long feedbackDeliverId) { | ||
return socialFeedbackRepository.findAllByDeliverId(feedbackDeliverId) | ||
.stream() | ||
.map(FeedbackOutput::fromDeliver) | ||
.collect(Collectors.groupingBy(FeedbackOutput::roomId)); | ||
} | ||
|
||
public Map<Long, List<FeedbackOutput>> collectReceivedSocialFeedback(long feedbackReceiverId) { | ||
return socialFeedbackRepository.findAllByReceiverId(feedbackReceiverId) | ||
.stream() | ||
.map(FeedbackOutput::fromReceiver) | ||
.collect(Collectors.groupingBy(FeedbackOutput::roomId)); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
backend/src/main/java/corea/feedback/dto/DevelopFeedbackCreateRequest.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,41 @@ | ||
package corea.feedback.dto; | ||
|
||
import corea.feedback.domain.DevelopFeedback; | ||
import corea.feedback.util.FeedbackKeywordConverter; | ||
import corea.member.domain.Member; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
import java.util.List; | ||
|
||
@Schema(description = "개발 능력 관련 피드백 작성 요청") | ||
public record DevelopFeedbackCreateRequest(@Schema(description = "리뷰이 아이디", example = "2") | ||
@NotNull | ||
long receiverId, | ||
|
||
@Schema(description = "평가 점수", example = "4") | ||
@NotNull | ||
int evaluationPoint, | ||
|
||
@Schema(description = "선택한 피드백 키워드", example = "[\"코드를 이해하기 쉬웠어요\", \"컨벤션이 잘 지켜졌어요\"]") | ||
@NotNull | ||
List<String> feedbackKeywords, | ||
|
||
@Schema(description = "부가 작성 가능한 피드백 텍스트", example = "처음 자바를 접해봤다고 했는데 생각보다 매우 잘 구성되어 있는 코드였습니다. ...") | ||
String feedbackText, | ||
|
||
@Schema(description = "랭킹에 필요한 추천 점수", example = "2") | ||
int recommendationPoint) { | ||
|
||
public DevelopFeedback toEntity(long roomId, Member deliver, Member receiver) { | ||
return new DevelopFeedback( | ||
roomId, | ||
deliver, | ||
receiver, | ||
evaluationPoint, | ||
FeedbackKeywordConverter.convertToKeywords(feedbackKeywords), | ||
feedbackText, | ||
recommendationPoint | ||
); | ||
} | ||
} |
37 changes: 0 additions & 37 deletions
37
backend/src/main/java/corea/feedback/dto/DevelopFeedbackRequest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.