package com.flightfeather.uav.domain.repository
|
|
import com.flightfeather.uav.domain.entity.DeviceInfo
|
import com.flightfeather.uav.domain.entity.Mission
|
import com.flightfeather.uav.domain.mapper.DeviceInfoMapper
|
import com.flightfeather.uav.domain.mapper.MissionMapper
|
import com.flightfeather.uav.socket.eunm.UWDeviceType
|
import org.springframework.stereotype.Repository
|
import tk.mybatis.mapper.entity.Example
|
|
@Repository
|
class DeviceRep(private val deviceInfoMapper: DeviceInfoMapper) {
|
|
fun find(deviceInfo: DeviceInfo): List<DeviceInfo> {
|
return deviceInfoMapper.select(deviceInfo)
|
}
|
|
/**
|
* 按字段条件相等查询
|
*/
|
fun find(deviceType: UWDeviceType?, asc: Boolean = true): List<DeviceInfo> {
|
return deviceInfoMapper.selectByExample(Example(DeviceInfo::class.java).apply {
|
createCriteria().andEqualTo("deviceType", deviceType?.value)
|
orderBy("displayIndex").apply {
|
if (asc) asc() else desc()
|
}
|
})
|
}
|
|
/**
|
* 插入一台新设备
|
*/
|
fun insert(deviceInfo: DeviceInfo): Int {
|
return deviceInfoMapper.insert(deviceInfo)
|
}
|
|
fun delete(deviceCode: String): Int {
|
return deviceInfoMapper.deleteByPrimaryKey(deviceCode)
|
}
|
}
|