@xmobitea/gn-server 2.6.5 → 2.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +198 -5
- package/apiReferences/Authenticate.json +1328 -1
- package/apiReferences/CharacterPlayer.json +3199 -1
- package/apiReferences/CloudScript.json +278 -1
- package/apiReferences/Content.json +324 -1
- package/apiReferences/GamePlayer.json +3844 -1
- package/apiReferences/Group.json +2454 -1
- package/apiReferences/Inventory.json +1964 -1
- package/apiReferences/MasterAdmin.json +5569 -1
- package/apiReferences/MasterPlayer.json +5924 -1
- package/apiReferences/Multiplayer.json +545 -1
- package/apiReferences/StoreInventory.json +1290 -1
- package/dist/GN-app-api/handler/controller/handler/characterPlayer/model/GroupMemberParam.d.ts +0 -1
- package/dist/GN-app-api/handler/controller/handler/cloudScript/ExecuteFunctionRequestHandler.d.ts +1 -1
- package/dist/GN-app-api/handler/controller/handler/group/model/GroupMemberParam.d.ts +0 -1
- package/dist/GN-app-api/handler/controller/handler/masterPlayer/SetPlayerBanRequestHandler.d.ts +2 -0
- package/dist/GN-app-api/service/CloudScriptEventService.d.ts +144 -0
- package/dist/GN-app-api/service/CloudScriptService.d.ts +1 -1
- package/dist/GN-app-api/service/EventCallbackService.d.ts +9 -17
- package/dist/GN-app-api/service/ICloudScriptService.d.ts +2 -2
- package/dist/GN-app-api/service/IEventCallbackService.d.ts +0 -14
- package/dist/GN-app-api/{handler/controller/handler/multiplayer/MatchmakingHandler.d.ts → service/IMatchmakingService.d.ts} +2 -19
- package/dist/GN-app-api/service/MatchmakingService.d.ts +21 -0
- package/dist/GN-startup/cloudScript/CloudScriptAdmin.ts +74 -0
- package/dist/GN-startup/cloudScript/CloudScriptDatabase.ts +93 -0
- package/dist/GN-startup/cloudScript/CloudScriptEvent.ts +158 -0
- package/dist/GN-startup/cloudScript/CloudScriptHttp.ts +31 -0
- package/dist/GN-startup/cloudScript/CloudScriptMail.ts +26 -0
- package/dist/GN-startup/cloudScript/CloudScriptMatchmaking.ts +14 -0
- package/dist/GN-startup/cloudScript/CloudScriptPushNotification.ts +65 -0
- package/dist/GN-startup/cloudScript/CloudScriptSocket.ts +64 -0
- package/dist/GN-startup/cloudScript/eventCallbackCloudScriptData.json +59 -17
- package/dist/GN-startup/cloudScript/templateCloudScript.ts +26 -385
- package/dist/GN-startup/cloudScript/templateEventCallback.ts +301 -509
- package/dist/GN-startup/middleware/ApiMiddleware.d.ts +1 -0
- package/dist/GN-startup/routes/SocketAppHandler.d.ts +7 -0
- package/dist/GNServer.d.ts +5 -1
- package/dist/RequestControllerUtils.d.ts +4 -0
- package/dist/index.d.ts +1 -1
- package/package.json +3 -3
- package/syncCode.js +1394 -0
- package/index.js +0 -26
package/syncCode.js
ADDED
|
@@ -0,0 +1,1394 @@
|
|
|
1
|
+
var secretPermissionItem = {
|
|
2
|
+
authenticate: {
|
|
3
|
+
loginByAccount: {},
|
|
4
|
+
loginByAndroidDeviceId: {},
|
|
5
|
+
loginByApple: {},
|
|
6
|
+
loginByCustomDeviceId: {},
|
|
7
|
+
loginByCustomId: {},
|
|
8
|
+
loginByFacebook: {},
|
|
9
|
+
loginByGenericService: {},
|
|
10
|
+
loginByGoogle: {},
|
|
11
|
+
loginByiOSDeviceId: {},
|
|
12
|
+
loginByWindowsPhoneDeviceId: {},
|
|
13
|
+
registerAccount: {},
|
|
14
|
+
loginByEditorDeviceId: {},
|
|
15
|
+
loginByLinuxDeviceId: {},
|
|
16
|
+
loginByMacOSDeviceId: {},
|
|
17
|
+
loginByWindowsDeviceId: {},
|
|
18
|
+
refreshAuthToken: {},
|
|
19
|
+
},
|
|
20
|
+
masterPlayer: {
|
|
21
|
+
linkAccount: {},
|
|
22
|
+
linkAndroidDeviceId: {},
|
|
23
|
+
linkApple: {},
|
|
24
|
+
linkCustomDeviceId: {},
|
|
25
|
+
linkCustomId: {},
|
|
26
|
+
linkEditorDeviceId: {},
|
|
27
|
+
linkFacebook: {},
|
|
28
|
+
linkGenericService: {},
|
|
29
|
+
linkGoogle: {},
|
|
30
|
+
linkiOSDeviceId: {},
|
|
31
|
+
linkLinuxDeviceId: {},
|
|
32
|
+
linkMacOSDeviceId: {},
|
|
33
|
+
linkWindowsDeviceId: {},
|
|
34
|
+
linkWindowsPhoneDeviceId: {},
|
|
35
|
+
|
|
36
|
+
unlinkAccount: {},
|
|
37
|
+
unlinkAndroidDeviceId: {},
|
|
38
|
+
unlinkApple: {},
|
|
39
|
+
unlinkCustomDeviceId: {},
|
|
40
|
+
unlinkCustomId: {},
|
|
41
|
+
unlinkEditorDeviceId: {},
|
|
42
|
+
unlinkFacebook: {},
|
|
43
|
+
unlinkGenericService: {},
|
|
44
|
+
unlinkGoogle: {},
|
|
45
|
+
unlinkiOSDeviceId: {},
|
|
46
|
+
unlinkLinuxDeviceId: {},
|
|
47
|
+
unlinkMacOSDeviceId: {},
|
|
48
|
+
unlinkWindowsDeviceId: {},
|
|
49
|
+
unlinkWindowsPhoneDeviceId: {},
|
|
50
|
+
|
|
51
|
+
addSegment: {},
|
|
52
|
+
removeSegment: {},
|
|
53
|
+
getSegment: {},
|
|
54
|
+
|
|
55
|
+
setTag: {},
|
|
56
|
+
removeTag: {},
|
|
57
|
+
getTag: {},
|
|
58
|
+
|
|
59
|
+
getDisplayName: {},
|
|
60
|
+
setDisplayName: {},
|
|
61
|
+
|
|
62
|
+
getTsCreate: {},
|
|
63
|
+
getIpAddressCreate: {},
|
|
64
|
+
|
|
65
|
+
setTsLastLogin: {},
|
|
66
|
+
getTsLastLogin: {},
|
|
67
|
+
|
|
68
|
+
setPlayerBan: {},
|
|
69
|
+
getPlayerBan: {},
|
|
70
|
+
|
|
71
|
+
setCountryCode: {},
|
|
72
|
+
getCountryCode: {},
|
|
73
|
+
|
|
74
|
+
changeAccountPassword: {},
|
|
75
|
+
resetAccountPassword: {},
|
|
76
|
+
|
|
77
|
+
setAvatar: {},
|
|
78
|
+
getAvatar: {},
|
|
79
|
+
|
|
80
|
+
changePlayerCurrency: {},
|
|
81
|
+
getPlayerCurrency: {},
|
|
82
|
+
|
|
83
|
+
changePlayerStatistics: {},
|
|
84
|
+
getPlayerStatistics: {},
|
|
85
|
+
|
|
86
|
+
getStatisticsLeaderboard: {},
|
|
87
|
+
getStatisticsLeaderboardAroundPlayer: {},
|
|
88
|
+
|
|
89
|
+
getCustomData: {},
|
|
90
|
+
setCustomData: {},
|
|
91
|
+
|
|
92
|
+
setPlayerData: {},
|
|
93
|
+
getPlayerData: {},
|
|
94
|
+
|
|
95
|
+
getPlayerInformation: {},
|
|
96
|
+
|
|
97
|
+
getPlayersWithApple: {},
|
|
98
|
+
getPlayersWithFacebook: {},
|
|
99
|
+
getPlayersWithGoogle: {},
|
|
100
|
+
getPlayersWithGenericService: {},
|
|
101
|
+
getPlayersWithSegment: {},
|
|
102
|
+
getPlayersWithTag: {},
|
|
103
|
+
getExternal: {},
|
|
104
|
+
|
|
105
|
+
getPlayersWithDisplayName: {},
|
|
106
|
+
|
|
107
|
+
setEmail: {},
|
|
108
|
+
getEmail: {},
|
|
109
|
+
},
|
|
110
|
+
gamePlayer: {
|
|
111
|
+
addSegment: {},
|
|
112
|
+
removeSegment: {},
|
|
113
|
+
getSegment: {},
|
|
114
|
+
|
|
115
|
+
setTag: {},
|
|
116
|
+
removeTag: {},
|
|
117
|
+
getTag: {},
|
|
118
|
+
|
|
119
|
+
getDisplayName: {},
|
|
120
|
+
setDisplayName: {},
|
|
121
|
+
|
|
122
|
+
getTsCreate: {},
|
|
123
|
+
getIpAddressCreate: {},
|
|
124
|
+
getTsLastLogin: {},
|
|
125
|
+
|
|
126
|
+
setPlayerBan: {},
|
|
127
|
+
getPlayerBan: {},
|
|
128
|
+
|
|
129
|
+
setCountryCode: {},
|
|
130
|
+
getCountryCode: {},
|
|
131
|
+
|
|
132
|
+
setAvatar: {},
|
|
133
|
+
getAvatar: {},
|
|
134
|
+
|
|
135
|
+
changePlayerCurrency: {},
|
|
136
|
+
getPlayerCurrency: {},
|
|
137
|
+
|
|
138
|
+
changePlayerStatistics: {},
|
|
139
|
+
getPlayerStatistics: {},
|
|
140
|
+
|
|
141
|
+
getStatisticsLeaderboard: {},
|
|
142
|
+
getStatisticsLeaderboardAroundPlayer: {},
|
|
143
|
+
|
|
144
|
+
getCustomData: {},
|
|
145
|
+
setCustomData: {},
|
|
146
|
+
|
|
147
|
+
setPlayerData: {},
|
|
148
|
+
getPlayerData: {},
|
|
149
|
+
|
|
150
|
+
getPlayerInformation: {},
|
|
151
|
+
|
|
152
|
+
getPlayersWithSegment: {},
|
|
153
|
+
getPlayersWithTag: {},
|
|
154
|
+
|
|
155
|
+
getPlayerCharacter: {},
|
|
156
|
+
getPlayerInventory: {},
|
|
157
|
+
getPlayerGroup: {},
|
|
158
|
+
getPlayerFriend: {},
|
|
159
|
+
|
|
160
|
+
removePlayerItem: {},
|
|
161
|
+
|
|
162
|
+
getOnlineStatus: {},
|
|
163
|
+
createGroup: {},
|
|
164
|
+
createPlayerItem: {},
|
|
165
|
+
createPlayerCharacter: {},
|
|
166
|
+
|
|
167
|
+
addPlayerFriend: {},
|
|
168
|
+
removePlayerFriend: {},
|
|
169
|
+
|
|
170
|
+
removePlayerCharacter: {},
|
|
171
|
+
|
|
172
|
+
joinGroup: {},
|
|
173
|
+
leaveGroup: {},
|
|
174
|
+
|
|
175
|
+
getPlayersWithDisplayName: {},
|
|
176
|
+
|
|
177
|
+
getFriendStatisticsLeaderboardAroundPlayer: {},
|
|
178
|
+
getFriendStatisticsLeaderboard: {},
|
|
179
|
+
},
|
|
180
|
+
characterPlayer: {
|
|
181
|
+
addSegment: {},
|
|
182
|
+
removeSegment: {},
|
|
183
|
+
getSegment: {},
|
|
184
|
+
|
|
185
|
+
setTag: {},
|
|
186
|
+
removeTag: {},
|
|
187
|
+
getTag: {},
|
|
188
|
+
|
|
189
|
+
getDisplayName: {},
|
|
190
|
+
setDisplayName: {},
|
|
191
|
+
|
|
192
|
+
getTsCreate: {},
|
|
193
|
+
getIpAddressCreate: {},
|
|
194
|
+
getTsLastLogin: {},
|
|
195
|
+
|
|
196
|
+
setPlayerBan: {},
|
|
197
|
+
getPlayerBan: {},
|
|
198
|
+
|
|
199
|
+
setCountryCode: {},
|
|
200
|
+
getCountryCode: {},
|
|
201
|
+
|
|
202
|
+
setAvatar: {},
|
|
203
|
+
getAvatar: {},
|
|
204
|
+
|
|
205
|
+
changePlayerCurrency: {},
|
|
206
|
+
getPlayerCurrency: {},
|
|
207
|
+
|
|
208
|
+
changePlayerStatistics: {},
|
|
209
|
+
getPlayerStatistics: {},
|
|
210
|
+
|
|
211
|
+
getStatisticsLeaderboard: {},
|
|
212
|
+
getStatisticsLeaderboardAroundPlayer: {},
|
|
213
|
+
|
|
214
|
+
getCustomData: {},
|
|
215
|
+
setCustomData: {},
|
|
216
|
+
|
|
217
|
+
setPlayerData: {},
|
|
218
|
+
getPlayerData: {},
|
|
219
|
+
|
|
220
|
+
getPlayerInformation: {},
|
|
221
|
+
|
|
222
|
+
getPlayersWithSegment: {},
|
|
223
|
+
getPlayersWithTag: {},
|
|
224
|
+
|
|
225
|
+
getCatalogId: {},
|
|
226
|
+
getOwner: {},
|
|
227
|
+
getRemoveStatus: {},
|
|
228
|
+
|
|
229
|
+
getPlayerFriend: {},
|
|
230
|
+
getPlayerGroup: {},
|
|
231
|
+
getPlayerInventory: {},
|
|
232
|
+
removePlayerItem: {},
|
|
233
|
+
createPlayerItem: {},
|
|
234
|
+
|
|
235
|
+
createGroup: {},
|
|
236
|
+
joinGroup: {},
|
|
237
|
+
leaveGroup: {},
|
|
238
|
+
|
|
239
|
+
setOwner: {},
|
|
240
|
+
|
|
241
|
+
addPlayerFriend: {},
|
|
242
|
+
removePlayerFriend: {},
|
|
243
|
+
|
|
244
|
+
getPlayersWithDisplayName: {},
|
|
245
|
+
|
|
246
|
+
setRemoveStatus: {},
|
|
247
|
+
|
|
248
|
+
getFriendStatisticsLeaderboardAroundPlayer: {},
|
|
249
|
+
getFriendStatisticsLeaderboard: {},
|
|
250
|
+
},
|
|
251
|
+
content: {
|
|
252
|
+
getContentData: {},
|
|
253
|
+
setContentData: {},
|
|
254
|
+
createNewFileUploadInfo: {},
|
|
255
|
+
getFileUploadInfo: {},
|
|
256
|
+
requestDownloadFileUploadInfo: {},
|
|
257
|
+
removeFileUploadInfo: {},
|
|
258
|
+
getFileUploadInfoList: {},
|
|
259
|
+
},
|
|
260
|
+
group: {
|
|
261
|
+
addSegment: {},
|
|
262
|
+
removeSegment: {},
|
|
263
|
+
getSegment: {},
|
|
264
|
+
|
|
265
|
+
setTag: {},
|
|
266
|
+
removeTag: {},
|
|
267
|
+
getTag: {},
|
|
268
|
+
|
|
269
|
+
getDisplayName: {},
|
|
270
|
+
setDisplayName: {},
|
|
271
|
+
|
|
272
|
+
getTsCreate: {},
|
|
273
|
+
|
|
274
|
+
setAvatar: {},
|
|
275
|
+
getAvatar: {},
|
|
276
|
+
|
|
277
|
+
changeGroupCurrency: {},
|
|
278
|
+
getGroupCurrency: {},
|
|
279
|
+
|
|
280
|
+
changeGroupStatistics: {},
|
|
281
|
+
getGroupStatistics: {},
|
|
282
|
+
|
|
283
|
+
getStatisticsLeaderboard: {},
|
|
284
|
+
getStatisticsLeaderboardAroundGroup: {},
|
|
285
|
+
|
|
286
|
+
getCustomData: {},
|
|
287
|
+
setCustomData: {},
|
|
288
|
+
|
|
289
|
+
setGroupData: {},
|
|
290
|
+
getGroupData: {},
|
|
291
|
+
|
|
292
|
+
getGroupInformation: {},
|
|
293
|
+
|
|
294
|
+
getGroupsWithSegment: {},
|
|
295
|
+
getGroupsWithTag: {},
|
|
296
|
+
|
|
297
|
+
getCatalogId: {},
|
|
298
|
+
getRemoveStatus: {},
|
|
299
|
+
|
|
300
|
+
getGroupInventory: {},
|
|
301
|
+
removeGroupItem: {},
|
|
302
|
+
createGroupItem: {},
|
|
303
|
+
|
|
304
|
+
getMembers: {},
|
|
305
|
+
|
|
306
|
+
addMember: {},
|
|
307
|
+
removeMember: {},
|
|
308
|
+
sendGroupMessage: {},
|
|
309
|
+
getGroupMessage: {},
|
|
310
|
+
setRemoveStatus: {},
|
|
311
|
+
|
|
312
|
+
getGroupsWithDisplayName: {},
|
|
313
|
+
},
|
|
314
|
+
inventory: {
|
|
315
|
+
addSegment: {},
|
|
316
|
+
removeSegment: {},
|
|
317
|
+
getSegment: {},
|
|
318
|
+
|
|
319
|
+
setTag: {},
|
|
320
|
+
removeTag: {},
|
|
321
|
+
getTag: {},
|
|
322
|
+
|
|
323
|
+
getDisplayName: {},
|
|
324
|
+
setDisplayName: {},
|
|
325
|
+
|
|
326
|
+
getTsCreate: {},
|
|
327
|
+
|
|
328
|
+
setAvatar: {},
|
|
329
|
+
getAvatar: {},
|
|
330
|
+
|
|
331
|
+
changeItemStatistics: {},
|
|
332
|
+
getItemStatistics: {},
|
|
333
|
+
|
|
334
|
+
getStatisticsLeaderboard: {},
|
|
335
|
+
getStatisticsLeaderboardAroundItem: {},
|
|
336
|
+
|
|
337
|
+
getCustomData: {},
|
|
338
|
+
setCustomData: {},
|
|
339
|
+
|
|
340
|
+
setItemData: {},
|
|
341
|
+
getItemData: {},
|
|
342
|
+
|
|
343
|
+
getItemInformation: {},
|
|
344
|
+
|
|
345
|
+
getItemsWithSegment: {},
|
|
346
|
+
getItemsWithTag: {},
|
|
347
|
+
|
|
348
|
+
getCatalogId: {},
|
|
349
|
+
getClassId: {},
|
|
350
|
+
getItemType: {},
|
|
351
|
+
getAmount: {},
|
|
352
|
+
getOwner: {},
|
|
353
|
+
getRemoveStatus: {},
|
|
354
|
+
|
|
355
|
+
setAmount: {},
|
|
356
|
+
setOwner: {},
|
|
357
|
+
|
|
358
|
+
setRemoveStatus: {},
|
|
359
|
+
|
|
360
|
+
getItemsWithDisplayName: {},
|
|
361
|
+
},
|
|
362
|
+
storeInventory: {
|
|
363
|
+
buyStoreItem: {},
|
|
364
|
+
getStoreItemInformation: {},
|
|
365
|
+
getStoreItemsWithTag: {},
|
|
366
|
+
createStoreItem: {},
|
|
367
|
+
setRemoveStatus: {},
|
|
368
|
+
setStoreItemInformation: {},
|
|
369
|
+
validateAppleAppStoreReceipt: {},
|
|
370
|
+
validateGooglePlayStoreReceipt: {},
|
|
371
|
+
validateFacebookStoreReceipt: {},
|
|
372
|
+
},
|
|
373
|
+
masterAdmin: {
|
|
374
|
+
setMasterGameSettings: {},
|
|
375
|
+
createAdminAccount: {},
|
|
376
|
+
removeAdminAccount: {},
|
|
377
|
+
setPasswordAdminAccount: {},
|
|
378
|
+
setSecretKeyAdminAccount: {},
|
|
379
|
+
setGameInformation: {},
|
|
380
|
+
createGame: {},
|
|
381
|
+
changePasswordAdminAccount: {},
|
|
382
|
+
getAdminAccountList: {},
|
|
383
|
+
getGameInformation: {},
|
|
384
|
+
getGameList: {},
|
|
385
|
+
getMasterGameSettings: {},
|
|
386
|
+
getServerLog: {},
|
|
387
|
+
getSecretInfoInformation: {},
|
|
388
|
+
getSecretInfoList: {},
|
|
389
|
+
createSecretInfo: {},
|
|
390
|
+
setSecretInfoInformation: {},
|
|
391
|
+
},
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
const fs = require("fs");
|
|
395
|
+
|
|
396
|
+
console.log("syncode running..........");
|
|
397
|
+
|
|
398
|
+
//mainCSharp();
|
|
399
|
+
|
|
400
|
+
mainTypescript();
|
|
401
|
+
|
|
402
|
+
// mainGetSecretInformation();
|
|
403
|
+
|
|
404
|
+
function mainGetSecretInformation() {
|
|
405
|
+
let mainKeys = Object.keys(secretPermissionItem);
|
|
406
|
+
|
|
407
|
+
let str = "\t\tlet gnPermission = new GNHashtable();\n\n";
|
|
408
|
+
|
|
409
|
+
mainKeys.forEach((mainKey) => {
|
|
410
|
+
str += "\t\t{\n";
|
|
411
|
+
|
|
412
|
+
let mainKeyName = mainKey[0].toUpperCase() + mainKey.substring(1);
|
|
413
|
+
|
|
414
|
+
str += "\t\t\tlet gn" + mainKeyName + " = new GNHashtable();\n";
|
|
415
|
+
str += "\t\t\tlet " + mainKey + " = permission." + mainKey + ";\n\n";
|
|
416
|
+
|
|
417
|
+
let permissionItem = secretPermissionItem[mainKey];
|
|
418
|
+
|
|
419
|
+
let childKeys = Object.keys(permissionItem);
|
|
420
|
+
|
|
421
|
+
childKeys.forEach((childKey) => {
|
|
422
|
+
str += "\t\t\t{\n";
|
|
423
|
+
str += "\t\t\t\tlet permissionRules = " + mainKey + "." + childKey + ";\n";
|
|
424
|
+
str += "\t\t\t\tlet gnPermissionRules = new GNHashtable();\n\n";
|
|
425
|
+
|
|
426
|
+
str += "\t\t\t\tgnPermissionRules.add(ParameterCode.SelfEnable, permissionRules.selfEnable);\n";
|
|
427
|
+
str += "\t\t\t\tgnPermissionRules.add(ParameterCode.OtherSelfEnable, permissionRules.otherSelfEnable);\n";
|
|
428
|
+
str += "\t\t\t\tgnPermissionRules.add(ParameterCode.ServerSelfEnable, permissionRules.serverSelfEnable);\n";
|
|
429
|
+
str += "\t\t\t\tgnPermissionRules.add(ParameterCode.AdminSelfEnable, permissionRules.adminSelfEnable);\n\n";
|
|
430
|
+
|
|
431
|
+
let childKeyName = childKey[0].toUpperCase() + childKey.substring(1);
|
|
432
|
+
|
|
433
|
+
str += "\t\t\t\tgn" + mainKeyName + ".add(ParameterCode." + childKeyName + ", permissionRules);\n";
|
|
434
|
+
|
|
435
|
+
str += "\t\t\t}\n\n";
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
str += "\t\t}\n\n";
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
fs.writeFileSync("C:/GNServerFile/GetSecretInformation.ts", str);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function mainCSharp() {
|
|
445
|
+
syncCodeCSharp("authenticate", ["LoginBaseRequestHandler.ts"], "Authenticate");
|
|
446
|
+
syncCodeCSharp("characterPlayer", ["CharacterPlayerBaseRequestHandler.ts"], "CharacterPlayer");
|
|
447
|
+
syncCodeCSharp("content", [], "Content");
|
|
448
|
+
syncCodeCSharp("dashboard", [], "MasterAdmin");
|
|
449
|
+
syncCodeCSharp("gamePlayer", ["GamePlayerBaseRequestHandler.ts"], "GamePlayer");
|
|
450
|
+
syncCodeCSharp("group", ["GroupBaseRequestHandler.ts"], "Group");
|
|
451
|
+
syncCodeCSharp("inventory", ["ItemBaseRequestHandler.ts"], "Inventory");
|
|
452
|
+
syncCodeCSharp("masterPlayer", ["MasterPlayerBaseRequestHandler.ts"], "MasterPlayer");
|
|
453
|
+
syncCodeCSharp("storeInventory", ["StoreItemBaseRequestHandler.ts"], "StoreInventory");
|
|
454
|
+
|
|
455
|
+
syncModelCodeCSharp("authenticate", "Authenticate");
|
|
456
|
+
syncModelCodeCSharp("characterPlayer", "CharacterPlayer");
|
|
457
|
+
syncModelCodeCSharp("content", "Content");
|
|
458
|
+
syncModelCodeCSharp("dashboard", "MasterAdmin");
|
|
459
|
+
syncModelCodeCSharp("gamePlayer", "GamePlayer");
|
|
460
|
+
syncModelCodeCSharp("group", "Group");
|
|
461
|
+
syncModelCodeCSharp("inventory", "Inventory");
|
|
462
|
+
syncModelCodeCSharp("masterPlayer", "MasterPlayer");
|
|
463
|
+
syncModelCodeCSharp("storeInventory", "StoreInventory");
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function syncCodeCSharp(dirName, ignoreFileLst, modelName) {
|
|
467
|
+
let fileDir = __dirname + "/./src/GN-app-api/handler/controller/handler/" + dirName;
|
|
468
|
+
let allFilePaths = fs.readdirSync(fileDir);
|
|
469
|
+
|
|
470
|
+
let clientApiStr = "";
|
|
471
|
+
clientApiStr += "public class " + modelName + "Api\n";
|
|
472
|
+
clientApiStr += "{\n";
|
|
473
|
+
clientApiStr += "\tpublic ServerApi server { get; } = new ServerApi();\n\n";
|
|
474
|
+
clientApiStr += "\tpublic AdminApi admin { get; } = new AdminApi();\n\n";
|
|
475
|
+
|
|
476
|
+
let serverApiStr = "";
|
|
477
|
+
serverApiStr += "\tpublic class ServerApi\n";
|
|
478
|
+
serverApiStr += "\t{\n";
|
|
479
|
+
|
|
480
|
+
let adminApiStr = "";
|
|
481
|
+
adminApiStr += "\tpublic class AdminApi\n";
|
|
482
|
+
adminApiStr += "\t{\n";
|
|
483
|
+
|
|
484
|
+
let clientModelFileStr = "";
|
|
485
|
+
clientModelFileStr += "public partial class " + modelName + "Models\n";
|
|
486
|
+
clientModelFileStr += "{\n";
|
|
487
|
+
|
|
488
|
+
let clientRequestModelFileStr = "";
|
|
489
|
+
clientRequestModelFileStr += "public class " + modelName + "RequestModels\n";
|
|
490
|
+
clientRequestModelFileStr += "{\n";
|
|
491
|
+
|
|
492
|
+
let clientResponseModelFileStr = "";
|
|
493
|
+
clientResponseModelFileStr += "public class " + modelName + "ResponseModels\n";
|
|
494
|
+
clientResponseModelFileStr += "{\n";
|
|
495
|
+
|
|
496
|
+
for (let i = 0; i < allFilePaths.length; i++) {
|
|
497
|
+
let filePath = allFilePaths[i];
|
|
498
|
+
|
|
499
|
+
if (!filePath.includes(".ts")) continue;
|
|
500
|
+
|
|
501
|
+
if (ignoreFileLst.indexOf(filePath) != -1) continue;
|
|
502
|
+
|
|
503
|
+
let allLines = fs
|
|
504
|
+
.readFileSync(fileDir + "/" + filePath)
|
|
505
|
+
.toString()
|
|
506
|
+
.split("\n");
|
|
507
|
+
|
|
508
|
+
let name = filePath.replace(".ts", "").replace("RequestHandler", "");
|
|
509
|
+
|
|
510
|
+
clientResponseModelFileStr += "\tpublic class " + name + "OperationResponse : CustomOperationResponse<" + modelName + "Models.ResponseData>\n";
|
|
511
|
+
clientResponseModelFileStr += "\t{\n\n";
|
|
512
|
+
clientResponseModelFileStr += "\t}\n\n";
|
|
513
|
+
|
|
514
|
+
let hasServer = false;
|
|
515
|
+
let hasAdmin = false;
|
|
516
|
+
|
|
517
|
+
for (let j = 0; j < allLines.length; j++) {
|
|
518
|
+
let lineJ = allLines[j].trim();
|
|
519
|
+
|
|
520
|
+
if (lineJ.startsWith("class ")) {
|
|
521
|
+
if (lineJ.includes("RequestHandler")) {
|
|
522
|
+
// requestModelFileStr += "\tpublic class " + name + "OperationRequest : CustomOperationRequest<AuthenticateModels.LoginByAccountRequestData>"
|
|
523
|
+
} else {
|
|
524
|
+
let requestDataName = name + "RequestData";
|
|
525
|
+
let newRequestDataName = requestDataName;
|
|
526
|
+
|
|
527
|
+
let lineSpls = lineJ.split(" ");
|
|
528
|
+
|
|
529
|
+
if (lineSpls[1].startsWith("Admin")) {
|
|
530
|
+
newRequestDataName = "Admin" + requestDataName;
|
|
531
|
+
hasAdmin = true;
|
|
532
|
+
} else if (lineSpls[1].startsWith("Server")) {
|
|
533
|
+
newRequestDataName = "Server" + requestDataName;
|
|
534
|
+
hasServer = true;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
if (lineSpls[3] == "OperationRequest") {
|
|
538
|
+
clientModelFileStr += "\tpublic class " + requestDataName + "\n";
|
|
539
|
+
} else {
|
|
540
|
+
clientModelFileStr += "\tpublic class " + newRequestDataName + " : " + requestDataName + "\n";
|
|
541
|
+
}
|
|
542
|
+
clientModelFileStr += "\t{\n";
|
|
543
|
+
|
|
544
|
+
for (let k = j + 1; k < allLines.length; k++) {
|
|
545
|
+
let lineK = allLines[k];
|
|
546
|
+
|
|
547
|
+
if (lineK.startsWith("class ") || lineK.startsWith("export class ")) {
|
|
548
|
+
clientModelFileStr += "\t}\n\n";
|
|
549
|
+
|
|
550
|
+
break;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
if (lineK.includes("@")) {
|
|
554
|
+
let lineKSpls = lineK.split("@"); // [ StringDataMember({ code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true }) ]
|
|
555
|
+
let lineK2Spls = lineKSpls[1].split("("); // [ StringDataMember, { code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true }) ]
|
|
556
|
+
let dataMemberName = lineK2Spls[0]; // StringDataMember
|
|
557
|
+
let lineK3Spls = lineK2Spls[1].split("{")[1].split("}")[0].split(","); // [ code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true ]
|
|
558
|
+
|
|
559
|
+
let hasMustInt = false;
|
|
560
|
+
let isOptional = false;
|
|
561
|
+
|
|
562
|
+
clientModelFileStr += "\t\t[" + dataMemberName + "(";
|
|
563
|
+
|
|
564
|
+
for (let l = 0; l < lineK3Spls.length; l++) {
|
|
565
|
+
let lineK4Spls = lineK3Spls[l].split(":");
|
|
566
|
+
|
|
567
|
+
if (lineK4Spls.length <= 1) continue;
|
|
568
|
+
|
|
569
|
+
let key = lineK4Spls[0].trim();
|
|
570
|
+
let value = lineK4Spls[1].trim();
|
|
571
|
+
|
|
572
|
+
if (key == "elementCls") {
|
|
573
|
+
if (value == "String") value = "string";
|
|
574
|
+
clientModelFileStr += key + " = typeof(" + value + ")";
|
|
575
|
+
} else clientModelFileStr += key + " = " + value;
|
|
576
|
+
|
|
577
|
+
if (l < lineK3Spls.length - 1) clientModelFileStr += ", ";
|
|
578
|
+
|
|
579
|
+
if (key == "mustInt" && value == "true") hasMustInt = true;
|
|
580
|
+
else if (key == "isOptional" && value == "true") isOptional = true;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
clientModelFileStr += ")]\n";
|
|
584
|
+
|
|
585
|
+
k += 1;
|
|
586
|
+
let lineKNext = allLines[k];
|
|
587
|
+
|
|
588
|
+
let lineKNextUse = lineKNext.trim().split(";")[0];
|
|
589
|
+
let lineKNextUseSpls = lineKNextUse.split(":");
|
|
590
|
+
|
|
591
|
+
let type = lineKNextUseSpls[1].trim();
|
|
592
|
+
|
|
593
|
+
if (type == "boolean") type = "bool";
|
|
594
|
+
else if (type == "number") {
|
|
595
|
+
if (hasMustInt) type = "long";
|
|
596
|
+
else type = "double";
|
|
597
|
+
} else if (type.startsWith("Array")) type = type.replace("Array", "List");
|
|
598
|
+
else if (type == "any") type = "object";
|
|
599
|
+
//createPlayerIfNotExists?
|
|
600
|
+
if (isOptional) {
|
|
601
|
+
if (lineSpls[1].startsWith("Admin") || lineSpls[1].startsWith("Server")) clientModelFileStr += "\t\tpublic new " + type + "? " + lineKNextUseSpls[0].trim().split("?")[0] + ";\n\n";
|
|
602
|
+
else clientModelFileStr += "\t\tpublic " + type + "? " + lineKNextUseSpls[0].trim().split("?")[0] + ";\n\n";
|
|
603
|
+
} else {
|
|
604
|
+
if (lineSpls[1].startsWith("Admin") || lineSpls[1].startsWith("Server")) clientModelFileStr += "\t\tpublic new " + type + " " + lineKNextUseSpls[0].trim().split("?")[0] + ";\n\n";
|
|
605
|
+
else clientModelFileStr += "\t\tpublic " + type + " " + lineKNextUseSpls[0].trim().split("?")[0] + ";\n\n";
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
j = k;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
let name2 = name[0].toLowerCase() + name.substring(1);
|
|
616
|
+
|
|
617
|
+
clientApiStr +=
|
|
618
|
+
"\tpublic void " +
|
|
619
|
+
name2 +
|
|
620
|
+
"(" +
|
|
621
|
+
modelName +
|
|
622
|
+
"Models." +
|
|
623
|
+
name +
|
|
624
|
+
"RequestData requestData, Action<" +
|
|
625
|
+
modelName +
|
|
626
|
+
"ResponseModels." +
|
|
627
|
+
name +
|
|
628
|
+
"OperationResponse> response = null, string overrideAuthToken = null, string overrideSecretKey = null, GNHashtable customTags = null, int timeout = OperationRequest.defaultTimeOut)\n";
|
|
629
|
+
clientApiStr += "\t{\n";
|
|
630
|
+
clientApiStr += "\t\tGNNetwork.sendViaHttp(new " + modelName + "RequestModels." + name + "OperationRequest(requestData, timeout), response, overrideAuthToken, overrideSecretKey, customTags);\n";
|
|
631
|
+
clientApiStr += "\t}\n\n";
|
|
632
|
+
|
|
633
|
+
clientRequestModelFileStr += "\tpublic class " + name + "OperationRequest : CustomOperationRequest<" + modelName + "Models." + name + "RequestData>\n";
|
|
634
|
+
clientRequestModelFileStr += "\t{\n";
|
|
635
|
+
clientRequestModelFileStr += "\t\tprotected override int operationCode => OperationCode." + name + ";\n";
|
|
636
|
+
clientRequestModelFileStr += "\t\tprotected override RequestType requestType => RequestType." + modelName + ";\n";
|
|
637
|
+
clientRequestModelFileStr += "\t\tprotected override RequestRole requestRole => RequestRole.Client;\n\n";
|
|
638
|
+
|
|
639
|
+
clientRequestModelFileStr += "\t\tpublic " + name + "OperationRequest(" + modelName + "Models." + name + "RequestData requestData, int timeout = OperationRequest.defaultTimeOut) : base(requestData, timeout) { }\n";
|
|
640
|
+
clientRequestModelFileStr += "\t}\n\n";
|
|
641
|
+
|
|
642
|
+
if (hasServer) {
|
|
643
|
+
serverApiStr +=
|
|
644
|
+
"\t\tpublic void " +
|
|
645
|
+
name2 +
|
|
646
|
+
"(" +
|
|
647
|
+
modelName +
|
|
648
|
+
"Models.Server" +
|
|
649
|
+
name +
|
|
650
|
+
"RequestData requestData, Action<" +
|
|
651
|
+
modelName +
|
|
652
|
+
"ResponseModels." +
|
|
653
|
+
name +
|
|
654
|
+
"OperationResponse> response = null, string overrideAuthToken = null, string overrideSecretKey = null, GNHashtable customTags = null, int timeout = OperationRequest.defaultTimeOut)\n";
|
|
655
|
+
serverApiStr += "\t\t{\n";
|
|
656
|
+
serverApiStr += "\t\t\tGNNetwork.sendViaHttp(new " + modelName + "RequestModels.Server" + name + "OperationRequest(requestData, timeout), response, overrideAuthToken, overrideSecretKey, customTags);\n";
|
|
657
|
+
serverApiStr += "\t\t}\n\n";
|
|
658
|
+
|
|
659
|
+
clientRequestModelFileStr += "\tpublic class Server" + name + "OperationRequest : " + name + "OperationRequest\n";
|
|
660
|
+
clientRequestModelFileStr += "\t{\n";
|
|
661
|
+
clientRequestModelFileStr += "\t\tprotected override RequestRole requestRole => RequestRole.Server;\n\n";
|
|
662
|
+
|
|
663
|
+
clientRequestModelFileStr += "\t\tpublic Server" + name + "OperationRequest(" + modelName + "Models.Server" + name + "RequestData requestData, int timeout = OperationRequest.defaultTimeOut) : base(requestData, timeout) { }\n";
|
|
664
|
+
clientRequestModelFileStr += "\t}\n\n";
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
if (hasAdmin) {
|
|
668
|
+
adminApiStr +=
|
|
669
|
+
"\t\tpublic void " +
|
|
670
|
+
name2 +
|
|
671
|
+
"(" +
|
|
672
|
+
modelName +
|
|
673
|
+
"Models.Admin" +
|
|
674
|
+
name +
|
|
675
|
+
"RequestData requestData, Action<" +
|
|
676
|
+
modelName +
|
|
677
|
+
"ResponseModels." +
|
|
678
|
+
name +
|
|
679
|
+
"OperationResponse> response = null, string overrideAuthToken = null, string overrideSecretKey = null, GNHashtable customTags = null, int timeout = OperationRequest.defaultTimeOut)\n";
|
|
680
|
+
adminApiStr += "\t\t{\n";
|
|
681
|
+
adminApiStr += "\t\t\tGNNetwork.sendViaHttp(new " + modelName + "RequestModels.Admin" + name + "OperationRequest(requestData, timeout), response, overrideAuthToken, overrideSecretKey, customTags);\n";
|
|
682
|
+
adminApiStr += "\t\t}\n\n";
|
|
683
|
+
|
|
684
|
+
clientRequestModelFileStr += "\tpublic class Admin" + name + "OperationRequest : " + name + "OperationRequest\n";
|
|
685
|
+
clientRequestModelFileStr += "\t{\n";
|
|
686
|
+
clientRequestModelFileStr += "\t\tprotected override RequestRole requestRole => RequestRole.Admin;\n\n";
|
|
687
|
+
|
|
688
|
+
clientRequestModelFileStr += "\t\tpublic Admin" + name + "OperationRequest(" + modelName + "Models.Admin" + name + "RequestData requestData, int timeout = OperationRequest.defaultTimeOut) : base(requestData, timeout) { }\n";
|
|
689
|
+
clientRequestModelFileStr += "\t}\n\n";
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
clientRequestModelFileStr += "\n";
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
serverApiStr += "\t}\n";
|
|
696
|
+
adminApiStr += "\t}\n";
|
|
697
|
+
|
|
698
|
+
clientApiStr += "\n";
|
|
699
|
+
clientApiStr += serverApiStr;
|
|
700
|
+
clientApiStr += "\n";
|
|
701
|
+
clientApiStr += adminApiStr;
|
|
702
|
+
clientApiStr += "\n";
|
|
703
|
+
|
|
704
|
+
clientApiStr += "}\n";
|
|
705
|
+
clientModelFileStr += "}\n";
|
|
706
|
+
clientRequestModelFileStr += "}\n";
|
|
707
|
+
clientResponseModelFileStr += "}\n";
|
|
708
|
+
|
|
709
|
+
fs.writeFileSync("C:/GNServerFile/" + modelName + "Api.cs", clientApiStr);
|
|
710
|
+
fs.writeFileSync("C:/GNServerFile/" + modelName + "Models.cs", clientModelFileStr);
|
|
711
|
+
fs.writeFileSync("C:/GNServerFile/" + modelName + "RequestModels.cs", clientRequestModelFileStr);
|
|
712
|
+
fs.writeFileSync("C:/GNServerFile/" + modelName + "ResponseModels.cs", clientResponseModelFileStr);
|
|
713
|
+
|
|
714
|
+
// console.log(clientApiStr);
|
|
715
|
+
// console.log(clientModelFileStr);
|
|
716
|
+
// console.log(clientRequestModelFileStr);
|
|
717
|
+
// console.log(clientResponseModelFileStr);
|
|
718
|
+
|
|
719
|
+
// fs.readFileSync();
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
function syncModelCodeCSharp(dirName, modelName) {
|
|
723
|
+
let fileDir = __dirname + "/./src/GN-app-api/handler/controller/handler/" + dirName;
|
|
724
|
+
let allFilePaths = fs.readdirSync(fileDir);
|
|
725
|
+
|
|
726
|
+
let clientModelFileStr = "";
|
|
727
|
+
clientModelFileStr += "public partial class " + modelName + "Models\n";
|
|
728
|
+
clientModelFileStr += "{\n";
|
|
729
|
+
|
|
730
|
+
for (let i = 0; i < allFilePaths.length; i++) {
|
|
731
|
+
let filePath0 = allFilePaths[i];
|
|
732
|
+
|
|
733
|
+
if (filePath0.includes(".ts")) continue;
|
|
734
|
+
|
|
735
|
+
let allFilePaths2 = fs.readdirSync(fileDir + "/" + filePath0);
|
|
736
|
+
|
|
737
|
+
for (let m = 0; m < allFilePaths2.length; m++) {
|
|
738
|
+
let filePath = allFilePaths2[m];
|
|
739
|
+
|
|
740
|
+
let allLines = fs
|
|
741
|
+
.readFileSync(fileDir + "/" + filePath0 + "/" + filePath)
|
|
742
|
+
.toString()
|
|
743
|
+
.split("\n");
|
|
744
|
+
|
|
745
|
+
let name = filePath.replace(".ts", "").replace("RequestHandler", "");
|
|
746
|
+
|
|
747
|
+
for (let j = 0; j < allLines.length; j++) {
|
|
748
|
+
let lineJ = allLines[j].trim();
|
|
749
|
+
|
|
750
|
+
if (lineJ.startsWith("export class ")) {
|
|
751
|
+
let requestDataName = name;
|
|
752
|
+
|
|
753
|
+
clientModelFileStr += "\tpublic class " + requestDataName + "\n";
|
|
754
|
+
|
|
755
|
+
clientModelFileStr += "\t{\n";
|
|
756
|
+
|
|
757
|
+
for (let k = j + 1; k < allLines.length; k++) {
|
|
758
|
+
let lineK = allLines[k];
|
|
759
|
+
|
|
760
|
+
if (lineK.startsWith("class ") || lineK.startsWith("export class ")) {
|
|
761
|
+
clientModelFileStr += "\t}\n\n";
|
|
762
|
+
|
|
763
|
+
break;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
if (lineK.includes("@")) {
|
|
767
|
+
let lineKSpls = lineK.split("@"); // [ StringDataMember({ code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true }) ]
|
|
768
|
+
let lineK2Spls = lineKSpls[1].split("("); // [ StringDataMember, { code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true }) ]
|
|
769
|
+
let dataMemberName = lineK2Spls[0]; // StringDataMember
|
|
770
|
+
let lineK3Spls = lineK2Spls[1].split("{")[1].split("}")[0].split(","); // [ code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true ]
|
|
771
|
+
|
|
772
|
+
let hasMustInt = false;
|
|
773
|
+
let isOptional = false;
|
|
774
|
+
|
|
775
|
+
clientModelFileStr += "\t\t[" + dataMemberName + "(";
|
|
776
|
+
|
|
777
|
+
for (let l = 0; l < lineK3Spls.length; l++) {
|
|
778
|
+
let lineK4Spls = lineK3Spls[l].split(":");
|
|
779
|
+
|
|
780
|
+
if (lineK4Spls.length <= 1) continue;
|
|
781
|
+
|
|
782
|
+
let key = lineK4Spls[0].trim();
|
|
783
|
+
let value = lineK4Spls[1].trim();
|
|
784
|
+
|
|
785
|
+
if (key == "elementCls") {
|
|
786
|
+
if (value == "String") value = "string";
|
|
787
|
+
clientModelFileStr += key + " = typeof(" + value + ")";
|
|
788
|
+
} else clientModelFileStr += key + " = " + value;
|
|
789
|
+
|
|
790
|
+
if (l < lineK3Spls.length - 1) clientModelFileStr += ", ";
|
|
791
|
+
|
|
792
|
+
if (key == "mustInt" && value == "true") hasMustInt = true;
|
|
793
|
+
else if (key == "isOptional" && value == "true") isOptional = true;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
clientModelFileStr += ")]\n";
|
|
797
|
+
|
|
798
|
+
k += 1;
|
|
799
|
+
let lineKNext = allLines[k];
|
|
800
|
+
|
|
801
|
+
let lineKNextUse = lineKNext.trim().split(";")[0];
|
|
802
|
+
let lineKNextUseSpls = lineKNextUse.split(":");
|
|
803
|
+
|
|
804
|
+
let type = lineKNextUseSpls[1].trim();
|
|
805
|
+
|
|
806
|
+
if (type == "boolean") type = "bool";
|
|
807
|
+
else if (type == "number") {
|
|
808
|
+
if (hasMustInt) type = "long";
|
|
809
|
+
else type = "double";
|
|
810
|
+
} else if (type.startsWith("Array")) type = type.replace("Array", "List");
|
|
811
|
+
else if (type == "any") type = "object";
|
|
812
|
+
|
|
813
|
+
if (isOptional) {
|
|
814
|
+
clientModelFileStr += "\t\tpublic " + type + "? " + lineKNextUseSpls[0].trim().split("?")[0] + ";\n\n";
|
|
815
|
+
} else {
|
|
816
|
+
clientModelFileStr += "\t\tpublic " + type + " " + lineKNextUseSpls[0].trim().split("?")[0] + ";\n\n";
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
j = k;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
clientModelFileStr += "\t}\n\n";
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
clientModelFileStr += "}\n";
|
|
830
|
+
|
|
831
|
+
fs.writeFileSync("C:/GNServerFile/" + modelName + "Models.Partial.cs", clientModelFileStr);
|
|
832
|
+
|
|
833
|
+
// console.log(clientApiStr);
|
|
834
|
+
// console.log(clientModelFileStr);
|
|
835
|
+
// console.log(clientRequestModelFileStr);
|
|
836
|
+
// console.log(clientResponseModelFileStr);
|
|
837
|
+
|
|
838
|
+
// fs.readFileSync();
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
function mainTypescript() {
|
|
842
|
+
// syncApiCodeTypescript("authenticate", ["LoginBaseRequestHandler.ts"], "Authenticate");
|
|
843
|
+
// syncApiCodeTypescript("characterPlayer", ["CharacterPlayerBaseRequestHandler.ts"], "CharacterPlayer");
|
|
844
|
+
// syncApiCodeTypescript("cloudScript", [], "CloudScript");
|
|
845
|
+
// syncApiCodeTypescript("content", [], "Content");
|
|
846
|
+
|
|
847
|
+
syncApiCodeTypescript("dashboard", [], "MasterAdmin");
|
|
848
|
+
// syncApiCodeTypescript("gamePlayer", ["GamePlayerBaseRequestHandler.ts"], "GamePlayer");
|
|
849
|
+
// syncApiCodeTypescript("group", ["GroupBaseRequestHandler.ts", "GroupMessageItem.ts"], "Group");
|
|
850
|
+
// syncApiCodeTypescript("inventory", ["ItemBaseRequestHandler.ts"], "Inventory");
|
|
851
|
+
// syncApiCodeTypescript("masterPlayer", ["MasterPlayerBaseRequestHandler.ts"], "MasterPlayer");
|
|
852
|
+
// syncApiCodeTypescript("multiplayer", ["MultiplayerBaseRequestHandler.ts"], "Multiplayer");
|
|
853
|
+
// syncApiCodeTypescript("storeInventory", ["StoreItemBaseRequestHandler.ts"], "StoreInventory");
|
|
854
|
+
|
|
855
|
+
// syncModelCodeTypescript("authenticate", "Authenticate");
|
|
856
|
+
// syncModelCodeTypescript("characterPlayer", "CharacterPlayer");
|
|
857
|
+
// syncModelCodeTypescript("content", "Content");
|
|
858
|
+
// syncModelCodeTypescript("dashboard", "MasterAdmin");
|
|
859
|
+
// syncModelCodeTypescript("gamePlayer", "GamePlayer");
|
|
860
|
+
// syncModelCodeTypescript("group", "Group");
|
|
861
|
+
// syncModelCodeTypescript("inventory", "Inventory");
|
|
862
|
+
// syncModelCodeTypescript("masterPlayer", "MasterPlayer");
|
|
863
|
+
// syncModelCodeTypescript("storeInventory", "StoreInventory");
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
function fixCodeTypescript(dirName, ignoreFileLst, modelName) {
|
|
867
|
+
let fileDir = __dirname + "/./src/GN-app-api/handler/controller/handler/" + dirName;
|
|
868
|
+
if (!fs.existsSync(fileDir)) return;
|
|
869
|
+
|
|
870
|
+
let allFilePaths = fs.readdirSync(fileDir);
|
|
871
|
+
|
|
872
|
+
for (let i = 0; i < allFilePaths.length; i++) {
|
|
873
|
+
let filePath = allFilePaths[i];
|
|
874
|
+
|
|
875
|
+
if (!filePath.includes(".ts")) continue;
|
|
876
|
+
|
|
877
|
+
if (ignoreFileLst.indexOf(filePath) != -1) continue;
|
|
878
|
+
|
|
879
|
+
let allLines = fs
|
|
880
|
+
.readFileSync(fileDir + "/" + filePath)
|
|
881
|
+
.toString()
|
|
882
|
+
.split("\n");
|
|
883
|
+
|
|
884
|
+
for (let j = 0; j < allLines.length - 1; j++) {
|
|
885
|
+
let lineJ = allLines[j];
|
|
886
|
+
|
|
887
|
+
if (lineJ.includes("@GNHashtable") || lineJ.includes("@String") || lineJ.includes("@Number") || lineJ.includes("@GNArray") || lineJ.includes("@Boolean") || lineJ.includes("@DataMember")) {
|
|
888
|
+
let isOptional = false;
|
|
889
|
+
let hasMustInt = false;
|
|
890
|
+
let parameterCode = "";
|
|
891
|
+
|
|
892
|
+
let lineK = lineJ;
|
|
893
|
+
|
|
894
|
+
let lineKSpls = lineK.split("@"); // [ StringDataMember({ code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true }) ]
|
|
895
|
+
let lineK2Spls = lineKSpls[1].split("("); // [ StringDataMember, { code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true }) ]
|
|
896
|
+
let lineK3Spls = lineK2Spls[1].split("{")[1].split("}")[0].split(","); // [ code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true ]
|
|
897
|
+
|
|
898
|
+
for (let l = 0; l < lineK3Spls.length; l++) {
|
|
899
|
+
let lineK4Spls = lineK3Spls[l].split(":");
|
|
900
|
+
|
|
901
|
+
if (lineK4Spls.length <= 1) continue;
|
|
902
|
+
|
|
903
|
+
let key = lineK4Spls[0].trim();
|
|
904
|
+
let value = lineK4Spls[1].trim();
|
|
905
|
+
|
|
906
|
+
if (key == "mustInt" && value == "true") hasMustInt = true;
|
|
907
|
+
else if (key == "isOptional" && value == "true") isOptional = true;
|
|
908
|
+
else if (key == "code") {
|
|
909
|
+
parameterCode = value.split(".")[1];
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
j += 1;
|
|
914
|
+
|
|
915
|
+
if (isOptional) {
|
|
916
|
+
let lineKNext = allLines[j];
|
|
917
|
+
|
|
918
|
+
let lineKNextUse = lineKNext.split(";")[0];
|
|
919
|
+
let lineKNextUseSpls = lineKNextUse.split(":");
|
|
920
|
+
|
|
921
|
+
let type = lineKNextUseSpls[1];
|
|
922
|
+
let fieldName = lineKNextUseSpls[0].split("?")[0];
|
|
923
|
+
|
|
924
|
+
if (fieldName.split(" ")[fieldName.split(" ").length - 1].toLowerCase() != parameterCode.toLowerCase()) {
|
|
925
|
+
console.log(parameterCode + " " + filePath + " " + dirName);
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
allLines[j] = fieldName + "?:" + type + ";";
|
|
929
|
+
} else {
|
|
930
|
+
let lineKNext = allLines[j];
|
|
931
|
+
|
|
932
|
+
let lineKNextUse = lineKNext.split(";")[0];
|
|
933
|
+
let lineKNextUseSpls = lineKNextUse.split(":");
|
|
934
|
+
|
|
935
|
+
let fieldName = lineKNextUseSpls[0].split("?")[0];
|
|
936
|
+
|
|
937
|
+
if (fieldName.split(" ")[fieldName.split(" ").length - 1].toLowerCase() != parameterCode.toLowerCase()) {
|
|
938
|
+
console.log(parameterCode + " " + filePath + " " + dirName);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
let str = "";
|
|
945
|
+
for (let j = 0; j < allLines.length; j++) {
|
|
946
|
+
str += allLines[j];
|
|
947
|
+
|
|
948
|
+
if (j < allLines.length - 1) str += "\n";
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
// console.log(str);
|
|
952
|
+
|
|
953
|
+
// fs.writeFileSync(fileDir + "/" + filePath, str);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
function syncModelCodeTypescript(dirName, modelName) {
|
|
958
|
+
let fileDir = __dirname + "/./src/GN-app-api/handler/controller/handler/" + dirName;
|
|
959
|
+
let allFilePaths = fs.readdirSync(fileDir);
|
|
960
|
+
|
|
961
|
+
for (let i = 0; i < allFilePaths.length; i++) {
|
|
962
|
+
let filePath0 = allFilePaths[i];
|
|
963
|
+
|
|
964
|
+
if (filePath0.includes(".ts")) continue;
|
|
965
|
+
|
|
966
|
+
let allFilePaths2 = fs.readdirSync(fileDir + "/" + filePath0);
|
|
967
|
+
|
|
968
|
+
for (let m = 0; m < allFilePaths2.length; m++) {
|
|
969
|
+
let filePath = allFilePaths2[m];
|
|
970
|
+
|
|
971
|
+
let allLines = fs
|
|
972
|
+
.readFileSync(fileDir + "/" + filePath0 + "/" + filePath)
|
|
973
|
+
.toString()
|
|
974
|
+
.split("\n");
|
|
975
|
+
|
|
976
|
+
for (let j = 0; j < allLines.length - 1; j++) {
|
|
977
|
+
let lineJ = allLines[j];
|
|
978
|
+
|
|
979
|
+
if (lineJ.includes("@GNHashtable") || lineJ.includes("@String") || lineJ.includes("@Number") || lineJ.includes("@GNArray") || lineJ.includes("@Boolean") || lineJ.includes("@DataMember")) {
|
|
980
|
+
let isOptional = false;
|
|
981
|
+
let hasMustInt = false;
|
|
982
|
+
let lineK = lineJ;
|
|
983
|
+
|
|
984
|
+
let lineKSpls = lineK.split("@"); // [ StringDataMember({ code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true }) ]
|
|
985
|
+
let lineK2Spls = lineKSpls[1].split("("); // [ StringDataMember, { code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true }) ]
|
|
986
|
+
let lineK3Spls = lineK2Spls[1].split("{")[1].split("}")[0].split(","); // [ code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true ]
|
|
987
|
+
|
|
988
|
+
for (let l = 0; l < lineK3Spls.length; l++) {
|
|
989
|
+
let lineK4Spls = lineK3Spls[l].split(":");
|
|
990
|
+
|
|
991
|
+
if (lineK4Spls.length <= 1) continue;
|
|
992
|
+
|
|
993
|
+
let key = lineK4Spls[0].trim();
|
|
994
|
+
let value = lineK4Spls[1].trim();
|
|
995
|
+
|
|
996
|
+
if (key == "mustInt" && value == "true") hasMustInt = true;
|
|
997
|
+
else if (key == "isOptional" && value == "true") isOptional = true;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
j += 1;
|
|
1001
|
+
|
|
1002
|
+
if (isOptional) {
|
|
1003
|
+
let lineKNext = allLines[j];
|
|
1004
|
+
|
|
1005
|
+
let lineKNextUse = lineKNext.split(";")[0];
|
|
1006
|
+
let lineKNextUseSpls = lineKNextUse.split(":");
|
|
1007
|
+
|
|
1008
|
+
let type = lineKNextUseSpls[1];
|
|
1009
|
+
let fieldName = lineKNextUseSpls[0].split("?")[0];
|
|
1010
|
+
|
|
1011
|
+
allLines[j] = fieldName + "?:" + type + ";";
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
let str = "";
|
|
1017
|
+
for (let j = 0; j < allLines.length; j++) {
|
|
1018
|
+
str += allLines[j];
|
|
1019
|
+
|
|
1020
|
+
if (j < allLines.length - 1) str += "\n";
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
console.log(str);
|
|
1024
|
+
fs.writeFileSync(fileDir + "/" + filePath0 + "/" + filePath, str);
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// console.log(clientApiStr);
|
|
1029
|
+
// console.log(clientModelFileStr);
|
|
1030
|
+
// console.log(clientRequestModelFileStr);
|
|
1031
|
+
// console.log(clientResponseModelFileStr);
|
|
1032
|
+
|
|
1033
|
+
// fs.readFileSync();
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
function syncApiCodeTypescript(dirName, ignoreFileLst, requestType) {
|
|
1037
|
+
let finalModels = {
|
|
1038
|
+
requestType: requestType,
|
|
1039
|
+
operations: [],
|
|
1040
|
+
models: [],
|
|
1041
|
+
};
|
|
1042
|
+
|
|
1043
|
+
{
|
|
1044
|
+
let fileDir = __dirname + "/./src/GN-app-api/handler/controller/handler/" + dirName;
|
|
1045
|
+
let allFilePaths = fs.readdirSync(fileDir);
|
|
1046
|
+
|
|
1047
|
+
for (let i = 0; i < allFilePaths.length; i++) {
|
|
1048
|
+
let filePath = allFilePaths[i];
|
|
1049
|
+
|
|
1050
|
+
if (!filePath.includes(".ts")) continue;
|
|
1051
|
+
|
|
1052
|
+
if (ignoreFileLst.indexOf(filePath) != -1) continue;
|
|
1053
|
+
|
|
1054
|
+
let allLines = fs
|
|
1055
|
+
.readFileSync(fileDir + "/" + filePath)
|
|
1056
|
+
.toString()
|
|
1057
|
+
.split("\n");
|
|
1058
|
+
|
|
1059
|
+
let lineOperationCodeIndex = allLines.findIndex((x) => x.includes("public override getCode()")) + 1;
|
|
1060
|
+
let operationCode = allLines[lineOperationCodeIndex].replace("\r", "").replace("\n", "").replace("\t", "").split(" ")[1].replace(";", "").split(".")[1].trim();
|
|
1061
|
+
let thisOperation = finalModels.operations.find((x) => x.operationCode == operationCode);
|
|
1062
|
+
if (thisOperation == null) {
|
|
1063
|
+
thisOperation = {
|
|
1064
|
+
operationCode: operationCode,
|
|
1065
|
+
details: [],
|
|
1066
|
+
responseData: [],
|
|
1067
|
+
description: "",
|
|
1068
|
+
};
|
|
1069
|
+
|
|
1070
|
+
finalModels.operations.push(thisOperation);
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
let isClient = true;
|
|
1074
|
+
let isServer = false;
|
|
1075
|
+
let isAdmin = false;
|
|
1076
|
+
|
|
1077
|
+
for (let j = 0; j < allLines.length - 1; j++) {
|
|
1078
|
+
let lineJ = allLines[j];
|
|
1079
|
+
|
|
1080
|
+
if (lineJ.startsWith("class Server")) {
|
|
1081
|
+
isClient = false;
|
|
1082
|
+
isServer = true;
|
|
1083
|
+
isAdmin = false;
|
|
1084
|
+
} else if (lineJ.startsWith("class Admin")) {
|
|
1085
|
+
isClient = false;
|
|
1086
|
+
isServer = false;
|
|
1087
|
+
isAdmin = true;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
if (lineJ.includes("@GNHashtable") || lineJ.includes("@String") || lineJ.includes("@Number") || lineJ.includes("@GNArray") || lineJ.includes("@Boolean") || lineJ.includes("@DataMember")) {
|
|
1091
|
+
let gnType = lineJ.includes("@GNHashtable")
|
|
1092
|
+
? "GNHashtable"
|
|
1093
|
+
: lineJ.includes("@String")
|
|
1094
|
+
? "String"
|
|
1095
|
+
: lineJ.includes("@Number")
|
|
1096
|
+
? "Number"
|
|
1097
|
+
: lineJ.includes("@GNArray")
|
|
1098
|
+
? "GNArray"
|
|
1099
|
+
: lineJ.includes("@Boolean")
|
|
1100
|
+
? "Boolean"
|
|
1101
|
+
: lineJ.includes("@DataMember")
|
|
1102
|
+
? "DataMember"
|
|
1103
|
+
: "Other";
|
|
1104
|
+
|
|
1105
|
+
let isOptional = false;
|
|
1106
|
+
let hasMustInt = null;
|
|
1107
|
+
let mustNonNull = null;
|
|
1108
|
+
let minLength = null;
|
|
1109
|
+
let maxLength = null;
|
|
1110
|
+
let minValue = null;
|
|
1111
|
+
let maxValue = null;
|
|
1112
|
+
let elementCls = null;
|
|
1113
|
+
let defaultValue = null;
|
|
1114
|
+
|
|
1115
|
+
let parameterCode = "";
|
|
1116
|
+
|
|
1117
|
+
let lineK = lineJ;
|
|
1118
|
+
|
|
1119
|
+
let lineKSpls = lineK.split("@"); // [ StringDataMember({ code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true }) ]
|
|
1120
|
+
let lineK2Spls = lineKSpls[1].split("("); // [ StringDataMember, { code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true }) ]
|
|
1121
|
+
let lineK3Spls = lineK2Spls[1].split("{")[1].split("}")[0].split(","); // [ code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true ]
|
|
1122
|
+
|
|
1123
|
+
for (let l = 0; l < lineK3Spls.length; l++) {
|
|
1124
|
+
let lineK4Spls = lineK3Spls[l].split(":");
|
|
1125
|
+
|
|
1126
|
+
if (lineK4Spls.length <= 1) continue;
|
|
1127
|
+
|
|
1128
|
+
let key = lineK4Spls[0].trim();
|
|
1129
|
+
let value = lineK4Spls[1].trim();
|
|
1130
|
+
|
|
1131
|
+
if (key == "mustInt" && value == "true") hasMustInt = true;
|
|
1132
|
+
else if (key == "isOptional" && value == "true") isOptional = true;
|
|
1133
|
+
else if (key == "code") {
|
|
1134
|
+
parameterCode = value.split(".")[1];
|
|
1135
|
+
} else if (key == "mustNonNull" && value == "true") mustNonNull = true;
|
|
1136
|
+
else if (key == "minValue") minValue = parseInt(value);
|
|
1137
|
+
else if (key == "maxValue") maxValue = parseInt(value);
|
|
1138
|
+
else if (key == "minLength") minLength = parseInt(value);
|
|
1139
|
+
else if (key == "maxLength") maxLength = parseInt(value);
|
|
1140
|
+
else if (key == "elementCls") elementCls = value;
|
|
1141
|
+
else if (key == "defaultValue") defaultValue = value;
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
j += 1;
|
|
1145
|
+
|
|
1146
|
+
let lineKNext = allLines[j];
|
|
1147
|
+
|
|
1148
|
+
let type = lineKNext.replace("declare ", "").replace("\r", "").replace("\t", "").replace("\n", "").replace(";", "").replace("declare", "").replace(":", "").split(" ")[2];
|
|
1149
|
+
|
|
1150
|
+
//Array<string>
|
|
1151
|
+
if (lineJ.includes("@GNArray")) {
|
|
1152
|
+
type = type.split("<")[1].replace(">", "");
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
let role = isClient ? "Client" : isServer ? "Server" : isAdmin ? "Admin" : "";
|
|
1156
|
+
let thisDetail = thisOperation.details.find((x) => x.role == role);
|
|
1157
|
+
if (thisDetail == null) {
|
|
1158
|
+
thisDetail = {
|
|
1159
|
+
role: role,
|
|
1160
|
+
requestData: [],
|
|
1161
|
+
};
|
|
1162
|
+
|
|
1163
|
+
thisOperation.details.push(thisDetail);
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
let thisRequestData = thisDetail.requestData.find((x) => x.code == parameterCode);
|
|
1167
|
+
|
|
1168
|
+
if (thisRequestData == null) {
|
|
1169
|
+
thisRequestData = {
|
|
1170
|
+
code: parameterCode,
|
|
1171
|
+
description: "",
|
|
1172
|
+
};
|
|
1173
|
+
|
|
1174
|
+
thisDetail.requestData.push(thisRequestData);
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
thisRequestData.optional = isOptional;
|
|
1178
|
+
thisRequestData.type = type;
|
|
1179
|
+
thisRequestData.gnType = gnType;
|
|
1180
|
+
thisRequestData.defaultValue = defaultValue;
|
|
1181
|
+
thisRequestData.conditions = {
|
|
1182
|
+
mustNonNull: mustNonNull,
|
|
1183
|
+
mustInt: hasMustInt,
|
|
1184
|
+
minLength: minLength,
|
|
1185
|
+
maxLength: maxLength,
|
|
1186
|
+
minValue: minValue,
|
|
1187
|
+
maxValue: maxValue,
|
|
1188
|
+
};
|
|
1189
|
+
|
|
1190
|
+
if (thisRequestData.defaultValue == null) delete thisRequestData.defaultValue;
|
|
1191
|
+
if (thisRequestData.conditions.mustNonNull == null) delete thisRequestData.conditions.mustNonNull;
|
|
1192
|
+
if (thisRequestData.conditions.mustInt == null) delete thisRequestData.conditions.mustInt;
|
|
1193
|
+
if (thisRequestData.conditions.minLength == null) delete thisRequestData.conditions.minLength;
|
|
1194
|
+
if (thisRequestData.conditions.maxLength == null) delete thisRequestData.conditions.maxLength;
|
|
1195
|
+
if (thisRequestData.conditions.minValue == null) delete thisRequestData.conditions.minValue;
|
|
1196
|
+
if (thisRequestData.conditions.maxValue == null) delete thisRequestData.conditions.maxValue;
|
|
1197
|
+
} else if (lineJ.includes("operationResponse.setParameter(")) {
|
|
1198
|
+
let lineK = lineJ;
|
|
1199
|
+
|
|
1200
|
+
let parameterCode = lineK.replace("operationResponse.setParameter(", "").split(",")[0].split(".")[1].trim();
|
|
1201
|
+
|
|
1202
|
+
let thisResponseData = thisOperation.responseData.find((x) => x.code == parameterCode);
|
|
1203
|
+
if (!thisResponseData) {
|
|
1204
|
+
thisResponseData = {
|
|
1205
|
+
code: parameterCode,
|
|
1206
|
+
};
|
|
1207
|
+
|
|
1208
|
+
thisOperation.responseData.push(thisResponseData);
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
if (parameterCode == "ErrorCode") {
|
|
1212
|
+
if (thisResponseData.value == null) thisResponseData.value = [];
|
|
1213
|
+
|
|
1214
|
+
//(ParameterCode.ErrorCode, ErrorCode.Ok);//
|
|
1215
|
+
let errorCode = lineK.replace("operationResponse.setParameter", "").split(",")[1].split(")")[0].trim().split(".")[1];
|
|
1216
|
+
if (!thisResponseData.value.includes(errorCode)) thisResponseData.value.push(errorCode);
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
thisOperation.responseData.sort((a, b) => (a.code == "ErrorCode" ? -1 : 1));
|
|
1222
|
+
|
|
1223
|
+
// let str = "";
|
|
1224
|
+
// for (let j = 0; j < allLines.length; j++) {
|
|
1225
|
+
// str += allLines[j];
|
|
1226
|
+
|
|
1227
|
+
// if (j < allLines.length - 1) str += "\n";
|
|
1228
|
+
// }
|
|
1229
|
+
|
|
1230
|
+
// console.log(str);
|
|
1231
|
+
|
|
1232
|
+
// fs.writeFileSync(fileDir + "/" + filePath, str);
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
{
|
|
1237
|
+
let fileDir = __dirname + "/./src/GN-app-api/handler/controller/handler/" + dirName + "/model";
|
|
1238
|
+
if (fs.existsSync(fileDir)) {
|
|
1239
|
+
let allFilePaths = fs.readdirSync(fileDir);
|
|
1240
|
+
|
|
1241
|
+
for (let i = 0; i < allFilePaths.length; i++) {
|
|
1242
|
+
let filePath = allFilePaths[i];
|
|
1243
|
+
|
|
1244
|
+
if (!filePath.includes(".ts")) continue;
|
|
1245
|
+
|
|
1246
|
+
if (ignoreFileLst.indexOf(filePath) != -1) continue;
|
|
1247
|
+
|
|
1248
|
+
let allLines = fs
|
|
1249
|
+
.readFileSync(fileDir + "/" + filePath)
|
|
1250
|
+
.toString()
|
|
1251
|
+
.split("\n");
|
|
1252
|
+
|
|
1253
|
+
for (let j = 0; j < allLines.length - 1; j++) {
|
|
1254
|
+
let lineJ = allLines[j];
|
|
1255
|
+
|
|
1256
|
+
if (lineJ.includes("export class ") || lineJ.includes("class ")) {
|
|
1257
|
+
let modelName = lineJ.includes("export class ") ? lineJ.replace("\r", "").replace("\n", "").replace("\t", "").split(" ")[2].trim() : lineJ.replace("\r", "").replace("\n", "").replace("\t", "").split(" ")[1].trim();
|
|
1258
|
+
let thisModel = finalModels.models.find((x) => x.name == modelName);
|
|
1259
|
+
if (thisModel == null) {
|
|
1260
|
+
thisModel = {
|
|
1261
|
+
name: modelName,
|
|
1262
|
+
details: [],
|
|
1263
|
+
};
|
|
1264
|
+
|
|
1265
|
+
finalModels.models.push(thisModel);
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
j += 1;
|
|
1269
|
+
for (let k = j; k < allLines.length - 1; k++) {
|
|
1270
|
+
lineJ = allLines[k];
|
|
1271
|
+
|
|
1272
|
+
if (lineJ.startsWith("}")) {
|
|
1273
|
+
break;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
if (lineJ.includes("@GNHashtable") || lineJ.includes("@String") || lineJ.includes("@Number") || lineJ.includes("@GNArray") || lineJ.includes("@Boolean") || lineJ.includes("@DataMember")) {
|
|
1277
|
+
let gnType = lineJ.includes("@GNHashtable")
|
|
1278
|
+
? "GNHashtable"
|
|
1279
|
+
: lineJ.includes("@String")
|
|
1280
|
+
? "String"
|
|
1281
|
+
: lineJ.includes("@Number")
|
|
1282
|
+
? "Number"
|
|
1283
|
+
: lineJ.includes("@GNArray")
|
|
1284
|
+
? "GNArray"
|
|
1285
|
+
: lineJ.includes("@Boolean")
|
|
1286
|
+
? "Boolean"
|
|
1287
|
+
: lineJ.includes("@DataMember")
|
|
1288
|
+
? "DataMember"
|
|
1289
|
+
: "Other";
|
|
1290
|
+
|
|
1291
|
+
let isOptional = false;
|
|
1292
|
+
let hasMustInt = null;
|
|
1293
|
+
let mustNonNull = null;
|
|
1294
|
+
let minLength = null;
|
|
1295
|
+
let maxLength = null;
|
|
1296
|
+
let minValue = null;
|
|
1297
|
+
let maxValue = null;
|
|
1298
|
+
let elementCls = null;
|
|
1299
|
+
let defaultValue = null;
|
|
1300
|
+
|
|
1301
|
+
let parameterCode = "";
|
|
1302
|
+
|
|
1303
|
+
let lineK = lineJ;
|
|
1304
|
+
|
|
1305
|
+
let lineKSpls = lineK.split("@"); // [ StringDataMember({ code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true }) ]
|
|
1306
|
+
let lineK2Spls = lineKSpls[1].split("("); // [ StringDataMember, { code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true }) ]
|
|
1307
|
+
let lineK3Spls = lineK2Spls[1].split("{")[1].split("}")[0].split(","); // [ code: ParameterCode.Username, minLength: 6, maxLength: 32, mustNonNull: true ]
|
|
1308
|
+
|
|
1309
|
+
for (let l = 0; l < lineK3Spls.length; l++) {
|
|
1310
|
+
let lineK4Spls = lineK3Spls[l].split(":");
|
|
1311
|
+
|
|
1312
|
+
if (lineK4Spls.length <= 1) continue;
|
|
1313
|
+
|
|
1314
|
+
let key = lineK4Spls[0].trim();
|
|
1315
|
+
let value = lineK4Spls[1].trim();
|
|
1316
|
+
|
|
1317
|
+
if (key == "mustInt" && value == "true") hasMustInt = true;
|
|
1318
|
+
else if (key == "isOptional" && value == "true") isOptional = true;
|
|
1319
|
+
else if (key == "code") {
|
|
1320
|
+
parameterCode = value.split(".")[1];
|
|
1321
|
+
} else if (key == "mustNonNull" && value == "true") mustNonNull = true;
|
|
1322
|
+
else if (key == "minValue") minValue = parseInt(value);
|
|
1323
|
+
else if (key == "maxValue") maxValue = parseInt(value);
|
|
1324
|
+
else if (key == "minLength") minLength = parseInt(value);
|
|
1325
|
+
else if (key == "maxLength") maxLength = parseInt(value);
|
|
1326
|
+
else if (key == "elementCls") elementCls = value;
|
|
1327
|
+
else if (key == "defaultValue") defaultValue = value;
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
j += 1;
|
|
1331
|
+
k += 1;
|
|
1332
|
+
|
|
1333
|
+
let lineKNext = allLines[k];
|
|
1334
|
+
|
|
1335
|
+
let type = lineKNext.replace("\r", "").replace("\t", "").replace("\n", "").replace(";", "").replace("declare", "").replace(":", "").split(" ")[2];
|
|
1336
|
+
|
|
1337
|
+
if (lineJ.includes("@GNArray")) {
|
|
1338
|
+
type = type.split("<")[1].replace(">", "");
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
let thisDetail = thisModel.details.find((x) => x.code == parameterCode);
|
|
1342
|
+
|
|
1343
|
+
if (thisDetail == null) {
|
|
1344
|
+
thisDetail = {
|
|
1345
|
+
code: parameterCode,
|
|
1346
|
+
description: "",
|
|
1347
|
+
};
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
thisDetail.optional = isOptional;
|
|
1351
|
+
thisDetail.type = type;
|
|
1352
|
+
thisDetail.gnType = gnType;
|
|
1353
|
+
thisDetail.defaultValue = defaultValue;
|
|
1354
|
+
thisDetail.conditions = {
|
|
1355
|
+
mustNonNull: mustNonNull,
|
|
1356
|
+
mustInt: hasMustInt,
|
|
1357
|
+
minLength: minLength,
|
|
1358
|
+
maxLength: maxLength,
|
|
1359
|
+
minValue: minValue,
|
|
1360
|
+
maxValue: maxValue,
|
|
1361
|
+
};
|
|
1362
|
+
|
|
1363
|
+
if (thisDetail.defaultValue == null) delete thisDetail.defaultValue;
|
|
1364
|
+
if (thisDetail.conditions.mustNonNull == null) delete thisDetail.conditions.mustNonNull;
|
|
1365
|
+
if (thisDetail.conditions.mustInt == null) delete thisDetail.conditions.mustInt;
|
|
1366
|
+
if (thisDetail.conditions.minLength == null) delete thisDetail.conditions.minLength;
|
|
1367
|
+
if (thisDetail.conditions.maxLength == null) delete thisDetail.conditions.maxLength;
|
|
1368
|
+
if (thisDetail.conditions.minValue == null) delete thisDetail.conditions.minValue;
|
|
1369
|
+
if (thisDetail.conditions.maxValue == null) delete thisDetail.conditions.maxValue;
|
|
1370
|
+
|
|
1371
|
+
thisModel.details.push(thisDetail);
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
j += 1;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
// let str = "";
|
|
1380
|
+
// for (let j = 0; j < allLines.length; j++) {
|
|
1381
|
+
// str += allLines[j];
|
|
1382
|
+
|
|
1383
|
+
// if (j < allLines.length - 1) str += "\n";
|
|
1384
|
+
// }
|
|
1385
|
+
|
|
1386
|
+
// console.log(str);
|
|
1387
|
+
|
|
1388
|
+
// fs.writeFileSync(fileDir + "/" + filePath, str);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
fs.writeFileSync("./apiReferences/" + requestType + ".json", JSON.stringify(finalModels, null, 2));
|
|
1394
|
+
}
|