Skip to content

Commit

Permalink
[FEAT] 스케줄링 요청을 위한 ScheduleDto 추가 #93
Browse files Browse the repository at this point in the history
  • Loading branch information
ddongseop committed Aug 14, 2023
1 parent e0e494e commit cf4fcb7
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
import sopt.org.umbba.api.config.sqs.producer.SqsProducer;
import sopt.org.umbba.common.exception.ErrorType;
import sopt.org.umbba.common.exception.model.CustomException;
import sopt.org.umbba.common.sqs.MessageType;
import sopt.org.umbba.common.sqs.dto.FCMPushRequestDto;
import sopt.org.umbba.common.sqs.dto.MessageDto;
import sopt.org.umbba.common.sqs.dto.ScheduleDto;
import sopt.org.umbba.common.sqs.dto.SlackDto;
import sopt.org.umbba.domain.domain.user.User;
import sopt.org.umbba.domain.domain.user.repository.UserRepository;
Expand Down Expand Up @@ -47,4 +50,8 @@ public void pushOpponentReply(String question, Long userId) {
throw new CustomException(ErrorType.FAIL_TO_SEND_PUSH_ALARM);
}*/
}

public void activateTodayQna() {
sqsProducer.produce(ScheduleDto.of());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import sopt.org.umbba.api.controller.parentchild.dto.response.InviteResultResponseDto;
import sopt.org.umbba.api.controller.parentchild.dto.response.OnboardingInviteResponseDto;
import sopt.org.umbba.api.controller.parentchild.dto.response.OnboardingReceiveResponseDto;
import sopt.org.umbba.api.service.notification.NotificationService;
import sopt.org.umbba.common.exception.ErrorType;
import sopt.org.umbba.common.exception.model.CustomException;
import sopt.org.umbba.domain.domain.parentchild.Parentchild;
Expand All @@ -34,7 +35,7 @@ public class ParentchildService {
private final ParentchildRepository parentchildRepository;
private final UserRepository userRepository;
private final ParentchildDao parentchildDao;
// private final FCMScheduler fcmScheduler; TODO ⭐️SQS로 변경
private final NotificationService notificationService;

// [발신] 초대하는 측의 온보딩 정보 입력
@Transactional
Expand Down Expand Up @@ -120,7 +121,8 @@ public OnboardingReceiveResponseDto onboardReceive(Long userId, OnboardingReceiv
/*if (!ParentchildRelation.validate(parentChildUsers, parentchild.getRelation())) {
throw new CustomException(ErrorType.INVALID_PARENT_CHILD_RELATION);
}*/
// TODO ⭐️SQS로 변경

notificationService.activateTodayQna();
// ScheduleConfig.resetScheduler();
// fcmScheduler.pushTodayQna();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ public final class MessageType {

public static final String MESSAGE_TYPE_HEADER = "TYPE";
public static final String FIREBASE = "FIREBASE";
public static final String SCHEDULE = "SCHEDULE";
public static final String SLACK = "SLACK";
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package sopt.org.umbba.common.sqs.dto;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import lombok.extern.slf4j.Slf4j;
import sopt.org.umbba.common.sqs.MessageType;

@Slf4j
@Getter
@SuperBuilder
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ScheduleDto extends MessageDto{

public static ScheduleDto of() {
return ScheduleDto.builder()
.type(MessageType.SCHEDULE)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
import sopt.org.umbba.common.sqs.MessageType;
import sopt.org.umbba.common.sqs.MessageUtils;
import sopt.org.umbba.common.sqs.dto.FCMPushRequestDto;
import sopt.org.umbba.common.sqs.dto.FirebaseDto;
import sopt.org.umbba.common.sqs.dto.SlackDto;
import sopt.org.umbba.notification.service.fcm.FCMService;
import sopt.org.umbba.notification.service.slack.SlackApi;

import javax.websocket.SendResult;
import java.util.Map;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public String pushTodayQna() {
// String cronExpression = String.format("*/20 * * * * *");
log.info("cron: {}", cronExpression);
fcmService.schedulePushAlarm(cronExpression, pc.getId());
})
;
});
return "Today QnA messages were sent successfully";
}

Expand Down

0 comments on commit cf4fcb7

Please sign in to comment.