mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2025-02-04 11:26:22 +01:00
refactor database classes
This commit is contained in:
parent
a01ef75822
commit
bb94e638cb
@ -1,13 +1,10 @@
|
||||
package eu.kanade.tachiyomi.extension.api
|
||||
|
||||
//import android.content.Context
|
||||
import com.github.salomonbrys.kotson.get
|
||||
import com.github.salomonbrys.kotson.int
|
||||
//import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.extension.model.Extension
|
||||
import eu.kanade.tachiyomi.extension.model.LoadResult
|
||||
import eu.kanade.tachiyomi.extension.util.ExtensionLoader
|
||||
import ir.armor.tachidesk.database.model.ExtensionDataClass
|
||||
import ir.armor.tachidesk.database.dataclass.ExtensionDataClass
|
||||
//import kotlinx.coroutines.Dispatchers
|
||||
//import kotlinx.coroutines.withContext
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
@ -15,7 +12,6 @@ import kotlinx.serialization.json.int
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
//import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Date
|
||||
|
||||
internal class ExtensionGithubApi {
|
||||
|
||||
|
@ -8,8 +8,12 @@ import eu.kanade.tachiyomi.source.SourceFactory
|
||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import io.javalin.Javalin
|
||||
import ir.armor.tachidesk.database.dataclass.ExtensionDataClass
|
||||
import ir.armor.tachidesk.database.dataclass.SourceDataClass
|
||||
import ir.armor.tachidesk.database.entity.ExtensionEntity
|
||||
import ir.armor.tachidesk.database.entity.SourceEntity
|
||||
import ir.armor.tachidesk.database.makeDataBaseTables
|
||||
import ir.armor.tachidesk.database.model.*
|
||||
import ir.armor.tachidesk.database.table.*
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import okhttp3.Request
|
||||
import okio.buffer
|
||||
|
@ -1,8 +1,8 @@
|
||||
package ir.armor.tachidesk.database
|
||||
|
||||
import ir.armor.tachidesk.Config
|
||||
import ir.armor.tachidesk.database.model.ExtensionsTable
|
||||
import ir.armor.tachidesk.database.model.SourcesTable
|
||||
import ir.armor.tachidesk.database.table.ExtensionsTable
|
||||
import ir.armor.tachidesk.database.table.SourcesTable
|
||||
import org.jetbrains.exposed.sql.Database
|
||||
import org.jetbrains.exposed.sql.SchemaUtils
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
|
@ -0,0 +1,14 @@
|
||||
package ir.armor.tachidesk.database.dataclass
|
||||
|
||||
data class ExtensionDataClass(
|
||||
val name: String,
|
||||
val pkgName: String,
|
||||
val versionName: String,
|
||||
val versionCode: Int,
|
||||
val lang: String,
|
||||
val isNsfw: Boolean,
|
||||
val apkName: String,
|
||||
val iconUrl: String,
|
||||
val installed: Boolean,
|
||||
val classFQName: String,
|
||||
)
|
@ -0,0 +1,9 @@
|
||||
package ir.armor.tachidesk.database.dataclass
|
||||
|
||||
data class SourceDataClass(
|
||||
val id: Long,
|
||||
val name: String,
|
||||
val lang: String,
|
||||
val iconUrl: String,
|
||||
val supportsLatest: Boolean
|
||||
)
|
@ -0,0 +1,21 @@
|
||||
package ir.armor.tachidesk.database.entity
|
||||
|
||||
import ir.armor.tachidesk.database.table.ExtensionsTable
|
||||
import org.jetbrains.exposed.dao.IntEntity
|
||||
import org.jetbrains.exposed.dao.IntEntityClass
|
||||
import org.jetbrains.exposed.dao.id.EntityID
|
||||
|
||||
class ExtensionEntity(id: EntityID<Int>) : IntEntity(id) {
|
||||
companion object : IntEntityClass<ExtensionEntity>(ExtensionsTable)
|
||||
|
||||
var name by ExtensionsTable.name
|
||||
var pkgName by ExtensionsTable.pkgName
|
||||
var versionName by ExtensionsTable.versionName
|
||||
var versionCode by ExtensionsTable.versionCode
|
||||
var lang by ExtensionsTable.lang
|
||||
var isNsfw by ExtensionsTable.isNsfw
|
||||
var apkName by ExtensionsTable.apkName
|
||||
var iconUrl by ExtensionsTable.iconUrl
|
||||
var installed by ExtensionsTable.installed
|
||||
var classFQName by ExtensionsTable.classFQName
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package ir.armor.tachidesk.database.entity
|
||||
|
||||
import ir.armor.tachidesk.database.table.SourcesTable
|
||||
import org.jetbrains.exposed.dao.IntEntity
|
||||
import org.jetbrains.exposed.dao.IntEntityClass
|
||||
import org.jetbrains.exposed.dao.id.EntityID
|
||||
|
||||
class SourceEntity(id: EntityID<Int>) : IntEntity(id) {
|
||||
companion object : IntEntityClass<SourceEntity>(SourcesTable)
|
||||
|
||||
var sourceId by SourcesTable.sourceId
|
||||
var name by SourcesTable.name
|
||||
var lang by SourcesTable.lang
|
||||
var extension by ExtensionEntity referencedOn SourcesTable.extension
|
||||
var partOfFactorySource by SourcesTable.partOfFactorySource
|
||||
var positionInFactorySource by SourcesTable.positionInFactorySource
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package ir.armor.tachidesk.database.model
|
||||
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import org.jetbrains.exposed.dao.IntEntity
|
||||
import org.jetbrains.exposed.dao.IntEntityClass
|
||||
import org.jetbrains.exposed.dao.id.EntityID
|
||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
||||
import org.jetbrains.exposed.sql.Column
|
||||
import org.jetbrains.exposed.sql.Table
|
||||
|
||||
|
||||
object ExtensionsTable : IntIdTable() {
|
||||
val name = varchar("name", 128)
|
||||
val pkgName = varchar("pkg_name", 128)
|
||||
val versionName = varchar("version_name", 16)
|
||||
val versionCode = integer("version_code")
|
||||
val lang = varchar("lang", 5)
|
||||
val isNsfw = bool("is_nsfw")
|
||||
val apkName = varchar("apk_name", 1024)
|
||||
val iconUrl = varchar("icon_url", 2048)
|
||||
|
||||
val installed = bool("installed").default(false)
|
||||
val classFQName = varchar("class_name", 256).default("") // fully qualified name
|
||||
}
|
||||
|
||||
data class ExtensionDataClass(
|
||||
val name: String,
|
||||
val pkgName: String,
|
||||
val versionName: String,
|
||||
val versionCode: Int,
|
||||
val lang: String,
|
||||
val isNsfw: Boolean,
|
||||
val apkName: String,
|
||||
val iconUrl: String,
|
||||
val installed: Boolean,
|
||||
val classFQName: String,
|
||||
)
|
||||
|
||||
class ExtensionEntity(id: EntityID<Int>) : IntEntity(id) {
|
||||
companion object : IntEntityClass<ExtensionEntity>(ExtensionsTable)
|
||||
|
||||
var name by ExtensionsTable.name
|
||||
var pkgName by ExtensionsTable.pkgName
|
||||
var versionName by ExtensionsTable.versionName
|
||||
var versionCode by ExtensionsTable.versionCode
|
||||
var lang by ExtensionsTable.lang
|
||||
var isNsfw by ExtensionsTable.isNsfw
|
||||
var apkName by ExtensionsTable.apkName
|
||||
var iconUrl by ExtensionsTable.iconUrl
|
||||
var installed by ExtensionsTable.installed
|
||||
var classFQName by ExtensionsTable.classFQName
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package ir.armor.tachidesk.database.model
|
||||
|
||||
import org.jetbrains.exposed.dao.*
|
||||
import org.jetbrains.exposed.dao.id.EntityID
|
||||
import org.jetbrains.exposed.dao.id.IdTable
|
||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
||||
import org.jetbrains.exposed.sql.Column
|
||||
import org.jetbrains.exposed.sql.Table
|
||||
|
||||
object SourcesTable : IntIdTable() {
|
||||
val sourceId = long("source_id")
|
||||
val name = varchar("name", 128)
|
||||
val lang = varchar("lang", 5)
|
||||
val extension = reference("extension", ExtensionsTable)
|
||||
val partOfFactorySource = bool("part_of_factory_source").default(false)
|
||||
val positionInFactorySource = integer("position_in_factory_source").nullable()
|
||||
}
|
||||
|
||||
data class SourceDataClass(
|
||||
val id: Long,
|
||||
val name: String,
|
||||
val lang: String,
|
||||
val iconUrl: String,
|
||||
val supportsLatest: Boolean
|
||||
)
|
||||
|
||||
class SourceEntity(id: EntityID<Int>) : IntEntity(id) {
|
||||
companion object : IntEntityClass<SourceEntity>(SourcesTable)
|
||||
|
||||
var sourceId by SourcesTable.sourceId
|
||||
var name by SourcesTable.name
|
||||
var lang by SourcesTable.lang
|
||||
var extension by ExtensionEntity referencedOn SourcesTable.extension
|
||||
var partOfFactorySource by SourcesTable.partOfFactorySource
|
||||
var positionInFactorySource by SourcesTable.positionInFactorySource
|
||||
}
|
||||
|
||||
|
||||
//object SourcesTable : IdTable<Long>() {
|
||||
// override val id = long("id").entityId()
|
||||
// val name= varchar("name", 128)
|
||||
// val extension = reference("extension", ExtensionsTable)
|
||||
// val partOfFactorySource = bool("part_of_factory_source").default(false)
|
||||
// val positionInFactorySource = integer("position_in_factory_source").nullable()
|
||||
//
|
||||
// override val primaryKey = PrimaryKey(id)
|
||||
//}
|
||||
//
|
||||
//class SourceEntity(id: EntityID<Long>) : LongEntity(id) {
|
||||
// companion object : LongEntityClass<SourceEntity>(SourcesTable)
|
||||
//
|
||||
// var name by SourcesTable.name
|
||||
// var extension by SourcesTable.extension
|
||||
// var partOfFactorySource by SourcesTable.partOfFactorySource
|
||||
// var positionInFactorySource by SourcesTable.positionInFactorySource
|
||||
//}
|
@ -0,0 +1,18 @@
|
||||
package ir.armor.tachidesk.database.table
|
||||
|
||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
||||
|
||||
|
||||
object ExtensionsTable : IntIdTable() {
|
||||
val name = varchar("name", 128)
|
||||
val pkgName = varchar("pkg_name", 128)
|
||||
val versionName = varchar("version_name", 16)
|
||||
val versionCode = integer("version_code")
|
||||
val lang = varchar("lang", 5)
|
||||
val isNsfw = bool("is_nsfw")
|
||||
val apkName = varchar("apk_name", 1024)
|
||||
val iconUrl = varchar("icon_url", 2048)
|
||||
|
||||
val installed = bool("installed").default(false)
|
||||
val classFQName = varchar("class_name", 256).default("") // fully qualified name
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package ir.armor.tachidesk.database.table
|
||||
|
||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
||||
|
||||
object SourcesTable : IntIdTable() {
|
||||
val sourceId = long("source_id")
|
||||
val name = varchar("name", 128)
|
||||
val lang = varchar("lang", 5)
|
||||
val extension = reference("extension", ExtensionsTable)
|
||||
val partOfFactorySource = bool("part_of_factory_source").default(false)
|
||||
val positionInFactorySource = integer("position_in_factory_source").nullable()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user