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

[PC-612] 매칭 차단 정보 추가 #61

Merged
merged 6 commits into from
Feb 16, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,33 @@

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.yapp.core.auth.AuthenticationService;
import org.springframework.transaction.annotation.Transactional;
import org.yapp.core.domain.block.DirectBlock;
import org.yapp.core.domain.match.MatchInfo;
import org.yapp.core.exception.ApplicationException;
import org.yapp.core.exception.error.code.MatchErrorCode;
import org.yapp.domain.block.dao.DirectBlockRepository;
import org.yapp.domain.match.dao.MatchInfoRepository;

@Service
@RequiredArgsConstructor
public class DirectBlockService {

private final DirectBlockRepository directBlockRepository;
private final AuthenticationService authenticationService;
private final MatchInfoRepository matchInfoRepository;

public DirectBlock blockUser(Long blockId) {
Long userId = authenticationService.getUserId();
@Transactional
public DirectBlock blockMatchedUser(Long userId, Long matchId) {
MatchInfo matchInfo = matchInfoRepository.findById(matchId)
.orElseThrow(() -> new ApplicationException(MatchErrorCode.NOTFOUND_MATCH));

matchInfo.blockMatch(userId);

return blockUser(userId, matchInfo.getPartnerUserId(userId));
}

@Transactional
public DirectBlock blockUser(Long userId, Long blockId) {
return directBlockRepository.save(new DirectBlock(userId, blockId));
}

Expand Down
451 changes: 228 additions & 223 deletions api/src/main/java/org/yapp/domain/match/application/MatchService.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,91 +31,92 @@
@RequestMapping("/api/matches")
public class MatchController {

private final MatchService matchService;
private final DirectBlockService directBlockService;
private final MatchService matchService;
private final DirectBlockService directBlockService;

@GetMapping("/infos")
@Operation(summary = "매칭 정보 조회", description = "이번 매칭의 정보를 조회합니다.", tags = {"매칭"})
public ResponseEntity<CommonResponse<MatchInfoResponse>> getMatchInfo() {
MatchInfoResponse matchInfoResponse = matchService.getMatchInfoResponse();
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccess(matchInfoResponse));
}
@GetMapping("/infos")
@Operation(summary = "매칭 정보 조회", description = "이번 매칭의 정보를 조회합니다.", tags = {"매칭"})
public ResponseEntity<CommonResponse<MatchInfoResponse>> getMatchInfo() {
MatchInfoResponse matchInfoResponse = matchService.getMatchInfoResponse();
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccess(matchInfoResponse));
}

@PatchMapping("/pieces/check")
@Operation(summary = "매칭 조각 확인 체크", description = "이번 매칭의 조각을 확인했음을 서버에 알립니다.", tags = {"매칭"})
public ResponseEntity<CommonResponse<Void>> checkMatchPiece() {
matchService.checkPiece();
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccessWithNoContent());
}
@PatchMapping("/pieces/check")
@Operation(summary = "매칭 조각 확인 체크", description = "이번 매칭의 조각을 확인했음을 서버에 알립니다.", tags = {"매칭"})
public ResponseEntity<CommonResponse<Void>> checkMatchPiece() {
matchService.checkPiece();
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccessWithNoContent());
}

@GetMapping("/profiles/basic")
@Operation(summary = "매칭 프로필 기본정보 확인", description = "매칭 상대의 프로필 기본정보를 확인합니다.", tags = {"매칭"})
public ResponseEntity<CommonResponse<MatchProfileBasicResponse>> getBasicMatchProfile() {
MatchProfileBasicResponse matchProfileBasic = matchService.getMatchProfileBasic();
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccess(matchProfileBasic));
}
@GetMapping("/profiles/basic")
@Operation(summary = "매칭 프로필 기본정보 확인", description = "매칭 상대의 프로필 기본정보를 확인합니다.", tags = {"매칭"})
public ResponseEntity<CommonResponse<MatchProfileBasicResponse>> getBasicMatchProfile() {
MatchProfileBasicResponse matchProfileBasic = matchService.getMatchProfileBasic();
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccess(matchProfileBasic));
}

@GetMapping("/values/talks")
@Operation(summary = "매칭 상대 가치관 톡 확인", description = "매칭 상대의 가치관 톡을 확인합니다.", tags = {"매칭"})
public ResponseEntity<CommonResponse<MatchValueTalkResponse>> getMatchTalkValues() {
MatchValueTalkResponse matchValueTalk = matchService.getMatchValueTalk();
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccess(matchValueTalk));
}
@GetMapping("/values/talks")
@Operation(summary = "매칭 상대 가치관 톡 확인", description = "매칭 상대의 가치관 톡을 확인합니다.", tags = {"매칭"})
public ResponseEntity<CommonResponse<MatchValueTalkResponse>> getMatchTalkValues() {
MatchValueTalkResponse matchValueTalk = matchService.getMatchValueTalk();
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccess(matchValueTalk));
}


@GetMapping("/values/picks")
@Operation(summary = "매칭 상대 가치관 픽 확인", description = "매칭 상대의 가치관 픽을 확인합니다.", tags = {"매칭"})
public ResponseEntity<CommonResponse<MatchValuePickResponse>> getMatchValuePicks() {
MatchValuePickResponse matchValuePickResponse = matchService.getMatchedUserValuePicks();
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccess(matchValuePickResponse));
}
@GetMapping("/values/picks")
@Operation(summary = "매칭 상대 가치관 픽 확인", description = "매칭 상대의 가치관 픽을 확인합니다.", tags = {"매칭"})
public ResponseEntity<CommonResponse<MatchValuePickResponse>> getMatchValuePicks() {
MatchValuePickResponse matchValuePickResponse = matchService.getMatchedUserValuePicks();
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccess(matchValuePickResponse));
}

@GetMapping("/images")
@Operation(summary = "매칭 상대 프로필 이미지 확인", description = "매칭 상대의 프로필 이미지를 확인합니다.", tags = {"매칭"})
public ResponseEntity<CommonResponse<ImageUrlResponse>> getMatchedUserImages() {
String matchedUserImageUrl = matchService.getMatchedUserImageUrl();
ImageUrlResponse imageUrlResponse = new ImageUrlResponse(matchedUserImageUrl);
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccess(imageUrlResponse));
}
@GetMapping("/images")
@Operation(summary = "매칭 상대 프로필 이미지 확인", description = "매칭 상대의 프로필 이미지를 확인합니다.", tags = {"매칭"})
public ResponseEntity<CommonResponse<ImageUrlResponse>> 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<CommonResponse<Void>> acceptMatch() {
matchService.acceptMatch();
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccessWithNoContent());
}
@PostMapping("/accept")
@Operation(summary = "매칭 수락하기", description = "매칭을 수락합니다.", tags = {"매칭"})
public ResponseEntity<CommonResponse<Void>> acceptMatch() {
matchService.acceptMatch();
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccessWithNoContent());
}

@GetMapping("/contacts")
@Operation(summary = "매칭 상대 연락처 조회", description = "매칭 상대의 연락처를 조회합니다", tags = {"매칭"})
public ResponseEntity<CommonResponse<ContactResponses>> getContacts() {
Map<ContactType, String> contacts = matchService.getContacts();
List<ContactResponse> contactsList = ContactResponses.convert(contacts);
ContactResponses contactResponses = new ContactResponses(contactsList);
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccess(contactResponses));
}
@GetMapping("/contacts")
@Operation(summary = "매칭 상대 연락처 조회", description = "매칭 상대의 연락처를 조회합니다", tags = {"매칭"})
public ResponseEntity<CommonResponse<ContactResponses>> getContacts() {
Map<ContactType, String> contacts = matchService.getContacts();
List<ContactResponse> contactsList = ContactResponses.convert(contacts);
ContactResponses contactResponses = new ContactResponses(contactsList);
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccess(contactResponses));
}

@PostMapping("/blocks/users/{userId}")
@Operation(summary = "매칭 상대 차단", description = "매칭 상대를 차단합니다", tags = {"매칭"})
public ResponseEntity<CommonResponse<Void>> blockUsers(
@PathVariable(name = "userId") Long userId) {
directBlockService.blockUser(userId);
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccessWithNoContent());
}
@PostMapping("/{matchId}/blocks")
@Operation(summary = "매칭 상대 차단", description = "매칭 상대를 차단합니다", tags = {"매칭"})
public ResponseEntity<CommonResponse<Void>> blockUsers(
@AuthenticationPrincipal Long userId,
@PathVariable Long matchId) {
directBlockService.blockMatchedUser(userId, matchId);
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccessWithNoContent("매칭 상대방을 차단하였습니다."));
}

@PutMapping("/refuse")
@Operation(summary = "매칭 거절", description = "매칭을 거절합니다", tags = {"매칭"})
public ResponseEntity<CommonResponse<Void>> refuseMatch(@AuthenticationPrincipal Long userId) {
matchService.refuseMatch(userId);
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccessWithNoContent());
}
@PutMapping("/refuse")
@Operation(summary = "매칭 거절", description = "매칭을 거절합니다", tags = {"매칭"})
public ResponseEntity<CommonResponse<Void>> refuseMatch(@AuthenticationPrincipal Long userId) {
matchService.refuseMatch(userId);
return ResponseEntity.status(HttpStatus.OK)
.body(CommonResponse.createSuccessWithNoContent());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.yapp.domain.match.presentation.dto.request;

public record MatchBlockRequest(Long matchId, Long blockId) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,35 @@
@NoArgsConstructor
public class MatchInfoResponse {

private Long matchId;
private Long matchedUserId;
private String matchStatus;
private String description;
private String nickname;
private String birthYear;
private String location;
private String job;
private Integer matchedValueCount;
private List<String> matchedValueList;
private Long matchId;
private Long matchedUserId;
private String matchStatus;
private String description;
private String nickname;
private String birthYear;
private String location;
private String job;
private Integer matchedValueCount;
private List<String> matchedValueList;
private boolean isBlocked;

@Builder
public MatchInfoResponse(Long matchId, Long matchedUserId, String matchStatus, String description,
String nickname,
String birthYear,
String location, String job, Integer matchedValueCount, List<String> matchedValueList) {
this.matchId = matchId;
this.matchedUserId = matchedUserId;
this.matchStatus = matchStatus;
this.description = description;
this.nickname = nickname;
this.birthYear = birthYear;
this.location = location;
this.job = job;
this.matchedValueCount = matchedValueCount;
this.matchedValueList = matchedValueList;
}
@Builder
public MatchInfoResponse(Long matchId, Long matchedUserId, String matchStatus,
String description,
String nickname,
String birthYear,
String location, String job, Integer matchedValueCount, List<String> matchedValueList,
boolean isBlocked) {
this.matchId = matchId;
this.matchedUserId = matchedUserId;
this.matchStatus = matchStatus;
this.isBlocked = isBlocked;
this.description = description;
this.nickname = nickname;
this.birthYear = birthYear;
this.location = location;
this.job = job;
this.matchedValueCount = matchedValueCount;
this.matchedValueList = matchedValueList;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ private List<Mono<ProfileValueTalkSummaryResponse>> getSummaryTasks(Long userId)
profileValueTalk.getAnswer() + TEXT_CONDITION)
.map(summarizedAnswer -> {
summarizedAnswer = summarizedAnswer.replaceAll("[\"']", "");
summarizedAnswer = summarizedAnswer.substring(0,
Math.min(summarizedAnswer.length(), 50));

sentSummaryResponse(userId, profileValueTalk.getId(),
summarizedAnswer);

Expand All @@ -98,6 +101,9 @@ private List<Mono<ProfileValueTalkSummaryResponse>> getSummaryTasks(Profile prof
profileValueTalk.getAnswer() + TEXT_CONDITION)
.map(summarizedAnswer -> {
summarizedAnswer = summarizedAnswer.replaceAll("[\"']", "");
summarizedAnswer = summarizedAnswer.substring(0,
Math.min(summarizedAnswer.length(), 50));

return new ProfileValueTalkSummaryResponse(profileValueTalk.getId(),
summarizedAnswer);
}))
Expand Down
Loading
Loading