package Ġcom . d restaurant . web Ċ Ċ import Ġcom . d restaurant . common . domain . model . Audit Entry Ċ import Ġcom . d restaurant . common . domain . model . Money Ċ import Ġcom . d restaurant . restaurant . domain . api . Create Restaurant Command Ċ import Ġcom . d restaurant . restaurant . domain . api . Mark Restaurant Order As Prepared Command Ċ import Ġcom . d restaurant . restaurant . domain . model . MenuItem Ċ import Ġcom . d restaurant . restaurant . domain . model . Restaurant Menu Ċ import Ġorg . ax on framework . command handling . callbacks . Logging Callback Ċ import Ġorg . ax on framework . command handling . gateway . Command Gateway Ċ import Ġorg . springframework . messaging . handler . annotation . Message Mapping Ċ import Ġorg . springframework . security . core . context . SecurityContext Holder Ċ import Ġorg . springframework . stereotype . Controller Ċ import Ġjava . math . BigDecimal Ċ import Ġjava . util .* ĊĊ Ċ @ Controller Ċ class ĠWeb Controller ( private Ġval Ġcommand Gateway : ĠCommand Gateway ) Ġ{ ĊĊĠĠĠ Ġprivate Ġval ĠcurrentUser : ĠString ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġif Ġ( SecurityContext Holder . getContext (). authentication Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSecurity Context Holder . getContext (). authentication . name ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ" TEST " ĊĊĠĠĠ Ġprivate Ġval Ġaudit Entry : ĠAudit Entry ĊĠĠĠĠĠĠĠ Ġget () Ġ= ĠAudit Entry ( currentUser , ĠCalendar . getInstance (). time ) ĊĊĠĠĠ Ġ@ Message Mapping ( value Ġ= Ġ["/ rest aurants / create command "]) ĊĠĠĠ Ġfun Ġcreate Restaurant ( request : ĠCreate Restaurant DTO ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmenu Items Ġ= ĠArrayList < MenuItem >() ĊĠĠĠĠĠĠĠ Ġfor Ġ(( id , Ġname , Ġprice ) Ġin Ġrequest . menu Items ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġitem Ġ= ĠMenuItem ( id , Ġname , ĠMoney ( price )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmenu Items . add ( item ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġmenu Ġ= ĠRest aurant Menu ( menu Items , Ġ" ver . 0 ") ĊĠĠĠĠĠĠĠ Ġval Ġcommand Ġ= ĠCreate Restaurant Command ( request . name , Ġmenu , Ġaudit Entry ) ĊĠĠĠĠĠĠĠ Ġcommand Gateway . send ( command , ĠLogging Callback . INSTANCE ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Message Mapping ( value Ġ= Ġ["/ rest aurants / orders / mark prepared command "]) ĊĠĠĠ Ġfun Ġmark Restaurant Order As Prepared ( id : ĠString ) Ġ= Ġcommand Gateway . send ( Mark Restaurant Order As Prepared Command ( id , Ġaudit Entry ), ĠLogging Callback . INSTANCE ) Ċ } Ċ Ċ /** Ċ Ġ* ĠA Ġrequest Ġfor Ġcreating Ġa ĠRest aurant Ċ Ġ*/ Ċ data Ġclass ĠCreate Restaurant DTO ( val Ġname : ĠString , Ġval Ġmenu Items : ĠList < MenuItem DTO >) Ċ Ċ /** Ċ Ġ* ĠA ĠMenu Ġitem Ġrequest Ċ Ġ*/ Ċ data Ġclass ĠMenuItem DTO ( val Ġid : ĠString , Ġval Ġname : ĠString , Ġval Ġprice : ĠBigDecimal ) Ċ