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

[Refactor] replies api 확정 #44

Merged
merged 1 commit into from
Dec 22, 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
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@ public ApiResponse<List<RepliesResponseDTO.allreceivedrepliesDTO>> getAllReceive
return ApiResponse.onSuccess(repliesService.getAllReceivedReplies(member_id));
}

@GetMapping("/{replyid}")
@Operation(summary = "답장 조회",description = "답장을 조회하는 API 입니다")
public ApiResponse<RepliesResponseDTO.getreplyDTO> getreply(
@RequestParam(name = "replyid") Long replyid
){
return ApiResponse.onSuccess(repliesService.getreply(replyid));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@ public class RepliesRequestDTO {
@NoArgsConstructor
@AllArgsConstructor
public static class addreplyDTO{
String photo_url;
String content;
Long letter_id;
String image_url;
Integer font;
Long sender_id;
Long receiver_id;
Long mailbox_id;
LocalDateTime created_at;



}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class RepliesResponseDTO {
@NoArgsConstructor
@AllArgsConstructor
public static class allsentrepliesDTO{
Long reply_id;
Long letter_id;
String content;
Long receiver_id;
Expand All @@ -27,11 +28,31 @@ public static class allsentrepliesDTO{
@NoArgsConstructor
@AllArgsConstructor
public static class allreceivedrepliesDTO{
Long reply_id;
Long letter_id;
String content;
Long sender_id;
String sender_name;
LocalDateTime created_at;
Integer font;
}


@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public static class getreplyDTO{
Long letter_id;
String content;
Long sender_id;
String sender_name;
Long receiver_id;
String receiver_name;
LocalDateTime created_at;
Integer font;
String photo_url;
}


}
29 changes: 25 additions & 4 deletions src/main/java/com/example/blism/service/RepliesServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class RepliesServiceImpl {
private final LetterRepository letterRepository;
private final S3Service s3Service;

// ---------------------------- 사진 추가 ------------------

@Transactional
public Reply addreplies(MultipartFile image, RepliesRequestDTO.addreplyDTO request) {

Expand All @@ -51,7 +51,7 @@ public Reply addreplies(MultipartFile image, RepliesRequestDTO.addreplyDTO reque
Reply newReply = Reply.builder()
.content(request.getContent())
.letter(letter)
.photoUrl(request.getPhoto_url())
.photoUrl(photoUrl)
.font(request.getFont())
.mailbox(mailbox)
.sender(sender)
Expand All @@ -62,7 +62,7 @@ public Reply addreplies(MultipartFile image, RepliesRequestDTO.addreplyDTO reque

return repliesRepository.save(newReply);
}
// ---------------------------- 사진 추가 ------------------



@Transactional
Expand All @@ -75,6 +75,7 @@ public List<RepliesResponseDTO.allsentrepliesDTO> getAllSentReplies(Long senderI
// JSON 형식으로 변환
return allReplies.stream()
.map(reply -> RepliesResponseDTO.allsentrepliesDTO.builder()
.reply_id(reply.getId())
.content(reply.getContent())
.letter_id(reply.getLetter().getId())
.receiver_id(reply.getReceiver().getId())
Expand All @@ -86,7 +87,7 @@ public List<RepliesResponseDTO.allsentrepliesDTO> getAllSentReplies(Long senderI
}


// ----------------------------- <리스트 부분> ---------------------------




Expand All @@ -99,6 +100,7 @@ public List<RepliesResponseDTO.allreceivedrepliesDTO> getAllReceivedReplies(Long

return allReplies.stream()
.map(reply -> RepliesResponseDTO.allreceivedrepliesDTO.builder()
.reply_id(reply.getId())
.content(reply.getContent())
.letter_id(reply.getLetter().getId())
.sender_name(reply.getSender().getNickname())
Expand All @@ -110,5 +112,24 @@ public List<RepliesResponseDTO.allreceivedrepliesDTO> getAllReceivedReplies(Long
}


@Transactional
public RepliesResponseDTO.getreplyDTO getreply(Long request) {
Reply reply = repliesRepository.findById(request).get();


return RepliesResponseDTO.getreplyDTO.builder()
.content(reply.getContent())
.letter_id(reply.getLetter().getId())
.sender_id(reply.getSender().getId())
.sender_name(reply.getSender().getNickname())
.font(reply.getFont())
.receiver_id(reply.getReceiver().getId())
.receiver_name(reply.getReceiver().getNickname())
.created_at(reply.getCreatedAt())
.photo_url(reply.getPhotoUrl())
.build();
}



}
Loading