package Ġcom . example . demo . interfaces . api . task Ċ Ċ import Ġcom . example . demo . application . service . task . Task Application Service Ċ import Ġcom . example . demo . domain . model . task . TaskId Ċ import Ġorg . springframework . http . HttpStatus Ċ import Ġorg . springframework . http . Response Entity Ċ import Ġorg . springframework . web . bind . annotation .* Ċ Ċ @ RestController Ċ @ RequestMapping ("/ tasks ") Ċ class ĠTask Controller ( ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġservice : ĠTask Application Service ) Ġ{ ĊĊĠĠĠ Ġ@ GetMapping () ĊĠĠĠ Ġfun Ġlist (): ĠTask List ResponseBody Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtasks Ġ= Ġservice . list () ĊĠĠĠĠĠĠĠ Ġreturn ĠTask List ResponseBody . from ( tasks ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ("/ { taskId }") ĊĠĠĠ Ġfun Ġget (@ PathVariable ĠtaskId : ĠInt ): ĠResponseEntity < Task Get ResponseBody > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtask Ġ= Ġservice . get ( TaskId ( taskId )) Ġ?: Ġreturn ĠResponseEntity . not Found (). build () ĊĠĠĠĠĠĠĠ Ġval Ġbody Ġ= ĠTask Get ResponseBody . from ( task ) ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . ok ( body ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ PostMapping ĊĠĠĠ Ġ@ ResponseStatus ( HttpStatus . CREATED ) ĊĠĠĠ Ġfun Ġpost (@ RequestBody Ġbody : ĠTask Post RequestBody ) Ġ{ ĊĠĠĠĠĠĠĠ Ġservice . register ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbody . task Name (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbody . assign ee UserId ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Delete Mapping ("/ { taskId }") ĊĠĠĠ Ġ@ ResponseStatus ( HttpStatus . NO _ CONTENT ) ĊĠĠĠ Ġfun Ġdelete (@ PathVariable ĠtaskId : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġservice . remove ( TaskId ( taskId )) ĊĠĠĠ Ġ} Ċ Ċ }