Skip to content

Commit

Permalink
Feat/#167 : 지연 알림 전송 배치 모듈을 구현합니다. (#170)
Browse files Browse the repository at this point in the history
* Feat : 토큰 업데이트 구현

* Feat : Controller DTO 수정

* Test : 회원가입 테스트

* Feat(batch) : batch 모듈 추가 및 초기 설정

* Feat(app) : 일기 시간 조회시 답변 타입도 같이 반환

* Feat(infra) : batch를 위한 meta DataSource 설정파일

* Feat(infra) : Schedule Repository Adapter계층 구현

* Feat(domain) : 도메인 계층 모델 정의

* Feat(domain) : 답변 작성시 알림 스케줄 이벤트 발행

- 추가적으로 SQS 로 메세지 발행 시, UserId 또한 포함하여 발송하도록 수정하였습니다.

* Chore(etc) : 사용하지 않는 파일 제거 및 형식 변경

* Feat(batch) : build.gradle

* Feat(batch) : config 추가

* Feat(batch) : Job 및 Step 구현

* Test(batch) : 일기 작성 알림 테스트

* Feat(domain) : schedule 엔티티 구현

* Feat(infra) : adapter 계층 구현

* Chore : 기타 파일 수정
  • Loading branch information
hyunw9 authored Aug 29, 2024
1 parent e693a75 commit b3c4792
Show file tree
Hide file tree
Showing 55 changed files with 1,147 additions and 108 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,4 @@ replay_pid*
*.lock
*.bin
*.probe
/clody-batch/build
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.clody.clodyapi.diary.controller.dto.response;

import com.clody.domain.reply.ReplyType;

public record DiaryCreatedTimeResponse(
int HH,
int mm,
int ss
int ss,
ReplyType replyType
) {
public static DiaryCreatedTimeResponse of(int HH, int mm, int ss) {
return new DiaryCreatedTimeResponse(HH, mm, ss);
public static DiaryCreatedTimeResponse of(int HH, int mm, int ss, ReplyType type) {
return new DiaryCreatedTimeResponse(HH, mm, ss, type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.clody.domain.diary.dto.DiaryDomainInfo;
import com.clody.domain.diary.dto.DiaryListGetResponse;
import com.clody.domain.diary.dto.response.DiaryCalenderGetResponse;
import com.clody.domain.diary.dto.response.DiaryCreatedInfo;
import com.clody.domain.diary.dto.response.DiaryDayInfo;
import com.clody.domain.diary.dto.response.DiaryListInfo;
import com.clody.domain.reply.ReplyType;
Expand Down Expand Up @@ -37,9 +38,8 @@ public static DiaryDateInfo toDiaryDateInfo(int year, int month, int date) {
return DiaryDateInfo.of(year, month, date);
}

public static DiaryCreatedTimeResponse toDiaryCreatedTimeResponse(int hour, int minute,
int second) {
return DiaryCreatedTimeResponse.of(hour, minute, second);
public static DiaryCreatedTimeResponse toDiaryCreatedTimeResponse(DiaryCreatedInfo info) {
return DiaryCreatedTimeResponse.of(info.HH(), info.MM(), info.SS(), info.replyType());
}

public static DiaryListGetResponse toDiaryListResponse(DiaryListInfo diaryListInfo){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.clody.clodyapi.diary.usecase.DiaryQueryUsecase;
import com.clody.domain.diary.dto.DiaryContent;
import com.clody.domain.diary.dto.DiaryDateInfo;
import com.clody.domain.diary.dto.response.DiaryTimeInfo;
import com.clody.domain.diary.dto.response.DiaryCreatedInfo;
import com.clody.domain.diary.service.DiaryQueryService;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand All @@ -21,14 +21,13 @@ public class DiaryRetrievalService implements DiaryQueryUsecase {
@Override
public DiaryCreatedTimeResponse getCreatedTime(int year, int month, int date) {
DiaryDateInfo diaryDateInfo = DiaryMapper.toDiaryDateInfo(year, month, date);
DiaryTimeInfo diaryTimeInfo = diaryQueryService.getCreatedTime(diaryDateInfo);
DiaryCreatedInfo diaryCreatedInfo = diaryQueryService.getCreatedTime(diaryDateInfo);

return DiaryMapper.toDiaryCreatedTimeResponse(diaryTimeInfo.HH(), diaryTimeInfo.MM(),
diaryTimeInfo.SS());
return DiaryMapper.toDiaryCreatedTimeResponse(diaryCreatedInfo);
}

@Override
public DiaryResponse getDiary(final int year,final int month,final int date) {
public DiaryResponse getDiary(final int year, final int month, final int date) {
DiaryDateInfo diaryDateInfo = DiaryMapper.toDiaryDateInfo(year, month, date);
List<DiaryContent> diaryContentList = diaryQueryService.getDiary(diaryDateInfo);
return DiaryMapper.toDiaryResponse(diaryContentList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static ReplyInsertionInfo toReplyInsertionInfo(Message message) {
}

public static Message parseToMessage(Reply reply) {
return Message.of(reply.getId(), reply.getContent(), reply.getVersion(),reply.getReplyType());
return Message.of(reply.getId(),reply.getUser().getId(), reply.getContent(), reply.getVersion(),reply.getReplyType());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.clody.clodyapi.alarm.service;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
class AlarmUpdateServiceTest {

@Test
void updateAlarmInfo() {

}

@Test
void updateFcmToken() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class UserApplicationServiceTest {

// then
assertNotNull(response);
verify(alarmUpdateService).updateFcmToken(userSignUpRequest.fcmToken());
verify(alarmUpdateService).updateFcmToken(newUser.getId(),userSignUpRequest.fcmToken());
}

}
47 changes: 47 additions & 0 deletions clody-batch/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
import org.gradle.internal.impldep.org.junit.experimental.categories.Categories.CategoryFilter.include

plugins {
java
id("org.springframework.boot") version "3.3.0"
}

group = "com.clody"
version = "0.0.1-SNAPSHOT"

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

repositories {
mavenCentral()
}

dependencies {
implementation(project(":clody-domain"))
implementation(project(":clody-infra"))
implementation("org.springframework.boot:spring-boot-starter-batch")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.batch:spring-batch-test")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")

//Lombok
annotationProcessor("org.projectlombok:lombok")
compileOnly("org.projectlombok:lombok")

runtimeOnly("org.postgresql:postgresql")

}

tasks.withType<Test> {
useJUnitPlatform()
}

the<DependencyManagementExtension>().apply {
imports {
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudDependenciesVersion")}")
}
}
7 changes: 7 additions & 0 deletions clody-batch/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit b3c4792

Please sign in to comment.