cgserver 8.3.5 → 8.3.6
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/Framework/Decorator/AdminValidate.js +19 -0
- package/dist/lib/Framework/Decorator/AuthorityValidate.js +22 -0
- package/dist/lib/Framework/Decorator/CreatorValidate.js +19 -0
- package/dist/lib/Framework/Decorator/JsonAdminValidate.js +15 -0
- package/dist/lib/Framework/Decorator/JsonAuthorityValidate.js +20 -0
- package/dist/lib/Framework/Decorator/JsonCreatorValidate.js +19 -0
- package/dist/lib/Framework/Decorator/SyncCall.js +41 -0
- package/dist/lib/Framework/Decorator/SyncCallServer.js +77 -0
- package/dist/lib/Framework/Service/MongoUserService.js +1 -1
- package/dist/lib/Framework/index.js +8 -8
- package/dist/types/Framework/Decorator/AdminValidate.d.ts +1 -0
- package/dist/types/Framework/Decorator/AuthorityValidate.d.ts +2 -0
- package/dist/types/Framework/Decorator/CreatorValidate.d.ts +1 -0
- package/dist/types/Framework/Decorator/JsonAdminValidate.d.ts +1 -0
- package/dist/types/Framework/Decorator/JsonAuthorityValidate.d.ts +2 -0
- package/dist/types/Framework/Decorator/JsonCreatorValidate.d.ts +1 -0
- package/dist/types/Framework/Decorator/SyncCall.d.ts +12 -0
- package/dist/types/Framework/Decorator/SyncCallServer.d.ts +14 -0
- package/dist/types/Framework/index.d.ts +8 -8
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdminValidate = void 0;
|
|
4
|
+
function AdminValidate(target, propertyName, descriptor) {
|
|
5
|
+
let method = descriptor.value;
|
|
6
|
+
descriptor.value = function () {
|
|
7
|
+
let self = this;
|
|
8
|
+
if (!self.isLogin) {
|
|
9
|
+
self.redirect(null, "Login");
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (!self.isAdmin) {
|
|
13
|
+
self.showText("需要管理员权限");
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return method.apply(this, arguments);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.AdminValidate = AdminValidate;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthorityValidate = void 0;
|
|
4
|
+
let AuthorityValidate = function (rg, ctr_name) {
|
|
5
|
+
ctr_name = ctr_name || "Wechat";
|
|
6
|
+
return function (target, propertyName, descriptor) {
|
|
7
|
+
let method = descriptor.value;
|
|
8
|
+
descriptor.value = function () {
|
|
9
|
+
let self = this;
|
|
10
|
+
if (!self.isLogin) {
|
|
11
|
+
self.redirect(null, ctr_name);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (rg && self.selfUser.role_group != rg) {
|
|
15
|
+
self.redirect(null, ctr_name); //权限不足
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
return method.apply(this, arguments);
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.AuthorityValidate = AuthorityValidate;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreatorValidate = void 0;
|
|
4
|
+
function CreatorValidate(target, propertyName, descriptor) {
|
|
5
|
+
let method = descriptor.value;
|
|
6
|
+
descriptor.value = function () {
|
|
7
|
+
let self = this;
|
|
8
|
+
if (!self.isLogin) {
|
|
9
|
+
self.redirect(null, "Login");
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (!self.isCreator) {
|
|
13
|
+
self.showText("需要创始人权限");
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return method.apply(this, arguments);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.CreatorValidate = CreatorValidate;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonAdminValidate = void 0;
|
|
4
|
+
function JsonAdminValidate(target, propertyName, descriptor) {
|
|
5
|
+
let method = descriptor.value;
|
|
6
|
+
descriptor.value = function () {
|
|
7
|
+
let self = this;
|
|
8
|
+
if (!self.isAdmin) {
|
|
9
|
+
self.showJson({ errcode: { id: 1, des: "需要管理员或创始人权限" }, err: "需要管理员或创始人权限" });
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return method.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.JsonAdminValidate = JsonAdminValidate;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonAuthorityValidate = void 0;
|
|
4
|
+
let JsonAuthorityValidate = function (rg) {
|
|
5
|
+
return function (target, propertyName, descriptor) {
|
|
6
|
+
let method = descriptor.value;
|
|
7
|
+
descriptor.value = function () {
|
|
8
|
+
let self = this;
|
|
9
|
+
if (!self.isLogin) {
|
|
10
|
+
self.showJson({ errcode: { id: 1, des: "未登陆" }, err: "未登陆" });
|
|
11
|
+
}
|
|
12
|
+
if (rg && self.selfUser.role_group != rg) {
|
|
13
|
+
self.showJson({ errcode: { id: 2, des: "权限不足" }, err: "权限不足" });
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return method.apply(this, arguments);
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.JsonAuthorityValidate = JsonAuthorityValidate;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonCreatorValidate = void 0;
|
|
4
|
+
function JsonCreatorValidate(target, propertyName, descriptor) {
|
|
5
|
+
let method = descriptor.value;
|
|
6
|
+
descriptor.value = function () {
|
|
7
|
+
let self = this;
|
|
8
|
+
if (!self.isLogin) {
|
|
9
|
+
self.showJson({ errcode: { id: 1, des: "请登陆后尝试" }, err: "请登陆后尝试" });
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (!self.isCreator) {
|
|
13
|
+
self.showJson({ errcode: { id: 1, des: "需要创始人权限" }, err: "需要创始人权限" });
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return method.apply(this, arguments);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.JsonCreatorValidate = JsonCreatorValidate;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SyncCall2 = exports.SyncCall = void 0;
|
|
4
|
+
const SyncQueueTool_1 = require("../Logic/SyncQueueTool");
|
|
5
|
+
/**
|
|
6
|
+
* 异步函数变为同步函数,当前进程有效
|
|
7
|
+
* @param target
|
|
8
|
+
* @param propertyName
|
|
9
|
+
* @param descriptor
|
|
10
|
+
*/
|
|
11
|
+
function SyncCall(target, propertyName, descriptor) {
|
|
12
|
+
let method = descriptor.value;
|
|
13
|
+
descriptor.value = function () {
|
|
14
|
+
let self = this;
|
|
15
|
+
let ret = SyncQueueTool_1.GSyncQueueTool.add(method.name, async () => {
|
|
16
|
+
return await method.apply(self, arguments);
|
|
17
|
+
});
|
|
18
|
+
return ret;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.SyncCall = SyncCall;
|
|
22
|
+
/**
|
|
23
|
+
* 异步函数变为同步函数,当前进程有效
|
|
24
|
+
* @param param_index 动态参数的索引
|
|
25
|
+
*/
|
|
26
|
+
function SyncCall2(param_index) {
|
|
27
|
+
return (target, propertyName, descriptor) => {
|
|
28
|
+
let method = descriptor.value;
|
|
29
|
+
descriptor.value = function () {
|
|
30
|
+
let key = propertyName;
|
|
31
|
+
if (param_index != undefined && param_index < arguments.length) {
|
|
32
|
+
key = propertyName + "_" + arguments[param_index];
|
|
33
|
+
}
|
|
34
|
+
let ret = SyncQueueTool_1.GSyncQueueTool.add(key, async () => {
|
|
35
|
+
return await method.apply(target, arguments);
|
|
36
|
+
});
|
|
37
|
+
return ret;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.SyncCall2 = SyncCall2;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SyncCallServer2 = exports.SyncCallServer = void 0;
|
|
4
|
+
const Core_1 = require("../Core/Core");
|
|
5
|
+
const SyncQueueTool_1 = require("../Logic/SyncQueueTool");
|
|
6
|
+
const MongoCacheService_1 = require("../Service/MongoCacheService");
|
|
7
|
+
/**
|
|
8
|
+
* 异步函数变为同步函数
|
|
9
|
+
* 服务器间的异步,效率低
|
|
10
|
+
* 只支持mongo模式
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
function SyncCallServer(target, propertyName, descriptor) {
|
|
14
|
+
let method = descriptor.value;
|
|
15
|
+
descriptor.value = async () => {
|
|
16
|
+
let key = "sync_" + method.name;
|
|
17
|
+
let func = async () => {
|
|
18
|
+
let item = await MongoCacheService_1.GMongoCacheSer.getData(key);
|
|
19
|
+
let ret = null;
|
|
20
|
+
while (item) {
|
|
21
|
+
await Core_1.core.sleep(200);
|
|
22
|
+
item = await MongoCacheService_1.GMongoCacheSer.getData(key);
|
|
23
|
+
}
|
|
24
|
+
//10秒后过期,避免卡死
|
|
25
|
+
let mcm = await MongoCacheService_1.GMongoCacheSer.addData(key, true, Date.now() + 10 * 1000);
|
|
26
|
+
if (!mcm) {
|
|
27
|
+
await func();
|
|
28
|
+
}
|
|
29
|
+
return;
|
|
30
|
+
};
|
|
31
|
+
await func();
|
|
32
|
+
let ret = SyncQueueTool_1.GSyncQueueTool.add(method.name, async () => {
|
|
33
|
+
return await method.apply(self, arguments);
|
|
34
|
+
});
|
|
35
|
+
await MongoCacheService_1.GMongoCacheSer.deleteOne({ key });
|
|
36
|
+
return ret;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
exports.SyncCallServer = SyncCallServer;
|
|
40
|
+
/**
|
|
41
|
+
* 异步函数变为同步函数
|
|
42
|
+
* 服务器间的异步,效率低
|
|
43
|
+
* 只支持mongo模式
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
let SyncCallServer2 = function (params_index) {
|
|
47
|
+
return function (target, propertyName, descriptor) {
|
|
48
|
+
let method = descriptor.value;
|
|
49
|
+
descriptor.value = async () => {
|
|
50
|
+
let key = "sync_" + method.name;
|
|
51
|
+
if (params_index != undefined && params_index < arguments.length) {
|
|
52
|
+
key = key + "_" + arguments[params_index];
|
|
53
|
+
}
|
|
54
|
+
let func = async () => {
|
|
55
|
+
let item = await MongoCacheService_1.GMongoCacheSer.getData(key);
|
|
56
|
+
let ret = null;
|
|
57
|
+
while (item) {
|
|
58
|
+
await Core_1.core.sleep(200);
|
|
59
|
+
item = await MongoCacheService_1.GMongoCacheSer.getData(key);
|
|
60
|
+
}
|
|
61
|
+
//10秒后过期,避免卡死
|
|
62
|
+
let mcm = await MongoCacheService_1.GMongoCacheSer.addData(key, true, Date.now() + 10 * 1000);
|
|
63
|
+
if (!mcm) {
|
|
64
|
+
await func();
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
};
|
|
68
|
+
await func();
|
|
69
|
+
let ret = SyncQueueTool_1.GSyncQueueTool.add(method.name, async () => {
|
|
70
|
+
return await method.apply(self, arguments);
|
|
71
|
+
});
|
|
72
|
+
await MongoCacheService_1.GMongoCacheSer.deleteOne({ key });
|
|
73
|
+
return ret;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
exports.SyncCallServer2 = SyncCallServer2;
|
|
@@ -11,7 +11,7 @@ const _ = require("underscore");
|
|
|
11
11
|
const MongoBaseService_1 = require("../Database/MongoBaseService");
|
|
12
12
|
const MongoManager_1 = require("../Database/MongoManager");
|
|
13
13
|
const ini_1 = require("./ini");
|
|
14
|
-
const SyncCall_1 = require("../
|
|
14
|
+
const SyncCall_1 = require("../Decorator/SyncCall");
|
|
15
15
|
class MongoUserModel extends MongoManager_1.MongoBaseModel {
|
|
16
16
|
id = -1;
|
|
17
17
|
account_id = -1;
|
|
@@ -141,17 +141,17 @@ var MysqlAccountService_2 = require("./Service/MysqlAccountService");
|
|
|
141
141
|
Object.defineProperty(exports, "MysqlAccountModel", { enumerable: true, get: function () { return MysqlAccountService_2.MysqlAccountModel; } });
|
|
142
142
|
var MongoAccountService_2 = require("./Service/MongoAccountService");
|
|
143
143
|
Object.defineProperty(exports, "MongoAccountModel", { enumerable: true, get: function () { return MongoAccountService_2.MongoAccountModel; } });
|
|
144
|
-
var AdminValidate_1 = require("./
|
|
144
|
+
var AdminValidate_1 = require("./Decorator/AdminValidate");
|
|
145
145
|
Object.defineProperty(exports, "AdminValidate", { enumerable: true, get: function () { return AdminValidate_1.AdminValidate; } });
|
|
146
|
-
var AuthorityValidate_1 = require("./
|
|
146
|
+
var AuthorityValidate_1 = require("./Decorator/AuthorityValidate");
|
|
147
147
|
Object.defineProperty(exports, "AuthorityValidate", { enumerable: true, get: function () { return AuthorityValidate_1.AuthorityValidate; } });
|
|
148
|
-
var CreatorValidate_1 = require("./
|
|
148
|
+
var CreatorValidate_1 = require("./Decorator/CreatorValidate");
|
|
149
149
|
Object.defineProperty(exports, "CreatorValidate", { enumerable: true, get: function () { return CreatorValidate_1.CreatorValidate; } });
|
|
150
|
-
var JsonAdminValidate_1 = require("./
|
|
150
|
+
var JsonAdminValidate_1 = require("./Decorator/JsonAdminValidate");
|
|
151
151
|
Object.defineProperty(exports, "JsonAdminValidate", { enumerable: true, get: function () { return JsonAdminValidate_1.JsonAdminValidate; } });
|
|
152
|
-
var JsonAuthorityValidate_1 = require("./
|
|
152
|
+
var JsonAuthorityValidate_1 = require("./Decorator/JsonAuthorityValidate");
|
|
153
153
|
Object.defineProperty(exports, "JsonAuthorityValidate", { enumerable: true, get: function () { return JsonAuthorityValidate_1.JsonAuthorityValidate; } });
|
|
154
|
-
var JsonCreatorValidate_1 = require("./
|
|
154
|
+
var JsonCreatorValidate_1 = require("./Decorator/JsonCreatorValidate");
|
|
155
155
|
Object.defineProperty(exports, "JsonCreatorValidate", { enumerable: true, get: function () { return JsonCreatorValidate_1.JsonCreatorValidate; } });
|
|
156
156
|
var ControllerManager_1 = require("./WebServer/Engine/ControllerManager");
|
|
157
157
|
Object.defineProperty(exports, "GCtrMgr", { enumerable: true, get: function () { return ControllerManager_1.GCtrMgr; } });
|
|
@@ -183,9 +183,9 @@ var IRpcServerWebSocket_1 = require("./SocketServer/IRpcServerWebSocket");
|
|
|
183
183
|
Object.defineProperty(exports, "IRpcServerWebSocket", { enumerable: true, get: function () { return IRpcServerWebSocket_1.IRpcServerWebSocket; } });
|
|
184
184
|
var IRpcClientWebSocket_1 = require("./SocketServer/IRpcClientWebSocket");
|
|
185
185
|
Object.defineProperty(exports, "IRpcClientWebSocket", { enumerable: true, get: function () { return IRpcClientWebSocket_1.IRpcClientWebSocket; } });
|
|
186
|
-
var SyncCall_1 = require("./
|
|
186
|
+
var SyncCall_1 = require("./Decorator/SyncCall");
|
|
187
187
|
Object.defineProperty(exports, "SyncCall", { enumerable: true, get: function () { return SyncCall_1.SyncCall; } });
|
|
188
188
|
Object.defineProperty(exports, "SyncCall2", { enumerable: true, get: function () { return SyncCall_1.SyncCall2; } });
|
|
189
|
-
var SyncCallServer_1 = require("./
|
|
189
|
+
var SyncCallServer_1 = require("./Decorator/SyncCallServer");
|
|
190
190
|
Object.defineProperty(exports, "SyncCallServer", { enumerable: true, get: function () { return SyncCallServer_1.SyncCallServer; } });
|
|
191
191
|
Object.defineProperty(exports, "SyncCallServer2", { enumerable: true, get: function () { return SyncCallServer_1.SyncCallServer2; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AdminValidate(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function CreatorValidate(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function JsonAdminValidate(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function JsonCreatorValidate(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 异步函数变为同步函数,当前进程有效
|
|
3
|
+
* @param target
|
|
4
|
+
* @param propertyName
|
|
5
|
+
* @param descriptor
|
|
6
|
+
*/
|
|
7
|
+
export declare function SyncCall(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>): void;
|
|
8
|
+
/**
|
|
9
|
+
* 异步函数变为同步函数,当前进程有效
|
|
10
|
+
* @param param_index 动态参数的索引
|
|
11
|
+
*/
|
|
12
|
+
export declare function SyncCall2(param_index?: number): (target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 异步函数变为同步函数
|
|
3
|
+
* 服务器间的异步,效率低
|
|
4
|
+
* 只支持mongo模式
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare function SyncCallServer(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>): void;
|
|
8
|
+
/**
|
|
9
|
+
* 异步函数变为同步函数
|
|
10
|
+
* 服务器间的异步,效率低
|
|
11
|
+
* 只支持mongo模式
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare let SyncCallServer2: (params_index?: number) => (target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>) => void;
|
|
@@ -62,12 +62,12 @@ export { MysqlBaseUserController } from './WebServer/Controller/MysqlBaseUserCon
|
|
|
62
62
|
export { MongoBaseUserController } from './WebServer/Controller/MongoBaseUserController';
|
|
63
63
|
export { MysqlAccountModel } from './Service/MysqlAccountService';
|
|
64
64
|
export { MongoAccountModel } from './Service/MongoAccountService';
|
|
65
|
-
export { AdminValidate } from './
|
|
66
|
-
export { AuthorityValidate } from './
|
|
67
|
-
export { CreatorValidate } from './
|
|
68
|
-
export { JsonAdminValidate } from './
|
|
69
|
-
export { JsonAuthorityValidate } from './
|
|
70
|
-
export { JsonCreatorValidate } from './
|
|
65
|
+
export { AdminValidate } from './Decorator/AdminValidate';
|
|
66
|
+
export { AuthorityValidate } from './Decorator/AuthorityValidate';
|
|
67
|
+
export { CreatorValidate } from './Decorator/CreatorValidate';
|
|
68
|
+
export { JsonAdminValidate } from './Decorator/JsonAdminValidate';
|
|
69
|
+
export { JsonAuthorityValidate } from './Decorator/JsonAuthorityValidate';
|
|
70
|
+
export { JsonCreatorValidate } from './Decorator/JsonCreatorValidate';
|
|
71
71
|
export { GCtrMgr } from './WebServer/Engine/ControllerManager';
|
|
72
72
|
export { Engine } from './WebServer/Engine/Engine';
|
|
73
73
|
export { RazorJs } from './WebServer/Engine/RazorJs';
|
|
@@ -82,5 +82,5 @@ export { Rpc, RpcConfig } from './ThirdParty/Rpc';
|
|
|
82
82
|
export { CgMq, CgMqConfig } from './ThirdParty/CgMq';
|
|
83
83
|
export { IRpcServerWebSocket } from './SocketServer/IRpcServerWebSocket';
|
|
84
84
|
export { IRpcClientWebSocket } from './SocketServer/IRpcClientWebSocket';
|
|
85
|
-
export { SyncCall, SyncCall2 } from './
|
|
86
|
-
export { SyncCallServer, SyncCallServer2 } from './
|
|
85
|
+
export { SyncCall, SyncCall2 } from './Decorator/SyncCall';
|
|
86
|
+
export { SyncCallServer, SyncCallServer2 } from './Decorator/SyncCallServer';
|