-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/woowacourse-teams/2024-c…
- Loading branch information
Showing
39 changed files
with
725 additions
and
197 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
|
||
public enum AlarmActionType { | ||
REVIEW_COMPLETE, | ||
REVIEW_URGE, | ||
} |
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
43 changes: 43 additions & 0 deletions
43
backend/src/main/java/corea/matching/infrastructure/PrivateGithubPullRequestClient.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,43 @@ | ||
package corea.matching.infrastructure; | ||
|
||
import corea.auth.infrastructure.GithubPersonalAccessTokenProvider; | ||
import corea.matching.infrastructure.dto.PullRequestResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.client.RestClient; | ||
|
||
import static org.springframework.http.MediaType.APPLICATION_JSON; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class PrivateGithubPullRequestClient { | ||
|
||
private final RestClient restClient; | ||
private final GithubPersonalAccessTokenProvider githubPersonalAccessTokenProvider; | ||
|
||
public PullRequestResponse getPullRequest(String repositoryLink, String username) { | ||
String apiLink = convertApiLink(repositoryLink, username); | ||
log.debug("요청 링크:{}", repositoryLink); | ||
return restClient.get() | ||
.uri(apiLink) | ||
.header(HttpHeaders.AUTHORIZATION, githubPersonalAccessTokenProvider.getRandomPersonalAccessToken()) | ||
.accept(APPLICATION_JSON) | ||
.exchange((clientRequest, clientResponse) -> { | ||
if (clientResponse.getStatusCode().is4xxClientError()) { | ||
return null; | ||
} | ||
PullRequestResponse[] data = clientResponse.bodyTo(PullRequestResponse[].class); | ||
return data.length > 0 ? data[0] : null; | ||
}); | ||
} | ||
|
||
private String convertApiLink(String repositoryLink, String username) { | ||
String[] parts = repositoryLink.substring(8) | ||
.split("/"); | ||
String repoName = parts[2]; | ||
return String.format("https://api.github.com/repos/%s/%s-%s/pulls", username, repoName, username); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
backend/src/main/java/corea/matching/service/PrivatePullRequestProvider.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,38 @@ | ||
package corea.matching.service; | ||
|
||
import corea.matching.domain.PullRequestInfo; | ||
import corea.matching.infrastructure.PrivateGithubPullRequestClient; | ||
import corea.matching.infrastructure.dto.PullRequestResponse; | ||
import corea.member.domain.MemberReader; | ||
import corea.participation.domain.ParticipationReader; | ||
import corea.room.domain.Room; | ||
import corea.room.domain.RoomReader; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class PrivatePullRequestProvider { | ||
|
||
private final PrivateGithubPullRequestClient privateGithubPullRequestClient; | ||
private final RoomReader roomReader; | ||
private final MemberReader memberReader; | ||
private final ParticipationReader participationReader; | ||
|
||
|
||
public PullRequestInfo getEachRepository(long roomId) { | ||
Room room = roomReader.find(roomId); | ||
List<Long> memberIds = participationReader.findRevieweeIdsByRoomId(roomId); | ||
List<String> members = memberReader.findUsernamesByIds(memberIds); | ||
|
||
return new PullRequestInfo(members.stream() | ||
.map(username -> privateGithubPullRequestClient.getPullRequest(room.getRepositoryLink(), username)) | ||
.filter(Objects::nonNull) | ||
.collect(Collectors.toMap(PullRequestResponse::getUserId, Function.identity()))); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package corea.review.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@Schema(description = "리뷰 재촉 요청") | ||
public record UrgeRequest(@Schema(description = "방 아이디", example = "1") | ||
long roomId, | ||
|
||
@Schema(description = "리뷰어 아이디", example = "2") | ||
long reviewerId) { | ||
} |
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
34 changes: 34 additions & 0 deletions
34
backend/src/main/java/corea/room/domain/RoomMatchInfo.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,34 @@ | ||
package corea.room.domain; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.Id; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import static jakarta.persistence.GenerationType.IDENTITY; | ||
|
||
@Entity | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
public class RoomMatchInfo { | ||
|
||
@Id | ||
@GeneratedValue(strategy = IDENTITY) | ||
private Long id; | ||
|
||
private long roomId; | ||
|
||
private boolean isPublic; | ||
|
||
public RoomMatchInfo(final long roomId, final boolean isPublic) { | ||
this(null, roomId, isPublic); | ||
} | ||
|
||
public boolean isPublic() { | ||
return isPublic; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
backend/src/main/java/corea/room/domain/RoomMatchInfoWriter.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,16 @@ | ||
package corea.room.domain; | ||
|
||
import corea.global.annotation.Writer; | ||
import corea.room.repository.RoomMatchInfoRepository; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Writer | ||
@RequiredArgsConstructor | ||
public class RoomMatchInfoWriter { | ||
|
||
private final RoomMatchInfoRepository roomMatchInfoRepository; | ||
|
||
public RoomMatchInfo create(Room room, boolean isPrivate) { | ||
return roomMatchInfoRepository.save(new RoomMatchInfo(room.getId(), isPrivate)); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
backend/src/main/java/corea/room/domain/RoomMatchReader.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,20 @@ | ||
package corea.room.domain; | ||
|
||
import corea.exception.CoreaException; | ||
import corea.exception.ExceptionType; | ||
import corea.global.annotation.Reader; | ||
import corea.room.repository.RoomMatchInfoRepository; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Reader | ||
@RequiredArgsConstructor | ||
public class RoomMatchReader { | ||
|
||
private final RoomMatchInfoRepository roomMatchInfoRepository; | ||
|
||
public boolean isPublicRoom(Room room) { | ||
return roomMatchInfoRepository.findByRoomId(room.getId()) | ||
.map(RoomMatchInfo::isPublic) | ||
.orElse(true); | ||
} | ||
} |
Oops, something went wrong.