package Ġorg . got son . kom ga . interfaces . api . rest Ċ Ċ import Ġio . swagger . v 3 . o as . annotations . Parameter Ċ import Ġorg . got son . kom ga . domain . persistence . Refer ential Repository Ċ import Ġorg . got son . kom ga . infrastructure . security . K om ga Principal Ċ import Ġorg . got son . kom ga . infrastructure . swagger . Page able Without Sort As QueryParam Ċ import Ġorg . got son . kom ga . interfaces . api . rest . dto . Author Dto Ċ import Ġorg . got son . kom ga . interfaces . api . rest . dto . to Dto Ċ import Ġorg . springframework . data . domain . Page Ċ import Ġorg . springframework . data . domain . Page Request Ċ import Ġorg . springframework . data . domain . Page able Ċ import Ġorg . springframework . http . MediaType Ċ import Ġorg . springframework . security . core . annotation . Authentication Principal Ċ import Ġorg . springframework . web . bind . annotation . GetMapping Ċ import Ġorg . springframework . web . bind . annotation . RequestMapping Ċ import Ġorg . springframework . web . bind . annotation . RequestParam Ċ import Ġorg . springframework . web . bind . annotation . RestController Ċ Ċ @ RestController Ċ @ RequestMapping (" api ", Ġproduces Ġ= Ġ[ MediaType . APPLICATION _ JSON _ VALUE ]) Ċ class ĠRefer ential Controller ( ĊĠ Ġprivate Ġval Ġrefer ential Repository : ĠRefer ential Repository , Ċ ) Ġ{ ĊĊĠ Ġ@ GetMapping (" v 1 / authors ") ĊĠ Ġfun Ġget Authors V 1 ( ĊĠĠĠ Ġ@ Authentication Principal Ġprincipal : ĠKom ga Principal , ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" search ", ĠdefaultValue Ġ= Ġ"") Ġsearch : ĠString , ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" library _ id ", Ġrequired Ġ= Ġfalse ) Ġlibrary Id : ĠString ?, ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" collection _ id ", Ġrequired Ġ= Ġfalse ) Ġcollection Id : ĠString ?, ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" series _ id ", Ġrequired Ġ= Ġfalse ) Ġseries Id : ĠString ?, ĊĠ Ġ): ĠList < Author Dto > Ġ= ĊĊĠĠĠ Ġwhen Ġ{ ĊĠĠĠĠĠ Ġlibrary Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Authors ByName And Library ( search , Ġlibrary Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġcollection Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Authors ByName And Collection ( search , Ġcollection Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġseries Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Authors ByName And Series ( search , Ġseries Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġelse Ġ-> Ġrefer ential Repository . findAll Authors ByName ( search , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠ Ġ}. map Ġ{ Ġit . to Dto () Ġ} ĊĊĠ Ġ@ Page able Without Sort As QueryParam ĊĠ Ġ@ GetMapping (" v 2 / authors ") ĊĠ Ġfun Ġget Authors ( ĊĠĠĠ Ġ@ Authentication Principal Ġprincipal : ĠKom ga Principal , ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" search ", Ġrequired Ġ= Ġfalse ) Ġsearch : ĠString ?, ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" role ", Ġrequired Ġ= Ġfalse ) Ġrole : ĠString ?, ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" library _ id ", Ġrequired Ġ= Ġfalse ) Ġlibrary Id : ĠString ?, ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" collection _ id ", Ġrequired Ġ= Ġfalse ) Ġcollection Id : ĠString ?, ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" series _ id ", Ġrequired Ġ= Ġfalse ) Ġseries Id : ĠString ?, ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" read list _ id ", Ġrequired Ġ= Ġfalse ) Ġread List Id : ĠString ?, ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" un page d ", Ġrequired Ġ= Ġfalse ) Ġun page d : ĠBoolean Ġ= Ġfalse , ĊĠĠĠ Ġ@ Parameter ( hidden Ġ= Ġtrue ) Ġpage : ĠPage able , ĊĠ Ġ): ĠPage < Author Dto > Ġ{ ĊĠĠĠ Ġval Ġpage Request Ġ= ĊĠĠĠĠĠ Ġif Ġ( un page d ) ĠPage able . un page d () ĊĠĠĠĠĠ Ġelse ĠPage Request . of ( ĊĠĠĠĠĠĠĠ Ġpage . pageNumber , ĊĠĠĠĠĠĠĠ Ġpage . pageSize , ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠ Ġreturn Ġwhen Ġ{ ĊĠĠĠĠĠ Ġlibrary Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Authors ByName And Library ( search , Ġrole , Ġlibrary Id , Ġprincipal . user . get Authorized Library Ids ( null ), Ġpage Request ) ĊĠĠĠĠĠ Ġcollection Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Authors ByName And Collection ( search , Ġrole , Ġcollection Id , Ġprincipal . user . get Authorized Library Ids ( null ), Ġpage Request ) ĊĠĠĠĠĠ Ġseries Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Authors ByName And Series ( search , Ġrole , Ġseries Id , Ġprincipal . user . get Authorized Library Ids ( null ), Ġpage Request ) ĊĠĠĠĠĠ Ġread List Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Authors ByName And Read List ( search , Ġrole , Ġread List Id , Ġprincipal . user . get Authorized Library Ids ( null ), Ġpage Request ) ĊĠĠĠĠĠ Ġelse Ġ-> Ġrefer ential Repository . findAll Authors ByName ( search , Ġrole , Ġprincipal . user . get Authorized Library Ids ( null ), Ġpage Request ) ĊĠĠĠ Ġ}. map Ġ{ Ġit . to Dto () Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ GetMapping (" v 1 / authors / names ") ĊĠ Ġfun Ġget Authors Names ( ĊĠĠĠ Ġ@ Authentication Principal Ġprincipal : ĠKom ga Principal , ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" search ", ĠdefaultValue Ġ= Ġ"") Ġsearch : ĠString , ĊĠ Ġ): ĠList < String > Ġ= ĊĠĠĠ Ġrefer ential Repository . findAll Authors Names ByName ( search , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĊĠ Ġ@ GetMapping (" v 1 / authors / roles ") ĊĠ Ġfun Ġget Authors Roles ( ĊĠĠĠ Ġ@ Authentication Principal Ġprincipal : ĠKom ga Principal , ĊĠ Ġ): ĠList < String > Ġ= ĊĠĠĠ Ġrefer ential Repository . findAll Authors Roles ( principal . user . get Authorized Library Ids ( null )) ĊĊĠ Ġ@ GetMapping (" v 1 / genres ") ĊĠ Ġfun Ġget Gen res ( ĊĠĠĠ Ġ@ Authentication Principal Ġprincipal : ĠKom ga Principal , ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" library _ id ", Ġrequired Ġ= Ġfalse ) Ġlibrary Id : ĠString ?, ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" collection _ id ", Ġrequired Ġ= Ġfalse ) Ġcollection Id : ĠString ?, ĊĠ Ġ): ĠSet < String > Ġ= ĊĠĠĠ Ġwhen Ġ{ ĊĠĠĠĠĠ Ġlibrary Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Gen res By Library ( library Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġcollection Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Gen res By Collection ( collection Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġelse Ġ-> Ġrefer ential Repository . findAll Gen res ( principal . user . get Authorized Library Ids ( null )) ĊĠĠĠ Ġ} ĊĊĠ Ġ@ GetMapping (" v 1 / tags ") ĊĠ Ġfun Ġget Tags ( ĊĠĠĠ Ġ@ Authentication Principal Ġprincipal : ĠKom ga Principal , ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" library _ id ", Ġrequired Ġ= Ġfalse ) Ġlibrary Id : ĠString ?, ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" collection _ id ", Ġrequired Ġ= Ġfalse ) Ġcollection Id : ĠString ?, ĊĠ Ġ): ĠSet < String > Ġ= ĊĠĠĠ Ġwhen Ġ{ ĊĠĠĠĠĠ Ġlibrary Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Series And Book Tags By Library ( library Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġcollection Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Series And Book Tags By Collection ( collection Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġelse Ġ-> Ġrefer ential Repository . findAll Series And Book Tags ( principal . user . get Authorized Library Ids ( null )) ĊĠĠĠ Ġ} ĊĊĠ Ġ@ GetMapping (" v 1 / tags / book ") ĊĠ Ġfun Ġget Book Tags ( ĊĠĠĠ Ġ@ Authentication Principal Ġprincipal : ĠKom ga Principal , ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" series _ id ", Ġrequired Ġ= Ġfalse ) Ġseries Id : ĠString ?, ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" read list _ id ", Ġrequired Ġ= Ġfalse ) Ġread List Id : ĠString ?, ĊĠ Ġ): ĠSet < String > Ġ= ĊĠĠĠ Ġwhen Ġ{ ĊĠĠĠĠĠ Ġseries Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Book Tags By Series ( series Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġread List Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Book Tags By Read List ( read List Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġelse Ġ-> Ġrefer ential Repository . findAll Book Tags ( principal . user . get Authorized Library Ids ( null )) ĊĠĠĠ Ġ} ĊĊĠ Ġ@ GetMapping (" v 1 / tags / series ") ĊĠ Ġfun Ġget Series Tags ( ĊĠĠĠ Ġ@ Authentication Principal Ġprincipal : ĠKom ga Principal , ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" library _ id ", Ġrequired Ġ= Ġfalse ) Ġlibrary Id : ĠString ?, ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" collection _ id ", Ġrequired Ġ= Ġfalse ) Ġcollection Id : ĠString ?, ĊĠ Ġ): ĠSet < String > Ġ= ĊĠĠĠ Ġwhen Ġ{ ĊĠĠĠĠĠ Ġlibrary Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Series Tags By Library ( library Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġcollection Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Series Tags By Collection ( collection Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġelse Ġ-> Ġrefer ential Repository . findAll Series Tags ( principal . user . get Authorized Library Ids ( null )) ĊĠĠĠ Ġ} ĊĊĠ Ġ@ GetMapping (" v 1 / languages ") ĊĠ Ġfun Ġget Languages ( ĊĠĠĠ Ġ@ Authentication Principal Ġprincipal : ĠKom ga Principal , ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" library _ id ", Ġrequired Ġ= Ġfalse ) Ġlibrary Id : ĠString ?, ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" collection _ id ", Ġrequired Ġ= Ġfalse ) Ġcollection Id : ĠString ?, ĊĠ Ġ): ĠSet < String > Ġ= ĊĠĠĠ Ġwhen Ġ{ ĊĠĠĠĠĠ Ġlibrary Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Language sBy Library ( library Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġcollection Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Language sBy Collection ( collection Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġelse Ġ-> Ġrefer ential Repository . findAll Languages ( principal . user . get Authorized Library Ids ( null )) ĊĠĠĠ Ġ} ĊĊĠ Ġ@ GetMapping (" v 1 / publish ers ") ĊĠ Ġfun Ġget Publish ers ( ĊĠĠĠ Ġ@ Authentication Principal Ġprincipal : ĠKom ga Principal , ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" library _ id ", Ġrequired Ġ= Ġfalse ) Ġlibrary Id : ĠString ?, ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" collection _ id ", Ġrequired Ġ= Ġfalse ) Ġcollection Id : ĠString ?, ĊĠ Ġ): ĠSet < String > Ġ= ĊĠĠĠ Ġwhen Ġ{ ĊĠĠĠĠĠ Ġlibrary Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Publish ers By Library ( library Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġcollection Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Publish ers By Collection ( collection Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġelse Ġ-> Ġrefer ential Repository . findAll Publish ers ( principal . user . get Authorized Library Ids ( null )) ĊĠĠĠ Ġ} ĊĊĠ Ġ@ GetMapping (" v 1 / age - ratings ") ĊĠ Ġfun Ġget Age Ratings ( ĊĠĠĠ Ġ@ Authentication Principal Ġprincipal : ĠKom ga Principal , ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" library _ id ", Ġrequired Ġ= Ġfalse ) Ġlibrary Id : ĠString ?, ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" collection _ id ", Ġrequired Ġ= Ġfalse ) Ġcollection Id : ĠString ?, ĊĠ Ġ): ĠSet < String > Ġ= ĊĠĠĠ Ġwhen Ġ{ ĊĠĠĠĠĠ Ġlibrary Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Age Rating sBy Library ( library Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġcollection Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Age Rating sBy Collection ( collection Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġelse Ġ-> Ġrefer ential Repository . findAll Age Ratings ( principal . user . get Authorized Library Ids ( null )) ĊĠĠĠ Ġ}. map Ġ{ Ġit ?. toString () Ġ?: Ġ" None " Ġ}. toSet () ĊĊĠ Ġ@ GetMapping (" v 1 / series / release - dates ") ĊĠ Ġfun Ġget Series Release Dates ( ĊĠĠĠ Ġ@ Authentication Principal Ġprincipal : ĠKom ga Principal , ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" library _ id ", Ġrequired Ġ= Ġfalse ) Ġlibrary Id : ĠString ?, ĊĠĠĠ Ġ@ RequestParam ( name Ġ= Ġ" collection _ id ", Ġrequired Ġ= Ġfalse ) Ġcollection Id : ĠString ?, ĊĠ Ġ): ĠSet < String > Ġ= ĊĠĠĠ Ġwhen Ġ{ ĊĠĠĠĠĠ Ġlibrary Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Series Release Dates By Library ( library Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġcollection Id Ġ!= Ġnull Ġ-> Ġrefer ential Repository . findAll Series Release Dates By Collection ( collection Id , Ġprincipal . user . get Authorized Library Ids ( null )) ĊĠĠĠĠĠ Ġelse Ġ-> Ġrefer ential Repository . findAll Series Release Dates ( principal . user . get Authorized Library Ids ( null )) ĊĠĠĠ Ġ}. map Ġ{ Ġit . year . toString () Ġ}. toSet () Ċ } Ċ