Skip to content

Commit

Permalink
chore: 스케쥴러 코드에 메세지 전송 추가, 회원가입 시 1월 1일 생일로 한 기념일 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ss7622 committed Jul 9, 2024
1 parent e4c6c86 commit 0d9c3fe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 0d9c3fe

Please sign in to comment.