Skip to content

Commit

Permalink
fix: 유저 정보 메인 DTO와 꿀조합으로 보이는 유저 정보 DTO 분리 (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
70825 authored May 29, 2024
1 parent 963be64 commit 72c1c83
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/com/funeat/member/dto/MemberRecipeDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ public class MemberRecipeDto {
private final Long id;
private final String title;
private final String content;
private final MemberProfileResponse author;
private final MemberResponse author;
private final LocalDateTime createdAt;
private final String image;

private MemberRecipeDto(final Long id, final String title, final String content, final MemberProfileResponse author,
private MemberRecipeDto(final Long id, final String title, final String content, final MemberResponse author,
final LocalDateTime createdAt) {
this(id, title, content, author, createdAt, null);
}

@JsonCreator
private MemberRecipeDto(final Long id, final String title, final String content, final MemberProfileResponse author,
private MemberRecipeDto(final Long id, final String title, final String content, final MemberResponse author,
final LocalDateTime createdAt, final String image) {
this.id = id;
this.title = title;
Expand All @@ -32,7 +32,7 @@ private MemberRecipeDto(final Long id, final String title, final String content,
}

public static MemberRecipeDto toDto(final Recipe recipe, final List<RecipeImage> findRecipeImages) {
final MemberProfileResponse author = MemberProfileResponse.toResponse(recipe.getMember());
final MemberResponse author = MemberResponse.toResponse(recipe.getMember());

if (findRecipeImages.isEmpty()) {
return new MemberRecipeDto(recipe.getId(), recipe.getTitle(), recipe.getContent(),author,
Expand All @@ -54,7 +54,7 @@ public String getContent() {
return content;
}

public MemberProfileResponse getAuthor() {
public MemberResponse getAuthor() {
return author;
}

Expand Down
26 changes: 26 additions & 0 deletions src/main/java/com/funeat/member/dto/MemberResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.funeat.member.dto;

import com.funeat.member.domain.Member;

public class MemberResponse {

private final String nickname;
private final String profileImage;

public MemberResponse(final String nickname, final String profileImage) {
this.nickname = nickname;
this.profileImage = profileImage;
}

public static MemberResponse toResponse(final Member member) {
return new MemberResponse(member.getNickname(), member.getProfileImage());
}

public String getNickname() {
return nickname;
}

public String getProfileImage() {
return profileImage;
}
}

0 comments on commit 72c1c83

Please sign in to comment.