From 2e92085e73e5fff17bc77f11a839aa7ff7eda5af Mon Sep 17 00:00:00 2001 From: tlarbals824 Date: Thu, 25 May 2023 17:56:33 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20mypet=20=EC=A0=95=EB=B3=B4=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=EC=8B=9C=20=EA=B3=B5=EB=B0=B1=20=ED=99=95=EC=9D=B8?= =?UTF-8?q?=ED=9B=84=20=EC=88=98=EC=A0=95=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/MyPetUpdateRequest.java | 14 +++++++++++++- .../samsion/domain/user/domain/entity/MyPet.java | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/kusitms/samsion/domain/user/application/dto/request/MyPetUpdateRequest.java b/src/main/java/com/kusitms/samsion/domain/user/application/dto/request/MyPetUpdateRequest.java index ef10553..2ad7905 100644 --- a/src/main/java/com/kusitms/samsion/domain/user/application/dto/request/MyPetUpdateRequest.java +++ b/src/main/java/com/kusitms/samsion/domain/user/application/dto/request/MyPetUpdateRequest.java @@ -1,6 +1,7 @@ package com.kusitms.samsion.domain.user.application.dto.request; import org.springframework.lang.Nullable; +import org.springframework.util.StringUtils; import org.springframework.web.multipart.MultipartFile; import lombok.Builder; @@ -26,9 +27,20 @@ public MyPetUpdateRequest(String userNickname, String description, String petTyp this.userNickname = userNickname; this.description = description; this.petType = petType; - this.petAge = Integer.parseInt(petAge); + this.petAge = petAgeParse(petAge); this.petName = petName; this.profileImage = profileImage; this.petImage = petImage; } + + private int petAgeParse(String petAge) { + if(StringUtils.hasText(petAge)){ + try{ + return Integer.parseInt(petAge); + }catch (NumberFormatException e){ + return 0; + } + } + return 0; + } } diff --git a/src/main/java/com/kusitms/samsion/domain/user/domain/entity/MyPet.java b/src/main/java/com/kusitms/samsion/domain/user/domain/entity/MyPet.java index 4217d50..fbbc727 100644 --- a/src/main/java/com/kusitms/samsion/domain/user/domain/entity/MyPet.java +++ b/src/main/java/com/kusitms/samsion/domain/user/domain/entity/MyPet.java @@ -69,7 +69,7 @@ private void updatePetAge(int petAge) { } private void updatePetType(String petType) { - if (!Objects.equals(petType, this.petType)&&Objects.nonNull(petType)) + if (!Objects.equals(petType, this.petType)&&StringUtils.hasText(petType)) this.petType = petType; }