Skip to content

Commit

Permalink
feat: 닉네임이 탈퇴한 사용자가 반환되도록 수정 (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
mungmnb777 authored Feb 6, 2024
1 parent dbd5a3d commit c17071d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -174,4 +173,9 @@ public void delete() {
this.deleted = true;
}

public String getNickname() {
if (isDeleted())
return "탈퇴한 사용자";
return nickname;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<SupportTteokgukResponse> toSupportTteokgukResponses(List<Support> supports) {
Expand Down

0 comments on commit c17071d

Please sign in to comment.