From d3af59177a73918e5e4cb30a840cf20476436d9c Mon Sep 17 00:00:00 2001 From: Andrea Brighi Date: Mon, 15 May 2023 23:08:01 +0200 Subject: [PATCH] docs(desktop): add query docs --- .../desktopdata/db/DesktopDAO.kt | 72 ++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/desktopData/src/main/kotlin/com/intelligentbackpack/desktopdata/db/DesktopDAO.kt b/desktopData/src/main/kotlin/com/intelligentbackpack/desktopdata/db/DesktopDAO.kt index e6a6e9d3..5708e72a 100644 --- a/desktopData/src/main/kotlin/com/intelligentbackpack/desktopdata/db/DesktopDAO.kt +++ b/desktopData/src/main/kotlin/com/intelligentbackpack/desktopdata/db/DesktopDAO.kt @@ -58,43 +58,108 @@ internal interface DesktopDAO { @Insert(onConflict = OnConflictStrategy.ABORT) fun addSchoolSupply(schoolSupply: SchoolSupply) + /** + * Add a wrote relation to the database + * + * @param wrote the wrote relation to add + */ @Insert(onConflict = OnConflictStrategy.IGNORE) fun addWrote(wrote: Wrote) + /** + * Change the field in_backpack of a school supply to true + * + * @param rfid the rfid of the school supplies to put in the backpack + */ @Query("UPDATE school_supplies SET in_backpack = 1 WHERE rfid IN (:rfid)") fun putSchoolSuppliesInBackpack(rfid: Set) + /** + * Change the field in_backpack of a school supply to false + * + * @param rfid the rfid of the school supplies to take from the backpack + */ @Query("UPDATE school_supplies SET in_backpack = 0 WHERE rfid IN (:rfid)") fun takeSchoolSuppliesFromBackpack(rfid: Set) + /** + * Get all the authors + * + * @return the authors + */ @Query("SELECT * FROM Authors WHERE name = :name") fun getAuthors(name: String): List + /** + * Get an author from its id + * + * @param authorId the author id + * @return the author + */ @Query("SELECT * FROM Authors WHERE author_id = :authorId") fun getAuthor(authorId: Long): Author + /** + * Get all school supply types + * + * @return the school supply types + */ @Query("SELECT * FROM School_supply_types") fun getSchoolSupplyTypes(): List + /** + * Get a school supply type from its name + * + * @param type the school supply type name + * @return the school supply type + */ @Query("SELECT * FROM School_supply_types WHERE type = :type") fun getSchoolSupplyTypesFromName(type: String): List + /** + * Get all books + * + * @return the books + */ @Transaction @Query("SELECT * FROM Books") fun getBooks(): List + /** + * Get a book from its isbn + * + * @param isbn the book isbn + * @return the book + */ @Transaction @Query("SELECT * FROM Books WHERE isbn = :isbn") fun getBook(isbn: String): BookWithAuthors? + /** + * Get all book copy from the rfid + * + * @param rfid the book copy rfid + * @return the book copy + */ @Transaction @Query("SELECT * FROM Book_copies WHERE rfid = :rfid") - fun getBookCopy(rfid: String): List + fun getBookCopy(rfid: String): BookCopyWithAuthors? + /** + * Get all book copies in the backpack + * + * @return the book copies in the backpack + */ @Transaction @Query("SELECT * FROM Book_copies WHERE in_backpack = 1") fun getBookCopiesInBackpack(): List + /** + * Get the school supply type from the rfid + * + * @param rfid the school supply + * @return the school supply type + */ @Transaction @Query( "SELECT School_supply_types.type" + @@ -103,6 +168,11 @@ internal interface DesktopDAO { ) fun getSchoolSupplyType(rfid: String): String? + /** + * Get all school supplies' rfid + * + * @return the school supplies' rfid + */ @Transaction @Query("SELECT rfid FROM School_supplies") fun getAllSchoolSupplyRfid(): List