Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] feat: 리뷰이 / 리뷰어 조회 기능 구현 (#5) #20

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions backend/src/main/java/corea/DataInitializer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package corea;

import corea.domain.Member;
import corea.domain.Participation;
import corea.domain.Room;
import corea.repository.MemberRepository;
import corea.repository.ParticipationRepository;
import corea.repository.RoomRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;

@Component
@RequiredArgsConstructor
public class DataInitializer implements CommandLineRunner {
private final MemberRepository memberRepository;
private final RoomRepository roomRepository;
private final ParticipationRepository participationRepository;

@Override
public void run(final String... args) throws Exception {
final var members = memberRepository.saveAll(List.of(
new Member("[email protected]", "뽀로로"),
new Member("[email protected]", "애쉬"),
new Member("[email protected]", "무빙"),
new Member("[email protected]", "조이썬썬"),
new Member("[email protected]", "팔팔"),
new Member("[email protected]", "초코"),
new Member("[email protected]", "다르"),
new Member("[email protected]", "포비")
));

final Room room = new Room(
"레이싱 카와 함께하는 TDD",
members.get(0)
.getId(),
"https://github.com/jcoding-play/java-racingcar",
"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3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ime.now()
.plusDays(14)
);
roomRepository.save(room);

participationRepository.saveAll(
List.of(
new Participation(room.getId(),members.get(0).getId()),
new Participation(room.getId(),members.get(1).getId()),
new Participation(room.getId(),members.get(2).getId()),
new Participation(room.getId(),members.get(3).getId()),
new Participation(room.getId(),members.get(4).getId()),
new Participation(room.getId(),members.get(5).getId()),
new Participation(room.getId(),members.get(6).getId()),
new Participation(room.getId(),members.get(7).getId())

));
}
}
5 changes: 3 additions & 2 deletions backend/src/main/java/corea/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ public class Member {
private Long id;

private String email;
private String name;

public Member(final String email) {
this(null, email);
public Member(final String email, final String name) {
this(null,email,name);
}
}
4 changes: 4 additions & 0 deletions backend/src/main/java/corea/dto/ApiResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package corea.dto;

public record ApiResponse(String message) {
}
6 changes: 6 additions & 0 deletions backend/src/main/java/corea/dto/MatchedGroupResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package corea.dto;

import java.util.List;

public record MatchedGroupResponse(List<String> emails) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package corea.member.controller;

import corea.dto.ApiResponse;
import corea.dto.MatchedGroupResponse;
import corea.member.service.MatchService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
public class MemberController {
private final MatchService matchService;

@GetMapping("/my/reviewer")
public MatchedGroupResponse getMyReviewer(@RequestHeader("Authorization") final String email) {
return matchService.getMatchedGroup(email);
}

@GetMapping("/my/reviewee")
public MatchedGroupResponse getMyReviewee(@RequestHeader("Authorization") final String email) {
return matchService.getMatchedGroup(email);
}

@PostMapping("/match/{roomId}")
public ApiResponse match(@PathVariable final long roomId) {
matchService.match(roomId);
return new ApiResponse("GOOD");
}
}
8 changes: 3 additions & 5 deletions backend/src/main/java/corea/member/domain/Matching.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package corea.member.domain;

import corea.domain.Member;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;

Expand All @@ -13,18 +12,17 @@
@NoArgsConstructor(access = PROTECTED)
public class Matching {

public Map<Long, List<Long>> matchGroup(final List<Member> members, final int matchingSize) {
public Map<Long, List<Long>> matchGroup(final List<Long> memberIds, final int matchingSize) {
final Map<Long, List<Long>> matchedGroup = new HashMap<>();

final List<Long> memberIds = new ArrayList<>(members.stream().map(Member::getId).toList());
Collections.shuffle(memberIds);

final List<List<Long>> groupedMemberIds = IntStream.range(0, (members.size() + matchingSize - 1) / matchingSize)
final List<List<Long>> groupedMemberIds = IntStream.range(0, (memberIds.size() + matchingSize - 1) / matchingSize)
.mapToObj(i -> memberIds.subList(i * matchingSize, Math.min(i * matchingSize + matchingSize, memberIds.size())))
.toList();

long groupId = 1L;
for (List<Long> l : groupedMemberIds) {
for (final List<Long> l : groupedMemberIds) {
matchedGroup.put(groupId++, l);
}

Expand Down
5 changes: 5 additions & 0 deletions backend/src/main/java/corea/member/entity/MatchedGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import static jakarta.persistence.GenerationType.IDENTITY;
Expand All @@ -12,6 +13,7 @@
@Entity
@NoArgsConstructor(access = PROTECTED)
@AllArgsConstructor
@Getter
public class MatchedGroup {

@Id
Expand All @@ -25,4 +27,7 @@ public class MatchedGroup {
public MatchedGroup(final Long groupId, final Long memberId) {
this(null, groupId, memberId);
}
public boolean isEqualMember(final long memberId){
return this.memberId.equals(memberId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.Optional;

public interface MatchedGroupRepository extends JpaRepository<MatchedGroup, Long> {

Long findGroupIdByMemberId(final Long memberId);
Optional<MatchedGroup> findOneByMemberId(final long memberId);

List<Long> findMemberIdsByGroupId(final Long groupId);
List<MatchedGroup> findByGroupId(final long groupId);
}
53 changes: 53 additions & 0 deletions backend/src/main/java/corea/member/service/MatchService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package corea.member.service;

import corea.domain.Member;
import corea.domain.Participation;
import corea.dto.MatchedGroupResponse;
import corea.member.entity.MatchedGroup;
import corea.member.repository.MatchedGroupRepository;
import corea.repository.MemberRepository;
import corea.repository.ParticipationRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class MatchService {
private final MatchingService matchingService;
private final ParticipationRepository participationRepository;
private final MatchedGroupRepository matchedGroupRepository;
private final MemberRepository memberRepository;

public void match(final long roomId) {
final List<Participation> participations = participationRepository.findAllByRoomId(roomId);

matchingService.matchMaking(participations, 2);
}

public MatchedGroupResponse getMatchedGroup(final String email) {
final Member member = memberRepository.findByEmail(email)
.orElseThrow(() -> new IllegalArgumentException(String.format("%s는 없는 이메일입니다.", email)));

final MatchedGroup matchedGroup = matchedGroupRepository.findOneByMemberId(member.getId())
.orElseThrow(IllegalArgumentException::new);

final List<Long> memberIds = matchedGroupRepository.findByGroupId(matchedGroup.getGroupId())
.stream()
.filter(matching -> !matching.isEqualMember(member.getId()))
.map(MatchedGroup::getMemberId)
.toList();



final List<String> memberEmails =
memberIds.stream()
.map(id -> memberRepository.findById(id)
.orElse(null))
.map(Member::getEmail)
.toList();

return new MatchedGroupResponse(memberEmails);
}
}
Loading
Loading