-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [REPACKAGE] avatar/model -> avatar/domain 으로 패키지 이전 * [FEAT] 기본 아바타 대사 전략 구현 * [FEAT] 음식 조건 전략 구현 * [MIGRATION] sql: avatar 6번 대사 추가, 조건 변경 및 삽입문에서 id 제거 * [FEAT] RandomFoodProvider에서 반환하는 음식 종류 추가 * [FEAT] 아바타 대사 시간 조건 전략 구현 * [FEAT] 한국 음력 달력 변환기 구현 * [REFACTOR, FEAT] 대사 제공 서비스 리팩터링 및 음력 날짜에 따른 대사 제공 기능 구현
- Loading branch information
Showing
27 changed files
with
474 additions
and
105 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
6 changes: 6 additions & 0 deletions
6
src/main/java/com/wakeUpTogetUp/togetUp/api/avatar/application/RandomFoodProvider.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,6 @@ | ||
package com.wakeUpTogetUp.togetUp.api.avatar.application; | ||
|
||
public interface RandomFoodProvider { | ||
|
||
String getRandomFoodWord(); | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/wakeUpTogetUp/togetUp/api/avatar/application/SpeechStrategyFactory.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,33 @@ | ||
package com.wakeUpTogetUp.togetUp.api.avatar.application; | ||
|
||
import com.wakeUpTogetUp.togetUp.api.avatar.application.strategy.BasicSpeechStrategy; | ||
import com.wakeUpTogetUp.togetUp.api.avatar.application.strategy.FoodSpeechStrategy; | ||
import com.wakeUpTogetUp.togetUp.api.avatar.application.strategy.SpeechStrategy; | ||
import com.wakeUpTogetUp.togetUp.api.avatar.application.strategy.TimeSpeechStrategy; | ||
import com.wakeUpTogetUp.togetUp.api.avatar.domain.AvatarSpeechCondition; | ||
import java.util.EnumMap; | ||
import java.util.Map; | ||
import javax.annotation.PostConstruct; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class SpeechStrategyFactory { | ||
private static final Map<AvatarSpeechCondition, SpeechStrategy> strategies = new EnumMap<>(AvatarSpeechCondition.class); | ||
private final BasicSpeechStrategy basicSpeechStrategy; | ||
private final FoodSpeechStrategy foodSpeechStrategy; | ||
private final TimeSpeechStrategy timeSpeechStrategy; | ||
|
||
@PostConstruct | ||
public void init() { | ||
strategies.put(AvatarSpeechCondition.DEFAULT, basicSpeechStrategy); | ||
strategies.put(AvatarSpeechCondition.NONE, basicSpeechStrategy); | ||
strategies.put(AvatarSpeechCondition.FOOD, foodSpeechStrategy); | ||
strategies.put(AvatarSpeechCondition.TIME, timeSpeechStrategy); | ||
} | ||
|
||
public SpeechStrategy getStrategy(AvatarSpeechCondition condition) { | ||
return strategies.getOrDefault(condition, new BasicSpeechStrategy()); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
src/main/java/com/wakeUpTogetUp/togetUp/api/avatar/application/UserAvatarQueryService.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
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
2 changes: 1 addition & 1 deletion
2
...in/java/com/wakeUpTogetUp/togetUp/api/avatar/application/UserAvatarValidationService.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
13 changes: 13 additions & 0 deletions
13
...n/java/com/wakeUpTogetUp/togetUp/api/avatar/application/strategy/BasicSpeechStrategy.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,13 @@ | ||
package com.wakeUpTogetUp.togetUp.api.avatar.application.strategy; | ||
|
||
import com.wakeUpTogetUp.togetUp.api.avatar.domain.AvatarSpeech; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class BasicSpeechStrategy implements SpeechStrategy{ | ||
|
||
@Override | ||
public String makeSpeech(AvatarSpeech avatarSpeech) { | ||
return avatarSpeech.getSpeech(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...in/java/com/wakeUpTogetUp/togetUp/api/avatar/application/strategy/FoodSpeechStrategy.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,18 @@ | ||
package com.wakeUpTogetUp.togetUp.api.avatar.application.strategy; | ||
|
||
import com.wakeUpTogetUp.togetUp.api.avatar.application.RandomFoodProvider; | ||
import com.wakeUpTogetUp.togetUp.api.avatar.domain.AvatarSpeech; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class FoodSpeechStrategy implements SpeechStrategy{ | ||
|
||
private final RandomFoodProvider randomFoodProvider; | ||
|
||
@Override | ||
public String makeSpeech(AvatarSpeech avatarSpeech) { | ||
return String.format(avatarSpeech.getSpeech(), randomFoodProvider.getRandomFoodWord()); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/wakeUpTogetUp/togetUp/api/avatar/application/strategy/SpeechStrategy.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,8 @@ | ||
package com.wakeUpTogetUp.togetUp.api.avatar.application.strategy; | ||
|
||
import com.wakeUpTogetUp.togetUp.api.avatar.domain.AvatarSpeech; | ||
|
||
public interface SpeechStrategy { | ||
|
||
String makeSpeech(AvatarSpeech avatarSpeech); | ||
} |
16 changes: 16 additions & 0 deletions
16
...in/java/com/wakeUpTogetUp/togetUp/api/avatar/application/strategy/TimeSpeechStrategy.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,16 @@ | ||
package com.wakeUpTogetUp.togetUp.api.avatar.application.strategy; | ||
|
||
import com.wakeUpTogetUp.togetUp.api.avatar.domain.AvatarSpeech; | ||
import com.wakeUpTogetUp.togetUp.utils.DateTimeProvider; | ||
import java.time.LocalDateTime; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class TimeSpeechStrategy implements SpeechStrategy{ | ||
|
||
@Override | ||
public String makeSpeech(AvatarSpeech avatarSpeech) { | ||
LocalDateTime now = DateTimeProvider.getCurrentDateTimeInSeoul(); | ||
return String.format(avatarSpeech.getSpeech(), now.getHour(), now.getMinute()); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...etUp/togetUp/api/avatar/model/Avatar.java → ...tUp/togetUp/api/avatar/domain/Avatar.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
2 changes: 1 addition & 1 deletion
2
...ogetUp/api/avatar/model/AvatarSpeech.java → ...getUp/api/avatar/domain/AvatarSpeech.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
13 changes: 13 additions & 0 deletions
13
src/main/java/com/wakeUpTogetUp/togetUp/api/avatar/domain/AvatarSpeechCondition.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,13 @@ | ||
package com.wakeUpTogetUp.togetUp.api.avatar.domain; | ||
|
||
public enum AvatarSpeechCondition { | ||
|
||
DEFAULT, | ||
NONE, | ||
FOOD, | ||
TIME, | ||
NEW_MOON, | ||
HALF_MOON, | ||
FULL_MOON | ||
; | ||
} |
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
2 changes: 1 addition & 1 deletion
2
.../togetUp/api/avatar/model/UserAvatar.java → ...togetUp/api/avatar/domain/UserAvatar.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
8 changes: 0 additions & 8 deletions
8
src/main/java/com/wakeUpTogetUp/togetUp/api/avatar/model/AvatarSpeechCondition.java
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/main/java/com/wakeUpTogetUp/togetUp/api/avatar/repository/AvatarRepository.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
6 changes: 5 additions & 1 deletion
6
src/main/java/com/wakeUpTogetUp/togetUp/api/avatar/repository/AvatarSpeechRepository.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,10 +1,14 @@ | ||
package com.wakeUpTogetUp.togetUp.api.avatar.repository; | ||
|
||
import com.wakeUpTogetUp.togetUp.api.avatar.model.AvatarSpeech; | ||
import com.wakeUpTogetUp.togetUp.api.avatar.domain.AvatarSpeech; | ||
import com.wakeUpTogetUp.togetUp.api.avatar.domain.AvatarSpeechCondition; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface AvatarSpeechRepository extends JpaRepository<AvatarSpeech, Integer> { | ||
|
||
List<AvatarSpeech> findAllByAvatar_Id(int avatarId); | ||
|
||
Optional<AvatarSpeech> findByAvatarIdAndCondition(Integer avatarId, AvatarSpeechCondition condition); | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/java/com/wakeUpTogetUp/togetUp/api/avatar/repository/UserAvatarRepository.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
Oops, something went wrong.