This repository was archived by the owner on Oct 21, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
src/main/kotlin/com/parnote/db Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,12 @@ interface ShareLinkDao : Dao<ShareLink> {
2626 handler : (noteID: Int? , asyncResult: AsyncResult <* >) -> Unit
2727 )
2828
29+ fun getTokenIDByNoteID (
30+ noteID : Int ,
31+ sqlConnection : SQLConnection ,
32+ handler : (tokenID: Int? , asyncResult: AsyncResult <* >) -> Unit
33+ )
34+
2935 fun isLinkExistsByNoteID (
3036 noteID : Int ,
3137 sqlConnection : SQLConnection ,
Original file line number Diff line number Diff line change @@ -85,6 +85,24 @@ class ShareLinkDaoImpl(override val tableName: String = "share_link") : DaoImpl(
8585 }
8686 }
8787
88+ override fun getTokenIDByNoteID (
89+ noteID : Int ,
90+ sqlConnection : SQLConnection ,
91+ handler : (tokenID: Int? , asyncResult: AsyncResult <* >) -> Unit
92+ ) {
93+ val query =
94+ " SELECT `token_id` FROM `${getTablePrefix() + tableName} ` WHERE `note_id` = ?"
95+
96+ sqlConnection.queryWithParams(query, JsonArray ().add(noteID)) { queryResult ->
97+ if (queryResult.succeeded()) {
98+ val row = queryResult.result().results[0 ]
99+
100+ handler.invoke(row.getInteger(0 ), queryResult)
101+ } else
102+ handler.invoke(null , queryResult)
103+ }
104+ }
105+
88106 override fun isLinkExistsByNoteID (
89107 noteID : Int ,
90108 sqlConnection : SQLConnection ,
You can’t perform that action at this time.
0 commit comments