Skip to content

Commit b6fd6b8

Browse files
committed
chore: Email domain - is_mail_send field 추가
1 parent d4c618b commit b6fd6b8

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/main/java/com/gdg/poppet/chat/domain/model/ChatRoom.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,17 @@ public class ChatRoom extends BaseEntity {
2828

2929
private String username; // TODO: user 간접 참조
3030

31+
@Column(name = "is_mail_sent", nullable = false, columnDefinition = "BOOLEAN DEFAULT false")
32+
private boolean isMailSent;
33+
3134
@OneToMany(mappedBy = "chatRoom", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
3235
private List<Chat> chats;
3336

3437
public boolean isValidChatRoom(LocalDate emailPeriodDate) {
3538
return !getCreatedAt().toLocalDate().isBefore(emailPeriodDate);
3639
}
40+
41+
public void updateIsMailSent() {
42+
isMailSent = true;
43+
}
3744
}

src/main/java/com/gdg/poppet/chat/domain/repository/ChatRoomRepository.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,11 @@ public interface ChatRoomRepository extends JpaRepository<ChatRoom, Long> {
2424
"FROM ChatRoom cr " +
2525
"WHERE cr.chatRoomId = :chatRoomId")
2626
void deleteChatRoomByChatRoomId(@Param(value = "chatRoomId") Long chatRoomId);
27+
28+
@Query(value = "SELECT cr " +
29+
"FROM ChatRoom cr " +
30+
"WHERE cr.username = :username " +
31+
"AND cr.isMailSent = FALSE " +
32+
"ORDER BY cr.createdAt DESC")
33+
List<ChatRoom> findByUsernameAndCreatedAtAndIsMailSent(@Param(value = "username") String username);
2734
}

src/main/java/com/gdg/poppet/email/presentation/EmailController.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,13 @@ public ResponseEntity<ApiResponse<String>> deleteEmail(
6767
emailService.deleteEmailAddress(name, emailId);
6868
return ApiResponse.success(SuccessStatus.DELETE_EMAIL_SUCCESS);
6969
}
70+
71+
@GetMapping("/send")
72+
public ResponseEntity<ApiResponse<EmailDto>> sendEmail(
73+
@RequestParam("name") String name
74+
) {
75+
emailService.sendEmail(name);
76+
// TODO: 이메일 발송 후 response 수정
77+
return ApiResponse.success(SuccessStatus.OK);
78+
}
7079
}

0 commit comments

Comments
 (0)