Skip to content

Commit 86599d0

Browse files
committed
added:id region convert supported
1 parent 10e662e commit 86599d0

File tree

17 files changed

+368
-1
lines changed

17 files changed

+368
-1
lines changed

XEngine_Source/XEngine_ModuleDatabase/ModuleDB_Define.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,25 @@ extern "C" bool ModuleDatabase_IDCard_Destory();
5959
备注:
6060
*********************************************************************/
6161
extern "C" bool ModuleDatabase_IDCard_QueryRegion(XENGINE_IDREGION * pSt_IDRegion, XENGINE_IDCARDINFO * pSt_IDInfo);
62+
/********************************************************************
63+
函数名称:ModuleDatabase_IDCard_QueryByAddr
64+
函数功能:查询地址对应的区域ID
65+
参数.一:pSt_IDRegion
66+
In/Out:Out
67+
类型:数据结构指针
68+
可空:N
69+
意思:输出查询到的位置信息
70+
参数.二:pInt_IDNumber
71+
In/Out:Out
72+
类型:整数型指针
73+
可空:N
74+
意思:输出对应ID
75+
返回值
76+
类型:逻辑型
77+
意思:是否成功
78+
备注:
79+
*********************************************************************/
80+
extern "C" bool ModuleDatabase_IDCard_QueryByAddr(XENGINE_IDREGION* pSt_IDRegion, int* pInt_IDNumber);
6281
/************************************************************************/
6382
/* 导出的银行卡信息函数 */
6483
/************************************************************************/

XEngine_Source/XEngine_ModuleDatabase/ModuleDatabase_IDCard/ModuleDatabase_IDCard.cpp

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,142 @@ bool CModuleDatabase_IDCard::ModuleDatabase_IDCard_QueryRegion(XENGINE_IDREGION*
9797
return true;
9898
}
9999
/********************************************************************
100+
函数名称:ModuleDatabase_IDCard_QueryByAddr
101+
函数功能:查询地址对应的区域ID
102+
参数.一:pSt_IDRegion
103+
In/Out:Out
104+
类型:数据结构指针
105+
可空:N
106+
意思:输出查询到的位置信息
107+
参数.二:pInt_IDNumber
108+
In/Out:Out
109+
类型:整数型指针
110+
可空:N
111+
意思:输出对应ID
112+
返回值
113+
类型:逻辑型
114+
意思:是否成功
115+
备注:
116+
*********************************************************************/
117+
bool CModuleDatabase_IDCard::ModuleDatabase_IDCard_QueryByAddr(XENGINE_IDREGION* pSt_IDRegion, int* pInt_IDNumber)
118+
{
119+
DBModule_IsErrorOccur = false;
120+
121+
if ((NULL == pSt_IDRegion) || (NULL == pInt_IDNumber))
122+
{
123+
DBModule_IsErrorOccur = true;
124+
DBModule_dwErrorCode = ERROR_APISERVICE_MODULE_DATABASE_PARAMENT;
125+
return false;
126+
}
127+
//查询
128+
__int64u nLine = 0;
129+
__int64u nRow = 0;
130+
int nProvincer = 0;
131+
int nCity = 0;
132+
int nCounty = 0;
133+
XNETHANDLE xhTable = 0;
134+
XCHAR tszSQLStatement[1024];
135+
136+
memset(tszSQLStatement, '\0', sizeof(tszSQLStatement));
137+
_xstprintf(tszSQLStatement, _X("SELECT * FROM `RegionID` WHERE name = '%s'"), pSt_IDRegion->tszProvincer);
138+
139+
#ifdef _MSC_BUILD
140+
XCHAR tszUTFBuffer[1024] = {};
141+
int nULen = _tcsxlen(tszSQLStatement);
142+
BaseLib_OperatorCharset_AnsiToUTF(tszSQLStatement, tszUTFBuffer, &nULen);
143+
if (!DataBase_MySQL_ExecuteQuery(xhDBSQL, &xhTable, tszUTFBuffer, &nLine, &nRow))
144+
#else
145+
if (!DataBase_MySQL_ExecuteQuery(xhDBSQL, &xhTable, tszSQLStatement, &nLine, &nRow))
146+
#endif
147+
{
148+
DBModule_IsErrorOccur = true;
149+
DBModule_dwErrorCode = DataBase_GetLastError();
150+
return false;
151+
}
152+
if (nLine <= 0)
153+
{
154+
DBModule_IsErrorOccur = true;
155+
DBModule_dwErrorCode = ERROR_APISERVICE_MODULE_DATABASE_NOTFOUND;
156+
return false;
157+
}
158+
XCHAR** pptszResult = DataBase_MySQL_GetResult(xhDBSQL, xhTable);
159+
nProvincer = _ttxoi(pptszResult[0]);
160+
DataBase_MySQL_FreeResult(xhDBSQL, xhTable);
161+
162+
if (_tcsxlen(pSt_IDRegion->tszCity) > 0)
163+
{
164+
memset(tszSQLStatement, '\0', sizeof(tszSQLStatement));
165+
_xstprintf(tszSQLStatement, _X("SELECT * FROM `RegionID` WHERE name = '%s' AND parentCode = %d"), pSt_IDRegion->tszCity, nProvincer);
166+
167+
#ifdef _MSC_BUILD
168+
XCHAR tszUTFBuffer[1024] = {};
169+
int nULen = _tcsxlen(tszSQLStatement);
170+
BaseLib_OperatorCharset_AnsiToUTF(tszSQLStatement, tszUTFBuffer, &nULen);
171+
if (!DataBase_MySQL_ExecuteQuery(xhDBSQL, &xhTable, tszUTFBuffer, &nLine, &nRow))
172+
#else
173+
if (!DataBase_MySQL_ExecuteQuery(xhDBSQL, &xhTable, tszSQLStatement, &nLine, &nRow))
174+
#endif
175+
{
176+
DBModule_IsErrorOccur = true;
177+
DBModule_dwErrorCode = DataBase_GetLastError();
178+
return false;
179+
}
180+
if (nLine <= 0)
181+
{
182+
DBModule_IsErrorOccur = true;
183+
DBModule_dwErrorCode = ERROR_APISERVICE_MODULE_DATABASE_NOTFOUND;
184+
return false;
185+
}
186+
XCHAR** pptszResult = DataBase_MySQL_GetResult(xhDBSQL, xhTable);
187+
nCity = _ttxoi(pptszResult[0]);
188+
DataBase_MySQL_FreeResult(xhDBSQL, xhTable);
189+
}
190+
191+
if (_tcsxlen(pSt_IDRegion->tszCounty) > 0)
192+
{
193+
memset(tszSQLStatement, '\0', sizeof(tszSQLStatement));
194+
_xstprintf(tszSQLStatement, _X("SELECT * FROM `RegionID` WHERE name = '%s' AND parentCode = %d"), pSt_IDRegion->tszCounty, nCity);
195+
196+
#ifdef _MSC_BUILD
197+
XCHAR tszUTFBuffer[1024] = {};
198+
int nULen = _tcsxlen(tszSQLStatement);
199+
BaseLib_OperatorCharset_AnsiToUTF(tszSQLStatement, tszUTFBuffer, &nULen);
200+
if (!DataBase_MySQL_ExecuteQuery(xhDBSQL, &xhTable, tszUTFBuffer, &nLine, &nRow))
201+
#else
202+
if (!DataBase_MySQL_ExecuteQuery(xhDBSQL, &xhTable, tszSQLStatement, &nLine, &nRow))
203+
#endif
204+
{
205+
DBModule_IsErrorOccur = true;
206+
DBModule_dwErrorCode = DataBase_GetLastError();
207+
return false;
208+
}
209+
if (nLine <= 0)
210+
{
211+
DBModule_IsErrorOccur = true;
212+
DBModule_dwErrorCode = ERROR_APISERVICE_MODULE_DATABASE_NOTFOUND;
213+
return false;
214+
}
215+
XCHAR** pptszResult = DataBase_MySQL_GetResult(xhDBSQL, xhTable);
216+
nCounty = _ttxoi(pptszResult[0]);
217+
DataBase_MySQL_FreeResult(xhDBSQL, xhTable);
218+
}
219+
220+
if (0 == nCounty && 0 == nCity)
221+
{
222+
*pInt_IDNumber = nProvincer;
223+
}
224+
else if (0 == nCounty && 0 != nCity)
225+
{
226+
*pInt_IDNumber = nCity;
227+
}
228+
else
229+
{
230+
*pInt_IDNumber = nCounty;
231+
}
232+
233+
return true;
234+
}
235+
/********************************************************************
100236
函数名称:ModuleDatabase_IDCard_QueryProvincer
101237
函数功能:查询省份信息
102238
参数.一:pSt_IDRegion

XEngine_Source/XEngine_ModuleDatabase/ModuleDatabase_IDCard/ModuleDatabase_IDCard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class CModuleDatabase_IDCard
2121
bool ModuleDatabase_IDCard_Init(DATABASE_MYSQL_CONNECTINFO* pSt_DBConnector);
2222
bool ModuleDatabase_IDCard_Destory();
2323
bool ModuleDatabase_IDCard_QueryRegion(XENGINE_IDREGION* pSt_IDRegion, XENGINE_IDCARDINFO* pSt_IDInfo);
24+
public:
25+
bool ModuleDatabase_IDCard_QueryByAddr(XENGINE_IDREGION* pSt_IDRegion, int* pInt_IDNumber);
2426
protected:
2527
bool ModuleDatabase_IDCard_QueryProvincer(XENGINE_IDREGION* pSt_IDRegion, XENGINE_IDCARDINFO* pSt_IDInfo);
2628
bool ModuleDatabase_IDCard_QueryCity(XENGINE_IDREGION* pSt_IDRegion, XENGINE_IDCARDINFO* pSt_IDInfo);

XEngine_Source/XEngine_ModuleDatabase/XEngine_ModuleDatabase.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ EXPORTS
66
ModuleDatabase_IDCard_Init
77
ModuleDatabase_IDCard_Destory
88
ModuleDatabase_IDCard_QueryRegion
9+
ModuleDatabase_IDCard_QueryByAddr
910

1011
ModuleDatabase_Bank_Init
1112
ModuleDatabase_Bank_Destory

XEngine_Source/XEngine_ModuleDatabase/pch.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ extern "C" bool ModuleDatabase_IDCard_QueryRegion(XENGINE_IDREGION * pSt_IDRegio
5151
{
5252
return m_IDCard.ModuleDatabase_IDCard_QueryRegion(pSt_IDRegion, pSt_IDInfo);
5353
}
54+
extern "C" bool ModuleDatabase_IDCard_QueryByAddr(XENGINE_IDREGION * pSt_IDRegion, int* pInt_IDNumber)
55+
{
56+
return m_IDCard.ModuleDatabase_IDCard_QueryByAddr(pSt_IDRegion, pInt_IDNumber);
57+
}
5458
/************************************************************************/
5559
/* 导出的银行卡信息函数 */
5660
/************************************************************************/

XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Define.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,35 @@ extern "C" bool ModuleProtocol_Packet_Common(XCHAR * ptszMsgBuffer, int* pInt_Ms
8686
*********************************************************************/
8787
extern "C" bool ModuleProtocol_Packet_IDQuery(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_IDCARDINFO* pSt_IDInfo, XENGINE_IDREGION* pSt_IDRegion, int nCode = 0, LPCXSTR lpszMsgBuffer = NULL);
8888
/********************************************************************
89+
函数名称:ModuleProtocol_Packet_IDRegion
90+
函数功能:ID区域转换
91+
参数.一:ptszMsgBuffer
92+
In/Out:Out
93+
类型:字符指针
94+
可空:N
95+
意思:输出打包的数据信息
96+
参数.二:pInt_MsgLen
97+
In/Out:Out
98+
类型:整数型指针
99+
可空:N
100+
意思:输出打包大小
101+
参数.三:pSt_IDRegion
102+
In/Out:In
103+
类型:数据结构指针
104+
可空:N
105+
意思:输入要打包的数据
106+
参数.四:nIDRegion
107+
In/Out:In
108+
类型:整数型
109+
可空:Y
110+
意思:输入要打包的ID
111+
返回值
112+
类型:逻辑型
113+
意思:是否成功
114+
备注:
115+
*********************************************************************/
116+
extern "C" bool ModuleProtocol_Packet_IDRegion(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_IDREGION* pSt_IDRegion, int nIDRegion);
117+
/********************************************************************
89118
函数名称:ModuleProtocol_Packet_BankQuery
90119
函数功能:银行卡信息查询打包为JSON
91120
参数.一:ptszMsgBuffer

XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,62 @@ bool CModuleProtocol_Packet::ModuleProtocol_Packet_IDQuery(XCHAR* ptszMsgBuffer,
153153
return true;
154154
}
155155
/********************************************************************
156+
函数名称:ModuleProtocol_Packet_IDRegion
157+
函数功能:ID区域转换
158+
参数.一:ptszMsgBuffer
159+
In/Out:Out
160+
类型:字符指针
161+
可空:N
162+
意思:输出打包的数据信息
163+
参数.二:pInt_MsgLen
164+
In/Out:Out
165+
类型:整数型指针
166+
可空:N
167+
意思:输出打包大小
168+
参数.三:pSt_IDRegion
169+
In/Out:In
170+
类型:数据结构指针
171+
可空:N
172+
意思:输入要打包的数据
173+
参数.四:nIDRegion
174+
In/Out:In
175+
类型:整数型
176+
可空:Y
177+
意思:输入要打包的ID
178+
返回值
179+
类型:逻辑型
180+
意思:是否成功
181+
备注:
182+
*********************************************************************/
183+
bool CModuleProtocol_Packet::ModuleProtocol_Packet_IDRegion(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_IDREGION* pSt_IDRegion, int nIDRegion)
184+
{
185+
ModuleProtocol_IsErrorOccur = false;
186+
187+
if ((NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen))
188+
{
189+
ModuleProtocol_IsErrorOccur = true;
190+
ModuleProtocol_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PROTOCOL_PACKET_PARAMENT;
191+
return false;
192+
}
193+
Json::Value st_JsonRoot;
194+
Json::Value st_JsonObject;
195+
Json::StreamWriterBuilder st_JsonBuilder;
196+
197+
st_JsonObject["tszProvincer"] = pSt_IDRegion->tszProvincer;
198+
st_JsonObject["tszCity"] = pSt_IDRegion->tszCity;
199+
st_JsonObject["tszCounty"] = pSt_IDRegion->tszCounty;
200+
st_JsonObject["nIDRegion"] = nIDRegion;
201+
202+
st_JsonRoot["code"] = 0;
203+
st_JsonRoot["msg"] = "success";
204+
st_JsonRoot["data"] = st_JsonObject;
205+
st_JsonBuilder["emitUTF8"] = true;
206+
207+
*pInt_MsgLen = Json::writeString(st_JsonBuilder, st_JsonRoot).length();
208+
memcpy(ptszMsgBuffer, Json::writeString(st_JsonBuilder, st_JsonRoot).c_str(), *pInt_MsgLen);
209+
return true;
210+
}
211+
/********************************************************************
156212
函数名称:ModuleProtocol_Packet_BankQuery
157213
函数功能:银行卡信息查询打包为JSON
158214
参数.一:ptszMsgBuffer

XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class CModuleProtocol_Packet
2424
public:
2525
bool ModuleProtocol_Packet_Common(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, int nCode = 0, LPCXSTR lpszMsgBuffer = NULL);
2626
bool ModuleProtocol_Packet_IDQuery(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_IDCARDINFO* pSt_IDInfo, XENGINE_IDREGION* pSt_IDRegion, int nCode = 0, LPCXSTR lpszMsgBuffer = NULL);
27+
bool ModuleProtocol_Packet_IDRegion(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_IDREGION* pSt_IDRegion, int nIDRegion);
2728
bool ModuleProtocol_Packet_BankQuery(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_BANKINFO* pSt_BankInfo, int nCode = 0, LPCXSTR lpszMsgBuffer = NULL);
2829
bool ModuleProtocol_Packet_LanguageQuery(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_LANGUAGEINFO* pSt_LanguageInfo, int nCode = 0, LPCXSTR lpszMsgBuffer = NULL);
2930
bool ModuleProtocol_Packet_Locker(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XNETHANDLE xhToken, int nCode = 0, LPCXSTR lpszMsgBuffer = NULL);

XEngine_Source/XEngine_ModuleProtocol/XEngine_ModuleProtocol.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ EXPORTS
55

66
ModuleProtocol_Packet_Common
77
ModuleProtocol_Packet_IDQuery
8+
ModuleProtocol_Packet_IDRegion
89
ModuleProtocol_Packet_BankQuery
910
ModuleProtocol_Packet_LanguageQuery
1011
ModuleProtocol_Packet_Locker

XEngine_Source/XEngine_ModuleProtocol/pch.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ extern "C" bool ModuleProtocol_Packet_IDQuery(XCHAR * ptszMsgBuffer, int* pInt_M
3939
{
4040
return m_ProtocolPacket.ModuleProtocol_Packet_IDQuery(ptszMsgBuffer, pInt_MsgLen, pSt_IDInfo, pSt_IDRegion, nCode, lpszMsgBuffer);
4141
}
42+
extern "C" bool ModuleProtocol_Packet_IDRegion(XCHAR * ptszMsgBuffer, int* pInt_MsgLen, XENGINE_IDREGION * pSt_IDRegion, int nIDRegion)
43+
{
44+
return m_ProtocolPacket.ModuleProtocol_Packet_IDRegion(ptszMsgBuffer, pInt_MsgLen, pSt_IDRegion, nIDRegion);
45+
}
4246
extern "C" bool ModuleProtocol_Packet_BankQuery(XCHAR * ptszMsgBuffer, int* pInt_MsgLen, XENGINE_BANKINFO * pSt_BankInfo, int nCode, LPCXSTR lpszMsgBuffer)
4347
{
4448
return m_ProtocolPacket.ModuleProtocol_Packet_BankQuery(ptszMsgBuffer, pInt_MsgLen, pSt_BankInfo, nCode, lpszMsgBuffer);

0 commit comments

Comments
 (0)