cgserver 7.10.2113 → 7.12.2113

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.
Files changed (80) hide show
  1. package/package.json +3 -3
  2. package/src/Framework/AI/AiObject.ts +0 -12
  3. package/src/Framework/AI/Astar.ts +0 -157
  4. package/src/Framework/AI/BehaviorAI.ts +0 -382
  5. package/src/Framework/AI/Entity.ts +0 -37
  6. package/src/Framework/AI/Point.ts +0 -84
  7. package/src/Framework/AI/TriggerMgr.ts +0 -280
  8. package/src/Framework/Config/Config.ts +0 -61
  9. package/src/Framework/Config/FrameworkConfig.ts +0 -286
  10. package/src/Framework/Config/IServerConfig.ts +0 -28
  11. package/src/Framework/Config/_error_.ts +0 -32
  12. package/src/Framework/Core/Core.ts +0 -810
  13. package/src/Framework/Core/Timer.ts +0 -147
  14. package/src/Framework/Database/Decorator/AutoIncrement.ts +0 -9
  15. package/src/Framework/Database/Decorator/DBCache.ts +0 -74
  16. package/src/Framework/Database/Decorator/NotNull.ts +0 -9
  17. package/src/Framework/Database/Decorator/PrimaryKey.ts +0 -9
  18. package/src/Framework/Database/Decorator/Property.ts +0 -64
  19. package/src/Framework/Database/Decorator/Table.ts +0 -13
  20. package/src/Framework/Database/Decorator/Type.ts +0 -21
  21. package/src/Framework/Database/MSSqlManager.ts +0 -52
  22. package/src/Framework/Database/MongoBaseService.ts +0 -136
  23. package/src/Framework/Database/MongoManager.ts +0 -501
  24. package/src/Framework/Database/MysqlBaseService.ts +0 -345
  25. package/src/Framework/Database/MysqlManager.ts +0 -212
  26. package/src/Framework/Database/RedisManager.ts +0 -544
  27. package/src/Framework/Logic/CacheTool.ts +0 -85
  28. package/src/Framework/Logic/EventTool.ts +0 -31
  29. package/src/Framework/Logic/HttpTool.ts +0 -82
  30. package/src/Framework/Logic/Log.ts +0 -171
  31. package/src/Framework/Logic/SyncQueueTool.ts +0 -51
  32. package/src/Framework/Service/AccountService.ts +0 -508
  33. package/src/Framework/Service/MongoAccountService.ts +0 -456
  34. package/src/Framework/Service/MongoCacheService.ts +0 -48
  35. package/src/Framework/Service/MongoUserService.ts +0 -103
  36. package/src/Framework/Service/UserService.ts +0 -168
  37. package/src/Framework/Service/ini.ts +0 -33
  38. package/src/Framework/SocketServer/IClientWebSocket.ts +0 -50
  39. package/src/Framework/SocketServer/IRpc.ts +0 -12
  40. package/src/Framework/SocketServer/IRpcClientWebSocket.ts +0 -75
  41. package/src/Framework/SocketServer/IRpcServerWebSocket.ts +0 -76
  42. package/src/Framework/SocketServer/IServerWebSocket.ts +0 -88
  43. package/src/Framework/SocketServer/ISocketServer.ts +0 -243
  44. package/src/Framework/SocketServer/IWebSocket.ts +0 -243
  45. package/src/Framework/SocketServer/ProtoFilter/GoogleProtoFilter.ts +0 -68
  46. package/src/Framework/SocketServer/ProtoFilter/IProtoFilter.ts +0 -11
  47. package/src/Framework/SocketServer/ProtoFilter/JsonProtoFilter.ts +0 -34
  48. package/src/Framework/SocketServer/ProtoFilter/ProtoFactory.ts +0 -34
  49. package/src/Framework/ThirdParty/AlipayTool.ts +0 -224
  50. package/src/Framework/ThirdParty/Alisms.ts +0 -53
  51. package/src/Framework/ThirdParty/AppleTool.ts +0 -252
  52. package/src/Framework/ThirdParty/CgMq.ts +0 -153
  53. package/src/Framework/ThirdParty/EmailTool.ts +0 -37
  54. package/src/Framework/ThirdParty/OpenSocial.ts +0 -36
  55. package/src/Framework/ThirdParty/QQTool.ts +0 -124
  56. package/src/Framework/ThirdParty/QiniuTool.ts +0 -23
  57. package/src/Framework/ThirdParty/Rpc.ts +0 -75
  58. package/src/Framework/ThirdParty/WechatOATool.ts +0 -61
  59. package/src/Framework/ThirdParty/WechatTool.ts +0 -80
  60. package/src/Framework/WebServer/Controller/BaseController.ts +0 -140
  61. package/src/Framework/WebServer/Controller/BaseUserController.ts +0 -209
  62. package/src/Framework/WebServer/Controller/MongoBaseUserController.ts +0 -209
  63. package/src/Framework/WebServer/Decorator/AdminValidate.ts +0 -19
  64. package/src/Framework/WebServer/Decorator/AuthorityValidate.ts +0 -25
  65. package/src/Framework/WebServer/Decorator/CreatorValidate.ts +0 -19
  66. package/src/Framework/WebServer/Decorator/JsonAdminValidate.ts +0 -16
  67. package/src/Framework/WebServer/Decorator/JsonAuthorityValidate.d.ts +0 -2
  68. package/src/Framework/WebServer/Decorator/JsonAuthorityValidate.ts +0 -23
  69. package/src/Framework/WebServer/Decorator/JsonCreatorValidate.ts +0 -19
  70. package/src/Framework/WebServer/Decorator/SyncCall.ts +0 -20
  71. package/src/Framework/WebServer/Decorator/SyncCallServer.ts +0 -45
  72. package/src/Framework/WebServer/Engine/ControllerManager.ts +0 -134
  73. package/src/Framework/WebServer/Engine/Engine.ts +0 -186
  74. package/src/Framework/WebServer/Engine/RazorJs.ts +0 -720
  75. package/src/Framework/WebServer/Engine/Request.ts +0 -267
  76. package/src/Framework/WebServer/Engine/Response.ts +0 -123
  77. package/src/Framework/WebServer/IWebServer.ts +0 -61
  78. package/src/Framework/cgserver.ts +0 -112
  79. package/src/Framework/index.ts +0 -92
  80. package/src/test/test.ts +0 -12
@@ -1,508 +0,0 @@
1
- import { EPropertyType } from './../Database/Decorator/Property';
2
- import { BaseModel, MysqlBaseService } from '../Database/MysqlBaseService';
3
- import { GMysqlMgr } from '../Database/MysqlManager';
4
- import { GCacheTool } from '../Logic/CacheTool';
5
- import { EErrorCode } from '../Config/_error_';
6
- import { GOpenSocial } from '../ThirdParty/OpenSocial';
7
- import { GUserSer, UserModel } from './UserService';
8
- import { GQQTool } from '../ThirdParty/QQTool';
9
- import { GWechatTool } from '../ThirdParty/WechatTool';
10
- import { Table } from '../Database/Decorator/Table';
11
- import { PrimaryKey } from '../Database/Decorator/PrimaryKey';
12
- import { NotNull } from '../Database/Decorator/NotNull';
13
- import { Type } from '../Database/Decorator/Type';
14
- import { AutoIncrement } from '../Database/Decorator/AutoIncrement';
15
- import { EAccountFrom, EAccountState } from './ini';
16
-
17
- @Table("account",1,"账号")
18
- export class AccountModel extends BaseModel
19
- {
20
- @Type(EPropertyType.Int)
21
- @NotNull
22
- @PrimaryKey
23
- @AutoIncrement
24
- id:number = -1
25
-
26
- @NotNull
27
- @Type(EPropertyType.Varchar)
28
- phone:string=""
29
-
30
- @NotNull
31
- @Type(EPropertyType.Varchar)
32
- email:string=""
33
-
34
- @NotNull
35
- @Type(EPropertyType.Varchar)
36
- name:string=""
37
-
38
- @NotNull
39
- @Type(EPropertyType.Varchar)
40
- password:string=""
41
-
42
- @NotNull
43
- @Type(EPropertyType.Varchar,"",128)
44
- unionid:string=""//第三方
45
-
46
- @NotNull
47
- @Type(EPropertyType.Varchar,"",128)
48
- openid:string=""
49
-
50
- @NotNull
51
- @Type(EPropertyType.BigInt)
52
- create_time:number=-1
53
-
54
- @NotNull
55
- @Type(EPropertyType.Varchar)
56
- create_ip:string=""
57
-
58
- @NotNull
59
- @Type(EPropertyType.BigInt)
60
- login_time:number=-1
61
-
62
- @NotNull
63
- @Type(EPropertyType.Varchar)
64
- login_ip:string=""
65
-
66
- @NotNull
67
- @Type(EPropertyType.Int)
68
- from:number=0
69
-
70
- @NotNull
71
- @Type(EPropertyType.Int)
72
- state:number=EAccountState.Waitting
73
- }
74
- //暂时不实例化,方便重写
75
- export let GAccountSer:AccountService=null
76
- export class AccountService extends MysqlBaseService<AccountModel>
77
- {
78
- protected _account_cache_key_pre="table_account_"
79
- protected _account_cache_time_sec=1*60*60*1000
80
- constructor()
81
- {
82
- super(AccountModel)
83
- GAccountSer = this
84
- }
85
- protected _getNewModel()
86
- {
87
- return new AccountModel()
88
- }
89
- /**
90
- * 注册新账号
91
- * @param unionid
92
- * @param openid
93
- * @param ip
94
- * @param from
95
- */
96
- async add(unionid:string,openid:string,ip:string,from:EAccountFrom)
97
- {
98
- let account = this._getNewModel()
99
- switch(from)
100
- {
101
- case EAccountFrom.OpenSocial:
102
- case EAccountFrom.WeChat:
103
- case EAccountFrom.QQ:
104
- case EAccountFrom.Apple:
105
- case EAccountFrom.Google:
106
- {
107
- account.unionid=unionid
108
- account.openid=openid
109
- break
110
- }
111
- case EAccountFrom.Email:
112
- {
113
- account.email=unionid
114
- account.password=openid
115
- break
116
- }
117
- case EAccountFrom.Phone:
118
- case EAccountFrom.QuickPhone:
119
- {
120
- account.phone=unionid
121
- account.password=openid
122
- break
123
- }
124
- case EAccountFrom.Name:
125
- case EAccountFrom.Guest:
126
- {
127
- account.name=unionid
128
- account.password=openid
129
- break
130
- }
131
- }
132
- account.create_time=Date.now()
133
- account.create_ip=ip
134
- account.login_time=Date.now()
135
- account.login_ip=ip
136
- account.from=from
137
- account.state=EAccountState.Waitting
138
- delete account.id
139
- let sr = await this.insert(account)
140
- if(sr.error
141
- ||!sr.results.insertId)
142
- {
143
- return null
144
- }
145
- account.id = sr.results.insertId
146
- return account
147
- }
148
- /**
149
- * 通过第三方信息获取账号
150
- * @param unionid
151
- * @param openid
152
- */
153
- async getByThird(unionid:string,openid:string)
154
- {
155
- let key = this._account_cache_key_pre+unionid
156
- let am:AccountModel=GCacheTool.get(key)
157
- if(am)
158
- {
159
- return am
160
- }
161
- am = await this.get(null,"unionid=? and openid=?",[unionid,openid])
162
- if(am)
163
- {
164
- GCacheTool.add(key,am,this._account_cache_time_sec)
165
- }
166
- return am
167
- }
168
- /**
169
- * 通过第三方信息获取账号
170
- * @param unionid
171
- */
172
- async getByUnionid(unionid:string)
173
- {
174
- let key = this._account_cache_key_pre+unionid
175
- let am:AccountModel=GCacheTool.get(key)
176
- if(am)
177
- {
178
- return am
179
- }
180
- am = await this.get(null,"unionid=?",[unionid])
181
- if(am)
182
- {
183
- GCacheTool.add(key,am,this._account_cache_time_sec)
184
- }
185
- return am
186
- }
187
- async getByPhone(phone:string)
188
- {
189
- let key = this._account_cache_key_pre+phone
190
- let am:AccountModel=GCacheTool.get(key)
191
- if(am)
192
- {
193
- return am
194
- }
195
- am = await this.get(null,"phone=?",[phone])
196
- if(am)
197
- {
198
- GCacheTool.add(key,am,this._account_cache_time_sec)
199
- }
200
- return am
201
- }
202
- /**
203
- * 登陆接口
204
- * @param unionid
205
- * @param openid
206
- * @param ip
207
- * @param from
208
- * @param access_token qq、wechat使用
209
- */
210
- async login(unionid:string,openid:string,ip:string,from:EAccountFrom,access_token?:string,extra?:{nickname:string,sex:number,logo:string})
211
- {
212
- let rs = {errcode:null,account:<AccountModel>null,is_new:false}
213
- if(!unionid||!openid)
214
- {
215
- rs.errcode=EErrorCode.Wrong_Params
216
- return rs
217
- }
218
- let login_rs = await this._login(unionid,openid,from)
219
- rs.account=login_rs.account
220
- rs.errcode=login_rs.errcode
221
- if(rs.errcode)
222
- {
223
- return rs
224
- }
225
- let account = rs.account
226
- let extra_info:{nickname:string,sex:number,logo:string}=extra
227
- if(!account)
228
- {
229
- switch(from)
230
- {
231
- case EAccountFrom.OpenSocial:
232
- case EAccountFrom.QQ:
233
- case EAccountFrom.WeChat:
234
- case EAccountFrom.Guest:
235
- case EAccountFrom.QuickPhone:
236
- case EAccountFrom.Apple:
237
- case EAccountFrom.Google:
238
- {
239
- account = await this.add(unionid,openid,ip,from)
240
- break
241
- }
242
- default:
243
- {
244
- rs.errcode = EErrorCode.No_Account
245
- return rs
246
- }
247
- }
248
- }
249
- if(!account)
250
- {
251
- rs.errcode = EErrorCode.No_Account
252
- return rs
253
- }
254
- let user = await GUserSer.getByAccountId(account.id)
255
- if(!user)
256
- {
257
- switch(from)
258
- {
259
- case EAccountFrom.OpenSocial:
260
- case EAccountFrom.QQ:
261
- case EAccountFrom.WeChat:
262
- case EAccountFrom.Apple:
263
- case EAccountFrom.Google:
264
- {
265
- if(!extra_info)
266
- {
267
- if(from==EAccountFrom.OpenSocial)
268
- {
269
- let body = await GOpenSocial.getUser(unionid,openid)
270
- if(body&&body.errcode)
271
- {
272
- rs.errcode = body.errcode
273
- return rs
274
- }
275
- else if(body&&body.user)
276
- {
277
- extra_info=
278
- {
279
- logo:body.user.logo,
280
- sex:body.user.sex,
281
- nickname:body.user.nickname
282
- }
283
- }
284
- }
285
- else if(from==EAccountFrom.QQ)
286
- {
287
- let userInfo = await GQQTool.getUserInfo(access_token,openid)
288
- if(userInfo.ret)
289
- {
290
- rs.errcode=EErrorCode.Server_Error
291
- return rs
292
- }
293
- extra_info=
294
- {
295
- logo:userInfo.figureurl_qq,
296
- sex:(userInfo.gender=="男"?1:0),
297
- nickname:userInfo.nickname
298
- }
299
- }
300
- else if(from==EAccountFrom.WeChat)
301
- {
302
- let userInfo = await GWechatTool.getUserInfo(access_token,openid)
303
- if((<any>userInfo).errcode)
304
- {
305
- rs.errcode=EErrorCode.Server_Error
306
- return rs
307
- }
308
- extra_info=
309
- {
310
- logo:userInfo.headimgurl,
311
- sex:(userInfo.sex==1?1:0),
312
- nickname:userInfo.nickname
313
- }
314
- }
315
- else if(from==EAccountFrom.Apple||from==EAccountFrom.Google)
316
- {
317
- extra_info=
318
- {
319
- logo:"32",
320
- sex:0,
321
- nickname:"noname"
322
- }
323
- }
324
- }
325
- let user = await GUserSer.add(account.id,extra_info.nickname,extra_info.sex,extra_info.logo)
326
- if(!user)
327
- {
328
- this.removeById(account.id)
329
- rs.errcode=EErrorCode.User_Create_Failed
330
- return rs
331
- }
332
- break;
333
- }
334
- case EAccountFrom.QuickPhone:
335
- case EAccountFrom.Guest:
336
- {
337
- let user:UserModel = null
338
- if(extra_info)
339
- {
340
- user = await GUserSer.add(account.id,extra_info.nickname,extra_info.sex,extra_info.logo)
341
- }
342
- else
343
- {
344
- user = await GUserSer.add(account.id,null,null,null)
345
- }
346
- if(!user)
347
- {
348
- this.removeById(account.id)
349
- rs.errcode=EErrorCode.User_Create_Failed
350
- return rs
351
- }
352
- break;
353
- }
354
- default:
355
- {
356
- rs.errcode = EErrorCode.No_Account
357
- return rs
358
- }
359
- }
360
- rs.is_new=true
361
- if(extra)
362
- {
363
- await GUserSer.updateBaseInfoByAccount(account.id,extra_info.nickname,extra_info.sex,extra_info.logo)
364
- }
365
- }
366
- if(user&&extra_info)
367
- {
368
- await GUserSer.updateProperty("nickname=?,sex=?,logo=?","id=?",[extra_info.nickname,extra_info.sex||0,extra_info.logo,user.id])
369
- }
370
- rs.account = account
371
- return rs
372
- }
373
- protected async _login(unionid:string,openid:string,from:EAccountFrom)
374
- {
375
- let rs = {errcode:null,account:<AccountModel>null}
376
- if(from==EAccountFrom.QQ
377
- ||from==EAccountFrom.WeChat
378
- ||from==EAccountFrom.OpenSocial
379
- ||from==EAccountFrom.Apple
380
- ||from==EAccountFrom.Google)
381
- {
382
- rs.account = await this.getByThird(unionid,openid)
383
- }
384
- else if(from==EAccountFrom.QuickPhone)
385
- {
386
- let key = "phone_code_"+unionid
387
- let code = GCacheTool.get(key)
388
- if(!code||code!=openid)
389
- {
390
- rs.errcode=EErrorCode.Wrong_Phone_Code
391
- return rs
392
- }
393
- rs.account = await this.getByPhone(unionid)
394
- }
395
- else if(from==EAccountFrom.Phone)
396
- {
397
- rs.account = await this.get(null,"phone=? and password=?",[unionid,openid])
398
- if(!rs.account)
399
- {
400
- rs.errcode=EErrorCode.Login_Failed
401
- }
402
- }
403
- else if(from==EAccountFrom.Email)
404
- {
405
- rs.account = await this.get(null,"email=? and password=?",[unionid,openid])
406
- if(!rs.account)
407
- {
408
- rs.errcode=EErrorCode.Login_Failed
409
- }
410
- }
411
- else if(from==EAccountFrom.Name||from==EAccountFrom.Guest)
412
- {
413
- rs.account = await this.get(null,"name=? and password=?",[unionid,openid])
414
- if(!rs.account&&from==EAccountFrom.Name)
415
- {
416
- rs.errcode=EErrorCode.Login_Failed
417
- }
418
- }
419
- return rs
420
- }
421
- /**
422
- * 修改密码
423
- * @param unionid
424
- * @param openid
425
- * @param new_pwd
426
- */
427
- async updatePwd(unionid:string,openid:string,new_pwd:string)
428
- {
429
- let rs = await GOpenSocial.updatePwd(unionid,openid,new_pwd)
430
- return rs
431
- }
432
- async register(type:EAccountFrom,key:string,password:string,ip:string,extra?)
433
- {
434
- let rs={user:<UserModel>null,errcode:null}
435
- extra=extra||{}
436
- let am = this._getNewModel()
437
- switch(type)
438
- {
439
- case EAccountFrom.Phone:
440
- {
441
- am.phone=key
442
- let temp=await this.get("id","phone=?",[key])
443
- if(temp)
444
- {
445
- rs.errcode=EErrorCode.Account_Phone_Exist
446
- return rs
447
- }
448
- break
449
- }
450
- case EAccountFrom.Email:
451
- {
452
- am.email=key
453
- let temp=await this.get("id","email=?",[key])
454
- if(temp)
455
- {
456
- rs.errcode=EErrorCode.Account_Email_Exist
457
- return rs
458
- }
459
- break
460
- }
461
- case EAccountFrom.Name:
462
- {
463
- am.name=key
464
- let temp=await this.get("id","name=?",[key])
465
- if(temp)
466
- {
467
- rs.errcode=EErrorCode.Account_Name_Exist
468
- return rs
469
- }
470
- break
471
- }
472
- default:
473
- {
474
- rs.errcode=EErrorCode.Account_Type_Error
475
- return rs
476
- }
477
- }
478
- am.password=password
479
- am.create_time=Date.now()
480
- am.create_ip=ip
481
- am.login_time=Date.now()
482
- am.login_ip=ip
483
-
484
- let sr = await this.insert(am)
485
- if(sr.results.insertId)
486
- {
487
- am.id=sr.results.insertId
488
- }
489
- else
490
- {
491
- am = null
492
- }
493
- if(!am)
494
- {
495
- rs.errcode=EErrorCode.Mysql_Error
496
- return rs
497
- }
498
- let user = await GUserSer.add(am.id,extra.nickname,extra.sex,extra.logo)
499
- if(!user)
500
- {
501
- this.removeById(am.id)
502
- rs.errcode=EErrorCode.User_Create_Failed
503
- return rs
504
- }
505
- rs.user=user
506
- return rs
507
- }
508
- }