cgserver 7.10.2113 → 7.11.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 +1 -1
  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,147 +0,0 @@
1
- import { core } from './Core';
2
- import { GLog } from '../Logic/Log';
3
- export class Timer
4
- {
5
- protected _deadline:number = -1
6
- get deadline()
7
- {
8
- return this._deadline
9
- }
10
- protected _handler = null
11
- get handler()
12
- {
13
- return this._handler
14
- }
15
- get isRunning()
16
- {
17
- if(this._handler)
18
- {
19
- return true
20
- }
21
- return false
22
- }
23
- protected _call_back:Function = null
24
- protected _left_time:number = -1
25
- protected _is_interval:boolean=false
26
- constructor()
27
- {
28
-
29
- }
30
- setTimeout(handler: any, timeout?: any, ...args: any[])
31
- {
32
- this._call_back = handler
33
- this.clear()
34
- if(timeout==undefined)
35
- {
36
- timeout = 30000
37
- }
38
- this._deadline = Date.now() + timeout
39
- this._handler = setTimeout(()=>
40
- {
41
- this._deadline = -1
42
- this._handler = null
43
- this._left_time = -1
44
- try
45
- {
46
- this._call_back()
47
- }
48
- catch(e)
49
- {
50
- if(e&&e.stack)
51
- {
52
- GLog.error(e.stack)
53
- }
54
- else
55
- {
56
- GLog.error(e)
57
- }
58
- }
59
- }, timeout, ...args)
60
- }
61
- setInterval(handler: any, timeout?: any, ...args: any[])
62
- {
63
- this._call_back = handler
64
- this.clear()
65
- this._is_interval=true
66
- if(timeout==undefined)
67
- {
68
- timeout = 30000
69
- }
70
- this._deadline = -1
71
- this._left_time=timeout
72
- this._handler = setInterval(()=>
73
- {
74
- try
75
- {
76
- this._call_back()
77
- }
78
- catch(e)
79
- {
80
- if(e&&e.stack)
81
- {
82
- GLog.error(e.stack)
83
- }
84
- else
85
- {
86
- GLog.error(e)
87
- }
88
- }
89
- }, timeout, ...args)
90
- }
91
- pause()
92
- {
93
- if(this._handler)
94
- {
95
- if(!this._is_interval)
96
- {
97
- this._left_time = this._deadline - Date.now()
98
- clearTimeout(this._handler)
99
- }
100
- else
101
- {
102
- clearInterval(this._handler)
103
- }
104
- this._deadline = -1
105
- this._handler = null
106
- }
107
- }
108
- resume()
109
- {
110
- if(this._left_time>0)
111
- {
112
- if(!this._is_interval)
113
- {
114
- this._deadline = Date.now() + this._left_time
115
- this._handler = setTimeout(()=>
116
- {
117
- this._call_back()
118
- this._deadline = -1
119
- this._handler = null
120
- this._left_time = -1
121
- }, this._left_time)
122
- }
123
- else
124
- {
125
- this.setInterval(this._call_back,this._left_time)
126
- }
127
- }
128
- }
129
- clear()
130
- {
131
- if(this._handler)
132
- {
133
- if(!this._is_interval)
134
- {
135
- clearTimeout(this._handler)
136
- }
137
- else
138
- {
139
- clearInterval(this._handler)
140
- }
141
- }
142
- this._deadline = -1
143
- this._handler = null
144
- this._left_time = -1
145
- this._is_interval=false
146
- }
147
- }
@@ -1,9 +0,0 @@
1
- import { Property, TableProperty } from "./Property"
2
-
3
- export function AutoIncrement(target: any, propertyName: string)
4
- {
5
- let table:TableProperty=target[TableProperty.key]=target[TableProperty.key]||new TableProperty()
6
- table.items[propertyName]=table.items[propertyName]||new Property()
7
- let pt:Property = table.items[propertyName]
8
- pt.auto_increment=true
9
- }
@@ -1,74 +0,0 @@
1
- import { GLog } from './../../Logic/Log';
2
- import * as fs from "fs";
3
-
4
- export class VersionModel
5
- {
6
- table:string=""
7
- version:number=0
8
- /**
9
- * 创建时间
10
- */
11
- create_time:number=0
12
-
13
- /**
14
- * 创建时间
15
- */
16
- update_time:number=0
17
- }
18
-
19
- export let GDBCache:DBCache=null
20
- class DBCache
21
- {
22
- protected _versions:{[table_name:string]:VersionModel}={}
23
- protected _path=__dirname+"/tmp_table_version.json"
24
- async init()
25
- {
26
- if(fs.existsSync(this._path))
27
- {
28
- try{
29
- let table=fs.readFileSync(this._path)
30
- this._versions=JSON.parse(table.toString())
31
- }
32
- catch(e)
33
- {
34
- GLog.info("error:"+this._path)
35
- process.exit()
36
- }
37
- }
38
- else
39
- {
40
- this._versions={}
41
- fs.writeFileSync(this._path,JSON.stringify(this._versions))
42
- }
43
- }
44
- async setVersion(table:string,version:number)
45
- {
46
- let vm:VersionModel = this._versions[table]
47
- if(!vm)
48
- {
49
- vm = new VersionModel()
50
- vm.table=table
51
- vm.version=version
52
- vm.create_time=Date.now()
53
- vm.update_time=Date.now()
54
- this._versions[table]=vm
55
- fs.writeFileSync(this._path,JSON.stringify(this._versions))
56
- }
57
- else if(vm.version!=version)
58
- {
59
- vm.version=version
60
- vm.update_time=Date.now()
61
- fs.writeFileSync(this._path,JSON.stringify(this._versions))
62
- }
63
- }
64
- getVersion(table:string)
65
- {
66
- let vm:VersionModel = this._versions[table]
67
- if(!vm)
68
- {
69
- return -1
70
- }
71
- return vm.version
72
- }
73
- }
74
- GDBCache=new DBCache()
@@ -1,9 +0,0 @@
1
- import { Property, TableProperty } from "./Property"
2
-
3
- export function NotNull(target: any, propertyName: string)
4
- {
5
- let table:TableProperty=target[TableProperty.key]=target[TableProperty.key]||new TableProperty()
6
- table.items[propertyName]=table.items[propertyName]||new Property()
7
- let pt:Property = table.items[propertyName]
8
- pt.is_notnull=true
9
- }
@@ -1,9 +0,0 @@
1
- import { Property, TableProperty } from "./Property"
2
-
3
- export function PrimaryKey(target: any, propertyName: string)
4
- {
5
- let table:TableProperty=target[TableProperty.key]=target[TableProperty.key]||new TableProperty()
6
- table.items[propertyName]=table.items[propertyName]||new Property()
7
- let pt:Property = table.items[propertyName]
8
- pt.is_primary=true
9
- }
@@ -1,64 +0,0 @@
1
- export class EPropertyType
2
- {
3
- public static Char="char";
4
- public static NVarchar="nvarchar";
5
- public static Varchar="varchar";
6
-
7
- public static BigInt="bigint";
8
- public static Decimal="decimal";
9
- public static Double="double";
10
- public static Float="float";
11
- public static Int="int";
12
- public static MediumInt="Mediumint";
13
- public static Real="real";
14
- public static SmallInt="smallint";
15
- public static TinyInt="tinyint";
16
-
17
- public static LongText="longtext";
18
- public static MediumText="mediumtext";
19
- public static Text="text";
20
- public static TinyText="tinytext";
21
-
22
- public static defs=
23
- {
24
- "char":"",
25
- "nvarchar":"",
26
- "varchar":"",
27
-
28
- "bigint":0,
29
- "decimal":0,
30
- "double":0,
31
- "float":0,
32
- "int":0,
33
- "Mediumint":0,
34
- "real":0,
35
- "smallint":0,
36
- "tinyint":0,
37
-
38
- "longtext":"",
39
- "mediumtext":"",
40
- "text":undefined,
41
- "tinytext":""
42
- }
43
- }
44
- export class Property
45
- {
46
- public is_primary:boolean=false
47
- public is_notnull:boolean=false
48
- public auto_increment:boolean=false
49
- public auto_start:number=1//包含
50
- public type:string=EPropertyType.Varchar
51
- public type_len:number=45
52
- public default:any=null
53
- }
54
- export class TableProperty
55
- {
56
- public static key="___table___"
57
- public table:string=null
58
- public version:number=1
59
- public engine:string="InnoDB"
60
- public auto_increment:number=null
61
- public charset:string="utf8mb4"
62
- public comment:string=null
63
- public items:{[name:string]:Property}={}
64
- }
@@ -1,13 +0,0 @@
1
- import { TableProperty } from "./Property"
2
-
3
- export function Table(table_name:string,version:number,comment?:string,charset?:string,auto_increment?:number) {
4
- return function(constructor: Function)
5
- {
6
- let table:TableProperty = constructor.prototype[TableProperty.key]=constructor.prototype[TableProperty.key]||new TableProperty()
7
- table.table=table_name
8
- table.version=version
9
- table.comment=comment||table.comment
10
- table.charset=charset||table.charset
11
- table.auto_increment=auto_increment||table.auto_increment
12
- }
13
- }
@@ -1,21 +0,0 @@
1
- import { Property, EPropertyType, TableProperty } from "./Property"
2
-
3
- export function Type(type:string,def?:any,len?:number)
4
- {
5
- return function (target: any, propertyName: string)
6
- {
7
- let table:TableProperty=target[TableProperty.key]=target[TableProperty.key]||new TableProperty()
8
- table.items[propertyName]=table.items[propertyName]||new Property()
9
- let pt:Property = table.items[propertyName]
10
- pt.type=type
11
- if(def!=undefined)
12
- {
13
- pt.default=def
14
- }
15
- else
16
- {
17
- pt.default=EPropertyType.defs[type]
18
- }
19
- pt.type_len=len||pt.type_len
20
- }
21
- }
@@ -1,52 +0,0 @@
1
- import * as mssql from "mssql";
2
- import { GServerCfg } from "../Config/IServerConfig";
3
- import { GDBCache } from "./Decorator/DBCache";
4
-
5
- export class MssqlReturn
6
- {
7
- error=null
8
- fields=null
9
- list:Array<any>=null
10
- }
11
-
12
- export let GMSSqlMgr:MSSqlManager=null
13
- class MSSqlManager
14
- {
15
- protected _init_cbs=[]
16
- protected _pool:mssql.ConnectionPool = null
17
- get pool()
18
- {
19
- return this._pool
20
- }
21
- get isValid()
22
- {
23
- return !!this._pool
24
- }
25
- constructor()
26
- {
27
-
28
- }
29
- async init()
30
- {
31
- if(this._pool
32
- ||!GServerCfg.db.mssql
33
- ||!GServerCfg.db.mssql.open)
34
- {
35
- return
36
- }
37
-
38
- this._pool = await mssql.connect(<any>GServerCfg.db.mssql)
39
- console.log("mssql config="+JSON.stringify(GServerCfg.db.mssql))
40
- //这个的初始化位置不能变,必须位于cbs前,pool后
41
- await GDBCache.init()
42
- for(let i=0;i<this._init_cbs.length;++i)
43
- {
44
- this._init_cbs[i]()
45
- }
46
- }
47
- registerInitCb(cb:Function)
48
- {
49
- this._init_cbs.push(cb)
50
- }
51
- }
52
- GMSSqlMgr=new MSSqlManager()
@@ -1,136 +0,0 @@
1
- import { GMongoMgr } from "./MongoManager";
2
- import * as mongo from 'mongodb';
3
-
4
- export class MongoBaseService<T>
5
- {
6
- protected _table:string=""
7
- get table()
8
- {
9
- return this._table
10
- }
11
- protected _inited=false
12
- get isInited()
13
- {
14
- return this._inited
15
- }
16
- get mongo()
17
- {
18
- return GMongoMgr.mongo
19
- }
20
- protected _t_type:{ new(): T}=null
21
- constructor(table:string,type: { new(): T})
22
- {
23
- this._t_type=type
24
- this._table=table
25
- }
26
- async getNextId()
27
- {
28
- let id = await GMongoMgr.getAutoIds(this._table)
29
- return id
30
- }
31
- /**
32
- * 没有id(非_id)的表不能使用该函数
33
- * @param id
34
- */
35
- async getById(id:any)
36
- {
37
- let rs=await GMongoMgr.findOne(this._table,null,{id:id})
38
- return rs.one
39
- }
40
- async get(proterty?:{},where?:{})
41
- {
42
- let rs = await GMongoMgr.findOne(this._table,proterty,where)
43
- return rs.one
44
- }
45
- async countDocuments(where?:{},options?: mongo.CountDocumentsOptions)
46
- {
47
- let rs = await GMongoMgr.countDocuments(this._table,where)
48
- return rs.count
49
- }
50
- async gets(property?:{},where?:{},sort?:{},skip=0,limit=0)
51
- {
52
- let rs = await GMongoMgr.findMany(this._table,property,where,sort,skip,limit)
53
- return rs.list
54
- }
55
- async getRandoms(num:number,proterty?:{},where?:{})
56
- {
57
- let rs = await GMongoMgr.simpleAggregate(this._table,proterty,where,null,num)
58
- return rs.list
59
- }
60
- async updateOne(model,where?:{},upsert=false)
61
- {
62
- let rs = await GMongoMgr.updateOne(this._table,model,where,upsert)
63
- return rs
64
- }
65
- async updateMany(model,where?:{})
66
- {
67
- let rs = await GMongoMgr.updateMany(this._table,model,where)
68
- return rs
69
- }
70
- async insert(model:T)
71
- {
72
- let rs = await GMongoMgr.insertOne(this._table,model)
73
- return rs
74
- }
75
- async deleteOne(where)
76
- {
77
- let rs = await GMongoMgr.deleteOne(this._table,where)
78
- return rs
79
- }
80
- async deleteMany(where)
81
- {
82
- let rs = await GMongoMgr.deleteMany(this._table,where)
83
- return rs
84
- }
85
- async createIndex(index:any,options?:mongo.CreateIndexesOptions)
86
- {
87
- let rs = await GMongoMgr.createIndex(this._table,index,options)
88
- return rs
89
- }
90
- aggregate(pipeline?: Document[], options?: mongo.AggregateOptions)
91
- {
92
- let ret = GMongoMgr.aggregate(this._table,pipeline,options)
93
- return ret
94
- }
95
- /**
96
- * 仅仅支持一级
97
- * @param array 数据名称 比如 items
98
- * @param where 数组内赛选条件 比如 "items.id":1
99
- * @param pre_match 数组上一级赛选条件 比如 "user_id":1
100
- */
101
- async getsInArray<T>(array:string,where?:any,pre_match?:any)
102
- {
103
- let agg = this.aggregate()
104
- if(pre_match)
105
- {
106
- agg=agg.match(pre_match)
107
- }
108
- agg=agg.unwind("$"+array)
109
- if(where)
110
- {
111
- agg=agg.match(where)
112
- }
113
- let all = await agg.toArray()
114
- let items:T[] = []
115
- for(let i=0;i<all.length;++i)
116
- {
117
- items.push(all[i][array])
118
- }
119
- return items
120
- }
121
- /**
122
- * 仅仅支持一级
123
- * @param array 数据名称 比如 items
124
- * @param where 数组内赛选条件 比如 "items.id":1
125
- * @param pre_match 数组上一级赛选条件 比如 "user_id":1
126
- */
127
- async getInArray<T>(array:string,where?:any,pre_match?:any)
128
- {
129
- let items = await this.getsInArray<T>(array,where,pre_match)
130
- if(items.length<=0)
131
- {
132
- return null
133
- }
134
- return items[0]
135
- }
136
- }