派生自 development/c++

pansen
2019-03-07 d3b7bbe7102cd089680a828f5d8f6402c8cf6342
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
 
#ifndef VSSUPPERSVRTBL_MANAGER_H
#define VSSUPPERSVRTBL_MANAGER_H
 
#include "../model/VssUpperSvrTbl.h"
#include "BaseDao.h"
 
#define VSSUpperSvrTbl_TABLE_NAME "VSSUpperSvrTbl"
 
/**
 * 创建上级平台服务器表管理类
 */
class VssUpperSvrTblDao : public BaseDao {
private:
    /** 创建上级平台服务器表构造函数 */
    VssUpperSvrTblDao() {}
public:
    /** 创建上级平台服务器表单例模式 */
    static VssUpperSvrTblDao* instance() {
        static VssUpperSvrTblDao instance;
        return &instance;
    }
    
    /** 添加创建上级平台服务器表 keyValuesToAdd 需要添加的列名和列值对map*/
    mysqlpp::SimpleResult addVssUpperSvrTbl(std::map<std::string, std::string>& keyValuesToAdd) {
        return add(keyValuesToAdd, VSSUpperSvrTbl_TABLE_NAME);
    }
    
    /** 删除创建上级平台服务器表 whereKey 列名;whereValue 列值 */
    bool deleteByColumn(string whereKey, string whereValue) {
        std::map<std::string, std::string> whereKeyValues;
        whereKeyValues[whereKey] = whereValue;
        return deleteVssUpperSvrTbl(whereKeyValues);
    }
 
    /** 删除创建上级平台服务器表 whereColumnNameValues 列名和列值对条件 */
    bool deleteVssUpperSvrTbl(std::map<std::string, std::string>& whereKeyValues) {
        return del(VSSUpperSvrTbl_TABLE_NAME, whereKeyValues);
    }
    
    /** 更新创建上级平台服务器表 keyValuesToUpdate 需要更新的列名和列值对; whereKeyValues 列名和列值条件 */
    bool updateVssUpperSvrTbl(std::map<std::string, std::string>& keyValuesToUpdate, 
                                    std::map<std::string, std::string>& whereKeyValues) {
        return update(keyValuesToUpdate, VSSUpperSvrTbl_TABLE_NAME, whereKeyValues);
    }
    
    /** 更新创建二级设备表 keyValuesToUpdate 需要更新的列名和列值对; whereKeyValues 列名和列值条件 */
    bool updateVssUpperSvrTbl(std::map<std::string, std::string>& keyValuesToUpdate,
                             string whereKey,
                             string whereValue) {
        std::map<std::string, std::string> whereKeyValues;
        whereKeyValues[whereKey] = whereValue;
        return update(keyValuesToUpdate, VSSUpperSvrTbl_TABLE_NAME, whereKeyValues);
    }
    
    /** 查询创建上级平台服务器表列表  querySql 要查询的sql语句 */
    vector<VssUpperSvrTbl> findVssUpperSvrTblList(string querySql) {
        vector<VssUpperSvrTbl> vssUpperSvrTblVec;
        vector<map<string, string>> rowDatList = findList(querySql);
        vssUpperSvrTblVec.reserve(rowDatList.size());
        for (auto rowData : rowDatList) {
            vssUpperSvrTblVec.emplace_back(mapToModel(rowData));
        }
        return vssUpperSvrTblVec;
    }
    
    /**查询创建上级平台服务器表列表 whereKeyValues 列名和列值对条件 */
    vector<VssUpperSvrTbl> findVssUpperSvrTblList(std::map<std::string, std::string>& whereKeyValues) {
        return findVssUpperSvrTblList(string("select * from ") + VSSUpperSvrTbl_TABLE_NAME + " where 1=1 " + getWhereColumnNameValuePair(whereKeyValues));
    }
    
    /**查询所有创建上级平台服务器表列表 */
    vector<VssUpperSvrTbl> findAllVssUpperSvrTblList() {
        return findVssUpperSvrTblList(string("select * from ") + VSSUpperSvrTbl_TABLE_NAME + " where 1=1 ");
    }
    
    /** 查询map列表 querySql 要查询的sql语句 */
    vector<map<string, string>> findMapList(string querySql) {
        return findList(querySql);
    }
    
    /** 执行sql语句 */
    bool execute(string sql) {
        return exec(move(sql));
    }
    
    /** map转model类 */
    VssUpperSvrTbl mapToModel(map<string, string>& rowData) {
        VssUpperSvrTbl vssUpperSvrTbl;
        string IDValue = rowData[VssUpperSvrTbl_ID];
        if (IDValue.length() != 0 && IDValue != "NULL") {
            vssUpperSvrTbl.ID = std::stoi(IDValue);
        }
        string NameValue = rowData[VssUpperSvrTbl_Name];
        if (NameValue.length() != 0 && NameValue != "NULL") {
            vssUpperSvrTbl.Name = NameValue;
        }
        string PublicIDValue = rowData[VssUpperSvrTbl_PublicID];
        if (PublicIDValue.length() != 0 && PublicIDValue != "NULL") {
            vssUpperSvrTbl.PublicID = PublicIDValue;
        }
        string AuthUsernameValue = rowData[VssUpperSvrTbl_AuthUsername];
        if (AuthUsernameValue.length() != 0 && AuthUsernameValue != "NULL") {
            vssUpperSvrTbl.AuthUsername = AuthUsernameValue;
        }
        string AuthPasswdValue = rowData[VssUpperSvrTbl_AuthPasswd];
        if (AuthPasswdValue.length() != 0 && AuthPasswdValue != "NULL") {
            vssUpperSvrTbl.AuthPasswd = AuthPasswdValue;
        }
        string DomainValue = rowData[VssUpperSvrTbl_Domain];
        if (DomainValue.length() != 0 && DomainValue != "NULL") {
            vssUpperSvrTbl.Domain = DomainValue;
        }
        string IPValue = rowData[VssUpperSvrTbl_IP];
        if (IPValue.length() != 0 && IPValue != "NULL") {
            vssUpperSvrTbl.IP = IPValue;
        }
        string PortValue = rowData[VssUpperSvrTbl_Port];
        if (PortValue.length() != 0 && PortValue != "NULL") {
            vssUpperSvrTbl.Port = std::stoi(PortValue);
        }
        string RegisterTimeValue = rowData[VssUpperSvrTbl_RegisterTime];
        if (RegisterTimeValue.length() != 0 && RegisterTimeValue != "NULL") {
            vssUpperSvrTbl.RegisterTime = std::stoi(RegisterTimeValue);
        }
        string KeepAliveTimeValue = rowData[VssUpperSvrTbl_KeepAliveTime];
        if (KeepAliveTimeValue.length() != 0 && KeepAliveTimeValue != "NULL") {
            vssUpperSvrTbl.KeepAliveTime = std::stoi(KeepAliveTimeValue);
        }
        string AliveValue = rowData[VssUpperSvrTbl_Alive];
        if (AliveValue.length() != 0 && AliveValue != "NULL") {
            vssUpperSvrTbl.Alive = std::stoi(AliveValue);
        }
        string IsSyncTimeValue = rowData[VssUpperSvrTbl_IsSyncTime];
        if (IsSyncTimeValue.length() != 0 && IsSyncTimeValue != "NULL") {
            vssUpperSvrTbl.IsSyncTime = std::stoi(IsSyncTimeValue);
        }
        string PushProtocolValue = rowData[VssUpperSvrTbl_PushProtocol];
        if (PushProtocolValue.length() != 0 && PushProtocolValue != "NULL") {
            vssUpperSvrTbl.PushProtocol = std::stoi(PushProtocolValue);
        }
        string PlatformInfoValue = rowData[VssUpperSvrTbl_PlatformInfo];
        if (PlatformInfoValue.length() != 0 && PlatformInfoValue != "NULL") {
            vssUpperSvrTbl.PlatformInfo = std::stoi(PlatformInfoValue);
        }
        string IsEnableValue = rowData[VssUpperSvrTbl_IsEnable];
        if (IsEnableValue.length() != 0 && IsEnableValue != "NULL") {
            vssUpperSvrTbl.IsEnable = std::stoi(IsEnableValue);
        }
        string UpdateTimeValue = rowData[VssUpperSvrTbl_UpdateTime];
        if (UpdateTimeValue.length() != 0 && UpdateTimeValue != "NULL") {
            vssUpperSvrTbl.UpdateTime = UpdateTimeValue;
        }
        return vssUpperSvrTbl;
    }
   
};
 
 
#endif //VSSUPPERSVRTBL_MANAGER_H