package Ġcom . kotlin . cache demo . controller Ċ Ċ import Ġcom . kotlin . cache demo . domain . User Entity Ċ import Ġcom . kotlin . cache demo . dto . User Dto Ċ import Ġcom . kotlin . cache demo . service . UserService Ċ import Ġorg . springframework . context . ApplicationContext Ċ import Ġorg . springframework . http . HttpStatus Ċ import Ġorg . springframework . web . bind . annotation . Delete Mapping Ċ import Ġorg . springframework . web . bind . annotation . GetMapping Ċ import Ġorg . springframework . web . bind . annotation . PathVariable Ċ import Ġorg . springframework . web . bind . annotation . PostMapping Ċ import Ġorg . springframework . web . bind . annotation . RequestBody Ċ import Ġorg . springframework . web . bind . annotation . RequestMapping Ċ import Ġorg . springframework . web . bind . annotation . ResponseStatus Ċ import Ġorg . springframework . web . bind . annotation . RestController Ċ Ċ /** Ċ Ġ* Ġ@ project Ġcache - demo Ċ Ġ* Ġ@ author Ġi ak ony ak ina Ċ Ġ* Ġ@ created Ġ 1 7 / 1 0 / 2 0 2 1 Ċ Ġ*/ Ċ @ RestController Ċ @ RequestMapping ("/ api / v 1 / users ") Ċ class ĠUser Controller ( Ċ ĉ private Ġval ĠuserService : ĠUserService , Ċ ĉ private Ġval Ġapplication Context : ĠApplication Context Ġ// Ġfor Ġdebug Ċ ) Ġ{ Ċ ĉ @ ResponseStatus ( HttpStatus . FOUND ) Ċ ĉ @ GetMapping ("/ { id }") Ċ ĉ fun Ġget (@ PathVariable Ġid : ĠLong ) Ġ= ĠuserService . get ( id ) Ċĉ ĉ . let Ġ{ ĠUser Dto ( it ) Ġ} ĊĊ ĉ @ ResponseStatus ( HttpStatus . FOUND ) Ċ ĉ @ GetMapping Ċ ĉ fun ĠfindAll () Ġ= ĠuserService . findAll () Ċĉ ĉ . map Ġ{ ĠUser Dto ( it ) Ġ} ĊĊ ĉ @ ResponseStatus ( HttpStatus . CREATED ) Ċ ĉ @ PostMapping Ċ ĉ fun Ġcreate (@ RequestBody Ġdto : ĠUser Dto ) Ġ= ĠUser Entity ( dto . name , Ġdto . email ) Ċĉ ĉ . let Ġ{ ĠuserService . create ( it ) Ġ} Ċĉ ĉ . let Ġ{ ĠUser Dto ( it ) Ġ} ĊĊ ĉ @ ResponseStatus ( HttpStatus . OK ) Ċ ĉ @ Delete Mapping ("/ { id }") Ċ ĉ fun Ġdelete (@ PathVariable Ġid : ĠLong ) Ġ= ĠuserService . delete ById ( id ) Ċ }