diff --git a/api/src/main/java/org/yapp/domain/block/application/DirectBlockService.java b/api/src/main/java/org/yapp/domain/block/application/DirectBlockService.java new file mode 100644 index 0000000..c017141 --- /dev/null +++ b/api/src/main/java/org/yapp/domain/block/application/DirectBlockService.java @@ -0,0 +1,26 @@ +package org.yapp.domain.block.application; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.yapp.application.AuthenticationService; +import org.yapp.domain.block.DirectBlock; +import org.yapp.domain.block.dao.DirectBlockRepository; + +@Service +@RequiredArgsConstructor +public class DirectBlockService { + + private final DirectBlockRepository directBlockRepository; + private final AuthenticationService authenticationService; + + public DirectBlock blockUser(Long blockId) { + Long userId = authenticationService.getUserId(); + return directBlockRepository.save(new DirectBlock(userId, blockId)); + } + + public boolean checkBlock(Long userId, Long partnerId) { + return directBlockRepository.existsDirectBlockByBlockingUserIdAndBlockedUserId(userId, + partnerId); + } + +} diff --git a/api/src/main/java/org/yapp/domain/block/dao/DirectBlockRepository.java b/api/src/main/java/org/yapp/domain/block/dao/DirectBlockRepository.java new file mode 100644 index 0000000..9935875 --- /dev/null +++ b/api/src/main/java/org/yapp/domain/block/dao/DirectBlockRepository.java @@ -0,0 +1,10 @@ +package org.yapp.domain.block.dao; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.yapp.domain.block.DirectBlock; + +public interface DirectBlockRepository extends JpaRepository { + + boolean existsDirectBlockByBlockingUserIdAndBlockedUserId(Long blockingUserId, + Long blockedUserId); +} diff --git a/api/src/main/java/org/yapp/domain/match/application/MatchService.java b/api/src/main/java/org/yapp/domain/match/application/MatchService.java index 3d10662..5eed84f 100644 --- a/api/src/main/java/org/yapp/domain/match/application/MatchService.java +++ b/api/src/main/java/org/yapp/domain/match/application/MatchService.java @@ -3,12 +3,27 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.yapp.application.AuthenticationService; import org.yapp.domain.match.MatchInfo; import org.yapp.domain.match.dao.MatchInfoRepository; +import org.yapp.domain.match.enums.MatchStatus; +import org.yapp.domain.match.presentation.dto.response.MatchInfoResponse; +import org.yapp.domain.match.presentation.dto.response.MatchProfileBasicResponse; +import org.yapp.domain.match.presentation.dto.response.MatchValuePickInnerResponse; +import org.yapp.domain.match.presentation.dto.response.MatchValuePickResponse; +import org.yapp.domain.match.presentation.dto.response.MatchValueTalkInnerResponse; +import org.yapp.domain.match.presentation.dto.response.MatchValueTalkResponse; +import org.yapp.domain.profile.Profile; +import org.yapp.domain.profile.ProfileValuePick; +import org.yapp.domain.profile.ProfileValueTalk; +import org.yapp.domain.profile.application.ProfileValuePickService; import org.yapp.domain.user.User; import org.yapp.domain.user.application.UserService; import org.yapp.error.dto.MatchErrorCode; @@ -20,14 +35,33 @@ public class MatchService { private final MatchInfoRepository matchInfoRepository; private final AuthenticationService authenticationService; + private final ProfileValuePickService profileValuePickService; private final UserService userService; + @Transactional public MatchInfo createMatchInfo(Long user1Id, Long user2Id) { User user1 = userService.getUserById(user1Id); User user2 = userService.getUserById(user2Id); return matchInfoRepository.save(new MatchInfo(LocalDate.now(), user1, user2)); } + @Transactional(readOnly = true) + public MatchProfileBasicResponse getMatchProfileBasic() { + Long userId = authenticationService.getUserId(); + MatchInfo matchInfo = getMatchInfo(userId); + + User matchedUser = getMatchedUser(userId, matchInfo); + Profile matchedProfile = matchedUser.getProfile(); + return MatchProfileBasicResponse.fromProfile(matchInfo.getId(), matchedProfile); + } + + @Transactional + public void checkPiece() { + Long userId = authenticationService.getUserId(); + MatchInfo matchInfo = getMatchInfo(userId); + matchInfo.checkPiece(userId); + } + public LocalDate getMatchDate() { LocalDateTime nowDateTime = LocalDateTime.now(); LocalDate nowDate = nowDateTime.toLocalDate(); @@ -39,14 +73,188 @@ public LocalDate getMatchDate() { return nowDate; } + @Transactional(readOnly = true) public boolean wasUsersMatched(Long user1Id, Long user2Id) { Optional matchInfoByIds = matchInfoRepository.findMatchInfoByIds(user1Id, user2Id); return matchInfoByIds.isPresent(); } - public MatchInfo getMatchInfo() { - Long userId = authenticationService.getUserId(); + @Transactional(readOnly = true) + public MatchInfo getMatchInfo(Long userId) { return matchInfoRepository.findByUserIdAndDate(userId, getMatchDate()) .orElseThrow(() -> new ApplicationException(MatchErrorCode.NOTFOUND_MATCH)); } + + @Transactional(readOnly = true) + public MatchInfoResponse getMatchInfoResponse() { + Long userId = authenticationService.getUserId(); + MatchInfo matchInfo = getMatchInfo(userId); + + User matchedUser = getMatchedUser(userId, matchInfo); + User user = userService.getUserById(userId); + List matchedValues = getMatchedValues(user.getProfile().getId(), + matchedUser.getProfile().getId()); + + //TODO : 왜 deprecated 된 ProfileBio에만 introduce가 있는지 논의가 필요 + MatchInfoResponse response = MatchInfoResponse.builder() + .matchId(matchInfo.getId()) + .matchStatus(getMatchStatus(userId, matchInfo)) + .shortIntroduce("") // Deprecated 된 BIO 에서 넣어야하는지? + .nickname(matchedUser.getProfile().getProfileBasic().getNickname()) + .birthYear( + String.valueOf(matchedUser.getProfile().getProfileBasic().getBirthdate().getYear())) + .location(matchedUser.getProfile().getProfileBasic().getLocation()) + .job(matchedUser.getProfile().getProfileBasic().getJob()) + .matchedValueCount(matchedValues.size()) + .matchedValueList(matchedValues) + .build(); + + return response; + } + + private User getMatchedUser(Long userId, MatchInfo matchInfo) { + if (userId.equals(matchInfo.getUser1().getId())) { + return matchInfo.getUser2(); + } + return matchInfo.getUser1(); + } + + private String getMatchStatus(Long userId, MatchInfo matchInfo) { + if (userId.equals(matchInfo.getUser1().getId())) { + if (!matchInfo.getUser1PieceChecked()) { + return MatchStatus.BEFORE_OPEN.getStatus(); + } + if (matchInfo.getUser1Accepted() && matchInfo.getUser2Accepted()) { + return MatchStatus.MATCHED.getStatus(); + } + if (matchInfo.getUser1Accepted()) { + return MatchStatus.RESPONDED.getStatus(); + } + if (matchInfo.getUser2Accepted()) { + return MatchStatus.GREEN_LIGHT.getStatus(); + } + return MatchStatus.WAITING.getStatus(); + } else { + if (!matchInfo.getUser2PieceChecked()) { + return MatchStatus.BEFORE_OPEN.getStatus(); + } + if (matchInfo.getUser1Accepted() && matchInfo.getUser2Accepted()) { + return MatchStatus.MATCHED.getStatus(); + } + if (matchInfo.getUser2Accepted()) { + return MatchStatus.RESPONDED.getStatus(); + } + if (matchInfo.getUser1Accepted()) { + return MatchStatus.GREEN_LIGHT.getStatus(); + } + return MatchStatus.WAITING.getStatus(); + } + } + + @Transactional(readOnly = true) + public MatchValueTalkResponse getMatchValueTalk() { + Long userId = authenticationService.getUserId(); + MatchInfo matchInfo = getMatchInfo(userId); + User matchedUser = getMatchedUser(userId, matchInfo); + List profileValueTalks = matchedUser.getProfile().getProfileValueTalks(); + List talkResponses = new ArrayList<>(); + for (ProfileValueTalk profileValueTalk : profileValueTalks) { + String summary = profileValueTalk.getSummary(); + String answer = profileValueTalk.getAnswer(); + String category = profileValueTalk.getValueTalk().getCategory(); + talkResponses.add(new MatchValueTalkInnerResponse(category, summary, answer)); + } + return new MatchValueTalkResponse(matchInfo.getId(), "", + matchedUser.getProfile().getProfileBasic().getNickname(), talkResponses); + } + + @Transactional(readOnly = true) + public MatchValuePickResponse getMatchedUserValuePicks() { + Long userId = authenticationService.getUserId(); + User user = userService.getUserById(userId); + MatchInfo matchInfo = getMatchInfo(userId); + User matchedUser = getMatchedUser(userId, matchInfo); + List matchValuePickInnerResponses = getMatchValuePickInnerResponses( + user.getProfile().getId(), matchedUser.getProfile().getId()); + + return new MatchValuePickResponse(matchInfo.getId(), "", + matchedUser.getProfile().getProfileBasic().getNickname(), matchValuePickInnerResponses); + } + + private List getMatchValuePickInnerResponses(Long fromProfileId, + Long toProfileId) { + List profileValuePicksOfFrom = + profileValuePickService.getAllProfileValuesByProfileId(fromProfileId); + List profileValuePicksOfTo = profileValuePickService.getAllProfileValuesByProfileId( + toProfileId); + + List talkInnerResponses = new ArrayList<>(); + int valueListSize = profileValuePicksOfFrom.size(); + for (int i = 0; i < valueListSize; i++) { + ProfileValuePick profileValuePickFrom = profileValuePicksOfFrom.get(i); + ProfileValuePick profileValuePickTo = profileValuePicksOfTo.get(i); + String category = profileValuePickTo.getValuePick().getCategory(); + String question = profileValuePickTo.getValuePick().getQuestion(); + Integer selectedAnswer = profileValuePickTo.getSelectedAnswer(); + Map answers = profileValuePickTo.getValuePick().getAnswers(); + if (profileValuePickTo.getSelectedAnswer().equals(profileValuePickFrom.getSelectedAnswer())) { + talkInnerResponses.add( + new MatchValuePickInnerResponse(category, question, true, answers, selectedAnswer)); + } else { + talkInnerResponses.add( + new MatchValuePickInnerResponse(category, question, false, answers, selectedAnswer) + ); + } + } + return talkInnerResponses; + } + + @Transactional(readOnly = true) + public String getMatchedUserImageUrl() { + Long userId = authenticationService.getUserId(); + MatchInfo matchInfo = getMatchInfo(userId); + User matchedUser = getMatchedUser(userId, matchInfo); + + return matchedUser.getProfile().getProfileBasic().getImageUrl(); + } + + private List getMatchedValues(Long fromProfileId, Long toProfileId) { + List profileValuePicksOfFrom = + profileValuePickService.getAllProfileValuesByProfileId(fromProfileId); + List profileValuePicksOfTo = profileValuePickService.getAllProfileValuesByProfileId( + toProfileId); + + int valueListSize = profileValuePicksOfFrom.size(); + List matchedValues = new ArrayList<>(); + for (int i = 0; i < valueListSize; i++) { + ProfileValuePick profileValuePickOfFrom = profileValuePicksOfFrom.get(i); + ProfileValuePick profileValuePickOfTo = profileValuePicksOfTo.get(i); + if (profileValuePickOfFrom.getSelectedAnswer() + .equals(profileValuePickOfTo.getSelectedAnswer())) { + Integer selectedAnswer = profileValuePickOfTo.getSelectedAnswer(); + Map answers = profileValuePickOfTo.getValuePick().getAnswers(); + String value = (String) answers.get(selectedAnswer); + matchedValues.add(value); + } + } + return matchedValues; + } + + @Transactional + public void acceptMatch() { + Long userId = authenticationService.getUserId(); + MatchInfo matchInfo = getMatchInfo(userId); + matchInfo.acceptPiece(userId); + } + + @Transactional(readOnly = true) + public Map getContacts() { + Long userId = authenticationService.getUserId(); + MatchInfo matchInfo = getMatchInfo(userId); + if (!matchInfo.getUser1Accepted() || !matchInfo.getUser2Accepted()) { + throw new ApplicationException(MatchErrorCode.MATCH_NOT_ACCEPTED); + } + User matchedUser = getMatchedUser(userId, matchInfo); + return matchedUser.getProfile().getProfileBasic().getContacts(); + } } diff --git a/api/src/main/java/org/yapp/domain/match/application/blocker/DirectBlockBasedBlocker.java b/api/src/main/java/org/yapp/domain/match/application/blocker/DirectBlockBasedBlocker.java index ccd8332..1e35930 100644 --- a/api/src/main/java/org/yapp/domain/match/application/blocker/DirectBlockBasedBlocker.java +++ b/api/src/main/java/org/yapp/domain/match/application/blocker/DirectBlockBasedBlocker.java @@ -1,8 +1,17 @@ package org.yapp.domain.match.application.blocker; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; +import org.yapp.domain.block.application.DirectBlockService; + +@Component +@RequiredArgsConstructor public class DirectBlockBasedBlocker implements Blocker { + + private final DirectBlockService directBlockService; + @Override public boolean blocked(Long blockingUserId, Long blockedUserId) { - return false; + return directBlockService.checkBlock(blockingUserId, blockedUserId); } } diff --git a/api/src/main/java/org/yapp/domain/match/presentation/MatchController.java b/api/src/main/java/org/yapp/domain/match/presentation/MatchController.java new file mode 100644 index 0000000..27d9695 --- /dev/null +++ b/api/src/main/java/org/yapp/domain/match/presentation/MatchController.java @@ -0,0 +1,102 @@ +package org.yapp.domain.match.presentation; + +import io.swagger.v3.oas.annotations.Operation; +import java.util.Map; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.yapp.domain.block.application.DirectBlockService; +import org.yapp.domain.match.application.MatchService; +import org.yapp.domain.match.presentation.dto.response.ContactResponse; +import org.yapp.domain.match.presentation.dto.response.ImageUrlResponse; +import org.yapp.domain.match.presentation.dto.response.MatchInfoResponse; +import org.yapp.domain.match.presentation.dto.response.MatchProfileBasicResponse; +import org.yapp.domain.match.presentation.dto.response.MatchValuePickResponse; +import org.yapp.domain.match.presentation.dto.response.MatchValueTalkResponse; +import org.yapp.util.CommonResponse; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/matches") +public class MatchController { + + private final MatchService matchService; + private final DirectBlockService directBlockService; + + @GetMapping("/infos") + @Operation(summary = "매칭 정보 조회", description = "이번 매칭의 정보를 조회합니다.", tags = {"매칭"}) + public ResponseEntity> getMatchInfo() { + MatchInfoResponse matchInfoResponse = matchService.getMatchInfoResponse(); + return ResponseEntity.status(HttpStatus.OK) + .body(CommonResponse.createSuccess(matchInfoResponse)); + } + + @PatchMapping("/pieces/check") + @Operation(summary = "매칭 조각 확인 체크", description = "이번 매칭의 조각을 확인했음을 서버에 알립니다.", tags = {"매칭"}) + public ResponseEntity> checkMatchPiece() { + matchService.checkPiece(); + return ResponseEntity.status(HttpStatus.OK).body(CommonResponse.createSuccessWithNoContent()); + } + + @GetMapping("/profiles/basic") + @Operation(summary = "매칭 프로필 기본정보 확인", description = "매칭 상대의 프로필 기본정보를 확인합니다.", tags = {"매칭"}) + public ResponseEntity> getBasicMatchProfile() { + MatchProfileBasicResponse matchProfileBasic = matchService.getMatchProfileBasic(); + return ResponseEntity.status(HttpStatus.OK) + .body(CommonResponse.createSuccess(matchProfileBasic)); + } + + @GetMapping("/values/talks") + @Operation(summary = "매칭 상대 가치관 톡 확인", description = "매칭 상대의 가치관 톡을 확인합니다.", tags = {"매칭"}) + public ResponseEntity> getMatchTalkValues() { + MatchValueTalkResponse matchValueTalk = matchService.getMatchValueTalk(); + return ResponseEntity.status(HttpStatus.OK).body(CommonResponse.createSuccess(matchValueTalk)); + } + + + @GetMapping("/values/picks") + @Operation(summary = "매칭 상대 가치관 픽 확인", description = "매칭 상대의 가치관 픽을 확인합니다.", tags = {"매칭"}) + public ResponseEntity> getMatchValuePicks() { + MatchValuePickResponse matchValuePickResponse = matchService.getMatchedUserValuePicks(); + return ResponseEntity.status(HttpStatus.OK) + .body(CommonResponse.createSuccess(matchValuePickResponse)); + } + + @GetMapping("/images") + @Operation(summary = "매칭 상대 프로필 이미지 확인", description = "매칭 상대의 프로필 이미지를 확인합니다.", tags = {"매칭"}) + public ResponseEntity> getMatchedUserImages() { + String matchedUserImageUrl = matchService.getMatchedUserImageUrl(); + ImageUrlResponse imageUrlResponse = new ImageUrlResponse(matchedUserImageUrl); + return ResponseEntity.status(HttpStatus.OK) + .body(CommonResponse.createSuccess(imageUrlResponse)); + } + + @PostMapping("/accept") + @Operation(summary = "매칭 수락하기", description = "매칭을 수락합니다.", tags = {"매칭"}) + public ResponseEntity> acceptMatch() { + matchService.acceptMatch(); + return ResponseEntity.status(HttpStatus.OK).body(CommonResponse.createSuccessWithNoContent()); + } + + @GetMapping("/contacts") + @Operation(summary = "매칭 상대 연락처 조회", description = "매칭 상대의 연락처를 조회합니다", tags = {"매칭"}) + public ResponseEntity> getContacts() { + Map contacts = matchService.getContacts(); + ContactResponse contactResponse = new ContactResponse(contacts); + return ResponseEntity.status(HttpStatus.OK).body(CommonResponse.createSuccess(contactResponse)); + } + + @PostMapping("/blocks/users/{userId}") + @Operation(summary = "매칭 상대 차단", description = "매칭 상대를 차단합니다", tags = {"매칭"}) + public ResponseEntity> blockUsers( + @PathVariable(name = "userId") Long userId) { + directBlockService.blockUser(userId); + return ResponseEntity.status(HttpStatus.OK).body(CommonResponse.createSuccessWithNoContent()); + } +} diff --git a/api/src/main/java/org/yapp/domain/match/presentation/dto/response/ContactResponse.java b/api/src/main/java/org/yapp/domain/match/presentation/dto/response/ContactResponse.java new file mode 100644 index 0000000..5cf5e1e --- /dev/null +++ b/api/src/main/java/org/yapp/domain/match/presentation/dto/response/ContactResponse.java @@ -0,0 +1,14 @@ +package org.yapp.domain.match.presentation.dto.response; + +import java.util.Map; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@AllArgsConstructor +@NoArgsConstructor +@Getter +public class ContactResponse { + + private Map contacts; +} \ No newline at end of file diff --git a/api/src/main/java/org/yapp/domain/match/presentation/dto/response/ImageUrlResponse.java b/api/src/main/java/org/yapp/domain/match/presentation/dto/response/ImageUrlResponse.java new file mode 100644 index 0000000..a76b66d --- /dev/null +++ b/api/src/main/java/org/yapp/domain/match/presentation/dto/response/ImageUrlResponse.java @@ -0,0 +1,13 @@ +package org.yapp.domain.match.presentation.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class ImageUrlResponse { + + private String url; +} diff --git a/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchInfoResponse.java b/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchInfoResponse.java new file mode 100644 index 0000000..4ae4a59 --- /dev/null +++ b/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchInfoResponse.java @@ -0,0 +1,35 @@ +package org.yapp.domain.match.presentation.dto.response; + +import java.util.List; + +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +public class MatchInfoResponse { + private Long matchId; + private String matchStatus; + private String shortIntroduce; + private String nickname; + private String birthYear; + private String location; + private String job; + private Integer matchedValueCount; + private List matchedValueList; + + @Builder + public MatchInfoResponse(Long matchId, String matchStatus, String shortIntroduce, String nickname, String birthYear, + String location, String job, Integer matchedValueCount, List matchedValueList) { + this.matchId = matchId; + this.matchStatus = matchStatus; + this.shortIntroduce = shortIntroduce; + this.nickname = nickname; + this.birthYear = birthYear; + this.location = location; + this.job = job; + this.matchedValueCount = matchedValueCount; + this.matchedValueList = matchedValueList; + } +} diff --git a/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchProfileBasicResponse.java b/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchProfileBasicResponse.java new file mode 100644 index 0000000..4afec98 --- /dev/null +++ b/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchProfileBasicResponse.java @@ -0,0 +1,34 @@ +package org.yapp.domain.match.presentation.dto.response; + +import java.time.LocalDate; +import java.time.Period; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.yapp.domain.profile.Profile; + +@NoArgsConstructor +@Getter +@AllArgsConstructor +public class MatchProfileBasicResponse { + + private Long matchId; + private String shortIntroduce; + private String nickname; + private String age; + private String birthYear; + private String location; + private String job; + + public static MatchProfileBasicResponse fromProfile(Long matchId, Profile profile) { + String nickname = profile.getProfileBasic().getNickname(); + LocalDate birthDate = profile.getProfileBasic().getBirthdate(); + LocalDate now = LocalDate.now(); + String age = String.valueOf(Period.between(birthDate, now).getYears()); + String birthYearFormatted = String.valueOf(birthDate.getYear()).substring(2); + String location = profile.getProfileBasic().getLocation(); + String job = profile.getProfileBasic().getJob(); + return new MatchProfileBasicResponse(matchId, "", nickname, birthYearFormatted, age, location, + job); + } +} diff --git a/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchValuePickInnerResponse.java b/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchValuePickInnerResponse.java new file mode 100644 index 0000000..93161e0 --- /dev/null +++ b/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchValuePickInnerResponse.java @@ -0,0 +1,18 @@ +package org.yapp.domain.match.presentation.dto.response; + +import java.util.Map; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@Getter +@AllArgsConstructor +public class MatchValuePickInnerResponse { + + private String category; + private String question; + private Boolean sameWithMe; + private Map answer; + private Integer answerNumber; +} diff --git a/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchValuePickResponse.java b/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchValuePickResponse.java new file mode 100644 index 0000000..4b19559 --- /dev/null +++ b/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchValuePickResponse.java @@ -0,0 +1,17 @@ +package org.yapp.domain.match.presentation.dto.response; + +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Getter +public class MatchValuePickResponse { + + private Long matchId; + private String shortIntroduction; + private String nickname; + private List valuePicks; +} diff --git a/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchValueTalkInnerResponse.java b/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchValueTalkInnerResponse.java new file mode 100644 index 0000000..1f22f31 --- /dev/null +++ b/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchValueTalkInnerResponse.java @@ -0,0 +1,16 @@ +package org.yapp.domain.match.presentation.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Getter +public class MatchValueTalkInnerResponse { + + private String category; + private String summary; + private String answer; + +} diff --git a/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchValueTalkResponse.java b/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchValueTalkResponse.java new file mode 100644 index 0000000..331bfee --- /dev/null +++ b/api/src/main/java/org/yapp/domain/match/presentation/dto/response/MatchValueTalkResponse.java @@ -0,0 +1,17 @@ +package org.yapp.domain.match.presentation.dto.response; + +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Getter +public class MatchValueTalkResponse { + + private Long matchId; + private String shortIntroduction; + private String nickname; + private List valueTalks; +} diff --git a/common/src/main/java/org/yapp/domain/block/DirectBlock.java b/common/src/main/java/org/yapp/domain/block/DirectBlock.java new file mode 100644 index 0000000..34b4759 --- /dev/null +++ b/common/src/main/java/org/yapp/domain/block/DirectBlock.java @@ -0,0 +1,31 @@ +package org.yapp.domain.block; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@NoArgsConstructor +@Getter +@Table(name = "direct_block") +public class DirectBlock { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Long id; + @Column(name = "blocking_user_id") + private Long blockingUserId; + @Column(name = "blocked_user_id") + private Long blockedUserId; + + public DirectBlock(Long blockingUserId, Long blockedUserId) { + this.blockingUserId = blockingUserId; + this.blockedUserId = blockedUserId; + } +} diff --git a/common/src/main/java/org/yapp/domain/match/MatchInfo.java b/common/src/main/java/org/yapp/domain/match/MatchInfo.java index 61afff5..2594ce0 100644 --- a/common/src/main/java/org/yapp/domain/match/MatchInfo.java +++ b/common/src/main/java/org/yapp/domain/match/MatchInfo.java @@ -1,9 +1,5 @@ package org.yapp.domain.match; -import org.yapp.domain.user.User; - -import java.time.LocalDate; - import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; @@ -11,13 +7,16 @@ import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; +import java.time.LocalDate; import lombok.Getter; import lombok.NoArgsConstructor; +import org.yapp.domain.user.User; @Entity @Getter @NoArgsConstructor public class MatchInfo { + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @@ -30,20 +29,20 @@ public class MatchInfo { private User user1; @Column(name = "user_1_piece_checked") - private Boolean user1PieceChecked; + private Boolean user1PieceChecked = false; @Column(name = "user_1_accept") - private Boolean user1Accepted; + private Boolean user1Accepted = false; @ManyToOne @JoinColumn(name = "user_2") private User user2; @Column(name = "user_2_piece_checked") - private Boolean user2PieceChecked; + private Boolean user2PieceChecked = false; @Column(name = "user_2_accept") - private Boolean user2Accepted; + private Boolean user2Accepted = false; public MatchInfo(LocalDate date, User user1, User user2) { this.date = date; @@ -54,4 +53,20 @@ public MatchInfo(LocalDate date, User user1, User user2) { public static MatchInfo createMatchInfo(User user1, User user2) { return new MatchInfo(LocalDate.now(), user1, user2); } + + public void checkPiece(Long userId) { + if (user1.getId().equals(userId)) { + user1PieceChecked = true; + } else { + user2PieceChecked = true; + } + } + + public void acceptPiece(Long userId) { + if (user1.getId().equals(userId)) { + user1Accepted = true; + } else { + user2Accepted = true; + } + } } diff --git a/common/src/main/java/org/yapp/domain/match/enums/MatchStatus.java b/common/src/main/java/org/yapp/domain/match/enums/MatchStatus.java new file mode 100644 index 0000000..9948db4 --- /dev/null +++ b/common/src/main/java/org/yapp/domain/match/enums/MatchStatus.java @@ -0,0 +1,16 @@ +package org.yapp.domain.match.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum MatchStatus { + BEFORE_OPEN("BEFORE OPEN"), + WAITING("WAITING"), + RESPONDED("RESPONDED"), + GREEN_LIGHT("GREEN_LIGHT"), + MATCHED("MATCHED"); + + private final String status; +} diff --git a/common/src/main/java/org/yapp/error/dto/MatchErrorCode.java b/common/src/main/java/org/yapp/error/dto/MatchErrorCode.java index 1c66c1a..5e8da18 100644 --- a/common/src/main/java/org/yapp/error/dto/MatchErrorCode.java +++ b/common/src/main/java/org/yapp/error/dto/MatchErrorCode.java @@ -1,14 +1,14 @@ package org.yapp.error.dto; -import org.springframework.http.HttpStatus; - import lombok.Getter; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; @Getter @RequiredArgsConstructor public enum MatchErrorCode implements ErrorCode { NOTFOUND_MATCH(HttpStatus.NOT_FOUND, "Match not found"), + MATCH_NOT_ACCEPTED(HttpStatus.BAD_REQUEST, "Match not accepted"), ; private final HttpStatus httpStatus;