package com.flightfeather.obd.repository.impl
|
|
import com.flightfeather.obd.domain.entity.ThresholdValue
|
import com.flightfeather.obd.domain.mapper.ThresholdValueMapper
|
import com.flightfeather.obd.lightshare.bean.ThresholdValueVo
|
import com.flightfeather.obd.repository.ObdThresholdValueRepository
|
import org.springframework.beans.BeanUtils
|
import org.springframework.stereotype.Repository
|
import tk.mybatis.mapper.entity.Example
|
|
/**
|
* @author riku
|
* Date: 2019/9/5
|
*/
|
@Repository
|
class ObdThresholdValueDaoImpl(val obdThresholdValueMapper: ThresholdValueMapper) : ObdThresholdValueRepository {
|
|
override fun save(thresholdValueVo: ThresholdValueVo): Boolean {
|
val thresholdValue = ThresholdValue()
|
BeanUtils.copyProperties(thresholdValueVo, thresholdValue)
|
return obdThresholdValueMapper.insert(thresholdValue) == 1
|
}
|
|
override fun update(thresholdValueVo: ThresholdValueVo): Boolean {
|
val thresholdValue = ThresholdValue()
|
BeanUtils.copyProperties(thresholdValueVo, thresholdValue)
|
return obdThresholdValueMapper.updateByPrimaryKey(thresholdValue) == 1
|
}
|
|
override fun getByVinCode(vinCode: String): ThresholdValueVo? {
|
val example = Example(ThresholdValue::class.java).apply {
|
createCriteria().andEqualTo("obdVin", vinCode)
|
}
|
|
val result = obdThresholdValueMapper.selectByExample(example)
|
|
if (result.isNotEmpty()) {
|
val vo = ThresholdValueVo()
|
BeanUtils.copyProperties(vo, result[0])
|
return vo
|
}
|
|
return null
|
}
|
|
}
|