package Ġcom . v eng ates hm . expense tracker . controller Ċ Ċ import Ġcom . v eng ates hm . expense tracker . dto . Expense Dto Ċ import Ġcom . v eng ates hm . expense tracker . response . Expense Response Ċ import Ġcom . v eng ates hm . expense tracker . service . Expense Service Ċ import Ġorg . springframework . http . HttpStatus Ċ import Ġorg . springframework . http . Response Entity Ċ import Ġorg . springframework . web . bind . annotation .* Ċ Ċ @ RestController Ċ @ RequestMapping ("/ api / v 1 / expense ") Ċ @ Cross Origin ("* ") Ċ class ĠExp ense Controller ( private Ġval Ġexpense Service : ĠExp ense Service ) Ġ{ ĊĠĠĠ Ġ@ GetMapping ("/ all ") ĊĠĠĠ Ġfun ĠgetAll (): ĠResponseEntity < Expense Response > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexp enses Ġ= Ġexpense Service . getAll () ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity ( Expense Response (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthis . status Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthis . exp enses Ġ= Ġexp enses ĊĠĠĠĠĠĠĠ Ġ}, ĠHttpStatus . OK ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ PostMapping ĊĠĠĠ Ġfun Ġcreate (@ RequestBody Ġexpense Dto : ĠExp ense Dto ): ĠResponseEntity < Any > Ġ{ ĊĠĠĠĠĠĠĠ Ġexpense Service . create ( expense Dto ) ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity ( HttpStatus . OK ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Delete Mapping ("/ all ") ĊĠĠĠ Ġfun Ġdelete All (): ĠResponseEntity < Any > Ġ{ ĊĠĠĠĠĠĠĠ Ġexpense Service . delete All () ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity ( HttpStatus . OK ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Delete Mapping ("/ { id }") ĊĠĠĠ Ġfun Ġdelete ById (@ PathVariable Ġid : ĠString ): ĠResponseEntity < Any > Ġ{ ĊĠĠĠĠĠĠĠ Ġexpense Service . delete ById ( id ) ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity ( HttpStatus . OK ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ĊĠĠĠ Ġfun ĠfindBy CategoryId ( ĊĠĠĠĠĠĠĠ Ġ@ RequestParam ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġname Ġ= Ġ" categoryId ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrequired Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) Ġcategory Id : ĠString ĊĠĠĠ Ġ): ĠResponseEntity < Expense Response > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexp enses Ġ= Ġexpense Service . findBy CategoryId ( categoryId ) ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity ( Expense Response (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthis . status Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthis . exp enses Ġ= Ġexp enses ĊĠĠĠĠĠĠĠ Ġ}, ĠHttpStatus . OK ) ĊĠĠĠ Ġ} Ċ }