From 8f9ae328ff10afb198d10acb059a5579ebe3d7e3 Mon Sep 17 00:00:00 2001 From: 101 Date: Fri, 10 May 2024 22:19:31 +0900 Subject: [PATCH] update --- .../document_editor/model/DocumentEditor.java | 10 ++++++--- .../domain/document_info/model/Info.java | 4 ++++ .../org/daemawiki/domain/file/model/File.java | 9 +------- .../domain/file/model/FileDetail.java | 7 +----- .../user/dto/response/UserDetailResponse.java | 22 ------------------- .../user/dto/response/UserDetailVo.java | 16 ++++++++++++++ .../org/daemawiki/domain/user/model/User.java | 22 +++++++++++++++++-- .../domain/user/model/UserDetail.java | 4 +--- .../UpdateDocumentEditorAndUpdatedDate.java | 5 ++--- .../facade/CreateDocumentFacadeImpl.java | 4 ++-- .../service/DeleteDocumentService.java | 2 +- .../service/UpdateDocumentService.java | 2 +- .../service/AddContentTableService.java | 6 ++--- .../service/RemoveContentTableService.java | 2 +- .../UpdateContentTableTitleService.java | 2 +- .../service/WriteContentService.java | 2 +- .../service/UpdateDocumentInfoService.java | 6 ++--- .../service/UploadDocumentImageService.java | 4 ++-- .../service/ChangeUserPasswordService.java | 2 +- .../user/service/UpdateUserService.java | 2 +- .../UploadUserProfileImageService.java | 2 +- .../user_auth/service/SignupService.java | 2 +- 22 files changed, 71 insertions(+), 66 deletions(-) delete mode 100644 daemawiki-domain/src/main/java/org/daemawiki/domain/user/dto/response/UserDetailResponse.java create mode 100644 daemawiki-domain/src/main/java/org/daemawiki/domain/user/dto/response/UserDetailVo.java diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/document_editor/model/DocumentEditor.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_editor/model/DocumentEditor.java index 9100b36d..f1e9f0cf 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/document_editor/model/DocumentEditor.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_editor/model/DocumentEditor.java @@ -2,15 +2,15 @@ import lombok.Builder; import lombok.Getter; -import org.daemawiki.domain.user.dto.response.UserDetailResponse; +import org.daemawiki.domain.user.dto.response.UserDetailVo; import java.util.List; @Getter @Builder public class DocumentEditor { - private final UserDetailResponse createdUser; - private UserDetailResponse updatedUser; + private final UserDetailVo createdUser; + private UserDetailVo updatedUser; private List canEdit; public boolean hasEditPermission(String email) { @@ -18,6 +18,10 @@ public boolean hasEditPermission(String email) { .noneMatch(editor -> editor.user().equals(email)); } + public void updateUpdatedUser(UserDetailVo updatedUser) { + this.updatedUser = updatedUser; + } + public void addEditor(Editor editor) { this.canEdit.add(editor); } diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/document_info/model/Info.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_info/model/Info.java index 7ff6ac9b..3276f78f 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/document_info/model/Info.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/document_info/model/Info.java @@ -15,6 +15,10 @@ public class Info { private List details; + public void updateDocumentImage(File documentImage) { + this.documentImage = documentImage; + } + public void update(String subTitle, List details) { this.subTitle = subTitle; this.details = details; diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/file/model/File.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/file/model/File.java index 7a91e068..0bb70d4b 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/file/model/File.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/file/model/File.java @@ -1,6 +1,5 @@ package org.daemawiki.domain.file.model; -import lombok.Builder; import lombok.Getter; import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.MongoId; @@ -22,7 +21,6 @@ public class File { protected File() {} - @Builder public File(UUID id, String fileName, String fileType, FileDetail detail) { this.id = id; this.fileName = fileName; @@ -31,12 +29,7 @@ public File(UUID id, String fileName, String fileType, FileDetail detail) { } public static File create(UUID id, String fileName, String fileType, FileDetail detail) { - return File.builder() - .id(id) - .fileName(fileName) - .fileType(fileType) - .detail(detail) - .build(); + return new File(id, fileName, fileType, detail); } } diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/file/model/FileDetail.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/file/model/FileDetail.java index 00d8a25e..ad5bb40d 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/file/model/FileDetail.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/file/model/FileDetail.java @@ -1,19 +1,14 @@ package org.daemawiki.domain.file.model; import org.daemawiki.domain.file.model.type.FileType; -import lombok.Builder; -@Builder public record FileDetail( FileType type, String url ) { public static FileDetail create(FileType type, String url) { - return FileDetail.builder() - .type(type) - .url(url) - .build(); + return new FileDetail(type, url); } } diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/user/dto/response/UserDetailResponse.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/user/dto/response/UserDetailResponse.java deleted file mode 100644 index 6d7be4e0..00000000 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/user/dto/response/UserDetailResponse.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.daemawiki.domain.user.dto.response; - -import org.daemawiki.domain.file.model.File; -import org.daemawiki.domain.user.model.User; -import lombok.Builder; - -@Builder -public record UserDetailResponse( - String id, - String name, - File profile -) { - - public static UserDetailResponse create(User user) { - return UserDetailResponse.builder() - .id(user.getId()) - .name(user.getName()) - .profile(user.getProfile()) - .build(); - } - -} diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/user/dto/response/UserDetailVo.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/user/dto/response/UserDetailVo.java new file mode 100644 index 00000000..8d7ea800 --- /dev/null +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/user/dto/response/UserDetailVo.java @@ -0,0 +1,16 @@ +package org.daemawiki.domain.user.dto.response; + +import org.daemawiki.domain.file.model.File; +import org.daemawiki.domain.user.model.User; + +public record UserDetailVo( + String id, + String name, + File profile +) { + + public static UserDetailVo create(User user) { + return new UserDetailVo(user.getId(), user.getName(), user.getProfile()); + } + +} diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/user/model/User.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/user/model/User.java index 4491719b..5b89b0d6 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/user/model/User.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/user/model/User.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Builder; import lombok.Getter; -import lombok.Setter; import org.daemawiki.domain.file.model.File; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.Id; @@ -12,7 +11,6 @@ import java.time.LocalDateTime; @Getter -@Setter @Document public class User { @@ -57,6 +55,26 @@ public void update(String name, UserDetail detail) { this.detail = detail; } + public void updateDocumentId(String documentId) { + this.documentId = documentId; + } + + public void updateProfile(File profile) { + this.profile = profile; + } + + public void setRole(Role role) { + this.role = role; + } + + public void setIsBlocked(Boolean blocked) { + this.isBlocked = blocked; + } + + public void updatePassword(String password) { + this.password = password; + } + public enum Role { USER, ADMIN, diff --git a/daemawiki-domain/src/main/java/org/daemawiki/domain/user/model/UserDetail.java b/daemawiki-domain/src/main/java/org/daemawiki/domain/user/model/UserDetail.java index 2e964f9b..070e2e1c 100644 --- a/daemawiki-domain/src/main/java/org/daemawiki/domain/user/model/UserDetail.java +++ b/daemawiki-domain/src/main/java/org/daemawiki/domain/user/model/UserDetail.java @@ -1,11 +1,9 @@ package org.daemawiki.domain.user.model; -import org.daemawiki.domain.user.model.type.major.MajorType; import lombok.Builder; import lombok.Getter; -import lombok.Setter; +import org.daemawiki.domain.user.model.type.major.MajorType; -@Setter @Getter @Builder public class UserDetail { diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document/component/UpdateDocumentEditorAndUpdatedDate.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document/component/UpdateDocumentEditorAndUpdatedDate.java index eed1c77d..bec958f5 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/document/component/UpdateDocumentEditorAndUpdatedDate.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document/component/UpdateDocumentEditorAndUpdatedDate.java @@ -1,8 +1,7 @@ package org.daemawiki.domain.document.component; import org.daemawiki.domain.document.model.DefaultDocument; -import org.daemawiki.domain.document.component.UpdateDocumentComponent; -import org.daemawiki.domain.user.dto.response.UserDetailResponse; +import org.daemawiki.domain.user.dto.response.UserDetailVo; import org.daemawiki.domain.user.model.User; import org.springframework.stereotype.Component; @@ -13,7 +12,7 @@ public class UpdateDocumentEditorAndUpdatedDate implements UpdateDocumentCompone @Override public void updateEditorAndUpdatedDate(DefaultDocument document, User user) { - document.getEditor().setUpdatedUser(UserDetailResponse.create(user)); + document.getEditor().updateUpdatedUser(UserDetailVo.create(user)); document.getDateTime().setUpdated(LocalDateTime.now()); } 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 ba5ffcc7..5a56d120 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 @@ -9,7 +9,7 @@ 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.dto.response.UserDetailVo; import org.daemawiki.domain.user.model.User; import org.eclipse.collections.api.factory.Lists; import org.springframework.stereotype.Component; @@ -28,7 +28,7 @@ public CreateDocumentFacadeImpl(DefaultProfileConfig defaultProfile) { @Override public Mono create(SaveDocumentRequest request, User user) { - UserDetailResponse userDetail = UserDetailResponse.create(user); + UserDetailVo userDetail = UserDetailVo.create(user); return Mono.just(DefaultDocument.create( request.title(), 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 ee37f990..2c480d43 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 @@ -44,7 +44,7 @@ public Mono delete(String documentId) { private Mono deleteDocument(DefaultDocument document) { return deleteDocumentPort.delete(document) - .then(createRevisionComponent.create(document, RevisionType.DELETE)); + .then(createRevisionComponent.create(document, RevisionType.DELETE, null)); } private Mono getDefaultDocumentMono(Tuple2 tuple) { 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 d39b7c1e..cbf7214f 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 @@ -48,7 +48,7 @@ public Mono update(SaveDocumentRequest request, String documentId) { private Mono saveDocumentAndCreateRevision(DefaultDocument document) { return saveDocumentPort.save(document) - .then(createRevisionComponent.create(document, RevisionType.UPDATE)); + .then(createRevisionComponent.create(document, RevisionType.UPDATE, null)); } private DefaultDocument checkPermissionAndUpdateDocument(Tuple2 tuple, SaveDocumentRequest request) { diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/AddContentTableService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/AddContentTableService.java index da83d911..a2fac40b 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/AddContentTableService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/AddContentTableService.java @@ -11,7 +11,7 @@ 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.dto.response.UserDetailVo; import org.daemawiki.domain.user.model.User; import org.daemawiki.exception.h400.VersionMismatchException; import org.daemawiki.exception.h403.NoEditPermissionUserException; @@ -53,7 +53,7 @@ public Mono add(AddContentRequest request, String documentId) { private Mono saveDocumentAndCreateRevision(DefaultDocument document) { return saveDocumentPort.save(document) - .then(createRevisionComponent.create(document, RevisionType.UPDATE)); + .then(createRevisionComponent.create(document, RevisionType.UPDATE, null)); } private DefaultDocument checkPermissionAndAddDocumentContentTable(Tuple2 tuple, AddContentRequest request) { @@ -108,7 +108,7 @@ private void sortContents(DefaultDocument document) { } private void setDocument(DefaultDocument document, User user) { - document.getEditor().setUpdatedUser(UserDetailResponse.create(user)); + document.getEditor().updateUpdatedUser(UserDetailVo.create(user)); sortContents(document); document.increaseVersion(); } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/RemoveContentTableService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/RemoveContentTableService.java index 93258599..809c2aca 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/RemoveContentTableService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/RemoveContentTableService.java @@ -47,7 +47,7 @@ public Mono remove(DeleteContentRequest request, String documentId) { private Mono saveDocumentAndCreateRevision(DefaultDocument document) { return saveDocumentPort.save(document) - .then(createRevisionComponent.create(document, RevisionType.UPDATE)); + .then(createRevisionComponent.create(document, RevisionType.UPDATE, null)); } private DefaultDocument checkPermissionAndDeleteDocumentContentTable(Tuple2 tuple, DeleteContentRequest request) { diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/UpdateContentTableTitleService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/UpdateContentTableTitleService.java index 1a39dce6..dd52aed5 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/UpdateContentTableTitleService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/UpdateContentTableTitleService.java @@ -53,7 +53,7 @@ public Mono update(EditContentTableTitleRequest request, String documentId private Mono saveDocumentAndCreateRevision(DefaultDocument document) { return saveDocumentPort.save(document) - .then(createRevisionComponent.create(document, RevisionType.UPDATE)); + .then(createRevisionComponent.create(document, RevisionType.UPDATE, null)); } private Mono checkPermissionAndUpdateDocument(Tuple2 tuple, EditContentTableTitleRequest request) { diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/WriteContentService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/WriteContentService.java index 2d8e20da..fc0c7a2b 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/WriteContentService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_content/service/WriteContentService.java @@ -53,7 +53,7 @@ public Mono write(WriteContentRequest request, String documentId) { private Mono saveDocumentAndCreateRevision(DefaultDocument document) { return saveDocumentPort.save(document) - .then(createRevisionComponent.create(document, RevisionType.UPDATE)); + .then(createRevisionComponent.create(document, RevisionType.UPDATE, null)); } private Mono checkPermissionAndWriteContent(Tuple2 tuple, WriteContentRequest request) { diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document_info/service/UpdateDocumentInfoService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_info/service/UpdateDocumentInfoService.java index 71fc1703..63a86b6e 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/document_info/service/UpdateDocumentInfoService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_info/service/UpdateDocumentInfoService.java @@ -10,7 +10,7 @@ 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.dto.response.UserDetailVo; import org.daemawiki.domain.user.model.User; import org.daemawiki.exception.h400.VersionMismatchException; import org.daemawiki.exception.h403.NoEditPermissionUserException; @@ -55,11 +55,11 @@ private Mono checkPermissionAndUpdateDocument(Tuple2 details) { - document.getEditor().setUpdatedUser(UserDetailResponse.create(user)); + document.getEditor().updateUpdatedUser(UserDetailVo.create(user)); document.getInfo().update(subTitle, details); document.increaseVersion(); } diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/document_info/service/UploadDocumentImageService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/document_info/service/UploadDocumentImageService.java index 869cbf1f..ba3d1cae 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/document_info/service/UploadDocumentImageService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/document_info/service/UploadDocumentImageService.java @@ -48,10 +48,10 @@ private Mono updateDocument(Tuple2 tuple) { DefaultDocument document = tuple.getT1(); File file = tuple.getT2(); - document.getInfo().setDocumentImage(file); + document.getInfo().updateDocumentImage(file); return saveDocumentPort.save(document) - .then(createRevisionComponent.create(document, RevisionType.UPDATE)); + .then(createRevisionComponent.create(document, RevisionType.UPDATE, null)); } private DefaultDocument checkPermission(Tuple2 tuple) { 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 cdb2de59..f7de86ff 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 @@ -50,7 +50,7 @@ public Mono nonLoggedInUser(ChangePasswordRequest request) { private Mono changePasswordAndSaveUser(String newPassword, User user) { return encodePassword(newPassword) .flatMap(password -> { - user.setPassword(password); + user.updatePassword(password); return saveUserPort.save(user); }) .onErrorMap(e -> ExecuteFailedException.EXCEPTION) 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 58756d73..bfab3204 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 @@ -48,7 +48,7 @@ private Mono updateUserDocument(User user) { private Mono saveDocumentAndCreateRevision(DefaultDocument document) { return saveDocumentPort.save(document) - .then(createRevisionComponent.create(document, RevisionType.UPDATE)); + .then(createRevisionComponent.create(document, RevisionType.UPDATE, null)); } private void setDocumentForUpdateUser(DefaultDocument document, User user) { 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 87fdc86c..20283315 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 @@ -28,7 +28,7 @@ public UploadUserProfileImageService(FindUserPort findUserPort, S3UploadObjectIm public Mono upload(FilePart filePart) { return findUserPort.currentUser() .zipWith(s3UploadObject.uploadObject(filePart, FileType.PROFILE.toString()), (user, file) -> { - user.setProfile(file); + user.updateProfile(file); return user; }) .flatMap(saveUserPort::save) diff --git a/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/service/SignupService.java b/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/service/SignupService.java index bbad099e..33c8a66b 100644 --- a/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/service/SignupService.java +++ b/daemawiki-service/src/main/java/org/daemawiki/domain/user_auth/service/SignupService.java @@ -82,7 +82,7 @@ private Mono saveUserAndCreateDocument(User user) { private Mono createDocumentAndUpdateUser(User savedUser) { return createDocumentUsecase.createByUser(savedUser) - .doOnNext(document -> savedUser.setDocumentId(document.getId())) + .doOnNext(document -> savedUser.updateDocumentId(document.getId())) .flatMap(document -> saveUser(savedUser)) .flatMap(this::updateAdminAccount); }