-
Notifications
You must be signed in to change notification settings - Fork 0
/
smsmysqlfeecodegetter.h
executable file
·60 lines (50 loc) · 1.27 KB
/
smsmysqlfeecodegetter.h
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
#ifndef AKA_SMS_ACE5771E_097A_41e8_8680_BE313A126EFD
#define AKA_SMS_ACE5771E_097A_41e8_8680_BE313A126EFD
#include <sqlplus.hh>
#include <time.h>
#include <sstream>
#include <string>
#include "sms.h"
#include "smsfeecodegetter.h"
namespace SMS{
class CSMSMysqlFeeCodeGetter:public CSMSFeeCodeGetter{
Connection *m_pConn;
int isOutterConn;
public:
CSMSMysqlFeeCodeGetter(Connection* pConn=NULL){
if (pConn!=NULL) {
m_pConn=pConn;
isOutterConn=TRUE;
} else {
m_pConn=new Connection(use_exceptions);
try {
m_pConn->connect(DB_NAME, DB_HOST, DB_USER, DB_PASSWORD);
} catch (BadQuery er) {
syslog(LOG_ERR," connect DB error: %s",er.error.c_str());
exit(-1);
}
}
}
int getFee(int feeType, int* pFeeMoney){
try{
Query query=m_pConn->query();
query<< "select * from SMSFeeCode_TB where feeType="<<feeType;
Result res=query.store();
if (res.size()!=0) {
Row row=*(res.begin());
*pFeeMoney=atoi(row["FeeMoney"]);
return SUCCESS;
}
} catch ( BadQuery er) {
syslog(LOG_ERR," mysql query err : %s", er.error.c_str());
}
return FAILED;
}
~CSMSMysqlFeeCodeGetter(){
if (!isOutterConn) {
delete m_pConn;
}
}
};
}
#endif