package com.example.data.local import androidx.room.* import com.example.data.model.* import kotlinx.coroutines.flow.Flow @Dao interface CompanyDao { @Query("SELECT * FROM companies ORDER BY riskScore ASC") fun getAllCompanies(): Flow> @Query("SELECT * FROM companies WHERE status = :status ORDER BY nameEn ASC") fun getCompaniesByStatus(status: VerificationStatus): Flow> @Query("SELECT * FROM companies WHERE id = :id") suspend fun getCompanyById(id: String): Company? @Query(""" SELECT * FROM companies WHERE nameEn LIKE '%' || :query || '%' OR nameBn LIKE '%' || :query || '%' OR rjscRegNo LIKE '%' || :query || '%' OR tradeLicenseNo LIKE '%' || :query || '%' OR phone LIKE '%' || :query || '%' OR bkashMerchantNo LIKE '%' || :query || '%' """) fun searchCompanies(query: String): Flow> @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertCompanies(companies: List) @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertCompany(company: Company) @Update suspend fun updateCompany(company: Company) } @Dao interface ScamReportDao { @Query("SELECT * FROM scam_reports ORDER BY dateReported DESC") fun getAllReports(): Flow> @Query("SELECT * FROM scam_reports WHERE status = :status ORDER BY dateReported DESC") fun getReportsByStatus(status: ReportStatus): Flow> @Query("SELECT * FROM scam_reports WHERE id = :id") suspend fun getReportById(id: String): ScamReport? @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertReport(report: ScamReport) @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertReports(reports: List) @Update suspend fun updateReport(report: ScamReport) } @Dao interface PublicWarningDao { @Query("SELECT * FROM public_warnings ORDER BY isPinned DESC, date DESC") fun getAllWarnings(): Flow> @Query("SELECT * FROM public_warnings WHERE division = :division ORDER BY date DESC") fun getWarningsByDivision(division: String): Flow> @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertWarnings(warnings: List) @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertWarning(warning: PublicWarning) } @Dao interface NotificationDao { @Query("SELECT * FROM notifications ORDER BY timestamp DESC") fun getAllNotifications(): Flow> @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertNotifications(notifications: List) @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertNotification(notification: AppNotification) @Query("UPDATE notifications SET isRead = 1") suspend fun markAllAsRead() }