package com.flightfeather.uav.repository.impl
|
|
import com.flightfeather.uav.domain.entity.ThresholdValue
|
import com.flightfeather.uav.domain.mapper.ThresholdValueMapper
|
import com.flightfeather.uav.lightshare.bean.ThresholdValueVo
|
import com.flightfeather.uav.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(userId: String, thresholdValueVo: ThresholdValueVo): Boolean {
|
val thresholdValue = ThresholdValue()
|
BeanUtils.copyProperties(thresholdValueVo, thresholdValue)
|
val example = Example(ThresholdValue::class.java).apply {
|
createCriteria().andEqualTo("obdVin", thresholdValueVo.obdVin)
|
}
|
val tempResult = obdThresholdValueMapper.selectByExample(example)
|
return if (tempResult.isNotEmpty())
|
false
|
else
|
obdThresholdValueMapper.insert(thresholdValue) == 1
|
}
|
|
override fun update(userId: String, thresholdValueVo: ThresholdValueVo): Boolean {
|
val thresholdValue = ThresholdValue()
|
BeanUtils.copyProperties(thresholdValueVo, thresholdValue)
|
val example = Example(ThresholdValue::class.java).apply {
|
createCriteria().andEqualTo("obdVin", thresholdValue.obdVin)
|
}
|
return obdThresholdValueMapper.updateByExample(thresholdValue, example) == 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(result[0], vo)
|
return vo
|
}
|
|
return null
|
}
|
|
}
|