Repository navigation
feat: 내 템플릿 목록 API (#66) #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e066344
feat: 휴지통 제외 내 템플릿을 생성 순으로 읽는 조회 추가 (#66)
oTAETAEo 20aa877
feat: 내 템플릿 목록 조회 서비스 구현 (#66)
oTAETAEo 7790d97
feat: 내 템플릿 목록 API 구현 (#66)
oTAETAEo 5424ad3
refactor: 내 템플릿 목록 컨트롤러의 서비스 호출을 변수로 분리 (#66)
oTAETAEo 5ff7b69
Merge remote-tracking branch 'origin/develop' into feat/66-template-list
oTAETAEo 4a266a8
test: 복구한 템플릿의 목록 위치를 실제 복구 API로 검증 (#66)
oTAETAEo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
33 changes: 33 additions & 0 deletions
33
src/main/java/com/sniptext/domain/template/controller/dto/TemplateListItemResponse.java
This file contains hidden or 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.sniptext.domain.template.controller.dto; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
|
|
||
| import com.sniptext.domain.template.service.dto.result.TemplateListItemResult; | ||
|
|
||
| /** 내 템플릿 목록의 한 항목 (명세 8번). 시각은 전역 직렬화 설정이 +09:00을 붙여 내보낸다. */ | ||
| public record TemplateListItemResponse( | ||
| Long templateId, | ||
| String title, | ||
| String shortcut, | ||
| String content, | ||
| List<String> variables, | ||
| LocalDateTime lastUsedAt, | ||
| LocalDateTime createdAt, | ||
| LocalDateTime editedAt | ||
| ) { | ||
|
|
||
| public static TemplateListItemResponse from(TemplateListItemResult result) { | ||
| return new TemplateListItemResponse( | ||
| result.templateId(), | ||
| result.title(), | ||
| result.shortcut(), | ||
| result.content(), | ||
| result.variables(), | ||
| result.lastUsedAt(), | ||
| result.createdAt(), | ||
| result.editedAt() | ||
| ); | ||
| } | ||
|
|
||
| } |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/sniptext/domain/template/controller/dto/TemplateListResponse.java
This file contains hidden or 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,17 @@ | ||
| package com.sniptext.domain.template.controller.dto; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import com.sniptext.domain.template.service.dto.result.TemplateListResult; | ||
|
|
||
| /** 명세 8번 내 템플릿 목록. 생성 순, 페이지 나눔 없음 */ | ||
| public record TemplateListResponse(int totalCount, List<TemplateListItemResponse> templates) { | ||
|
|
||
| public static TemplateListResponse from(TemplateListResult result) { | ||
| return new TemplateListResponse( | ||
| result.totalCount(), | ||
| result.templates().stream().map(TemplateListItemResponse::from).toList() | ||
| ); | ||
| } | ||
|
|
||
| } |
This file contains hidden or 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 hidden or 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/com/sniptext/domain/template/service/dto/result/TemplateListItemResult.java
This file contains hidden or 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 com.sniptext.domain.template.service.dto.result; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
|
|
||
| import com.sniptext.domain.template.entity.Template; | ||
| import com.sniptext.domain.template.support.TemplateVariableExtractor; | ||
|
|
||
| /** 내 템플릿 목록의 한 항목. 변수 목록은 저장하지 않고 복호화한 본문에서 뽑는다. */ | ||
| public record TemplateListItemResult( | ||
| Long templateId, | ||
| String title, | ||
| String shortcut, | ||
| String content, | ||
| List<String> variables, | ||
| LocalDateTime lastUsedAt, | ||
| LocalDateTime createdAt, | ||
| LocalDateTime editedAt | ||
| ) { | ||
|
|
||
| public static TemplateListItemResult from(Template template) { | ||
| String content = template.getContent().getValue(); | ||
| return new TemplateListItemResult( | ||
| template.getId(), | ||
| template.getTitle().getValue(), | ||
| template.getShortcut().getValue(), | ||
| content, | ||
| TemplateVariableExtractor.extract(content), | ||
| template.getLastUsedAt(), | ||
| template.getCreatedAt(), | ||
| template.getEditedAt() | ||
| ); | ||
| } | ||
|
|
||
| } |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/sniptext/domain/template/service/dto/result/TemplateListResult.java
This file contains hidden or 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,12 @@ | ||
| package com.sniptext.domain.template.service.dto.result; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** 내 템플릿 목록. 페이지를 나누지 않으므로 개수는 항목 수와 같다. */ | ||
| public record TemplateListResult(int totalCount, List<TemplateListItemResult> templates) { | ||
|
|
||
| public static TemplateListResult from(List<TemplateListItemResult> templates) { | ||
| return new TemplateListResult(templates.size(), List.copyOf(templates)); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
본문 복호화는 엔티티를 읽을 때 변환기에서 일어나서, 복호화에 실패하는 행이 하나라도 있으면 목록 전체가 500이 될 것 같아요. 그러면 사용자는 대시보드를 아예 못 보고, 그 템플릿을 휴지통으로 보낼 수도 없게 돼요. 이 PR에서 고칠 필요는 없지만, 깨진 행을 어떻게 다룰지(건너뛰고 로그를 남길지, 지금처럼 500으로 둘지) 이슈로 남겨두면 좋을 거 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋습니다! 복호화 실패는 키가 다르거나 저장값이 변조된 경우에만 나고, 키 문제라면 행 하나가 아니라 전체가 깨져서 건너뛰어도 의미가 없을 것 같아요. 지금은 500으로 두고, 나중에 키 교체를 도입하면 그때 같이 다루겠습니다 !