| | |
| | | import androidx.annotation.WorkerThread |
| | | import com.example.firstapp.database.dao.CodeDao |
| | | import com.example.firstapp.database.entity.Code |
| | | import com.example.firstapp.model.DailyStat |
| | | import com.example.firstapp.model.StationGroup |
| | | import kotlinx.coroutines.flow.Flow |
| | | |
| | | |
| | |
| | | @WorkerThread |
| | | fun delete(id: Long) = codeDao.delete(id) |
| | | |
| | | @WorkerThread |
| | | fun deleteAll() = codeDao.deleteAll() |
| | | |
| | | fun getAll() = codeDao.getAllCodes() |
| | | |
| | | fun getAllDesc() = codeDao.getAllCodesDesc() |
| | |
| | | return codeDao.getByKeyword(keyword) |
| | | } |
| | | |
| | | fun queryByTypeAndCodeAndDate(content: String, code: String, dateString: String): Code { |
| | | return codeDao.queryByTypeAndCodeAndDate(content, code, dateString) |
| | | @WorkerThread |
| | | fun queryByTypeAndCodeAndDate(content: String, code: String, smsTimestamp: Long): Code? { |
| | | return codeDao.queryByTypeAndCodeAndDate(content, code, smsTimestamp) |
| | | } |
| | | |
| | | @WorkerThread |
| | |
| | | fun getPackages(date: Long, dateType: String): Flow<List<Code>> { |
| | | return when (dateType) { |
| | | "DAY" -> codeDao.getPackagesByDay(date) |
| | | "WEEK" -> codeDao.getPackagesByWeek(date) |
| | | else -> codeDao.getPackagesByDay(date) |
| | | } |
| | | } |
| | | |
| | | fun getPackagesReaded(date: Long, dateType: String): Flow<List<Code>> { |
| | | return when (dateType) { |
| | | "DAY" -> codeDao.getPackagesByDayReaded(date) |
| | | "WEEK" -> codeDao.getPackagesByWeek(date) |
| | | else -> codeDao.getPackagesByDay(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) |
| | | } |
| | | |
| | | fun getCurrentWeekStats2(startDateCur: String, endDateCur: String) = codeDao.getCurrentWeekStats2(startDateCur,endDateCur) |
| | | fun getWeeklyStatsChart(startDateCur: String, endDateCur: String): Flow<List<DailyStat>> = codeDao.getWeeklyStatsChart(startDateCur,endDateCur) |
| | | fun getDateStatsByType(startDateCur: String, endDateCur: String, type: String) = codeDao.getDateStatsByType(startDateCur,endDateCur,type) |
| | | |
| | | } |