-
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.
refactor : 캐릭터 도감 조회 관련 domain 모듈과 api 모듈의 책임 할당 문제 리팩토링 (#104)
* refactor : CharacterBook 애그리거트 삭제 * refactor : database 모듈 character 변경 * refactor : package 명view -> domain 으로 변경 * refactor : CharacterBook 애그리거트 제거 및 CharacterBookView 일급컬렉션 도입 * docs : docs 업데이트 * refactor : CharacterBookReadController 변경에 따른 리팩토링
- Loading branch information
1 parent
ae583b1
commit f356edd
Showing
33 changed files
with
616 additions
and
585 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
35 changes: 35 additions & 0 deletions
35
src/main/java/univ/earthbreaker/namu/core/api/character/CharacterBookResponse.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,35 @@ | ||
package univ.earthbreaker.namu.core.api.character; | ||
|
||
import java.util.List; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import univ.earthbreaker.namu.core.domain.character.CharacterType; | ||
import univ.earthbreaker.namu.core.domain.common.Constant; | ||
|
||
public record CharacterBookResponse( | ||
int totalAcquiredCount, | ||
List<BookSectionResponse> sectionResponses | ||
) { | ||
record BookSectionResponse( | ||
CharacterType type, | ||
int totalCountOfType, | ||
int acquiredCount, | ||
List<ProfileResponse> profileResponses | ||
) { | ||
} | ||
|
||
record ProfileResponse( | ||
long characterNo, | ||
String thumbnailImageUrl, | ||
boolean isAcquired | ||
) { | ||
static @NotNull ProfileResponse of(long characterNo, String thumbnailImagePath, boolean isAcquired) { | ||
return new ProfileResponse( | ||
characterNo, | ||
Constant.IMAGE_ACCESS_URL + thumbnailImagePath, | ||
isAcquired | ||
); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/univ/earthbreaker/namu/core/api/character/CharacterBookView.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,44 @@ | ||
package univ.earthbreaker.namu.core.api.character; | ||
|
||
import java.util.List; | ||
|
||
import univ.earthbreaker.namu.core.domain.character.CharacterType; | ||
import univ.earthbreaker.namu.core.domain.character.book.MemberCharacter; | ||
|
||
public class CharacterBookView { | ||
|
||
private final List<MemberCharacter> values; | ||
|
||
public CharacterBookView(List<MemberCharacter> values) { | ||
this.values = values; | ||
} | ||
|
||
int readTotalAcquiredCharacterCount() { | ||
return values.stream() | ||
.mapToInt(MemberCharacter::getCount) | ||
.sum(); | ||
} | ||
|
||
int readAcquiredCharacterCountByType(CharacterType type) { | ||
return (int)values.stream() | ||
.filter(memberCharacter -> memberCharacter.isSameWithCharacterType(type) && memberCharacter.isAcquired()) | ||
.count(); | ||
} | ||
|
||
int readTotalCountOfType(CharacterType type) { | ||
return (int)values.stream() | ||
.filter(memberCharacter -> memberCharacter.isSameWithCharacterType(type)) | ||
.count(); | ||
} | ||
|
||
List<CharacterBookResponse.ProfileResponse> readCharactersByType(CharacterType type) { | ||
return values.stream() | ||
.filter(memberCharacter -> memberCharacter.isSameWithCharacterType(type)) | ||
.map(memberCharacter -> CharacterBookResponse.ProfileResponse.of( | ||
memberCharacter.getCharacterNo(), | ||
memberCharacter.getThumbnailImagePath(), | ||
memberCharacter.isAcquired() | ||
)) | ||
.toList(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/univ/earthbreaker/namu/core/api/character/CharacterBookViewReader.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 univ.earthbreaker.namu.core.api.character; | ||
|
||
import univ.earthbreaker.namu.core.domain.character.CharacterType; | ||
|
||
public class CharacterBookViewReader { | ||
|
||
private CharacterBookViewReader() { | ||
} | ||
|
||
static CharacterBookResponse.BookSectionResponse readByType(CharacterBookView book, CharacterType type) { | ||
return new CharacterBookResponse.BookSectionResponse( | ||
type, | ||
book.readTotalCountOfType(type), | ||
book.readAcquiredCharacterCountByType(type), | ||
book.readCharactersByType(type) | ||
); | ||
} | ||
} |
9 changes: 0 additions & 9 deletions
9
src/main/java/univ/earthbreaker/namu/core/domain/character/book/BookResult.java
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
src/main/java/univ/earthbreaker/namu/core/domain/character/book/BookSectionResult.java
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
src/main/java/univ/earthbreaker/namu/core/domain/character/book/CharacterBook.java
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
src/main/java/univ/earthbreaker/namu/core/domain/character/book/CharacterBookFinder.java
This file was deleted.
Oops, something went wrong.
64 changes: 0 additions & 64 deletions
64
src/main/java/univ/earthbreaker/namu/core/domain/character/book/CharacterBookMapper.java
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
...main/java/univ/earthbreaker/namu/core/domain/character/book/CharacterBookReadService.java
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
src/main/java/univ/earthbreaker/namu/core/domain/character/book/CharacterBookReader.java
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
src/main/java/univ/earthbreaker/namu/core/domain/character/book/CharacterDetailInfo.java
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
src/main/java/univ/earthbreaker/namu/core/domain/character/book/CharacterProfileResult.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.