package Ġcom . atar ax ia . gab riel _ vz . controller . editor Ċ Ċ import Ġcom . atar ax ia . gab riel _ vz . model . L iter ature Ċ import Ġcom . atar ax ia . gab riel _ vz . service . L iter ature Service Ċ import Ġorg . springframework . stereotype . Controller Ċ import Ġorg . springframework . ui . Model Ċ import Ġorg . springframework . validation . Binding Result Ċ import Ġorg . springframework . web . bind . annotation .* Ċ import Ġjavax . validation . Valid Ċ Ċ @ Controller Ċ @ RequestMapping ("/ editor /") Ċ class ĠEditor L iter ature Controller ( ĊĠĠĠĠĠĠĠ Ġval Ġliter ature Service : ĠL iter ature Service Ċ ) Ġ: Ġcom . atar ax ia . gab riel _ vz . root . Controller < Model , ĠL iter ature >() Ġ{ ĊĊĠĠĠ Ġ@ GetMapping ("/ create L iter ature ") ĊĠĠĠ Ġoverride Ġfun Ġshow Add Form ( m : ĠModel ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġm . addAttribute (" l iter ature ", ĠL iter ature ()) ĊĠĠĠĠĠĠĠ Ġreturn Ġ"/ editor / add L iter ature " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ PostMapping ("/ add L iter ature ") ĊĠĠĠ Ġoverride Ġfun Ġadd (@ Valid Ġtype : ĠL iter ature , Ġbinding Result : ĠBinding Result ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( binding Result . has Errors ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprint ( binding Result . all Errors ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġliter ature Service . create ( type ) ĊĠĠĠĠĠĠĠ Ġreturn Ġ" redirect :/ l iter ature " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ("/ edit Reference ") ĊĠĠĠ Ġoverride Ġfun Ġshow Update Form (@ RequestParam (" id ") Ġid : ĠString , Ġm : ĠModel ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġliter ature Ġ= Ġliter ature Service . get ( id ). to Option (). or Null () ĊĠĠĠĠĠĠĠ Ġm . addAttribute (" l iter ature ", Ġliter ature ) ĊĠĠĠĠĠĠĠ Ġreturn Ġ"/ editor / edit L iter ature " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ PostMapping ("/ update L iter ature /{ id }") ĊĠĠĠ Ġoverride Ġfun Ġupdate (@ PathVariable (" id ") Ġid : ĠString , Ġ@ Valid Ġtype : ĠL iter ature ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġliter ature Service . update ( id , Ġtype ) ĊĠĠĠĠĠĠĠ Ġreturn Ġ" redirect :/ l iter ature " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ("/ delete Reference ") ĊĠĠĠ Ġoverride Ġfun Ġdelete ById (@ RequestParam (" id ") Ġid : ĠString ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġliter ature Service . delete ( id ) ĊĠĠĠĠĠĠĠ Ġreturn Ġ" redirect :/ l iter ature " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ("/ delete L iter ature ") ĊĠĠĠ Ġoverride Ġfun Ġdelete All (): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġliter ature Service . delete All () ĊĠĠĠĠĠĠĠ Ġreturn Ġ" redirect :/ l iter ature " ĊĠĠĠ Ġ} Ċ }