package Ġcom . example . core web . domains . address . controllers Ċ Ċ import Ġcom . example . common . utils . Exception Util Ċ import Ġcom . example . core web . commons . Constants Ċ import Ġcom . example . core web . domains . address . models . dto . District Dto Ċ import Ġcom . example . core web . domains . address . models . entities . District Ċ import Ġcom . example . core web . domains . address . models . map pers . District Mapper Ċ import Ġcom . example . core web . domains . address . services . District Service Ċ import Ġcom . example . core web . domains . base . controllers . Crud Controller Ċ import Ġcom . example . core web . routing . Route Ċ import Ġio . swagger . annotations . Api Ċ import Ġio . swagger . annotations . ApiOperation Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . data . domain . Page Ċ import Ġorg . springframework . http . Response Entity Ċ import Ġorg . springframework . web . bind . annotation .* Ċ import Ġjavax . validation . Valid Ċ Ċ @ RestController Ċ @ Api ( tags Ġ= Ġ[ Constants . Swagger . DI STRICT ], Ġdescription Ġ= ĠConstants . Swagger . REST _ API ) Ċ class ĠDistrict Controller ( ĊĠĠĠĠĠĠĠ Ġ@ Autowired Ġval Ġdistrict Service : ĠDistrict Service , ĊĠĠĠĠĠĠĠ Ġ@ Autowired Ġval Ġdistrict Mapper : ĠDistrict Mapper Ċ ) Ġ: ĠCr ud Controller < District Dto > Ġ{ ĊĊĠĠĠ Ġ@ GetMapping ( Route . V 1 . SEARCH _ DI STRICT ) ĊĠĠĠ Ġ@ ApiOperation ( value Ġ= ĠConstants . Swagger . SEARCH _ ALL _ MSG Ġ+ ĠConstants . Swagger . DI STRICT ) ĊĠĠĠ Ġfun Ġsearch (@ RequestParam (" division _ id ", Ġrequired Ġ= Ġfalse ) Ġdivision Id : ĠLong ?, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ@ RequestParam (" q ", ĠdefaultValue Ġ= Ġ"") Ġquery : ĠString , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ@ RequestParam (" page ", ĠdefaultValue Ġ= Ġ" 0 ") Ġpage : ĠInt , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ@ RequestParam (" size ", ĠdefaultValue Ġ= Ġ" 1 0 ") Ġsize : ĠInt ): ĠResponseEntity < Page < District Dto >> Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdistrict s : ĠPage < District > Ġ= Ġthis . district Service . search ( division Id , Ġquery , Ġpage , Ġsize ) ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . ok ( district s . map Ġ{ Ġdistrict Ġ-> Ġthis . district Mapper . map ( district ) Ġ}) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ( Route . V 1 . FIND _ DI STRICT ) ĊĠĠĠ Ġ@ ApiOperation ( value Ġ= ĠConstants . Swagger . GET _ MSG Ġ+ ĠConstants . Swagger . DI STRICT ) ĊĠĠĠ Ġoverride Ġfun Ġfind (@ PathVariable Ġid : ĠLong ): ĠResponseEntity < District Dto > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdistrict : ĠDistrict Ġ= Ġthis . district Service . find ( id ). orElse Throw Ġ{ ĠException Util . not Found (" Could Ġnot Ġfind Ġdistrict Ġwith Ġid : Ġ$ id ") Ġ} ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . ok ( this . district Mapper . map ( district )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ PostMapping ( Route . V 1 . CREATE _ DI STRICT ) ĊĠĠĠ Ġ@ ApiOperation ( value Ġ= ĠConstants . Swagger . POST _ MSG Ġ+ ĠConstants . Swagger . DI STRICT ) ĊĠĠĠ Ġoverride Ġfun Ġcreate (@ Valid Ġ@ RequestBody Ġdto : ĠDistrict Dto ): ĠResponseEntity < District Dto > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdistrict : ĠDistrict Ġ= Ġthis . district Service . save ( this . district Mapper . map ( dto , Ġnull )) ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . ok ( this . district Mapper . map ( district )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Patch Mapping ( Route . V 1 . UPDATE _ DI STRICT ) ĊĠĠĠ Ġ@ ApiOperation ( value Ġ= ĠConstants . Swagger . PATCH _ MSG Ġ+ ĠConstants . Swagger . DI STRICT ) ĊĠĠĠ Ġoverride Ġfun Ġupdate (@ PathVariable Ġid : ĠLong , Ġ@ Valid Ġ@ RequestBody Ġdto : ĠDistrict Dto ): ĠResponseEntity < District Dto > Ġ{ ĊĠĠĠĠĠĠĠ Ġvar Ġdistrict : ĠDistrict Ġ= Ġthis . district Service . find ( id ). orElse Throw Ġ{ ĠException Util . not Found (" Could Ġnot Ġfind Ġdistrict Ġwith Ġid : Ġ$ id ") Ġ} ĊĠĠĠĠĠĠĠ Ġdistrict Ġ= Ġthis . district Service . save ( this . district Mapper . map ( dto , Ġdistrict )) ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . ok ( this . district Mapper . map ( district )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Delete Mapping ( Route . V 1 . DELETE _ DI STRICT ) ĊĠĠĠ Ġ@ ApiOperation ( value Ġ= ĠConstants . Swagger . DELETE _ MSG Ġ+ ĠConstants . Swagger . DI STRICT ) ĊĠĠĠ Ġoverride Ġfun Ġdelete (@ PathVariable Ġid : ĠLong ): ĠResponseEntity < Any > Ġ{ ĊĠĠĠĠĠĠĠ Ġthis . district Service . delete ( id , Ġtrue ) ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . ok (). build () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġsearch ( query : ĠString , Ġpage : ĠInt , Ġsize : ĠInt ): ĠResponseEntity < Page < District Dto >> Ġ{ ĊĠĠĠĠĠĠĠ ĠTODO (" Not Ġyet Ġimplemented ") ĊĠĠĠ Ġ} Ċ Ċ } Ċ