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 Feb 13, 2024
1 parent 57a13bc commit 890b55b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,23 @@

import com.example.daemawiki.domain.document.dto.response.GetDocumentResponse;
import com.example.daemawiki.domain.document.service.facade.DocumentFacade;
import com.example.daemawiki.domain.document.service.mapper.DocumentMapper;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

@Service
public class GetDocument {
private final DocumentFacade documentFacade;
private final DocumentMapper documentMapper;

public GetDocument(DocumentFacade documentFacade) {
public GetDocument(DocumentFacade documentFacade, DocumentMapper documentMapper) {
this.documentFacade = documentFacade;
this.documentMapper = documentMapper;
}

public Mono<GetDocumentResponse> execute(String id) {
return documentFacade.findDocumentById(id)
.map(document -> GetDocumentResponse.builder()
.title(document.getTitle())
.type(document.getType())
.dateTime(document.getDateTime())
.groups(document.getGroups())
.editor(document.getEditor())
.content(document.getContent())
.build());
.flatMap(documentMapper::defaultDocumentToGetResponse);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.daemawiki.domain.document.service.mapper;

import com.example.daemawiki.domain.document.dto.response.GetDocumentResponse;
import com.example.daemawiki.domain.document.model.DefaultDocument;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Mono;

@Component
public class DocumentMapper {

public Mono<GetDocumentResponse> defaultDocumentToGetResponse(DefaultDocument document) {
return Mono.justOrEmpty(GetDocumentResponse.builder()
.title(document.getTitle())
.type(document.getType())
.dateTime(document.getDateTime())
.groups(document.getGroups())
.editor(document.getEditor())
.content(document.getContent())
.build());
}

}

0 comments on commit 890b55b

Please sign in to comment.