package Ġs jj . no vel . data . source . local Ċ Ċ import Ġandroidx . paging . DataSource Ċ import Ġandroidx . room .* Ċ import Ġio . reactivex . Flow able Ċ import Ġs jj . no vel . model . Book Ċ import Ġs jj . no vel . model . Book Source Record Ċ import Ġs jj . no vel . model . Chapter ĊĊ Ċ @ Dao Ċ interface ĠBook Dao Ġ{ ĊĠĠĠ Ġ@ Insert ( on Conflict Ġ= ĠOn Conflict Strategy . REPLACE ) ĊĠĠĠ Ġfun Ġinsert Record And Books ( book Source : ĠBook Source Record , Ġbooks : ĠList < Book >) ĊĊĠĠĠ Ġ@ Query (" update ĠBook Source Record Ġset Ġsequence =: sequence Ġwhere Ġbook Name =: book Name Ġand Ġauthor =: author ") ĊĠĠĠ Ġfun Ġupdate Book Source Record Seq ( sequence : ĠInt , Ġbook Name : ĠString , Ġauthor : ĠString ) ĊĊĠĠĠ Ġ@ Query (" SELECT ĠMAX ( sequence ) ĠFROM ĠBook Source Record ") ĊĠĠĠ Ġfun Ġget Book Source Record Max Seq (): ĠInt ĊĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom ĠBook Ġwhere Ġurl Ġin Ġ( select Ġbook Url Ġfrom ĠBook Source Record )") ĊĠĠĠ Ġfun Ġget Books In Record (): ĠFlow able < List < Book >> ĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom ĠBook Ġwhere Ġurl =: url ") ĊĠĠĠ Ġfun Ġget Book ( url : ĠString ): ĠFlow able < Book > ĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom ĠBook Ġwhere Ġname =: name Ġand Ġauthor =: author ") ĊĠĠĠ Ġfun Ġget Book Source ( name : ĠString , Ġauthor : ĠString ): ĠFlow able < List < Book >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM ĠBook ĠWHERE Ġurl Ġ= Ġ( select Ġbook Url Ġfrom ĠBook Source Record Ġwhere Ġbook Name =: name Ġand Ġauthor =: author )") ĊĠĠĠ Ġfun Ġget Book In Book Source ( name : ĠString , Ġauthor : ĠString ): ĠFlow able < Book > ĊĊĠĠĠ Ġ@ Update ( on Conflict Ġ= ĠOn Conflict Strategy . REPLACE ) ĊĠĠĠ Ġfun Ġupdate Book ( book : ĠBook ) ĊĊĠĠĠ Ġ@ Insert ( on Conflict Ġ= ĠOn Conflict Strategy . IGNORE ) ĊĠĠĠ Ġfun Ġinsert Chapter s ( book : ĠList < Chapter >) ĊĊĠĠĠ Ġ@ Query (" update ĠChapter Ġset Ġ` index ` =: index Ġwhere Ġurl =: chapter Id ") ĊĠĠĠ Ġfun Ġupdate Chapter Index ( index : ĠInt , Ġchapter Id : ĠString ) ĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom ĠChapter Ġwhere Ġbook Url =: book Url Ġorder Ġby Ġ` index ` ") ĊĠĠĠ Ġfun Ġget Chapter s ( book Url : ĠString ): ĠDataSource . Factory < Int , ĠChapter > ĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom ĠChapter Ġwhere Ġurl =: url ") ĊĠĠĠ Ġfun Ġget Chapter ( url : ĠString ): ĠChapter ĊĊĠĠĠ Ġ@ Update ( on Conflict Ġ= ĠOn Conflict Strategy . REPLACE ) ĊĠĠĠ Ġfun Ġupdate Chapter ( chapter : ĠChapter ) ĊĊĠĠĠ Ġ@ Query (" delete Ġfrom ĠBook Source Record Ġwhere Ġbook Name =: book Name Ġand Ġauthor =: author ") ĊĠĠĠ Ġfun Ġdelete Book ( book Name : ĠString , Ġauthor : ĠString ): ĠInt ĊĊĠĠĠ Ġ@ Query (" update ĠBook Source Record Ġset Ġbook Url =: url Ġwhere Ġbook Name =: name Ġand Ġauthor =: author ") ĊĠĠĠ Ġfun Ġupdate Book Source ( name : ĠString , Ġauthor : ĠString , Ġurl : ĠString ): ĠInt ĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom ĠBook Source Record Ġwhere Ġbook Name =: name Ġand Ġauthor =: author ") ĊĠĠĠ Ġfun Ġget Book Source Record ( name : ĠString , Ġauthor : ĠString ): ĠFlow able < Book Source Record > ĊĊĠĠĠ Ġ@ Query (" update ĠBook Source Record Ġset Ġread Index =: index , chapter Name =: chapter Name , is Through =: is Through , page Pos =: page Pos Ġwhere Ġbook Name =: name Ġand Ġauthor =: author ") ĊĠĠĠ Ġfun Ġset Read Index ( name : ĠString , Ġauthor : ĠString , Ġindex : ĠInt , Ġchapter Name : ĠString , Ġpage Pos : ĠInt , Ġis Through : ĠBoolean ): ĠInt ĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom ĠChapter Ġwhere Ġbook Url =: book Url Ġorder Ġby Ġ` index ` Ġdesc Ġlimit Ġ 1 ") ĊĠĠĠ Ġfun Ġget Latest Chapter ( book Url : ĠString ): ĠChapter ĊĊĠĠĠ Ġ@ Query (" select Ġurl , book Url , ` index `, chapter Name , is Load Success Ġfrom ĠChapter Ġwhere Ġbook Url =: book Url Ġand Ġis Load Success = 0 Ġorder Ġby Ġ` index ` ") ĊĠĠĠ Ġfun Ġget Un Load Chapter s ( book Url : ĠString ): ĠList < Chapter > ĊĊĠĠĠ Ġ@ Query (" select Ġurl , book Url , ` index `, chapter Name , is Load Success Ġfrom ĠChapter Ġwhere Ġbook Url =: book Url Ġorder Ġby Ġ` index ` ") ĊĠĠĠ Ġfun Ġget Chapter Intro ( book Url : ĠString ): ĠFlow able < List < Chapter >> ĊĊĠĠĠ Ġ@ Query (" select Ġurl Ġfrom ĠChapter Ġwhere Ġbook Url =: book Url ") ĊĠĠĠ Ġfun Ġget Chapter Ids ( book Url : ĠString ): ĠList < String > ĊĊĠĠĠ Ġ@ Query (" delete Ġfrom Ġchapter Ġwhere Ġurl =: url ") ĊĠĠĠ Ġfun Ġdelete Chapter ( url : ĠString ) Ċ }