package Ġcom . net no vel reader . repo . db Ċ Ċ import Ġandroidx . paging . DataSource Ċ import Ġandroidx . room .* Ċ import Ġio . reactivex . Maybe Ċ import Ġio . reactivex . Single Ċ Ċ @ Dao Ċ interface ĠBook Info Dao Ġ{ ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ Reader Database . TABLE _ SHE LF } Ġorder Ġby Ġ${ Reader Database . ORDER _ NUM } ĠDESC ") ĊĠĠĠ Ġfun Ġall Books (): ĠDataSource . Factory < Int , ĠBook Info Entity > ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ Reader Database . TABLE _ SHE LF } Ġorder Ġby Ġ${ Reader Database . ORDER _ NUM } ĠDESC ") ĊĠĠĠ Ġfun ĠgetAll (): ĠSingle < List < Book Info Entity >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġ${ Reader Database . TABLE _ SHE LF } ĠWHERE Ġ${ Reader Database . BOOK NAME } ĠLIKE Ġ: book name ") ĊĠĠĠ Ġfun Ġget Book Info ( book name : ĠString ): ĠSingle < Book Info Entity > ĊĊĠĠĠ Ġ@ Query (" SELECT Ġmax (${ Reader Database . ORDER _ NUM }) Ġfrom Ġ${ Reader Database . TABLE _ SHE LF }") ĊĠĠĠ Ġfun ĠgetMax Order Num (): ĠMaybe < Int > ĊĊĠĠĠ Ġ@ Query (" update Ġ${ Reader Database . TABLE _ SHE LF } Ġset Ġ${ Reader Database . ORDER _ NUM }= (" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" select Ġ* Ġfrom Ġ( select Ġif null ((" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" select Ġmax (${ Reader Database . ORDER _ NUM }) Ġfrom Ġ${ Reader Database . TABLE _ SHE LF }), Ġ 0 )) Ġas Ġt " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ") Ġ+ Ġ 1 , Ġ${ Reader Database . HAS _ UPDATE } Ġ= Ġ 0 Ġwhere Ġ${ Reader Database . BOOK NAME } ĠLIKE Ġ: book name ; ") ĊĠĠĠ Ġfun Ġset Max Order To Book ( book name : ĠString ) ĊĊĠĠĠ Ġ@ Query (" update Ġ${ Reader Database . TABLE _ SHE LF } Ġset Ġ${ Reader Database . READ _ RECORD } =: record Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" WHERE Ġ${ Reader Database . BOOK NAME } ĠLIKE Ġ: book name ") ĊĠĠĠ Ġfun Ġset Record ( book name : ĠString , Ġrecord : ĠString ) ĊĊĠĠĠ Ġ@ Query (" DELETE ĠFROM Ġ${ Reader Database . TABLE _ SHE LF } ĠWHERE Ġ${ Reader Database . BOOK NAME } Ġ= Ġ: book name ") ĊĠĠĠ Ġfun Ġdelete ( book name : ĠString ) ĊĊĠĠĠ Ġ@ Insert ( on Conflict Ġ= ĠOn Conflict Strategy . REPLACE ) ĊĠĠĠ Ġfun Ġinsert ( var arg Ġentities : ĠBook Info Entity ) ĊĊĠĠĠ Ġ@ Delete ĊĠĠĠ Ġfun Ġdelete ( entity : ĠBook Info Entity ) ĊĊĠĠĠ Ġ@ Update ĊĠĠĠ Ġfun Ġupdate ( entity : ĠBook Info Entity ) Ċ }