midway-fatcms 0.0.1-beta.74 → 0.0.1-beta.75
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.
|
@@ -8,8 +8,7 @@ declare class AnonymousContext {
|
|
|
8
8
|
private app;
|
|
9
9
|
setApp(app: koa.Application): void;
|
|
10
10
|
getApp(): koa.IMidwayKoaApplication;
|
|
11
|
-
|
|
12
|
-
createAnonymousContext(): koa.IMidwayKoaContext;
|
|
11
|
+
private createAnonymousContext;
|
|
13
12
|
runServiceAtAnonymousContext(runner: RunServiceAtAnonymousContextRunner): Promise<RunServiceAtAnonymousContextRes>;
|
|
14
13
|
}
|
|
15
14
|
declare const ANONYMOUS_CONTEXT: AnonymousContext;
|
|
@@ -36,10 +36,11 @@ class AnonymousContext {
|
|
|
36
36
|
getApp() {
|
|
37
37
|
return this.app;
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
//
|
|
40
|
+
// async getAsyncService(identifier: any): Promise<any> {
|
|
41
|
+
// const ctx: koa.IMidwayKoaContext = this.createAnonymousContext();
|
|
42
|
+
// return ctx.requestContext.getAsync(identifier);
|
|
43
|
+
// }
|
|
43
44
|
createAnonymousContext() {
|
|
44
45
|
const app = this.app;
|
|
45
46
|
const ctx = app.createAnonymousContext();
|
|
@@ -87,8 +87,11 @@ let CurdMixByLinkToCustomService = CurdMixByLinkToCustomService_1 = class CurdMi
|
|
|
87
87
|
cacheName: bizmodels_1.CacheNameEnum.CurdMixByLinkToCustom,
|
|
88
88
|
scheduleRefresh: true,
|
|
89
89
|
getter: async () => {
|
|
90
|
-
const
|
|
91
|
-
|
|
90
|
+
const { result } = await schedule_1.ANONYMOUS_CONTEXT.runServiceAtAnonymousContext(async (ctx) => {
|
|
91
|
+
const service = await ctx.requestContext.getAsync(CurdMixByLinkToCustomService_1);
|
|
92
|
+
return await service.queryInfoByLinkToCustomImpl(code);
|
|
93
|
+
});
|
|
94
|
+
return result;
|
|
92
95
|
},
|
|
93
96
|
});
|
|
94
97
|
}
|
package/package.json
CHANGED
|
@@ -49,13 +49,13 @@ class AnonymousContext {
|
|
|
49
49
|
return this.app;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
//
|
|
53
|
+
// async getAsyncService(identifier: any): Promise<any> {
|
|
54
|
+
// const ctx: koa.IMidwayKoaContext = this.createAnonymousContext();
|
|
55
|
+
// return ctx.requestContext.getAsync(identifier);
|
|
56
|
+
// }
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
const ctx: koa.IMidwayKoaContext = this.createAnonymousContext();
|
|
55
|
-
return ctx.requestContext.getAsync(identifier);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
createAnonymousContext() {
|
|
58
|
+
private createAnonymousContext() {
|
|
59
59
|
const app = this.app;
|
|
60
60
|
const ctx: koa.IMidwayKoaContext = app.createAnonymousContext();
|
|
61
61
|
ctx.app = app;
|
|
@@ -94,14 +94,18 @@ export class CurdMixByLinkToCustomService implements IExecuteContextHandler {
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
|
|
97
98
|
public async queryInfoByLinkToCustom(code: string): Promise<Map<string, any>> {
|
|
98
99
|
return this.cacheServiceFactory.getJsonObjectCache({
|
|
99
100
|
cacheKey: md5(code),
|
|
100
101
|
cacheName: CacheNameEnum.CurdMixByLinkToCustom,
|
|
101
102
|
scheduleRefresh: true,
|
|
102
103
|
getter: async () => {
|
|
103
|
-
const
|
|
104
|
-
|
|
104
|
+
const { result } = await ANONYMOUS_CONTEXT.runServiceAtAnonymousContext(async (ctx: Context) => {
|
|
105
|
+
const service: CurdMixByLinkToCustomService = await ctx.requestContext.getAsync(CurdMixByLinkToCustomService);
|
|
106
|
+
return await service.queryInfoByLinkToCustomImpl(code);
|
|
107
|
+
});
|
|
108
|
+
return result;
|
|
105
109
|
},
|
|
106
110
|
});
|
|
107
111
|
}
|