diff --git a/db/HGPdtToolDb/HGPdtToolDb.h b/db/HGPdtToolDb/HGPdtToolDb.h index f7d4905..6717fcd 100644 --- a/db/HGPdtToolDb/HGPdtToolDb.h +++ b/db/HGPdtToolDb/HGPdtToolDb.h @@ -3,6 +3,7 @@ #include "base/HGDef.h" #include "base/HGBaseErr.h" +#include "HGPdtToolDbErr.h" /* 管理员账户 */ #define HGPDTTOOLDB_USERTYPE_ROOT 1L diff --git a/db/HGPdtToolDb/HGPdtToolDbErr.h b/db/HGPdtToolDb/HGPdtToolDbErr.h new file mode 100644 index 0000000..93a8c44 --- /dev/null +++ b/db/HGPdtToolDb/HGPdtToolDbErr.h @@ -0,0 +1,15 @@ +#ifndef __HGPDTTOOLDBERR_H__ +#define __HGPDTTOOLDBERR_H__ + +/* 一般错误 */ +#define HGPDTTOOLDB_ERR_FAIL 0x00006001L +/* 非法的用户 */ +#define HGPDTTOOLDB_ERR_INVALID_USER 0x00006002L +/* 错误的密码 */ +#define HGPDTTOOLDB_ERR_WRONG_PASSWORD 0x00006003L +/* 数据库错误 */ +#define HGPDTTOOLDB_ERR_DATABASE 0x00006004L +/* 连接错误 */ +#define HGPDTTOOLDB_ERR_CONNECT 0x00006005L + +#endif /* __HGPDTTOOLDBERR_H__ */ \ No newline at end of file diff --git a/db/HGPdtToolDb/HGPdtToolDbImpl.cpp b/db/HGPdtToolDb/HGPdtToolDbImpl.cpp index e7a1a7a..e3ba81b 100644 --- a/db/HGPdtToolDb/HGPdtToolDbImpl.cpp +++ b/db/HGPdtToolDb/HGPdtToolDbImpl.cpp @@ -132,7 +132,7 @@ HGResult HGPdtToolDbUserMgrImpl::Create(const HGChar* host, HGUShort port, const { // 连接错误 mysql_close(sql); - return HGBASE_ERR_FAIL; + return HGPDTTOOLDB_ERR_CONNECT; } std::string password = GetPassword(sql, userName); @@ -140,7 +140,7 @@ HGResult HGPdtToolDbUserMgrImpl::Create(const HGChar* host, HGUShort port, const { // 用户不存在 mysql_close(sql); - return HGBASE_ERR_FAIL; + return HGPDTTOOLDB_ERR_INVALID_USER; } std::string authString = GetAuthString(sql, pwd); @@ -148,7 +148,7 @@ HGResult HGPdtToolDbUserMgrImpl::Create(const HGChar* host, HGUShort port, const { // 密码不正确 mysql_close(sql); - return HGBASE_ERR_FAIL; + return HGPDTTOOLDB_ERR_WRONG_PASSWORD; } if (0 != CreateUserConfigTable(sql, userName) || 0 != CreateMainTestTable(sql) @@ -259,7 +259,7 @@ HGResult HGPdtToolDbUserMgrImpl::GetUserList(HGChar** userNameList, HGUInt maxLe break; } - assert(NULL != row && NULL != row[0]); + assert(NULL != row[0]); userNameList[*count] = (HGChar*)malloc(strlen(row[0]) + 1); assert(NULL != userNameList[*count]); strcpy(userNameList[*count], row[0]); @@ -392,7 +392,7 @@ HGResult HGPdtToolDbUserMgrImpl::ModifyPassword(const HGChar* oldPwd, const HGCh if (password != authString) { // 旧密码错误 - return HGBASE_ERR_FAIL; + return HGPDTTOOLDB_ERR_WRONG_PASSWORD; } char sqlCmd[1024] = {0}; diff --git a/db/HGPdtToolDbTest/HGPdtToolDbTest.cpp b/db/HGPdtToolDbTest/HGPdtToolDbTest.cpp index 3d35f94..ba04ef6 100644 --- a/db/HGPdtToolDbTest/HGPdtToolDbTest.cpp +++ b/db/HGPdtToolDbTest/HGPdtToolDbTest.cpp @@ -5,7 +5,7 @@ int main() { HGPdtToolDbUserMgr userMgr = NULL; - HGPdtToolDb_CreateUserMgr("127.0.0.1", 3306, "huago", "123456", &userMgr); + HGPdtToolDb_CreateUserMgr("127.0.0.1", 3306, "root", "123456", &userMgr); if (NULL != userMgr) { HGChar* name[256];