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

Commit

Permalink
update ::
Browse files Browse the repository at this point in the history
페이지네이션 구현
  • Loading branch information
ori0o0p committed Apr 19, 2024
1 parent f071334 commit 5e4bad9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.daemawiki.domain.info.dto.UpdateInfoRequest;
import org.daemawiki.domain.info.usecase.UpdateDocumentInfoUsecase;
import org.daemawiki.domain.info.usecase.UploadDocumentImageUsecase;
import org.daemawiki.utils.PagingInfo;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.codec.multipart.FilePart;
Expand Down Expand Up @@ -57,18 +58,36 @@ public Mono<GetDocumentResponse> getDocumentByRandom() {
}

@GetMapping("/search")
public Flux<DocumentSearchResult> searchDocument(@NotBlank @RequestParam("text") String text, @RequestParam("lastDocument") String lastDocument) {
return getDocumentUsecase.searchDocument(text, lastDocument);
public Flux<DocumentSearchResult> searchDocument(
@RequestParam("text") String text,
@RequestParam(defaultValue = "dateTime.created") String sortBy,
@RequestParam(defaultValue = "1") Integer sortDirection,
@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "10") Integer size
) {
return getDocumentUsecase.searchDocument(text, PagingInfo.of(sortBy, sortDirection, page, size));
}

@GetMapping("/search/title")
public Flux<DocumentSearchResult> searchDocumentTitle(@NotBlank @RequestParam("text") String text, @RequestParam("lastDocument") String lastDocument) {
return getDocumentUsecase.searchDocumentTitle(text, lastDocument);
public Flux<DocumentSearchResult> searchDocumentTitle(
@RequestParam("text") String text,
@RequestParam(defaultValue = "dateTime.created") String sortBy,
@RequestParam(defaultValue = "1") Integer sortDirection,
@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "10") Integer size
) {
return getDocumentUsecase.searchDocumentTitle(text, PagingInfo.of(sortBy, sortDirection, page, size));
}

@GetMapping("/search/content")
public Flux<DocumentSearchResult> searchDocumentContent(@NotBlank @RequestParam("text") String text, @RequestParam("lastDocument") String lastDocument) {
return getDocumentUsecase.searchDocumentContent(text, lastDocument);
public Flux<DocumentSearchResult> searchDocumentContent(
@RequestParam("text") String text,
@RequestParam(defaultValue = "dateTime.created") String sortBy,
@RequestParam(defaultValue = "1") Integer sortDirection,
@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "10") Integer size
) {
return getDocumentUsecase.searchDocumentContent(text, PagingInfo.of(sortBy, sortDirection, page, size));
}

@GetMapping("/most-revision/top-10")
Expand All @@ -77,13 +96,17 @@ public Flux<SimpleDocumentResponse> getDocumentsOrderByVersionTop10() {
}

@GetMapping("/most-revision")
public Flux<SimpleDocumentResponse> getDocumentsOrderByVersion(@RequestParam("lastDocument") String lastDocument) {
return getDocumentUsecase.getDocumentsMostRevision(lastDocument);
public Flux<SimpleDocumentResponse> getDocumentsOrderByVersion(
@RequestBody PagingInfo pagingInfo
) {
return getDocumentUsecase.getDocumentsMostRevision(pagingInfo);
}

@GetMapping("/most-view")
public Flux<GetMostViewDocumentResponse> getDocumentsOrderByView(@RequestParam("lastDocument") String lastDocument) {
return getDocumentUsecase.getDocumentOrderByView(lastDocument);
public Flux<GetMostViewDocumentResponse> getDocumentsOrderByView(
@RequestBody PagingInfo pagingInfo
) {
return getDocumentUsecase.getDocumentOrderByView(pagingInfo);
}

@GetMapping("/most-view/top-10")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package org.daemawiki.domain.revision.api;

import jakarta.validation.constraints.NotBlank;
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.utils.PagingInfo;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

import java.util.List;

@RestController
@RequestMapping("/api")
public class RevisionHistoryController {
Expand All @@ -18,23 +20,46 @@ public RevisionHistoryController(GetRevisionUsecase getRevisionUsecase) {
}

@GetMapping("/revisions")
public Flux<RevisionHistory> getRevisionToPage(@RequestParam("lastRevision") String lastRevision) {
return getRevisionUsecase.getAllRevisionPaging(lastRevision);
public Flux<RevisionHistory> getRevisionToPage(
@RequestParam(defaultValue = "createdDateTime") String sortBy,
@RequestParam(defaultValue = "1") Integer sortDirection,
@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "10") Integer size
) {
return getRevisionUsecase.getAllRevisionPaging(PagingInfo.of(sortBy, sortDirection, page, size));
}

@GetMapping("/documents/revisions/top-10")
public Flux<SimpleDocumentResponse> getRevisionTop10ByUpdatedDate() {
return getRevisionUsecase.getUpdatedTop10Revision();
@GetMapping("/documents/revisions")
public Flux<SimpleDocumentResponse> getRevisionOrderByUpdatedDate(
@RequestParam List<String> types,
@RequestParam(defaultValue = "createdDateTime") String sortBy,
@RequestParam(defaultValue = "1") Integer sortDirection,
@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "10") Integer size
) {
return getRevisionUsecase.getRevisionOrderByUpdated(types, PagingInfo.of(sortBy, sortDirection, page, size));
}

@GetMapping("/documents/{documentId}/revisions")
public Flux<RevisionHistory> getRevisionByDocument(@NotBlank @PathVariable String documentId, @RequestParam("lastRevision") String lastRevision) {
return getRevisionUsecase.getAllRevisionByDocument(documentId, lastRevision);
public Flux<RevisionHistory> getRevisionByDocument(
@PathVariable String documentId,
@RequestParam(defaultValue = "createdDateTime") String sortBy,
@RequestParam(defaultValue = "1") Integer sortDirection,
@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "10") Integer size
) {
return getRevisionUsecase.getAllRevisionByDocument(documentId, PagingInfo.of(sortBy, sortDirection, page, size));
}

@GetMapping("/users/{userId}/revisions")
public Flux<GetRevisionByUserResponse> getRevisionByUser(@NotBlank @PathVariable String userId, @RequestParam("lastRevision") String lastRevision) {
return getRevisionUsecase.getAllRevisionByUser(userId, lastRevision);
public Flux<GetRevisionByUserResponse> getRevisionByUser(
@PathVariable String userId,
@RequestParam(defaultValue = "createdDateTime") String sortBy,
@RequestParam(defaultValue = "1") Integer sortDirection,
@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "10") Integer size
) {
return getRevisionUsecase.getAllRevisionByUser(userId, PagingInfo.of(sortBy, sortDirection, page, size));
}

}

0 comments on commit 5e4bad9

Please sign in to comment.