Skip to content

Commit

Permalink
Merge pull request #655 from woowacourse-teams/develop
Browse files Browse the repository at this point in the history
코레아 1.22v 배포
  • Loading branch information
pp449 authored Oct 22, 2024
2 parents 1bd4df4 + 18604e7 commit 97f996d
Show file tree
Hide file tree
Showing 107 changed files with 1,368 additions and 705 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import corea.auth.dto.GithubAuthRequest;
import corea.auth.dto.GithubAuthResponse;
import corea.auth.dto.GithubPullRequestReview;
import corea.auth.dto.GithubUserInfo;
import corea.exception.CoreaException;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -59,13 +58,4 @@ public GithubUserInfo getUserInfo(String accessToken) {
.retrieve()
.body(GithubUserInfo.class);
}

public GithubPullRequestReview[] getReviewLink(String prLink) {
String url = GithubPullRequestUrlExchanger.pullRequestUrlToReview(prLink);
return restClient.get()
.uri(url)
.accept(APPLICATION_JSON)
.retrieve()
.body(GithubPullRequestReview[].class);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package corea.auth.service;

import corea.auth.dto.GithubPullRequestReview;
import corea.auth.dto.GithubUserInfo;
import corea.auth.infrastructure.GithubOAuthClient;
import lombok.RequiredArgsConstructor;
Expand All @@ -16,8 +15,4 @@ public GithubUserInfo getUserInfo(String code) {
String accessToken = githubOAuthClient.getAccessToken(code);
return githubOAuthClient.getUserInfo(accessToken);
}

public GithubPullRequestReview[] getPullRequestReview(String prLink) {
return githubOAuthClient.getReviewLink(prLink);
}
}
2 changes: 1 addition & 1 deletion backend/src/main/java/corea/exception/ExceptionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public enum ExceptionType {
TOKEN_EXPIRED(HttpStatus.UNAUTHORIZED, "토큰이 만료되었습니다."),
INVALID_TOKEN(HttpStatus.UNAUTHORIZED, "토큰이 올바르지 않습니다."),
AUTHORIZATION_ERROR(HttpStatus.UNAUTHORIZED, "인증에 실패했습니다."),
ROOM_DELETION_AUTHORIZATION_ERROR(HttpStatus.UNAUTHORIZED, "방 삭제 권한이 없습니다. 방 생성자만 방을 삭제할 수 있습니다."),
ROOM_MODIFY_AUTHORIZATION_ERROR(HttpStatus.UNAUTHORIZED, "방 정보 변경 권한이 없습니다. 방 생성자만 방 정보를 변경할 수 있습니다."),
FEEDBACK_UPDATE_AUTHORIZATION_ERROR(HttpStatus.UNAUTHORIZED, "피드백 수정 권한이 없습니다. 피드백 작성자만 피드백을 수정할 수 있습니다."),

MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "해당 멤버를 찾을 수 없습니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import corea.auth.annotation.LoginMember;
import corea.auth.domain.AuthInfo;
import corea.feedback.dto.SocialFeedbackRequest;
import corea.feedback.dto.SocialFeedbackCreateRequest;
import corea.feedback.dto.SocialFeedbackResponse;
import corea.feedback.dto.SocialFeedbackUpdateRequest;
import corea.feedback.service.SocialFeedbackService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
Expand All @@ -16,25 +17,29 @@ public class SocialFeedbackController implements SocialFeedbackControllerSpecifi

private final SocialFeedbackService socialFeedbackService;

@Override
@PostMapping
public ResponseEntity<Void> create(@PathVariable long roomId, @LoginMember AuthInfo authInfo, @RequestBody SocialFeedbackRequest request) {
public ResponseEntity<Void> create(@PathVariable long roomId,
@LoginMember AuthInfo authInfo,
@RequestBody SocialFeedbackCreateRequest request) {
socialFeedbackService.create(roomId, authInfo.getId(), request);
return ResponseEntity.ok()
.build();
}

@Override
@GetMapping
public ResponseEntity<SocialFeedbackResponse> socialFeedback(@PathVariable long roomId, @RequestParam String username, @LoginMember AuthInfo authInfo) {
public ResponseEntity<SocialFeedbackResponse> socialFeedback(@PathVariable long roomId,
@RequestParam String username,
@LoginMember AuthInfo authInfo) {
SocialFeedbackResponse response = socialFeedbackService.findSocialFeedback(roomId, authInfo.getId(), username);
return ResponseEntity.ok()
.body(response);
}

@Override
@PutMapping("/{feedbackId}")
public ResponseEntity<Void> update(@PathVariable long roomId, @PathVariable long feedbackId, @LoginMember AuthInfo authInfo, @RequestBody SocialFeedbackRequest request) {
public ResponseEntity<Void> update(@PathVariable long roomId,
@PathVariable long feedbackId,
@LoginMember AuthInfo authInfo,
@RequestBody SocialFeedbackUpdateRequest request) {
socialFeedbackService.update(feedbackId, authInfo.getId(), request);
return ResponseEntity.ok()
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import corea.auth.domain.AuthInfo;
import corea.exception.ExceptionType;
import corea.feedback.dto.SocialFeedbackRequest;
import corea.feedback.dto.SocialFeedbackCreateRequest;
import corea.feedback.dto.SocialFeedbackResponse;
import corea.feedback.dto.SocialFeedbackUpdateRequest;
import corea.global.annotation.ApiErrorResponses;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand All @@ -25,7 +26,7 @@ public interface SocialFeedbackControllerSpecification {
ResponseEntity<Void> create(@Parameter(description = "방 아이디", example = "1")
long roomId,
AuthInfo authInfo,
SocialFeedbackRequest request);
SocialFeedbackCreateRequest request);

@Operation(summary = "커뮤니케이션 관련 피드백을 반환합니다.",
description = "자신에게 사람들이 남긴 커뮤니케이션 능력 관련 피드백을 반환합니다. <br>" +
Expand Down Expand Up @@ -58,5 +59,5 @@ ResponseEntity<Void> update(@Parameter(description = "방 아이디", example =
@Parameter(description = "피드백 아이디", example = "2")
long feedbackId,
AuthInfo authInfo,
SocialFeedbackRequest request);
SocialFeedbackUpdateRequest request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private void validateAlreadyExist(long roomId, long deliverId, long receiverId)

public void update(DevelopFeedback developFeedback, long deliverId, DevelopFeedbackUpdateInput input) {
validateUpdateAuthority(developFeedback, deliverId);
log.info("개발 피드백 업데이트 [피드백 ID={}, 작성자 ID={}, 요청값={}]", developFeedback.getId(), developFeedback, input);
log.info("개발 피드백 업데이트 [피드백 ID={}, 작성자 ID={}, 요청값={}]", developFeedback.getId(), deliverId, input);

developFeedback.update(
input.evaluationPoint(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public SocialFeedback(long roomId, Member deliver, Member receiver, int evaluate
this(null, roomId, deliver, receiver, evaluatePoint, keywords, feedBackText);
}

public boolean isNotMatchingDeliver(long deliverId) {
return deliver.isNotMatchingId(deliverId);
}

public void update(int evaluationPoint, List<String> feedbackKeywords, String feedbackText) {
this.evaluatePoint = evaluationPoint;
this.keywords = FeedbackKeywordConverter.convertToKeywords(feedbackKeywords);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package corea.feedback.domain;

import corea.exception.CoreaException;
import corea.exception.ExceptionType;
import corea.feedback.dto.FeedbackOutput;
import corea.feedback.repository.SocialFeedbackRepository;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -30,4 +32,14 @@ public Map<Long, List<FeedbackOutput>> collectReceivedSocialFeedback(long feedba
.map(FeedbackOutput::fromReceiver)
.collect(Collectors.groupingBy(FeedbackOutput::roomId));
}

public SocialFeedback findById(long feedbackId) {
return socialFeedbackRepository.findById(feedbackId)
.orElseThrow(() -> new CoreaException(ExceptionType.FEEDBACK_NOT_FOUND));
}

public SocialFeedback findSocialFeedback(long roomId, long deliverId, String username) {
return socialFeedbackRepository.findByRoomIdAndDeliverIdAndReceiverUsername(roomId, deliverId, username)
.orElseThrow(() -> new CoreaException(ExceptionType.FEEDBACK_NOT_FOUND));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package corea.feedback.domain;

import corea.exception.CoreaException;
import corea.exception.ExceptionType;
import corea.feedback.dto.SocialFeedbackUpdateInput;
import corea.feedback.repository.SocialFeedbackRepository;
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 SocialFeedbackWriter {

private final SocialFeedbackRepository socialFeedbackRepository;

public SocialFeedback create(SocialFeedback socialFeedback, long roomId, long deliverId, long receiverId) {
validateAlreadyExist(roomId, deliverId, receiverId);
log.info("소셜 피드백 작성 [방 ID={}, 작성자 ID={}, 수신자 ID={}]", roomId, deliverId, receiverId);

return socialFeedbackRepository.save(socialFeedback);
}

private void validateAlreadyExist(long roomId, long deliverId, long receiverId) {
if (socialFeedbackRepository.existsByRoomIdAndDeliverIdAndReceiverId(roomId, deliverId, receiverId)) {
throw new CoreaException(ExceptionType.ALREADY_COMPLETED_FEEDBACK);
}
}

public void update(SocialFeedback socialFeedback, long deliverId, SocialFeedbackUpdateInput input) {
validateUpdateAuthority(socialFeedback, deliverId);
log.info("소셜 피드백 업데이트 [피드백 ID={}, 작성자 ID={}, 요청값={}]", socialFeedback.getId(), deliverId, input);

socialFeedback.update(
input.evaluationPoint(),
input.feedbackKeywords(),
input.feedbackText()
);
}

private void validateUpdateAuthority(SocialFeedback socialFeedback, long deliverId) {
if (socialFeedback.isNotMatchingDeliver(deliverId)) {
throw new CoreaException(ExceptionType.FEEDBACK_UPDATE_AUTHORIZATION_ERROR);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package corea.feedback.dto;

import corea.feedback.domain.SocialFeedback;
import corea.feedback.util.FeedbackKeywordConverter;
import corea.member.domain.Member;
import io.swagger.v3.oas.annotations.media.Schema;

import java.util.List;

@Schema(description = "커뮤니케이션 능력 관련 피드백 작성 요청")
public record SocialFeedbackCreateRequest(@Schema(description = "리뷰어 아이디", example = "2")
long receiverId,

@Schema(description = "평가 점수", example = "4")
int evaluationPoint,

@Schema(description = "선택한 피드백 키워드", example = "[\"이해가 잘 되게 설명을 잘해줘요(못해줘요)\", \"도움이 되었어요(아니에요)\"]")
List<String> feedbackKeywords,

@Schema(description = "부가 작성 가능한 피드백 텍스트", example = "말투가 너무 날카로운 것 같아요. ...")
String feedbackText) {

public SocialFeedback toEntity(long roomId, Member deliver, Member receiver) {
return new SocialFeedback(
null,
roomId,
deliver,
receiver,
evaluationPoint,
FeedbackKeywordConverter.convertToKeywords(feedbackKeywords),
feedbackText
);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package corea.feedback.dto;

import io.swagger.v3.oas.annotations.media.Schema;

import java.util.List;

@Schema(description = "커뮤니케이션 능력 관련 피드백 업데이트 요청")
public record SocialFeedbackUpdateInput(@Schema(description = "업데이트할 평가 점수", example = "4")
int evaluationPoint,

@Schema(description = "업데이트할 피드백 키워드", example = "[\"이해가 잘 되게 설명을 잘해줘요(못해줘요)\", \"도움이 되었어요(아니에요)\"]")
List<String> feedbackKeywords,

@Schema(description = "업데이트할 피드백 텍스트", example = "말투가 너무 날카로운 것 같아요. ...")
String feedbackText) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package corea.feedback.dto;

import io.swagger.v3.oas.annotations.media.Schema;

import java.util.List;

@Schema(description = "커뮤니케이션 능력 관련 피드백 업데이트 요청")
public record SocialFeedbackUpdateRequest(@Schema(description = "업데이트할 평가 점수", example = "4")
int evaluationPoint,

@Schema(description = "업데이트할 피드백 키워드", example = "[\"이해가 잘 되게 설명을 잘해줘요(못해줘요)\", \"도움이 되었어요(아니에요)\"]")
List<String> feedbackKeywords,

@Schema(description = "업데이트할 피드백 텍스트", example = "말투가 너무 날카로운 것 같아요. ...")
String feedbackText) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import corea.feedback.dto.DevelopFeedbackResponse;
import corea.feedback.dto.DevelopFeedbackUpdateInput;
import corea.feedback.dto.DevelopFeedbackUpdateRequest;
import corea.feedback.util.FeedbackMapper;
import corea.matchresult.domain.MatchResult;
import corea.matchresult.domain.MatchResultWriter;
import lombok.RequiredArgsConstructor;
Expand All @@ -22,6 +21,7 @@ public class DevelopFeedbackService {
private final DevelopFeedbackReader developFeedbackReader;
private final DevelopFeedbackWriter developFeedbackWriter;
private final MatchResultWriter matchResultWriter;
private final FeedbackMapper feedbackMapper;

@Transactional
public DevelopFeedbackResponse create(long roomId, long deliverId, DevelopFeedbackCreateRequest request) {
Expand All @@ -37,7 +37,7 @@ public DevelopFeedbackResponse create(long roomId, long deliverId, DevelopFeedba
public DevelopFeedbackResponse update(long feedbackId, long deliverId, DevelopFeedbackUpdateRequest request) {
DevelopFeedback developFeedback = developFeedbackReader.findById(feedbackId);

DevelopFeedbackUpdateInput input = FeedbackMapper.toFeedbackInput(request);
DevelopFeedbackUpdateInput input = feedbackMapper.toFeedbackInput(request);
developFeedbackWriter.update(developFeedback, deliverId, input);

return DevelopFeedbackResponse.from(developFeedback);
Expand Down
Loading

0 comments on commit 97f996d

Please sign in to comment.