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

Commit

Permalink
refactor ::
Browse files Browse the repository at this point in the history
  • Loading branch information
ori0o0p committed May 8, 2024
1 parent ce239f3 commit 6e002db
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ public class ArticleComment {

@Id
private String id;

private String content;

private Writer writer;

@CreatedDate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
package org.daemawiki.domain.document_content.model;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Builder
public class Content {

private String index;

private String title;

private String detail;

public static Content create(String index, String title, String detail) {
return Content.builder()
.index(index)
.title(title)
.detail(detail)
.build();
public void changeTitle(String title) {
this.title = title;
}

public void changeDetail(String detail) {
this.detail = detail;
}

private Content(String index, String title, String detail) {
this.index = index;
this.title = title;
this.detail = detail;
}

public static Content of(String index, String title, String detail) {
return new Content(index, title, detail);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
@Setter
@Builder
public class DocumentEditor {

private final UserDetailResponse createdUser;

private UserDetailResponse updatedUser;

private List<Editor> canEdit;

public boolean hasEditPermission(String email) {
return this.canEdit.stream().noneMatch(editor -> editor.user().equals(email));
return this.canEdit.stream()
.noneMatch(editor -> editor.user().equals(email));
}

public void addEditor(Editor editor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Mono<DefaultDocument> create(SaveDocumentRequest request, User user) {
.updatedUser(userDetail)
.canEdit(Collections.singletonList(Editor.create(user.getEmail(), user.getId())))
.build(),
Lists.mutable.of(Content.create("1", "개요", ""))
Lists.mutable.of(Content.of("1", "개요", ""))
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void setDocumentContent(DefaultDocument document, String index, String t
}

private Content createContent(String index, String title) {
return Content.create(index, title, "빈 내용");
return Content.of(index, title, "빈 내용");
}

private static final Comparator<Content> customComparator = (c1, c2) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private Mono<DefaultDocument> checkPermissionAndUpdateDocument(Tuple2<User, Defa
return Mono.error(ContentNotFoundException.EXCEPTION);
}

content.setTitle(request.newTitle());
content.changeTitle(request.newTitle());

document.increaseVersion();
updateDocumentComponent.updateEditorAndUpdatedDate(document, user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private Mono<DefaultDocument> checkPermissionAndWriteContent(Tuple2<User, Defaul
}

Content content = contentsMap.get(request.index());
content.setDetail(request.content());
content.changeDetail(request.content());
setDocument(document, user);

return Mono.just(document);
Expand Down

0 comments on commit 6e002db

Please sign in to comment.