Skip to content

Commit

Permalink
[Refactor] time column change data type #74 (#168)
Browse files Browse the repository at this point in the history
* setting: QueryDsl Qclass 생성 후 페키지 복사하도록 설정 완료

* feat(NoticeDateTime): NoticeDateTime 구현

* feat: NoticeDateTime을 Notice에 적용하기

* refactor(CategoryName): 지원 카테고리 순서 변경

* fix(NoticeDateTime): NoticeDateTime 에 null이나 empty string이 들어오는 경우도 처리하도록 추가 구현

* feat(FakeFirebaseAdapter): Loacal과 test에서 사용하게 될 FakeFirebaseAdapter 구현

* feat: 공지 시간 관련 UPDATE문 작성

* fix(LatestPageNoticeHtmlParser): 파서에서 noticeId를 3자리라 가정하고 파싱하던 문제 수정

* feat(LatestPageNoticeHtmlParserTwo): 더이상 사용하지 않는 LatestPageNoticeHtmlParserTwo 제거

* feat: prod-kr을 임시의 테스트 서버로 변경
  • Loading branch information
zbqmgldjfh authored Mar 29, 2024
1 parent 0b0c0ad commit 5adc4c0
Show file tree
Hide file tree
Showing 32 changed files with 1,739 additions and 921 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/prod-kr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: Deploy to prod KR
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ main ]
branches: [ develop ]

env:
GPG_PASSPHRASE: ${{ secrets.KR_PROD_GPG_PASSPHRASE }}
Expand Down
90 changes: 0 additions & 90 deletions .github/workflows/dev.yml

This file was deleted.

11 changes: 10 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,16 @@ jar {
}

// -- QueryDsl 설정 -------------------------------------------------------
//Querydsl 추가, 자동 생성된 Q클래스 gradle clean으로 제거
//Querydsl 추가
def querydslSrcDir = 'src/main/generated'
clean {
delete file(querydslSrcDir)
}
tasks.withType(JavaCompile) {
options.generatedSourceOutputDirectory = file(querydslSrcDir)
}

// 자동 생성된 Q클래스 gradle clean으로 제거
clean {
delete file('src/main/generated')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class AdminCommandService implements AdminCommandUseCase {
@Override
public void createTestNotice(TestNotificationCommand command) {
String testNoticePostedDate = LocalDateTime.now()
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));

CategoryName testCategoryName = CategoryName.fromStringName(command.category());

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.kustacks.kuring.message.adapter.out.firebase;

import com.google.firebase.messaging.FirebaseMessagingException;
import com.google.firebase.messaging.Message;
import com.kustacks.kuring.message.application.port.out.FirebaseAuthPort;
import com.kustacks.kuring.message.application.port.out.FirebaseMessagingPort;
import com.kustacks.kuring.message.application.port.out.FirebaseSubscribePort;
import com.kustacks.kuring.message.application.service.exception.FirebaseInvalidTokenException;
import com.kustacks.kuring.message.application.service.exception.FirebaseSubscribeException;
import com.kustacks.kuring.message.application.service.exception.FirebaseUnSubscribeException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
@Profile("local | test")
@RequiredArgsConstructor
public class FakeFirebaseAdapter implements FirebaseSubscribePort, FirebaseAuthPort, FirebaseMessagingPort {

@Override
public void verifyIdToken(String idToken) throws FirebaseInvalidTokenException {
log.info("FirebaseAdapter.verifyIdToken()");
}

@Override
public void subscribeToTopic(
List<String> tokens,
String topic
) throws FirebaseSubscribeException {
log.info("FirebaseAdapter.subscribeToTopic()");
}

@Override
public void unsubscribeFromTopic(
List<String> tokens,
String topic
) throws FirebaseUnSubscribeException {
log.info("FirebaseAdapter.unsubscribeFromTopic()");
}

@Override
public void send(Message message) throws FirebaseMessagingException {
log.info("FirebaseAdapter.send()");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,73 @@

import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseAuthException;
import com.google.firebase.auth.FirebaseToken;
import com.google.firebase.messaging.FirebaseMessaging;
import com.google.firebase.messaging.FirebaseMessagingException;
import com.google.firebase.messaging.Message;
import com.google.firebase.messaging.TopicManagementResponse;
import com.kustacks.kuring.message.application.port.out.FirebaseAuthPort;
import com.kustacks.kuring.message.application.port.out.FirebaseMessagingPort;
import com.kustacks.kuring.message.application.port.out.FirebaseSubscribePort;
import com.kustacks.kuring.message.application.service.exception.FirebaseInvalidTokenException;
import com.kustacks.kuring.message.application.service.exception.FirebaseSubscribeException;
import com.kustacks.kuring.message.application.service.exception.FirebaseUnSubscribeException;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Profile("prod | dev")
@RequiredArgsConstructor
public class FirebaseAdapter implements FirebaseSubscribePort, FirebaseAuthPort, FirebaseMessagingPort {

private final FirebaseMessaging firebaseMessaging;
private final FirebaseAuth firebaseAuth;

@Override
public FirebaseToken verifyIdToken(String idToken) throws FirebaseAuthException {
return firebaseAuth.verifyIdToken(idToken);
public void verifyIdToken(String idToken) throws FirebaseInvalidTokenException {
try {
firebaseAuth.verifyIdToken(idToken);
} catch (FirebaseAuthException exception) {
throw new FirebaseInvalidTokenException();
}
}

@Override
public TopicManagementResponse subscribeToTopic(
public void subscribeToTopic(
List<String> tokens,
String topic
) throws FirebaseMessagingException {
return firebaseMessaging.subscribeToTopic(tokens, topic);
) throws FirebaseSubscribeException {
try {
TopicManagementResponse response = firebaseMessaging.subscribeToTopic(tokens, topic);

if (response.getFailureCount() > 0) {
throw new FirebaseSubscribeException();
}
} catch (FirebaseMessagingException | FirebaseSubscribeException exception) {
throw new FirebaseSubscribeException();
}
}

@Override
public TopicManagementResponse unsubscribeFromTopic(
public void unsubscribeFromTopic(
List<String> tokens,
String topic
) throws FirebaseMessagingException {
return firebaseMessaging.unsubscribeFromTopic(tokens, topic);
) throws FirebaseUnSubscribeException {
try {
TopicManagementResponse response = firebaseMessaging.unsubscribeFromTopic(tokens, topic);

if (response.getFailureCount() > 0) {
throw new FirebaseUnSubscribeException();
}
} catch (FirebaseMessagingException | FirebaseUnSubscribeException exception) {
throw new FirebaseUnSubscribeException();
}
}

@Override
public String send(Message message) throws FirebaseMessagingException {
return firebaseMessaging.send(message);
public void send(Message message) throws FirebaseMessagingException {
firebaseMessaging.send(message);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.kustacks.kuring.message.application.port.out;

import com.google.firebase.auth.FirebaseAuthException;
import com.google.firebase.auth.FirebaseToken;
import com.kustacks.kuring.message.application.service.exception.FirebaseInvalidTokenException;

public interface FirebaseAuthPort {
FirebaseToken verifyIdToken(String idToken) throws FirebaseAuthException;
void verifyIdToken(String idToken) throws FirebaseInvalidTokenException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
import com.google.firebase.messaging.Message;

public interface FirebaseMessagingPort {
String send(Message message) throws FirebaseMessagingException;
void send(Message message) throws FirebaseMessagingException;
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.kustacks.kuring.message.application.port.out;

import com.google.firebase.messaging.FirebaseMessagingException;
import com.google.firebase.messaging.TopicManagementResponse;
import com.kustacks.kuring.message.application.service.exception.FirebaseSubscribeException;
import com.kustacks.kuring.message.application.service.exception.FirebaseUnSubscribeException;

import java.util.List;

public interface FirebaseSubscribePort {
TopicManagementResponse subscribeToTopic(List<String> tokens, String topic) throws FirebaseMessagingException;
TopicManagementResponse unsubscribeFromTopic(List<String> tokens, String topic) throws FirebaseMessagingException;
void subscribeToTopic(List<String> tokens, String topic) throws FirebaseSubscribeException;
void unsubscribeFromTopic(List<String> tokens, String topic) throws FirebaseUnSubscribeException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.google.firebase.messaging.FirebaseMessagingException;
import com.google.firebase.messaging.Message;
import com.google.firebase.messaging.TopicManagementResponse;
import com.kustacks.kuring.common.annotation.UseCase;
import com.kustacks.kuring.common.properties.ServerProperties;
import com.kustacks.kuring.message.application.port.in.FirebaseWithUserUseCase;
Expand All @@ -13,10 +12,11 @@
import com.kustacks.kuring.message.application.service.exception.FirebaseInvalidTokenException;
import com.kustacks.kuring.message.application.service.exception.FirebaseSubscribeException;
import com.kustacks.kuring.message.application.service.exception.FirebaseUnSubscribeException;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
@UseCase
@RequiredArgsConstructor
Expand All @@ -41,30 +41,23 @@ public void validationToken(String token) throws FirebaseInvalidTokenException {
@Override
public void subscribe(UserSubscribeCommand command) throws FirebaseSubscribeException {
try {
TopicManagementResponse response = firebaseSubscribePort
.subscribeToTopic(
List.of(command.token()),
serverProperties.ifDevThenAddSuffix(command.topic())
);

if (response.getFailureCount() > 0) {
throw new FirebaseSubscribeException();
}
} catch (FirebaseMessagingException | FirebaseSubscribeException exception) {
firebaseSubscribePort.subscribeToTopic(
List.of(command.token()),
serverProperties.ifDevThenAddSuffix(command.topic())
);
} catch (FirebaseSubscribeException exception) {
throw new FirebaseSubscribeException();
}
}

@Override
public void unsubscribe(UserUnsubscribeCommand command) throws FirebaseUnSubscribeException {
try {
TopicManagementResponse response = firebaseSubscribePort
.unsubscribeFromTopic(List.of(command.token()), serverProperties.ifDevThenAddSuffix(command.topic()));

if (response.getFailureCount() > 0) {
throw new FirebaseUnSubscribeException();
}
} catch (FirebaseMessagingException | FirebaseUnSubscribeException exception) {
firebaseSubscribePort.unsubscribeFromTopic(
List.of(command.token()),
serverProperties.ifDevThenAddSuffix(command.topic())
);
} catch (FirebaseUnSubscribeException exception) {
throw new FirebaseUnSubscribeException();
}
}
Expand Down
Loading

0 comments on commit 5adc4c0

Please sign in to comment.