package com.example.data import androidx.room.* import kotlinx.coroutines.flow.Flow @Dao interface AppDao { // User/Client Wallet Operations @Query("SELECT * FROM user_wallet WHERE userId = :id LIMIT 1") fun getUserWalletFlow(id: String): Flow @Query("SELECT * FROM user_wallet WHERE userId = :id LIMIT 1") suspend fun getUserWallet(id: String): UserWallet? @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertUserWallet(wallet: UserWallet) @Query("SELECT * FROM user_wallet") fun getAllUserWallets(): Flow> // Model Profile Operations @Query("SELECT * FROM model_profile") fun getAllModelsFlow(): Flow> @Query("SELECT * FROM model_profile") suspend fun getAllModels(): List @Query("SELECT * FROM model_profile WHERE id = :id LIMIT 1") fun getModelFlow(id: Int): Flow @Query("SELECT * FROM model_profile WHERE id = :id LIMIT 1") suspend fun getModelById(id: Int): ModelProfile? @Query("SELECT * FROM model_profile WHERE email = :email LIMIT 1") suspend fun getModelByEmail(email: String): ModelProfile? @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertModel(model: ModelProfile): Long @Update suspend fun updateModel(model: ModelProfile) @Delete suspend fun deleteModel(model: ModelProfile) // Booking Operations @Query("SELECT * FROM booking ORDER BY timestamp DESC") fun getAllBookingsFlow(): Flow> @Query("SELECT * FROM booking WHERE userId = :userId ORDER BY timestamp DESC") fun getBookingsForUserFlow(userId: String): Flow> @Query("SELECT * FROM booking WHERE modelId = :modelId ORDER BY timestamp DESC") fun getBookingsForModelFlow(modelId: Int): Flow> @Query("SELECT * FROM booking WHERE id = :id LIMIT 1") suspend fun getBookingById(id: Int): BookingEntity? @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertBooking(booking: BookingEntity): Long @Update suspend fun updateBooking(booking: BookingEntity) // Transaction History Operations @Query("SELECT * FROM transaction_log ORDER BY timestamp DESC") fun getAllLogsFlow(): Flow> @Query("SELECT * FROM transaction_log WHERE accountId = :accountId ORDER BY timestamp DESC") fun getLogsForAccountFlow(accountId: String): Flow> @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertLog(log: TransactionLog) // Cash Agent / Deposit Operations @Query("SELECT * FROM cash_deposit_request ORDER BY timestamp DESC") fun getAllCashDepositRequestsFlow(): Flow> @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertCashDepositRequest(request: CashDepositRequest): Long @Query("SELECT * FROM cash_deposit_request WHERE id = :id LIMIT 1") suspend fun getCashDepositRequestById(id: Int): CashDepositRequest? @Query("SELECT * FROM cash_deposit_request WHERE agentId = :agentId ORDER BY timestamp DESC") fun getCashDepositRequestsForAgentFlow(agentId: String): Flow> @Update suspend fun updateCashDepositRequest(request: CashDepositRequest) // Live Stream Operations @Query("SELECT * FROM live_stream ORDER BY startedAt DESC") fun getAllLiveStreamsFlow(): Flow> @Query("SELECT * FROM live_stream WHERE status = 'LIVE' ORDER BY startedAt DESC") fun getActiveLiveStreamsFlow(): Flow> @Query("SELECT * FROM live_stream WHERE id = :id LIMIT 1") suspend fun getLiveStreamById(id: Int): LiveStreamEntity? @Query("SELECT * FROM live_stream WHERE modelId = :modelId AND status = 'LIVE' LIMIT 1") suspend fun getActiveLiveStreamByModel(modelId: Int): LiveStreamEntity? @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertLiveStream(stream: LiveStreamEntity): Long @Update suspend fun updateLiveStream(stream: LiveStreamEntity) // Live Chat Operations @Query("SELECT * FROM live_chat WHERE streamId = :streamId ORDER BY timestamp ASC") fun getLiveChatsForStreamFlow(streamId: Int): Flow> @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertLiveChat(chat: LiveChatEntity): Long // Proof Operations @Query("SELECT * FROM proof WHERE bookingId = :bookingId LIMIT 1") fun getProofForBooking(bookingId: Int): Flow @Query("SELECT * FROM proof WHERE bookingId = :bookingId LIMIT 1") suspend fun getProofByBookingId(bookingId: Int): ProofEntity? @Query("SELECT * FROM proof ORDER BY timestamp DESC") fun getAllProofsFlow(): Flow> @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertProof(proof: ProofEntity): Long @Update suspend fun updateProof(proof: ProofEntity) // Admin Wallet Operations @Query("SELECT * FROM admin_wallet WHERE id = 'admin_default' LIMIT 1") fun getAdminWalletFlow(): Flow @Query("SELECT * FROM admin_wallet WHERE id = 'admin_default' LIMIT 1") suspend fun getAdminWallet(): AdminWalletEntity? @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertAdminWallet(wallet: AdminWalletEntity) // Withdrawal Operations @Query("SELECT * FROM withdrawals ORDER BY timestamp DESC") fun getAllWithdrawalsFlow(): Flow> @Query("SELECT * FROM withdrawals WHERE id = :id LIMIT 1") suspend fun getWithdrawalById(id: Int): WithdrawalEntity? @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertWithdrawal(withdrawal: WithdrawalEntity): Long @Update suspend fun updateWithdrawal(withdrawal: WithdrawalEntity) }