-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
35 changes: 35 additions & 0 deletions
35
src/main/kotlin/com/toyProject7/karrot/test/controller/TestController.kt
This file contains 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,35 @@ | ||
package com.toyProject7.karrot.test.controller | ||
|
||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
class TestController { | ||
@GetMapping("/api/test") | ||
fun getTest(): ResponseEntity<TestResponse> { | ||
return ResponseEntity.ok(TestResponse(1, 2, "2번 테스트 제목", "2번 테스트 본문내용")) | ||
} | ||
|
||
@GetMapping("/api/test2") | ||
fun getTest2(): ResponseEntity<TestResponse> { | ||
return ResponseEntity.ok(TestResponse(11, 22, "22번 테스트 제목", "22번 테스트 본문내용")) | ||
} | ||
|
||
@PostMapping("/api/test3") | ||
fun postTest( | ||
@RequestBody request: TestResponse, | ||
): ResponseEntity<TestResponse> { | ||
val response = TestResponse(request.userId, request.id, request.title, request.body) | ||
return ResponseEntity.ok(response) | ||
} | ||
} | ||
|
||
data class TestResponse( | ||
val userId: Int, | ||
val id: Int, | ||
val title: String, | ||
val body: String, | ||
) |