-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from inu-appcenter/wonjeong#58-refactor-ocp
- Loading branch information
Showing
15 changed files
with
80 additions
and
36 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
|
||
public interface BoardRepository<T extends Board> extends JpaRepository<T, Long> { | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
...ain/java/server/inuappcenter/kr/service/boardService/AdditionalBoardStrategyProvider.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,10 @@ | ||
package server.inuappcenter.kr.service.boardService; | ||
|
||
import server.inuappcenter.kr.data.dto.response.BoardResponseDto; | ||
|
||
import java.util.List; | ||
|
||
public interface AdditionalBoardStrategyProvider { | ||
List<BoardResponseDto> findBoardList(String boardName, String topic); | ||
List<BoardResponseDto> findBoardList(String boardName); | ||
} |
43 changes: 43 additions & 0 deletions
43
...java/server/inuappcenter/kr/service/boardService/AdditionalBoardStrategyProviderImpl.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,43 @@ | ||
package server.inuappcenter.kr.service.boardService; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
import server.inuappcenter.kr.data.dto.response.BoardResponseDto; | ||
import server.inuappcenter.kr.service.boardService.impl.AdditionalBoardService; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Component | ||
public class AdditionalBoardStrategyProviderImpl implements AdditionalBoardStrategyProvider { | ||
private static final Logger log = LoggerFactory.getLogger(AdditionalBoardStrategyProviderImpl.class); | ||
private final Map<String, AdditionalBoardService> boardStrategyMap; | ||
|
||
@Autowired | ||
public AdditionalBoardStrategyProviderImpl(List<AdditionalBoardService> additionalBoardServices) { | ||
this.boardStrategyMap = new HashMap<>(); | ||
for (AdditionalBoardService additionalBoardService : additionalBoardServices) { | ||
String key = additionalBoardService.getClass().getSimpleName().toLowerCase(); | ||
int index = key.indexOf("$"); | ||
this.boardStrategyMap.put(key.substring(0, index), additionalBoardService); | ||
} | ||
} | ||
|
||
|
||
@Override | ||
public List<BoardResponseDto> findBoardList(String boardName, String topic) { | ||
AdditionalBoardService additionalBoardService = boardStrategyMap.get(boardName.toLowerCase()); | ||
return additionalBoardService.findBoardList(topic); | ||
} | ||
|
||
@Override | ||
public List<BoardResponseDto> findBoardList(String boardName) { | ||
log.info("getTest"); | ||
AdditionalBoardService additionalBoardService = boardStrategyMap.get(boardName.toLowerCase()); | ||
System.out.println(additionalBoardService.getClass().getSimpleName()); | ||
return additionalBoardService.findBoardList(null); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../boardService/AdditionalBoardService.java → ...dService/impl/AdditionalBoardService.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
4 changes: 3 additions & 1 deletion
4
src/main/java/server/inuappcenter/kr/service/boardService/impl/IntroBoardServiceImpl.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
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
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