diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReferentialRepository.kt b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReferentialRepository.kt index 56766d4c4..cb5d479f8 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReferentialRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReferentialRepository.kt @@ -4,4 +4,5 @@ interface ReferentialRepository { fun findAuthorsByName(search: String): List fun findAllGenres(): Set fun findAllTags(): Set + fun findAllLanguages(): Set } diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReferentialDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReferentialDao.kt index 5c5fc328a..f1fff4105 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReferentialDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReferentialDao.kt @@ -3,10 +3,7 @@ package org.gotson.komga.infrastructure.jooq import org.gotson.komga.domain.persistence.ReferentialRepository import org.gotson.komga.jooq.Tables import org.jooq.DSLContext -import org.jooq.impl.DSL -import org.jooq.impl.DSL.field import org.jooq.impl.DSL.lower -import org.jooq.impl.DSL.one import org.jooq.impl.DSL.select import org.springframework.stereotype.Component @@ -16,6 +13,7 @@ class ReferentialDao( ) : ReferentialRepository { private val a = Tables.BOOK_METADATA_AUTHOR + private val sd = Tables.SERIES_METADATA private val g = Tables.SERIES_METADATA_GENRE private val bt = Tables.BOOK_METADATA_TAG private val st = Tables.SERIES_METADATA_TAG @@ -42,4 +40,10 @@ class ReferentialDao( .fetchSet(0, String::class.java) .sortedBy { it.toLowerCase() } .toSet() + + override fun findAllLanguages(): Set = + dsl.selectDistinct(sd.LANGUAGE) + .from(sd) + .orderBy(sd.LANGUAGE) + .fetchSet(sd.LANGUAGE) } diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/ReferentialController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/ReferentialController.kt index e449de71f..843f95eab 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/ReferentialController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/ReferentialController.kt @@ -27,4 +27,8 @@ class ReferentialController( @GetMapping("/tags") fun getTags(): Set = referentialRepository.findAllTags() + + @GetMapping("/languages") + fun getLanguages(): Set = + referentialRepository.findAllLanguages() }