package Ġio . y ur ick . account Ċ Ċ import Ġio . mic ronaut . http . HttpResponse Ċ import Ġio . mic ronaut . http . annotation . Controller Ċ import Ġio . mic ronaut . http . annotation . Get Ċ import Ġio . mic ronaut . http . annotation . PathVariable Ċ import Ġkotlinx . coroutines . reactor . await Single OrNull Ċ import Ġjava . util . UUID Ċ Ċ @ Controller ("/ accounts ") Ċ class ĠAccount Controller ( ĊĠĠĠ Ġprivate Ġval Ġaccount Service : ĠAccount Service , ĊĠĠĠ Ġprivate Ġval Ġaccount Dao : ĠAccount Dao , Ċ ) Ġ{ ĊĠĠĠ Ġ@ Get ("/ { accountId }") ĊĠĠĠ Ġsuspend Ġfun Ġfetch Account ById ( ĊĠĠĠĠĠĠĠ Ġ@ PathVariable (" accountId ") ĠaccountId : ĠUUID , ĊĠĠĠ Ġ): ĠHttpResponse < Account > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcached Account Ġ= Ġaccount Dao . get Account ById ( accountId . toString ()). await Single OrNull () ĊĊĠĠĠĠĠĠĠ Ġif Ġ( cached Account Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġaccount Ġ= Ġaccount Service . fetch Account ( accountId )?. also Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġaccount Dao . save ( it . to Account Cache ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠHttpResponse . ok ( account ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġreturn ĠHttpResponse . ok ( cached Account . to Account Model ()) ĊĠĠĠ Ġ} Ċ } Ċ