package Ġcom . m aly . presentation . building Ċ Ċ import Ġcom . m aly . domain . building . Building Service Ċ import Ġcom . m aly . domain . building . Building Type Ċ import Ġcom . m aly . domain . play . Play Service Ċ import Ġcom . m aly . presentation . building . Building Controller . Companion . BASE _ PATH Ċ import Ġcom . m aly . presentation . play . Play Model Ċ import Ġcom . m aly . system . Api Ċ import Ġorg . springframework . web . bind . annotation .* Ċ Ċ /** Ċ Ġ* Ġ@ author ĠAle ks ander ĠBr zo z owski Ċ Ġ*/ Ċ Ċ @ RestController Ċ @ RequestMapping ("${ Api . BASE _ URL }$ BASE _ PATH ") Ċ class ĠBuilding Controller ( private Ġval Ġbuilding Service : ĠBuilding Service , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprivate Ġval Ġplay Service : ĠPlay Service ) Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠBASE _ PATH Ġ= Ġ"/ build ings " ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠC ITY _ SORT ED _ PATH Ġ= Ġ"/ city - sorted " ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠID _ PATH Ġ= Ġ"/ { id }" ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠBUILD ING _ PLAY S Ġ= Ġ"$ ID _ PATH / play s " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ( C ITY _ SORT ED _ PATH ) ĊĠĠĠ Ġfun Ġget Build ings (@ RequestParam Ġtype : ĠBuilding Type . Type ): ĠList < City Sorted Build ings Model > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġbuilding Service . findAll Build ings ( type ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. groupBy Ġ{ Ġit . address . city Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġ( city , Ġbuild ings ) Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠCity Sorted Build ings Model ( city Ġ= Ġcity , Ġbuild ings Ġ= Ġbuild ings . map Ġ{ ĠBuilding Model . map ( it ) Ġ}) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ( BUILD ING _ PLAY S ) ĊĠĠĠ Ġfun Ġget Play s (@ PathVariable Ġid : ĠLong ): ĠList < Play Model > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġplay Service . get Play sBy Building Id ( id ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĠPlay Model . of ( it ) Ġ} ĊĠĠĠ Ġ} Ċ }