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 cn.flightfeather.thirdappmodule.repository.dao
 
import cn.flightfeather.thirdappmodule.bean.entity.Evaluationrule
import cn.flightfeather.thirdappmodule.bean.entity.Evaluationsubrule
import cn.flightfeather.thirdappmodule.common.database.DbFactory
import com.ping.greendao.gen.EvaluationruleDao
import com.ping.greendao.gen.EvaluationsubruleDao
import io.reactivex.Observable
 
/**
 * @author riku
 * Date: 2019/7/29
 * 评分相关数据库操作
 */
class EvaluationDao {
 
    fun getEvaluationRule(provinceCode: String, cityCode: String,
                          districtCode: String, sceneTypeId: Byte): Observable<List<Evaluationrule>> {
        return DbFactory.getGreenDaoObservable().map {
            it.evaluationruleDao.queryBuilder().where(
                    EvaluationruleDao.Properties.Provincecode.eq(provinceCode),
                    EvaluationruleDao.Properties.Citycode.eq(cityCode),
                    EvaluationruleDao.Properties.Districtcode.eq(districtCode),
                    EvaluationruleDao.Properties.Scensetypeid.eq(sceneTypeId)
            ).list()
        }
    }
 
    fun getEvaluationSubRule(evaluationruleGuid: String): Observable<List<Evaluationsubrule>> {
        return DbFactory.getGreenDaoObservable().map {
            it.evaluationsubruleDao.queryBuilder().where(
                    EvaluationsubruleDao.Properties.Erguid.eq(evaluationruleGuid)
            ).orderAsc(EvaluationsubruleDao.Properties.Displayid).list()
        }
    }
}