-
Notifications
You must be signed in to change notification settings - Fork 0
Draft > Application: Draft 제목, 시리즈, URL을 임시저장 합니다. #440
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
base: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -2,14 +2,17 @@ | |||
|
||||
import nettee.blolet.article.domain.Draft; | ||||
import nettee.blolet.article.domain.DraftImage; | ||||
import nettee.blolet.article.domain.SeriesArticle; | ||||
import nettee.blolet.article.domain.sub.DraftStatus; | ||||
import nettee.blolet.article.readmodel.DraftReadModels.DraftDetail; | ||||
|
||||
import java.util.Optional; | ||||
|
||||
public interface DraftCommandPort { | ||||
|
||||
Optional<DraftDetail> findById(String id); | ||||
Optional<DraftDetail> findDraftById(String id); | ||||
|
||||
Optional<SeriesArticle> findSeriesArticleById(String id); | ||||
|
||||
Draft save(Draft draft); | ||||
|
||||
|
@@ -18,4 +21,10 @@ public interface DraftCommandPort { | |||
void updateStatus(String id, DraftStatus draftStatus); | ||||
|
||||
DraftImage save(DraftImage draftImage); | ||||
|
||||
Draft updateTitle(String draftId, String title); | ||||
|
||||
Draft updatePath(String draftId, String path); | ||||
|
||||
SeriesArticle updateSeriesArticle(String draftId, String seriesId, String articleId); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,11 @@ | |
import nettee.blolet.article.application.usecase.DraftCreateUseCase; | ||
import nettee.blolet.article.application.usecase.DraftDeleteUseCase; | ||
import nettee.blolet.article.application.usecase.DraftImageCreateUseCase; | ||
import nettee.blolet.article.application.usecase.DraftPatchUseCase; | ||
import nettee.blolet.article.application.usecase.DraftUpdateUseCase; | ||
import nettee.blolet.article.domain.Draft; | ||
import nettee.blolet.article.domain.DraftImage; | ||
import nettee.blolet.article.domain.SeriesArticle; | ||
import nettee.blolet.article.domain.sub.DraftStatus; | ||
import nettee.blolet.blog.export.client.api.BlogClient; | ||
import nettee.upload.port.ImageStorage; | ||
|
@@ -16,10 +18,18 @@ | |
|
||
import static nettee.blolet.article.exception.DraftErrorCode.DRAFT_FORBIDDEN; | ||
import static nettee.blolet.article.exception.DraftErrorCode.DRAFT_NOT_FOUND; | ||
import static nettee.blolet.article.exception.DraftErrorCode.SERIES_ARTICLE_NOT_FOUND; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class DraftCommandService implements DraftCreateUseCase, DraftUpdateUseCase, DraftDeleteUseCase, DraftImageCreateUseCase { | ||
public class DraftCommandService implements | ||
DraftCreateUseCase, | ||
DraftUpdateUseCase, | ||
DraftDeleteUseCase, | ||
DraftImageCreateUseCase, | ||
DraftPatchUseCase | ||
|
||
{ | ||
|
||
private final DraftCommandPort draftCommandPort; | ||
private final BlogClient blogClient; | ||
private final ImageStorage imageStorage; | ||
|
@@ -38,7 +48,7 @@ public Draft updateDraft(String userId, Draft draft) { | |
|
||
@Override | ||
public void deleteDraft(String userId, String draftId) { | ||
var blogId = draftCommandPort.findById(draftId) | ||
var blogId = draftCommandPort.findDraftById(draftId) | ||
.orElseThrow(DRAFT_NOT_FOUND::exception) | ||
.blogId(); | ||
validateOwnership(userId, blogId); | ||
|
@@ -48,7 +58,7 @@ public void deleteDraft(String userId, String draftId) { | |
|
||
@Override | ||
public DraftImage createDraftImage(String userId, String draftId, MultipartFile file, String targetName) { | ||
var blogId = draftCommandPort.findById(draftId) | ||
var blogId = draftCommandPort.findDraftById(draftId) | ||
.orElseThrow(DRAFT_NOT_FOUND::exception) | ||
.blogId(); | ||
validateOwnership(userId, blogId); | ||
|
@@ -72,4 +82,34 @@ private void validateOwnership(String userId, String draftId) { | |
throw DRAFT_FORBIDDEN.exception(); | ||
} | ||
} | ||
|
||
@Override | ||
public Draft patchTitle(String userId, String draftId, String title) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎨 이 순서로 배치하는 게 유지보수하기에 좋습니다! 계속 추가하다 보면 자주 실수할 수 있는 영역이네요. class {
fields
public methods
private methods
} |
||
var draft = draftCommandPort.findDraftById(draftId) | ||
.orElseThrow(DRAFT_NOT_FOUND::exception); | ||
|
||
validateOwnership(userId, draft.blogId()); | ||
|
||
return draftCommandPort.updateTitle(draft.id(), title); | ||
} | ||
|
||
@Override | ||
public Draft patchPath(String userId, String draftId, String path) { | ||
var draft = draftCommandPort.findDraftById(draftId) | ||
.orElseThrow(DRAFT_NOT_FOUND::exception); | ||
|
||
validateOwnership(userId, draft.blogId()); | ||
|
||
return draftCommandPort.updatePath(draft.id(), path); | ||
} | ||
|
||
@Override | ||
public SeriesArticle patchSeriesArticle(String userId, String draftId, String seriesId, String articleId) { | ||
var seriesArticle = draftCommandPort.findSeriesArticleById(draftId) | ||
.orElseThrow(SERIES_ARTICLE_NOT_FOUND::exception); | ||
|
||
validateOwnership(userId, draftId); | ||
|
||
|
||
return draftCommandPort.updateSeriesArticle(seriesArticle.getDraftId(), seriesId, articleId); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package nettee.blolet.article.application.usecase; | ||
|
||
import nettee.blolet.article.domain.Draft; | ||
import nettee.blolet.article.domain.SeriesArticle; | ||
|
||
public interface DraftPatchUseCase { | ||
|
||
Draft patchTitle(String userId, String draftId, String title); | ||
|
||
Draft patchPath(String userId, String draftId, String path); | ||
|
||
SeriesArticle patchSeriesArticle(String userId, String draftId, String seriesId, String articleId); | ||
} |
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.
[nitpick] The empty line and comment placement creates inconsistent formatting. Remove the blank line after the enum declaration or move the comment to align with other comment groupings.
Copilot uses AI. Check for mistakes.