package com.remax.visualnovel.app.di


import com.remax.visualnovel.api.factory.ServiceFactory
import com.remax.visualnovel.api.service.AIService
import com.remax.visualnovel.api.service.BookService
import com.remax.visualnovel.api.service.ChatService
import com.remax.visualnovel.api.service.DictService
import com.remax.visualnovel.api.service.LoginService
import com.remax.visualnovel.api.service.MessageService
import com.remax.visualnovel.api.service.OssService
import com.remax.visualnovel.api.service.PayService
import com.remax.visualnovel.api.service.UserService
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

/**
 * hilt注入service请求
 */
@Module
@InstallIn(SingletonComponent::class)
object ApiServiceModule {

    @Singleton
    @Provides
    fun userService() = create<UserService>()

    @Singleton
    @Provides
    fun loginService() = create<LoginService>()

    @Singleton
    @Provides
    fun messageService() = create<MessageService>()

    @Singleton
    @Provides
    fun dictService() = create<DictService>()

    @Singleton
    @Provides
    fun bookService() = create<BookService>()

    @Singleton
    @Provides
    fun aiService() = create<AIService>()

    @Singleton
    @Provides
    fun ossService() = create<OssService>()

    @Singleton
    @Provides
    fun payService() = create<PayService>()

    @Singleton
    @Provides
    fun chatService() = create<ChatService>()


    private inline fun <reified T> create(): T {
        return ServiceFactory.createService()
    }
}