From 9d418ad34d09db705dd8f2b3fb5b2c52d110c7a8 Mon Sep 17 00:00:00 2001 From: Yeongjin Noh <129354455+nohy6630@users.noreply.github.com> Date: Thu, 16 Nov 2023 02:01:27 +0900 Subject: [PATCH] =?UTF-8?q?Fix(#68):=20=EC=98=A8=EB=B3=B4=EB=94=A9?= =?UTF-8?q?=EC=8B=9C=20fcm=ED=86=A0=ED=81=B0=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20(#69)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/member/controller/MemberController.java | 1 + .../domain/member/dto/request/OnboardingRequest.java | 5 ++++- .../com/numberone/backend/domain/member/entity/Member.java | 6 ++++-- .../backend/domain/member/service/MemberService.java | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/numberone/backend/domain/member/controller/MemberController.java b/src/main/java/com/numberone/backend/domain/member/controller/MemberController.java index 64e7cea8..6acfc70b 100644 --- a/src/main/java/com/numberone/backend/domain/member/controller/MemberController.java +++ b/src/main/java/com/numberone/backend/domain/member/controller/MemberController.java @@ -29,6 +29,7 @@ @Tag(name = "members", description = "사용자 관련 API") @RestController @RequiredArgsConstructor +@RequestMapping("/api/members") public class MemberController { private final MemberService memberService; diff --git a/src/main/java/com/numberone/backend/domain/member/dto/request/OnboardingRequest.java b/src/main/java/com/numberone/backend/domain/member/dto/request/OnboardingRequest.java index 7b06563d..852a1af0 100644 --- a/src/main/java/com/numberone/backend/domain/member/dto/request/OnboardingRequest.java +++ b/src/main/java/com/numberone/backend/domain/member/dto/request/OnboardingRequest.java @@ -12,9 +12,12 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class OnboardingRequest { @Schema(defaultValue = "초롱이") - @NotNull + @NotNull(message = "nickname은 null일 수 없습니다.") private String nickname; + @NotNull(message = "fcm token은 null일 수 없습니다.") + private String fcmToken; + private List addresses; private List disasterTypes; diff --git a/src/main/java/com/numberone/backend/domain/member/entity/Member.java b/src/main/java/com/numberone/backend/domain/member/entity/Member.java index 873322c0..cea2b8e5 100644 --- a/src/main/java/com/numberone/backend/domain/member/entity/Member.java +++ b/src/main/java/com/numberone/backend/domain/member/entity/Member.java @@ -64,11 +64,12 @@ public class Member extends BaseTimeEntity { private List notificationRegions = new ArrayList<>(); @Builder - public Member(String email, String nickName, String realName, Integer heartCnt) { + public Member(String email, String nickName, String realName, Integer heartCnt, String fcmToken) { this.email = email; this.nickName = nickName; this.realName = realName; this.heartCnt = heartCnt; + this.fcmToken = fcmToken; } public static Member of(String email, String realName) { @@ -83,8 +84,9 @@ public void updateProfileImageUrl(String imageUrl) { this.profileImageUrl = imageUrl; } - public void updateNickName(String nickName) { + public void setOnboardingData(String nickName, String fcmToken) { this.nickName = nickName; + this.fcmToken = fcmToken; } public void plusHeart(int heart) { diff --git a/src/main/java/com/numberone/backend/domain/member/service/MemberService.java b/src/main/java/com/numberone/backend/domain/member/service/MemberService.java index bca50289..cab4b378 100644 --- a/src/main/java/com/numberone/backend/domain/member/service/MemberService.java +++ b/src/main/java/com/numberone/backend/domain/member/service/MemberService.java @@ -46,7 +46,7 @@ public void create(String email, String realName) { public void initMemberData(String email, OnboardingRequest onboardingRequest) { Member member = memberRepository.findByEmail(email) .orElseThrow(NotFoundMemberException::new); - member.updateNickName(onboardingRequest.getNickname()); + member.setOnboardingData(onboardingRequest.getNickname(), onboardingRequest.getFcmToken()); notificationDisasterRepository.deleteAllByMemberId(member.getId()); notificationRegionRepository.deleteAllByMemberId(member.getId()); for (OnboardingAddress address : onboardingRequest.getAddresses()) {