From 6aa9e00203807b6e7f233076bd32e8950c5ddb96 Mon Sep 17 00:00:00 2001 From: HyeonJun An Date: Mon, 25 Sep 2023 16:16:53 +0900 Subject: [PATCH] =?UTF-8?q?[LH-195]=20patch=20api=20=EC=88=98=EC=A0=95=20(?= =?UTF-8?q?#43)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lighthouse/lingoswap/member/entity/Member.java | 12 ++++++------ .../lingoswap/member/service/MemberManager.java | 9 +++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/lighthouse/lingoswap/member/entity/Member.java b/src/main/java/com/lighthouse/lingoswap/member/entity/Member.java index cd71d1b..674c16a 100644 --- a/src/main/java/com/lighthouse/lingoswap/member/entity/Member.java +++ b/src/main/java/com/lighthouse/lingoswap/member/entity/Member.java @@ -56,12 +56,12 @@ public int calculateAge() { } public void updateMember(LocalDate birthday, String name, String description, String profileImageUri, Gender gender, Country region) { - this.birthday = birthday; - this.name = name; - this.description = description; - this.profileImageUri = profileImageUri; - this.gender = gender; - this.region = region; + if (birthday != null) this.birthday = birthday; + if (name != null) this.name = name; + if (description != null) this.description = description; + if (profileImageUri != null) this.profileImageUri = profileImageUri; + if (gender != null) this.gender = gender; + if (region != null) this.region = region; } public void patchDescription(String description) { diff --git a/src/main/java/com/lighthouse/lingoswap/member/service/MemberManager.java b/src/main/java/com/lighthouse/lingoswap/member/service/MemberManager.java index f0b4fb6..17d0fc3 100644 --- a/src/main/java/com/lighthouse/lingoswap/member/service/MemberManager.java +++ b/src/main/java/com/lighthouse/lingoswap/member/service/MemberManager.java @@ -229,8 +229,13 @@ public ResponseDto readLanguageForm() { public ResponseDto patch(final String uuid, final MemberRequest memberRequest) { Member member = memberService.findByUuid(uuid); - member.updateMember(memberRequest.birthday(), memberRequest.name(), memberRequest.description(), memberRequest.profileImageUri(), - memberRequest.gender(), countryService.findCountryByCode(memberRequest.region())); + if (memberRequest.region() == null) { + member.updateMember(memberRequest.birthday(), memberRequest.name(), memberRequest.description(), memberRequest.profileImageUri(), + memberRequest.gender(), null); + } else { + member.updateMember(memberRequest.birthday(), memberRequest.name(), memberRequest.description(), memberRequest.profileImageUri(), + memberRequest.gender(), countryService.findCountryByCode(memberRequest.region())); + } memberService.save(member); return ResponseDto.success(null); }