midway-fatcms 0.0.1-beta.66 → 0.0.1-beta.68
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/config/config.default.js +4 -1
- package/dist/controller/gateway/PublicApiController.js +3 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +4 -4
- package/dist/models/SystemEntities.d.ts +0 -22
- package/dist/models/SystemEntities.js +1 -14
- package/dist/models/bizmodels.d.ts +20 -2
- package/dist/models/bizmodels.js +15 -1
- package/dist/service/EnumInfoService.js +3 -9
- package/dist/service/UserSessionService.js +4 -7
- package/dist/service/base/cache/CacheServiceFactory.d.ts +3 -5
- package/dist/service/base/cache/CacheServiceFactory.js +31 -20
- package/dist/service/base/cache/{FatcmsBaseCtxCache.d.ts → CtxCache.d.ts} +4 -5
- package/dist/service/base/cache/{FatcmsBaseCtxCache.js → CtxCache.js} +4 -5
- package/dist/service/base/cache/DiskCache.d.ts +19 -0
- package/dist/service/base/cache/{FatcmsBaseDiskCache.js → DiskCache.js} +10 -17
- package/dist/service/base/cache/MemoryCache.d.ts +12 -0
- package/dist/service/base/cache/{FatcmsBaseMemoryCache.js → MemoryCache.js} +9 -17
- package/dist/service/base/cache/{FatcmsBaseNoneCache.d.ts → NoneCache.d.ts} +2 -2
- package/dist/service/base/cache/{FatcmsBaseNoneCache.js → NoneCache.js} +3 -3
- package/dist/service/base/cache/{FatcmsBaseRedisCache.d.ts → RedisCache.d.ts} +5 -11
- package/dist/service/base/cache/{FatcmsBaseRedisCache.js → RedisCache.js} +9 -17
- package/dist/service/crudstd/CrudStdService.js +3 -11
- package/dist/service/curd/CurdMixByAccountService.d.ts +4 -0
- package/dist/service/curd/CurdMixByAccountService.js +50 -12
- package/dist/service/curd/CurdMixByDictService.js +4 -8
- package/dist/service/curd/CurdMixByLinkToCustomService.js +2 -7
- package/dist/service/curd/CurdMixBySysConfigService.js +4 -8
- package/dist/service/curd/CurdMixByWorkbenchService.js +3 -9
- package/package.json +1 -1
- package/src/config/config.default.ts +4 -1
- package/src/controller/gateway/PublicApiController.ts +2 -14
- package/src/index.ts +1 -1
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +7 -5
- package/src/models/SystemEntities.ts +1 -30
- package/src/models/WorkbenchInfoTools.ts +3 -2
- package/src/models/bizmodels.ts +26 -4
- package/src/service/EnumInfoService.ts +12 -18
- package/src/service/UserSessionService.ts +14 -19
- package/src/service/base/cache/CacheServiceFactory.ts +51 -42
- package/src/service/base/cache/{FatcmsBaseCtxCache.ts → CtxCache.ts} +4 -6
- package/src/service/base/cache/{FatcmsBaseDiskCache.ts → DiskCache.ts} +18 -23
- package/src/service/base/cache/{FatcmsBaseMemoryCache.ts → MemoryCache.ts} +10 -16
- package/src/service/base/cache/{FatcmsBaseNoneCache.ts → NoneCache.ts} +3 -3
- package/src/service/base/cache/{FatcmsBaseRedisCache.ts → RedisCache.ts} +11 -18
- package/src/service/crudstd/CrudStdService.ts +19 -31
- package/src/service/curd/CurdMixByAccountService.ts +62 -14
- package/src/service/curd/CurdMixByDictService.ts +6 -11
- package/src/service/curd/CurdMixByLinkToCustomService.ts +1 -8
- package/src/service/curd/CurdMixBySysConfigService.ts +8 -15
- package/src/service/curd/CurdMixByWorkbenchService.ts +3 -10
- package/dist/service/base/cache/FatcmsBaseDiskCache.d.ts +0 -24
- package/dist/service/base/cache/FatcmsBaseMemoryCache.d.ts +0 -18
|
@@ -11,7 +11,7 @@ import { Exceptions } from '@/libs/crud-pro/exceptions';
|
|
|
11
11
|
import { parseDatabaseName } from '@/libs/crud-pro/utils/DatabaseName';
|
|
12
12
|
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
13
13
|
import { IRequestCfgModel2 } from '@/models/bizmodels';
|
|
14
|
-
import {
|
|
14
|
+
import { CacheNameEnum} from "@/models/bizmodels";
|
|
15
15
|
import { CacheServiceFactory } from '../base/cache/CacheServiceFactory';
|
|
16
16
|
import * as md5 from 'md5';
|
|
17
17
|
|
|
@@ -19,10 +19,6 @@ const linkToCustomMixUtils = new CrudMixUtils(RelatedType.linkToCustom);
|
|
|
19
19
|
const TMP_CTX_KEY = _.uniqueId('CurdMixByLinkToCustomService');
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
const DEFAULT_CACHE_LEVEL = CacheLevelEnum.MEMORY;
|
|
23
|
-
const DEFAULT_CACHE_SECOND = 60 * 5;
|
|
24
|
-
|
|
25
|
-
|
|
26
22
|
function toMapObject(rows: any[], fieldsArr: string[]): Map<string, any> {
|
|
27
23
|
const valueKey = fieldsArr[0];
|
|
28
24
|
const labelKey = fieldsArr[1];
|
|
@@ -98,11 +94,8 @@ export class CurdMixByLinkToCustomService implements IExecuteContextHandler {
|
|
|
98
94
|
}
|
|
99
95
|
|
|
100
96
|
public async queryInfoByLinkToCustom(code: string): Promise<Map<string, any>> {
|
|
101
|
-
const { curdMixByCommonCacheLevel, curdMixByCommonCacheSecond } = this.ctx.workbenchInfoTools.getWorkbenchConfig();
|
|
102
97
|
return this.cacheServiceFactory.getJsonObjectCache({
|
|
103
|
-
cacheLevel: curdMixByCommonCacheLevel || DEFAULT_CACHE_LEVEL,
|
|
104
98
|
cacheKey: md5(code),
|
|
105
|
-
cacheSecond: curdMixByCommonCacheSecond || DEFAULT_CACHE_SECOND,
|
|
106
99
|
cacheName: CacheNameEnum.CurdMixByLinkToCustom,
|
|
107
100
|
getter: async () => {
|
|
108
101
|
return await this.queryInfoByLinkToCustomImpl(code);
|
|
@@ -11,17 +11,12 @@ import { ColumnRelation } from '@/libs/crud-pro/interfaces';
|
|
|
11
11
|
import { parseConfigContentToEnumInfo } from '@/libs/utils/parseConfig';
|
|
12
12
|
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
13
13
|
import { CacheServiceFactory } from '../base/cache/CacheServiceFactory';
|
|
14
|
-
import {
|
|
14
|
+
import { CacheNameEnum} from "@/models/bizmodels";
|
|
15
15
|
|
|
16
16
|
const dictMixUtils = new CrudMixUtils(RelatedType.sysCfgEnum);
|
|
17
17
|
|
|
18
18
|
const TMP_CTX_KEY = _.uniqueId('CurdMixBySysConfigService');
|
|
19
19
|
|
|
20
|
-
const DEFAULT_CACHE_LEVEL = CacheLevelEnum.MEMORY;
|
|
21
|
-
const DEFAULT_CACHE_SECOND = 60 * 5;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
20
|
|
|
26
21
|
@Provide()
|
|
27
22
|
export class CurdMixBySysConfigService implements IExecuteContextHandler {
|
|
@@ -35,15 +30,13 @@ export class CurdMixBySysConfigService implements IExecuteContextHandler {
|
|
|
35
30
|
|
|
36
31
|
|
|
37
32
|
private async getFromCache(code: string): Promise<any> {
|
|
38
|
-
const
|
|
39
|
-
const cacheService = this.cacheServiceFactory.getCacheService(curdMixByCommonCacheLevel || DEFAULT_CACHE_LEVEL, CacheNameEnum.CurdMixBySysConfig);
|
|
33
|
+
const cacheService = this.cacheServiceFactory.getCacheServiceByName(CacheNameEnum.CurdMixBySysConfig);
|
|
40
34
|
return cacheService.getJsonObject(code);
|
|
41
35
|
}
|
|
42
36
|
|
|
43
37
|
private async setToCache(code: string, value: any): Promise<any> {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
return cacheService.setJsonObject(code, value, curdMixByCommonCacheSecond || DEFAULT_CACHE_SECOND);
|
|
38
|
+
const cacheService = this.cacheServiceFactory.getCacheServiceByName(CacheNameEnum.CurdMixBySysConfig);
|
|
39
|
+
return cacheService.setJsonObject(code, value);
|
|
47
40
|
}
|
|
48
41
|
|
|
49
42
|
|
|
@@ -63,10 +56,10 @@ export class CurdMixBySysConfigService implements IExecuteContextHandler {
|
|
|
63
56
|
return Object.values(resultRowMap);
|
|
64
57
|
}
|
|
65
58
|
|
|
66
|
-
const {
|
|
59
|
+
const {SystemDbName, SystemDbType} = GLOBAL_STATIC_CONFIG.getConfig();
|
|
67
60
|
const res1 = await this.curdProService.executeCrudByCfg(
|
|
68
61
|
{
|
|
69
|
-
condition: {
|
|
62
|
+
condition: {config_code: {$in: notCachedCodes}},
|
|
70
63
|
},
|
|
71
64
|
{
|
|
72
65
|
sqlTable: SystemTables.sys_configs,
|
|
@@ -79,12 +72,12 @@ export class CurdMixBySysConfigService implements IExecuteContextHandler {
|
|
|
79
72
|
if (Array.isArray(rows) && rows.length > 0) {
|
|
80
73
|
for (let i = 0; i < rows.length; i++) {
|
|
81
74
|
const row = rows[i];
|
|
82
|
-
const {
|
|
75
|
+
const {config_code} = row;
|
|
83
76
|
await this.setToCache(config_code, row);
|
|
84
77
|
resultRowMap[config_code] = row;
|
|
85
78
|
}
|
|
86
79
|
}
|
|
87
|
-
return Object.values(resultRowMap)
|
|
80
|
+
return Object.values(resultRowMap)
|
|
88
81
|
}
|
|
89
82
|
|
|
90
83
|
async handleExecuteContextPrepare(executeContext: HandleExecuteContextType) {
|
|
@@ -10,14 +10,12 @@ import { ColumnRelation } from '@/libs/crud-pro/interfaces';
|
|
|
10
10
|
import { MixinUtils } from '@/libs/crud-pro/utils/MixinUtils';
|
|
11
11
|
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
12
12
|
import { CacheServiceFactory } from '../base/cache/CacheServiceFactory';
|
|
13
|
-
import {
|
|
13
|
+
import { CacheNameEnum} from "@/models/bizmodels";
|
|
14
14
|
|
|
15
15
|
const workbenchMixUtils = new CrudMixUtils(RelatedType.workbenchBasic);
|
|
16
16
|
|
|
17
17
|
const TMP_CTX_KEY = _.uniqueId('CurdMixByWorkbenchService');
|
|
18
18
|
|
|
19
|
-
const DEFAULT_CACHE_LEVEL = CacheLevelEnum.MEMORY;
|
|
20
|
-
const DEFAULT_CACHE_SECOND = 60 * 5;
|
|
21
19
|
|
|
22
20
|
@Provide()
|
|
23
21
|
export class CurdMixByWorkbenchService implements IExecuteContextHandler {
|
|
@@ -30,13 +28,9 @@ export class CurdMixByWorkbenchService implements IExecuteContextHandler {
|
|
|
30
28
|
@Inject()
|
|
31
29
|
private cacheServiceFactory: CacheServiceFactory;
|
|
32
30
|
|
|
33
|
-
private async loadWorkbenchListMap() {
|
|
31
|
+
private async loadWorkbenchListMap(): Promise<Map<string, any>> {
|
|
34
32
|
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const workbenchListMap = await this.cacheServiceFactory.getJsonObjectCache({
|
|
38
|
-
cacheLevel: curdMixByCommonCacheLevel || DEFAULT_CACHE_LEVEL,
|
|
39
|
-
cacheSecond: curdMixByCommonCacheSecond || DEFAULT_CACHE_SECOND,
|
|
33
|
+
return await this.cacheServiceFactory.getJsonObjectCache({
|
|
40
34
|
cacheKey: 'loadWorkbenchListMap',
|
|
41
35
|
refreshCache: false,
|
|
42
36
|
cacheName: CacheNameEnum.CurdMixByWorkbench,
|
|
@@ -55,7 +49,6 @@ export class CurdMixByWorkbenchService implements IExecuteContextHandler {
|
|
|
55
49
|
return MixinUtils.toNewMap(workbenchList, (obj: any) => obj.workbench_code);
|
|
56
50
|
},
|
|
57
51
|
});
|
|
58
|
-
return workbenchListMap;
|
|
59
52
|
}
|
|
60
53
|
|
|
61
54
|
async handleExecuteContextPrepare(executeContext: HandleExecuteContextType) {
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Context } from '@midwayjs/koa';
|
|
2
|
-
import { ICacheServiceBase, IfatcmsCacheConfig } from '../../../models/bizmodels';
|
|
3
|
-
export declare class FatcmsBaseDiskCache implements ICacheServiceBase {
|
|
4
|
-
protected ctx: Context;
|
|
5
|
-
protected cacheName: string;
|
|
6
|
-
private fatcmsCache;
|
|
7
|
-
constructor(ctx: Context, cacheName: string, fatcmsCache: IfatcmsCacheConfig);
|
|
8
|
-
/**
|
|
9
|
-
* 获取缓存文件路径
|
|
10
|
-
* @param key
|
|
11
|
-
* @returns
|
|
12
|
-
*/
|
|
13
|
-
private getCacheFilePath;
|
|
14
|
-
getJsonObject(key: string): Promise<any>;
|
|
15
|
-
/**
|
|
16
|
-
* 设置缓存对象
|
|
17
|
-
* @param key
|
|
18
|
-
* @param obj
|
|
19
|
-
* @param expireSecond 过期时间,单位秒
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
setJsonObject(key: string, obj: any, expireSecond?: number): Promise<any>;
|
|
23
|
-
removeItem(key: string): Promise<any>;
|
|
24
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Context } from '@midwayjs/koa';
|
|
2
|
-
import { ICacheServiceBase } from '../../../models/bizmodels';
|
|
3
|
-
export declare class FatcmsBaseMemoryCache implements ICacheServiceBase {
|
|
4
|
-
protected ctx: Context;
|
|
5
|
-
protected cacheName: string;
|
|
6
|
-
constructor(ctx: Context, cacheName: string);
|
|
7
|
-
private getLruCache;
|
|
8
|
-
getJsonObject(key: string): Promise<any>;
|
|
9
|
-
/**
|
|
10
|
-
* 设置缓存对象
|
|
11
|
-
* @param key
|
|
12
|
-
* @param obj
|
|
13
|
-
* @param expireSecond 过期时间,单位秒
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
setJsonObject(key: string, obj: any, expireSecond?: number): Promise<any>;
|
|
17
|
-
removeItem(key: string): Promise<any>;
|
|
18
|
-
}
|