-
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.
- Loading branch information
1 parent
4c9dc20
commit 6325dfa
Showing
16 changed files
with
229 additions
and
183 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
90 changes: 90 additions & 0 deletions
90
src/main/java/com/spaceclub/notification/mail/domain/MailHistory.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,90 @@ | ||
package com.spaceclub.notification.mail.domain; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embedded; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.Id; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import static jakarta.persistence.GenerationType.IDENTITY; | ||
import static lombok.AccessLevel.PROTECTED; | ||
|
||
@Slf4j | ||
@Entity | ||
@ToString | ||
@EqualsAndHashCode(of = "id") | ||
@NoArgsConstructor(access = PROTECTED) | ||
public class MailHistory { | ||
|
||
@Id | ||
@Getter | ||
@Column(name = "mail_history_id") | ||
@GeneratedValue(strategy = IDENTITY) | ||
private Long id; | ||
|
||
@Getter | ||
private String addresses; | ||
|
||
@Getter | ||
private String title; | ||
|
||
@Getter | ||
@Enumerated(EnumType.STRING) | ||
private TemplateName templateName; | ||
|
||
@Getter | ||
private Long templateId; | ||
|
||
@Embedded | ||
private AdditionalInfo additionalInfo; | ||
|
||
private LocalDateTime sentAt; | ||
|
||
private boolean isSent; | ||
|
||
@Builder | ||
private MailHistory( | ||
String addresses, | ||
String title, | ||
TemplateName templateName, | ||
LocalDateTime sentAt, | ||
boolean isSent, | ||
AdditionalInfo additionalInfo | ||
) { | ||
this.addresses = addresses; | ||
this.title = title; | ||
this.templateName = templateName; | ||
this.templateId = templateName.getTemplateId(); | ||
this.sentAt = sentAt; | ||
this.isSent = isSent; | ||
log.info("MailTracker created: {}", this); | ||
} | ||
|
||
public void changeToSent() { | ||
this.sentAt = LocalDateTime.now(); | ||
this.isSent = true; | ||
} | ||
|
||
public String getClubName() { | ||
return additionalInfo.getClubName(); | ||
} | ||
|
||
public String getEventName() { | ||
return additionalInfo.getEventName(); | ||
} | ||
|
||
public String getEventStatus() { | ||
return additionalInfo.getEventStatus(); | ||
} | ||
|
||
} |
122 changes: 0 additions & 122 deletions
122
src/main/java/com/spaceclub/notification/mail/domain/MailTracker.java
This file was deleted.
Oops, something went wrong.
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
6 changes: 3 additions & 3 deletions
6
src/main/java/com/spaceclub/notification/mail/repository/MailTrackerRepository.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,14 +1,14 @@ | ||
package com.spaceclub.notification.mail.repository; | ||
|
||
import com.spaceclub.notification.mail.domain.MailTracker; | ||
import com.spaceclub.notification.mail.domain.MailHistory; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Slice; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface MailTrackerRepository extends JpaRepository<MailTracker, Long> { | ||
public interface MailTrackerRepository extends JpaRepository<MailHistory, Long> { | ||
|
||
int countByIsSentFalse(); | ||
|
||
Slice<MailTracker> findAllByIsSentFalse(Pageable pageable); | ||
Slice<MailHistory> findAllByIsSentFalse(Pageable pageable); | ||
|
||
} |
5 changes: 3 additions & 2 deletions
5
src/main/java/com/spaceclub/notification/mail/repository/TemplateRepository.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,15 +1,16 @@ | ||
package com.spaceclub.notification.mail.repository; | ||
|
||
import com.spaceclub.notification.mail.domain.Template; | ||
import com.spaceclub.notification.mail.domain.TemplateName; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface TemplateRepository extends JpaRepository<Template, Long> { | ||
|
||
@Query("select distinct t.template from Template t " + | ||
"join fetch MailTracker m on m.templateId = t.id " + | ||
"join fetch MailHistory m on m.templateId = t.id " + | ||
"where m.templateName = :templateName") | ||
String findTemplateByTemplateName(@Param("templateName") String templateName); | ||
String findTemplateByTemplateName(@Param("templateName") TemplateName templateName); | ||
|
||
} |
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
Oops, something went wrong.