From 1831c2a6304496729fc16af624c37e299beae83e Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期二, 01 四月 2025 11:36:19 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
app/src/main/java/com/example/firstapp/database/repository/CodeRepository.kt | 42 ++++++++++++++++++++++++++++++++++++++----
1 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/app/src/main/java/com/example/firstapp/database/repository/CodeRepository.kt b/app/src/main/java/com/example/firstapp/database/repository/CodeRepository.kt
index 7c14c1e..c7ccd88 100644
--- a/app/src/main/java/com/example/firstapp/database/repository/CodeRepository.kt
+++ b/app/src/main/java/com/example/firstapp/database/repository/CodeRepository.kt
@@ -3,9 +3,8 @@
import androidx.annotation.WorkerThread
import com.example.firstapp.database.dao.CodeDao
import com.example.firstapp.database.entity.Code
-import kotlinx.coroutines.Dispatchers
+import com.example.firstapp.model.StationGroup
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.withContext
class CodeRepository(private val codeDao: CodeDao) {
@@ -41,9 +40,19 @@
}
}
- fun getCourierStats(date: Long) = codeDao.getCourierStatsByWeek(date)
+ fun getCourierStats(date: Long, dateType: String) = when(dateType) {
+ "WEEK" -> codeDao.getCourierStatsByWeek(date)
+ "MONTH" -> codeDao.getCourierStatsByMonth(date)
+ "YEAR" -> codeDao.getCourierStatsByYear(date)
+ else -> codeDao.getCourierStatsByWeek(date)
+ }
- fun getDailyStats() = codeDao.getDailyStatsByWeek()
+// fun getStats(date: Long, dateType: String) = when(dateType) {
+// "WEEK" -> codeDao.getDailyStatsByWeek(date)
+// "MONTH" -> codeDao.getMonthlyStats(date)
+// "YEAR" -> codeDao.getYearlyStats(date)
+// else -> codeDao.getDailyStatsByWeek(date)
+// }
@WorkerThread
@@ -51,5 +60,30 @@
return codeDao.getNewPackagesByDay(date)
}
+ fun getYearlyHeatmap(date: Long) = codeDao.getYearlyHeatmap(date)
+
+ fun getWeeklyStats(date: Long, weekCount: Int) = codeDao.getWeeklyStats(date, weekCount)
+
+ fun getMonthlyStats(date: Long) = codeDao.getMonthlyStats(date)
+
+
+ fun getYearlyStats(date: Long) = codeDao.getYearlyStats(date)
+
+ fun getYearMonthlyStats(date: Long) = codeDao.getYearMonthlyStats(date)
+
+
+ fun getCurrentWeekStats(date: Long) = codeDao.getCurrentWeekStats(date)
+
+ fun getCurrentYearStats(date: Long) = codeDao.getCurrentYearStats(date)
+
+ @WorkerThread
+ fun getStationsByType(type: String): List<StationGroup> {
+ return codeDao.getStationsByType(type)
+ }
+
+ @WorkerThread
+ fun getPackagesByTypeAndStation(type: String, stationName: String): List<Code> {
+ return codeDao.getPackagesByTypeAndStation(type, stationName)
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3