备份代码
This commit is contained in:
parent
896df778c6
commit
72ba4fb18c
|
@ -5,6 +5,7 @@ import echo.org.domain.Folder
|
||||||
import echo.org.domain.FolderRepository
|
import echo.org.domain.FolderRepository
|
||||||
import echo.org.domain.FolderVO
|
import echo.org.domain.FolderVO
|
||||||
import echo.org.instructure.DatabaseSingleton.dbQuery
|
import echo.org.instructure.DatabaseSingleton.dbQuery
|
||||||
|
import echo.org.instructure.FolderDocuments.documentId
|
||||||
import echo.org.instructure.Folders.id
|
import echo.org.instructure.Folders.id
|
||||||
import echo.org.instructure.Folders.parentFolderId
|
import echo.org.instructure.Folders.parentFolderId
|
||||||
import org.jetbrains.exposed.sql.*
|
import org.jetbrains.exposed.sql.*
|
||||||
|
@ -45,6 +46,13 @@ object Folders : Table() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object FolderDocuments : Table() {
|
||||||
|
val folderId = long("folder_id").references(Folders.id, onDelete = ReferenceOption.CASCADE)
|
||||||
|
val documentId = long("document_id").references(Documents.id, onDelete = ReferenceOption.CASCADE)
|
||||||
|
override val primaryKey = PrimaryKey(folderId, documentId)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class FolderRepositoryImpl : FolderRepository {
|
class FolderRepositoryImpl : FolderRepository {
|
||||||
override suspend fun createFolder(folderVO: FolderVO): Folder = dbQuery {
|
override suspend fun createFolder(folderVO: FolderVO): Folder = dbQuery {
|
||||||
Folders.insert {
|
Folders.insert {
|
||||||
|
@ -95,7 +103,16 @@ class FolderRepositoryImpl : FolderRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getDocumentsInFolder(folderId: Long): List<Document> = dbQuery {
|
override suspend fun getDocumentsInFolder(folderId: Long): List<Document> = dbQuery {
|
||||||
TODO("Not yet implemented")
|
val toList = FolderDocuments.selectAll().where {
|
||||||
|
FolderDocuments.folderId eq folderId
|
||||||
|
}.map {
|
||||||
|
it[documentId]
|
||||||
|
}.toList()
|
||||||
|
Documents.selectAll().where {
|
||||||
|
Documents.id inList toList
|
||||||
|
}.map {
|
||||||
|
Documents.toDocument(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun addDocumentToFolder(folderId: Long, documentId: Long) = dbQuery {
|
override suspend fun addDocumentToFolder(folderId: Long, documentId: Long) = dbQuery {
|
||||||
|
|
Loading…
Reference in New Issue