Skip to content

Commit

Permalink
[fix] mypet 정보 수정시 공백 확인후 수정하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
tlarbals824 committed May 25, 2023
1 parent 82c8365 commit 2e92085
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 2e92085

Please sign in to comment.