package Ġorg . riz ki . m uf riz al . transaction . service . controller Ċ Ċ import Ġorg . riz ki . m uf riz al . transaction . service . domain . Pen j ual an Detail Ċ import Ġorg . riz ki . m uf riz al . transaction . service . mapping . Pen j ual an Detail Mapping Ċ import Ġorg . riz ki . m uf riz al . transaction . service . repository . Pen j ual an Detail Repository Ċ import Ġorg . riz ki . m uf riz al . transaction . service . rest client . Bar ang ServiceClient Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . data . domain . Page able Ċ import Ġorg . springframework . http . HttpStatus Ċ import Ġorg . springframework . http . Response Entity Ċ import Ġorg . springframework . web . bind . annotation . GetMapping Ċ import Ġorg . springframework . web . bind . annotation . PathVariable Ċ import Ġorg . springframework . web . bind . annotation . RequestMapping Ċ import Ġorg . springframework . web . bind . annotation . RestController Ċ Ċ /** Ċ Ġ* Ċ Ġ* Ġ@ Author ĠR iz ki ĠM uf riz al Ġ< m uf riz al riz ki @ gmail . com > Ċ Ġ* Ġ@ Web Ġ< https :// R iz ki M uf riz al . github . io > Ċ Ġ* Ġ@ Since Ġ 2 1 ĠDecember Ġ 2 0 1 7 Ċ Ġ* Ġ@ Time Ġ 2 1 . 4 4 Ċ Ġ* Ġ@ Project ĠTransaction - Service Ċ Ġ* Ġ@ Package Ġorg . riz ki . m uf riz al . transaction . service . controller Ċ Ġ* Ġ@ File ĠPen j ual an Detail Controller Ċ Ġ* Ċ Ġ*/ Ċ @ RestController Ċ @ RequestMapping ( value Ġ= Ġ["/ api "]) Ċ class ĠPen j ual an Detail Controller Ġ{ ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġpen j ual an Detail Repository : ĠPen j ual an Detail Repository ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbar ang ServiceClient : ĠBar ang ServiceClient ĊĊĠĠĠ Ġ@ GetMapping ( value Ġ= Ġ["/ pen j ual an details "]) ĊĠĠĠ Ġfun Ġget Pen j ual an Details ( page able : ĠPage able ): ĠResponseEntity < *> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity ( pen j ual an Detail Repository . findAll ( page able ), ĠHttpStatus . OK ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ( value Ġ= Ġ["/ pen j ual an details /{ id }" ]) ĊĠĠĠ Ġfun Ġget Pen j ual an Detail (@ PathVariable (" id ") Ġid : ĠString ): ĠResponseEntity < *> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity ( pen j ual an Detail Repository . findById Pen j ual an Detail ( id ). orElse ( Pen j ual an Detail ()), ĠHttpStatus . OK ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ( value Ġ= Ġ["/ pen j ual an / pen j ual an details /{ id }" ]) ĊĠĠĠ Ġfun Ġget Pen j ual an Detail ById Pen j ual an (@ PathVariable (" id ") Ġid : ĠString ): ĠResponseEntity < *> Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpen j ual an Details Ġ= Ġpen j ual an Detail Repository . findById Pen j ual an ( id ) ĊĠĠĠĠĠĠĠ Ġval Ġpen j ual an Details Mapping Ġ= Ġarray ListOf < Pen j ual an Detail Mapping >() ĊĊĠĠĠĠĠĠĠ Ġpen j ual an Details . forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpen j ual an Details Mapping . add ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠPen j ual an Detail Mapping ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġid Pen j ual an Detail Ġ= Ġit . id Pen j ual an Detail , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġid Pen j ual an Ġ= Ġit . id Pen j ual an , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġj umlah Bar ang Ġ= Ġit . jumlah Bar ang , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtotal H arga Per Bar ang Ġ= Ġit . total H arga Per Bar ang , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbar ang Ġ= Ġit . id Bar ang ?. let Ġ{ Ġit 1 Ġ-> Ġbar ang ServiceClient . get Bar ang ( it 1 ) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity ( pen j ual an Details Mapping , ĠHttpStatus . OK ) ĊĠĠĠ Ġ} Ċ Ċ }