mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-03 19:04:39 -05:00
Add items that are related to the deleted meta (#562)
This commit is contained in:
@@ -6,8 +6,10 @@ import org.jetbrains.exposed.sql.deleteWhere
|
|||||||
import org.jetbrains.exposed.sql.select
|
import org.jetbrains.exposed.sql.select
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
import suwayomi.tachidesk.graphql.types.CategoryMetaType
|
import suwayomi.tachidesk.graphql.types.CategoryMetaType
|
||||||
|
import suwayomi.tachidesk.graphql.types.CategoryType
|
||||||
import suwayomi.tachidesk.manga.impl.Category
|
import suwayomi.tachidesk.manga.impl.Category
|
||||||
import suwayomi.tachidesk.manga.model.table.CategoryMetaTable
|
import suwayomi.tachidesk.manga.model.table.CategoryMetaTable
|
||||||
|
import suwayomi.tachidesk.manga.model.table.CategoryTable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Mutations
|
* TODO Mutations
|
||||||
@@ -43,26 +45,31 @@ class CategoryMutation {
|
|||||||
)
|
)
|
||||||
data class DeleteCategoryMetaPayload(
|
data class DeleteCategoryMetaPayload(
|
||||||
val clientMutationId: String?,
|
val clientMutationId: String?,
|
||||||
val meta: CategoryMetaType?
|
val meta: CategoryMetaType?,
|
||||||
|
val category: CategoryType
|
||||||
)
|
)
|
||||||
fun deleteCategoryMeta(
|
fun deleteCategoryMeta(
|
||||||
input: DeleteCategoryMetaInput
|
input: DeleteCategoryMetaInput
|
||||||
): DeleteCategoryMetaPayload {
|
): DeleteCategoryMetaPayload {
|
||||||
val (clientMutationId, categoryId, key) = input
|
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) }
|
val meta = CategoryMetaTable.select { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) }
|
||||||
.firstOrNull()
|
.firstOrNull()
|
||||||
|
|
||||||
CategoryMetaTable.deleteWhere { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) }
|
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) {
|
if (meta != null) {
|
||||||
CategoryMetaType(meta)
|
CategoryMetaType(meta)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
} to category
|
||||||
}
|
}
|
||||||
|
|
||||||
return DeleteCategoryMetaPayload(clientMutationId, meta)
|
return DeleteCategoryMetaPayload(clientMutationId, meta, category)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,26 +156,31 @@ class ChapterMutation {
|
|||||||
)
|
)
|
||||||
data class DeleteChapterMetaPayload(
|
data class DeleteChapterMetaPayload(
|
||||||
val clientMutationId: String?,
|
val clientMutationId: String?,
|
||||||
val meta: ChapterMetaType?
|
val meta: ChapterMetaType?,
|
||||||
|
val chapter: ChapterType
|
||||||
)
|
)
|
||||||
fun deleteChapterMeta(
|
fun deleteChapterMeta(
|
||||||
input: DeleteChapterMetaInput
|
input: DeleteChapterMetaInput
|
||||||
): DeleteChapterMetaPayload {
|
): DeleteChapterMetaPayload {
|
||||||
val (clientMutationId, chapterId, key) = input
|
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) }
|
val meta = ChapterMetaTable.select { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) }
|
||||||
.firstOrNull()
|
.firstOrNull()
|
||||||
|
|
||||||
ChapterMetaTable.deleteWhere { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) }
|
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) {
|
if (meta != null) {
|
||||||
ChapterMetaType(meta)
|
ChapterMetaType(meta)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
} to chapter
|
||||||
}
|
}
|
||||||
|
|
||||||
return DeleteChapterMetaPayload(clientMutationId, meta)
|
return DeleteChapterMetaPayload(clientMutationId, meta, chapter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,26 +140,31 @@ class MangaMutation {
|
|||||||
)
|
)
|
||||||
data class DeleteMangaMetaPayload(
|
data class DeleteMangaMetaPayload(
|
||||||
val clientMutationId: String?,
|
val clientMutationId: String?,
|
||||||
val meta: MangaMetaType?
|
val meta: MangaMetaType?,
|
||||||
|
val manga: MangaType
|
||||||
)
|
)
|
||||||
fun deleteMangaMeta(
|
fun deleteMangaMeta(
|
||||||
input: DeleteMangaMetaInput
|
input: DeleteMangaMetaInput
|
||||||
): DeleteMangaMetaPayload {
|
): DeleteMangaMetaPayload {
|
||||||
val (clientMutationId, mangaId, key) = input
|
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) }
|
val meta = MangaMetaTable.select { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) }
|
||||||
.firstOrNull()
|
.firstOrNull()
|
||||||
|
|
||||||
MangaMetaTable.deleteWhere { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) }
|
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) {
|
if (meta != null) {
|
||||||
MangaMetaType(meta)
|
MangaMetaType(meta)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
} to manga
|
||||||
}
|
}
|
||||||
|
|
||||||
return DeleteMangaMetaPayload(clientMutationId, meta)
|
return DeleteMangaMetaPayload(clientMutationId, meta, manga)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user