Skip to content

Commit 6eff473

Browse files
committed
modify:can be delete owner info when delete user
1 parent 873c281 commit 6eff473

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

XEngine_Source/MQCore_DBModule/DBModule_MQUser/DBModule_MQUser.cpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -898,19 +898,33 @@ BOOL CDBModule_MQUser::DBModule_MQUser_OwnerDelete(XENGINE_DBTOPICOWNER* pSt_DBO
898898
TCHAR tszSQLStatement[10240];
899899
memset(tszSQLStatement, '\0', sizeof(tszSQLStatement));
900900

901-
_stprintf(tszSQLStatement, _T("DELETE FROM `KeyOwner` WHERE tszUserName = '%s' AND tszKeyName = '%s'"), pSt_DBOwner->tszUserName, pSt_DBOwner->tszQueueName);
902-
if (!DataBase_MySQL_Execute(xhDBSQL, tszSQLStatement, &nAffectRow))
901+
if ((_tcslen(pSt_DBOwner->tszUserName) > 0) && (_tcslen(pSt_DBOwner->tszQueueName) > 0))
903902
{
904-
DBModule_IsErrorOccur = TRUE;
905-
DBModule_dwErrorCode = DataBase_GetLastError();
906-
return FALSE;
903+
_stprintf(tszSQLStatement, _T("DELETE FROM `KeyOwner` WHERE tszUserName = '%s' AND tszKeyName = '%s'"), pSt_DBOwner->tszUserName, pSt_DBOwner->tszQueueName);
904+
if (!DataBase_MySQL_Execute(xhDBSQL, tszSQLStatement, &nAffectRow))
905+
{
906+
DBModule_IsErrorOccur = TRUE;
907+
DBModule_dwErrorCode = DataBase_GetLastError();
908+
return FALSE;
909+
}
910+
if (nAffectRow <= 0)
911+
{
912+
DBModule_IsErrorOccur = TRUE;
913+
DBModule_dwErrorCode = ERROR_XENGINE_MQCORE_DATABASE_NOTFOUND;
914+
return FALSE;
915+
}
907916
}
908-
if (nAffectRow <= 0)
917+
else
909918
{
910-
DBModule_IsErrorOccur = TRUE;
911-
DBModule_dwErrorCode = ERROR_XENGINE_MQCORE_DATABASE_NOTFOUND;
912-
return FALSE;
919+
_stprintf(tszSQLStatement, _T("DELETE FROM `KeyOwner` WHERE tszUserName = '%s'"), pSt_DBOwner->tszUserName);
920+
if (!DataBase_MySQL_Execute(xhDBSQL, tszSQLStatement))
921+
{
922+
DBModule_IsErrorOccur = TRUE;
923+
DBModule_dwErrorCode = DataBase_GetLastError();
924+
return FALSE;
925+
}
913926
}
927+
914928
return TRUE;
915929
}
916930
/********************************************************************

XEngine_Source/XEngine_MQServiceApp/MQService_TCPTask.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,16 @@ BOOL MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCTSTR lpszC
254254

255255
pSt_ProtocolHdr->wReserve = 0;
256256
XENGINE_DBUSERKEY st_UserKey;
257+
XENGINE_DBTOPICOWNER st_DBOwner;
258+
257259
memset(&st_UserKey, '\0', sizeof(XENGINE_DBUSERKEY));
260+
memset(&st_DBOwner, '\0', sizeof(XENGINE_DBTOPICOWNER));
258261

259262
_tcscpy(st_UserKey.tszUserName, st_UserInfo.tszUserName);
263+
_tcscpy(st_DBOwner.tszUserName, st_UserInfo.tszUserName);
264+
260265
DBModule_MQUser_KeyDelete(&st_UserKey);
266+
DBModule_MQUser_OwnerDelete(&st_DBOwner);
261267
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, NULL, tszSDBuffer, &nSDLen);
262268
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
263269
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("%s客户端:%s,请求用户删除成功,用户名:%s"), lpszClientType, lpszClientAddr, st_UserInfo.tszUserName);

0 commit comments

Comments
 (0)