-
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.
Browse files
Browse the repository at this point in the history
fix: 설정 파일 분리
- Loading branch information
Showing
46 changed files
with
478 additions
and
323 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
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
smeem-application/src/main/java/com/smeem/application/config/SmeemConfig.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 com.smeem.application.config; | ||
|
||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@EnableConfigurationProperties(SmeemProperties.class) | ||
public class SmeemConfig { | ||
} |
61 changes: 61 additions & 0 deletions
61
smeem-application/src/main/java/com/smeem/application/config/SmeemProperties.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,61 @@ | ||
package com.smeem.application.config; | ||
|
||
import jakarta.annotation.PostConstruct; | ||
import lombok.Getter; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.util.Base64; | ||
|
||
@Getter | ||
@ConfigurationProperties(prefix = "smeem") | ||
public class SmeemProperties { | ||
private final Secret secret; | ||
private final Duration duration; | ||
private final Client client; | ||
|
||
public SmeemProperties(Secret secret, Duration duration, Client client) { | ||
this.secret = secret; | ||
this.duration = duration; | ||
this.client = client; | ||
} | ||
|
||
@Getter | ||
public static class Secret { | ||
private String key; | ||
|
||
public Secret(String key) { | ||
this.key = key; | ||
} | ||
|
||
@PostConstruct | ||
private void init() { | ||
this.key = Base64.getEncoder().encodeToString(key.getBytes(StandardCharsets.UTF_8)); | ||
} | ||
} | ||
|
||
public record Duration( | ||
int remind, | ||
int expired | ||
) { | ||
} | ||
|
||
public record Client( | ||
Version version | ||
) { | ||
|
||
public record Version( | ||
String title, | ||
String content, | ||
APP ios, | ||
APP android | ||
) { | ||
|
||
public record APP( | ||
String app, | ||
String force | ||
) { | ||
} | ||
} | ||
} | ||
} |
9 changes: 4 additions & 5 deletions
9
smeem-application/src/main/java/com/smeem/application/domain/auth/SecretKeyFactory.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,22 +1,21 @@ | ||
package com.smeem.application.domain.auth; | ||
|
||
import com.smeem.common.util.SmeemProperty; | ||
import com.smeem.application.config.SmeemProperties; | ||
import io.jsonwebtoken.security.Keys; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.val; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.crypto.SecretKey; | ||
|
||
import static java.util.Base64.getEncoder; | ||
import java.util.Base64; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class SecretKeyFactory { | ||
private final SmeemProperty smeemProperty; | ||
private final SmeemProperties smeemProperties; | ||
|
||
public SecretKey create() { | ||
val encodedKey = getEncoder().encodeToString(smeemProperty.getSMEEM_SECRET_KEY().getBytes()); | ||
val encodedKey = Base64.getEncoder().encodeToString(smeemProperties.getSecret().getKey().getBytes()); | ||
return Keys.hmacShaKeyFor(encodedKey.getBytes()); | ||
} | ||
} |
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
22 changes: 0 additions & 22 deletions
22
smeem-application/src/main/java/com/smeem/application/domain/version/Property.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
15 changes: 15 additions & 0 deletions
15
smeem-application/src/main/resources/smeem-config/application-dev.yml
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,15 @@ | ||
smeem: | ||
secret: | ||
key: ${SMEEM_SECRET_KEY} | ||
duration: | ||
remind: ${SMEEM_DURATION_REMIND} | ||
client: | ||
version: | ||
title: ${CLIENT_VERSION_TITLE} | ||
content: ${CLIENT_VERSION_CONTENT} | ||
ios: | ||
app: ${CLIENT_VERSION_IOS_APP} | ||
force: ${CLIENT_VERSION_IOS_FORCE} | ||
android: | ||
app: ${CLIENT_VERSION_ANDROID_APP} | ||
force: ${CLIENT_VERSION_ANDROID_FORCE} |
15 changes: 15 additions & 0 deletions
15
smeem-application/src/main/resources/smeem-config/application-local.yml
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,15 @@ | ||
smeem: | ||
secret: | ||
key: ${SMEEM_SECRET_KEY} | ||
duration: | ||
remind: ${SMEEM_DURATION_REMIND} | ||
client: | ||
version: | ||
title: ${CLIENT_VERSION_TITLE} | ||
content: ${CLIENT_VERSION_CONTENT} | ||
ios: | ||
app: ${CLIENT_VERSION_IOS_APP} | ||
force: ${CLIENT_VERSION_IOS_FORCE} | ||
android: | ||
app: ${CLIENT_VERSION_ANDROID_APP} | ||
force: ${CLIENT_VERSION_ANDROID_FORCE} |
15 changes: 15 additions & 0 deletions
15
smeem-application/src/main/resources/smeem-config/application-prod.yml
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,15 @@ | ||
smeem: | ||
secret: | ||
key: ${SMEEM_SECRET_KEY} | ||
duration: | ||
remind: ${SMEEM_DURATION_REMIND} | ||
client: | ||
version: | ||
title: ${CLIENT_VERSION_TITLE} | ||
content: ${CLIENT_VERSION_CONTENT} | ||
ios: | ||
app: ${CLIENT_VERSION_IOS_APP} | ||
force: ${CLIENT_VERSION_IOS_FORCE} | ||
android: | ||
app: ${CLIENT_VERSION_ANDROID_APP} | ||
force: ${CLIENT_VERSION_ANDROID_FORCE} |
10 changes: 5 additions & 5 deletions
10
smeem-batch/src/main/java/com/smeem/batch/scheduler/DiaryScheduler.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,21 +1,21 @@ | ||
package com.smeem.batch.scheduler; | ||
|
||
import com.smeem.application.config.SmeemProperties; | ||
import com.smeem.application.port.input.DiaryUseCase; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import lombok.val; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class DiaryScheduler { | ||
private final DiaryUseCase diaryUseCase; | ||
|
||
@Value("${smeem.duration.expired}") | ||
private int DURATION_EXPIRED; | ||
private final SmeemProperties smeemProperties; | ||
|
||
@Scheduled(cron = "0 0 0 * * *") | ||
public void deleteExpiredDiaries() { | ||
diaryUseCase.deleteExpiredDiaries(DURATION_EXPIRED); | ||
val expiredDuration = smeemProperties.getDuration().expired(); | ||
diaryUseCase.deleteExpiredDiaries(expiredDuration); | ||
} | ||
} |
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.