-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: 자바 마이그레이션 #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
refactor: 자바 마이그레이션 #132
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
136 changes: 136 additions & 0 deletions
136
src/main/java/com/wooteco/wiki/document/controller/DocumentController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| package com.wooteco.wiki.document.controller; | ||
|
|
||
| import com.wooteco.wiki.document.domain.Document; | ||
| import com.wooteco.wiki.document.domain.dto.*; | ||
| import com.wooteco.wiki.document.service.DocumentSearchService; | ||
| import com.wooteco.wiki.document.service.DocumentService; | ||
| import com.wooteco.wiki.document.service.DocumentServiceJava; | ||
| import com.wooteco.wiki.global.common.ApiResponse; | ||
| import com.wooteco.wiki.global.common.ApiResponse.SuccessBody; | ||
| import com.wooteco.wiki.global.common.ApiResponseGenerator; | ||
| import com.wooteco.wiki.global.common.PageRequestDto; | ||
| import com.wooteco.wiki.global.common.ResponseDto; | ||
| import com.wooteco.wiki.history.domain.dto.HistoryDetailResponse; | ||
| import com.wooteco.wiki.history.domain.dto.HistoryResponse; | ||
| import com.wooteco.wiki.history.service.HistoryService; | ||
| import com.wooteco.wiki.organizationdocument.dto.OrganizationDocumentSearchResponse; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/document") | ||
| @RequiredArgsConstructor | ||
| public class DocumentController { | ||
|
|
||
| private final DocumentService documentService; | ||
| private final HistoryService historyService; | ||
| private final DocumentSearchService documentSearchService; | ||
| private final DocumentServiceJava documentServiceJava; | ||
|
|
||
| @Operation(summary = "위키 글 작성", description = "위키 글을 작성합니다.") | ||
| @PostMapping | ||
| public ApiResponse<SuccessBody<DocumentResponse>> post(@RequestBody CrewDocumentCreateRequest crewDocumentCreateRequest) { | ||
| DocumentResponse response = documentService.postCrewDocument(crewDocumentCreateRequest); | ||
| return ApiResponseGenerator.success(response); | ||
| } | ||
|
|
||
| @Operation(summary = "랜덤 위키 글 조회", description = "랜덤으로 위키 글을 조회합니다.") | ||
| @GetMapping("/random") | ||
| public ApiResponse<SuccessBody<DocumentResponse>> getRandom() { | ||
| DocumentResponse response = documentService.getRandom(); | ||
| return ApiResponseGenerator.success(response); | ||
| } | ||
|
|
||
| @Operation(summary = "위키 글 전체 조회", description = "페이지네이션을 통해 모든 위키 글을 조회합니다.") | ||
| @GetMapping("") | ||
| public ApiResponse<SuccessBody<ResponseDto<List<Document>>>> findAll(@ModelAttribute PageRequestDto pageRequestDto) { | ||
| Page<Document> pageResponses = documentService.findAll(pageRequestDto); | ||
| return ApiResponseGenerator.success(convertToResponse(pageResponses)); | ||
| } | ||
|
|
||
| @Operation(summary = "제목으로 위키 글 조회", description = "제목을 통해 위키 글을 조회합니다.") | ||
| @GetMapping("title/{title}") | ||
| public ApiResponse<SuccessBody<Object>> get(@PathVariable String title) { | ||
| Object response = documentService.get(title); | ||
| return ApiResponseGenerator.success(response); | ||
| } | ||
|
|
||
| @Operation(summary = "제목으로 UUID 조회", description = "제목을 통해 위키 글의 UUID를 조회합니다.") | ||
| @GetMapping("title/{title}/uuid") | ||
| public ApiResponse<SuccessBody<Object>> getUuidByTitle(@PathVariable String title) { | ||
| Object response = documentService.getUuidByTitle(title); | ||
| return ApiResponseGenerator.success(response); | ||
| } | ||
|
|
||
| @Operation(summary = "UUID로 위키 글 조회", description = "UUID를 통해 위키 글을 조회합니다.") | ||
| @GetMapping("uuid/{uuidText}") | ||
| public ApiResponse<SuccessBody<Object>> getByUuid(@PathVariable String uuidText) { | ||
| UUID uuid = UUID.fromString(uuidText); | ||
| Object response = documentService.getByUuid(uuid); | ||
| return ApiResponseGenerator.success(response); | ||
| } | ||
|
|
||
| @Operation(summary = "문서 로그 목록 조회", description = "문서 UUID로 해당 문서의 로그 목록을 페이지네이션을 통해 조회합니다.") | ||
| @GetMapping("uuid/{uuidText}/log") | ||
| public ApiResponse<SuccessBody<ResponseDto<List<HistoryResponse>>>> getLogs( | ||
| @PathVariable String uuidText, | ||
| @ModelAttribute PageRequestDto pageRequestDto | ||
| ) { | ||
| UUID uuid = UUID.fromString(uuidText); | ||
| Page<HistoryResponse> pageResponses = historyService.findAllByDocumentUuid(uuid, pageRequestDto); | ||
| return ApiResponseGenerator.success(convertToResponse(pageResponses)); | ||
| } | ||
|
|
||
| @Operation(summary = "로그 상세 조회", description = "로그 ID로 로그 상세 정보를 조회합니다.") | ||
| @GetMapping("/log/{logId}") | ||
| public ApiResponse<SuccessBody<HistoryDetailResponse>> getDocumentLogs(@PathVariable Long logId) { | ||
| HistoryDetailResponse logDetail = historyService.getLogDetail(logId); | ||
| return ApiResponseGenerator.success(logDetail); | ||
| } | ||
|
|
||
| @Operation(summary = "위키 글 수정", description = "위키 글을 수정합니다.") | ||
| @PutMapping | ||
| public ApiResponse<SuccessBody<DocumentResponse>> put( | ||
| @RequestBody DocumentUpdateRequest documentUpdateRequest | ||
| ) { | ||
| DocumentResponse response = documentService.put(documentUpdateRequest.uuid(), documentUpdateRequest); | ||
| return ApiResponseGenerator.success(response); | ||
| } | ||
|
|
||
| @Operation(summary = "키워드로 위키 글 검색", description = "키워드로 위키 글을 검색합니다.") | ||
| @GetMapping("/search") | ||
| public ApiResponse<SuccessBody<List<DocumentSearchResponse>>> search(@RequestParam String keyWord) { | ||
| return ApiResponseGenerator.success(documentSearchService.search(keyWord)); | ||
| } | ||
|
|
||
| @Operation(summary = "누적 조회수 수신 API", description = "프론트에서 누적된 조회수를 전달받아 DB에 반영합니다.") | ||
| @PostMapping("/views/flush") | ||
| public ApiResponse<SuccessBody<String>> flushViews( | ||
| @RequestBody ViewFlushRequest request | ||
| ) { | ||
| documentService.flushViews(request.views()); | ||
| return ApiResponseGenerator.success("조회수 누적 완료"); | ||
| } | ||
|
|
||
| @Operation(summary = "특정 문서에 대한 조직 문서 조회 API", description = "특정 문서에 대한 조직 문서들을 조회합니다.") | ||
| @GetMapping("/{uuidText}/organization-documents") | ||
| public ApiResponse<SuccessBody<List<OrganizationDocumentSearchResponse>>> readOrganizationDocument( | ||
| @PathVariable String uuidText | ||
| ) { | ||
| UUID uuid = UUID.fromString(uuidText); | ||
| return ApiResponseGenerator.success(documentServiceJava.searchOrganizationDocument(uuid)); | ||
| } | ||
|
|
||
| private <T> ResponseDto<List<T>> convertToResponse(Page<T> pageResponses) { | ||
| return ResponseDto.of( | ||
| pageResponses.getNumber(), | ||
| pageResponses.getTotalPages(), | ||
| pageResponses.getContent() | ||
| ); | ||
| } | ||
| } | ||
|
|
||
132 changes: 0 additions & 132 deletions
132
src/main/java/com/wooteco/wiki/document/controller/DocumentController.kt
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
src/main/java/com/wooteco/wiki/document/domain/dto/DocumentResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.wooteco.wiki.document.domain.dto; | ||
|
|
||
| import com.wooteco.wiki.organizationdocument.dto.response.OrganizationDocumentResponse; | ||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| public record DocumentResponse( | ||
| Long documentId, | ||
| UUID documentUUID, | ||
| String title, | ||
| String contents, | ||
| String writer, | ||
| LocalDateTime generateTime, | ||
| Integer viewCount, | ||
| Long latestVersion, | ||
| List<OrganizationDocumentResponse> organizationDocumentResponses | ||
| ) { | ||
| } | ||
|
|
17 changes: 0 additions & 17 deletions
17
src/main/java/com/wooteco/wiki/document/domain/dto/DocumentResponse.kt
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/main/java/com/wooteco/wiki/document/domain/dto/DocumentSearchResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.wooteco.wiki.document.domain.dto; | ||
|
|
||
| import com.wooteco.wiki.document.domain.DocumentType; | ||
| import java.util.UUID; | ||
|
|
||
| public record DocumentSearchResponse( | ||
| String title, | ||
| UUID uuid, | ||
| DocumentType documentType | ||
| ) { | ||
| } | ||
|
|
10 changes: 0 additions & 10 deletions
10
src/main/java/com/wooteco/wiki/document/domain/dto/DocumentSearchResponse.kt
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
src/main/java/com/wooteco/wiki/document/domain/dto/DocumentUpdateRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.wooteco.wiki.document.domain.dto; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| public record DocumentUpdateRequest( | ||
| String title, | ||
| String contents, | ||
| String writer, | ||
| Long documentBytes, | ||
| UUID uuid | ||
| ) { | ||
| } | ||
|
|
12 changes: 0 additions & 12 deletions
12
src/main/java/com/wooteco/wiki/document/domain/dto/DocumentUpdateRequest.kt
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
src/main/java/com/wooteco/wiki/document/domain/dto/ViewFlushRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.wooteco.wiki.document.domain.dto; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.UUID; | ||
|
|
||
| public record ViewFlushRequest( | ||
| Map<UUID, Integer> views | ||
| ) { | ||
| } | ||
|
|
7 changes: 0 additions & 7 deletions
7
src/main/java/com/wooteco/wiki/document/domain/dto/ViewFlushRequest.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p2) 나중에 서비스 로직으로 들어가도 되겠네요~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이건 유틸성이 강해보인다고 생각하는데 어떠신가용 ~?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그르네요
DTO 형태는 서비스 책임이라고 생각해서 한 말이었는데 다시 보니 오해의 소지가 있을 수 있겠군요
convertToResponse는 유틸 클래스로 빼고,DTO를 반환하는 결정을 서비스에서 끝내는 구조는 어떻게 생각하시나요~?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋습니다~ 현재 PR은 마이그레이션만 진행을 마치고 새로운 이슈로 파는 게 좋아보여서 머지할게요~