Skip to content

Commit

Permalink
[fix] 매칭 보낸 요청 리스트 데이터 타입으로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
tmdtmdqorekf committed May 22, 2024
1 parent fb59e61 commit a75d15f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public ResponseEntity<ApiResponse<MatchDto>> sendMatchRequest(@RequestBody Match
}

@GetMapping("/request/info")
public ResponseEntity<ApiResponse<MatchInfoResponseDto>> getMatchRequestInfo(
public ResponseEntity<ApiResponse<List<MatchInfoResponseDto>>> getMatchRequestInfo(
@RequestParam("senderId") Long senderId) {
DtoLogger.requestParam("senderId", senderId);

MatchInfoResponseDto response = matchService.getMatchRequestInfo(senderId);
List<MatchInfoResponseDto> response = matchService.getMatchRequestInfo(senderId);
return ResponseEntity.ok(ApiResponse.success(response));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
public class MatchInfoResponseDto {
private String matchId;
private String requestTypeId;
private Long senderId;
private Long receiverId;
private ReceiverInfoDto receiverInfo;
private String expirationTime;
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,15 @@ public MatchDto sendMatchRequest(MatchRequestDto dto) {
}

// 보낸 매칭 요청 정보
public MatchInfoResponseDto getMatchRequestInfo(Long senderId) {
public List<MatchInfoResponseDto> getMatchRequestInfo(Long senderId) {
log.trace("getMatchRequestInfo()");

Set<String> keys = redisTemplate.keys("receiverId:*-senderId:" + senderId);
if (keys == null || keys.isEmpty()) {
throw new CustomException(ErrorCode.REQUEST_NOT_FOUND);
}

List<MatchInfoResponseDto> response = new ArrayList<>();
for (String key : keys) {
Map<Object, Object> matchInfo = redisTemplate.opsForHash().entries(key);
String expirationTime = (String) matchInfo.get("expirationTime");
Expand All @@ -127,16 +128,15 @@ public MatchInfoResponseDto getMatchRequestInfo(Long senderId) {
receiverInfo.setReceiverId(receiverId);
receiverInfo.setCompany(customMapper.toCompanyDto(receiver.getCompany()));

MatchInfoResponseDto response = mapper.map(matchInfo, MatchInfoResponseDto.class);
response.setMatchId(matchId);
response.setRequestTypeId((String) matchInfo.get("requestTypeId"));
response.setReceiverInfo(receiverInfo);
return response;
} else {
throw new CustomException(ErrorCode.REQUEST_NOT_FOUND);
MatchInfoResponseDto res = new MatchInfoResponseDto();
res.setMatchId(matchId);
res.setRequestTypeId((String) matchInfo.get("requestTypeId"));
res.setReceiverInfo(receiverInfo);
res.setExpirationTime(expirationTime);
response.add(res);
}
}
return new MatchInfoResponseDto();
return response;
}

// 받은 요청 정보
Expand Down

0 comments on commit a75d15f

Please sign in to comment.