-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 테스트를 위한 @EnableJpaAuditing 설정 이동 * feat: mail 전송 여부 확인을 위한 isSent 변수 추가 * feat: mail 전송시 체크를 위한 consultingId 추가 * feat: 스케쥴링을 통한 메일 전송 실패 대비 * feat: 메일 구성 추가 로고 및 사용자 이름 추가 * chore: 메일 스케쥴링 cron 변경 1분 -> 5분
- Loading branch information
Showing
15 changed files
with
167 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...r/src/main/java/softeer/be_my_car_master/application/consult/handler/MailSendAdaptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package softeer.be_my_car_master.application.consult.handler; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import softeer.be_my_car_master.domain.consulting.Consulting; | ||
import softeer.be_my_car_master.global.annotation.Adaptor; | ||
import softeer.be_my_car_master.infrastructure.jpa.car_master.entity.ConsultingEntity; | ||
import softeer.be_my_car_master.infrastructure.jpa.car_master.repository.ConsultingJpaRepository; | ||
|
||
@Adaptor | ||
@RequiredArgsConstructor | ||
public class MailSendAdaptor implements MailSendPort { | ||
|
||
private final ConsultingJpaRepository consultingJpaRepository; | ||
|
||
@Override | ||
@Transactional | ||
public void sendComplete(Long consultingId) { | ||
ConsultingEntity consulting = consultingJpaRepository.findById(consultingId).get(); | ||
consulting.sendEmail(); | ||
} | ||
|
||
@Override | ||
public List<Consulting> findSendFailureConsultings() { | ||
return consultingJpaRepository.findAllByIsSent(false).stream() | ||
.map(ConsultingEntity::toConsulting) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...ster/src/main/java/softeer/be_my_car_master/application/consult/handler/MailSendPort.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package softeer.be_my_car_master.application.consult.handler; | ||
|
||
import java.util.List; | ||
|
||
import softeer.be_my_car_master.domain.consulting.Consulting; | ||
import softeer.be_my_car_master.global.annotation.Port; | ||
|
||
@Port | ||
public interface MailSendPort { | ||
|
||
void sendComplete(Long consultingId); | ||
|
||
List<Consulting> findSendFailureConsultings(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
BE-MyCarMaster/src/main/java/softeer/be_my_car_master/global/config/BaseTimeConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package softeer.be_my_car_master.global.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | ||
|
||
@Configuration | ||
@EnableJpaAuditing | ||
public class BaseTimeConfig { | ||
} |
43 changes: 43 additions & 0 deletions
43
BE-MyCarMaster/src/main/java/softeer/be_my_car_master/global/config/SchedulingConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package softeer.be_my_car_master.global.config; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import softeer.be_my_car_master.application.consult.handler.MailSendEvent; | ||
import softeer.be_my_car_master.application.consult.handler.MailSendPort; | ||
import softeer.be_my_car_master.domain.consulting.Consulting; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class SchedulingConfig { | ||
|
||
private final MailSendPort mailSendPort; | ||
private final ApplicationEventPublisher eventPublisher; | ||
|
||
@Transactional | ||
@Scheduled(cron = "0 */5 * * * *") | ||
public void setDiaryEditStatus() { | ||
List<Consulting> sendFailureConsultings = mailSendPort.findSendFailureConsultings(); | ||
sendEmails(sendFailureConsultings); | ||
} | ||
|
||
private void sendEmails(List<Consulting> sendFailureConsultings) { | ||
sendFailureConsultings.stream() | ||
.forEach(consulting -> { | ||
UUID uuid = consulting.getUuid(); | ||
String clientName = consulting.getClientName(); | ||
String clientEmail = consulting.getClientEmail(); | ||
Long id = consulting.getId(); | ||
eventPublisher.publishEvent(new MailSendEvent(uuid, clientName, clientEmail, id)); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...er/be_my_car_master/infrastructure/jpa/car_master/repository/ConsultingJpaRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
package softeer.be_my_car_master.infrastructure.jpa.car_master.repository; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
import softeer.be_my_car_master.infrastructure.jpa.car_master.entity.ConsultingEntity; | ||
|
||
public interface ConsultingJpaRepository extends JpaRepository<ConsultingEntity, Long> { | ||
|
||
@Query(value = "SELECT c " | ||
+ "FROM ConsultingEntity c " | ||
+ "JOIN FETCH c.estimate " | ||
+ "WHERE c.isSent = :isSent") | ||
List<ConsultingEntity> findAllByIsSent(boolean isSent); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters