添加错误码
This commit is contained in:
parent
1779aab94f
commit
e82d20cdac
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "base/HGDef.h"
|
||||
#include "base/HGBaseErr.h"
|
||||
#include "HGPdtToolDbErr.h"
|
||||
|
||||
/* 管理员账户 */
|
||||
#define HGPDTTOOLDB_USERTYPE_ROOT 1L
|
||||
|
|
|
@ -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__ */
|
|
@ -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};
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in New Issue