cgserver 6.1.3 → 6.1.4
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/dist/lib/Database/Decorator/DBCache.js +2 -2
- package/dist/lib/Database/Decorator/Property.js +1 -1
- package/dist/lib/Logic/CacheTool.js +1 -1
- package/dist/lib/SocketServer/ISocketServer.js +1 -1
- package/dist/lib/WebServer/Engine/ControllerManager.js +9 -9
- package/dist/types/Database/Decorator/DBCache.d.ts +3 -1
- package/dist/types/Database/Decorator/Property.d.ts +3 -1
- package/dist/types/Logic/CacheTool.d.ts +3 -1
- package/dist/types/SocketServer/ISocketServer.d.ts +3 -1
- package/dist/types/WebServer/Engine/ControllerManager.d.ts +24 -6
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@ class VersionModel {
|
|
|
18
18
|
exports.VersionModel = VersionModel;
|
|
19
19
|
exports.GDBCache = null;
|
|
20
20
|
class DBCache {
|
|
21
|
-
_versions =
|
|
21
|
+
_versions = {};
|
|
22
22
|
_path = __dirname + "/tmp_table_version.json";
|
|
23
23
|
async init() {
|
|
24
24
|
if (fs.existsSync(this._path)) {
|
|
@@ -32,7 +32,7 @@ class DBCache {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
|
-
this._versions =
|
|
35
|
+
this._versions = {};
|
|
36
36
|
fs.writeFileSync(this._path, JSON.stringify(this._versions));
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GCtrMgr = void 0;
|
|
4
4
|
exports.GCtrMgr = null;
|
|
5
5
|
class ControllerManager {
|
|
6
|
-
|
|
7
|
-
_ctr_cls =
|
|
6
|
+
_static_ctr = {};
|
|
7
|
+
_ctr_cls = {};
|
|
8
8
|
//module ctrname lower normal
|
|
9
|
-
_cache_action_names =
|
|
9
|
+
_cache_action_names = {};
|
|
10
10
|
registerController(module_name, ctr_name, cls) {
|
|
11
11
|
module_name = module_name.toLowerCase();
|
|
12
12
|
ctr_name = ctr_name.toLowerCase();
|
|
@@ -22,7 +22,7 @@ class ControllerManager {
|
|
|
22
22
|
ctr_name = ctr_name.toLowerCase();
|
|
23
23
|
//不能通过cls.name来获取ctr名称,因为混淆之后类名会变化
|
|
24
24
|
let prototype = cls.prototype;
|
|
25
|
-
let map_names =
|
|
25
|
+
let map_names = {};
|
|
26
26
|
while (prototype && prototype.constructor.name != "BaseController") {
|
|
27
27
|
let names = Object.getOwnPropertyNames(prototype);
|
|
28
28
|
for (let action_name of names) {
|
|
@@ -61,15 +61,15 @@ class ControllerManager {
|
|
|
61
61
|
registerStaticController(module_name, ctr_name, obj) {
|
|
62
62
|
module_name = module_name.toLowerCase();
|
|
63
63
|
ctr_name = ctr_name.toLowerCase();
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
64
|
+
this._static_ctr[module_name] = this._static_ctr[module_name] || {};
|
|
65
|
+
this._static_ctr[module_name][ctr_name] = obj;
|
|
66
66
|
this._cacheActionNameForStatic(module_name, ctr_name, obj);
|
|
67
67
|
}
|
|
68
68
|
_cacheActionNameForStatic(module_name, ctr_name, obj) {
|
|
69
69
|
module_name = module_name.toLowerCase();
|
|
70
70
|
ctr_name = ctr_name.toLowerCase();
|
|
71
71
|
let prototype = Object.getPrototypeOf(obj);
|
|
72
|
-
let map_names =
|
|
72
|
+
let map_names = {};
|
|
73
73
|
while (prototype && prototype.constructor.name != "BaseController") {
|
|
74
74
|
let names = Object.getOwnPropertyNames(prototype);
|
|
75
75
|
for (let func_name of names) {
|
|
@@ -91,10 +91,10 @@ class ControllerManager {
|
|
|
91
91
|
if (controller_name) {
|
|
92
92
|
controller_name = controller_name.toLowerCase();
|
|
93
93
|
}
|
|
94
|
-
if (!this.
|
|
94
|
+
if (!this._static_ctr[module_name]) {
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
|
-
return this.
|
|
97
|
+
return this._static_ctr[module_name][controller_name];
|
|
98
98
|
}
|
|
99
99
|
getClass(module_name, controller_name) {
|
|
100
100
|
if (module_name) {
|
|
@@ -12,7 +12,9 @@ export declare class VersionModel {
|
|
|
12
12
|
}
|
|
13
13
|
export declare let GDBCache: DBCache;
|
|
14
14
|
declare class DBCache {
|
|
15
|
-
protected _versions:
|
|
15
|
+
protected _versions: {
|
|
16
|
+
[table_name: string]: VersionModel;
|
|
17
|
+
};
|
|
16
18
|
protected _path: string;
|
|
17
19
|
init(): Promise<void>;
|
|
18
20
|
setVersion(table: string, version: number): Promise<void>;
|
|
@@ -11,7 +11,9 @@ export declare class ISocketServer {
|
|
|
11
11
|
get fullServerName(): string;
|
|
12
12
|
private _web_socket;
|
|
13
13
|
get serverWebSocket(): ws.server;
|
|
14
|
-
protected _ws_clients:
|
|
14
|
+
protected _ws_clients: {
|
|
15
|
+
[socketid: number]: IServerWebSocket;
|
|
16
|
+
};
|
|
15
17
|
private _listen_port;
|
|
16
18
|
get listenPort(): number;
|
|
17
19
|
set listenPort(value: number);
|
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
import { BaseController } from "../Controller/BaseController";
|
|
2
2
|
export declare let GCtrMgr: ControllerManager;
|
|
3
3
|
declare class ControllerManager {
|
|
4
|
-
protected
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
protected _static_ctr: {
|
|
5
|
+
[module_name: string]: {
|
|
6
|
+
[ctrname: string]: BaseController;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
protected _ctr_cls: {
|
|
10
|
+
[module_name: string]: {
|
|
11
|
+
[ctrname: string]: {
|
|
12
|
+
new (): BaseController;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
protected _cache_action_names: {
|
|
17
|
+
[module: string]: {
|
|
18
|
+
[ctrname: string]: {
|
|
19
|
+
[lower: string]: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
registerController(module_name: string, ctr_name: string, cls: {
|
|
24
|
+
new (): BaseController;
|
|
25
|
+
}): void;
|
|
8
26
|
protected _cacheActionName(module_name: string, ctr_name: string, cls: Function): void;
|
|
9
|
-
getActionName(module_name: string, ctr_name: string, action_name: string):
|
|
27
|
+
getActionName(module_name: string, ctr_name: string, action_name: string): string;
|
|
10
28
|
/**
|
|
11
29
|
* 静态ctr,这样,ctr就不会被多次创建
|
|
12
30
|
* @param module_name
|
|
@@ -16,6 +34,6 @@ declare class ControllerManager {
|
|
|
16
34
|
registerStaticController(module_name: string, ctr_name: string, obj: BaseController): void;
|
|
17
35
|
protected _cacheActionNameForStatic(module_name: string, ctr_name: string, obj: BaseController): void;
|
|
18
36
|
getStaticCtr(module_name: string, controller_name: string): BaseController;
|
|
19
|
-
getClass(module_name: string, controller_name: string):
|
|
37
|
+
getClass(module_name: string, controller_name: string): new () => BaseController;
|
|
20
38
|
}
|
|
21
39
|
export {};
|