From 0d9c3feb6d6d1227ce03b9d5c4c121ece8038c46 Mon Sep 17 00:00:00 2001 From: Lee junbeom Date: Tue, 9 Jul 2024 16:30:27 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=EC=8A=A4=EC=BC=80=EC=A5=B4=EB=9F=AC?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=EC=97=90=20=EB=A9=94=EC=84=B8=EC=A7=80=20?= =?UTF-8?q?=EC=A0=84=EC=86=A1=20=EC=B6=94=EA=B0=80,=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20=EC=8B=9C=201=EC=9B=94=201=EC=9D=BC=20?= =?UTF-8?q?=EC=83=9D=EC=9D=BC=EB=A1=9C=20=ED=95=9C=20=EA=B8=B0=EB=85=90?= =?UTF-8?q?=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/fiurinee/domain/mail/AnniversarySchedular.java | 7 ++++++- .../fiurinee/domain/oauth2/service/OAuth2UserService.java | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/example/fiurinee/domain/mail/AnniversarySchedular.java b/src/main/java/com/example/fiurinee/domain/mail/AnniversarySchedular.java index 0433741..69944f0 100644 --- a/src/main/java/com/example/fiurinee/domain/mail/AnniversarySchedular.java +++ b/src/main/java/com/example/fiurinee/domain/mail/AnniversarySchedular.java @@ -4,6 +4,7 @@ import com.example.fiurinee.domain.anniversary.service.AnniversaryService; import com.example.fiurinee.domain.member.entity.Member; import com.example.fiurinee.domain.member.service.MemberService; +import com.example.fiurinee.domain.sms.service.SmsService; import jakarta.mail.MessagingException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; @@ -19,11 +20,13 @@ public class AnniversarySchedular { private final AnniversaryService anniversaryService; private final MailService mailService; private final MemberService memberService; + private final SmsService smsService; - public AnniversarySchedular(AnniversaryService anniversaryService, MailService mailService, MemberService memberService) { + public AnniversarySchedular(AnniversaryService anniversaryService, MailService mailService, MemberService memberService,SmsService smsService) { this.anniversaryService = anniversaryService; this.mailService = mailService; this.memberService = memberService; + this.smsService = smsService; } @Scheduled(cron = "0 30 14 * * *", zone = "Asia/Seoul") @@ -42,8 +45,10 @@ public void sendAnniversaryEmails() { try { if (entry.getValue() == 0) { mailService.sendAnniversaryEmail(anniversary.getMember(), anniversary); + smsService.sendSMS(anniversary.getMember(), anniversary); } else if (entry.getValue() == 3) { mailService.sendPreAnniversaryEmail(anniversary.getMember(), anniversary); + smsService.preSendSMS(anniversary.getMember(), anniversary); } } catch (MessagingException e) { e.printStackTrace(); diff --git a/src/main/java/com/example/fiurinee/domain/oauth2/service/OAuth2UserService.java b/src/main/java/com/example/fiurinee/domain/oauth2/service/OAuth2UserService.java index d6fa856..537ca9b 100644 --- a/src/main/java/com/example/fiurinee/domain/oauth2/service/OAuth2UserService.java +++ b/src/main/java/com/example/fiurinee/domain/oauth2/service/OAuth2UserService.java @@ -1,5 +1,7 @@ package com.example.fiurinee.domain.oauth2.service; +import com.example.fiurinee.domain.anniversary.dto.AnniversaryRequestDTO; +import com.example.fiurinee.domain.anniversary.service.AnniversaryService; import com.example.fiurinee.domain.member.entity.Member; import com.example.fiurinee.domain.member.entity.PrincipalDetail; import com.example.fiurinee.domain.member.entity.Role; @@ -18,6 +20,7 @@ import org.springframework.stereotype.Service; import java.net.URL; +import java.time.LocalDate; import java.util.Collections; import java.util.Map; import java.util.Optional; @@ -28,6 +31,7 @@ @RequiredArgsConstructor public class OAuth2UserService extends DefaultOAuth2UserService { private final MemberRepository memberRepository; + private final AnniversaryService anniversaryService; @Override public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException { @@ -56,6 +60,9 @@ public Member saveSocialMember(String socialId, String name, String email, Strin int defaultProfileImage = 11; boolean defaultAlarm = false; Member newMember = Member.createMember(email, name, socialId, Role.USER,kakaoAccessToken, defaultProfileImage, defaultAlarm); + LocalDate localDate = LocalDate.of(2024, 1, 1); + AnniversaryRequestDTO anniversaryRequestDTO = new AnniversaryRequestDTO(name + "님 생일", localDate, "생일"); + anniversaryService.addAnniversary(newMember.getId(), anniversaryRequestDTO); return memberRepository.save(newMember); }