1
1
package com.jeluchu.features.anime.mappers
2
2
3
- import com.example.models.*
4
3
import com.jeluchu.core.extensions.*
5
- import com.jeluchu.features.anime.models.anime.Images
4
+ import com.jeluchu.features.anime.models.anime.*
6
5
import com.jeluchu.features.anime.models.directory.AnimeDirectoryEntity
7
6
import com.jeluchu.features.rankings.models.AnimeTopEntity
8
7
import com.jeluchu.features.schedule.models.DayEntity
9
8
import org.bson.Document
9
+ import java.sql.Timestamp
10
+ import java.time.ZonedDateTime
11
+ import java.time.format.DateTimeFormatter
10
12
11
13
fun documentToAnimeDirectoryEntity (doc : Document ) = AnimeDirectoryEntity (
12
14
rank = doc.getIntSafe(" rank" ),
@@ -26,7 +28,7 @@ fun documentToAnimeDirectoryEntity(doc: Document) = AnimeDirectoryEntity(
26
28
27
29
fun documentToMoreInfoEntity (doc : Document ): MoreInfoEntity {
28
30
return MoreInfoEntity (
29
- id = doc.getLongSafe( " id " ),
31
+ id = doc.getObjectId( " _id " ).toString( ),
30
32
malId = doc.getIntSafe(" malId" ),
31
33
title = doc.getStringSafe(" title" ),
32
34
poster = doc.getStringSafe(" poster" ),
@@ -155,9 +157,14 @@ fun documentToIndividual(doc: Document): Individual {
155
157
156
158
fun documentToMergedEpisode (doc : Document ): MergedEpisode {
157
159
return MergedEpisode (
158
- number = doc.getIntSafe(" number" , 0 ),
159
- ids = doc.getListSafe<Document >(" ids" ).map { documentToAnimeSource(it) }.toMutableList(),
160
- nextEpisodeDate = doc.getStringSafe(" nextEpisodeDate" )
160
+ malId = doc.getIntSafe(" malId" ),
161
+ title = doc.getStringSafe(" title" ),
162
+ titleJapanese = doc.getStringSafe(" titleJapanese" ),
163
+ titleRomanji = doc.getStringSafe(" titleRomanji" ),
164
+ aired = doc.getStringSafe(" aired" , ZonedDateTime .now().format(DateTimeFormatter .ISO_OFFSET_DATE_TIME )),
165
+ score = doc.getFloatSafe(" score" ),
166
+ filler = doc.getBooleanSafe(" filler" ),
167
+ recap = doc.getBooleanSafe(" recap" )
161
168
)
162
169
}
163
170
0 commit comments