From 4e3525ef1aa5d74b1f81c6f847d529900d080e3f Mon Sep 17 00:00:00 2001 From: 101 Date: Sun, 24 Mar 2024 22:26:30 +0900 Subject: [PATCH] refactor CreateDocumentFacadeImpl.java --- .../domain/auth/type/GetDocumentType.java | 22 ------------------- .../facade/CreateDocumentFacadeImpl.java | 8 +++---- 2 files changed, 3 insertions(+), 27 deletions(-) delete mode 100644 daemawiki-api/src/main/java/org/daemawiki/domain/auth/type/GetDocumentType.java diff --git a/daemawiki-api/src/main/java/org/daemawiki/domain/auth/type/GetDocumentType.java b/daemawiki-api/src/main/java/org/daemawiki/domain/auth/type/GetDocumentType.java deleted file mode 100644 index 4ea2e2a1..00000000 --- a/daemawiki-api/src/main/java/org/daemawiki/domain/auth/type/GetDocumentType.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.daemawiki.domain.auth.type; - -import org.daemawiki.domain.document.model.type.DocumentType; -import org.springframework.stereotype.Component; - -@Component -public class GetDocumentType { - - public DocumentType execute(String type) { - return switch (type) { - case "student" -> DocumentType.STUDENT; - case "teacher" -> DocumentType.TEACHER; - case "club" -> DocumentType.CLUB; - case "gen" -> DocumentType.GEN; - case "major" -> DocumentType.MAJOR; - case "main" -> DocumentType.MAIN; - - case null, default -> DocumentType.DEFAULT; - }; - } - -} diff --git a/daemawiki-api/src/main/java/org/daemawiki/domain/document/component/facade/CreateDocumentFacadeImpl.java b/daemawiki-api/src/main/java/org/daemawiki/domain/document/component/facade/CreateDocumentFacadeImpl.java index 0e437c12..c33e785e 100644 --- a/daemawiki-api/src/main/java/org/daemawiki/domain/document/component/facade/CreateDocumentFacadeImpl.java +++ b/daemawiki-api/src/main/java/org/daemawiki/domain/document/component/facade/CreateDocumentFacadeImpl.java @@ -1,11 +1,11 @@ package org.daemawiki.domain.document.component.facade; import org.daemawiki.datetime.model.EditDateTime; -import org.daemawiki.domain.auth.type.GetDocumentType; import org.daemawiki.domain.common.DefaultProfile; import org.daemawiki.domain.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; @@ -20,11 +20,9 @@ @Component public class CreateDocumentFacadeImpl implements CreateDocumentFacade{ - private final GetDocumentType getDocumentType; private final DefaultProfile defaultProfile; - public CreateDocumentFacadeImpl(GetDocumentType getDocumentType, DefaultProfile defaultProfile) { - this.getDocumentType = getDocumentType; + public CreateDocumentFacadeImpl(DefaultProfile defaultProfile) { this.defaultProfile = defaultProfile; } @@ -34,7 +32,7 @@ public Mono create(SaveDocumentRequest request, User user) { return Mono.just(DefaultDocument.builder() .title(request.title()) - .type(getDocumentType.execute(request.type().toLowerCase())) + .type(DocumentType.valueOf(request.type().toUpperCase())) .dateTime(EditDateTime.builder() .created(LocalDateTime.now()) .updated(LocalDateTime.now())