package safeluck.drive.evaluation.DB.lightdb
|
|
import kotlinx.coroutines.Dispatchers.IO
|
import kotlinx.coroutines.withContext
|
|
/**DriveJudge
|
* Created by lzw on 2021/1/15. 10:01:31
|
* 邮箱:632393724@qq.com
|
* All Rights Saved! Chongqing AnYun Tech co. LTD
|
*/
|
class LightDefaultRepository private constructor(
|
private val lightdefaulDao: LightUseQuestionsDao
|
){
|
suspend fun removeItem(lightusequest:LightUseQuestions){
|
withContext(IO){
|
lightdefaulDao.deleteItem(lightusequest)
|
}
|
}
|
|
|
|
fun getLightUseQuestions() = lightdefaulDao.getLightUseQuestions()
|
suspend fun updateQuest2Answer(questionId: Int, answ: String) {
|
withContext(IO){
|
|
lightdefaulDao.updateAnswer(questionId,answ)
|
}
|
}
|
|
suspend fun addItem(questionId: Int, question: String, flag: Int,answ:String) {
|
withContext(IO){
|
|
var lightquest = LightUseQuestions()
|
lightquest.question = question
|
lightquest.id = questionId
|
lightquest.flag = flag
|
lightquest.answer = answ
|
lightdefaulDao.insertQuestion(lightquest)
|
}
|
}
|
|
|
companion object{
|
@Volatile
|
private var instance:LightDefaultRepository ?= null
|
|
fun getInstance(lightdefaulDao: LightUseQuestionsDao)= instance?: synchronized(this){
|
instance?: LightDefaultRepository(lightdefaulDao).also { instance = it }
|
}
|
}
|
}
|