Skip to content

Commit 64e2859

Browse files
committed
added:hardware code login support
1 parent d20b69d commit 64e2859

File tree

8 files changed

+312
-19
lines changed

8 files changed

+312
-19
lines changed

XEngine_Source/AuthorizeModule_Database/AuthorizeModule_Database.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ EXPORTS
99
DBModule_SQLite_UserDelete
1010
DBModule_SQLite_UserRegister
1111
DBModule_SQLite_UserQuery
12+
DBModule_SQLite_CodeQuery
1213
DBModule_SQLite_UserPay
1314
DBModule_SQLite_UserLeave
1415
DBModule_SQLite_UserSet
@@ -43,6 +44,7 @@ EXPORTS
4344
DBModule_MySQL_UserDelete
4445
DBModule_MySQL_UserRegister
4546
DBModule_MySQL_UserQuery
47+
DBModule_MySQL_CodeQuery
4648
DBModule_MySQL_UserPay
4749
DBModule_MySQL_UserLeave
4850
DBModule_MySQL_UserSet

XEngine_Source/AuthorizeModule_Database/DBModule_MySQL/DBModule_MySQL.cpp

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,136 @@ bool CDBModule_MySQL::DBModule_MySQL_UserQuery(LPCXSTR lpszUserName, AUTHREG_USE
265265
return true;
266266
}
267267
/********************************************************************
268+
函数名称:DBModule_MySQL_CodeQuery
269+
函数功能:硬件吗查询用户信息
270+
参数.一:lpszUserName
271+
In/Out:In
272+
类型:常量字符指针
273+
可空:N
274+
意思:要查询的指定信息
275+
参数.二:pSt_UserInfo
276+
In/Out:Out
277+
类型:数据结构指针
278+
可空:Y
279+
意思:如果为空NULL,那么将只判断此用户是否存在
280+
返回值
281+
类型:逻辑型
282+
意思:是否查询成功
283+
备注:
284+
*********************************************************************/
285+
bool CDBModule_MySQL::DBModule_MySQL_CodeQuery(LPCXSTR lpszHardCode, AUTHREG_USERTABLE* pSt_UserInfo /* = NULL */)
286+
{
287+
SQLPacket_IsErrorOccur = false;
288+
//查询
289+
XNETHANDLE xhTable = 0;
290+
__int64u nColumn = 0;
291+
__int64u nRow = 0;
292+
293+
XCHAR tszSQLStatement[1024]; //SQL语句
294+
memset(tszSQLStatement, '\0', 1024);
295+
296+
_xstprintf(tszSQLStatement, _X("SELECT * FROM `Authorize_User` WHERE HardCode = '%s'"), lpszHardCode);
297+
if (!DataBase_MySQL_ExecuteQuery(xhData, &xhTable, tszSQLStatement, &nRow, &nColumn))
298+
{
299+
SQLPacket_IsErrorOccur = true;
300+
SQLPacket_dwErrorCode = ERROR_AUTHORIZE_MODULE_DATABASE_GETTABLE;
301+
return false;
302+
}
303+
if (nRow <= 0)
304+
{
305+
SQLPacket_IsErrorOccur = true;
306+
SQLPacket_dwErrorCode = ERROR_AUTHORIZE_MODULE_DATABASE_GETTABLE;
307+
return false;
308+
}
309+
XCHAR** pptszResult = DataBase_MySQL_GetResult(xhData, xhTable);
310+
if (NULL != pSt_UserInfo)
311+
{
312+
memset(pSt_UserInfo, '\0', sizeof(AUTHREG_USERTABLE));
313+
314+
//ID
315+
int nFliedValue = 0;
316+
317+
//用户名
318+
nFliedValue++;
319+
if (NULL != pptszResult[nFliedValue])
320+
{
321+
_tcsxcpy(pSt_UserInfo->st_UserInfo.tszUserName, pptszResult[nFliedValue]);
322+
}
323+
324+
//密码
325+
nFliedValue++;
326+
if (NULL != pptszResult[nFliedValue])
327+
{
328+
_tcsxcpy(pSt_UserInfo->st_UserInfo.tszUserPass, pptszResult[nFliedValue]);
329+
}
330+
331+
//过期时间
332+
nFliedValue++;
333+
if (NULL != pptszResult[nFliedValue])
334+
{
335+
_tcsxcpy(pSt_UserInfo->tszLeftTime, pptszResult[nFliedValue]);
336+
}
337+
338+
//电子邮件
339+
nFliedValue++;
340+
if (NULL != pptszResult[nFliedValue])
341+
{
342+
_tcsxcpy(pSt_UserInfo->st_UserInfo.tszEMailAddr, pptszResult[nFliedValue]);
343+
}
344+
345+
//硬件码
346+
nFliedValue++;
347+
if (NULL != pptszResult[nFliedValue])
348+
{
349+
_tcsxcpy(pSt_UserInfo->tszHardCode, pptszResult[nFliedValue]);
350+
}
351+
352+
//充值卡类型
353+
nFliedValue++;
354+
if (NULL != pptszResult[nFliedValue])
355+
{
356+
pSt_UserInfo->enSerialType = (ENUM_AUTHORIZE_MODULE_SERIAL_TYPE)_ttxoi(pptszResult[nFliedValue]);
357+
}
358+
359+
//QQ号
360+
nFliedValue++;
361+
if (NULL != pptszResult[nFliedValue])
362+
{
363+
pSt_UserInfo->st_UserInfo.nPhoneNumber = _ttxoll(pptszResult[nFliedValue]);
364+
}
365+
366+
//身份证ID
367+
nFliedValue++;
368+
if (NULL != pptszResult[nFliedValue])
369+
{
370+
pSt_UserInfo->st_UserInfo.nIDNumber = _ttxoll(pptszResult[nFliedValue]);
371+
}
372+
373+
//用户级别 -1表示封禁
374+
nFliedValue++;
375+
if (NULL != pptszResult[nFliedValue])
376+
{
377+
pSt_UserInfo->st_UserInfo.nUserLevel = _ttxoi(pptszResult[nFliedValue]);
378+
}
379+
380+
//登录日期
381+
nFliedValue++;
382+
if (NULL != pptszResult[nFliedValue] && _tcsxlen(pptszResult[nFliedValue]) > 0)
383+
{
384+
_tcsxcpy(pSt_UserInfo->st_UserInfo.tszLoginTime, pptszResult[nFliedValue]);
385+
}
386+
//注册日期
387+
nFliedValue++;
388+
if (NULL != pptszResult[nFliedValue])
389+
{
390+
_tcsxcpy(pSt_UserInfo->st_UserInfo.tszCreateTime, pptszResult[nFliedValue]);
391+
}
392+
393+
}
394+
DataBase_MySQL_FreeResult(xhData, xhTable);
395+
return true;
396+
}
397+
/********************************************************************
268398
函数名称:DBModule_MySQL_UserPay
269399
函数功能:用户充值函数
270400
参数.一:lpszUserName

XEngine_Source/AuthorizeModule_Database/DBModule_MySQL/DBModule_MySQL.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class CDBModule_MySQL
2626
bool DBModule_MySQL_UserDelete(XENGINE_PROTOCOL_USERINFO* pSt_UserInfo); //删除用户
2727
bool DBModule_MySQL_UserRegister(AUTHREG_USERTABLE* pSt_UserInfo); //用户注册
2828
bool DBModule_MySQL_UserQuery(LPCXSTR lpszUserName, AUTHREG_USERTABLE* pSt_UserInfo = NULL); //用户查询
29+
bool DBModule_MySQL_CodeQuery(LPCXSTR lpszHardCode, AUTHREG_USERTABLE* pSt_UserInfo = NULL);
2930
bool DBModule_MySQL_UserPay(LPCXSTR lpszUserName, LPCXSTR lpszSerialName); //充值卡充值
3031
bool DBModule_MySQL_UserLeave(AUTHREG_PROTOCOL_TIME* pSt_TimeProtocol); //用户离开更新表
3132
bool DBModule_MySQL_UserSet(AUTHREG_USERTABLE* pSt_UserTable); //设置用户信息

XEngine_Source/AuthorizeModule_Database/DBModule_SQLite/DBModule_SQLite.cpp

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,94 @@ bool CDBModule_SQLite::DBModule_SQLite_UserQuery(LPCXSTR lpszUserName, AUTHREG_U
223223
return true;
224224
}
225225
/********************************************************************
226+
函数名称:DBModule_SQLite_CodeQuery
227+
函数功能:硬件吗查询用户信息
228+
参数.一:lpszUserName
229+
In/Out:In
230+
类型:常量字符指针
231+
可空:N
232+
意思:要查询的指定信息
233+
参数.二:pSt_UserInfo
234+
In/Out:Out
235+
类型:数据结构指针
236+
可空:Y
237+
意思:如果为空NULL,那么将只判断此用户是否存在
238+
返回值
239+
类型:逻辑型
240+
意思:是否查询成功
241+
备注:
242+
*********************************************************************/
243+
bool CDBModule_SQLite::DBModule_SQLite_CodeQuery(LPCXSTR lpszHardCode, AUTHREG_USERTABLE* pSt_UserInfo /* = NULL */)
244+
{
245+
SQLPacket_IsErrorOccur = false;
246+
247+
XCHAR tszSQLStatement[XPATH_MAX]; //SQL语句
248+
char** ppszResult = NULL;
249+
int nRow = 0;
250+
int nColumn = 0;
251+
memset(tszSQLStatement, '\0', XPATH_MAX);
252+
253+
_xstprintf(tszSQLStatement, _X("SELECT * FROM `Authorize_User` WHERE HardCode = '%s'"), lpszHardCode);
254+
if (!DataBase_SQLite_GetTable(xhData, tszSQLStatement, &ppszResult, &nRow, &nColumn))
255+
{
256+
SQLPacket_IsErrorOccur = true;
257+
SQLPacket_dwErrorCode = ERROR_AUTHORIZE_MODULE_DATABASE_GETTABLE;
258+
return false;
259+
}
260+
if ((0 == nRow) || (0 == nColumn))
261+
{
262+
SQLPacket_IsErrorOccur = true;
263+
SQLPacket_dwErrorCode = ERROR_AUTHORIZE_MODULE_DATABASE_NOTUSER;
264+
return false;
265+
}
266+
//如果是NULL,表示不想知道结果
267+
if (NULL != pSt_UserInfo)
268+
{
269+
memset(pSt_UserInfo, '\0', sizeof(AUTHREG_USERTABLE));
270+
//ID
271+
int nFliedValue = nColumn;
272+
//用户名
273+
nFliedValue++;
274+
_tcsxcpy(pSt_UserInfo->st_UserInfo.tszUserName, ppszResult[nFliedValue]);
275+
//密码
276+
nFliedValue++;
277+
_tcsxcpy(pSt_UserInfo->st_UserInfo.tszUserPass, ppszResult[nFliedValue]);
278+
//过期时间
279+
nFliedValue++;
280+
_tcsxcpy(pSt_UserInfo->tszLeftTime, ppszResult[nFliedValue]);
281+
//电子邮件
282+
nFliedValue++;
283+
_tcsxcpy(pSt_UserInfo->st_UserInfo.tszEMailAddr, ppszResult[nFliedValue]);
284+
//硬件码
285+
nFliedValue++;
286+
_tcsxcpy(pSt_UserInfo->tszHardCode, ppszResult[nFliedValue]);
287+
//充值卡类型
288+
nFliedValue++;
289+
pSt_UserInfo->enSerialType = (ENUM_AUTHORIZE_MODULE_SERIAL_TYPE)_ttxoi(ppszResult[nFliedValue]);
290+
//QQ号
291+
nFliedValue++;
292+
pSt_UserInfo->st_UserInfo.nPhoneNumber = _ttxoll(ppszResult[nFliedValue]);
293+
//身份证ID
294+
nFliedValue++;
295+
pSt_UserInfo->st_UserInfo.nIDNumber = _ttxoll(ppszResult[nFliedValue]);
296+
//用户级别 -1表示封禁
297+
nFliedValue++;
298+
pSt_UserInfo->st_UserInfo.nUserLevel = _ttxoi(ppszResult[nFliedValue]);
299+
//登录日期
300+
nFliedValue++;
301+
if (NULL != ppszResult[nFliedValue] && _tcsxlen(ppszResult[nFliedValue]) > 0)
302+
{
303+
_tcsxcpy(pSt_UserInfo->st_UserInfo.tszLoginTime, ppszResult[nFliedValue]);
304+
}
305+
//注册日期
306+
nFliedValue++;
307+
_tcsxcpy(pSt_UserInfo->st_UserInfo.tszCreateTime, ppszResult[nFliedValue]);
308+
}
309+
310+
DataBase_SQLite_FreeTable(ppszResult);
311+
return true;
312+
}
313+
/********************************************************************
226314
函数名称:DBModule_SQLite_UserPay
227315
函数功能:用户充值函数
228316
参数.一:lpszUserName

XEngine_Source/AuthorizeModule_Database/DBModule_SQLite/DBModule_SQLite.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class CDBModule_SQLite
2626
bool DBModule_SQLite_UserDelete(XENGINE_PROTOCOL_USERINFO* pSt_UserInfo); //删除用户
2727
bool DBModule_SQLite_UserRegister(AUTHREG_USERTABLE*pSt_UserInfo); //用户注册
2828
bool DBModule_SQLite_UserQuery(LPCXSTR lpszUserName, AUTHREG_USERTABLE* pSt_UserInfo = NULL); //用户查询
29+
bool DBModule_SQLite_CodeQuery(LPCXSTR lpszHardCode, AUTHREG_USERTABLE* pSt_UserInfo = NULL);
2930
bool DBModule_SQLite_UserPay(LPCXSTR lpszUserName,LPCXSTR lpszSerialName); //充值卡充值
3031
bool DBModule_SQLite_UserLeave(AUTHREG_PROTOCOL_TIME* pSt_TimeProtocol); //用户离开更新表
3132
bool DBModule_SQLite_UserSet(AUTHREG_USERTABLE* pSt_UserTable);

XEngine_Source/AuthorizeModule_Database/Database_Define.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,25 @@ extern "C" bool DBModule_SQLite_UserRegister(AUTHREG_USERTABLE * pSt_UserInfo);
9393
*********************************************************************/
9494
extern "C" bool DBModule_SQLite_UserQuery(LPCXSTR lpszUserName,AUTHREG_USERTABLE *pSt_UserInfo);
9595
/********************************************************************
96+
函数名称:DBModule_SQLite_CodeQuery
97+
函数功能:硬件吗查询用户信息
98+
参数.一:lpszUserName
99+
In/Out:In
100+
类型:常量字符指针
101+
可空:N
102+
意思:要查询的指定信息
103+
参数.二:pSt_UserInfo
104+
In/Out:Out
105+
类型:数据结构指针
106+
可空:Y
107+
意思:如果为空NULL,那么将只判断此用户是否存在
108+
返回值
109+
类型:逻辑型
110+
意思:是否查询成功
111+
备注:
112+
*********************************************************************/
113+
extern "C" bool DBModule_SQLite_CodeQuery(LPCXSTR lpszHardCode, AUTHREG_USERTABLE* pSt_UserInfo = NULL);
114+
/********************************************************************
96115
函数名称:DBModule_SQLite_UserPay
97116
函数功能:用户充值函数
98117
参数.一:lpszUserName
@@ -582,6 +601,25 @@ extern "C" bool DBModule_MySQL_UserRegister(AUTHREG_USERTABLE* pSt_UserInfo);
582601
*********************************************************************/
583602
extern "C" bool DBModule_MySQL_UserQuery(LPCXSTR lpszUserName, AUTHREG_USERTABLE* pSt_UserInfo);
584603
/********************************************************************
604+
函数名称:DBModule_MySQL_CodeQuery
605+
函数功能:硬件吗查询用户信息
606+
参数.一:lpszUserName
607+
In/Out:In
608+
类型:常量字符指针
609+
可空:N
610+
意思:要查询的指定信息
611+
参数.二:pSt_UserInfo
612+
In/Out:Out
613+
类型:数据结构指针
614+
可空:Y
615+
意思:如果为空NULL,那么将只判断此用户是否存在
616+
返回值
617+
类型:逻辑型
618+
意思:是否查询成功
619+
备注:
620+
*********************************************************************/
621+
extern "C" bool DBModule_MySQL_CodeQuery(LPCXSTR lpszHardCode, AUTHREG_USERTABLE* pSt_UserInfo = NULL);
622+
/********************************************************************
585623
函数名称:DBModule_MySQL_UserPay
586624
函数功能:用户充值函数
587625
参数.一:lpszUserName

XEngine_Source/AuthorizeModule_Database/pch.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ extern "C" bool DBModule_SQLite_UserQuery(LPCXSTR lpszUserName, AUTHREG_USERTABL
5151
{
5252
return m_DBSQLite.DBModule_SQLite_UserQuery(lpszUserName, pSt_UserInfo);
5353
}
54+
extern "C" bool DBModule_SQLite_CodeQuery(LPCXSTR lpszHardCode, AUTHREG_USERTABLE* pSt_UserInfo)
55+
{
56+
return m_DBSQLite.DBModule_SQLite_CodeQuery(lpszHardCode, pSt_UserInfo);
57+
}
5458
extern "C" bool DBModule_SQLite_UserPay(LPCXSTR lpszUserName, LPCXSTR lpszSerialName)
5559
{
5660
return m_DBSQLite.DBModule_SQLite_UserPay(lpszUserName, lpszSerialName);
@@ -167,6 +171,10 @@ extern "C" bool DBModule_MySQL_UserQuery(LPCXSTR lpszUserName, AUTHREG_USERTABLE
167171
{
168172
return m_DBMySQL.DBModule_MySQL_UserQuery(lpszUserName, pSt_UserInfo);
169173
}
174+
extern "C" bool DBModule_MySQL_CodeQuery(LPCXSTR lpszHardCode, AUTHREG_USERTABLE* pSt_UserInfo)
175+
{
176+
return m_DBMySQL.DBModule_MySQL_CodeQuery(lpszHardCode, pSt_UserInfo);
177+
}
170178
extern "C" bool DBModule_MySQL_UserPay(LPCXSTR lpszUserName, LPCXSTR lpszSerialName)
171179
{
172180
return m_DBMySQL.DBModule_MySQL_UserPay(lpszUserName, lpszSerialName);

0 commit comments

Comments
 (0)