package Ġstudio . st yx . chain reaction . api . controller . rest Ċ Ċ import Ġorg . slf 4 j . Logger Ċ import Ġorg . slf 4 j . LoggerFactory Ċ import Ġorg . springframework . data . domain . Page able Ċ import Ġorg . springframework . data . domain . Sort . Direction Ċ import Ġorg . springframework . data . web . Page able Default Ċ import Ġorg . springframework . http . Response Entity Ċ import Ġorg . springframework . http . Response Entity .* Ċ import Ġorg . springframework . web . bind . annotation .* Ċ import Ġorg . springframework . web . servlet . support . Servlet Uri Components Builder Ċ import Ġstudio . st yx . chain reaction . domain . document . Player Ċ import Ġstudio . st yx . chain reaction . domain . document . Play ground Ċ import Ġstudio . st yx . chain reaction . domain . model . Default Play ground Request Dto Ċ import Ġstudio . st yx . chain reaction . domain . model . Default Play ground Response Dto Ċ import Ġstudio . st yx . chain reaction . service . Play ground Service Ċ import Ġjavax . servlet . http . HttpServletRequest ĊĊ Ċ @ RestController Ċ @ RequestMapping (" v 1 / playground s ") Ċ class ĠPlay ground Controller ( private Ġval Ġplay ground Service : ĠPlay ground Service ) Ġ{ ĊĠĠĠ Ġprivate Ġval Ġlogger : ĠLogger Ġ= ĠLoggerFactory . getLogger ( java Class ) ĊĊĠĠĠ Ġ@ PostMapping ĊĠĠĠ Ġfun Ġcreate Play ground (@ RequestBody Ġdefault Station Request : ĠDefault Play ground Request Dto , Ġrequest : ĠHttpServletRequest ): ĠResponseEntity < Default Play ground Response Dto > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġstation Ġ= Ġplay ground Service . create Play ground ( default Station Request ); ĊĠĠĠĠĠĠĠ Ġreturn Ġcreated ( Servlet Uri Components Builder . from Context Path ( request ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. path ( request . request URI . plus ("/ { playground Id } ")) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. build And Expand ( station . id ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. to Uri ()). body ( station ); ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ĊĠĠĠ Ġfun ĠgetAll Play ground s ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ@ Page able Default ( page Ġ= Ġ 0 , Ġsize Ġ= Ġ 1 0 , Ġdirection Ġ= ĠDirection . DESC ) Ġpage : ĠPage able ): ĠList < Play ground > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġplay ground Service . getAll Play ground s ( page ); ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ("/ { playground Id }") ĊĠĠĠ Ġfun Ġget Play ground ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ@ PathVariable (" playground Id ") Ġplay ground Id : ĠLong ): ĠResponseEntity < Play ground > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġif Ġ( playground Service . get Play ground ( playground Id ) Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġok ( playground Service . get Play ground ( playground Id ) !! ) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnot Found (). build (); ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ("/ { playground Id }/ players ") ĊĠĠĠ Ġfun Ġget Players By Play ground ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ@ PathVariable (" playground Id ") Ġplay ground Id : ĠLong ): ĠResponseEntity < List < Player >> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġif Ġ( playground Service . get Play ground ( playground Id ) Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġok ( playground Service . get Play ground ( playground Id ) !!. players . values . toList ()) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnot Found (). build (); ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ