package com.jld.vod.repository

import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import com.jld.vod.interfaces.remote.Apis
import com.jld.vod.model.bean.*
import kotlinx.coroutines.flow.Flow

class MovieRepository {

    /**
     * 获取电影一级列表分类
     */
    fun getCategoryFatherAllByMid(gameApi: Apis, mid:Long,  lid:Long): Flow<PagingData<CategoryFatherAllBean>> {
        return Pager(
            config = PagingConfig(pageSize = 10, initialLoadSize = 20),
            pagingSourceFactory = { CategoryFatherAllPagingSource(gameApi,mid,lid) }
        ).flow
    }

    /**
     * 获取电影二级列表分类
     */
    fun getategorySonAllByMid(gameApi: Apis, cid:Long,  lid:Long): Flow<PagingData<CategorySonAllBean>> {
        return Pager(
            config = PagingConfig(pageSize = 10, initialLoadSize = 20),
            pagingSourceFactory = { CategorySonAllPagingSource(gameApi,cid,lid) }
        ).flow
    }

    /**
     * 获取全部电影列表
     */
    fun getMovieAllList(gameApi: Apis, mid:Long,  lid:Long): Flow<PagingData<MovieByMidBean>> {
        return Pager(
            config = PagingConfig(pageSize = 10, initialLoadSize = 20),
            pagingSourceFactory = { MovieAllPagingSource(gameApi,mid,lid) }
        ).flow
    }

    /**
     * 获取分类电影列表
     */
    fun getMovieCidList(gameApi: Apis, cid:Long,mid:Long,  lid:Long): Flow<PagingData<MovieByMidBean>> {
        return Pager(
            config = PagingConfig(pageSize = 10, initialLoadSize = 20),
            pagingSourceFactory = { MoviePagingSource(gameApi,cid,mid,lid) }
        ).flow
    }
}