mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2024-12-25 16:21:50 +01:00
rename tables
This commit is contained in:
parent
32a9321b8a
commit
590be4f04b
@ -2,8 +2,8 @@ package ir.armor.tachidesk.database
|
||||
|
||||
import ir.armor.tachidesk.Config
|
||||
import ir.armor.tachidesk.database.table.ExtensionsTable
|
||||
import ir.armor.tachidesk.database.table.MangasTable
|
||||
import ir.armor.tachidesk.database.table.SourcesTable
|
||||
import ir.armor.tachidesk.database.table.MangaTable
|
||||
import ir.armor.tachidesk.database.table.SourceTable
|
||||
import org.jetbrains.exposed.sql.Database
|
||||
import org.jetbrains.exposed.sql.SchemaUtils
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
@ -20,7 +20,7 @@ fun makeDataBaseTables() {
|
||||
|
||||
transaction {
|
||||
SchemaUtils.create(ExtensionsTable)
|
||||
SchemaUtils.create(SourcesTable)
|
||||
SchemaUtils.create(MangasTable)
|
||||
SchemaUtils.create(SourceTable)
|
||||
SchemaUtils.create(MangaTable)
|
||||
}
|
||||
}
|
@ -1,24 +1,23 @@
|
||||
package ir.armor.tachidesk.database.entity
|
||||
|
||||
import ir.armor.tachidesk.database.table.MangasTable
|
||||
import ir.armor.tachidesk.database.table.SourcesTable
|
||||
import ir.armor.tachidesk.database.table.MangaTable
|
||||
import org.jetbrains.exposed.dao.IntEntity
|
||||
import org.jetbrains.exposed.dao.IntEntityClass
|
||||
import org.jetbrains.exposed.dao.id.EntityID
|
||||
|
||||
class MangaEntity(id: EntityID<Int>) : IntEntity(id) {
|
||||
companion object : IntEntityClass<MangaEntity>(MangasTable)
|
||||
companion object : IntEntityClass<MangaEntity>(MangaTable)
|
||||
|
||||
var url by MangasTable.url
|
||||
var title by MangasTable.title
|
||||
var initialized by MangasTable.initialized
|
||||
var url by MangaTable.url
|
||||
var title by MangaTable.title
|
||||
var initialized by MangaTable.initialized
|
||||
|
||||
var artist by MangasTable.artist
|
||||
var author by MangasTable.author
|
||||
var description by MangasTable.description
|
||||
var genre by MangasTable.genre
|
||||
var status by MangasTable.status
|
||||
var thumbnail_url by MangasTable.thumbnail_url
|
||||
var artist by MangaTable.artist
|
||||
var author by MangaTable.author
|
||||
var description by MangaTable.description
|
||||
var genre by MangaTable.genre
|
||||
var status by MangaTable.status
|
||||
var thumbnail_url by MangaTable.thumbnail_url
|
||||
|
||||
var sourceReference by MangaEntity referencedOn MangasTable.sourceReference
|
||||
var sourceReference by MangaEntity referencedOn MangaTable.sourceReference
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
package ir.armor.tachidesk.database.entity
|
||||
|
||||
import ir.armor.tachidesk.database.table.SourcesTable
|
||||
import ir.armor.tachidesk.database.table.SourceTable
|
||||
import org.jetbrains.exposed.dao.*
|
||||
import org.jetbrains.exposed.dao.id.EntityID
|
||||
|
||||
class SourceEntity(id: EntityID<Long>) : LongEntity(id) {
|
||||
companion object : EntityClass<Long, SourceEntity>(SourcesTable, null)
|
||||
companion object : EntityClass<Long, SourceEntity>(SourceTable, null)
|
||||
|
||||
var sourceId by SourcesTable.id
|
||||
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
|
||||
var sourceId by SourceTable.id
|
||||
var name by SourceTable.name
|
||||
var lang by SourceTable.lang
|
||||
var extension by ExtensionEntity referencedOn SourceTable.extension
|
||||
var partOfFactorySource by SourceTable.partOfFactorySource
|
||||
var positionInFactorySource by SourceTable.positionInFactorySource
|
||||
}
|
@ -2,7 +2,7 @@ package ir.armor.tachidesk.database.table
|
||||
|
||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
||||
|
||||
object MangasTable : IntIdTable() {
|
||||
object MangaTable : IntIdTable() {
|
||||
val url = varchar("url", 2048)
|
||||
val title = varchar("title", 512)
|
||||
val initialized = bool("initialized").default(false)
|
||||
@ -15,7 +15,7 @@ object MangasTable : IntIdTable() {
|
||||
val thumbnail_url = varchar("thumbnail_url", 2048).nullable()
|
||||
|
||||
// source is used by some ancestor of IntIdTable
|
||||
val sourceReference = reference("source", SourcesTable)
|
||||
val sourceReference = reference("source", SourceTable)
|
||||
}
|
||||
|
||||
enum class MangaStatus(val status: Int) {
|
@ -2,7 +2,7 @@ package ir.armor.tachidesk.database.table
|
||||
|
||||
import org.jetbrains.exposed.dao.id.IdTable
|
||||
|
||||
object SourcesTable : IdTable<Long>() {
|
||||
object SourceTable : IdTable<Long>() {
|
||||
override val id = long("id").entityId()
|
||||
val name= varchar("name", 128)
|
||||
val lang = varchar("lang", 10)
|
@ -8,18 +8,15 @@ import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import ir.armor.tachidesk.APKExtractor
|
||||
import ir.armor.tachidesk.Config
|
||||
import ir.armor.tachidesk.database.table.ExtensionsTable
|
||||
import ir.armor.tachidesk.database.table.SourcesTable
|
||||
import ir.armor.tachidesk.database.table.SourceTable
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import okhttp3.Request
|
||||
import okio.buffer
|
||||
import okio.sink
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.insert
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
@ -71,8 +68,8 @@ fun installAPK(apkName: String): Int {
|
||||
// name = httpSource.name
|
||||
// this.extension = ExtensionEntity.find { ExtensionsTable.name eq extension.name }.first().id
|
||||
// }
|
||||
if (SourcesTable.select { SourcesTable.id eq httpSource.id }.count() == 0L) {
|
||||
SourcesTable.insert {
|
||||
if (SourceTable.select { SourceTable.id eq httpSource.id }.count() == 0L) {
|
||||
SourceTable.insert {
|
||||
it[this.id] = httpSource.id
|
||||
it[name] = httpSource.name
|
||||
it[this.lang] = httpSource.lang
|
||||
@ -89,8 +86,8 @@ fun installAPK(apkName: String): Int {
|
||||
transaction {
|
||||
sourceFactory.createSources().forEachIndexed { index, source ->
|
||||
val httpSource = source as HttpSource
|
||||
if (SourcesTable.select { SourcesTable.id eq httpSource.id }.count() == 0L) {
|
||||
SourcesTable.insert {
|
||||
if (SourceTable.select { SourceTable.id eq httpSource.id }.count() == 0L) {
|
||||
SourceTable.insert {
|
||||
it[this.id] = httpSource.id
|
||||
it[name] = httpSource.name
|
||||
it[this.lang] = httpSource.lang
|
||||
|
@ -3,13 +3,11 @@ package ir.armor.tachidesk.util
|
||||
import eu.kanade.tachiyomi.source.SourceFactory
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import ir.armor.tachidesk.Config
|
||||
import ir.armor.tachidesk.Main
|
||||
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.table.ExtensionsTable
|
||||
import ir.armor.tachidesk.database.table.SourcesTable
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import ir.armor.tachidesk.database.table.SourceTable
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
@ -71,13 +69,13 @@ fun getHttpSource(sourceId: Long): HttpSource {
|
||||
|
||||
fun getSourceList(): List<SourceDataClass> {
|
||||
return transaction {
|
||||
return@transaction SourcesTable.selectAll().map {
|
||||
return@transaction SourceTable.selectAll().map {
|
||||
SourceDataClass(
|
||||
it[SourcesTable.id].value.toString(),
|
||||
it[SourcesTable.name],
|
||||
Locale(it[SourcesTable.lang]).getDisplayLanguage(Locale(it[SourcesTable.lang])),
|
||||
ExtensionsTable.select { ExtensionsTable.id eq it[SourcesTable.extension] }.first()[ExtensionsTable.iconUrl],
|
||||
getHttpSource(it[SourcesTable.id].value).supportsLatest
|
||||
it[SourceTable.id].value.toString(),
|
||||
it[SourceTable.name],
|
||||
Locale(it[SourceTable.lang]).getDisplayLanguage(Locale(it[SourceTable.lang])),
|
||||
ExtensionsTable.select { ExtensionsTable.id eq it[SourceTable.extension] }.first()[ExtensionsTable.iconUrl],
|
||||
getHttpSource(it[SourceTable.id].value).supportsLatest
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user