diff --git a/daemawiki-api/src/main/java/org/daemawiki/domain/document/api/DocumentController.java b/daemawiki-api/src/main/java/org/daemawiki/domain/document/api/DocumentController.java index 48161d0b..ea9b51f2 100644 --- a/daemawiki-api/src/main/java/org/daemawiki/domain/document/api/DocumentController.java +++ b/daemawiki-api/src/main/java/org/daemawiki/domain/document/api/DocumentController.java @@ -11,9 +11,9 @@ import org.daemawiki.domain.document.usecase.DeleteDocumentUsecase; import org.daemawiki.domain.document.usecase.GetDocumentUsecase; import org.daemawiki.domain.document.usecase.UpdateDocumentUsecase; -import org.daemawiki.domain.info.dto.UpdateInfoRequest; -import org.daemawiki.domain.info.usecase.UpdateDocumentInfoUsecase; -import org.daemawiki.domain.info.usecase.UploadDocumentImageUsecase; +import org.daemawiki.domain.document_info.dto.UpdateInfoRequest; +import org.daemawiki.domain.document_info.usecase.UpdateDocumentInfoUsecase; +import org.daemawiki.domain.document_info.usecase.UploadDocumentImageUsecase; import org.daemawiki.utils.PagingInfo; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -76,7 +76,7 @@ public Flux searchDocumentTitle( @RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer size ) { - return getDocumentUsecase.searchDocumentTitle(text, PagingInfo.of(sortBy, sortDirection, page, size)); + return getDocumentUsecase.searchDocumentsByTitle(text, PagingInfo.of(sortBy, sortDirection, page, size)); } @GetMapping("/search/content") @@ -87,7 +87,7 @@ public Flux searchDocumentContent( @RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer size ) { - return getDocumentUsecase.searchDocumentContent(text, PagingInfo.of(sortBy, sortDirection, page, size)); + return getDocumentUsecase.searchDocumentsByContent(text, PagingInfo.of(sortBy, sortDirection, page, size)); } @GetMapping("/most-revision") @@ -97,7 +97,7 @@ public Flux getDocumentsOrderByVersion( @RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer size ) { - return getDocumentUsecase.getDocumentsMostRevision(PagingInfo.of(sortBy, sortDirection, page, size)); + return getDocumentUsecase.getDocumentsSortByMostRevision(PagingInfo.of(sortBy, sortDirection, page, size)); } @GetMapping("/most-view") @@ -107,7 +107,7 @@ public Flux getDocumentsOrderByView( @RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer size ) { - return getDocumentUsecase.getDocumentOrderByView(PagingInfo.of(sortBy, sortDirection, page, size)); + return getDocumentUsecase.getDocumentsSortByView(PagingInfo.of(sortBy, sortDirection, page, size)); } @DeleteMapping("/{documentId}") diff --git a/daemawiki-api/src/main/java/org/daemawiki/domain/content/api/DocumentContentController.java b/daemawiki-api/src/main/java/org/daemawiki/domain/document_content/api/DocumentContentController.java similarity index 69% rename from daemawiki-api/src/main/java/org/daemawiki/domain/content/api/DocumentContentController.java rename to daemawiki-api/src/main/java/org/daemawiki/domain/document_content/api/DocumentContentController.java index adea9ad0..8bc4043a 100644 --- a/daemawiki-api/src/main/java/org/daemawiki/domain/content/api/DocumentContentController.java +++ b/daemawiki-api/src/main/java/org/daemawiki/domain/document_content/api/DocumentContentController.java @@ -1,17 +1,17 @@ -package org.daemawiki.domain.content.api; - -import org.daemawiki.domain.content.dto.AddContentRequest; -import org.daemawiki.domain.content.dto.DeleteContentRequest; -import org.daemawiki.domain.content.dto.EditContentTableTitleRequest; -import org.daemawiki.domain.content.dto.WriteContentRequest; -import org.daemawiki.domain.content.usecase.AddContentTableUsecase; -import org.daemawiki.domain.content.usecase.RemoveContentTableUsecase; -import org.daemawiki.domain.content.usecase.UpdateContentTableTitleUsecase; -import org.daemawiki.domain.content.usecase.WriteContentUsecase; -import org.daemawiki.domain.content.service.AddContentTableService; -import org.daemawiki.domain.content.service.RemoveContentTableService; -import org.daemawiki.domain.content.service.UpdateContentTableTitleService; -import org.daemawiki.domain.content.service.WriteContentService; +package org.daemawiki.domain.document_content.api; + +import org.daemawiki.domain.document_content.dto.AddContentRequest; +import org.daemawiki.domain.document_content.dto.DeleteContentRequest; +import org.daemawiki.domain.document_content.dto.EditContentTableTitleRequest; +import org.daemawiki.domain.document_content.dto.WriteContentRequest; +import org.daemawiki.domain.document_content.usecase.AddContentTableUsecase; +import org.daemawiki.domain.document_content.usecase.RemoveContentTableUsecase; +import org.daemawiki.domain.document_content.usecase.UpdateContentTableTitleUsecase; +import org.daemawiki.domain.document_content.usecase.WriteContentUsecase; +import org.daemawiki.domain.document_content.service.AddContentTableService; +import org.daemawiki.domain.document_content.service.RemoveContentTableService; +import org.daemawiki.domain.document_content.service.UpdateContentTableTitleService; +import org.daemawiki.domain.document_content.service.WriteContentService; import jakarta.validation.Valid; import jakarta.validation.constraints.NotBlank; import org.springframework.http.HttpStatus; diff --git a/daemawiki-api/src/main/java/org/daemawiki/domain/editor/api/DocumentEditorController.java b/daemawiki-api/src/main/java/org/daemawiki/domain/document_editor/api/DocumentEditorController.java similarity index 79% rename from daemawiki-api/src/main/java/org/daemawiki/domain/editor/api/DocumentEditorController.java rename to daemawiki-api/src/main/java/org/daemawiki/domain/document_editor/api/DocumentEditorController.java index b2a52bcc..78a8e2ed 100644 --- a/daemawiki-api/src/main/java/org/daemawiki/domain/editor/api/DocumentEditorController.java +++ b/daemawiki-api/src/main/java/org/daemawiki/domain/document_editor/api/DocumentEditorController.java @@ -1,11 +1,11 @@ -package org.daemawiki.domain.editor.api; +package org.daemawiki.domain.document_editor.api; import jakarta.validation.Valid; import jakarta.validation.constraints.NotBlank; -import org.daemawiki.domain.editor.dto.AddEditorRequest; -import org.daemawiki.domain.editor.dto.DeleteEditorRequest; -import org.daemawiki.domain.editor.usecase.AddDocumentEditorUsecase; -import org.daemawiki.domain.editor.usecase.RemoveDocumentEditorUsecase; +import org.daemawiki.domain.document_editor.dto.AddEditorRequest; +import org.daemawiki.domain.document_editor.dto.DeleteEditorRequest; +import org.daemawiki.domain.document_editor.usecase.AddDocumentEditorUsecase; +import org.daemawiki.domain.document_editor.usecase.RemoveDocumentEditorUsecase; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; import reactor.core.publisher.Mono; diff --git a/daemawiki-api/src/main/java/org/daemawiki/domain/revision/api/RevisionHistoryController.java b/daemawiki-api/src/main/java/org/daemawiki/domain/document_revision/api/RevisionHistoryController.java similarity index 90% rename from daemawiki-api/src/main/java/org/daemawiki/domain/revision/api/RevisionHistoryController.java rename to daemawiki-api/src/main/java/org/daemawiki/domain/document_revision/api/RevisionHistoryController.java index 5b1b23a4..808e19e4 100644 --- a/daemawiki-api/src/main/java/org/daemawiki/domain/revision/api/RevisionHistoryController.java +++ b/daemawiki-api/src/main/java/org/daemawiki/domain/document_revision/api/RevisionHistoryController.java @@ -1,9 +1,9 @@ -package org.daemawiki.domain.revision.api; +package org.daemawiki.domain.document_revision.api; import org.daemawiki.domain.document.dto.response.SimpleDocumentResponse; -import org.daemawiki.domain.revision.dto.response.GetRevisionByUserResponse; -import org.daemawiki.domain.revision.model.RevisionHistory; -import org.daemawiki.domain.revision.usecase.GetRevisionUsecase; +import org.daemawiki.domain.document_revision.dto.response.GetRevisionByUserResponse; +import org.daemawiki.domain.document_revision.model.RevisionHistory; +import org.daemawiki.domain.document_revision.usecase.GetRevisionUsecase; import org.daemawiki.utils.PagingInfo; import org.springframework.web.bind.annotation.*; import reactor.core.publisher.Flux; diff --git a/daemawiki-api/src/main/java/org/daemawiki/domain/auth/api/AuthController.java b/daemawiki-api/src/main/java/org/daemawiki/domain/user_auth/api/AuthController.java similarity index 73% rename from daemawiki-api/src/main/java/org/daemawiki/domain/auth/api/AuthController.java rename to daemawiki-api/src/main/java/org/daemawiki/domain/user_auth/api/AuthController.java index c4636f3b..e404617a 100644 --- a/daemawiki-api/src/main/java/org/daemawiki/domain/auth/api/AuthController.java +++ b/daemawiki-api/src/main/java/org/daemawiki/domain/user_auth/api/AuthController.java @@ -1,12 +1,12 @@ -package org.daemawiki.domain.auth.api; +package org.daemawiki.domain.user_auth.api; import jakarta.validation.Valid; -import org.daemawiki.domain.auth.dto.request.LoginRequest; -import org.daemawiki.domain.auth.dto.request.SignupRequest; -import org.daemawiki.domain.auth.dto.response.TokenResponse; -import org.daemawiki.domain.auth.usecase.ReissueUsecase; -import org.daemawiki.domain.auth.usecase.SigninUsecase; -import org.daemawiki.domain.auth.usecase.SignupUsecase; +import org.daemawiki.domain.user_auth.dto.request.LoginRequest; +import org.daemawiki.domain.user_auth.dto.request.SignupRequest; +import org.daemawiki.domain.user_auth.dto.response.TokenResponse; +import org.daemawiki.domain.user_auth.usecase.ReissueUsecase; +import org.daemawiki.domain.user_auth.usecase.SigninUsecase; +import org.daemawiki.domain.user_auth.usecase.SignupUsecase; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; import reactor.core.publisher.Mono; diff --git a/daemawiki-api/src/main/resources/application.yml b/daemawiki-api/src/main/resources/application.yml index a90fa527..45420c94 100644 --- a/daemawiki-api/src/main/resources/application.yml +++ b/daemawiki-api/src/main/resources/application.yml @@ -3,6 +3,7 @@ spring: mongodb: uri: ${MONGO_URI} database: ${MONGO_DB} + auto-index-creation: true redis: host: ${REDIS_HOST} @@ -35,7 +36,7 @@ daemawiki: secret: ${SEC_SECRET} issuer: ${SEC_ISSUER} expiration: ${SEC_EXPIRATION} - + profile: image: url: ${DEFAULT_PROFILE_IMAGE} diff --git a/daemawiki-auth/src/main/java/org/daemawiki/security/TokenizerImpl.java b/daemawiki-auth/src/main/java/org/daemawiki/security/TokenizerImpl.java index 5b3d2890..15f14694 100644 --- a/daemawiki-auth/src/main/java/org/daemawiki/security/TokenizerImpl.java +++ b/daemawiki-auth/src/main/java/org/daemawiki/security/TokenizerImpl.java @@ -2,7 +2,7 @@ import io.jsonwebtoken.*; import org.daemawiki.config.SecurityProperties; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.exception.h400.InvalidTokenException; import org.daemawiki.exception.h404.UserNotFoundException; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/article/model/Article.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/article/model/Article.java index e4df36b3..775d9cbe 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/article/model/Article.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/article/model/Article.java @@ -38,6 +38,10 @@ public Article(String title, String content, Writer writer) { this.writer = writer; } + public static Article of(String title, String content, Writer writer) { + return new Article(title, content, writer); + } + public void increaseView() { view++; } diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/article_comment/model/ArticleComment.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/article_comment/model/ArticleComment.java new file mode 100644 index 00000000..956d7dc0 --- /dev/null +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/article_comment/model/ArticleComment.java @@ -0,0 +1,23 @@ +package org.daemawiki.domain.article_comment.model; + +import org.daemawiki.domain.user.model.Writer; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.Id; +import org.springframework.data.mongodb.core.mapping.Document; + +import java.time.LocalDateTime; + +@Document +public class ArticleComment { + + @Id + private String id; + + private String content; + + private Writer writer; + + @CreatedDate + private LocalDateTime createdAt; + +} diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/adapter/DocumentAdapter.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/adapter/DocumentAdapter.java new file mode 100644 index 00000000..0053c914 --- /dev/null +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/adapter/DocumentAdapter.java @@ -0,0 +1,101 @@ +package org.daemawiki.domain.document.adapter; + +import org.daemawiki.domain.document.model.DefaultDocument; +import org.daemawiki.domain.document.model.DocumentSearchResult; +import org.daemawiki.domain.document.port.DeleteDocumentPort; +import org.daemawiki.domain.document.port.FindDocumentPort; +import org.daemawiki.domain.document.port.SaveDocumentPort; +import org.daemawiki.domain.document.repository.DocumentRepository; +import org.daemawiki.utils.PagingInfo; +import org.springframework.stereotype.Component; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +@Component +public class DocumentAdapter implements SaveDocumentPort, FindDocumentPort, DeleteDocumentPort { + private final DocumentRepository documentRepository; + + public DocumentAdapter(DocumentRepository documentRepository) { + this.documentRepository = documentRepository; + } + + @Override + public Mono findById(String id) { + return documentRepository.findById(id); + } + + @Override + public Mono findRandom() { + return documentRepository.findRandomDocument(); + } + + @Override + public Flux search(String text, PagingInfo pagingInfo) { + return documentRepository.findByTextContaining( + text, + pagingInfo.sortBy(), + pagingInfo.sortDirection(), + pagingInfo.page() * pagingInfo.size(), + pagingInfo.size() + ); + } + + @Override + public Flux searchByTitle(String text, PagingInfo pagingInfo) { + return documentRepository.findByTitleContaining( + text, + pagingInfo.sortBy(), + pagingInfo.sortDirection(), + pagingInfo.page() * pagingInfo.size(), + pagingInfo.size()); + } + + @Override + public Flux searchByContent(String text, PagingInfo pagingInfo) { + return documentRepository.findByContentTextContaining( + text, + pagingInfo.sortBy(), + pagingInfo.sortDirection(), + pagingInfo.page() * pagingInfo.size(), + pagingInfo.size() + ); + } + + public Flux findAllSortByMostRevision(PagingInfo pagingInfo) { + return documentRepository.findAllByOrderByVersion( + pagingInfo.sortDirection(), + pagingInfo.page() * pagingInfo.size(), + pagingInfo.size() + ); + } + + @Override + public Flux findAllSortByView(PagingInfo pagingInfo) { + return documentRepository.findAllByOrderByView( + pagingInfo.sortDirection(), + pagingInfo.page() * pagingInfo.size(), + pagingInfo.size() + ); + } + + @Override + public Mono save(DefaultDocument document) { + return documentRepository.save(document); + } + + @Override + public Mono increaseView(DefaultDocument document) { + return documentRepository.increaseView(document); + } + + @Override + public Mono deleteById(String id) { + return documentRepository.deleteById(id); + } + + @Override + public Mono delete(DefaultDocument document) { + return documentRepository.delete(document); + } + +} diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/application/FindDocumentPort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/application/FindDocumentPort.java deleted file mode 100644 index 9397d838..00000000 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/application/FindDocumentPort.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.daemawiki.domain.document.application; - -import org.daemawiki.domain.document.model.DefaultDocument; -import org.daemawiki.domain.document.model.DocumentSearchResult; -import org.daemawiki.utils.PagingInfo; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public interface FindDocumentPort { - Mono getDocumentById(String id); - Mono getDocumentByRandom(); - Flux searchDocument(String text, PagingInfo pagingInfo); - Flux searchDocumentTitle(String text, PagingInfo pagingInfo); - Flux searchDocumentContent(String text, PagingInfo pagingInfo); - Flux getDocumentMostRevision(PagingInfo pagingInfo); - Flux getDocumentOrderByView(PagingInfo pagingInfo); - -} diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/dto/request/SaveDocumentRequest.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/dto/request/SaveDocumentRequest.java index 6ee1db9a..e82774cf 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/dto/request/SaveDocumentRequest.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/dto/request/SaveDocumentRequest.java @@ -1,10 +1,11 @@ package org.daemawiki.domain.document.dto.request; -import org.daemawiki.domain.content.model.Content; import jakarta.annotation.Nullable; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.Builder; +import org.daemawiki.domain.document_content.model.Content; +import org.daemawiki.domain.document_revision.model.RevisionDetail; import java.util.List; @@ -19,7 +20,9 @@ public record SaveDocumentRequest( @NotNull(message = "문서의 분류가 비어있습니다.") List> groups, @Nullable - Long version + Long version, + @Nullable // TODO: 5/7/24 수정 내역 필드 + List data ) { public static SaveDocumentRequest create(String title, String type, List> groups) { diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/dto/response/GetDocumentResponse.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/dto/response/GetDocumentResponse.java index 7c1954a5..1dfe8e08 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/dto/response/GetDocumentResponse.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/dto/response/GetDocumentResponse.java @@ -1,11 +1,11 @@ package org.daemawiki.domain.document.dto.response; import org.daemawiki.datetime.model.EditDateTime; -import org.daemawiki.domain.content.model.Content; +import org.daemawiki.domain.document_content.model.Content; import org.daemawiki.domain.document.model.DefaultDocument; import org.daemawiki.domain.document.model.type.DocumentType; -import org.daemawiki.domain.editor.model.DocumentEditor; -import org.daemawiki.domain.info.model.Info; +import org.daemawiki.domain.document_editor.model.DocumentEditor; +import org.daemawiki.domain.document_info.model.Info; import lombok.Builder; import java.util.List; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/model/DefaultDocument.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/model/DefaultDocument.java index 4c03f1fe..c0c0945e 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/model/DefaultDocument.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/model/DefaultDocument.java @@ -3,10 +3,10 @@ import lombok.Builder; import lombok.Getter; import org.daemawiki.datetime.model.EditDateTime; -import org.daemawiki.domain.content.model.Content; +import org.daemawiki.domain.document_content.model.Content; import org.daemawiki.domain.document.model.type.DocumentType; -import org.daemawiki.domain.editor.model.DocumentEditor; -import org.daemawiki.domain.info.model.Info; +import org.daemawiki.domain.document_editor.model.DocumentEditor; +import org.daemawiki.domain.document_info.model.Info; import org.eclipse.collections.api.factory.Lists; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Document; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/model/DocumentSearchResult.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/model/DocumentSearchResult.java index 5acab055..6b432947 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/model/DocumentSearchResult.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/model/DocumentSearchResult.java @@ -3,7 +3,7 @@ import lombok.Builder; import lombok.Data; import org.daemawiki.datetime.model.EditDateTime; -import org.daemawiki.domain.content.model.Content; +import org.daemawiki.domain.document_content.model.Content; import org.daemawiki.domain.document.model.type.DocumentType; @Builder diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/persistence/DocumentPersistenceAdapter.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/persistence/DocumentPersistenceAdapter.java deleted file mode 100644 index c052f9c0..00000000 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/persistence/DocumentPersistenceAdapter.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.daemawiki.domain.document.persistence; - -import org.daemawiki.domain.document.application.DeleteDocumentPort; -import org.daemawiki.domain.document.application.FindDocumentPort; -import org.daemawiki.domain.document.application.SaveDocumentPort; -import org.daemawiki.domain.document.model.DefaultDocument; -import org.daemawiki.domain.document.model.DocumentSearchResult; -import org.daemawiki.domain.document.repository.DocumentRepository; -import org.daemawiki.exception.h404.DocumentNotFoundException; -import org.daemawiki.utils.PagingInfo; -import org.springframework.stereotype.Component; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -@Component -public class DocumentPersistenceAdapter implements SaveDocumentPort, FindDocumentPort, DeleteDocumentPort { - private final DocumentRepository documentRepository; - - public DocumentPersistenceAdapter(DocumentRepository documentRepository) { - this.documentRepository = documentRepository; - } - - @Override - public Mono getDocumentById(String id) { - return documentRepository.findById(id) - .switchIfEmpty(Mono.defer(() -> Mono.error(DocumentNotFoundException.EXCEPTION))); - } - - @Override - public Mono getDocumentByRandom() { - return documentRepository.findRandomDocument(); - } - - @Override - public Flux searchDocument(String text, PagingInfo pagingInfo) { - return documentRepository.findByTextContaining(text, pagingInfo.sortBy().isBlank() ? "dateTime.created" : pagingInfo.sortBy(), pagingInfo.sortDirection(), pagingInfo.page() * pagingInfo.size(), pagingInfo.size()); - } - - @Override - public Flux searchDocumentTitle(String text, PagingInfo pagingInfo) { - return documentRepository.findByTitleContaining(text, pagingInfo.sortBy(), pagingInfo.sortDirection(), pagingInfo.page() * pagingInfo.size(), pagingInfo.size()); - } - - @Override - public Flux searchDocumentContent(String text, PagingInfo pagingInfo) { - return documentRepository.findByContentTextContaining(text, pagingInfo.sortBy(), pagingInfo.sortDirection(), pagingInfo.page() * pagingInfo.size(), pagingInfo.size()); - } - - public Flux getDocumentMostRevision(PagingInfo pagingInfo) { - return documentRepository.findAllByOrderByVersion(pagingInfo.sortDirection(), pagingInfo.page() * pagingInfo.size(), pagingInfo.size()); - } - - @Override - public Flux getDocumentOrderByView(PagingInfo pagingInfo) { - return documentRepository.findAllByOrderByView(pagingInfo.sortDirection(), pagingInfo.page() * pagingInfo.size(), pagingInfo.size()); - } - - @Override - public Mono save(DefaultDocument document) { - return documentRepository.save(document); - } - - @Override - public Mono increaseView(DefaultDocument document) { - return documentRepository.increaseView(document); - } - - @Override - public Mono deleteById(String id) { - return documentRepository.deleteById(id); - } - - @Override - public Mono delete(DefaultDocument document) { - return documentRepository.delete(document); - } - -} diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/application/DeleteDocumentPort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/port/DeleteDocumentPort.java similarity index 81% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/document/application/DeleteDocumentPort.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document/port/DeleteDocumentPort.java index cb8bc441..6caa9fa1 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/application/DeleteDocumentPort.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/port/DeleteDocumentPort.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.document.application; +package org.daemawiki.domain.document.port; import org.daemawiki.domain.document.model.DefaultDocument; import reactor.core.publisher.Mono; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/port/FindDocumentPort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/port/FindDocumentPort.java new file mode 100644 index 00000000..bcf9553b --- /dev/null +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/port/FindDocumentPort.java @@ -0,0 +1,18 @@ +package org.daemawiki.domain.document.port; + +import org.daemawiki.domain.document.model.DefaultDocument; +import org.daemawiki.domain.document.model.DocumentSearchResult; +import org.daemawiki.utils.PagingInfo; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +public interface FindDocumentPort { + Mono findById(String id); + Mono findRandom(); + Flux search(String text, PagingInfo pagingInfo); + Flux searchByTitle(String text, PagingInfo pagingInfo); + Flux searchByContent(String text, PagingInfo pagingInfo); + Flux findAllSortByMostRevision(PagingInfo pagingInfo); + Flux findAllSortByView(PagingInfo pagingInfo); + +} diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/application/SaveDocumentPort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/port/SaveDocumentPort.java similarity index 83% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/document/application/SaveDocumentPort.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document/port/SaveDocumentPort.java index 6304ca3b..74f4015c 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/document/application/SaveDocumentPort.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document/port/SaveDocumentPort.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.document.application; +package org.daemawiki.domain.document.port; import org.daemawiki.domain.document.model.DefaultDocument; import reactor.core.publisher.Mono; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/content/dto/AddContentRequest.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_content/dto/AddContentRequest.java similarity index 89% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/content/dto/AddContentRequest.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_content/dto/AddContentRequest.java index 9f03a269..4d2374d3 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/content/dto/AddContentRequest.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_content/dto/AddContentRequest.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.content.dto; +package org.daemawiki.domain.document_content.dto; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/content/dto/DeleteContentRequest.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_content/dto/DeleteContentRequest.java similarity index 86% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/content/dto/DeleteContentRequest.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_content/dto/DeleteContentRequest.java index 87cbda59..9e7f0dfd 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/content/dto/DeleteContentRequest.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_content/dto/DeleteContentRequest.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.content.dto; +package org.daemawiki.domain.document_content.dto; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/content/dto/EditContentTableTitleRequest.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_content/dto/EditContentTableTitleRequest.java similarity index 89% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/content/dto/EditContentTableTitleRequest.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_content/dto/EditContentTableTitleRequest.java index 4740fdd4..f74409e5 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/content/dto/EditContentTableTitleRequest.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_content/dto/EditContentTableTitleRequest.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.content.dto; +package org.daemawiki.domain.document_content.dto; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/content/dto/WriteContentRequest.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_content/dto/WriteContentRequest.java similarity index 89% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/content/dto/WriteContentRequest.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_content/dto/WriteContentRequest.java index 4a9c62e0..839bf88b 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/content/dto/WriteContentRequest.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_content/dto/WriteContentRequest.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.content.dto; +package org.daemawiki.domain.document_content.dto; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/content/model/Content.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_content/model/Content.java similarity index 89% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/content/model/Content.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_content/model/Content.java index 742d995c..df0a1d68 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/content/model/Content.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_content/model/Content.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.content.model; +package org.daemawiki.domain.document_content.model; import lombok.Builder; import lombok.Getter; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/editor/dto/AddEditorRequest.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_editor/dto/AddEditorRequest.java similarity index 80% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/editor/dto/AddEditorRequest.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_editor/dto/AddEditorRequest.java index 518ed2da..f15eea2b 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/editor/dto/AddEditorRequest.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_editor/dto/AddEditorRequest.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.editor.dto; +package org.daemawiki.domain.document_editor.dto; import jakarta.validation.constraints.NotBlank; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/editor/dto/DeleteEditorRequest.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_editor/dto/DeleteEditorRequest.java similarity index 81% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/editor/dto/DeleteEditorRequest.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_editor/dto/DeleteEditorRequest.java index 8499c240..4bdddef4 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/editor/dto/DeleteEditorRequest.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_editor/dto/DeleteEditorRequest.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.editor.dto; +package org.daemawiki.domain.document_editor.dto; import jakarta.validation.constraints.NotBlank; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/editor/model/DocumentEditor.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_editor/model/DocumentEditor.java similarity index 91% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/editor/model/DocumentEditor.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_editor/model/DocumentEditor.java index 441453bc..db31e320 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/editor/model/DocumentEditor.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_editor/model/DocumentEditor.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.editor.model; +package org.daemawiki.domain.document_editor.model; import org.daemawiki.domain.user.dto.response.UserDetailResponse; import lombok.Builder; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/editor/model/Editor.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_editor/model/Editor.java similarity index 83% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/editor/model/Editor.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_editor/model/Editor.java index f79ebf27..42533c7d 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/editor/model/Editor.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_editor/model/Editor.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.editor.model; +package org.daemawiki.domain.document_editor.model; import lombok.Builder; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/info/dto/UpdateInfoRequest.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_info/dto/UpdateInfoRequest.java similarity index 75% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/info/dto/UpdateInfoRequest.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_info/dto/UpdateInfoRequest.java index c03fd49c..e91594e1 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/info/dto/UpdateInfoRequest.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_info/dto/UpdateInfoRequest.java @@ -1,7 +1,7 @@ -package org.daemawiki.domain.info.dto; +package org.daemawiki.domain.document_info.dto; import jakarta.validation.constraints.NotNull; -import org.daemawiki.domain.info.model.Detail; +import org.daemawiki.domain.document_info.model.Detail; import java.util.List; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/info/model/Detail.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_info/model/Detail.java similarity index 85% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/info/model/Detail.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_info/model/Detail.java index 9f46077b..e8ff4db9 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/info/model/Detail.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_info/model/Detail.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.info.model; +package org.daemawiki.domain.document_info.model; import lombok.Builder; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/info/model/Info.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_info/model/Info.java similarity index 89% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/info/model/Info.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_info/model/Info.java index 5fc1fb59..46d9fd69 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/info/model/Info.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_info/model/Info.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.info.model; +package org.daemawiki.domain.document_info.model; import org.daemawiki.domain.file.model.File; import lombok.Builder; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/persistence/RevisionPersistenceAdapter.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/adapter/RevisionAdapter.java similarity index 60% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/revision/persistence/RevisionPersistenceAdapter.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/adapter/RevisionAdapter.java index e645ea1b..9557671c 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/persistence/RevisionPersistenceAdapter.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/adapter/RevisionAdapter.java @@ -1,10 +1,10 @@ -package org.daemawiki.domain.revision.persistence; +package org.daemawiki.domain.document_revision.adapter; -import org.daemawiki.domain.revision.application.SaveRevisionPort; -import org.daemawiki.domain.revision.application.FindRevisionPort; -import org.daemawiki.domain.revision.model.RevisionHistory; -import org.daemawiki.domain.revision.model.type.RevisionType; -import org.daemawiki.domain.revision.repository.RevisionHistoryRepository; +import org.daemawiki.domain.document_revision.port.SaveRevisionPort; +import org.daemawiki.domain.document_revision.port.FindRevisionPort; +import org.daemawiki.domain.document_revision.model.RevisionHistory; +import org.daemawiki.domain.document_revision.model.type.RevisionType; +import org.daemawiki.domain.document_revision.repository.RevisionHistoryRepository; import org.daemawiki.utils.PagingInfo; import org.springframework.stereotype.Component; import reactor.core.publisher.Flux; @@ -13,10 +13,10 @@ import java.util.List; @Component -public class RevisionPersistenceAdapter implements SaveRevisionPort, FindRevisionPort { +public class RevisionAdapter implements SaveRevisionPort, FindRevisionPort { private final RevisionHistoryRepository revisionHistoryRepository; - public RevisionPersistenceAdapter(RevisionHistoryRepository revisionHistoryRepository) { + public RevisionAdapter(RevisionHistoryRepository revisionHistoryRepository) { this.revisionHistoryRepository = revisionHistoryRepository; } @@ -26,7 +26,7 @@ public Mono save(RevisionHistory revisionHistory) { } @Override - public Flux getRevisionOrderByUpdated(PagingInfo pagingInfo, List types) { + public Flux findAllSortByUpdatedDate(PagingInfo pagingInfo, List types) { List typeValues = types.stream() .map(type -> RevisionType.valueOf(type.toUpperCase())) .toList(); @@ -35,17 +35,17 @@ public Flux getRevisionOrderByUpdated(PagingInfo pagingInfo, Li } @Override - public Flux getAllRevisionPaging(PagingInfo pagingInfo) { + public Flux findAll(PagingInfo pagingInfo) { return revisionHistoryRepository.findAllOrderByCustom(pagingInfo.sortBy(), pagingInfo.sortDirection(), pagingInfo.page() * pagingInfo.size(), pagingInfo.size()); } @Override - public Flux getAllRevisionByDocument(String documentId, PagingInfo pagingInfo) { + public Flux findAllByDocumentId(String documentId, PagingInfo pagingInfo) { return revisionHistoryRepository.findAllByDocumentId(documentId, pagingInfo.sortBy(), pagingInfo.sortDirection(), pagingInfo.page() * pagingInfo.size(), pagingInfo.size()); } @Override - public Flux getAllRevisionByUser(String userId, PagingInfo pagingInfo) { + public Flux findAllByUserId(String userId, PagingInfo pagingInfo) { return revisionHistoryRepository.findAllByEditor_Id(userId, pagingInfo.sortBy(), pagingInfo.sortDirection(), pagingInfo.page() * pagingInfo.size(), pagingInfo.size()); } diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/dto/request/SaveRevisionHistoryDto.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/dto/request/SaveRevisionHistoryDto.java new file mode 100644 index 00000000..8fd8e160 --- /dev/null +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/dto/request/SaveRevisionHistoryDto.java @@ -0,0 +1,20 @@ +package org.daemawiki.domain.document_revision.dto.request; + +import org.daemawiki.domain.document_revision.model.RevisionDetail; +import org.daemawiki.domain.document_revision.model.type.RevisionType; + +import java.util.List; + +public record SaveRevisionHistoryDto( + RevisionType type, + String documentId, + Long version, + String title, + List data +) { + + public static SaveRevisionHistoryDto create(RevisionType type, String documentId, Long version, String title, List data) { + return new SaveRevisionHistoryDto(type, documentId, version, title, data); + } + +} diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/dto/response/GetRevisionByUserResponse.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/dto/response/GetRevisionByUserResponse.java similarity index 80% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/revision/dto/response/GetRevisionByUserResponse.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/dto/response/GetRevisionByUserResponse.java index f098de17..a4827ba4 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/dto/response/GetRevisionByUserResponse.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/dto/response/GetRevisionByUserResponse.java @@ -1,9 +1,9 @@ -package org.daemawiki.domain.revision.dto.response; +package org.daemawiki.domain.document_revision.dto.response; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Builder; -import org.daemawiki.domain.revision.model.RevisionHistory; -import org.daemawiki.domain.revision.model.type.RevisionType; +import org.daemawiki.domain.document_revision.model.RevisionHistory; +import org.daemawiki.domain.document_revision.model.type.RevisionType; import java.time.LocalDateTime; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/model/RevisionDetail.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/model/RevisionDetail.java new file mode 100644 index 00000000..6915dd9b --- /dev/null +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/model/RevisionDetail.java @@ -0,0 +1,8 @@ +package org.daemawiki.domain.document_revision.model; + +public record RevisionDetail( + Boolean added, + Boolean removed, + String value +) { +} diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/model/RevisionHistory.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/model/RevisionHistory.java similarity index 64% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/revision/model/RevisionHistory.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/model/RevisionHistory.java index dd8f72a3..a40f2b44 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/model/RevisionHistory.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/model/RevisionHistory.java @@ -1,20 +1,19 @@ -package org.daemawiki.domain.revision.model; +package org.daemawiki.domain.document_revision.model; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; -import org.daemawiki.domain.editor.model.Editor; -import org.daemawiki.domain.revision.model.type.RevisionType; import lombok.Builder; import lombok.Getter; -import lombok.NoArgsConstructor; +import org.daemawiki.domain.document_editor.model.Editor; +import org.daemawiki.domain.document_revision.model.type.RevisionType; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Document; import java.time.LocalDateTime; +import java.util.List; @Getter @Document -@NoArgsConstructor public class RevisionHistory { @Id @@ -25,6 +24,8 @@ public class RevisionHistory { private String documentId; + private Long version; + private String title; private Editor editor; @@ -32,13 +33,19 @@ public class RevisionHistory { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "Asia/Seoul") private LocalDateTime createdDateTime; + private List data = List.of(); + + protected RevisionHistory() {} + @Builder - public RevisionHistory(RevisionType type, String documentId, String title, Editor editor, LocalDateTime createdDateTime) { + public RevisionHistory(RevisionType type, String documentId, Long version, String title, Editor editor, LocalDateTime createdDateTime, List data) { this.type = type; this.documentId = documentId; + this.version = version; this.title = title; this.editor = editor; this.createdDateTime = createdDateTime; + this.data = data; } } diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/model/type/RevisionType.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/model/type/RevisionType.java similarity index 52% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/revision/model/type/RevisionType.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/model/type/RevisionType.java index 9fd85756..7d92d870 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/model/type/RevisionType.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/model/type/RevisionType.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.revision.model.type; +package org.daemawiki.domain.document_revision.model.type; public enum RevisionType { CREATE, diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/port/FindRevisionPort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/port/FindRevisionPort.java new file mode 100644 index 00000000..e6cf9cd9 --- /dev/null +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/port/FindRevisionPort.java @@ -0,0 +1,14 @@ +package org.daemawiki.domain.document_revision.port; + +import org.daemawiki.domain.document_revision.model.RevisionHistory; +import org.daemawiki.utils.PagingInfo; +import reactor.core.publisher.Flux; + +import java.util.List; + +public interface FindRevisionPort { + Flux findAllSortByUpdatedDate(PagingInfo pagingInfo, List types); + Flux findAll(PagingInfo pagingInfo); + Flux findAllByDocumentId(String documentId, PagingInfo pagingInfo); + Flux findAllByUserId(String userId, PagingInfo pagingInfo); +} diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/application/SaveRevisionPort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/port/SaveRevisionPort.java similarity index 53% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/revision/application/SaveRevisionPort.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/port/SaveRevisionPort.java index c98d1a0a..1982588b 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/application/SaveRevisionPort.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/port/SaveRevisionPort.java @@ -1,6 +1,6 @@ -package org.daemawiki.domain.revision.application; +package org.daemawiki.domain.document_revision.port; -import org.daemawiki.domain.revision.model.RevisionHistory; +import org.daemawiki.domain.document_revision.model.RevisionHistory; import reactor.core.publisher.Mono; public interface SaveRevisionPort { diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/repository/RevisionHistoryRepository.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/repository/RevisionHistoryRepository.java similarity index 89% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/revision/repository/RevisionHistoryRepository.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/repository/RevisionHistoryRepository.java index 3fa28a2e..7f827b56 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/repository/RevisionHistoryRepository.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_revision/repository/RevisionHistoryRepository.java @@ -1,7 +1,7 @@ -package org.daemawiki.domain.revision.repository; +package org.daemawiki.domain.document_revision.repository; -import org.daemawiki.domain.revision.model.RevisionHistory; -import org.daemawiki.domain.revision.model.type.RevisionType; +import org.daemawiki.domain.document_revision.model.RevisionHistory; +import org.daemawiki.domain.document_revision.model.type.RevisionType; import org.springframework.data.mongodb.repository.Aggregation; import org.springframework.data.mongodb.repository.ReactiveMongoRepository; import reactor.core.publisher.Flux; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/file/persistence/FilePersistenceAdapter.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/file/adapter/FileAdapter.java similarity index 65% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/file/persistence/FilePersistenceAdapter.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/file/adapter/FileAdapter.java index 9160025f..0e536558 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/file/persistence/FilePersistenceAdapter.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/file/adapter/FileAdapter.java @@ -1,6 +1,7 @@ -package org.daemawiki.domain.file.persistence; +package org.daemawiki.domain.file.adapter; -import org.daemawiki.domain.file.application.FindFilePort; +import org.daemawiki.domain.file.port.DeleteFilePort; +import org.daemawiki.domain.file.port.FindFilePort; import org.daemawiki.domain.file.model.File; import org.daemawiki.domain.file.repository.FileRepository; import org.springframework.stereotype.Component; @@ -10,10 +11,10 @@ import java.util.UUID; @Component -public class FilePersistenceAdapter implements FindFilePort { +public class FileAdapter implements FindFilePort, DeleteFilePort { private final FileRepository fileRepository; - public FilePersistenceAdapter(FileRepository fileRepository) { + public FileAdapter(FileRepository fileRepository) { this.fileRepository = fileRepository; } @@ -32,4 +33,9 @@ public Flux findAll() { return fileRepository.findAll(); } + @Override + public Mono deleteById(UUID id) { + return fileRepository.deleteById(id); + } + } diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/file/port/DeleteFilePort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/file/port/DeleteFilePort.java new file mode 100644 index 00000000..dca65eda --- /dev/null +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/file/port/DeleteFilePort.java @@ -0,0 +1,10 @@ +package org.daemawiki.domain.file.port; + +import reactor.core.publisher.Mono; + +import java.util.UUID; + +public interface DeleteFilePort { + Mono deleteById(UUID id); + +} diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/file/application/FindFilePort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/file/port/FindFilePort.java similarity index 85% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/file/application/FindFilePort.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/file/port/FindFilePort.java index f8187eae..16f41048 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/file/application/FindFilePort.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/file/port/FindFilePort.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.file.application; +package org.daemawiki.domain.file.port; import org.daemawiki.domain.file.model.File; import reactor.core.publisher.Flux; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/adapter/AuthCodeAdapter.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/adapter/AuthCodeAdapter.java new file mode 100644 index 00000000..3edff775 --- /dev/null +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/adapter/AuthCodeAdapter.java @@ -0,0 +1,35 @@ +package org.daemawiki.domain.mail.adapter; + +import org.daemawiki.domain.mail.model.AuthCode; +import org.daemawiki.domain.mail.port.code.DeleteAuthCodePort; +import org.daemawiki.domain.mail.port.code.FindAuthCodePort; +import org.daemawiki.domain.mail.port.code.SaveAuthCodePort; +import org.daemawiki.domain.mail.repository.AuthCodeRepository; +import org.springframework.stereotype.Component; +import reactor.core.publisher.Mono; + +@Component +public class AuthCodeAdapter implements FindAuthCodePort, DeleteAuthCodePort, SaveAuthCodePort { + private final AuthCodeRepository authCodeRepository; + + public AuthCodeAdapter(AuthCodeRepository authCodeRepository) { + this.authCodeRepository = authCodeRepository; + } + + @Override + public Mono delete(AuthCode authCode) { + return authCodeRepository.delete(authCode) + .then(); + } + + @Override + public Mono findByMail(String mail) { + return authCodeRepository.findByMail(mail); + } + + @Override + public Mono save(AuthCode authCode) { + return authCodeRepository.save(authCode) + .then(); + } +} diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/adapter/AuthMailAdapter.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/adapter/AuthMailAdapter.java new file mode 100644 index 00000000..62ec4fcf --- /dev/null +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/adapter/AuthMailAdapter.java @@ -0,0 +1,35 @@ +package org.daemawiki.domain.mail.adapter; + +import org.daemawiki.domain.mail.model.AuthMail; +import org.daemawiki.domain.mail.port.mail.DeleteAuthMailPort; +import org.daemawiki.domain.mail.port.mail.FindAuthMailPort; +import org.daemawiki.domain.mail.port.mail.SaveAuthMailPort; +import org.daemawiki.domain.mail.repository.AuthMailRepository; +import org.springframework.stereotype.Component; +import reactor.core.publisher.Mono; + +@Component +public class AuthMailAdapter implements FindAuthMailPort, SaveAuthMailPort, DeleteAuthMailPort { + private final AuthMailRepository authMailRepository; + + public AuthMailAdapter(AuthMailRepository authMailRepository) { + this.authMailRepository = authMailRepository; + } + + @Override + public Mono delete(String mail) { + return authMailRepository.delete(mail) + .then(); + } + + @Override + public Mono findByMail(String mail) { + return authMailRepository.findByMail(mail); + } + + @Override + public Mono save(AuthMail authMail) { + return authMailRepository.save(authMail) + .then(); + } +} diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/code/DeleteAuthCodePort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/code/DeleteAuthCodePort.java similarity index 76% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/code/DeleteAuthCodePort.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/code/DeleteAuthCodePort.java index c533ecd0..a2c2e54b 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/code/DeleteAuthCodePort.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/code/DeleteAuthCodePort.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.mail.application.code; +package org.daemawiki.domain.mail.port.code; import org.daemawiki.domain.mail.model.AuthCode; import reactor.core.publisher.Mono; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/code/FindAuthCodePort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/code/FindAuthCodePort.java similarity index 76% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/code/FindAuthCodePort.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/code/FindAuthCodePort.java index ac49dbd9..53e53b33 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/code/FindAuthCodePort.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/code/FindAuthCodePort.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.mail.application.code; +package org.daemawiki.domain.mail.port.code; import org.daemawiki.domain.mail.model.AuthCode; import reactor.core.publisher.Mono; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/code/SaveAuthCodePort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/code/SaveAuthCodePort.java similarity index 76% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/code/SaveAuthCodePort.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/code/SaveAuthCodePort.java index 95e62a60..8d02008a 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/code/SaveAuthCodePort.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/code/SaveAuthCodePort.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.mail.application.code; +package org.daemawiki.domain.mail.port.code; import org.daemawiki.domain.mail.model.AuthCode; import reactor.core.publisher.Mono; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/mail/DeleteAuthMailPort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/mail/DeleteAuthMailPort.java similarity index 68% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/mail/DeleteAuthMailPort.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/mail/DeleteAuthMailPort.java index 28c427fa..09f53804 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/mail/DeleteAuthMailPort.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/mail/DeleteAuthMailPort.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.mail.application.mail; +package org.daemawiki.domain.mail.port.mail; import reactor.core.publisher.Mono; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/mail/FindAuthMailPort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/mail/FindAuthMailPort.java similarity index 69% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/mail/FindAuthMailPort.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/mail/FindAuthMailPort.java index 14e4b367..3e591e1d 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/mail/FindAuthMailPort.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/mail/FindAuthMailPort.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.mail.application.mail; +package org.daemawiki.domain.mail.port.mail; import reactor.core.publisher.Mono; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/mail/SaveAuthMailPort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/mail/SaveAuthMailPort.java similarity index 76% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/mail/SaveAuthMailPort.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/mail/SaveAuthMailPort.java index 330fc704..bdd3e676 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/application/mail/SaveAuthMailPort.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/port/mail/SaveAuthMailPort.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.mail.application.mail; +package org.daemawiki.domain.mail.port.mail; import org.daemawiki.domain.mail.model.AuthMail; import reactor.core.publisher.Mono; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/repository/AuthCodeRepository.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/repository/AuthCodeRepository.java index 631e3171..f0a4ba37 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/repository/AuthCodeRepository.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/repository/AuthCodeRepository.java @@ -1,9 +1,6 @@ package org.daemawiki.domain.mail.repository; import org.daemawiki.config.RedisKey; -import org.daemawiki.domain.mail.application.code.DeleteAuthCodePort; -import org.daemawiki.domain.mail.application.code.FindAuthCodePort; -import org.daemawiki.domain.mail.application.code.SaveAuthCodePort; import org.daemawiki.domain.mail.model.AuthCode; import org.daemawiki.exception.h500.ExecuteFailedException; import org.daemawiki.exception.h500.RedisConnectFailedException; @@ -15,39 +12,34 @@ import java.time.Duration; @Repository -public class AuthCodeRepository implements FindAuthCodePort, DeleteAuthCodePort, SaveAuthCodePort { +public class AuthCodeRepository { private final ReactiveRedisOperations redisOperations; public AuthCodeRepository(ReactiveRedisOperations redisOperations) { this.redisOperations = redisOperations; } - private static final String AUTHCODE = RedisKey.AUTH_CODE.getKey(); + private static final String AUTH_CODE = RedisKey.AUTH_CODE.getKey(); - @Override public Mono findByMail(String mail) { - return redisOperations.opsForValue().get(AUTHCODE + mail) + return redisOperations.opsForValue().get(AUTH_CODE + mail) .map(value -> AuthCode.builder() .mail(mail) .code(value).build()) .onErrorMap(e -> e instanceof RedisConnectionFailureException ? RedisConnectFailedException.EXCEPTION : ExecuteFailedException.EXCEPTION); } - @Override - public Mono delete(AuthCode authCode) { - return redisOperations.delete(AUTHCODE + authCode.getMail()) - .onErrorMap(e -> e instanceof RedisConnectionFailureException ? RedisConnectFailedException.EXCEPTION : ExecuteFailedException.EXCEPTION) - .then(); + public Mono delete(AuthCode authCode) { + return redisOperations.delete(AUTH_CODE + authCode.getMail()) + .onErrorMap(e -> e instanceof RedisConnectionFailureException ? RedisConnectFailedException.EXCEPTION : ExecuteFailedException.EXCEPTION); } - @Override - public Mono save(AuthCode authCode) { + public Mono save(AuthCode authCode) { return redisOperations.opsForValue() - .set(AUTHCODE + authCode.getMail(), + .set(AUTH_CODE + authCode.getMail(), authCode.getCode(), Duration.ofHours(3)) - .onErrorMap(e -> e instanceof RedisConnectionFailureException ? RedisConnectFailedException.EXCEPTION : ExecuteFailedException.EXCEPTION) - .then(); + .onErrorMap(e -> e instanceof RedisConnectionFailureException ? RedisConnectFailedException.EXCEPTION : ExecuteFailedException.EXCEPTION); } } diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/repository/AuthMailRepository.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/repository/AuthMailRepository.java index 3119a46c..d845d0c9 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/repository/AuthMailRepository.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/mail/repository/AuthMailRepository.java @@ -1,9 +1,6 @@ package org.daemawiki.domain.mail.repository; import org.daemawiki.config.RedisKey; -import org.daemawiki.domain.mail.application.mail.DeleteAuthMailPort; -import org.daemawiki.domain.mail.application.mail.FindAuthMailPort; -import org.daemawiki.domain.mail.application.mail.SaveAuthMailPort; import org.daemawiki.domain.mail.model.AuthMail; import org.daemawiki.exception.h500.ExecuteFailedException; import org.daemawiki.exception.h500.RedisConnectFailedException; @@ -15,7 +12,7 @@ import java.time.Duration; @Repository -public class AuthMailRepository implements FindAuthMailPort, SaveAuthMailPort, DeleteAuthMailPort { +public class AuthMailRepository { private final ReactiveRedisOperations redisOperations; @@ -23,31 +20,26 @@ public AuthMailRepository(ReactiveRedisOperations redisOperation this.redisOperations = redisOperations; } - private static final String AUTHMAIL = RedisKey.AUTH_MAIL.getKey(); + private static final String AUTH_MAIL = RedisKey.AUTH_MAIL.getKey(); - @Override - public Mono save(AuthMail authMail) { + public Mono save(AuthMail authMail) { return redisOperations.opsForValue() - .set(AUTHMAIL + authMail.getMail(), + .set(AUTH_MAIL + authMail.getMail(), authMail.getMail(), Duration.ofHours(3)) - .onErrorMap(e -> e instanceof RedisConnectionFailureException ? RedisConnectFailedException.EXCEPTION : ExecuteFailedException.EXCEPTION) - .then(); + .onErrorMap(e -> e instanceof RedisConnectionFailureException ? RedisConnectFailedException.EXCEPTION : ExecuteFailedException.EXCEPTION); } - @Override public Mono findByMail(String mail) { return redisOperations.opsForValue() - .get(AUTHMAIL + mail) + .get(AUTH_MAIL + mail) .hasElement() .onErrorMap(e -> e instanceof RedisConnectionFailureException ? RedisConnectFailedException.EXCEPTION : ExecuteFailedException.EXCEPTION); } - @Override - public Mono delete(String mail) { - return redisOperations.delete(AUTHMAIL + mail) - .onErrorMap(e -> e instanceof RedisConnectionFailureException ? RedisConnectFailedException.EXCEPTION : ExecuteFailedException.EXCEPTION) - .then(); + public Mono delete(String mail) { + return redisOperations.delete(AUTH_MAIL + mail) + .onErrorMap(e -> e instanceof RedisConnectionFailureException ? RedisConnectFailedException.EXCEPTION : ExecuteFailedException.EXCEPTION); } } diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/application/FindRevisionPort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/application/FindRevisionPort.java deleted file mode 100644 index c9ad0800..00000000 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/application/FindRevisionPort.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.daemawiki.domain.revision.application; - -import org.daemawiki.domain.revision.model.RevisionHistory; -import org.daemawiki.utils.PagingInfo; -import reactor.core.publisher.Flux; - -import java.util.List; - -public interface FindRevisionPort { - Flux getRevisionOrderByUpdated(PagingInfo pagingInfo, List types); - Flux getAllRevisionPaging(PagingInfo pagingInfo); - Flux getAllRevisionByDocument(String documentId, PagingInfo pagingInfo); - Flux getAllRevisionByUser(String userId, PagingInfo pagingInfo); -} diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/dto/request/SaveRevisionHistoryRequest.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/dto/request/SaveRevisionHistoryRequest.java deleted file mode 100644 index 2b8a6fa0..00000000 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/revision/dto/request/SaveRevisionHistoryRequest.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.daemawiki.domain.revision.dto.request; - -import org.daemawiki.domain.revision.model.type.RevisionType; -import lombok.Builder; - -@Builder -public record SaveRevisionHistoryRequest( - RevisionType type, - String documentId, - String title -) { - - public static SaveRevisionHistoryRequest create(RevisionType type, String documentId, String title) { - return SaveRevisionHistoryRequest.builder() - .type(type) - .documentId(documentId) - .title(title) - .build(); - } - -} diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/user/persistence/UserPersistenceAdapter.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/user/adapter/UserAdapter.java similarity index 88% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/user/persistence/UserPersistenceAdapter.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/user/adapter/UserAdapter.java index 67c89485..cb2c13d3 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/user/persistence/UserPersistenceAdapter.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/user/adapter/UserAdapter.java @@ -1,8 +1,8 @@ -package org.daemawiki.domain.user.persistence; +package org.daemawiki.domain.user.adapter; -import org.daemawiki.domain.user.application.DeleteUserPort; -import org.daemawiki.domain.user.application.FindUserPort; -import org.daemawiki.domain.user.application.SaveUserPort; +import org.daemawiki.domain.user.port.DeleteUserPort; +import org.daemawiki.domain.user.port.FindUserPort; +import org.daemawiki.domain.user.port.SaveUserPort; import org.daemawiki.domain.user.dto.FindUserDto; import org.daemawiki.domain.user.model.User; import org.daemawiki.domain.user.model.type.major.MajorType; @@ -23,11 +23,11 @@ import java.security.Principal; @Component -public class UserPersistenceAdapter implements FindUserPort, SaveUserPort, DeleteUserPort { +public class UserAdapter implements FindUserPort, SaveUserPort, DeleteUserPort { private final UserRepository userRepository; private final MongoQueryUtils mongoQueryUtils; - public UserPersistenceAdapter(UserRepository userRepository, MongoQueryUtils mongoQueryUtils) { + public UserAdapter(UserRepository userRepository, MongoQueryUtils mongoQueryUtils) { this.userRepository = userRepository; this.mongoQueryUtils = mongoQueryUtils; } diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/user/application/DeleteUserPort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/user/port/DeleteUserPort.java similarity index 76% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/user/application/DeleteUserPort.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/user/port/DeleteUserPort.java index f73548b4..9c6c675a 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/user/application/DeleteUserPort.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/user/port/DeleteUserPort.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.user.application; +package org.daemawiki.domain.user.port; import org.daemawiki.domain.user.model.User; import reactor.core.publisher.Mono; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/user/application/FindUserPort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/user/port/FindUserPort.java similarity index 88% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/user/application/FindUserPort.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/user/port/FindUserPort.java index bb81ae42..8521f282 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/user/application/FindUserPort.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/user/port/FindUserPort.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.user.application; +package org.daemawiki.domain.user.port; import org.daemawiki.domain.user.dto.FindUserDto; import org.daemawiki.domain.user.model.User; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/user/application/SaveUserPort.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/user/port/SaveUserPort.java similarity index 76% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/user/application/SaveUserPort.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/user/port/SaveUserPort.java index a1c285d3..6ed43f0f 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/user/application/SaveUserPort.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/user/port/SaveUserPort.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.user.application; +package org.daemawiki.domain.user.port; import org.daemawiki.domain.user.model.User; import reactor.core.publisher.Mono; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/auth/dto/request/LoginRequest.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/user_auth/dto/request/LoginRequest.java similarity index 83% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/auth/dto/request/LoginRequest.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/user_auth/dto/request/LoginRequest.java index 9d7817b8..47ba1690 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/auth/dto/request/LoginRequest.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/user_auth/dto/request/LoginRequest.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.auth.dto.request; +package org.daemawiki.domain.user_auth.dto.request; import jakarta.validation.constraints.NotBlank; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/auth/dto/request/ReissueRequest.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/user_auth/dto/request/ReissueRequest.java similarity index 76% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/auth/dto/request/ReissueRequest.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/user_auth/dto/request/ReissueRequest.java index 6648f7d2..620b7c57 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/auth/dto/request/ReissueRequest.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/user_auth/dto/request/ReissueRequest.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.auth.dto.request; +package org.daemawiki.domain.user_auth.dto.request; import jakarta.validation.constraints.NotBlank; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/auth/dto/request/SignupRequest.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/user_auth/dto/request/SignupRequest.java similarity index 95% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/auth/dto/request/SignupRequest.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/user_auth/dto/request/SignupRequest.java index dcfc5c49..c16ba22d 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/auth/dto/request/SignupRequest.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/user_auth/dto/request/SignupRequest.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.auth.dto.request; +package org.daemawiki.domain.user_auth.dto.request; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/auth/dto/response/TokenResponse.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/user_auth/dto/response/TokenResponse.java similarity index 93% rename from daemawiki-domain/src/main/java/org/daemawiki/domain/auth/dto/response/TokenResponse.java rename to daemawiki-domain/src/main/java/org/daemawiki/domain/user_auth/dto/response/TokenResponse.java index 3916ba4e..08b20358 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/auth/dto/response/TokenResponse.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/user_auth/dto/response/TokenResponse.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.auth.dto.response; +package org.daemawiki.domain.user_auth.dto.response; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Builder; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/utils/MongoQueryUtils.java b/daemawiki-domain/src/main/java/org/daemawiki/utils/MongoQueryUtils.java index 8dc1be8c..cfeab3e6 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/utils/MongoQueryUtils.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/utils/MongoQueryUtils.java @@ -2,10 +2,10 @@ import org.springframework.data.mongodb.core.ReactiveMongoTemplate; import org.springframework.data.mongodb.core.query.Query; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; import reactor.core.publisher.Flux; -@Service +@Component public class MongoQueryUtils { private final ReactiveMongoTemplate reactiveMongoTemplate; diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/admin/component/ValidateAdminComponent.java b/daemawiki-service/src/main/java/org/daemawiki/domain/admin/component/ValidateAdminComponent.java new file mode 100644 index 00000000..6606a40e --- /dev/null +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/admin/component/ValidateAdminComponent.java @@ -0,0 +1,11 @@ +package org.daemawiki.domain.admin.component; + +import org.daemawiki.domain.admin.model.Admin; +import org.daemawiki.domain.user.model.User; +import reactor.core.publisher.Mono; + +public interface ValidateAdminComponent { + Mono validateSuperAdmin(); + Mono validateAdmin(); + +} diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/admin/component/ValidateAdminComponentImpl.java b/daemawiki-service/src/main/java/org/daemawiki/domain/admin/component/ValidateAdminComponentImpl.java new file mode 100644 index 00000000..d33d726a --- /dev/null +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/admin/component/ValidateAdminComponentImpl.java @@ -0,0 +1,39 @@ +package org.daemawiki.domain.admin.component; + +import org.daemawiki.domain.admin.application.FindAdminAccountPort; +import org.daemawiki.domain.admin.model.Admin; +import org.daemawiki.domain.user.port.FindUserPort; +import org.daemawiki.domain.user.model.User; +import org.daemawiki.exception.h403.NoPermissionUserException; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import reactor.core.publisher.Mono; + +@Component +public class ValidateAdminComponentImpl implements ValidateAdminComponent { + private final FindAdminAccountPort findAdminAccountPort; + private final FindUserPort findUserPort; + + public ValidateAdminComponentImpl(FindAdminAccountPort findAdminAccountPort, FindUserPort findUserPort) { + this.findAdminAccountPort = findAdminAccountPort; + this.findUserPort = findUserPort; + } + + @Value("${daemawiki.admin.email}") + private String adminEmail; + + @Override + public Mono validateAdmin() { + return findUserPort.currentUser() + .flatMap(user -> findAdminAccountPort.findByUserId(user.getId())) + .switchIfEmpty(Mono.defer(() -> Mono.error(NoPermissionUserException.EXCEPTION))); + } + + @Override + public Mono validateSuperAdmin() { + return findUserPort.currentUser() + .filter(user -> user.getEmail().equals(adminEmail)) + .switchIfEmpty(Mono.defer(() -> Mono.error(NoPermissionUserException.EXCEPTION))); + } + +} diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/AddAdminService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/AddAdminService.java index 8a3cdd3b..d76c3b20 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/AddAdminService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/AddAdminService.java @@ -1,31 +1,25 @@ package org.daemawiki.domain.admin.service; import org.daemawiki.domain.admin.application.SaveAdminAccountPort; +import org.daemawiki.domain.admin.component.ValidateAdminComponent; import org.daemawiki.domain.admin.model.Admin; import org.daemawiki.domain.admin.usecase.AddAdminUsecase; -import org.daemawiki.domain.user.application.FindUserPort; -import org.daemawiki.domain.user.model.User; -import org.daemawiki.exception.h403.NoPermissionUserException; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; @Service public class AddAdminService implements AddAdminUsecase { private final SaveAdminAccountPort saveAdminAccountPort; - private final FindUserPort findUserPort; + private final ValidateAdminComponent validateAdminComponent; - public AddAdminService(SaveAdminAccountPort saveAdminAccountPort, FindUserPort findUserPort) { + public AddAdminService(SaveAdminAccountPort saveAdminAccountPort, ValidateAdminComponent validateAdminComponent) { this.saveAdminAccountPort = saveAdminAccountPort; - this.findUserPort = findUserPort; + this.validateAdminComponent = validateAdminComponent; } - @Value("${daemawiki.admin.email}") - private String adminEmail; - @Override public Mono add(String email) { - return validate() + return validateAdminComponent.validateSuperAdmin() .then(createAdminAccount(email)); } @@ -35,10 +29,4 @@ private Mono createAdminAccount(String email) { ).then(); } - private Mono validate() { - return findUserPort.currentUser() - .filter(user -> user.getEmail().equals(adminEmail)) - .switchIfEmpty(Mono.error(NoPermissionUserException.EXCEPTION)); - } - } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/BlockUserService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/BlockUserService.java index f198b1fd..969a7958 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/BlockUserService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/BlockUserService.java @@ -1,39 +1,31 @@ package org.daemawiki.domain.admin.service; -import org.daemawiki.domain.admin.application.FindAdminAccountPort; -import org.daemawiki.domain.admin.model.Admin; +import org.daemawiki.domain.admin.component.ValidateAdminComponent; import org.daemawiki.domain.admin.usecase.BlockUserUsecase; -import org.daemawiki.domain.user.application.FindUserPort; -import org.daemawiki.domain.user.application.SaveUserPort; -import org.daemawiki.exception.h403.NoPermissionUserException; +import org.daemawiki.domain.user.port.FindUserPort; +import org.daemawiki.domain.user.port.SaveUserPort; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; @Service public class BlockUserService implements BlockUserUsecase { - private final FindAdminAccountPort findAdminAccountPort; private final SaveUserPort saveUserPort; private final FindUserPort findUserPort; + private final ValidateAdminComponent validateAdminComponent; - public BlockUserService(FindAdminAccountPort findAdminAccountPort, SaveUserPort saveUserPort, FindUserPort findUserPort) { - this.findAdminAccountPort = findAdminAccountPort; + public BlockUserService(SaveUserPort saveUserPort, FindUserPort findUserPort, ValidateAdminComponent validateAdminComponent) { this.saveUserPort = saveUserPort; this.findUserPort = findUserPort; + this.validateAdminComponent = validateAdminComponent; } @Override public Mono block(String userId) { - return validate() + return validateAdminComponent.validateAdmin() .flatMap(admin -> findUserPort.findById(userId) .doOnNext(user -> user.setIsBlocked(true)) .flatMap(saveUserPort::save)) .then(); } - private Mono validate() { - return findUserPort.currentUser() - .flatMap(user -> findAdminAccountPort.findByUserId(user.getId())) - .switchIfEmpty(Mono.error(NoPermissionUserException.EXCEPTION)); - } - } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/GetAdminService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/GetAdminService.java index c5fda0c6..22a12218 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/GetAdminService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/GetAdminService.java @@ -1,36 +1,27 @@ package org.daemawiki.domain.admin.service; import org.daemawiki.domain.admin.application.FindAdminAccountPort; +import org.daemawiki.domain.admin.component.ValidateAdminComponent; import org.daemawiki.domain.admin.dto.GetAdminResponse; -import org.daemawiki.domain.admin.model.Admin; import org.daemawiki.domain.admin.usecase.GetAdminUsecase; -import org.daemawiki.domain.user.application.FindUserPort; -import org.daemawiki.exception.h403.NoPermissionUserException; import org.springframework.stereotype.Service; import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; @Service public class GetAdminService implements GetAdminUsecase { private final FindAdminAccountPort findAdminAccountPort; - private final FindUserPort findUserPort; + private final ValidateAdminComponent validateAdminComponent; - public GetAdminService(FindAdminAccountPort findAdminAccountPort, FindUserPort findUserPort) { + public GetAdminService(FindAdminAccountPort findAdminAccountPort, ValidateAdminComponent validateAdminComponent) { this.findAdminAccountPort = findAdminAccountPort; - this.findUserPort = findUserPort; + this.validateAdminComponent = validateAdminComponent; } @Override public Flux getAll() { - return validate() + return validateAdminComponent.validateAdmin() .flatMapMany(admin -> findAdminAccountPort.findAll() .map(GetAdminResponse::of)); } - private Mono validate() { - return findUserPort.currentUser() - .flatMap(user -> findAdminAccountPort.findByUserId(user.getId())) - .switchIfEmpty(Mono.error(NoPermissionUserException.EXCEPTION)); - } - } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/RemoveAdminService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/RemoveAdminService.java index 463bc8d8..be24c771 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/RemoveAdminService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/RemoveAdminService.java @@ -2,14 +2,13 @@ import org.daemawiki.domain.admin.application.DeleteAdminAccountPort; import org.daemawiki.domain.admin.application.FindAdminAccountPort; +import org.daemawiki.domain.admin.component.ValidateAdminComponent; import org.daemawiki.domain.admin.model.Admin; import org.daemawiki.domain.admin.usecase.RemoveAdminUsecase; -import org.daemawiki.domain.user.application.FindUserPort; -import org.daemawiki.domain.user.application.SaveUserPort; +import org.daemawiki.domain.user.port.FindUserPort; +import org.daemawiki.domain.user.port.SaveUserPort; import org.daemawiki.domain.user.model.User; -import org.daemawiki.exception.h403.NoPermissionUserException; import org.daemawiki.exception.h404.UserNotFoundException; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; @@ -19,20 +18,19 @@ public class RemoveAdminService implements RemoveAdminUsecase { private final FindAdminAccountPort findAdminAccountPort; private final FindUserPort findUserPort; private final SaveUserPort saveUserPort; + private final ValidateAdminComponent validateAdminComponent; - public RemoveAdminService(DeleteAdminAccountPort deleteAdminAccountPort, FindAdminAccountPort findAdminAccountPort, FindUserPort findUserPort, SaveUserPort saveUserPort) { + public RemoveAdminService(DeleteAdminAccountPort deleteAdminAccountPort, FindAdminAccountPort findAdminAccountPort, FindUserPort findUserPort, SaveUserPort saveUserPort, ValidateAdminComponent validateAdminComponent) { this.deleteAdminAccountPort = deleteAdminAccountPort; this.findAdminAccountPort = findAdminAccountPort; this.findUserPort = findUserPort; this.saveUserPort = saveUserPort; + this.validateAdminComponent = validateAdminComponent; } - @Value("${daemawiki.admin.email}") - private String adminEmail; - @Override public Mono remove(String email) { - return validate() + return validateAdminComponent.validateSuperAdmin() .flatMap(user -> findAdminAccountPort.findByEmail(email)) .switchIfEmpty(Mono.error(UserNotFoundException.EXCEPTION)) .flatMap(this::deleteAdmin); @@ -56,10 +54,4 @@ private Mono deleteByEmail(String email) { return deleteAdminAccountPort.deleteByEmail(email); } - private Mono validate() { - return findUserPort.currentUser() - .filter(user -> user.getEmail().equals(adminEmail)) - .switchIfEmpty(Mono.error(NoPermissionUserException.EXCEPTION)); - } - } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/UnBlockUserService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/UnBlockUserService.java index fa383964..ce4b2881 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/UnBlockUserService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/admin/service/UnBlockUserService.java @@ -1,39 +1,31 @@ package org.daemawiki.domain.admin.service; -import org.daemawiki.domain.admin.application.FindAdminAccountPort; -import org.daemawiki.domain.admin.model.Admin; +import org.daemawiki.domain.admin.component.ValidateAdminComponent; import org.daemawiki.domain.admin.usecase.UnBlockUserUsecase; -import org.daemawiki.domain.user.application.FindUserPort; -import org.daemawiki.domain.user.application.SaveUserPort; -import org.daemawiki.exception.h403.NoPermissionUserException; +import org.daemawiki.domain.user.port.FindUserPort; +import org.daemawiki.domain.user.port.SaveUserPort; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; @Service public class UnBlockUserService implements UnBlockUserUsecase { - private final FindAdminAccountPort findAdminAccountPort; private final FindUserPort findUserPort; private final SaveUserPort saveUserPort; + private final ValidateAdminComponent validateAdminComponent; - public UnBlockUserService(FindAdminAccountPort findAdminAccountPort, FindUserPort findUserPort, SaveUserPort saveUserPort) { - this.findAdminAccountPort = findAdminAccountPort; + public UnBlockUserService(FindUserPort findUserPort, SaveUserPort saveUserPort, ValidateAdminComponent validateAdminComponent) { this.findUserPort = findUserPort; this.saveUserPort = saveUserPort; + this.validateAdminComponent = validateAdminComponent; } @Override public Mono unblock(String userId) { - return validate() + return validateAdminComponent.validateAdmin() .flatMap(admin -> findUserPort.findById(userId) .doOnNext(user -> user.setIsBlocked(false)) .flatMap(saveUserPort::save)) .then(); } - private Mono validate() { - return findUserPort.currentUser() - .flatMap(user -> findAdminAccountPort.findByUserId(user.getId())) - .switchIfEmpty(Mono.error(NoPermissionUserException.EXCEPTION)); - } - } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/article/service/WriteArticleService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/article/service/WriteArticleService.java index f2f223ad..de3dfa77 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/article/service/WriteArticleService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/article/service/WriteArticleService.java @@ -4,7 +4,7 @@ import org.daemawiki.domain.article.model.Article; import org.daemawiki.domain.article.port.SaveArticlePort; import org.daemawiki.domain.article.usecase.WriteArticleUseCase; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.domain.user.model.Writer; import org.daemawiki.exception.h403.NoPermissionUserException; import org.springframework.stereotype.Service; @@ -26,7 +26,7 @@ public Mono write(WriteArticleRequest request) { .filter(user -> !user.getIsBlocked()) .switchIfEmpty(Mono.defer(() -> Mono.error(NoPermissionUserException.EXCEPTION))) .flatMap(user -> { - Article article = Article.create(request.title(), request.content(), Writer.of(user)); + Article article = Article.of(request.title(), request.content(), Writer.of(user)); return saveArticlePort.save(article); }) .then(); diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/auth/usecase/SigninUsecase.java b/daemawiki-service/src/main/java/org/daemawiki/domain/auth/usecase/SigninUsecase.java deleted file mode 100644 index a54fc926..00000000 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/auth/usecase/SigninUsecase.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.daemawiki.domain.auth.usecase; - -import org.daemawiki.domain.auth.dto.request.LoginRequest; -import org.daemawiki.domain.auth.dto.response.TokenResponse; -import reactor.core.publisher.Mono; - -public interface SigninUsecase { - Mono signin(LoginRequest request); - -} diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document/usecase/UpdateDocumentComponent.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document/component/UpdateDocumentComponent.java similarity index 82% rename from daemawiki-service/src/main/java/org/daemawiki/domain/document/usecase/UpdateDocumentComponent.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document/component/UpdateDocumentComponent.java index 02da7211..d43f5f35 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/document/usecase/UpdateDocumentComponent.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document/component/UpdateDocumentComponent.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.document.usecase; +package org.daemawiki.domain.document.component; import org.daemawiki.domain.document.model.DefaultDocument; import org.daemawiki.domain.user.model.User; diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/UpdateDocumentEditorAndUpdatedDate.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document/component/UpdateDocumentEditorAndUpdatedDate.java similarity index 83% rename from daemawiki-service/src/main/java/org/daemawiki/domain/document/service/UpdateDocumentEditorAndUpdatedDate.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document/component/UpdateDocumentEditorAndUpdatedDate.java index 2158e3a2..eed1c77d 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/UpdateDocumentEditorAndUpdatedDate.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document/component/UpdateDocumentEditorAndUpdatedDate.java @@ -1,7 +1,7 @@ -package org.daemawiki.domain.document.service; +package org.daemawiki.domain.document.component; import org.daemawiki.domain.document.model.DefaultDocument; -import org.daemawiki.domain.document.usecase.UpdateDocumentComponent; +import org.daemawiki.domain.document.component.UpdateDocumentComponent; import org.daemawiki.domain.user.dto.response.UserDetailResponse; import org.daemawiki.domain.user.model.User; import org.springframework.stereotype.Component; diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document/component/facade/CreateDocumentFacadeImpl.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document/component/facade/CreateDocumentFacadeImpl.java index 6a893478..4b132fe5 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/document/component/facade/CreateDocumentFacadeImpl.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document/component/facade/CreateDocumentFacadeImpl.java @@ -2,13 +2,13 @@ import org.daemawiki.config.DefaultProfileConfig; import org.daemawiki.datetime.model.EditDateTime; -import org.daemawiki.domain.content.model.Content; +import org.daemawiki.domain.document_content.model.Content; import org.daemawiki.domain.document.dto.request.SaveDocumentRequest; import org.daemawiki.domain.document.model.DefaultDocument; import org.daemawiki.domain.document.model.type.DocumentType; -import org.daemawiki.domain.editor.model.DocumentEditor; -import org.daemawiki.domain.editor.model.Editor; -import org.daemawiki.domain.info.model.Info; +import org.daemawiki.domain.document_editor.model.DocumentEditor; +import org.daemawiki.domain.document_editor.model.Editor; +import org.daemawiki.domain.document_info.model.Info; import org.daemawiki.domain.user.dto.response.UserDetailResponse; import org.daemawiki.domain.user.model.User; import org.eclipse.collections.api.factory.Lists; diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/CreateDocumentService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/CreateDocumentService.java index e50825bc..583c7ed9 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/CreateDocumentService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/CreateDocumentService.java @@ -1,14 +1,13 @@ package org.daemawiki.domain.document.service; -import org.daemawiki.domain.document.application.SaveDocumentPort; +import org.daemawiki.domain.document.port.SaveDocumentPort; import org.daemawiki.domain.document.component.facade.CreateDocumentFacade; import org.daemawiki.domain.document.dto.request.SaveDocumentRequest; import org.daemawiki.domain.document.model.DefaultDocument; import org.daemawiki.domain.document.usecase.CreateDocumentUsecase; -import org.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest; -import org.daemawiki.domain.revision.model.type.RevisionType; -import org.daemawiki.domain.revision.usecase.CreateRevisionUsecase; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.document_revision.component.CreateRevisionComponent; +import org.daemawiki.domain.document_revision.model.type.RevisionType; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.domain.user.model.User; import org.daemawiki.exception.h403.NoEditPermissionUserException; import org.daemawiki.exception.h500.ExecuteFailedException; @@ -22,13 +21,13 @@ public class CreateDocumentService implements CreateDocumentUsecase { private final SaveDocumentPort saveDocumentPort; private final FindUserPort findUserPort; private final CreateDocumentFacade createDocumentFacade; - private final CreateRevisionUsecase createRevisionUsecase; + private final CreateRevisionComponent createRevisionComponent; - public CreateDocumentService(SaveDocumentPort saveDocumentPort, FindUserPort findUserPort, CreateDocumentFacade createDocumentFacade, CreateRevisionUsecase createRevisionUsecase) { + public CreateDocumentService(SaveDocumentPort saveDocumentPort, FindUserPort findUserPort, CreateDocumentFacade createDocumentFacade, CreateRevisionComponent createRevisionComponent) { this.saveDocumentPort = saveDocumentPort; this.findUserPort = findUserPort; this.createDocumentFacade = createDocumentFacade; - this.createRevisionUsecase = createRevisionUsecase; + this.createRevisionComponent = createRevisionComponent; } @Override @@ -43,7 +42,8 @@ public Mono create(SaveDocumentRequest request) { private Mono saveDocumentAndCreateRevision(DefaultDocument document) { return saveDocumentPort.save(document) - .then(createRevision(document)); + .flatMap(this::createRevisionByDocument) + .then(); } @Override @@ -55,13 +55,13 @@ public Mono createByUser(User user) { } private Mono createRevisionByDocument(DefaultDocument document) { - return createRevision(document) + return createRevisionComponent.create(document, RevisionType.CREATE, null) .thenReturn(document); } private Mono createDocument(User user) { List> groups = List.of( - List.of("학생", user.getDetail().getGen() + "기", user.getName()), + List.of("학생", String.format("%s기", user.getDetail().getGen()), user.getName()), List.of("전공", user.getDetail().getMajor().getMajor()) ); @@ -71,9 +71,4 @@ private Mono createDocument(User user) { groups), user); } - private Mono createRevision(DefaultDocument document) { - return createRevisionUsecase.saveHistory(SaveRevisionHistoryRequest - .create(RevisionType.CREATE, document.getId(), document.getTitle())); - } - } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/DeleteDocumentService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/DeleteDocumentService.java index 6a2af7eb..ee37f990 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/DeleteDocumentService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/DeleteDocumentService.java @@ -1,14 +1,13 @@ package org.daemawiki.domain.document.service; -import org.daemawiki.domain.document.application.DeleteDocumentPort; -import org.daemawiki.domain.document.application.FindDocumentPort; +import org.daemawiki.domain.document.port.DeleteDocumentPort; +import org.daemawiki.domain.document.port.FindDocumentPort; import org.daemawiki.domain.document.model.DefaultDocument; import org.daemawiki.domain.document.model.type.DocumentType; import org.daemawiki.domain.document.usecase.DeleteDocumentUsecase; -import org.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest; -import org.daemawiki.domain.revision.model.type.RevisionType; -import org.daemawiki.domain.revision.usecase.CreateRevisionUsecase; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.document_revision.component.CreateRevisionComponent; +import org.daemawiki.domain.document_revision.model.type.RevisionType; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.domain.user.model.User; import org.daemawiki.exception.h403.NoEditPermissionUserException; import org.daemawiki.exception.h403.NoPermissionUserException; @@ -22,14 +21,14 @@ public class DeleteDocumentService implements DeleteDocumentUsecase { private final FindDocumentPort findDocumentPort; private final DeleteDocumentPort deleteDocumentPort; - private final CreateRevisionUsecase createRevisionUsecase; private final FindUserPort findUserPort; + private final CreateRevisionComponent createRevisionComponent; - public DeleteDocumentService(FindDocumentPort findDocumentPort, DeleteDocumentPort deleteDocumentPort, CreateRevisionUsecase createRevisionUsecase, FindUserPort findUserPort) { + public DeleteDocumentService(FindDocumentPort findDocumentPort, DeleteDocumentPort deleteDocumentPort, FindUserPort findUserPort, CreateRevisionComponent createRevisionComponent) { this.findDocumentPort = findDocumentPort; this.deleteDocumentPort = deleteDocumentPort; - this.createRevisionUsecase = createRevisionUsecase; this.findUserPort = findUserPort; + this.createRevisionComponent = createRevisionComponent; } @Override @@ -37,7 +36,7 @@ public Mono delete(String documentId) { return findUserPort.currentUser() .filter(user -> !user.getIsBlocked()) .switchIfEmpty(Mono.defer(() -> Mono.error(NoEditPermissionUserException.EXCEPTION))) - .zipWith(findDocumentPort.getDocumentById(documentId)) + .zipWith(findDocumentPort.findById(documentId)) .flatMap(this::getDefaultDocumentMono) .flatMap(this::deleteDocument) .onErrorMap(this::mapException); @@ -45,7 +44,7 @@ public Mono delete(String documentId) { private Mono deleteDocument(DefaultDocument document) { return deleteDocumentPort.delete(document) - .then(createRevision(document)); + .then(createRevisionComponent.create(document, RevisionType.DELETE)); } private Mono getDefaultDocumentMono(Tuple2 tuple) { @@ -59,11 +58,6 @@ private Mono getDefaultDocumentMono(Tuple2 createRevision(DefaultDocument document) { - return createRevisionUsecase.saveHistory(SaveRevisionHistoryRequest - .create(RevisionType.DELETE, document.getId(), document.getTitle())); - } - private Throwable mapException(Throwable e) { return e instanceof StudentDocumentDeleteFailedException || e instanceof NoPermissionUserException ? e : ExecuteFailedException.EXCEPTION; } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/GetDocumentService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/GetDocumentService.java index 3725c446..0dadc53f 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/GetDocumentService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/GetDocumentService.java @@ -1,14 +1,13 @@ package org.daemawiki.domain.document.service; -import org.bson.types.ObjectId; -import org.daemawiki.domain.document.application.FindDocumentPort; -import org.daemawiki.domain.document.application.SaveDocumentPort; +import org.daemawiki.domain.document.port.FindDocumentPort; +import org.daemawiki.domain.document.port.SaveDocumentPort; import org.daemawiki.domain.document.dto.response.GetDocumentResponse; import org.daemawiki.domain.document.dto.response.GetMostViewDocumentResponse; import org.daemawiki.domain.document.dto.response.SimpleDocumentResponse; -import org.daemawiki.domain.document.model.DefaultDocument; import org.daemawiki.domain.document.model.DocumentSearchResult; import org.daemawiki.domain.document.usecase.GetDocumentUsecase; +import org.daemawiki.exception.h404.DocumentNotFoundException; import org.daemawiki.utils.PagingInfo; import org.springframework.stereotype.Service; import reactor.core.publisher.Flux; @@ -26,42 +25,45 @@ public GetDocumentService(FindDocumentPort findDocumentPort, SaveDocumentPort sa @Override public Mono getDocumentById(String id) { - return findDocumentPort.getDocumentById(id) + return findDocumentPort.findById(id) + .switchIfEmpty(Mono.defer(() -> Mono.error(DocumentNotFoundException.EXCEPTION))) .flatMap(saveDocumentPort::increaseView) .map(GetDocumentResponse::of); } @Override public Mono getDocumentByRandom() { - return findDocumentPort.getDocumentByRandom() + return findDocumentPort.findRandom() .flatMap(saveDocumentPort::increaseView) .map(GetDocumentResponse::of); } @Override public Flux searchDocument(String text, PagingInfo pagingInfo) { - return findDocumentPort.searchDocument(text, pagingInfo); + return findDocumentPort.search(text, pagingInfo); } @Override - public Flux searchDocumentTitle(String text, PagingInfo pagingInfo) { - return findDocumentPort.searchDocumentTitle(text, pagingInfo) + public Flux searchDocumentsByTitle(String text, PagingInfo pagingInfo) { + return findDocumentPort.searchByTitle(text, pagingInfo) .map(DocumentSearchResult::of); } @Override - public Flux searchDocumentContent(String text, PagingInfo pagingInfo) { - return findDocumentPort.searchDocumentContent(text, pagingInfo); + public Flux searchDocumentsByContent(String text, PagingInfo pagingInfo) { + return findDocumentPort.searchByContent(text, pagingInfo); } @Override - public Flux getDocumentsMostRevision(PagingInfo pagingInfo) { - return findDocumentPort.getDocumentMostRevision(pagingInfo).map(SimpleDocumentResponse::of); + public Flux getDocumentsSortByMostRevision(PagingInfo pagingInfo) { + return findDocumentPort.findAllSortByMostRevision(pagingInfo) + .map(SimpleDocumentResponse::of); } @Override - public Flux getDocumentOrderByView(PagingInfo pagingInfo) { - return findDocumentPort.getDocumentOrderByView(pagingInfo).map(GetMostViewDocumentResponse::of); + public Flux getDocumentsSortByView(PagingInfo pagingInfo) { + return findDocumentPort.findAllSortByView(pagingInfo) + .map(GetMostViewDocumentResponse::of); } } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/UpdateDocumentService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/UpdateDocumentService.java index 224beac8..d39b7c1e 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/UpdateDocumentService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document/service/UpdateDocumentService.java @@ -1,17 +1,16 @@ package org.daemawiki.domain.document.service; import org.daemawiki.domain.common.UserFilter; -import org.daemawiki.domain.document.application.FindDocumentPort; -import org.daemawiki.domain.document.application.SaveDocumentPort; -import org.daemawiki.domain.document.model.type.DocumentType; -import org.daemawiki.domain.document.usecase.UpdateDocumentComponent; +import org.daemawiki.domain.document.port.FindDocumentPort; +import org.daemawiki.domain.document.port.SaveDocumentPort; import org.daemawiki.domain.document.dto.request.SaveDocumentRequest; import org.daemawiki.domain.document.model.DefaultDocument; +import org.daemawiki.domain.document.model.type.DocumentType; +import org.daemawiki.domain.document.component.UpdateDocumentComponent; import org.daemawiki.domain.document.usecase.UpdateDocumentUsecase; -import org.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest; -import org.daemawiki.domain.revision.model.type.RevisionType; -import org.daemawiki.domain.revision.usecase.CreateRevisionUsecase; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.document_revision.component.CreateRevisionComponent; +import org.daemawiki.domain.document_revision.model.type.RevisionType; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.domain.user.model.User; import org.daemawiki.exception.h400.VersionMismatchException; import org.daemawiki.exception.h403.NoEditPermissionUserException; @@ -25,23 +24,23 @@ public class UpdateDocumentService implements UpdateDocumentUsecase { private final SaveDocumentPort saveDocumentPort; private final FindDocumentPort findDocumentPort; private final FindUserPort findUserPort; - private final CreateRevisionUsecase createRevisionUsecase; private final UpdateDocumentComponent updateDocumentComponent; private final UserFilter userFilter; + private final CreateRevisionComponent createRevisionComponent; - public UpdateDocumentService(SaveDocumentPort saveDocumentPort, FindDocumentPort findDocumentPort, FindUserPort findUserPort, CreateRevisionUsecase createRevisionUsecase, UpdateDocumentComponent updateDocumentComponent, UserFilter userFilter) { + public UpdateDocumentService(SaveDocumentPort saveDocumentPort, FindDocumentPort findDocumentPort, FindUserPort findUserPort, UpdateDocumentComponent updateDocumentComponent, UserFilter userFilter, CreateRevisionComponent createRevisionComponent) { this.saveDocumentPort = saveDocumentPort; this.findDocumentPort = findDocumentPort; this.findUserPort = findUserPort; - this.createRevisionUsecase = createRevisionUsecase; this.updateDocumentComponent = updateDocumentComponent; this.userFilter = userFilter; + this.createRevisionComponent = createRevisionComponent; } @Override public Mono update(SaveDocumentRequest request, String documentId) { return findUserPort.currentUser() - .zipWith(findDocumentPort.getDocumentById(documentId)) + .zipWith(findDocumentPort.findById(documentId)) .map(tuple -> checkPermissionAndUpdateDocument(tuple, request)) .flatMap(this::saveDocumentAndCreateRevision) .onErrorMap(this::mapException); @@ -49,7 +48,7 @@ public Mono update(SaveDocumentRequest request, String documentId) { private Mono saveDocumentAndCreateRevision(DefaultDocument document) { return saveDocumentPort.save(document) - .then(createRevision(document)); + .then(createRevisionComponent.create(document, RevisionType.UPDATE)); } private DefaultDocument checkPermissionAndUpdateDocument(Tuple2 tuple, SaveDocumentRequest request) { @@ -69,11 +68,6 @@ private DefaultDocument checkPermissionAndUpdateDocument(Tuple2 createRevision(DefaultDocument document) { - return createRevisionUsecase.saveHistory(SaveRevisionHistoryRequest - .create(RevisionType.UPDATE, document.getId(), document.getTitle())); - } - private Throwable mapException(Throwable e) { return e instanceof VersionMismatchException || e instanceof NoEditPermissionUserException ? e : ExecuteFailedException.EXCEPTION; } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document/usecase/GetDocumentUsecase.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document/usecase/GetDocumentUsecase.java index 2e0a2274..a9cca397 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/document/usecase/GetDocumentUsecase.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document/usecase/GetDocumentUsecase.java @@ -12,9 +12,9 @@ public interface GetDocumentUsecase { Mono getDocumentById(String id); Mono getDocumentByRandom(); Flux searchDocument(String text, PagingInfo pagingInfo); - Flux searchDocumentTitle(String text, PagingInfo pagingInfo); - Flux searchDocumentContent(String text, PagingInfo pagingInfo); - Flux getDocumentsMostRevision(PagingInfo pagingInfo); - Flux getDocumentOrderByView(PagingInfo pagingInfo); + Flux searchDocumentsByTitle(String text, PagingInfo pagingInfo); + Flux searchDocumentsByContent(String text, PagingInfo pagingInfo); + Flux getDocumentsSortByMostRevision(PagingInfo pagingInfo); + Flux getDocumentsSortByView(PagingInfo pagingInfo); } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/content/service/AddContentTableService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/AddContentTableService.java similarity index 72% rename from daemawiki-service/src/main/java/org/daemawiki/domain/content/service/AddContentTableService.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/AddContentTableService.java index 36c43b41..1eced044 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/content/service/AddContentTableService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/AddContentTableService.java @@ -1,17 +1,16 @@ -package org.daemawiki.domain.content.service; +package org.daemawiki.domain.document_content.service; import org.daemawiki.domain.common.UserFilter; -import org.daemawiki.domain.content.dto.AddContentRequest; -import org.daemawiki.domain.content.model.Content; -import org.daemawiki.domain.content.usecase.AddContentTableUsecase; -import org.daemawiki.domain.document.application.FindDocumentPort; -import org.daemawiki.domain.document.application.SaveDocumentPort; +import org.daemawiki.domain.document.port.FindDocumentPort; +import org.daemawiki.domain.document.port.SaveDocumentPort; import org.daemawiki.domain.document.model.DefaultDocument; -import org.daemawiki.domain.document.usecase.UpdateDocumentComponent; -import org.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest; -import org.daemawiki.domain.revision.model.type.RevisionType; -import org.daemawiki.domain.revision.usecase.CreateRevisionUsecase; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.document.component.UpdateDocumentComponent; +import org.daemawiki.domain.document_content.dto.AddContentRequest; +import org.daemawiki.domain.document_content.model.Content; +import org.daemawiki.domain.document_content.usecase.AddContentTableUsecase; +import org.daemawiki.domain.document_revision.component.CreateRevisionComponent; +import org.daemawiki.domain.document_revision.model.type.RevisionType; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.domain.user.dto.response.UserDetailResponse; import org.daemawiki.domain.user.model.User; import org.daemawiki.exception.h400.VersionMismatchException; @@ -19,6 +18,7 @@ import org.daemawiki.exception.h500.ExecuteFailedException; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; +import reactor.core.scheduler.Schedulers; import reactor.util.function.Tuple2; import java.util.Comparator; @@ -27,24 +27,25 @@ public class AddContentTableService implements AddContentTableUsecase { private final SaveDocumentPort saveDocumentPort; private final FindDocumentPort findDocumentPort; - private final CreateRevisionUsecase createRevisionUsecase; private final FindUserPort findUserPort; private final UserFilter userFilter; private final UpdateDocumentComponent updateDocumentComponent; + private final CreateRevisionComponent createRevisionComponent; - public AddContentTableService(SaveDocumentPort saveDocumentPort, FindDocumentPort findDocumentPort, CreateRevisionUsecase createRevisionUsecase, FindUserPort findUserPort, UserFilter userFilter, UpdateDocumentComponent updateDocumentComponent) { + public AddContentTableService(SaveDocumentPort saveDocumentPort, FindDocumentPort findDocumentPort, FindUserPort findUserPort, UserFilter userFilter, UpdateDocumentComponent updateDocumentComponent, CreateRevisionComponent createRevisionComponent) { this.saveDocumentPort = saveDocumentPort; this.findDocumentPort = findDocumentPort; - this.createRevisionUsecase = createRevisionUsecase; this.findUserPort = findUserPort; this.userFilter = userFilter; this.updateDocumentComponent = updateDocumentComponent; + this.createRevisionComponent = createRevisionComponent; } @Override public Mono add(AddContentRequest request, String documentId) { return findUserPort.currentUser() - .zipWith(findDocumentPort.getDocumentById(documentId)) + .zipWith(findDocumentPort.findById(documentId)) + .publishOn(Schedulers.boundedElastic()) .map(tuple -> checkPermissionAndAddDocumentContentTable(tuple, request)) .flatMap(this::saveDocumentAndCreateRevision) .onErrorMap(this::mapException); @@ -52,7 +53,7 @@ public Mono add(AddContentRequest request, String documentId) { private Mono saveDocumentAndCreateRevision(DefaultDocument document) { return saveDocumentPort.save(document) - .then(createRevision(document)); + .then(createRevisionComponent.create(document, RevisionType.UPDATE)); } private DefaultDocument checkPermissionAndAddDocumentContentTable(Tuple2 tuple, AddContentRequest request) { @@ -102,7 +103,8 @@ private Content createContent(String index, String title) { }; private void sortContents(DefaultDocument document) { - document.getContents().sort(customComparator); + document.getContents() + .sort(customComparator); } private void setDocument(DefaultDocument document, User user) { @@ -111,11 +113,6 @@ private void setDocument(DefaultDocument document, User user) { document.increaseVersion(); } - private Mono createRevision(DefaultDocument document) { - return createRevisionUsecase.saveHistory(SaveRevisionHistoryRequest - .create(RevisionType.UPDATE, document.getId(), document.getTitle())); - } - private Throwable mapException(Throwable e) { return e instanceof VersionMismatchException || e instanceof NoEditPermissionUserException ? e : ExecuteFailedException.EXCEPTION; } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/content/service/RemoveContentTableService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/RemoveContentTableService.java similarity index 66% rename from daemawiki-service/src/main/java/org/daemawiki/domain/content/service/RemoveContentTableService.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/RemoveContentTableService.java index 6f50a9b1..93258599 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/content/service/RemoveContentTableService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/RemoveContentTableService.java @@ -1,16 +1,15 @@ -package org.daemawiki.domain.content.service; +package org.daemawiki.domain.document_content.service; import org.daemawiki.domain.common.UserFilter; -import org.daemawiki.domain.content.dto.DeleteContentRequest; -import org.daemawiki.domain.content.usecase.RemoveContentTableUsecase; -import org.daemawiki.domain.document.application.FindDocumentPort; -import org.daemawiki.domain.document.application.SaveDocumentPort; +import org.daemawiki.domain.document.port.FindDocumentPort; +import org.daemawiki.domain.document.port.SaveDocumentPort; import org.daemawiki.domain.document.model.DefaultDocument; -import org.daemawiki.domain.document.usecase.UpdateDocumentComponent; -import org.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest; -import org.daemawiki.domain.revision.model.type.RevisionType; -import org.daemawiki.domain.revision.usecase.CreateRevisionUsecase; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.document.component.UpdateDocumentComponent; +import org.daemawiki.domain.document_content.dto.DeleteContentRequest; +import org.daemawiki.domain.document_content.usecase.RemoveContentTableUsecase; +import org.daemawiki.domain.document_revision.component.CreateRevisionComponent; +import org.daemawiki.domain.document_revision.model.type.RevisionType; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.domain.user.model.User; import org.daemawiki.exception.h400.VersionMismatchException; import org.daemawiki.exception.h403.NoEditPermissionUserException; @@ -24,23 +23,23 @@ public class RemoveContentTableService implements RemoveContentTableUsecase { private final FindDocumentPort findDocumentPort; private final FindUserPort findUserPort; private final SaveDocumentPort saveDocumentPort; - private final CreateRevisionUsecase createRevisionUsecase; private final UserFilter userFilter; private final UpdateDocumentComponent updateDocumentComponent; + private final CreateRevisionComponent createRevisionComponent; - public RemoveContentTableService(FindDocumentPort findDocumentPort, FindUserPort findUserPort, SaveDocumentPort saveDocumentPort, CreateRevisionUsecase createRevisionUsecase, UserFilter userFilter, UpdateDocumentComponent updateDocumentComponent) { + public RemoveContentTableService(FindDocumentPort findDocumentPort, FindUserPort findUserPort, SaveDocumentPort saveDocumentPort, UserFilter userFilter, UpdateDocumentComponent updateDocumentComponent, CreateRevisionComponent createRevisionComponent) { this.findDocumentPort = findDocumentPort; this.findUserPort = findUserPort; this.saveDocumentPort = saveDocumentPort; - this.createRevisionUsecase = createRevisionUsecase; this.userFilter = userFilter; this.updateDocumentComponent = updateDocumentComponent; + this.createRevisionComponent = createRevisionComponent; } @Override public Mono remove(DeleteContentRequest request, String documentId) { return findUserPort.currentUser() - .zipWith(findDocumentPort.getDocumentById(documentId)) + .zipWith(findDocumentPort.findById(documentId)) .map(tuple -> checkPermissionAndDeleteDocumentContentTable(tuple, request)) .flatMap(this::saveDocumentAndCreateRevision) .onErrorMap(this::mapException); @@ -48,7 +47,7 @@ public Mono remove(DeleteContentRequest request, String documentId) { private Mono saveDocumentAndCreateRevision(DefaultDocument document) { return saveDocumentPort.save(document) - .then(createRevision(document)); + .then(createRevisionComponent.create(document, RevisionType.UPDATE)); } private DefaultDocument checkPermissionAndDeleteDocumentContentTable(Tuple2 tuple, DeleteContentRequest request) { @@ -60,11 +59,6 @@ private DefaultDocument checkPermissionAndDeleteDocumentContentTable(Tuple2 createRevision(DefaultDocument document) { - return createRevisionUsecase.saveHistory(SaveRevisionHistoryRequest - .create(RevisionType.UPDATE, document.getId(), document.getTitle())); - } - private void removeContent(DefaultDocument document, String index) { document.getContents().removeIf(content -> content.getIndex().equals(index)); document.increaseVersion(); diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/content/service/UpdateContentTableTitleService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/UpdateContentTableTitleService.java similarity index 62% rename from daemawiki-service/src/main/java/org/daemawiki/domain/content/service/UpdateContentTableTitleService.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/UpdateContentTableTitleService.java index 9147d11e..10d00b7a 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/content/service/UpdateContentTableTitleService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/UpdateContentTableTitleService.java @@ -1,17 +1,16 @@ -package org.daemawiki.domain.content.service; +package org.daemawiki.domain.document_content.service; import org.daemawiki.domain.common.UserFilter; -import org.daemawiki.domain.content.dto.EditContentTableTitleRequest; -import org.daemawiki.domain.content.model.Content; -import org.daemawiki.domain.content.usecase.UpdateContentTableTitleUsecase; -import org.daemawiki.domain.document.application.FindDocumentPort; -import org.daemawiki.domain.document.application.SaveDocumentPort; +import org.daemawiki.domain.document.port.FindDocumentPort; +import org.daemawiki.domain.document.port.SaveDocumentPort; import org.daemawiki.domain.document.model.DefaultDocument; -import org.daemawiki.domain.document.usecase.UpdateDocumentComponent; -import org.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest; -import org.daemawiki.domain.revision.model.type.RevisionType; -import org.daemawiki.domain.revision.usecase.CreateRevisionUsecase; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.document.component.UpdateDocumentComponent; +import org.daemawiki.domain.document_content.dto.EditContentTableTitleRequest; +import org.daemawiki.domain.document_content.model.Content; +import org.daemawiki.domain.document_content.usecase.UpdateContentTableTitleUsecase; +import org.daemawiki.domain.document_revision.component.CreateRevisionComponent; +import org.daemawiki.domain.document_revision.model.type.RevisionType; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.domain.user.model.User; import org.daemawiki.exception.h404.ContentNotFoundException; import org.springframework.stereotype.Service; @@ -27,26 +26,26 @@ public class UpdateContentTableTitleService implements UpdateContentTableTitleUsecase { private final FindDocumentPort findDocumentPort; private final SaveDocumentPort saveDocumentPort; - private final CreateRevisionUsecase createRevisionUsecase; private final FindUserPort findUserPort; private final UserFilter userFilter; private final Scheduler scheduler; private final UpdateDocumentComponent updateDocumentComponent; + private final CreateRevisionComponent createRevisionComponent; - public UpdateContentTableTitleService(FindDocumentPort findDocumentPort, SaveDocumentPort saveDocumentPort, CreateRevisionUsecase createRevisionUsecase, FindUserPort findUserPort, UserFilter userFilter, Scheduler scheduler, UpdateDocumentComponent updateDocumentComponent) { + public UpdateContentTableTitleService(FindDocumentPort findDocumentPort, SaveDocumentPort saveDocumentPort, FindUserPort findUserPort, UserFilter userFilter, Scheduler scheduler, UpdateDocumentComponent updateDocumentComponent, CreateRevisionComponent createRevisionComponent) { this.findDocumentPort = findDocumentPort; this.saveDocumentPort = saveDocumentPort; - this.createRevisionUsecase = createRevisionUsecase; this.findUserPort = findUserPort; this.userFilter = userFilter; this.scheduler = scheduler; this.updateDocumentComponent = updateDocumentComponent; + this.createRevisionComponent = createRevisionComponent; } @Override public Mono update(EditContentTableTitleRequest request, String documentId) { return findUserPort.currentUser() - .zipWith(findDocumentPort.getDocumentById(documentId)) + .zipWith(findDocumentPort.findById(documentId)) .flatMap(tuple -> checkPermissionAndUpdateDocument(tuple, request)) .subscribeOn(scheduler) .flatMap(this::saveDocumentAndCreateRevision); @@ -54,7 +53,7 @@ public Mono update(EditContentTableTitleRequest request, String documentId private Mono saveDocumentAndCreateRevision(DefaultDocument document) { return saveDocumentPort.save(document) - .then(createRevision(document)); + .then(createRevisionComponent.create(document, RevisionType.UPDATE)); } private Mono checkPermissionAndUpdateDocument(Tuple2 tuple, EditContentTableTitleRequest request) { @@ -69,21 +68,16 @@ private Mono checkPermissionAndUpdateDocument(Tuple2 createRevision(DefaultDocument document) { - return createRevisionUsecase.saveHistory(SaveRevisionHistoryRequest - .create(RevisionType.UPDATE, document.getId(), document.getTitle())); - } - } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/content/service/WriteContentService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/WriteContentService.java similarity index 62% rename from daemawiki-service/src/main/java/org/daemawiki/domain/content/service/WriteContentService.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/WriteContentService.java index 79f8d3c3..d8394d14 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/content/service/WriteContentService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/WriteContentService.java @@ -1,17 +1,16 @@ -package org.daemawiki.domain.content.service; +package org.daemawiki.domain.document_content.service; import org.daemawiki.domain.common.UserFilter; -import org.daemawiki.domain.content.dto.WriteContentRequest; -import org.daemawiki.domain.content.model.Content; -import org.daemawiki.domain.content.usecase.WriteContentUsecase; -import org.daemawiki.domain.document.application.FindDocumentPort; -import org.daemawiki.domain.document.application.SaveDocumentPort; +import org.daemawiki.domain.document.port.FindDocumentPort; +import org.daemawiki.domain.document.port.SaveDocumentPort; import org.daemawiki.domain.document.model.DefaultDocument; -import org.daemawiki.domain.document.usecase.UpdateDocumentComponent; -import org.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest; -import org.daemawiki.domain.revision.model.type.RevisionType; -import org.daemawiki.domain.revision.usecase.CreateRevisionUsecase; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.document.component.UpdateDocumentComponent; +import org.daemawiki.domain.document_content.dto.WriteContentRequest; +import org.daemawiki.domain.document_content.model.Content; +import org.daemawiki.domain.document_content.usecase.WriteContentUsecase; +import org.daemawiki.domain.document_revision.component.CreateRevisionComponent; +import org.daemawiki.domain.document_revision.model.type.RevisionType; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.domain.user.model.User; import org.daemawiki.exception.h400.VersionMismatchException; import org.daemawiki.exception.h403.NoEditPermissionUserException; @@ -29,24 +28,24 @@ public class WriteContentService implements WriteContentUsecase { private final SaveDocumentPort saveDocumentPort; private final FindDocumentPort findDocumentPort; - private final CreateRevisionUsecase createRevisionUsecase; private final FindUserPort findUserPort; private final UserFilter userFilter; private final UpdateDocumentComponent updateDocumentComponent; + private final CreateRevisionComponent createRevisionComponent; - public WriteContentService(SaveDocumentPort saveDocumentPort, FindDocumentPort findDocumentPort, CreateRevisionUsecase createRevisionUsecase, FindUserPort findUserPort, UserFilter userFilter, UpdateDocumentComponent updateDocumentComponent) { + public WriteContentService(SaveDocumentPort saveDocumentPort, FindDocumentPort findDocumentPort, FindUserPort findUserPort, UserFilter userFilter, UpdateDocumentComponent updateDocumentComponent, CreateRevisionComponent createRevisionComponent) { this.saveDocumentPort = saveDocumentPort; this.findDocumentPort = findDocumentPort; - this.createRevisionUsecase = createRevisionUsecase; this.findUserPort = findUserPort; this.userFilter = userFilter; this.updateDocumentComponent = updateDocumentComponent; + this.createRevisionComponent = createRevisionComponent; } @Override public Mono write(WriteContentRequest request, String documentId) { return findUserPort.currentUser() - .zipWith(findDocumentPort.getDocumentById(documentId)) + .zipWith(findDocumentPort.findById(documentId)) .flatMap(tuple -> checkPermissionAndWriteContent(tuple, request)) .flatMap(this::saveDocumentAndCreateRevision) .onErrorMap(this::mapException); @@ -54,7 +53,7 @@ public Mono write(WriteContentRequest request, String documentId) { private Mono saveDocumentAndCreateRevision(DefaultDocument document) { return saveDocumentPort.save(document) - .then(createRevision(document)); + .then(createRevisionComponent.create(document, RevisionType.UPDATE)); } private Mono checkPermissionAndWriteContent(Tuple2 tuple, WriteContentRequest request) { @@ -66,15 +65,15 @@ private Mono checkPermissionAndWriteContent(Tuple2 contentsMap = document.getContents().stream() .collect(Collectors.toMap(Content::getIndex, Function.identity())); - if (contentsMap.containsKey(request.index())) { - Content content = contentsMap.get(request.index()); - content.setDetail(request.content()); - setDocument(document, user); - - return Mono.just(document); - } else { + if (!contentsMap.containsKey(request.index())) { return Mono.error(ContentNotFoundException.EXCEPTION); } + + Content content = contentsMap.get(request.index()); + content.setDetail(request.content()); + setDocument(document, user); + + return Mono.just(document); } private void setDocument(DefaultDocument document, User user) { @@ -82,11 +81,6 @@ private void setDocument(DefaultDocument document, User user) { document.increaseVersion(); } - private Mono createRevision(DefaultDocument document) { - return createRevisionUsecase.saveHistory(SaveRevisionHistoryRequest - .create(RevisionType.UPDATE, document.getId(), document.getTitle())); - } - private Throwable mapException(Throwable e) { return (e instanceof ContentNotFoundException || e instanceof VersionMismatchException || e instanceof NoEditPermissionUserException) ? e : ExecuteFailedException.EXCEPTION; } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/content/usecase/AddContentTableUsecase.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/usecase/AddContentTableUsecase.java similarity index 54% rename from daemawiki-service/src/main/java/org/daemawiki/domain/content/usecase/AddContentTableUsecase.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_content/usecase/AddContentTableUsecase.java index 1f37e94f..3ce2867d 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/content/usecase/AddContentTableUsecase.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/usecase/AddContentTableUsecase.java @@ -1,6 +1,6 @@ -package org.daemawiki.domain.content.usecase; +package org.daemawiki.domain.document_content.usecase; -import org.daemawiki.domain.content.dto.AddContentRequest; +import org.daemawiki.domain.document_content.dto.AddContentRequest; import reactor.core.publisher.Mono; public interface AddContentTableUsecase { diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/content/usecase/RemoveContentTableUsecase.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/usecase/RemoveContentTableUsecase.java similarity index 55% rename from daemawiki-service/src/main/java/org/daemawiki/domain/content/usecase/RemoveContentTableUsecase.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_content/usecase/RemoveContentTableUsecase.java index 915b77af..e73c69a7 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/content/usecase/RemoveContentTableUsecase.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/usecase/RemoveContentTableUsecase.java @@ -1,6 +1,6 @@ -package org.daemawiki.domain.content.usecase; +package org.daemawiki.domain.document_content.usecase; -import org.daemawiki.domain.content.dto.DeleteContentRequest; +import org.daemawiki.domain.document_content.dto.DeleteContentRequest; import reactor.core.publisher.Mono; public interface RemoveContentTableUsecase { diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/content/usecase/UpdateContentTableTitleUsecase.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/usecase/UpdateContentTableTitleUsecase.java similarity index 56% rename from daemawiki-service/src/main/java/org/daemawiki/domain/content/usecase/UpdateContentTableTitleUsecase.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_content/usecase/UpdateContentTableTitleUsecase.java index 21de9d82..6aae89ee 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/content/usecase/UpdateContentTableTitleUsecase.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/usecase/UpdateContentTableTitleUsecase.java @@ -1,6 +1,6 @@ -package org.daemawiki.domain.content.usecase; +package org.daemawiki.domain.document_content.usecase; -import org.daemawiki.domain.content.dto.EditContentTableTitleRequest; +import org.daemawiki.domain.document_content.dto.EditContentTableTitleRequest; import reactor.core.publisher.Mono; public interface UpdateContentTableTitleUsecase { diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/content/usecase/WriteContentUsecase.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/usecase/WriteContentUsecase.java similarity index 54% rename from daemawiki-service/src/main/java/org/daemawiki/domain/content/usecase/WriteContentUsecase.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_content/usecase/WriteContentUsecase.java index b93ce1f4..c8847f41 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/content/usecase/WriteContentUsecase.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/usecase/WriteContentUsecase.java @@ -1,6 +1,6 @@ -package org.daemawiki.domain.content.usecase; +package org.daemawiki.domain.document_content.usecase; -import org.daemawiki.domain.content.dto.WriteContentRequest; +import org.daemawiki.domain.document_content.dto.WriteContentRequest; import reactor.core.publisher.Mono; public interface WriteContentUsecase { diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/editor/service/AddDocumentEditorService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_editor/service/AddDocumentEditorService.java similarity index 80% rename from daemawiki-service/src/main/java/org/daemawiki/domain/editor/service/AddDocumentEditorService.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_editor/service/AddDocumentEditorService.java index 8d894ccc..a293f462 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/editor/service/AddDocumentEditorService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_editor/service/AddDocumentEditorService.java @@ -1,12 +1,12 @@ -package org.daemawiki.domain.editor.service; +package org.daemawiki.domain.document_editor.service; -import org.daemawiki.domain.document.application.FindDocumentPort; -import org.daemawiki.domain.document.application.SaveDocumentPort; +import org.daemawiki.domain.document.port.FindDocumentPort; +import org.daemawiki.domain.document.port.SaveDocumentPort; import org.daemawiki.domain.document.model.DefaultDocument; -import org.daemawiki.domain.editor.dto.AddEditorRequest; -import org.daemawiki.domain.editor.model.Editor; -import org.daemawiki.domain.editor.usecase.AddDocumentEditorUsecase; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.document_editor.dto.AddEditorRequest; +import org.daemawiki.domain.document_editor.model.Editor; +import org.daemawiki.domain.document_editor.usecase.AddDocumentEditorUsecase; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.domain.user.model.User; import org.daemawiki.exception.h403.NoPermissionUserException; import org.daemawiki.exception.h404.UserNotFoundException; @@ -29,7 +29,7 @@ public AddDocumentEditorService(FindUserPort findUserPort, SaveDocumentPort save @Override public Mono add(AddEditorRequest request, String documentId) { return findUserPort.currentUser() - .zipWith(findDocumentPort.getDocumentById(documentId)) + .zipWith(findDocumentPort.findById(documentId)) .flatMap(this::checkPermission) .zipWith(findUser(request)) .map(this::updateDocument) diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/editor/service/RemoveDocumentEditorService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_editor/service/RemoveDocumentEditorService.java similarity index 79% rename from daemawiki-service/src/main/java/org/daemawiki/domain/editor/service/RemoveDocumentEditorService.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_editor/service/RemoveDocumentEditorService.java index 91608281..34048bc3 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/editor/service/RemoveDocumentEditorService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_editor/service/RemoveDocumentEditorService.java @@ -1,11 +1,11 @@ -package org.daemawiki.domain.editor.service; +package org.daemawiki.domain.document_editor.service; -import org.daemawiki.domain.document.application.FindDocumentPort; -import org.daemawiki.domain.document.application.SaveDocumentPort; +import org.daemawiki.domain.document.port.FindDocumentPort; +import org.daemawiki.domain.document.port.SaveDocumentPort; import org.daemawiki.domain.document.model.DefaultDocument; -import org.daemawiki.domain.editor.dto.DeleteEditorRequest; -import org.daemawiki.domain.editor.usecase.RemoveDocumentEditorUsecase; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.document_editor.dto.DeleteEditorRequest; +import org.daemawiki.domain.document_editor.usecase.RemoveDocumentEditorUsecase; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.domain.user.model.User; import org.daemawiki.exception.h403.NoPermissionUserException; import org.springframework.stereotype.Service; @@ -29,7 +29,7 @@ public RemoveDocumentEditorService(FindUserPort findUserPort, FindDocumentPort f @Override public Mono remove(DeleteEditorRequest request, String documentId) { return findUserPort.currentUser() - .zipWith(findDocumentPort.getDocumentById(documentId)) + .zipWith(findDocumentPort.findById(documentId)) .flatMap(this::checkPermission) .flatMap(document -> updateDocument(document, request.userId())); } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/editor/usecase/AddDocumentEditorUsecase.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_editor/usecase/AddDocumentEditorUsecase.java similarity index 55% rename from daemawiki-service/src/main/java/org/daemawiki/domain/editor/usecase/AddDocumentEditorUsecase.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_editor/usecase/AddDocumentEditorUsecase.java index d6b5cfef..36858345 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/editor/usecase/AddDocumentEditorUsecase.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_editor/usecase/AddDocumentEditorUsecase.java @@ -1,6 +1,6 @@ -package org.daemawiki.domain.editor.usecase; +package org.daemawiki.domain.document_editor.usecase; -import org.daemawiki.domain.editor.dto.AddEditorRequest; +import org.daemawiki.domain.document_editor.dto.AddEditorRequest; import reactor.core.publisher.Mono; public interface AddDocumentEditorUsecase { diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/editor/usecase/RemoveDocumentEditorUsecase.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_editor/usecase/RemoveDocumentEditorUsecase.java similarity index 56% rename from daemawiki-service/src/main/java/org/daemawiki/domain/editor/usecase/RemoveDocumentEditorUsecase.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_editor/usecase/RemoveDocumentEditorUsecase.java index f69d1e60..95afce5b 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/editor/usecase/RemoveDocumentEditorUsecase.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_editor/usecase/RemoveDocumentEditorUsecase.java @@ -1,6 +1,6 @@ -package org.daemawiki.domain.editor.usecase; +package org.daemawiki.domain.document_editor.usecase; -import org.daemawiki.domain.editor.dto.DeleteEditorRequest; +import org.daemawiki.domain.document_editor.dto.DeleteEditorRequest; import reactor.core.publisher.Mono; public interface RemoveDocumentEditorUsecase { diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/info/service/UpdateDocumentInfoService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_info/service/UpdateDocumentInfoService.java similarity index 65% rename from daemawiki-service/src/main/java/org/daemawiki/domain/info/service/UpdateDocumentInfoService.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_info/service/UpdateDocumentInfoService.java index 71a90b96..71fc1703 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/info/service/UpdateDocumentInfoService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_info/service/UpdateDocumentInfoService.java @@ -1,16 +1,15 @@ -package org.daemawiki.domain.info.service; +package org.daemawiki.domain.document_info.service; import org.daemawiki.domain.common.UserFilter; -import org.daemawiki.domain.document.application.FindDocumentPort; -import org.daemawiki.domain.document.application.SaveDocumentPort; +import org.daemawiki.domain.document.port.FindDocumentPort; +import org.daemawiki.domain.document.port.SaveDocumentPort; import org.daemawiki.domain.document.model.DefaultDocument; -import org.daemawiki.domain.info.dto.UpdateInfoRequest; -import org.daemawiki.domain.info.model.Detail; -import org.daemawiki.domain.info.usecase.UpdateDocumentInfoUsecase; -import org.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest; -import org.daemawiki.domain.revision.model.type.RevisionType; -import org.daemawiki.domain.revision.usecase.CreateRevisionUsecase; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.document_info.dto.UpdateInfoRequest; +import org.daemawiki.domain.document_info.model.Detail; +import org.daemawiki.domain.document_info.usecase.UpdateDocumentInfoUsecase; +import org.daemawiki.domain.document_revision.component.CreateRevisionComponent; +import org.daemawiki.domain.document_revision.model.type.RevisionType; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.domain.user.dto.response.UserDetailResponse; import org.daemawiki.domain.user.model.User; import org.daemawiki.exception.h400.VersionMismatchException; @@ -26,22 +25,23 @@ public class UpdateDocumentInfoService implements UpdateDocumentInfoUsecase { private final SaveDocumentPort saveDocumentPort; private final FindDocumentPort findDocumentPort; - private final CreateRevisionUsecase createRevisionUsecase; private final FindUserPort findUserPort; private final UserFilter userFilter; + private final CreateRevisionComponent createRevisionComponent; - public UpdateDocumentInfoService(SaveDocumentPort saveDocumentPort, FindDocumentPort findDocumentPort, CreateRevisionUsecase createRevisionUsecase, FindUserPort findUserPort, UserFilter userFilter) { + + public UpdateDocumentInfoService(SaveDocumentPort saveDocumentPort, FindDocumentPort findDocumentPort, FindUserPort findUserPort, UserFilter userFilter, CreateRevisionComponent createRevisionComponent) { this.saveDocumentPort = saveDocumentPort; this.findDocumentPort = findDocumentPort; - this.createRevisionUsecase = createRevisionUsecase; this.findUserPort = findUserPort; this.userFilter = userFilter; + this.createRevisionComponent = createRevisionComponent; } @Override public Mono update(String documentId, UpdateInfoRequest request) { return findUserPort.currentUser() - .zipWith(findDocumentPort.getDocumentById(documentId)) + .zipWith(findDocumentPort.findById(documentId)) .flatMap(tuple -> checkPermissionAndUpdateDocument(tuple, request)) .onErrorMap(this::mapException); } @@ -55,7 +55,7 @@ private Mono checkPermissionAndUpdateDocument(Tuple2 details) { @@ -64,11 +64,6 @@ private void setDocument(DefaultDocument document, User user, String subTitle, L document.increaseVersion(); } - private Mono createRevision(DefaultDocument document) { - return createRevisionUsecase.saveHistory(SaveRevisionHistoryRequest - .create(RevisionType.UPDATE, document.getId(), document.getTitle())); - } - private Throwable mapException(Throwable e) { return e instanceof VersionMismatchException || e instanceof NoEditPermissionUserException ? e : ExecuteFailedException.EXCEPTION; } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/info/service/UploadDocumentImageService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_info/service/UploadDocumentImageService.java similarity index 66% rename from daemawiki-service/src/main/java/org/daemawiki/domain/info/service/UploadDocumentImageService.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_info/service/UploadDocumentImageService.java index 773139a9..869cbf1f 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/info/service/UploadDocumentImageService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_info/service/UploadDocumentImageService.java @@ -1,16 +1,15 @@ -package org.daemawiki.domain.info.service; +package org.daemawiki.domain.document_info.service; import org.daemawiki.domain.common.UserFilter; -import org.daemawiki.domain.document.application.FindDocumentPort; -import org.daemawiki.domain.document.application.SaveDocumentPort; +import org.daemawiki.domain.document.port.FindDocumentPort; +import org.daemawiki.domain.document.port.SaveDocumentPort; import org.daemawiki.domain.document.model.DefaultDocument; +import org.daemawiki.domain.document_info.usecase.UploadDocumentImageUsecase; +import org.daemawiki.domain.document_revision.component.CreateRevisionComponent; +import org.daemawiki.domain.document_revision.model.type.RevisionType; import org.daemawiki.domain.file.model.File; import org.daemawiki.domain.file.model.type.FileType; -import org.daemawiki.domain.info.usecase.UploadDocumentImageUsecase; -import org.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest; -import org.daemawiki.domain.revision.model.type.RevisionType; -import org.daemawiki.domain.revision.usecase.CreateRevisionUsecase; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.domain.user.model.User; import org.daemawiki.infra.s3.service.S3UploadObject; import org.springframework.http.codec.multipart.FilePart; @@ -25,21 +24,21 @@ public class UploadDocumentImageService implements UploadDocumentImageUsecase { private final FindDocumentPort findDocumentPort; private final SaveDocumentPort saveDocumentPort; private final UserFilter userFilter; - private final CreateRevisionUsecase createRevisionUsecase; + private final CreateRevisionComponent createRevisionComponent; - public UploadDocumentImageService(S3UploadObject s3UploadObject, FindUserPort findUserPort, FindDocumentPort findDocumentPort, SaveDocumentPort saveDocumentPort, UserFilter userFilter, CreateRevisionUsecase createRevisionUsecase) { + public UploadDocumentImageService(S3UploadObject s3UploadObject, FindUserPort findUserPort, FindDocumentPort findDocumentPort, SaveDocumentPort saveDocumentPort, UserFilter userFilter, CreateRevisionComponent createRevisionComponent) { this.s3UploadObject = s3UploadObject; this.findUserPort = findUserPort; this.findDocumentPort = findDocumentPort; this.saveDocumentPort = saveDocumentPort; this.userFilter = userFilter; - this.createRevisionUsecase = createRevisionUsecase; + this.createRevisionComponent = createRevisionComponent; } @Override public Mono upload(FilePart filePart, String documentId) { return findUserPort.currentUser() - .zipWith(findDocumentPort.getDocumentById(documentId)) + .zipWith(findDocumentPort.findById(documentId)) .map(this::checkPermission) .zipWith(s3UploadObject.uploadObject(filePart, FileType.DOCUMENT.toString())) .flatMap(this::updateDocument); @@ -52,7 +51,7 @@ private Mono updateDocument(Tuple2 tuple) { document.getInfo().setDocumentImage(file); return saveDocumentPort.save(document) - .then(createRevision(document)); + .then(createRevisionComponent.create(document, RevisionType.UPDATE)); } private DefaultDocument checkPermission(Tuple2 tuple) { @@ -60,9 +59,4 @@ private DefaultDocument checkPermission(Tuple2 tuple) { return tuple.getT2(); } - private Mono createRevision(DefaultDocument document) { - return createRevisionUsecase.saveHistory(SaveRevisionHistoryRequest - .create(RevisionType.UPDATE, document.getId(), document.getTitle())); - } - } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/info/usecase/UpdateDocumentInfoUsecase.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_info/usecase/UpdateDocumentInfoUsecase.java similarity index 56% rename from daemawiki-service/src/main/java/org/daemawiki/domain/info/usecase/UpdateDocumentInfoUsecase.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_info/usecase/UpdateDocumentInfoUsecase.java index 138246d4..0c4c6664 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/info/usecase/UpdateDocumentInfoUsecase.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_info/usecase/UpdateDocumentInfoUsecase.java @@ -1,6 +1,6 @@ -package org.daemawiki.domain.info.usecase; +package org.daemawiki.domain.document_info.usecase; -import org.daemawiki.domain.info.dto.UpdateInfoRequest; +import org.daemawiki.domain.document_info.dto.UpdateInfoRequest; import reactor.core.publisher.Mono; public interface UpdateDocumentInfoUsecase { diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/info/usecase/UploadDocumentImageUsecase.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_info/usecase/UploadDocumentImageUsecase.java similarity index 79% rename from daemawiki-service/src/main/java/org/daemawiki/domain/info/usecase/UploadDocumentImageUsecase.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_info/usecase/UploadDocumentImageUsecase.java index 8a36f1c7..25ca510e 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/info/usecase/UploadDocumentImageUsecase.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_info/usecase/UploadDocumentImageUsecase.java @@ -1,4 +1,4 @@ -package org.daemawiki.domain.info.usecase; +package org.daemawiki.domain.document_info.usecase; import org.springframework.http.codec.multipart.FilePart; import reactor.core.publisher.Mono; diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/component/CreateRevisionComponent.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/component/CreateRevisionComponent.java new file mode 100644 index 00000000..5daf9d9e --- /dev/null +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/component/CreateRevisionComponent.java @@ -0,0 +1,13 @@ +package org.daemawiki.domain.document_revision.component; + +import org.daemawiki.domain.document.model.DefaultDocument; +import org.daemawiki.domain.document_revision.model.RevisionDetail; +import org.daemawiki.domain.document_revision.model.type.RevisionType; +import reactor.core.publisher.Mono; + +import java.util.List; + +public interface CreateRevisionComponent { + Mono create(DefaultDocument document, RevisionType revisionType, List data); + +} diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/component/CreateRevisionComponentImpl.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/component/CreateRevisionComponentImpl.java new file mode 100644 index 00000000..ad567b04 --- /dev/null +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/component/CreateRevisionComponentImpl.java @@ -0,0 +1,27 @@ +package org.daemawiki.domain.document_revision.component; + +import org.daemawiki.domain.document.model.DefaultDocument; +import org.daemawiki.domain.document_revision.dto.request.SaveRevisionHistoryDto; +import org.daemawiki.domain.document_revision.model.RevisionDetail; +import org.daemawiki.domain.document_revision.model.type.RevisionType; +import org.daemawiki.domain.document_revision.usecase.CreateRevisionUsecase; +import org.springframework.stereotype.Component; +import reactor.core.publisher.Mono; + +import java.util.List; + +@Component +public class CreateRevisionComponentImpl implements CreateRevisionComponent { + private final CreateRevisionUsecase createRevisionUsecase; + + public CreateRevisionComponentImpl(CreateRevisionUsecase createRevisionUsecase) { + this.createRevisionUsecase = createRevisionUsecase; + } + + @Override + public Mono create(DefaultDocument document, RevisionType revisionType, List data) { + return createRevisionUsecase.saveHistory(SaveRevisionHistoryDto + .create(revisionType, document.getId(), document.getVersion(), document.getTitle(), data)); + } + +} diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/revision/mapper/RevisionMapper.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/mapper/RevisionMapper.java similarity index 67% rename from daemawiki-service/src/main/java/org/daemawiki/domain/revision/mapper/RevisionMapper.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/mapper/RevisionMapper.java index 57fd9a08..fd3ad2c7 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/revision/mapper/RevisionMapper.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/mapper/RevisionMapper.java @@ -1,7 +1,7 @@ -package org.daemawiki.domain.revision.mapper; +package org.daemawiki.domain.document_revision.mapper; import org.daemawiki.domain.document.dto.response.SimpleDocumentResponse; -import org.daemawiki.domain.revision.model.RevisionHistory; +import org.daemawiki.domain.document_revision.model.RevisionHistory; import reactor.core.publisher.Mono; public interface RevisionMapper { diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/revision/mapper/RevisionMapperImpl.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/mapper/RevisionMapperImpl.java similarity index 69% rename from daemawiki-service/src/main/java/org/daemawiki/domain/revision/mapper/RevisionMapperImpl.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/mapper/RevisionMapperImpl.java index 31e7e972..0a371442 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/revision/mapper/RevisionMapperImpl.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/mapper/RevisionMapperImpl.java @@ -1,8 +1,8 @@ -package org.daemawiki.domain.revision.mapper; +package org.daemawiki.domain.document_revision.mapper; -import org.daemawiki.domain.document.application.FindDocumentPort; +import org.daemawiki.domain.document.port.FindDocumentPort; import org.daemawiki.domain.document.dto.response.SimpleDocumentResponse; -import org.daemawiki.domain.revision.model.RevisionHistory; +import org.daemawiki.domain.document_revision.model.RevisionHistory; import org.springframework.stereotype.Component; import reactor.core.publisher.Mono; @@ -16,7 +16,7 @@ public RevisionMapperImpl(FindDocumentPort findDocumentPort) { @Override public Mono revisionToRevisionSimpleDocumentResponse(RevisionHistory revisionHistory) { - return findDocumentPort.getDocumentById(revisionHistory.getDocumentId()) + return findDocumentPort.findById(revisionHistory.getDocumentId()) .map(SimpleDocumentResponse::of); } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/revision/service/CreateRevisionService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/service/CreateRevisionService.java similarity index 56% rename from daemawiki-service/src/main/java/org/daemawiki/domain/revision/service/CreateRevisionService.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/service/CreateRevisionService.java index 80e478dd..551d480a 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/revision/service/CreateRevisionService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/service/CreateRevisionService.java @@ -1,11 +1,11 @@ -package org.daemawiki.domain.revision.service; +package org.daemawiki.domain.document_revision.service; -import org.daemawiki.domain.editor.model.Editor; -import org.daemawiki.domain.revision.application.SaveRevisionPort; -import org.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest; -import org.daemawiki.domain.revision.model.RevisionHistory; -import org.daemawiki.domain.revision.usecase.CreateRevisionUsecase; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.document_editor.model.Editor; +import org.daemawiki.domain.document_revision.port.SaveRevisionPort; +import org.daemawiki.domain.document_revision.dto.request.SaveRevisionHistoryDto; +import org.daemawiki.domain.document_revision.model.RevisionHistory; +import org.daemawiki.domain.document_revision.usecase.CreateRevisionUsecase; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.domain.user.model.User; import org.daemawiki.exception.h500.ExecuteFailedException; import org.springframework.stereotype.Service; @@ -24,22 +24,24 @@ public CreateRevisionService(SaveRevisionPort saveRevisionPort, FindUserPort fin } @Override - public Mono saveHistory(SaveRevisionHistoryRequest request) { + public Mono saveHistory(SaveRevisionHistoryDto request) { return findUserPort.currentUser() - .flatMap(user -> createRevision(request, user)) + .map(user -> createRevision(request, user)) .flatMap(saveRevisionPort::save) .onErrorMap(e -> ExecuteFailedException.EXCEPTION) .then(); } - private Mono createRevision(SaveRevisionHistoryRequest request, User user) { - return Mono.just(RevisionHistory.builder() + private RevisionHistory createRevision(SaveRevisionHistoryDto request, User user) { + return RevisionHistory.builder() .type(request.type()) .documentId(request.documentId()) + .version(request.version()) .title(request.title()) .editor(Editor.create(user.getName(), user.getId())) .createdDateTime(LocalDateTime.now()) - .build()); + .data(request.data()) + .build(); } } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/revision/service/GetRevisionService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/service/GetRevisionService.java similarity index 50% rename from daemawiki-service/src/main/java/org/daemawiki/domain/revision/service/GetRevisionService.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/service/GetRevisionService.java index ea02a93f..e24e22bb 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/revision/service/GetRevisionService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/service/GetRevisionService.java @@ -1,11 +1,11 @@ -package org.daemawiki.domain.revision.service; +package org.daemawiki.domain.document_revision.service; import org.daemawiki.domain.document.dto.response.SimpleDocumentResponse; -import org.daemawiki.domain.revision.dto.response.GetRevisionByUserResponse; -import org.daemawiki.domain.revision.mapper.RevisionMapper; -import org.daemawiki.domain.revision.model.RevisionHistory; -import org.daemawiki.domain.revision.persistence.RevisionPersistenceAdapter; -import org.daemawiki.domain.revision.usecase.GetRevisionUsecase; +import org.daemawiki.domain.document_revision.port.FindRevisionPort; +import org.daemawiki.domain.document_revision.dto.response.GetRevisionByUserResponse; +import org.daemawiki.domain.document_revision.mapper.RevisionMapper; +import org.daemawiki.domain.document_revision.model.RevisionHistory; +import org.daemawiki.domain.document_revision.usecase.GetRevisionUsecase; import org.daemawiki.utils.PagingInfo; import org.springframework.stereotype.Service; import reactor.core.publisher.Flux; @@ -14,33 +14,33 @@ @Service public class GetRevisionService implements GetRevisionUsecase { - private final RevisionPersistenceAdapter revisionPersistenceAdapter; + private final FindRevisionPort findRevisionPort; private final RevisionMapper revisionMapper; - public GetRevisionService(RevisionPersistenceAdapter revisionPersistenceAdapter, RevisionMapper revisionMapper) { - this.revisionPersistenceAdapter = revisionPersistenceAdapter; + public GetRevisionService(FindRevisionPort findRevisionPort, RevisionMapper revisionMapper) { + this.findRevisionPort = findRevisionPort; this.revisionMapper = revisionMapper; } @Override public Flux getRevisionOrderByUpdated(List types, PagingInfo pagingInfo) { - return revisionPersistenceAdapter.getRevisionOrderByUpdated(pagingInfo, types) + return findRevisionPort.findAllSortByUpdatedDate(pagingInfo, types) .flatMap(revisionMapper::revisionToRevisionSimpleDocumentResponse); } @Override public Flux getAllRevisionPaging(PagingInfo pagingInfo) { - return revisionPersistenceAdapter.getAllRevisionPaging(pagingInfo); + return findRevisionPort.findAll(pagingInfo); } @Override public Flux getAllRevisionByDocument(String documentId, PagingInfo pagingInfo) { - return revisionPersistenceAdapter.getAllRevisionByDocument(documentId, pagingInfo); + return findRevisionPort.findAllByDocumentId(documentId, pagingInfo); } @Override public Flux getAllRevisionByUser(String userId, PagingInfo pagingInfo) { - return revisionPersistenceAdapter.getAllRevisionByUser(userId, pagingInfo) + return findRevisionPort.findAllByUserId(userId, pagingInfo) .map(GetRevisionByUserResponse::of); } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/usecase/CreateRevisionUsecase.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/usecase/CreateRevisionUsecase.java new file mode 100644 index 00000000..607e4c34 --- /dev/null +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/usecase/CreateRevisionUsecase.java @@ -0,0 +1,9 @@ +package org.daemawiki.domain.document_revision.usecase; + +import org.daemawiki.domain.document_revision.dto.request.SaveRevisionHistoryDto; +import reactor.core.publisher.Mono; + +public interface CreateRevisionUsecase { + Mono saveHistory(SaveRevisionHistoryDto request); + +} diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/revision/usecase/GetRevisionUsecase.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/usecase/GetRevisionUsecase.java similarity index 73% rename from daemawiki-service/src/main/java/org/daemawiki/domain/revision/usecase/GetRevisionUsecase.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/usecase/GetRevisionUsecase.java index 6391c1ae..544aed34 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/revision/usecase/GetRevisionUsecase.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_revision/usecase/GetRevisionUsecase.java @@ -1,8 +1,8 @@ -package org.daemawiki.domain.revision.usecase; +package org.daemawiki.domain.document_revision.usecase; import org.daemawiki.domain.document.dto.response.SimpleDocumentResponse; -import org.daemawiki.domain.revision.dto.response.GetRevisionByUserResponse; -import org.daemawiki.domain.revision.model.RevisionHistory; +import org.daemawiki.domain.document_revision.dto.response.GetRevisionByUserResponse; +import org.daemawiki.domain.document_revision.model.RevisionHistory; import org.daemawiki.utils.PagingInfo; import reactor.core.publisher.Flux; diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/file/component/DeleteFile.java b/daemawiki-service/src/main/java/org/daemawiki/domain/file/component/DeleteFile.java index 1d72fba8..d50dab9d 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/file/component/DeleteFile.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/file/component/DeleteFile.java @@ -1,6 +1,6 @@ package org.daemawiki.domain.file.component; -import org.daemawiki.domain.file.repository.FileRepository; +import org.daemawiki.domain.file.port.DeleteFilePort; import org.daemawiki.exception.h500.ExecuteFailedException; import org.springframework.stereotype.Component; import reactor.core.publisher.Mono; @@ -9,14 +9,14 @@ @Component public class DeleteFile { - private final FileRepository fileRepository; + private final DeleteFilePort deleteFilePort; - public DeleteFile(FileRepository fileRepository) { - this.fileRepository = fileRepository; + public DeleteFile(DeleteFilePort deleteFilePort) { + this.deleteFilePort = deleteFilePort; } public Mono deleteById(String id) { - return fileRepository.deleteById(UUID.fromString(id)) + return deleteFilePort.deleteById(UUID.fromString(id)) .onErrorMap(e -> ExecuteFailedException.EXCEPTION); } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/file/service/GetFileService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/file/service/GetFileService.java index d601686a..a2d34976 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/file/service/GetFileService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/file/service/GetFileService.java @@ -1,6 +1,6 @@ package org.daemawiki.domain.file.service; -import org.daemawiki.domain.file.application.FindFilePort; +import org.daemawiki.domain.file.port.FindFilePort; import org.daemawiki.domain.file.model.File; import org.daemawiki.domain.file.usecase.GetFileUsecase; import org.daemawiki.exception.h404.FileNotFoundException; diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/mail/service/UserMailSendService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/mail/service/UserMailSendService.java index dc21cb79..5a73ec1b 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/mail/service/UserMailSendService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/mail/service/UserMailSendService.java @@ -3,12 +3,13 @@ import jakarta.mail.MessagingException; import jakarta.mail.internet.InternetAddress; import jakarta.mail.internet.MimeMessage; -import org.daemawiki.domain.mail.application.code.SaveAuthCodePort; +import lombok.extern.slf4j.Slf4j; +import org.daemawiki.domain.mail.port.code.SaveAuthCodePort; import org.daemawiki.domain.mail.dto.AuthCodeRequest; import org.daemawiki.domain.mail.model.AuthCode; import org.daemawiki.domain.mail.model.type.MailType; import org.daemawiki.domain.mail.usecase.UserMailSendUsecase; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.exception.h409.EmailAlreadyExistsException; import org.daemawiki.exception.h500.ExecuteFailedException; import org.daemawiki.exception.h500.MailSendFailedException; @@ -25,6 +26,7 @@ import java.util.Base64; import java.util.Objects; +@Slf4j @Service public class UserMailSendService implements UserMailSendUsecase { private final SaveAuthCodePort saveAuthCodePort; @@ -57,6 +59,8 @@ public Mono send(AuthCodeRequest request) { .then(Mono.defer(() -> { String authCode = getRandomCode(); + log.info("authCode: {} to: {}", authCode, mail); + sendMail(mail, authCode) .subscribeOn(scheduler) .subscribe(); diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/mail/service/UserMailVerifyService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/mail/service/UserMailVerifyService.java index 1118376d..ef4d85d2 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/mail/service/UserMailVerifyService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/mail/service/UserMailVerifyService.java @@ -1,8 +1,8 @@ package org.daemawiki.domain.mail.service; -import org.daemawiki.domain.mail.application.code.DeleteAuthCodePort; -import org.daemawiki.domain.mail.application.code.FindAuthCodePort; -import org.daemawiki.domain.mail.application.mail.SaveAuthMailPort; +import org.daemawiki.domain.mail.port.code.DeleteAuthCodePort; +import org.daemawiki.domain.mail.port.code.FindAuthCodePort; +import org.daemawiki.domain.mail.port.mail.SaveAuthMailPort; import org.daemawiki.domain.mail.dto.AuthCodeVerifyRequest; import org.daemawiki.domain.mail.dto.AuthCodeVerifyResponse; import org.daemawiki.domain.mail.model.AuthCode; diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/revision/usecase/CreateRevisionUsecase.java b/daemawiki-service/src/main/java/org/daemawiki/domain/revision/usecase/CreateRevisionUsecase.java deleted file mode 100644 index 991b9e90..00000000 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/revision/usecase/CreateRevisionUsecase.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.daemawiki.domain.revision.usecase; - -import org.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest; -import reactor.core.publisher.Mono; - -public interface CreateRevisionUsecase { - Mono saveHistory(SaveRevisionHistoryRequest request); - -} diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/ChangeUserPasswordService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/ChangeUserPasswordService.java index 9607910b..cdb2de59 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/ChangeUserPasswordService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/ChangeUserPasswordService.java @@ -1,8 +1,8 @@ package org.daemawiki.domain.user.service; -import org.daemawiki.domain.mail.application.mail.FindAuthMailPort; -import org.daemawiki.domain.user.application.FindUserPort; -import org.daemawiki.domain.user.application.SaveUserPort; +import org.daemawiki.domain.mail.port.mail.FindAuthMailPort; +import org.daemawiki.domain.user.port.FindUserPort; +import org.daemawiki.domain.user.port.SaveUserPort; import org.daemawiki.domain.user.dto.request.ChangePasswordRequest; import org.daemawiki.domain.user.model.User; import org.daemawiki.domain.user.usecase.ChangeUserPasswordUsecase; diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/DeleteUserService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/DeleteUserService.java index 572e624e..17ec5a00 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/DeleteUserService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/DeleteUserService.java @@ -1,11 +1,7 @@ package org.daemawiki.domain.user.service; -import org.daemawiki.domain.document.application.DeleteDocumentPort; -import org.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest; -import org.daemawiki.domain.revision.model.type.RevisionType; -import org.daemawiki.domain.revision.usecase.CreateRevisionUsecase; -import org.daemawiki.domain.user.application.DeleteUserPort; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.user.port.DeleteUserPort; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.domain.user.usecase.DeleteUserUsecase; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; @@ -14,31 +10,16 @@ public class DeleteUserService implements DeleteUserUsecase { private final FindUserPort findUserPort; private final DeleteUserPort deleteUserPort; - private final DeleteDocumentPort deleteDocumentPort; - private final CreateRevisionUsecase createRevisionUsecase; - public DeleteUserService(FindUserPort findUserPort, DeleteUserPort deleteUserPort, DeleteDocumentPort deleteDocumentPort, CreateRevisionUsecase createRevisionUsecase) { + public DeleteUserService(FindUserPort findUserPort, DeleteUserPort deleteUserPort) { this.findUserPort = findUserPort; this.deleteUserPort = deleteUserPort; - this.deleteDocumentPort = deleteDocumentPort; - this.createRevisionUsecase = createRevisionUsecase; } @Override public Mono deleteCurrentUser() { return findUserPort.currentUser() - .flatMap(user -> { - String documentId = user.getDocumentId(); - - return Mono.when(deleteDocumentPort.deleteById(documentId), - deleteUserPort.delete(user)) - .then(createRevision(documentId, user.getName())); - }); - } - - private Mono createRevision(String documentId, String name) { - return createRevisionUsecase.saveHistory(SaveRevisionHistoryRequest - .create(RevisionType.DELETE, documentId, name)); + .flatMap(deleteUserPort::delete); } } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/GetUserService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/GetUserService.java index db3a1bdc..6cd6fcb2 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/GetUserService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/GetUserService.java @@ -1,6 +1,6 @@ package org.daemawiki.domain.user.service; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.domain.user.dto.FindUserDto; import org.daemawiki.domain.user.dto.response.GetUserResponse; import org.daemawiki.domain.user.usecase.GetUserUsecase; @@ -26,8 +26,8 @@ public Mono getCurrentUser() { @Override public Flux getUserByGenAndMajorAndClub(Integer gen, String major, String club, String sortBy, Integer sortDirection, Integer page, Integer size) { return findUserPort.findAllByGenAndMajorAndClub( - FindUserDto.of(gen, major, club, PagingInfo.of(sortBy, sortDirection, page, size)) - ).map(GetUserResponse::of); + FindUserDto.of(gen, major, club, PagingInfo.of(sortBy, sortDirection, page, size))) + .map(GetUserResponse::of); } } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/UpdateUserService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/UpdateUserService.java index 60adf0d0..58756d73 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/UpdateUserService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/UpdateUserService.java @@ -1,13 +1,12 @@ package org.daemawiki.domain.user.service; -import org.daemawiki.domain.document.application.FindDocumentPort; -import org.daemawiki.domain.document.application.SaveDocumentPort; +import org.daemawiki.domain.document.port.FindDocumentPort; +import org.daemawiki.domain.document.port.SaveDocumentPort; import org.daemawiki.domain.document.model.DefaultDocument; -import org.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest; -import org.daemawiki.domain.revision.model.type.RevisionType; -import org.daemawiki.domain.revision.usecase.CreateRevisionUsecase; -import org.daemawiki.domain.user.application.FindUserPort; -import org.daemawiki.domain.user.application.SaveUserPort; +import org.daemawiki.domain.document_revision.component.CreateRevisionComponent; +import org.daemawiki.domain.document_revision.model.type.RevisionType; +import org.daemawiki.domain.user.port.FindUserPort; +import org.daemawiki.domain.user.port.SaveUserPort; import org.daemawiki.domain.user.dto.request.UpdateUserRequest; import org.daemawiki.domain.user.model.User; import org.daemawiki.domain.user.usecase.UpdateUserUsecase; @@ -23,14 +22,14 @@ public class UpdateUserService implements UpdateUserUsecase { private final FindDocumentPort findDocumentPort; private final SaveDocumentPort saveDocumentPort; private final SaveUserPort saveUserPort; - private final CreateRevisionUsecase createRevisionUsecase; + private final CreateRevisionComponent createRevisionComponent; - public UpdateUserService(FindUserPort findUserPort, FindDocumentPort findDocumentPort, SaveDocumentPort saveDocumentPort, SaveUserPort saveUserPort, CreateRevisionUsecase createRevisionUsecase) { + public UpdateUserService(FindUserPort findUserPort, FindDocumentPort findDocumentPort, SaveDocumentPort saveDocumentPort, SaveUserPort saveUserPort, CreateRevisionComponent createRevisionComponent) { this.findUserPort = findUserPort; this.findDocumentPort = findDocumentPort; this.saveDocumentPort = saveDocumentPort; this.saveUserPort = saveUserPort; - this.createRevisionUsecase = createRevisionUsecase; + this.createRevisionComponent = createRevisionComponent; } @Override @@ -42,14 +41,14 @@ public Mono updateUser(UpdateUserRequest request) { } private Mono updateUserDocument(User user) { - return findDocumentPort.getDocumentById(user.getDocumentId()) + return findDocumentPort.findById(user.getDocumentId()) .doOnNext(document -> setDocumentForUpdateUser(document, user)) .flatMap(this::saveDocumentAndCreateRevision); } private Mono saveDocumentAndCreateRevision(DefaultDocument document) { return saveDocumentPort.save(document) - .then(createRevision(document)); + .then(createRevisionComponent.create(document, RevisionType.UPDATE)); } private void setDocumentForUpdateUser(DefaultDocument document, User user) { @@ -71,9 +70,4 @@ private List> createNewGroups(User user) { return newGroups; } - private Mono createRevision(DefaultDocument document) { - return createRevisionUsecase.saveHistory(SaveRevisionHistoryRequest - .create(RevisionType.UPDATE, document.getId(), document.getTitle())); - } - } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/UploadUserProfileImageService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/UploadUserProfileImageService.java index e7ba41c0..87fdc86c 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/UploadUserProfileImageService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/user/service/UploadUserProfileImageService.java @@ -1,8 +1,8 @@ package org.daemawiki.domain.user.service; import org.daemawiki.domain.file.model.type.FileType; -import org.daemawiki.domain.user.application.FindUserPort; -import org.daemawiki.domain.user.application.SaveUserPort; +import org.daemawiki.domain.user.port.FindUserPort; +import org.daemawiki.domain.user.port.SaveUserPort; import org.daemawiki.domain.user.usecase.UploadUserProfileImageUsecase; import org.daemawiki.exception.h500.ExecuteFailedException; import org.daemawiki.exception.h500.FileUploadFailedException; diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/auth/service/ReissueService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/service/ReissueService.java similarity index 86% rename from daemawiki-service/src/main/java/org/daemawiki/domain/auth/service/ReissueService.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/service/ReissueService.java index 4e1ba4d3..f5c1825f 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/auth/service/ReissueService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/service/ReissueService.java @@ -1,7 +1,7 @@ -package org.daemawiki.domain.auth.service; +package org.daemawiki.domain.user_auth.service; -import org.daemawiki.domain.auth.dto.response.TokenResponse; -import org.daemawiki.domain.auth.usecase.ReissueUsecase; +import org.daemawiki.domain.user_auth.dto.response.TokenResponse; +import org.daemawiki.domain.user_auth.usecase.ReissueUsecase; import org.daemawiki.exception.h500.TokenReissueFailedException; import org.daemawiki.security.Tokenizer; import org.springframework.stereotype.Service; diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/auth/service/SigninService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/service/SigninService.java similarity index 88% rename from daemawiki-service/src/main/java/org/daemawiki/domain/auth/service/SigninService.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/service/SigninService.java index d3158eba..5a01b7b5 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/auth/service/SigninService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/service/SigninService.java @@ -1,9 +1,9 @@ -package org.daemawiki.domain.auth.service; +package org.daemawiki.domain.user_auth.service; -import org.daemawiki.domain.auth.dto.request.LoginRequest; -import org.daemawiki.domain.auth.dto.response.TokenResponse; -import org.daemawiki.domain.auth.usecase.SigninUsecase; -import org.daemawiki.domain.user.application.FindUserPort; +import org.daemawiki.domain.user_auth.dto.request.LoginRequest; +import org.daemawiki.domain.user_auth.dto.response.TokenResponse; +import org.daemawiki.domain.user_auth.usecase.SigninUsecase; +import org.daemawiki.domain.user.port.FindUserPort; import org.daemawiki.domain.user.model.User; import org.daemawiki.exception.h401.PasswordMismatchException; import org.daemawiki.exception.h404.UserNotFoundException; diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/auth/service/SignupService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/service/SignupService.java similarity index 92% rename from daemawiki-service/src/main/java/org/daemawiki/domain/auth/service/SignupService.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/service/SignupService.java index 2e93b563..bbad099e 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/auth/service/SignupService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/service/SignupService.java @@ -1,15 +1,15 @@ -package org.daemawiki.domain.auth.service; +package org.daemawiki.domain.user_auth.service; import org.daemawiki.config.DefaultProfileConfig; import org.daemawiki.domain.admin.application.FindAdminAccountPort; import org.daemawiki.domain.admin.application.SaveAdminAccountPort; -import org.daemawiki.domain.auth.dto.request.SignupRequest; -import org.daemawiki.domain.auth.usecase.SignupUsecase; +import org.daemawiki.domain.user_auth.dto.request.SignupRequest; +import org.daemawiki.domain.user_auth.usecase.SignupUsecase; import org.daemawiki.domain.document.usecase.CreateDocumentUsecase; -import org.daemawiki.domain.mail.application.mail.DeleteAuthMailPort; -import org.daemawiki.domain.mail.application.mail.FindAuthMailPort; -import org.daemawiki.domain.user.application.FindUserPort; -import org.daemawiki.domain.user.application.SaveUserPort; +import org.daemawiki.domain.mail.port.mail.DeleteAuthMailPort; +import org.daemawiki.domain.mail.port.mail.FindAuthMailPort; +import org.daemawiki.domain.user.port.FindUserPort; +import org.daemawiki.domain.user.port.SaveUserPort; import org.daemawiki.domain.user.model.User; import org.daemawiki.domain.user.model.UserDetail; import org.daemawiki.domain.user.model.type.major.MajorType; diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/auth/usecase/ReissueUsecase.java b/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/usecase/ReissueUsecase.java similarity index 51% rename from daemawiki-service/src/main/java/org/daemawiki/domain/auth/usecase/ReissueUsecase.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/usecase/ReissueUsecase.java index 212f05e8..045d6b0d 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/auth/usecase/ReissueUsecase.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/usecase/ReissueUsecase.java @@ -1,6 +1,6 @@ -package org.daemawiki.domain.auth.usecase; +package org.daemawiki.domain.user_auth.usecase; -import org.daemawiki.domain.auth.dto.response.TokenResponse; +import org.daemawiki.domain.user_auth.dto.response.TokenResponse; import reactor.core.publisher.Mono; public interface ReissueUsecase { diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/usecase/SigninUsecase.java b/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/usecase/SigninUsecase.java new file mode 100644 index 00000000..4456353d --- /dev/null +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/usecase/SigninUsecase.java @@ -0,0 +1,10 @@ +package org.daemawiki.domain.user_auth.usecase; + +import org.daemawiki.domain.user_auth.dto.request.LoginRequest; +import org.daemawiki.domain.user_auth.dto.response.TokenResponse; +import reactor.core.publisher.Mono; + +public interface SigninUsecase { + Mono signin(LoginRequest request); + +} diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/auth/usecase/SignupUsecase.java b/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/usecase/SignupUsecase.java similarity index 51% rename from daemawiki-service/src/main/java/org/daemawiki/domain/auth/usecase/SignupUsecase.java rename to daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/usecase/SignupUsecase.java index 1a16f6d2..ddcbc6bd 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/auth/usecase/SignupUsecase.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/usecase/SignupUsecase.java @@ -1,6 +1,6 @@ -package org.daemawiki.domain.auth.usecase; +package org.daemawiki.domain.user_auth.usecase; -import org.daemawiki.domain.auth.dto.request.SignupRequest; +import org.daemawiki.domain.user_auth.dto.request.SignupRequest; import reactor.core.publisher.Mono; public interface SignupUsecase {