cgserver 8.3.2546 → 8.5.0
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/README.md +3 -23
- package/dist/lib/Framework/Database/RedisManager.js +12 -367
- 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 +4 -7
- package/dist/lib/Framework/Service/MysqlUserService.js +1 -14
- package/dist/lib/Framework/WebServer/Decorator/SyncCall.js +21 -1
- package/dist/lib/Framework/WebServer/Decorator/SyncCallServer.js +39 -3
- package/dist/lib/Framework/index.js +12 -9
- package/dist/types/Framework/Database/MongoBaseService.d.ts +2 -2
- package/dist/types/Framework/Database/MongoManager.d.ts +2 -2
- package/dist/types/Framework/Database/RedisManager.d.ts +7 -54
- 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/Service/MongoUserService.d.ts +1 -2
- package/dist/types/Framework/Service/MysqlUserService.d.ts +0 -3
- package/dist/types/Framework/WebServer/Decorator/SyncCall.d.ts +5 -0
- package/dist/types/Framework/WebServer/Decorator/SyncCallServer.d.ts +8 -1
- package/dist/types/Framework/index.d.ts +8 -8
- package/package.json +28 -28
- package/debug.log +0 -8
- package/dist/lib/Framework/Service/AccountService.js +0 -473
- package/dist/lib/Framework/Service/UserService.js +0 -184
- package/dist/lib/Framework/WebServer/Controller/BaseUserController.js +0 -169
- package/dist/types/Framework/Service/AccountService.d.ts +0 -77
- package/dist/types/Framework/Service/UserService.d.ts +0 -36
- package/dist/types/Framework/WebServer/Controller/BaseUserController.d.ts +0 -27
package/README.md
CHANGED
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
1
|
|
3
|
-
2
|
|
4
|
-
6.6.5
|
|
5
|
-
1、mongomanager可单独初始化
|
|
6
|
-
6.6.5
|
|
7
|
-
1、mongoaccountservice增加登录时间和ip
|
|
8
|
-
6.5.8
|
|
9
|
-
1、修改编译bug
|
|
10
|
-
6.5.7
|
|
11
|
-
1、debug标志又cgserver处命令行处理,默认为false
|
|
12
|
-
6.5.7
|
|
13
|
-
1、增加配置debug,是否是debug调试模式,主要区别于读取数据档,debug默认读取file_d文件,release默认读取file_r文件,如果不存在都会读取file文件
|
|
14
|
-
6.5.6
|
|
15
|
-
1、增加一点服务器事件,目前cgserver只支持start
|
|
16
|
-
6.5.5
|
|
17
|
-
1、修改GLog的输出,控制台的输出由FrameworkConfig控制,console_level(默认0) -1都不输出,0仅输出error,1都输出
|
|
18
|
-
6.5.3
|
|
19
|
-
1、增加账号状态EAccountState
|
|
20
|
-
6.5.3
|
|
21
|
-
1、事件分发器GEventTool添加emit
|
|
22
|
-
6.5.2
|
|
23
|
-
1、添加事件分发器GEventTool
|
|
1
|
+
8.4.1
|
|
2
|
+
1、更新所有库到最新版
|
|
3
|
+
2、暴力升级redis接口注意修改
|
|
@@ -9,12 +9,9 @@ class RedisManager {
|
|
|
9
9
|
get redis() {
|
|
10
10
|
return this._redis;
|
|
11
11
|
}
|
|
12
|
-
_resis_init_succ = false;
|
|
13
12
|
_redisCfg = null;
|
|
14
|
-
constructor() {
|
|
15
|
-
}
|
|
16
13
|
async init(redisCfg) {
|
|
17
|
-
|
|
14
|
+
let p = new Promise((resolve) => {
|
|
18
15
|
if (!redisCfg || !redisCfg.open) {
|
|
19
16
|
resolve(null);
|
|
20
17
|
return;
|
|
@@ -24,8 +21,8 @@ class RedisManager {
|
|
|
24
21
|
return;
|
|
25
22
|
}
|
|
26
23
|
this._redisCfg = redisCfg;
|
|
27
|
-
Log_1.GLog.info("begin
|
|
28
|
-
this._redis = redis.createClient(redisCfg
|
|
24
|
+
Log_1.GLog.info("begin connect redis=" + JSON.stringify(redisCfg));
|
|
25
|
+
this._redis = redis.createClient(redisCfg);
|
|
29
26
|
this._redis.on("connect", () => {
|
|
30
27
|
this.onConnect();
|
|
31
28
|
resolve(null);
|
|
@@ -33,376 +30,24 @@ class RedisManager {
|
|
|
33
30
|
this._redis.on("end", this.onEnd.bind(this));
|
|
34
31
|
this._redis.on("error", this.onError.bind(this));
|
|
35
32
|
});
|
|
33
|
+
let ret = await p;
|
|
34
|
+
for (let key in this._redis) {
|
|
35
|
+
if (typeof this._redis[key] == "function") {
|
|
36
|
+
this[key] = this._redis[key].bind(this._redis);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return ret;
|
|
36
40
|
}
|
|
37
41
|
onConnect() {
|
|
38
|
-
if (this._redisCfg.database) {
|
|
39
|
-
this._redis.select(this._redisCfg.database);
|
|
40
|
-
}
|
|
41
|
-
this._resis_init_succ = true;
|
|
42
42
|
Log_1.GLog.info("redis has connected!");
|
|
43
43
|
}
|
|
44
44
|
onEnd() {
|
|
45
|
-
this._resis_init_succ = false;
|
|
46
45
|
this._redis = null;
|
|
47
46
|
this.init(this._redisCfg); //重连
|
|
48
47
|
}
|
|
49
48
|
onError(err) {
|
|
50
|
-
Log_1.GLog.info("Error connected=" + this._redis
|
|
51
|
-
}
|
|
52
|
-
expire(key, seconds) {
|
|
53
|
-
return new Promise((resolve, reject) => {
|
|
54
|
-
if (!this._redis) {
|
|
55
|
-
resolve(null);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
this._redis.expire(key, seconds, (err, reply) => {
|
|
59
|
-
if (err) {
|
|
60
|
-
Log_1.GLog.error(err);
|
|
61
|
-
}
|
|
62
|
-
resolve(reply);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
incr(key) {
|
|
67
|
-
return new Promise((resolve, reject) => {
|
|
68
|
-
if (!this._redis) {
|
|
69
|
-
resolve(null);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
this._redis.incr(key, (err, reply) => {
|
|
73
|
-
if (err) {
|
|
74
|
-
Log_1.GLog.error(err);
|
|
75
|
-
}
|
|
76
|
-
resolve(reply);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
set(key, value) {
|
|
81
|
-
return new Promise((resolve, reject) => {
|
|
82
|
-
if (!this._redis) {
|
|
83
|
-
resolve(null);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
this._redis.set(key, value, (err, reply) => {
|
|
87
|
-
if (err) {
|
|
88
|
-
Log_1.GLog.error(err);
|
|
89
|
-
}
|
|
90
|
-
resolve(reply);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
get(key) {
|
|
95
|
-
return new Promise((resolve, reject) => {
|
|
96
|
-
if (!this._redis) {
|
|
97
|
-
resolve(null);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
this._redis.get(key, (err, reply) => {
|
|
101
|
-
if (err) {
|
|
102
|
-
Log_1.GLog.error(err);
|
|
103
|
-
}
|
|
104
|
-
resolve(reply);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
*
|
|
110
|
-
* @param key
|
|
111
|
-
* @param cb 有表示异步
|
|
112
|
-
*/
|
|
113
|
-
del(key, cb) {
|
|
114
|
-
return new Promise((resolve, reject) => {
|
|
115
|
-
if (!this._redis) {
|
|
116
|
-
resolve(null);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
this._redis.del(key, (err, reply) => {
|
|
120
|
-
if (err) {
|
|
121
|
-
Log_1.GLog.error(err);
|
|
122
|
-
}
|
|
123
|
-
resolve(reply);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
hset(h, key, value) {
|
|
128
|
-
return new Promise((resolve, reject) => {
|
|
129
|
-
if (!this._redis) {
|
|
130
|
-
resolve(null);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
this._redis.hset(h, key, value, (err, reply) => {
|
|
134
|
-
if (err) {
|
|
135
|
-
Log_1.GLog.error(err);
|
|
136
|
-
}
|
|
137
|
-
resolve(reply);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
hget(h, key) {
|
|
142
|
-
return new Promise((resolve, reject) => {
|
|
143
|
-
if (!this._redis) {
|
|
144
|
-
resolve(null);
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
this._redis.hget(h, key, (err, reply) => {
|
|
148
|
-
if (err) {
|
|
149
|
-
Log_1.GLog.error(err);
|
|
150
|
-
}
|
|
151
|
-
resolve(reply);
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
hdel(key, sub_key) {
|
|
156
|
-
return new Promise((resolve, reject) => {
|
|
157
|
-
if (!this._redis) {
|
|
158
|
-
resolve(null);
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
this._redis.hdel(key, sub_key, (err, reply) => {
|
|
162
|
-
if (err) {
|
|
163
|
-
Log_1.GLog.error(err);
|
|
164
|
-
}
|
|
165
|
-
resolve(reply);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* hash值,能转换位整数的就自动转换为整数
|
|
171
|
-
* @param h key
|
|
172
|
-
*/
|
|
173
|
-
hgetall(h) {
|
|
174
|
-
return new Promise((resolve, reject) => {
|
|
175
|
-
if (!this._redis) {
|
|
176
|
-
resolve(null);
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
this._redis.hgetall(h, (err, replys) => {
|
|
180
|
-
if (err) {
|
|
181
|
-
Log_1.GLog.error(err);
|
|
182
|
-
resolve(replys);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
let value = {};
|
|
186
|
-
for (let k in replys) {
|
|
187
|
-
let v = replys[k];
|
|
188
|
-
let iv = parseInt(v);
|
|
189
|
-
if (v == "" + iv) {
|
|
190
|
-
value[k] = iv;
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
value[k] = v;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
if (!replys) {
|
|
197
|
-
value = null;
|
|
198
|
-
}
|
|
199
|
-
resolve(value);
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
*
|
|
205
|
-
* @param h
|
|
206
|
-
* @param array
|
|
207
|
-
*/
|
|
208
|
-
hmset(h, array) {
|
|
209
|
-
return new Promise((resolve, reject) => {
|
|
210
|
-
if (!this._redis) {
|
|
211
|
-
resolve(null);
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
this._redis.hmset(h, array, (err, replys) => {
|
|
215
|
-
if (err) {
|
|
216
|
-
Log_1.GLog.error(err);
|
|
217
|
-
}
|
|
218
|
-
resolve(replys);
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
lpush(key, array) {
|
|
223
|
-
return new Promise((resolve, reject) => {
|
|
224
|
-
if (!this._redis) {
|
|
225
|
-
resolve(null);
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
this._redis.lpush(key, array, (err, replys) => {
|
|
229
|
-
if (err) {
|
|
230
|
-
Log_1.GLog.error(err);
|
|
231
|
-
}
|
|
232
|
-
resolve(replys);
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
lrange(key, start, end) {
|
|
237
|
-
return new Promise((resolve, reject) => {
|
|
238
|
-
if (!this._redis) {
|
|
239
|
-
resolve(null);
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
if (!this._redis) {
|
|
243
|
-
return null;
|
|
244
|
-
}
|
|
245
|
-
if (!start) {
|
|
246
|
-
start = 0;
|
|
247
|
-
}
|
|
248
|
-
if (!end) {
|
|
249
|
-
end = -1;
|
|
250
|
-
}
|
|
251
|
-
this._redis.lrange(key, start, end, (err, replys) => {
|
|
252
|
-
if (err) {
|
|
253
|
-
Log_1.GLog.error(err);
|
|
254
|
-
}
|
|
255
|
-
resolve(replys);
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
ltrim(key, start, end) {
|
|
260
|
-
return new Promise((resolve, reject) => {
|
|
261
|
-
if (!this._redis) {
|
|
262
|
-
resolve(null);
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
if (!this._redis) {
|
|
266
|
-
return null;
|
|
267
|
-
}
|
|
268
|
-
if (!start) {
|
|
269
|
-
start = 0;
|
|
270
|
-
}
|
|
271
|
-
if (!end) {
|
|
272
|
-
end = -1;
|
|
273
|
-
}
|
|
274
|
-
this._redis.ltrim(key, start, end, (err, replys) => {
|
|
275
|
-
if (err) {
|
|
276
|
-
Log_1.GLog.error(err);
|
|
277
|
-
}
|
|
278
|
-
resolve(replys);
|
|
279
|
-
});
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
sadd(key, array) {
|
|
283
|
-
return new Promise((resolve, reject) => {
|
|
284
|
-
if (!this._redis) {
|
|
285
|
-
resolve(null);
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
this._redis.sadd(key, array, (err, replys) => {
|
|
289
|
-
if (err) {
|
|
290
|
-
Log_1.GLog.error(err);
|
|
291
|
-
}
|
|
292
|
-
resolve(replys);
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
smembers(key) {
|
|
297
|
-
return new Promise((resolve, reject) => {
|
|
298
|
-
if (!this._redis) {
|
|
299
|
-
resolve(null);
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
this._redis.smembers(key, (err, replys) => {
|
|
303
|
-
if (err) {
|
|
304
|
-
Log_1.GLog.error(err);
|
|
305
|
-
}
|
|
306
|
-
resolve(replys);
|
|
307
|
-
});
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
srem(key, array) {
|
|
311
|
-
return new Promise((resolve, reject) => {
|
|
312
|
-
if (!this._redis) {
|
|
313
|
-
resolve(null);
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
this._redis.srem(key, array, (err, replys) => {
|
|
317
|
-
if (err) {
|
|
318
|
-
Log_1.GLog.error(err);
|
|
319
|
-
}
|
|
320
|
-
resolve(replys);
|
|
321
|
-
});
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
keys(key) {
|
|
325
|
-
return new Promise((resolve, reject) => {
|
|
326
|
-
if (!this._redis) {
|
|
327
|
-
resolve(null);
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
this._redis.keys(key, (err, replys) => {
|
|
331
|
-
if (err) {
|
|
332
|
-
Log_1.GLog.error(err);
|
|
333
|
-
}
|
|
334
|
-
resolve(replys);
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
multi() {
|
|
339
|
-
if (!this._redis) {
|
|
340
|
-
return null;
|
|
341
|
-
}
|
|
342
|
-
return this._redis.multi();
|
|
343
|
-
}
|
|
344
|
-
exists(key) {
|
|
345
|
-
return new Promise((resolve, reject) => {
|
|
346
|
-
if (!this._redis) {
|
|
347
|
-
resolve(null);
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
this._redis.exists(key, (err, replys) => {
|
|
351
|
-
if (err) {
|
|
352
|
-
Log_1.GLog.error(err);
|
|
353
|
-
}
|
|
354
|
-
resolve(replys);
|
|
355
|
-
});
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
exec(multi) {
|
|
359
|
-
return new Promise((resolve, reject) => {
|
|
360
|
-
if (!this._redis || !multi) {
|
|
361
|
-
resolve(null);
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
multi.exec((err, replys) => {
|
|
365
|
-
if (err) {
|
|
366
|
-
Log_1.GLog.error(err);
|
|
367
|
-
}
|
|
368
|
-
resolve(replys);
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
publish(channel, value) {
|
|
373
|
-
return new Promise((resolve, reject) => {
|
|
374
|
-
if (!this._redis) {
|
|
375
|
-
resolve(null);
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
this._redis.publish(channel, value, (err, num) => {
|
|
379
|
-
if (err) {
|
|
380
|
-
Log_1.GLog.error(err);
|
|
381
|
-
}
|
|
382
|
-
resolve(num);
|
|
383
|
-
});
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
subscribe(channel) {
|
|
387
|
-
return new Promise((resolve, reject) => {
|
|
388
|
-
if (!this._redis) {
|
|
389
|
-
resolve(null);
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
this._redis.subscribe(channel, (err, msg) => {
|
|
393
|
-
if (err) {
|
|
394
|
-
Log_1.GLog.error(err);
|
|
395
|
-
}
|
|
396
|
-
resolve(msg);
|
|
397
|
-
});
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
on(message, cb) {
|
|
401
|
-
if (!this._redis) {
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
this._redis.on(message, cb);
|
|
49
|
+
Log_1.GLog.info("Error connected=" + this._redis + ": " + err);
|
|
405
50
|
}
|
|
406
51
|
}
|
|
407
52
|
exports.RedisManager = RedisManager;
|
|
408
|
-
exports.GRedisMgr = new RedisManager();
|
|
53
|
+
exports.GRedisMgr = (new RedisManager());
|
|
@@ -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;
|