diff --git a/src/main/java/com/wooteco/wiki/document/controller/DocumentController.kt b/src/main/java/com/wooteco/wiki/document/controller/DocumentController.kt index b153d33..0080d67 100644 --- a/src/main/java/com/wooteco/wiki/document/controller/DocumentController.kt +++ b/src/main/java/com/wooteco/wiki/document/controller/DocumentController.kt @@ -71,9 +71,9 @@ class DocumentController( return ApiResponseGenerator.success(response) } - @Operation(summary = "문서 로그 목록 조회", description = "문서 UUID로 해당 문서의 로그 목록을 페이지네이션을 통해 조회합니다.") - @GetMapping("uuid/{uuidText}/log") - fun getLogs( + @Operation(summary = "문서 히스토리 목록 조회", description = "문서 UUID로 해당 문서의 히스토리 목록을 페이지네이션을 통해 조회합니다.") + @GetMapping("uuid/{uuidText}/history") + fun getHistories( @PathVariable uuidText: String, @ModelAttribute pageRequestDto: PageRequestDto ): ApiResponse>>> { @@ -82,11 +82,11 @@ class DocumentController( return ApiResponseGenerator.success(convertToResponse(pageResponses)) } - @Operation(summary = "로그 상세 조회", description = "로그 ID로 로그 상세 정보를 조회합니다.") - @GetMapping("/log/{logId}") - fun getDocumentLogs(@PathVariable logId: Long): ApiResponse> { - val logDetail = historyService.getLogDetail(logId) - return ApiResponseGenerator.success(logDetail) + @Operation(summary = "히스토리 상세 조회", description = "히스토리 ID로 히스토리 상세 정보를 조회합니다.") + @GetMapping("/history/{historyId}") + fun getDocumentHistory(@PathVariable historyId: Long): ApiResponse> { + val historyDetail = historyService.getHistoryDetail(historyId) + return ApiResponseGenerator.success(historyDetail) } @Operation(summary = "위키 글 수정", description = "위키 글을 수정합니다.") diff --git a/src/main/java/com/wooteco/wiki/history/domain/History.java b/src/main/java/com/wooteco/wiki/history/domain/History.java index b3b6228..0ac6e4d 100644 --- a/src/main/java/com/wooteco/wiki/history/domain/History.java +++ b/src/main/java/com/wooteco/wiki/history/domain/History.java @@ -18,12 +18,12 @@ @Getter @Entity -@Table(name = "log") +@Table(name = "history") public class History { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "log_id") + @Column(name = "history_id") private Long id; private String title; diff --git a/src/main/java/com/wooteco/wiki/history/domain/dto/HistoryDetailResponse.java b/src/main/java/com/wooteco/wiki/history/domain/dto/HistoryDetailResponse.java index 44ec3d2..51ecb2b 100644 --- a/src/main/java/com/wooteco/wiki/history/domain/dto/HistoryDetailResponse.java +++ b/src/main/java/com/wooteco/wiki/history/domain/dto/HistoryDetailResponse.java @@ -2,6 +2,6 @@ import java.time.LocalDateTime; -public record HistoryDetailResponse(Long logId, String title, String contents, String writer, +public record HistoryDetailResponse(Long historyId, String title, String contents, String writer, LocalDateTime generateTime) { } diff --git a/src/main/java/com/wooteco/wiki/history/service/HistoryService.java b/src/main/java/com/wooteco/wiki/history/service/HistoryService.java index 537a71b..2f0f853 100644 --- a/src/main/java/com/wooteco/wiki/history/service/HistoryService.java +++ b/src/main/java/com/wooteco/wiki/history/service/HistoryService.java @@ -39,10 +39,10 @@ public void save(Document document) { } @Transactional(readOnly = true) - public HistoryDetailResponse getLogDetail(Long logId) { - History history = historyRepository.findById(logId) + public HistoryDetailResponse getHistoryDetail(Long historyId) { + History history = historyRepository.findById(historyId) .orElseThrow(() -> new WikiException(DOCUMENT_NOT_FOUND)); - return new HistoryDetailResponse(logId, history.getTitle(), history.getContents(), history.getWriter(), + return new HistoryDetailResponse(historyId, history.getTitle(), history.getContents(), history.getWriter(), history.getGenerateTime()); } @@ -52,14 +52,14 @@ public Page findAllByDocumentUuid(UUID documentUuid, PageReques .orElseThrow(() -> new WikiException(DOCUMENT_NOT_FOUND)); Pageable pageable = pageRequestDto.toPageable(); - Page logs = historyRepository.findAllByDocumentId(documentId, pageable); - List content = logs.getContent(); + Page histories = historyRepository.findAllByDocumentId(documentId, pageable); + List content = histories.getContent(); List responses = content.stream() .map(HistoryResponse::of) .collect(Collectors.toList()); - return new PageImpl<>(responses, pageable, logs.getTotalElements()); + return new PageImpl<>(responses, pageable, histories.getTotalElements()); } @Transactional(readOnly = true) diff --git a/src/main/resources/init.sql b/src/main/resources/init.sql index ccac05a..2e85915 100644 --- a/src/main/resources/init.sql +++ b/src/main/resources/init.sql @@ -10,7 +10,7 @@ VALUES ('titleA', '내용A', '작성자1', 100, '2024-01-01T10:00:00', 'c036a5d8 ('titleD1', '내용D1', '작성자11', 400, '2024-01-04T10:00:00', 'e64ae9dc-70d2-4ef7-a431-6ef5f81b2cf0'), ('titleE1', '내용E1', '작성자21', 500, '2024-01-05T10:00:00', 'a3eb4453-e317-4411-932f-8d3b3e3b5b74'); -INSERT INTO log (title, contents, writer, document_bytes, generate_time, document_id, version) +INSERT INTO history (title, contents, writer, document_bytes, generate_time, document_id, version) VALUES ('titleA', '내용Abefore', '작성자1before', 1000, '2023-01-01T10:00:00', 1, 1), ('titleA', '내용A', '작성자1', 100, '2024-01-01T10:00:00', 1, 2), ('titleB', '내용B', '작성자2', 200, '2024-01-02T10:00:00', 2, 1), diff --git a/src/test/java/com/wooteco/wiki/history/service/HistoryServiceTest.java b/src/test/java/com/wooteco/wiki/history/service/HistoryServiceTest.java index 4be778a..ed3df52 100644 --- a/src/test/java/com/wooteco/wiki/history/service/HistoryServiceTest.java +++ b/src/test/java/com/wooteco/wiki/history/service/HistoryServiceTest.java @@ -40,7 +40,7 @@ public class HistoryServiceTest { private HistoryRepository historyRepository; @Nested - @DisplayName("documentUuid로 요청 시 로그 리스트 반환하는 기능") + @DisplayName("documentUuid로 요청 시 히스토리 리스트 반환하는 기능") class findAllByCrewDocumentUuid { private PageRequestDto pageRequestDto = new PageRequestDto(); @@ -59,7 +59,7 @@ void setUp() { HistoryFixture.create("t1", "c2", "w2", 20L, LocalDateTime.now(), savedCrewDocument, 2L)); } - @DisplayName("documentUuid에 해당하는 로그들이 반환된다") + @DisplayName("documentUuid에 해당하는 히스토리들이 반환된다") @Test void findAllByDocumentUuid_success_bySomeData() { // when @@ -100,7 +100,7 @@ void findAllByDocumentUuid_throwsException_byNonExistsDocumentUuid() { assertThat(ex.getErrorCode()).isEqualTo(ErrorCode.DOCUMENT_NOT_FOUND); } - @DisplayName("로그 저장 시 최신 version을 제공한다.") + @DisplayName("히스토리 저장 시 최신 version을 제공한다.") @Test void save_versionIsNumberedCorrectly() { // when @@ -110,10 +110,10 @@ void save_versionIsNumberedCorrectly() { historyService.save(updatedDocument); // then - Page secondLogs = historyService.findAllByDocumentUuid(savedCrewDocument.getUuid(), pageRequestDto); - assertThat(secondLogs.getContent()).hasSize(3); - assertThat(secondLogs.getContent().get(0).version()).isEqualTo(1L); - assertThat(secondLogs.getContent().get(2).version()).isEqualTo(3L); + Page secondHistories = historyService.findAllByDocumentUuid(savedCrewDocument.getUuid(), pageRequestDto); + assertThat(secondHistories.getContent()).hasSize(3); + assertThat(secondHistories.getContent().get(0).version()).isEqualTo(1L); + assertThat(secondHistories.getContent().get(2).version()).isEqualTo(3L); } } }