Skip to content

Commit

Permalink
REFACTOR(like) :: likeDto record로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
Woongbin06 committed Oct 1, 2024
1 parent ad40889 commit 84554f1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package com.woongeya.zoing.domain.like.presentation.dto.response;

import lombok.Getter;

@Getter
public class LikerResponseDto {

private Long id;
private String name;

public LikerResponseDto(Long id, String name) {
this.id = id;
this.name = name;
public record LikerResponseDto (
Long id,
String name
) {
public static LikerResponseDto of(Long id, String name) {
return new LikerResponseDto(id, name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public List<LikerResponseDto> execute(Long id) {
return likes.stream()
.map(like -> userFacade.getUserById(like.getUserId()))
.map(User::getName)
.map(name -> new LikerResponseDto(id, name))
.map(name -> LikerResponseDto.of(id, name))
.collect(Collectors.toList());

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public List<NotificationResponse> execute() {
notifications.forEach(Notification::checkState);

return notifications.stream()
.map(NotificationResponse::of)
.map(NotificationResponse::from)
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class QueryPostService {
public PostResponseList execute() {
List<Post> posts = postRepository.findAll();

return PostResponseList.of(
return PostResponseList.from(
posts.stream()
.map(post -> PostResponse.of(post, userFacade.getUserById(post.getWriter())))
.collect(Collectors.toList())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class QuerySearchPostService {
public PostResponseList execute(String q) {
List<Post> posts = postRepository.searchPost(q);

return PostResponseList.of(
return PostResponseList.from(
posts.stream()
.map(post -> PostResponse.of(post, userFacade.getUserById(post.getWriter())))
.collect(Collectors.toList())
Expand Down

0 comments on commit 84554f1

Please sign in to comment.