package Ġcom . example . work time administration . controllers Ċ Ċ import Ġcom . example . work time administration . model . dto . Employee Dto Ċ import Ġcom . example . work time administration . services . employee . Employee Service Ċ import Ġorg . springframework . http . HttpStatus Ċ import Ġorg . springframework . http . Response Entity Ċ import Ġorg . springframework . http . Response Entity . ok Ċ import Ġorg . springframework . web . bind . annotation . GetMapping Ċ import Ġorg . springframework . web . bind . annotation . PathVariable Ċ import Ġorg . springframework . web . bind . annotation . RestController Ċ import Ġorg . springframework . web . server . ResponseStatus Exception Ċ Ċ const Ġval Ġemployee Url Ġ= Ġ" employee " Ċ Ċ /** Ċ Ġ* ĠREST ĠAPI Ġto Ġinteract Ġwith Ġthe Ġreplic ated Ġemployees . ĠAccept s Ġno Ġmanip ulating Ġcommands , Ġonly ĠGET . Ċ Ġ*/ Ċ @ RestController Ċ class ĠEmployee Controller ( val Ġemployee Service : ĠEmployee Service ) Ġ{ ĊĊĠĠĠ Ġ@ GetMapping ( employee Url ) ĊĠĠĠ Ġfun ĠgetAll Employees (): ĠResponseEntity < List < Employee Dto >> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġok ( employee Service . getAll Employees ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ("$ employee Url /{ id }") ĊĠĠĠ Ġfun Ġget Employee ById (@ PathVariable (" id ") Ġid : ĠLong ): ĠResponseEntity < Employee Dto > Ġ{ ĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġok ( employee Service . get Employee ById ( id )) ĊĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( ex : ĠNoSuch ElementException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠResponse Status Exception ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHttpStatus . BAD _ REQUEST , Ġ" No ĠEmployee Ġunder Ġthe Ġgiven Ġid ", Ġex ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ("$ employee Url / project /{ id }") ĊĠĠĠ Ġfun Ġget Employees Of Project (@ PathVariable (" id ") ĠprojectId : ĠLong ): ĠResponseEntity < List < Employee Dto >> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġok ( employee Service . get Employees Of Project ( projectId )) ĊĠĠĠ Ġ} Ċ Ċ }