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

update #10

Merged
merged 4 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import org.daemawiki.domain.document.usecase.DeleteDocumentUsecase;
import org.daemawiki.domain.document.usecase.GetDocumentUsecase;
import org.daemawiki.domain.document.usecase.UpdateDocumentUsecase;
import org.daemawiki.domain.info.dto.UpdateInfoRequest;
import org.daemawiki.domain.info.usecase.UpdateDocumentInfoUsecase;
import org.daemawiki.domain.info.usecase.UploadDocumentImageUsecase;
import org.daemawiki.domain.document_info.dto.UpdateInfoRequest;
import org.daemawiki.domain.document_info.usecase.UpdateDocumentInfoUsecase;
import org.daemawiki.domain.document_info.usecase.UploadDocumentImageUsecase;
import org.daemawiki.utils.PagingInfo;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
Expand Down Expand Up @@ -76,7 +76,7 @@ public Flux<DocumentSearchResult> searchDocumentTitle(
@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "10") Integer size
) {
return getDocumentUsecase.searchDocumentTitle(text, PagingInfo.of(sortBy, sortDirection, page, size));
return getDocumentUsecase.searchDocumentsByTitle(text, PagingInfo.of(sortBy, sortDirection, page, size));
}

@GetMapping("/search/content")
Expand All @@ -87,7 +87,7 @@ public Flux<DocumentSearchResult> searchDocumentContent(
@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "10") Integer size
) {
return getDocumentUsecase.searchDocumentContent(text, PagingInfo.of(sortBy, sortDirection, page, size));
return getDocumentUsecase.searchDocumentsByContent(text, PagingInfo.of(sortBy, sortDirection, page, size));
}

@GetMapping("/most-revision")
Expand All @@ -97,7 +97,7 @@ public Flux<SimpleDocumentResponse> getDocumentsOrderByVersion(
@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "10") Integer size
) {
return getDocumentUsecase.getDocumentsMostRevision(PagingInfo.of(sortBy, sortDirection, page, size));
return getDocumentUsecase.getDocumentsSortByMostRevision(PagingInfo.of(sortBy, sortDirection, page, size));
}

@GetMapping("/most-view")
Expand All @@ -107,7 +107,7 @@ public Flux<GetMostViewDocumentResponse> getDocumentsOrderByView(
@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "10") Integer size
) {
return getDocumentUsecase.getDocumentOrderByView(PagingInfo.of(sortBy, sortDirection, page, size));
return getDocumentUsecase.getDocumentsSortByView(PagingInfo.of(sortBy, sortDirection, page, size));
}

@DeleteMapping("/{documentId}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package org.daemawiki.domain.content.api;

import org.daemawiki.domain.content.dto.AddContentRequest;
import org.daemawiki.domain.content.dto.DeleteContentRequest;
import org.daemawiki.domain.content.dto.EditContentTableTitleRequest;
import org.daemawiki.domain.content.dto.WriteContentRequest;
import org.daemawiki.domain.content.usecase.AddContentTableUsecase;
import org.daemawiki.domain.content.usecase.RemoveContentTableUsecase;
import org.daemawiki.domain.content.usecase.UpdateContentTableTitleUsecase;
import org.daemawiki.domain.content.usecase.WriteContentUsecase;
import org.daemawiki.domain.content.service.AddContentTableService;
import org.daemawiki.domain.content.service.RemoveContentTableService;
import org.daemawiki.domain.content.service.UpdateContentTableTitleService;
import org.daemawiki.domain.content.service.WriteContentService;
package org.daemawiki.domain.document_content.api;

import org.daemawiki.domain.document_content.dto.AddContentRequest;
import org.daemawiki.domain.document_content.dto.DeleteContentRequest;
import org.daemawiki.domain.document_content.dto.EditContentTableTitleRequest;
import org.daemawiki.domain.document_content.dto.WriteContentRequest;
import org.daemawiki.domain.document_content.usecase.AddContentTableUsecase;
import org.daemawiki.domain.document_content.usecase.RemoveContentTableUsecase;
import org.daemawiki.domain.document_content.usecase.UpdateContentTableTitleUsecase;
import org.daemawiki.domain.document_content.usecase.WriteContentUsecase;
import org.daemawiki.domain.document_content.service.AddContentTableService;
import org.daemawiki.domain.document_content.service.RemoveContentTableService;
import org.daemawiki.domain.document_content.service.UpdateContentTableTitleService;
import org.daemawiki.domain.document_content.service.WriteContentService;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import org.springframework.http.HttpStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.daemawiki.domain.editor.api;
package org.daemawiki.domain.document_editor.api;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import org.daemawiki.domain.editor.dto.AddEditorRequest;
import org.daemawiki.domain.editor.dto.DeleteEditorRequest;
import org.daemawiki.domain.editor.usecase.AddDocumentEditorUsecase;
import org.daemawiki.domain.editor.usecase.RemoveDocumentEditorUsecase;
import org.daemawiki.domain.document_editor.dto.AddEditorRequest;
import org.daemawiki.domain.document_editor.dto.DeleteEditorRequest;
import org.daemawiki.domain.document_editor.usecase.AddDocumentEditorUsecase;
import org.daemawiki.domain.document_editor.usecase.RemoveDocumentEditorUsecase;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.daemawiki.domain.revision.api;
package org.daemawiki.domain.document_revision.api;

import org.daemawiki.domain.document.dto.response.SimpleDocumentResponse;
import org.daemawiki.domain.revision.dto.response.GetRevisionByUserResponse;
import org.daemawiki.domain.revision.model.RevisionHistory;
import org.daemawiki.domain.revision.usecase.GetRevisionUsecase;
import org.daemawiki.domain.document_revision.dto.response.GetRevisionByUserResponse;
import org.daemawiki.domain.document_revision.model.RevisionHistory;
import org.daemawiki.domain.document_revision.usecase.GetRevisionUsecase;
import org.daemawiki.utils.PagingInfo;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.daemawiki.domain.auth.api;
package org.daemawiki.domain.user_auth.api;

import jakarta.validation.Valid;
import org.daemawiki.domain.auth.dto.request.LoginRequest;
import org.daemawiki.domain.auth.dto.request.SignupRequest;
import org.daemawiki.domain.auth.dto.response.TokenResponse;
import org.daemawiki.domain.auth.usecase.ReissueUsecase;
import org.daemawiki.domain.auth.usecase.SigninUsecase;
import org.daemawiki.domain.auth.usecase.SignupUsecase;
import org.daemawiki.domain.user_auth.dto.request.LoginRequest;
import org.daemawiki.domain.user_auth.dto.request.SignupRequest;
import org.daemawiki.domain.user_auth.dto.response.TokenResponse;
import org.daemawiki.domain.user_auth.usecase.ReissueUsecase;
import org.daemawiki.domain.user_auth.usecase.SigninUsecase;
import org.daemawiki.domain.user_auth.usecase.SignupUsecase;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;
Expand Down
3 changes: 2 additions & 1 deletion daemawiki-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ spring:
mongodb:
uri: ${MONGO_URI}
database: ${MONGO_DB}
auto-index-creation: true

redis:
host: ${REDIS_HOST}
Expand Down Expand Up @@ -35,7 +36,7 @@ daemawiki:
secret: ${SEC_SECRET}
issuer: ${SEC_ISSUER}
expiration: ${SEC_EXPIRATION}

profile:
image:
url: ${DEFAULT_PROFILE_IMAGE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.jsonwebtoken.*;
import org.daemawiki.config.SecurityProperties;
import org.daemawiki.domain.user.application.FindUserPort;
import org.daemawiki.domain.user.port.FindUserPort;
import org.daemawiki.exception.h400.InvalidTokenException;
import org.daemawiki.exception.h404.UserNotFoundException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.daemawiki.domain.article.model;

import lombok.Builder;
import lombok.Getter;
import org.daemawiki.domain.user.model.Writer;
import org.springframework.data.annotation.CreatedDate;
Expand All @@ -14,32 +15,39 @@ public class Article {

@Id
private String id;

private String title;

private String content;

private Writer writer;

@CreatedDate
private LocalDateTime createdAt;
private Long recommend = 0L;
private Long view = 0L;

public void increaseView() {
view++;
}
private Long recommend = 0L;

public void increaseRecommend() {
recommend++;
}
private Long view = 0L;

protected Article() {}

protected Article(String title, String content, Writer writer) {
@Builder
public Article(String title, String content, Writer writer) {
this.title = title;
this.content = content;
this.writer = writer;
}

public static Article create(String title, String content, Writer writer) {
public static Article of(String title, String content, Writer writer) {
return new Article(title, content, writer);
}

public void increaseView() {
view++;
}

public void increaseRecommend() {
recommend++;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.daemawiki.domain.article_comment.model;

import org.daemawiki.domain.user.model.Writer;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.time.LocalDateTime;

@Document
public class ArticleComment {

@Id
private String id;

private String content;

private Writer writer;

@CreatedDate
private LocalDateTime createdAt;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package org.daemawiki.domain.document.adapter;

import org.daemawiki.domain.document.model.DefaultDocument;
import org.daemawiki.domain.document.model.DocumentSearchResult;
import org.daemawiki.domain.document.port.DeleteDocumentPort;
import org.daemawiki.domain.document.port.FindDocumentPort;
import org.daemawiki.domain.document.port.SaveDocumentPort;
import org.daemawiki.domain.document.repository.DocumentRepository;
import org.daemawiki.utils.PagingInfo;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@Component
public class DocumentAdapter implements SaveDocumentPort, FindDocumentPort, DeleteDocumentPort {
private final DocumentRepository documentRepository;

public DocumentAdapter(DocumentRepository documentRepository) {
this.documentRepository = documentRepository;
}

@Override
public Mono<DefaultDocument> findById(String id) {
return documentRepository.findById(id);
}

@Override
public Mono<DefaultDocument> findRandom() {
return documentRepository.findRandomDocument();
}

@Override
public Flux<DocumentSearchResult> search(String text, PagingInfo pagingInfo) {
return documentRepository.findByTextContaining(
text,
pagingInfo.sortBy(),
pagingInfo.sortDirection(),
pagingInfo.page() * pagingInfo.size(),
pagingInfo.size()
);
}

@Override
public Flux<DefaultDocument> searchByTitle(String text, PagingInfo pagingInfo) {
return documentRepository.findByTitleContaining(
text,
pagingInfo.sortBy(),
pagingInfo.sortDirection(),
pagingInfo.page() * pagingInfo.size(),
pagingInfo.size());
}

@Override
public Flux<DocumentSearchResult> searchByContent(String text, PagingInfo pagingInfo) {
return documentRepository.findByContentTextContaining(
text,
pagingInfo.sortBy(),
pagingInfo.sortDirection(),
pagingInfo.page() * pagingInfo.size(),
pagingInfo.size()
);
}

public Flux<DefaultDocument> findAllSortByMostRevision(PagingInfo pagingInfo) {
return documentRepository.findAllByOrderByVersion(
pagingInfo.sortDirection(),
pagingInfo.page() * pagingInfo.size(),
pagingInfo.size()
);
}

@Override
public Flux<DefaultDocument> findAllSortByView(PagingInfo pagingInfo) {
return documentRepository.findAllByOrderByView(
pagingInfo.sortDirection(),
pagingInfo.page() * pagingInfo.size(),
pagingInfo.size()
);
}

@Override
public Mono<DefaultDocument> save(DefaultDocument document) {
return documentRepository.save(document);
}

@Override
public Mono<DefaultDocument> increaseView(DefaultDocument document) {
return documentRepository.increaseView(document);
}

@Override
public Mono<Void> deleteById(String id) {
return documentRepository.deleteById(id);
}

@Override
public Mono<Void> delete(DefaultDocument document) {
return documentRepository.delete(document);
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package org.daemawiki.domain.document.dto.request;

import org.daemawiki.domain.content.model.Content;
import jakarta.annotation.Nullable;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import org.daemawiki.domain.document_content.model.Content;
import org.daemawiki.domain.document_revision.model.RevisionDetail;

import java.util.List;

Expand All @@ -19,7 +20,9 @@ public record SaveDocumentRequest(
@NotNull(message = "문서의 분류가 비어있습니다.")
List<List<String>> groups,
@Nullable
Long version
Long version,
@Nullable // TODO: 5/7/24 수정 내역 필드
List<RevisionDetail> data
) {

public static SaveDocumentRequest create(String title, String type, List<List<String>> groups) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.daemawiki.domain.document.dto.response;

import org.daemawiki.datetime.model.EditDateTime;
import org.daemawiki.domain.content.model.Content;
import org.daemawiki.domain.document_content.model.Content;
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.info.model.Info;
import org.daemawiki.domain.document_editor.model.DocumentEditor;
import org.daemawiki.domain.document_info.model.Info;
import lombok.Builder;

import java.util.List;
Expand Down
Loading
Loading