From fe04012057d024770e0180543483d393281a542f Mon Sep 17 00:00:00 2001 From: zhujie <leon.zhu@cloudroam.com.cn> Date: 星期四, 03 四月 2025 09:18:16 +0800 Subject: [PATCH] Merge branch 'master' of http://47.96.225.205:8888/r/FirstApp2 --- app/src/main/java/com/example/firstapp/database/repository/CodeRepository.kt | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 40 insertions(+), 5 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..ad83877 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) { @@ -25,7 +24,8 @@ return codeDao.getByKeyword(keyword) } - fun queryByTypeAndCodeAndDate(content: String, code: String, dateString: String): Code { + @WorkerThread + fun queryByTypeAndCodeAndDate(content: String, code: String, dateString: String): Code? { return codeDao.queryByTypeAndCodeAndDate(content, code, dateString) } @@ -41,9 +41,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 +61,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