Add items that are related to the deleted meta (#562)

This commit is contained in:
Mitchell Syer
2023-05-27 14:09:47 -04:00
committed by GitHub
parent 1e82c879bf
commit 241abc3956
3 changed files with 29 additions and 12 deletions
@@ -6,8 +6,10 @@ import org.jetbrains.exposed.sql.deleteWhere
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.graphql.types.CategoryMetaType
import suwayomi.tachidesk.graphql.types.CategoryType
import suwayomi.tachidesk.manga.impl.Category
import suwayomi.tachidesk.manga.model.table.CategoryMetaTable
import suwayomi.tachidesk.manga.model.table.CategoryTable
/**
* TODO Mutations
@@ -43,26 +45,31 @@ class CategoryMutation {
)
data class DeleteCategoryMetaPayload(
val clientMutationId: String?,
val meta: CategoryMetaType?
val meta: CategoryMetaType?,
val category: CategoryType
)
fun deleteCategoryMeta(
input: DeleteCategoryMetaInput
): DeleteCategoryMetaPayload {
val (clientMutationId, categoryId, key) = input
val meta = transaction {
val (meta, category) = transaction {
val meta = CategoryMetaTable.select { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) }
.firstOrNull()
CategoryMetaTable.deleteWhere { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) }
val category= transaction {
CategoryType(CategoryTable.select { CategoryTable.id eq categoryId }.first())
}
if (meta != null) {
CategoryMetaType(meta)
} else {
null
}
} to category
}
return DeleteCategoryMetaPayload(clientMutationId, meta)
return DeleteCategoryMetaPayload(clientMutationId, meta, category)
}
}
@@ -156,26 +156,31 @@ class ChapterMutation {
)
data class DeleteChapterMetaPayload(
val clientMutationId: String?,
val meta: ChapterMetaType?
val meta: ChapterMetaType?,
val chapter: ChapterType
)
fun deleteChapterMeta(
input: DeleteChapterMetaInput
): DeleteChapterMetaPayload {
val (clientMutationId, chapterId, key) = input
val meta = transaction {
val (meta, chapter) = transaction {
val meta = ChapterMetaTable.select { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) }
.firstOrNull()
ChapterMetaTable.deleteWhere { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) }
val chapter= transaction {
ChapterType(ChapterTable.select { ChapterTable.id eq chapterId }.first())
}
if (meta != null) {
ChapterMetaType(meta)
} else {
null
}
} to chapter
}
return DeleteChapterMetaPayload(clientMutationId, meta)
return DeleteChapterMetaPayload(clientMutationId, meta, chapter)
}
}
@@ -140,26 +140,31 @@ class MangaMutation {
)
data class DeleteMangaMetaPayload(
val clientMutationId: String?,
val meta: MangaMetaType?
val meta: MangaMetaType?,
val manga: MangaType
)
fun deleteMangaMeta(
input: DeleteMangaMetaInput
): DeleteMangaMetaPayload {
val (clientMutationId, mangaId, key) = input
val meta = transaction {
val (meta, manga) = transaction {
val meta = MangaMetaTable.select { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) }
.firstOrNull()
MangaMetaTable.deleteWhere { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) }
val manga = transaction {
MangaType(MangaTable.select { MangaTable.id eq mangaId }.first())
}
if (meta != null) {
MangaMetaType(meta)
} else {
null
}
} to manga
}
return DeleteMangaMetaPayload(clientMutationId, meta)
return DeleteMangaMetaPayload(clientMutationId, meta, manga)
}
}