From 9ae52dba4a0ac0c5ff65c581689c248774d806c4 Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Thu, 5 Jun 2025 11:11:42 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`feature?= =?UTF-8?q?-board`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docstrings generation was requested by @DevCHW. * https://github.com/DevCHW/coderabbit-demo/pull/2#issuecomment-2943759502 The following files were modified: * `src/main/kotlin/io/devchw/coderabbit/BoardController.kt` --- .../io/devchw/coderabbit/BoardController.kt | 42 ++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/io/devchw/coderabbit/BoardController.kt b/src/main/kotlin/io/devchw/coderabbit/BoardController.kt index fe5c88b..6c0aacf 100644 --- a/src/main/kotlin/io/devchw/coderabbit/BoardController.kt +++ b/src/main/kotlin/io/devchw/coderabbit/BoardController.kt @@ -23,7 +23,12 @@ class BoardController { private val posts = mutableMapOf() private val idGenerator = AtomicLong(1) - // 게시물 생성 + /** + * Creates a new post, assigns it a unique ID, and stores it in memory. + * + * @param post The post data to create. + * @return The created post with its assigned ID and HTTP status 201 (Created). + */ @PostMapping fun createPost(@RequestBody post: Post): ResponseEntity { val id = idGenerator.getAndIncrement() @@ -32,13 +37,24 @@ class BoardController { return ResponseEntity.status(HttpStatus.CREATED).body(post) } - // 게시물 목록 조회 + /** + * Retrieves a list of all posts. + * + * @return HTTP 200 response containing all stored posts. + */ @GetMapping fun getPosts(): ResponseEntity> { return ResponseEntity.ok(posts.values.toList()) } - // 게시물 상세 조회 + /** + * Retrieves a post by its unique ID. + * + * Returns the post with HTTP 200 if found, or HTTP 404 if no post exists with the given ID. + * + * @param id The unique identifier of the post to retrieve. + * @return A ResponseEntity containing the post if found, or a 404 status if not. + */ @GetMapping("/{id}") fun getPost(@PathVariable id: Long): ResponseEntity { val post = posts[id] @@ -49,7 +65,16 @@ class BoardController { } } - // 게시물 수정 + /** + * Updates an existing post with new data by its ID. + * + * If the post with the specified ID does not exist, returns HTTP 404 (Not Found). + * Otherwise, replaces the post's content and returns the updated post with HTTP 200 (OK). + * + * @param id The ID of the post to update. + * @param updatedPost The new post data to replace the existing post. + * @return The updated post with HTTP 200, or HTTP 404 if the post does not exist. + */ @PutMapping("/{id}") fun updatePost(@PathVariable id: Long, @RequestBody updatedPost: Post): ResponseEntity { if (!posts.containsKey(id)) { @@ -60,7 +85,14 @@ class BoardController { return ResponseEntity.ok(updatedPost) } - // 게시물 삭제 + /** + * Deletes a post by its ID. + * + * Removes the post with the specified ID from the in-memory store. Returns HTTP 204 (No Content) if the post was deleted, or HTTP 404 (Not Found) if the post does not exist. + * + * @param id The unique identifier of the post to delete. + * @return A ResponseEntity with HTTP status 204 if successful, or 404 if the post is not found. + */ @DeleteMapping("/{id}") fun deletePost(@PathVariable id: Long): ResponseEntity { if (!posts.containsKey(id)) {