From c17071d5beefa8a92b00193168b1b87c56ce6f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=AA=85=EB=B2=94?= <72181693+mungmnb777@users.noreply.github.com> Date: Tue, 6 Feb 2024 20:10:36 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=8B=89=EB=84=A4=EC=9E=84=EC=9D=B4=20?= =?UTF-8?q?=ED=83=88=ED=87=B4=ED=95=9C=20=EC=82=AC=EC=9A=A9=EC=9E=90?= =?UTF-8?q?=EA=B0=80=20=EB=B0=98=ED=99=98=EB=90=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#94)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tteokguk/member/domain/Member.java | 6 ++- .../assembler/TteokgukResponseAssembler.java | 47 ++++++------------- 2 files changed, 19 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/tteokguk/tteokguk/member/domain/Member.java b/src/main/java/com/tteokguk/tteokguk/member/domain/Member.java index 533ede0..488ebab 100644 --- a/src/main/java/com/tteokguk/tteokguk/member/domain/Member.java +++ b/src/main/java/com/tteokguk/tteokguk/member/domain/Member.java @@ -9,7 +9,6 @@ import lombok.Getter; import lombok.NoArgsConstructor; import org.hibernate.annotations.ColumnDefault; -import org.hibernate.annotations.Where; import java.util.ArrayList; import java.util.Arrays; @@ -174,4 +173,9 @@ public void delete() { this.deleted = true; } + public String getNickname() { + if (isDeleted()) + return "탈퇴한 사용자"; + return nickname; + } } diff --git a/src/main/java/com/tteokguk/tteokguk/tteokguk/application/dto/response/assembler/TteokgukResponseAssembler.java b/src/main/java/com/tteokguk/tteokguk/tteokguk/application/dto/response/assembler/TteokgukResponseAssembler.java index 83d01fc..62c67f6 100644 --- a/src/main/java/com/tteokguk/tteokguk/tteokguk/application/dto/response/assembler/TteokgukResponseAssembler.java +++ b/src/main/java/com/tteokguk/tteokguk/tteokguk/application/dto/response/assembler/TteokgukResponseAssembler.java @@ -5,7 +5,6 @@ import com.tteokguk.tteokguk.tteokguk.application.dto.response.TteokgukResponse; import com.tteokguk.tteokguk.tteokguk.constants.Ingredient; import com.tteokguk.tteokguk.tteokguk.domain.Tteokguk; -import jakarta.persistence.EntityNotFoundException; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -24,38 +23,20 @@ public static TteokgukResponse toTteokgukResponse(Tteokguk tteokguk) { .filter(ingredient -> !usedIngredients.contains(ingredient)) .toList(); - try { - return TteokgukResponse.builder() - .tteokgukId(tteokguk.getId()) - .memberId(tteokguk.getMember().getId()) - .nickname(tteokguk.getMember().getNickname()) - .wish(tteokguk.getWish()) - .ingredients(ingredients) - .usedIngredients(usedIngredients) - .requiredIngredients(requiredIngredients) - .access(tteokguk.isAccess()) - .completion(tteokguk.isCompletion()) - .backgroundColor(tteokguk.getBackgroundColor()) - .frontGarnish(tteokguk.getVisibleIngredient1()) - .backGarnish(tteokguk.getVisibleIngredient2()) - .build(); - } catch (EntityNotFoundException e) { - // 탈퇴한 사용자일 경우 - return TteokgukResponse.builder() - .tteokgukId(null) - .memberId(tteokguk.getMember().getId()) - .nickname("탈퇴한 사용자") - .wish(tteokguk.getWish()) - .ingredients(ingredients) - .usedIngredients(usedIngredients) - .requiredIngredients(requiredIngredients) - .access(tteokguk.isAccess()) - .completion(tteokguk.isCompletion()) - .backgroundColor(tteokguk.getBackgroundColor()) - .frontGarnish(tteokguk.getVisibleIngredient1()) - .backGarnish(tteokguk.getVisibleIngredient2()) - .build(); - } + return TteokgukResponse.builder() + .tteokgukId(tteokguk.getId()) + .memberId(tteokguk.getMember().getId()) + .nickname(tteokguk.getMember().getNickname()) + .wish(tteokguk.getWish()) + .ingredients(ingredients) + .usedIngredients(usedIngredients) + .requiredIngredients(requiredIngredients) + .access(tteokguk.isAccess()) + .completion(tteokguk.isCompletion()) + .backgroundColor(tteokguk.getBackgroundColor()) + .frontGarnish(tteokguk.getVisibleIngredient1()) + .backGarnish(tteokguk.getVisibleIngredient2()) + .build(); } public static List toSupportTteokgukResponses(List supports) {