1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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 LightAnswersRepository private constructor(
        private val lightdefaulDao: LightAllAnswerDao
){
 
 
 
 
   fun getLightAllQuestions(question_id:Int) =lightdefaulDao.getCurrQuest2Answers(question_id)
   suspend fun updateAnswerChoose(id: Int, flag: Int) {
        withContext(IO){
            lightdefaulDao.updateAnswerChoose(id,flag);
        }
    }
 
    fun getLightAllAnswers()=lightdefaulDao.getAllAnswers()
 
 
    companion object{
        @Volatile
        private var instance:LightAnswersRepository ?= null
 
        fun getInstance(lightdefaulDao: LightAllAnswerDao)= instance?: synchronized(this){
                instance?: LightAnswersRepository(lightdefaulDao).also { instance = it }
        }
    }
}