feiyu02
2024-08-02 16b961c2210fe29fd494ac1f9d830dd93503961f
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package cn.flightfeather.supervision.domain.ds1.repository
 
import cn.flightfeather.supervision.domain.ds1.entity.DeviceInfo
import cn.flightfeather.supervision.domain.ds1.entity.DeviceLocation
import cn.flightfeather.supervision.domain.ds1.mapper.DeviceInfoMapper
import cn.flightfeather.supervision.domain.ds1.mapper.DeviceLocationMapper
import org.springframework.stereotype.Repository
 
/**
 *
 * @date 2024/7/24
 * @author feiyu02
 */
@Repository
class DeviceRep(
    private val deviceInfoMapper: DeviceInfoMapper,
    private val deviceLocationMapper: DeviceLocationMapper,
) {
    /***--DeviceInfo--***/
    fun findDevice(sceneId: String): DeviceInfo? {
        return deviceInfoMapper.selectByPrimaryKey(sceneId)
    }
 
    fun findDeviceList(sceneId: String): List<DeviceInfo> {
        return findDeviceList(DeviceInfo().apply { diSceneGuid = sceneId })
    }
 
    fun findDeviceList(deviceInfo: DeviceInfo): List<DeviceInfo> {
        return deviceInfoMapper.select(deviceInfo)
    }
 
    fun insertDevice(deviceInfo: DeviceInfo): Int {
        return deviceInfoMapper.insert(deviceInfo)
    }
 
    fun updateDevice(deviceInfo: DeviceInfo): Int {
        return deviceInfoMapper.updateByPrimaryKey(deviceInfo)
    }
 
    /***--DeviceLocation--***/
    fun findLocation(id: Int): DeviceLocation? {
        return deviceLocationMapper.selectByPrimaryKey(id)
    }
 
    fun findLocations(deviceId: Int): List<DeviceLocation> {
        return findLocations(DeviceLocation().apply { dlDeviceId = deviceId })
    }
 
    fun findLocations(location: DeviceLocation): List<DeviceLocation> {
        return deviceLocationMapper.select(location)
    }
 
    fun insertLocation(location: DeviceLocation): Int {
        return deviceLocationMapper.insert(location)
    }
 
    fun updateLocation(location: DeviceLocation): Int {
        return deviceLocationMapper.updateByPrimaryKey(location)
    }
}