mirror of https://github.com/aruppi/aruppi-api
Fixed Directory endpoint and improve anime endpoints
This commit is contained in:
parent
02125b1403
commit
f948ca6b13
|
@ -47,3 +47,5 @@ out/
|
||||||
gradlew
|
gradlew
|
||||||
|
|
||||||
gradlew.bat
|
gradlew.bat
|
||||||
|
|
||||||
|
.kotlin/
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.jeluchu.core.models.jikan.anime
|
package com.jeluchu.core.models.jikan.anime
|
||||||
|
|
||||||
import com.jeluchu.core.models.jikan.anime.Prop
|
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.jeluchu.core.models.jikan.anime
|
||||||
import com.jeluchu.core.enums.Day
|
import com.jeluchu.core.enums.Day
|
||||||
import com.jeluchu.core.utils.toVideoPromo
|
import com.jeluchu.core.utils.toVideoPromo
|
||||||
import com.jeluchu.features.rankings.models.AnimeTopEntity
|
import com.jeluchu.features.rankings.models.AnimeTopEntity
|
||||||
import com.jeluchu.features.rankings.models.MangaTopEntity
|
|
||||||
import com.jeluchu.features.schedule.models.DayEntity
|
import com.jeluchu.features.schedule.models.DayEntity
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package fordelete
|
package fordelete
|
||||||
|
|
||||||
import com.jeluchu.core.models.jikan.anime.Images
|
import com.jeluchu.core.models.jikan.anime.Images
|
||||||
import com.jeluchu.core.models.jikan.people.PeopleData
|
|
||||||
import com.jeluchu.features.rankings.models.CharacterTopEntity
|
import com.jeluchu.features.rankings.models.CharacterTopEntity
|
||||||
import com.jeluchu.features.rankings.models.PeopleTopEntity
|
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,14 @@ object BaseUrls {
|
||||||
}
|
}
|
||||||
|
|
||||||
object Endpoints {
|
object Endpoints {
|
||||||
|
const val FULL = "full"
|
||||||
|
const val ANIME = "anime/"
|
||||||
const val SCHEDULES = "schedules"
|
const val SCHEDULES = "schedules"
|
||||||
const val TOP_ANIME = "top/anime"
|
const val TOP_ANIME = "top/anime"
|
||||||
const val TOP_MANGA = "top/manga"
|
const val TOP_MANGA = "top/manga"
|
||||||
const val TOP_PEOPLE = "top/people"
|
const val TOP_PEOPLE = "top/people"
|
||||||
|
const val STATISTICS = "statistics"
|
||||||
|
const val CHARACTERS = "characters"
|
||||||
const val TOP_CHARACTER = "top/characters"
|
const val TOP_CHARACTER = "top/characters"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,5 +45,6 @@ object Collections {
|
||||||
const val ANIME_RANKING = "anime_ranking"
|
const val ANIME_RANKING = "anime_ranking"
|
||||||
const val MANGA_RANKING = "manga_ranking"
|
const val MANGA_RANKING = "manga_ranking"
|
||||||
const val PEOPLE_RANKING = "people_ranking"
|
const val PEOPLE_RANKING = "people_ranking"
|
||||||
|
const val ANIME_DIRECTORY = "anime_directory"
|
||||||
const val CHARACTER_RANKING = "character_ranking"
|
const val CHARACTER_RANKING = "character_ranking"
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
package com.jeluchu.core.utils
|
package com.jeluchu.core.utils
|
||||||
|
|
||||||
import com.example.models.VideoPromo
|
|
||||||
import com.jeluchu.core.models.jikan.anime.ImageFormat
|
import com.jeluchu.core.models.jikan.anime.ImageFormat
|
||||||
import com.jeluchu.core.models.jikan.anime.Trailer
|
import com.jeluchu.core.models.jikan.anime.Trailer
|
||||||
import com.jeluchu.features.anime.models.anime.Images
|
import com.jeluchu.features.anime.models.anime.Images
|
||||||
|
import com.jeluchu.features.anime.models.anime.VideoPromo
|
||||||
|
|
||||||
fun Trailer.toVideoPromo() = VideoPromo(
|
fun Trailer.toVideoPromo() = VideoPromo(
|
||||||
url = url.orEmpty(),
|
url = url.orEmpty(),
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package com.jeluchu.features.anime.mappers
|
package com.jeluchu.features.anime.mappers
|
||||||
|
|
||||||
import com.example.models.*
|
|
||||||
import com.jeluchu.core.extensions.*
|
import com.jeluchu.core.extensions.*
|
||||||
import com.jeluchu.features.anime.models.anime.Images
|
import com.jeluchu.features.anime.models.anime.*
|
||||||
import com.jeluchu.features.anime.models.directory.AnimeDirectoryEntity
|
import com.jeluchu.features.anime.models.directory.AnimeDirectoryEntity
|
||||||
import com.jeluchu.features.rankings.models.AnimeTopEntity
|
import com.jeluchu.features.rankings.models.AnimeTopEntity
|
||||||
import com.jeluchu.features.schedule.models.DayEntity
|
import com.jeluchu.features.schedule.models.DayEntity
|
||||||
import org.bson.Document
|
import org.bson.Document
|
||||||
|
import java.sql.Timestamp
|
||||||
|
import java.time.ZonedDateTime
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
fun documentToAnimeDirectoryEntity(doc: Document) = AnimeDirectoryEntity(
|
fun documentToAnimeDirectoryEntity(doc: Document) = AnimeDirectoryEntity(
|
||||||
rank = doc.getIntSafe("rank"),
|
rank = doc.getIntSafe("rank"),
|
||||||
|
@ -26,7 +28,7 @@ fun documentToAnimeDirectoryEntity(doc: Document) = AnimeDirectoryEntity(
|
||||||
|
|
||||||
fun documentToMoreInfoEntity(doc: Document): MoreInfoEntity {
|
fun documentToMoreInfoEntity(doc: Document): MoreInfoEntity {
|
||||||
return MoreInfoEntity(
|
return MoreInfoEntity(
|
||||||
id = doc.getLongSafe("id"),
|
id = doc.getObjectId("_id").toString(),
|
||||||
malId = doc.getIntSafe("malId"),
|
malId = doc.getIntSafe("malId"),
|
||||||
title = doc.getStringSafe("title"),
|
title = doc.getStringSafe("title"),
|
||||||
poster = doc.getStringSafe("poster"),
|
poster = doc.getStringSafe("poster"),
|
||||||
|
@ -155,9 +157,14 @@ fun documentToIndividual(doc: Document): Individual {
|
||||||
|
|
||||||
fun documentToMergedEpisode(doc: Document): MergedEpisode {
|
fun documentToMergedEpisode(doc: Document): MergedEpisode {
|
||||||
return MergedEpisode(
|
return MergedEpisode(
|
||||||
number = doc.getIntSafe("number", 0),
|
malId = doc.getIntSafe("malId"),
|
||||||
ids = doc.getListSafe<Document>("ids").map { documentToAnimeSource(it) }.toMutableList(),
|
title = doc.getStringSafe("title"),
|
||||||
nextEpisodeDate = doc.getStringSafe("nextEpisodeDate")
|
titleJapanese = doc.getStringSafe("titleJapanese"),
|
||||||
|
titleRomanji = doc.getStringSafe("titleRomanji"),
|
||||||
|
aired = doc.getStringSafe("aired", ZonedDateTime.now().format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)),
|
||||||
|
score = doc.getFloatSafe("score"),
|
||||||
|
filler = doc.getBooleanSafe("filler"),
|
||||||
|
recap = doc.getBooleanSafe("recap")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class MergedEpisode(
|
data class MergedEpisode(
|
||||||
var number: Int,
|
var malId: Int,
|
||||||
var ids: MutableList<AnimeSource> = mutableListOf(),
|
var title: String,
|
||||||
var nextEpisodeDate: String = ""
|
var titleJapanese: String,
|
||||||
|
var titleRomanji: String,
|
||||||
|
var aired: String,
|
||||||
|
var score: Float,
|
||||||
|
var filler: Boolean,
|
||||||
|
var recap: Boolean,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
|
@ -7,8 +7,8 @@ import org.bson.Document
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class MoreInfoEntity(
|
data class MoreInfoEntity(
|
||||||
val id: Long? = null,
|
|
||||||
var malId: Int = 0,
|
var malId: Int = 0,
|
||||||
|
val id: String = "",
|
||||||
var title: String = "",
|
var title: String = "",
|
||||||
var poster: String = "",
|
var poster: String = "",
|
||||||
var cover: String = "",
|
var cover: String = "",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.example.models
|
package com.jeluchu.features.anime.models.anime
|
||||||
|
|
||||||
import com.jeluchu.features.anime.models.anime.Images
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
|
|
@ -8,8 +8,10 @@ import io.ktor.server.routing.*
|
||||||
|
|
||||||
fun Route.animeEndpoints(
|
fun Route.animeEndpoints(
|
||||||
mongoDatabase: MongoDatabase,
|
mongoDatabase: MongoDatabase,
|
||||||
service: AnimeService = AnimeService(mongoDatabase)
|
service: AnimeService = AnimeService(mongoDatabase),
|
||||||
) {
|
) {
|
||||||
getToJson(Routes.DIRECTORY) { service.getDirectory(call) }
|
|
||||||
getToJson(Routes.ANIME_DETAILS) { service.getAnimeByMalId(call) }
|
getToJson(Routes.ANIME_DETAILS) { service.getAnimeByMalId(call) }
|
||||||
|
route(Routes.DIRECTORY) {
|
||||||
|
getToJson { service.getDirectory(call) }
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package com.jeluchu.features.rankings.models
|
package com.jeluchu.features.rankings.models
|
||||||
|
|
||||||
import com.example.models.VideoPromo
|
import com.jeluchu.features.anime.models.anime.VideoPromo
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.jeluchu.features.schedule.models
|
package com.jeluchu.features.schedule.models
|
||||||
|
|
||||||
import com.jeluchu.core.models.jikan.search.Pagination
|
|
||||||
import com.jeluchu.core.models.jikan.anime.AnimeData
|
import com.jeluchu.core.models.jikan.anime.AnimeData
|
||||||
|
import com.jeluchu.core.models.jikan.search.Pagination
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue