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

fix: 유저 정보 메인 DTO와 꿀조합으로 보이는 유저 정보 DTO 분리 #63

Merged
merged 1 commit into from
May 29, 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
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;
}
}