package com.flightfeather.obd.repository.impl
|
|
import com.flightfeather.obd.domain.entity.ObdData
|
import com.flightfeather.obd.domain.mapper.ObdDataMapper
|
import com.flightfeather.obd.lightshare.bean.ObdDataVo
|
import com.flightfeather.obd.repository.ObdDataRepository
|
import com.github.pagehelper.PageHelper
|
import org.springframework.beans.BeanUtils
|
import org.springframework.stereotype.Repository
|
import tk.mybatis.mapper.entity.Example
|
|
/**
|
* obd数据相关数据库操作实现
|
* @author riku
|
* Date: 2019/8/27
|
*/
|
@Repository
|
class ObdDataDaoImpl(val obdDataMapper: ObdDataMapper) : ObdDataRepository {
|
|
override fun saveObdData(data: ObdDataVo) {
|
val obdData = ObdData()
|
BeanUtils.copyProperties(data, obdData)
|
obdDataMapper.insert(obdData)
|
}
|
|
override fun getDataByVinCode(vinCode: String, pageNum: Int?, pageSize: Int?): MutableList<ObdDataVo> {
|
val example = Example(ObdData::class.java).apply {
|
createCriteria().andEqualTo("obdVin", vinCode)
|
orderBy("obdTime").desc()
|
}
|
|
//分页
|
val offset = (pageSize?.times(pageNum?.minus(1) ?: 0)) ?: 0
|
val a = PageHelper.offsetPage<ObdData>(offset, pageSize ?: 10)
|
val result = obdDataMapper.selectByExample(example)
|
|
val resultList = mutableListOf<ObdDataVo>()
|
result.forEach {
|
val vo = ObdDataVo()
|
BeanUtils.copyProperties(it, vo)
|
resultList.add(vo)
|
}
|
|
return resultList
|
}
|
}
|