TbTopoPhysicalDeviceDao.java
2.13 KB
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
61
62
63
64
65
66
67
68
69
70
71
package com.sitech.snmptrap;
import com.sitech.database.dao.BaseDao;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* @author frank zmm@honggroup.com.cn
* @Description: 物理设备类对应dao。
* @Package com.sitech.snmptrap
* @ClassName: com.sitech.snmptrap.TbTopoPhysicalDeviceDao
* @date 2017年03月03日 10:20
*/
public class TbTopoPhysicalDeviceDao extends BaseDao {
/**
* 添加物理设备,如果该设备已经存在,则修改。
* @param physicalDevice
*/
public void addTbTopoPhysicalDevice(TbTopoPhysicalDeviceBean physicalDevice){
try {
int updateSum = sqlmapClient.update("updateTbTopoPhysicalDevice",physicalDevice);
if(updateSum == 0){
sqlmapClient.insert("addTbTopoPhysicalDevice", physicalDevice);
}
} catch (Exception e) {
error.error("Exception while addTbTopoPhysicalDevice.", e);
}
}
/**
* 按照设备ID删除设备。
* @param deviceId
*/
public int deleteTbTopoPhysicalDevice(String deviceId){
int result=0;
try {
result=sqlmapClient.delete("deleteTbTopoPhysicalDevice", deviceId);
} catch (Exception e) {
error.error("Exception while deleteTbTopoPhysicalDevice.", e);
}
return result;
}
public int deletePhysicalDeviceByIp(String ip){
try {
return sqlmapClient.delete("deletePhysicalDeviceByIp", ip);
} catch (Exception e) {
error.error("Exception while deletePhysicalDeviceByIp.", e);
}
return -1;
}
public List<TbTopoPhysicalDeviceBean> getPhysicalDeviceByIp(String deviceIp){
HashMap<String,String> param=new HashMap<String, String>();
param.put("DEVICE_IP",deviceIp);
List<TbTopoPhysicalDeviceBean> beanList=new ArrayList<TbTopoPhysicalDeviceBean>();
try {
beanList=sqlmapClient.queryForList("queryTbTopoPhysicalDevice", param);
} catch (SQLException e) {
e.printStackTrace();
}
return beanList;
}
}