-
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.
* feat: 아카이브 탭에 대한 enum 생성 * feat: 아카이브 조회 api 추가 * test: 아카이브 조회 테스트 생성 * fix: 아카이브 조회시 최신순 정렬 * fix: 리뷰 코멘트 반영
- Loading branch information
1 parent
5beec47
commit 3aea445
Showing
17 changed files
with
589 additions
and
18 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
43 changes: 43 additions & 0 deletions
43
src/main/java/com/baro/archive/application/dto/ArchiveUnitResult.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 com.baro.archive.application.dto; | ||
|
||
import com.baro.archive.domain.Archive; | ||
import com.baro.archive.domain.ArchiveTab; | ||
|
||
public record ArchiveUnitResult( | ||
Long archiveId, | ||
String tabName, | ||
String categoryName, | ||
String content, | ||
Integer copiedCount, | ||
Integer savedCount | ||
) { | ||
|
||
public static ArchiveUnitResult of(Archive archive) { | ||
if (archive.isMemo()) { | ||
return memoToArchiveUnit(archive); | ||
} | ||
return templateToArchiveUnit(archive); | ||
} | ||
|
||
private static ArchiveUnitResult memoToArchiveUnit(Archive archive) { | ||
return new ArchiveUnitResult( | ||
archive.getId(), | ||
ArchiveTab.MEMO.getName(), | ||
null, | ||
archive.getContent().value(), | ||
null, | ||
null | ||
); | ||
} | ||
|
||
private static ArchiveUnitResult templateToArchiveUnit(Archive archive) { | ||
return new ArchiveUnitResult( | ||
archive.getId(), | ||
ArchiveTab.TEMPLATE.getName(), | ||
archive.getTemplate().getCategory().getName(), | ||
archive.getContent().value(), | ||
archive.getTemplate().getCopiedCount(), | ||
archive.getTemplate().getSavedCount() | ||
); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/baro/archive/application/dto/GetArchiveQuery.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 com.baro.archive.application.dto; | ||
|
||
import com.baro.archive.domain.ArchiveTab; | ||
|
||
public record GetArchiveQuery( | ||
Long memberId, | ||
Long folderId, | ||
ArchiveTab tab | ||
) { | ||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.baro.archive.domain; | ||
|
||
import com.baro.archive.exception.ArchiveException; | ||
import com.baro.archive.exception.ArchiveExceptionType; | ||
import java.util.Arrays; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
@Getter | ||
public enum ArchiveTab { | ||
ALL("전체"), | ||
MEMO("끄적이는"), | ||
TEMPLATE("참고하는"), | ||
; | ||
|
||
private final String name; | ||
|
||
public static ArchiveTab from(String tabName) { | ||
return Arrays.stream(values()) | ||
.filter(tab -> tab.name().equalsIgnoreCase(tabName)) | ||
.findFirst() | ||
.orElseThrow(() -> new ArchiveException(ArchiveExceptionType.NOT_EXIST_TAB)); | ||
} | ||
} |
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
Oops, something went wrong.