Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
ori0o0p committed Mar 5, 2024
1 parent 22c6dfd commit f0356cc
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.Objects;

@Component
public class Commons {
public class UserFilter {

public void userPermissionAndDocumentVersionCheck(DefaultDocument document, String userEmail, Integer requestVersion) {
if (document.getEditor().hasEditPermission(userEmail)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.daemawiki.domain.content.service;

import com.example.daemawiki.domain.common.Commons;
import com.example.daemawiki.domain.common.UserFilter;
import com.example.daemawiki.domain.content.dto.AddContentRequest;
import com.example.daemawiki.domain.content.model.Content;
import com.example.daemawiki.domain.document.component.facade.DocumentFacade;
Expand All @@ -25,19 +25,19 @@ public class AddContentTable {
private final DocumentFacade documentFacade;
private final RevisionComponent revisionComponent;
private final UserFacade userFacade;
private final Commons commons;
private final UserFilter userFilter;

public AddContentTable(DocumentFacade documentFacade, RevisionComponent revisionComponent, UserFacade userFacade, Commons commons) {
public AddContentTable(DocumentFacade documentFacade, RevisionComponent revisionComponent, UserFacade userFacade, UserFilter userFilter) {
this.documentFacade = documentFacade;
this.revisionComponent = revisionComponent;
this.userFacade = userFacade;
this.commons = commons;
this.userFilter = userFilter;
}

public Mono<Void> execute(AddContentRequest request, String documentId) {
return userFacade.currentUser()
.zipWith(documentFacade.findDocumentById(documentId), (user, document) -> {
commons.userPermissionAndDocumentVersionCheck(document, user.getEmail(), request.version());
userFilter.userPermissionAndDocumentVersionCheck(document, user.getEmail(), request.version());

return Tuples.of(document, user);
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.daemawiki.domain.content.service;

import com.example.daemawiki.domain.common.Commons;
import com.example.daemawiki.domain.common.UserFilter;
import com.example.daemawiki.domain.content.dto.DeleteContentRequest;
import com.example.daemawiki.domain.document.component.facade.DocumentFacade;
import com.example.daemawiki.domain.revision.component.RevisionComponent;
Expand All @@ -18,19 +18,19 @@ public class DeleteContent {
private final DocumentFacade documentFacade;
private final RevisionComponent revisionComponent;
private final UserFacade userFacade;
private final Commons commons;
private final UserFilter userFilter;

public DeleteContent(DocumentFacade documentFacade, RevisionComponent revisionComponent, UserFacade userFacade, Commons commons) {
public DeleteContent(DocumentFacade documentFacade, RevisionComponent revisionComponent, UserFacade userFacade, UserFilter userFilter) {
this.documentFacade = documentFacade;
this.revisionComponent = revisionComponent;
this.userFacade = userFacade;
this.commons = commons;
this.userFilter = userFilter;
}

public Mono<Void> execute(DeleteContentRequest request, String documentId) {
return userFacade.currentUser()
.zipWith(documentFacade.findDocumentById(documentId), (user, document) -> {
commons.userPermissionAndDocumentVersionCheck(document, user.getEmail(), request.version());
userFilter.userPermissionAndDocumentVersionCheck(document, user.getEmail(), request.version());
return document;
})
.flatMap(document -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.daemawiki.domain.content.service;

import com.example.daemawiki.domain.common.Commons;
import com.example.daemawiki.domain.common.UserFilter;
import com.example.daemawiki.domain.content.dto.EditContentTableTitleRequest;
import com.example.daemawiki.domain.document.component.facade.DocumentFacade;
import com.example.daemawiki.domain.revision.component.RevisionComponent;
Expand All @@ -15,19 +15,19 @@ public class EditContentTableTitle {
private final DocumentFacade documentFacade;
private final RevisionComponent revisionComponent;
private final UserFacade userFacade;
private final Commons commons;
private final UserFilter userFilter;

public EditContentTableTitle(DocumentFacade documentFacade, RevisionComponent revisionComponent, UserFacade userFacade, Commons commons) {
public EditContentTableTitle(DocumentFacade documentFacade, RevisionComponent revisionComponent, UserFacade userFacade, UserFilter userFilter) {
this.documentFacade = documentFacade;
this.revisionComponent = revisionComponent;
this.userFacade = userFacade;
this.commons = commons;
this.userFilter = userFilter;
}

public Mono<Void> execute(EditContentTableTitleRequest request, String documentId) {
return userFacade.currentUser()
.zipWith(documentFacade.findDocumentById(documentId), (user, document) -> {
commons.userPermissionAndDocumentVersionCheck(document, user.getEmail(), request.version());
userFilter.userPermissionAndDocumentVersionCheck(document, user.getEmail(), request.version());
return document;
})
.map(document -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.daemawiki.domain.content.service;

import com.example.daemawiki.domain.common.Commons;
import com.example.daemawiki.domain.common.UserFilter;
import com.example.daemawiki.domain.content.dto.WriteContentRequest;
import com.example.daemawiki.domain.content.model.Content;
import com.example.daemawiki.domain.document.component.facade.DocumentFacade;
Expand Down Expand Up @@ -28,19 +28,19 @@ public class WriteContent {
private final DocumentFacade documentFacade;
private final RevisionComponent revisionComponent;
private final UserFacade userFacade;
private final Commons commons;
private final UserFilter userFilter;

public WriteContent(DocumentFacade documentFacade, RevisionComponent revisionComponent, UserFacade userFacade, Commons commons) {
public WriteContent(DocumentFacade documentFacade, RevisionComponent revisionComponent, UserFacade userFacade, UserFilter userFilter) {
this.documentFacade = documentFacade;
this.revisionComponent = revisionComponent;
this.userFacade = userFacade;
this.commons = commons;
this.userFilter = userFilter;
}

public Mono<Void> execute(WriteContentRequest request, String documentId) {
return userFacade.currentUser()
.zipWith(documentFacade.findDocumentById(documentId), (user, document) -> {
commons.userPermissionAndDocumentVersionCheck(document, user.getEmail(), request.version());
userFilter.userPermissionAndDocumentVersionCheck(document, user.getEmail(), request.version());
return Tuples.of(user, document);
})
.flatMap(tuple -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.daemawiki.domain.document.component.service;

import com.example.daemawiki.domain.common.Commons;
import com.example.daemawiki.domain.common.UserFilter;
import com.example.daemawiki.domain.document.component.facade.DocumentFacade;
import com.example.daemawiki.domain.document.dto.request.SaveDocumentRequest;
import com.example.daemawiki.domain.document.model.type.service.GetDocumentType;
Expand All @@ -21,20 +21,20 @@ public class UpdateDocument {
private final UserFacade userFacade;
private final GetDocumentType getDocumentType;
private final RevisionComponent revisionComponent;
private final Commons commons;
private final UserFilter userFilter;

public UpdateDocument(DocumentFacade documentFacade, UserFacade userFacade, GetDocumentType getDocumentType, RevisionComponent revisionComponent, Commons commons) {
public UpdateDocument(DocumentFacade documentFacade, UserFacade userFacade, GetDocumentType getDocumentType, RevisionComponent revisionComponent, UserFilter userFilter) {
this.documentFacade = documentFacade;
this.userFacade = userFacade;
this.getDocumentType = getDocumentType;
this.revisionComponent = revisionComponent;
this.commons = commons;
this.userFilter = userFilter;
}

public Mono<Void> execute(SaveDocumentRequest request, String documentId) {
return userFacade.currentUser()
.zipWith(documentFacade.findDocumentById(documentId), (user, document) -> {
commons.userPermissionAndDocumentVersionCheck(document, user.getEmail(), request.version());
userFilter.userPermissionAndDocumentVersionCheck(document, user.getEmail(), request.version());

document.getEditor().setUpdatedUser(UserDetailResponse.builder()
.id(user.getId())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.daemawiki.domain.info.service;

import com.example.daemawiki.domain.common.Commons;
import com.example.daemawiki.domain.common.UserFilter;
import com.example.daemawiki.domain.document.component.facade.DocumentFacade;
import com.example.daemawiki.domain.document.model.DefaultDocument;
import com.example.daemawiki.domain.document.repository.DocumentRepository;
Expand All @@ -24,20 +24,20 @@ public class UpdateInfo {
private final DocumentRepository documentRepository;
private final RevisionComponent revisionComponent;
private final UserFacade userFacade;
private final Commons commons;
private final UserFilter userFilter;

public UpdateInfo(DocumentFacade documentFacade, DocumentRepository documentRepository, RevisionComponent revisionComponent, UserFacade userFacade, Commons commons) {
public UpdateInfo(DocumentFacade documentFacade, DocumentRepository documentRepository, RevisionComponent revisionComponent, UserFacade userFacade, UserFilter userFilter) {
this.documentFacade = documentFacade;
this.documentRepository = documentRepository;
this.revisionComponent = revisionComponent;
this.userFacade = userFacade;
this.commons = commons;
this.userFilter = userFilter;
}

public Mono<Void> execute(UpdateInfoRequest request) {
return userFacade.currentUser()
.zipWith(documentFacade.findDocumentById(request.documentId()), (user, document) -> {
commons.userPermissionAndDocumentVersionCheck(document, user.getEmail(), request.version());
userFilter.userPermissionAndDocumentVersionCheck(document, user.getEmail(), request.version());

return Tuples.of(document, user);
})
Expand Down

0 comments on commit f0356cc

Please sign in to comment.