midway-fatcms 0.0.1-beta.67 → 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/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 +19 -1
- 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 +24 -13
- package/dist/service/base/cache/CtxCache.d.ts +2 -3
- package/dist/service/base/cache/CtxCache.js +1 -2
- package/dist/service/base/cache/DiskCache.d.ts +6 -11
- package/dist/service/base/cache/DiskCache.js +10 -17
- package/dist/service/base/cache/MemoryCache.d.ts +3 -9
- package/dist/service/base/cache/MemoryCache.js +6 -14
- package/dist/service/base/cache/RedisCache.d.ts +3 -9
- package/dist/service/base/cache/RedisCache.js +6 -14
- 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/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 +25 -3
- package/src/service/EnumInfoService.ts +12 -18
- package/src/service/UserSessionService.ts +13 -18
- package/src/service/base/cache/CacheServiceFactory.ts +47 -38
- package/src/service/base/cache/CtxCache.ts +2 -4
- package/src/service/base/cache/DiskCache.ts +15 -20
- package/src/service/base/cache/MemoryCache.ts +8 -14
- package/src/service/base/cache/RedisCache.ts +8 -15
- 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
|
@@ -26,14 +26,12 @@ const DatabaseName_1 = require("../../libs/crud-pro/utils/DatabaseName");
|
|
|
26
26
|
const global_config_1 = require("../../libs/global-config/global-config");
|
|
27
27
|
const MixinUtils_1 = require("../../libs/crud-pro/utils/MixinUtils");
|
|
28
28
|
const CacheServiceFactory_1 = require("../base/cache/CacheServiceFactory");
|
|
29
|
-
const
|
|
29
|
+
const bizmodels_1 = require("../../models/bizmodels");
|
|
30
30
|
exports.SPECIAL_SETTING_KEY = {
|
|
31
31
|
QUERY_LIST: 'QUERY_LIST',
|
|
32
32
|
QUERY_ONE: 'QUERY_ONE',
|
|
33
33
|
KANBAN_VIEW_STATUS_UPDATE: 'KANBAN_VIEW_STATUS_UPDATE', // 看板视图中更新状态
|
|
34
34
|
};
|
|
35
|
-
const DEFAULT_CACHE_LEVEL = SystemEntities_1.CacheLevelEnum.MEMORY;
|
|
36
|
-
const DEFAULT_CACHE_SECOND = 60 * 5;
|
|
37
35
|
function isNotEmptyStr(str) {
|
|
38
36
|
return typeof str === 'string' && str.trim().length > 0;
|
|
39
37
|
}
|
|
@@ -237,19 +235,13 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
237
235
|
* @private
|
|
238
236
|
*/
|
|
239
237
|
async getParsedCrudStdAppInfo(appCode) {
|
|
240
|
-
|
|
241
|
-
const cacheSecond = crudStdAppInfoCacheSecond || DEFAULT_CACHE_SECOND;
|
|
242
|
-
const cacheLevel = crudStdAppInfoCacheLevel || DEFAULT_CACHE_LEVEL;
|
|
243
|
-
let appInfo = await this.cacheServiceFactory.getJsonObjectCache({
|
|
244
|
-
cacheLevel,
|
|
238
|
+
return await this.cacheServiceFactory.getJsonObjectCache({
|
|
245
239
|
cacheKey: appCode,
|
|
246
|
-
|
|
247
|
-
cacheName: SystemEntities_1.CacheNameEnum.GetParsedCrudStdAppInfo,
|
|
240
|
+
cacheName: bizmodels_1.CacheNameEnum.GetParsedCrudStdAppInfo,
|
|
248
241
|
getter: async () => {
|
|
249
242
|
return await this.getParsedCrudStdAppInfoPrivate(appCode);
|
|
250
243
|
},
|
|
251
244
|
});
|
|
252
|
-
return appInfo;
|
|
253
245
|
}
|
|
254
246
|
/**
|
|
255
247
|
* 查询APP信息
|
|
@@ -4,6 +4,10 @@ import { HandleExecuteContextType, IExecuteContextHandler } from '../../libs/cru
|
|
|
4
4
|
export declare class CurdMixByAccountService implements IExecuteContextHandler {
|
|
5
5
|
protected ctx: Context;
|
|
6
6
|
protected curdProService: CurdProService;
|
|
7
|
+
private cacheServiceFactory;
|
|
7
8
|
handleExecuteContextPrepare(executeContext: HandleExecuteContextType): Promise<void>;
|
|
9
|
+
private getFromCache;
|
|
10
|
+
private setToCache;
|
|
11
|
+
private queryUserAccountIdList;
|
|
8
12
|
handleExecuteContext(executeContext: HandleExecuteContextType): Promise<void>;
|
|
9
13
|
}
|
|
@@ -18,12 +18,13 @@ const SystemTables_1 = require("../../models/SystemTables");
|
|
|
18
18
|
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
19
19
|
const MixinUtils_1 = require("../../libs/crud-pro/utils/MixinUtils");
|
|
20
20
|
const global_config_1 = require("../../libs/global-config/global-config");
|
|
21
|
+
const bizmodels_1 = require("../../models/bizmodels");
|
|
22
|
+
const CacheServiceFactory_1 = require("../../service/base/cache/CacheServiceFactory");
|
|
21
23
|
const dictMixUtils = new CurdMixUtils_1.CrudMixUtils(CurdMixUtils_1.RelatedType.accountBasic);
|
|
22
24
|
const TMP_CTX_KEY = _.uniqueId('CurdMixByAccountService');
|
|
23
25
|
const TMP_CTX_KEY2 = _.uniqueId('CurdMixByAccountService2');
|
|
24
26
|
let CurdMixByAccountService = class CurdMixByAccountService {
|
|
25
27
|
async handleExecuteContextPrepare(executeContext) {
|
|
26
|
-
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
27
28
|
const relations = dictMixUtils.pickColumnRelations(executeContext);
|
|
28
29
|
if (!relations || relations.length === 0) {
|
|
29
30
|
return;
|
|
@@ -49,25 +50,58 @@ let CurdMixByAccountService = class CurdMixByAccountService {
|
|
|
49
50
|
if (accountIds.size === 0) {
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
const userInfos = await this.queryUserAccountIdList([...accountIds]);
|
|
54
|
+
executeContext[TMP_CTX_KEY] = MixinUtils_1.MixinUtils.toNewMap(userInfos, (obj) => obj.account_id);
|
|
55
|
+
executeContext[TMP_CTX_KEY2] = isArrayModeMap;
|
|
56
|
+
}
|
|
57
|
+
async getFromCache(code) {
|
|
58
|
+
const cacheService = this.cacheServiceFactory.getCacheServiceByName(bizmodels_1.CacheNameEnum.CurdMixByAccount);
|
|
59
|
+
return cacheService.getJsonObject(code);
|
|
60
|
+
}
|
|
61
|
+
async setToCache(code, value) {
|
|
62
|
+
const cacheService = this.cacheServiceFactory.getCacheServiceByName(bizmodels_1.CacheNameEnum.CurdMixByAccount);
|
|
63
|
+
return cacheService.setJsonObject(code, value);
|
|
64
|
+
}
|
|
65
|
+
async queryUserAccountIdList(accountIds) {
|
|
66
|
+
const resultRowMap = {};
|
|
67
|
+
for (let i = 0; i < accountIds.length; i++) {
|
|
68
|
+
const accountId = accountIds[i];
|
|
69
|
+
const row = await this.getFromCache(accountId);
|
|
70
|
+
if (row) {
|
|
71
|
+
resultRowMap[accountId] = row;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const notCachedCodes = accountIds.filter((accountId) => !resultRowMap[accountId]);
|
|
75
|
+
if (notCachedCodes.length === 0) {
|
|
76
|
+
return Object.values(resultRowMap);
|
|
77
|
+
}
|
|
78
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
59
79
|
const reqJson = {
|
|
60
80
|
columns: ['nick_name', 'avatar', 'account_id'],
|
|
61
81
|
condition: {
|
|
62
82
|
account_id: {
|
|
63
|
-
$in: [...
|
|
83
|
+
$in: [...notCachedCodes],
|
|
64
84
|
},
|
|
65
85
|
},
|
|
66
86
|
};
|
|
87
|
+
const cfgModel = {
|
|
88
|
+
method: 'UserAccountService.queryAccountBasicInfoByIds',
|
|
89
|
+
sqlTable: SystemTables_1.SystemTables.sys_user_account,
|
|
90
|
+
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
91
|
+
sqlDatabase: SystemDbName,
|
|
92
|
+
sqlDbType: SystemDbType,
|
|
93
|
+
};
|
|
67
94
|
const res = await this.curdProService.executeCrudByCfg(reqJson, cfgModel);
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
95
|
+
const rows = res.getResRows();
|
|
96
|
+
if (Array.isArray(rows) && rows.length > 0) {
|
|
97
|
+
for (let i = 0; i < rows.length; i++) {
|
|
98
|
+
const row = rows[i];
|
|
99
|
+
const { account_id } = row;
|
|
100
|
+
await this.setToCache(account_id, row);
|
|
101
|
+
resultRowMap[account_id] = row;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return Object.values(resultRowMap);
|
|
71
105
|
}
|
|
72
106
|
async handleExecuteContext(executeContext) {
|
|
73
107
|
const userInfoMap = executeContext[TMP_CTX_KEY];
|
|
@@ -107,6 +141,10 @@ __decorate([
|
|
|
107
141
|
(0, core_1.Inject)(),
|
|
108
142
|
__metadata("design:type", CurdProService_1.CurdProService)
|
|
109
143
|
], CurdMixByAccountService.prototype, "curdProService", void 0);
|
|
144
|
+
__decorate([
|
|
145
|
+
(0, core_1.Inject)(),
|
|
146
|
+
__metadata("design:type", CacheServiceFactory_1.CacheServiceFactory)
|
|
147
|
+
], CurdMixByAccountService.prototype, "cacheServiceFactory", void 0);
|
|
110
148
|
CurdMixByAccountService = __decorate([
|
|
111
149
|
(0, core_1.Provide)()
|
|
112
150
|
], CurdMixByAccountService);
|
|
@@ -19,21 +19,17 @@ const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
|
19
19
|
const MultiKeyMap_1 = require("../../libs/crud-pro/utils/MultiKeyMap");
|
|
20
20
|
const global_config_1 = require("../../libs/global-config/global-config");
|
|
21
21
|
const CacheServiceFactory_1 = require("../base/cache/CacheServiceFactory");
|
|
22
|
-
const
|
|
22
|
+
const bizmodels_1 = require("../../models/bizmodels");
|
|
23
23
|
const TMP_CTX_KEY = _.uniqueId('CurdMixByDictService');
|
|
24
24
|
const dictMixUtils = new CurdMixUtils_1.CrudMixUtils(CurdMixUtils_1.RelatedType.dict);
|
|
25
|
-
const DEFAULT_CACHE_LEVEL = SystemEntities_1.CacheLevelEnum.MEMORY;
|
|
26
|
-
const DEFAULT_CACHE_SECOND = 60 * 5;
|
|
27
25
|
let CurdMixByDictService = class CurdMixByDictService {
|
|
28
26
|
async getFromCache(code) {
|
|
29
|
-
const
|
|
30
|
-
const cacheService = this.cacheServiceFactory.getCacheService(curdMixByCommonCacheLevel || DEFAULT_CACHE_LEVEL, SystemEntities_1.CacheNameEnum.CurdMixByDict);
|
|
27
|
+
const cacheService = this.cacheServiceFactory.getCacheServiceByName(bizmodels_1.CacheNameEnum.CurdMixByDict);
|
|
31
28
|
return cacheService.getJsonObject(code);
|
|
32
29
|
}
|
|
33
30
|
async setToCache(code, value) {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
return cacheService.setJsonObject(code, value, curdMixByCommonCacheSecond || DEFAULT_CACHE_SECOND);
|
|
31
|
+
const cacheService = this.cacheServiceFactory.getCacheServiceByName(bizmodels_1.CacheNameEnum.CurdMixByDict);
|
|
32
|
+
return cacheService.setJsonObject(code, value);
|
|
37
33
|
}
|
|
38
34
|
async handleExecuteContextPrepare(executeContext) {
|
|
39
35
|
const codes = dictMixUtils.pickColumnRelationCodes(executeContext);
|
|
@@ -19,13 +19,11 @@ const devops_1 = require("../../models/devops");
|
|
|
19
19
|
const exceptions_1 = require("../../libs/crud-pro/exceptions");
|
|
20
20
|
const DatabaseName_1 = require("../../libs/crud-pro/utils/DatabaseName");
|
|
21
21
|
const global_config_1 = require("../../libs/global-config/global-config");
|
|
22
|
-
const
|
|
22
|
+
const bizmodels_1 = require("../../models/bizmodels");
|
|
23
23
|
const CacheServiceFactory_1 = require("../base/cache/CacheServiceFactory");
|
|
24
24
|
const md5 = require("md5");
|
|
25
25
|
const linkToCustomMixUtils = new CurdMixUtils_1.CrudMixUtils(CurdMixUtils_1.RelatedType.linkToCustom);
|
|
26
26
|
const TMP_CTX_KEY = _.uniqueId('CurdMixByLinkToCustomService');
|
|
27
|
-
const DEFAULT_CACHE_LEVEL = SystemEntities_1.CacheLevelEnum.MEMORY;
|
|
28
|
-
const DEFAULT_CACHE_SECOND = 60 * 5;
|
|
29
27
|
function toMapObject(rows, fieldsArr) {
|
|
30
28
|
const valueKey = fieldsArr[0];
|
|
31
29
|
const labelKey = fieldsArr[1];
|
|
@@ -82,12 +80,9 @@ let CurdMixByLinkToCustomService = class CurdMixByLinkToCustomService {
|
|
|
82
80
|
});
|
|
83
81
|
}
|
|
84
82
|
async queryInfoByLinkToCustom(code) {
|
|
85
|
-
const { curdMixByCommonCacheLevel, curdMixByCommonCacheSecond } = this.ctx.workbenchInfoTools.getWorkbenchConfig();
|
|
86
83
|
return this.cacheServiceFactory.getJsonObjectCache({
|
|
87
|
-
cacheLevel: curdMixByCommonCacheLevel || DEFAULT_CACHE_LEVEL,
|
|
88
84
|
cacheKey: md5(code),
|
|
89
|
-
|
|
90
|
-
cacheName: SystemEntities_1.CacheNameEnum.CurdMixByLinkToCustom,
|
|
85
|
+
cacheName: bizmodels_1.CacheNameEnum.CurdMixByLinkToCustom,
|
|
91
86
|
getter: async () => {
|
|
92
87
|
return await this.queryInfoByLinkToCustomImpl(code);
|
|
93
88
|
},
|
|
@@ -20,21 +20,17 @@ const MultiKeyMap_1 = require("../../libs/crud-pro/utils/MultiKeyMap");
|
|
|
20
20
|
const parseConfig_1 = require("../../libs/utils/parseConfig");
|
|
21
21
|
const global_config_1 = require("../../libs/global-config/global-config");
|
|
22
22
|
const CacheServiceFactory_1 = require("../base/cache/CacheServiceFactory");
|
|
23
|
-
const
|
|
23
|
+
const bizmodels_1 = require("../../models/bizmodels");
|
|
24
24
|
const dictMixUtils = new CurdMixUtils_1.CrudMixUtils(CurdMixUtils_1.RelatedType.sysCfgEnum);
|
|
25
25
|
const TMP_CTX_KEY = _.uniqueId('CurdMixBySysConfigService');
|
|
26
|
-
const DEFAULT_CACHE_LEVEL = SystemEntities_1.CacheLevelEnum.MEMORY;
|
|
27
|
-
const DEFAULT_CACHE_SECOND = 60 * 5;
|
|
28
26
|
let CurdMixBySysConfigService = class CurdMixBySysConfigService {
|
|
29
27
|
async getFromCache(code) {
|
|
30
|
-
const
|
|
31
|
-
const cacheService = this.cacheServiceFactory.getCacheService(curdMixByCommonCacheLevel || DEFAULT_CACHE_LEVEL, SystemEntities_1.CacheNameEnum.CurdMixBySysConfig);
|
|
28
|
+
const cacheService = this.cacheServiceFactory.getCacheServiceByName(bizmodels_1.CacheNameEnum.CurdMixBySysConfig);
|
|
32
29
|
return cacheService.getJsonObject(code);
|
|
33
30
|
}
|
|
34
31
|
async setToCache(code, value) {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
return cacheService.setJsonObject(code, value, curdMixByCommonCacheSecond || DEFAULT_CACHE_SECOND);
|
|
32
|
+
const cacheService = this.cacheServiceFactory.getCacheServiceByName(bizmodels_1.CacheNameEnum.CurdMixBySysConfig);
|
|
33
|
+
return cacheService.setJsonObject(code, value);
|
|
38
34
|
}
|
|
39
35
|
async queryConfigRowsUseCache(codes) {
|
|
40
36
|
const resultRowMap = {};
|
|
@@ -19,21 +19,16 @@ const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
|
19
19
|
const MixinUtils_1 = require("../../libs/crud-pro/utils/MixinUtils");
|
|
20
20
|
const global_config_1 = require("../../libs/global-config/global-config");
|
|
21
21
|
const CacheServiceFactory_1 = require("../base/cache/CacheServiceFactory");
|
|
22
|
-
const
|
|
22
|
+
const bizmodels_1 = require("../../models/bizmodels");
|
|
23
23
|
const workbenchMixUtils = new CurdMixUtils_1.CrudMixUtils(CurdMixUtils_1.RelatedType.workbenchBasic);
|
|
24
24
|
const TMP_CTX_KEY = _.uniqueId('CurdMixByWorkbenchService');
|
|
25
|
-
const DEFAULT_CACHE_LEVEL = SystemEntities_1.CacheLevelEnum.MEMORY;
|
|
26
|
-
const DEFAULT_CACHE_SECOND = 60 * 5;
|
|
27
25
|
let CurdMixByWorkbenchService = class CurdMixByWorkbenchService {
|
|
28
26
|
async loadWorkbenchListMap() {
|
|
29
27
|
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
30
|
-
|
|
31
|
-
const workbenchListMap = await this.cacheServiceFactory.getJsonObjectCache({
|
|
32
|
-
cacheLevel: curdMixByCommonCacheLevel || DEFAULT_CACHE_LEVEL,
|
|
33
|
-
cacheSecond: curdMixByCommonCacheSecond || DEFAULT_CACHE_SECOND,
|
|
28
|
+
return await this.cacheServiceFactory.getJsonObjectCache({
|
|
34
29
|
cacheKey: 'loadWorkbenchListMap',
|
|
35
30
|
refreshCache: false,
|
|
36
|
-
cacheName:
|
|
31
|
+
cacheName: bizmodels_1.CacheNameEnum.CurdMixByWorkbench,
|
|
37
32
|
getter: async () => {
|
|
38
33
|
const reqJson = {
|
|
39
34
|
columns: 'workbench_code,workbench_name,workbench_domain',
|
|
@@ -49,7 +44,6 @@ let CurdMixByWorkbenchService = class CurdMixByWorkbenchService {
|
|
|
49
44
|
return MixinUtils_1.MixinUtils.toNewMap(workbenchList, (obj) => obj.workbench_code);
|
|
50
45
|
},
|
|
51
46
|
});
|
|
52
|
-
return workbenchListMap;
|
|
53
47
|
}
|
|
54
48
|
async handleExecuteContextPrepare(executeContext) {
|
|
55
49
|
const relations = workbenchMixUtils.pickColumnRelations(executeContext);
|
package/package.json
CHANGED
|
@@ -169,7 +169,10 @@ export default (appInfo: any) => {
|
|
|
169
169
|
*/
|
|
170
170
|
fatcmsCache: {
|
|
171
171
|
diskCacheDir: join(tmpdir(), 'fatcms-disk-cache'),
|
|
172
|
-
|
|
172
|
+
cacheConfig: {
|
|
173
|
+
UserSessionBySessionId: { cacheLevel: 'REDIS', cacheSecond: 3600 * 24 * 30 },
|
|
174
|
+
UserSessionByAsyncTaskId: { cacheLevel: 'REDIS', cacheSecond: 3600 },
|
|
175
|
+
}
|
|
173
176
|
},
|
|
174
177
|
|
|
175
178
|
// 用户会话保持时间,单位秒
|
|
@@ -11,12 +11,8 @@ import { WorkbenchService } from '@/service/WorkbenchService';
|
|
|
11
11
|
import { SystemRoleCode } from '@/models/SystemPerm';
|
|
12
12
|
import { KeysOfAuthType } from '@/libs/crud-pro/models/keys';
|
|
13
13
|
import { CacheServiceFactory } from '@/service/base/cache/CacheServiceFactory';
|
|
14
|
-
import md5
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const DEFAULT_CACHE_LEVEL = CacheLevelEnum.MEMORY;
|
|
19
|
-
const DEFAULT_CACHE_SECOND = 60 * 5;
|
|
14
|
+
import * as md5 from 'md5';
|
|
15
|
+
import { CacheNameEnum} from "@/models/bizmodels";
|
|
20
16
|
|
|
21
17
|
|
|
22
18
|
/**
|
|
@@ -64,12 +60,8 @@ export class PublicApiController extends BaseApiController {
|
|
|
64
60
|
return CommonResult.errorRes('param workbenchMenuCode is null');
|
|
65
61
|
}
|
|
66
62
|
|
|
67
|
-
const { publicApiMenuCacheLevel, publicApiMenuCacheSecond } = this.ctx.workbenchInfoTools.getWorkbenchConfig();
|
|
68
|
-
|
|
69
63
|
const mapResult = await this.cacheServiceFactory.getJsonObjectCache({
|
|
70
|
-
cacheLevel: publicApiMenuCacheLevel || DEFAULT_CACHE_LEVEL,
|
|
71
64
|
cacheKey: "" + workbenchMenuCode,
|
|
72
|
-
cacheSecond: publicApiMenuCacheSecond || DEFAULT_CACHE_SECOND,
|
|
73
65
|
cacheName: CacheNameEnum.GetWorkbenchMenu,
|
|
74
66
|
getter: async () => {
|
|
75
67
|
|
|
@@ -134,13 +126,9 @@ export class PublicApiController extends BaseApiController {
|
|
|
134
126
|
};
|
|
135
127
|
|
|
136
128
|
|
|
137
|
-
const { publicApiNavPageInfoCacheLevel, publicApiNavPageInfoCacheSecond } = this.ctx.workbenchInfoTools.getWorkbenchConfig();
|
|
138
|
-
|
|
139
129
|
const getOne = async (condition: any, tableName: string, key: string) => {
|
|
140
130
|
const cacheKey = md5(tableName + ':' + JSON.stringify(condition) + ":" + key);
|
|
141
131
|
const oneData = await this.cacheServiceFactory.getJsonObjectCache({
|
|
142
|
-
cacheLevel: publicApiNavPageInfoCacheLevel || DEFAULT_CACHE_LEVEL,
|
|
143
|
-
cacheSecond: publicApiNavPageInfoCacheSecond || DEFAULT_CACHE_SECOND,
|
|
144
132
|
cacheKey,
|
|
145
133
|
cacheName: CacheNameEnum.GetNavPageInfo,
|
|
146
134
|
getter: async () => {
|
|
@@ -29,7 +29,7 @@ class CrudProExecuteSqlService extends CrudProServiceBase {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
private async executeSqlCfgModel(sqlCfgModel: SqlCfgModel) {
|
|
32
|
-
this.logger.info('
|
|
32
|
+
this.logger.info('[CrudProExecuteSqlService] executeSqlCfgModel_before', sqlCfgModel.executeSql, sqlCfgModel.executeSqlArgs);
|
|
33
33
|
|
|
34
34
|
const exeCtx = this.getExecuteContext();
|
|
35
35
|
const connection = await this.getTxConnectionBySqlCfg(sqlCfgModel);
|
|
@@ -42,22 +42,24 @@ class CrudProExecuteSqlService extends CrudProServiceBase {
|
|
|
42
42
|
|
|
43
43
|
const pgClient: PoolClient = connection as any;
|
|
44
44
|
const pgSql = replaceQuestionMarks(sqlCfgModel.executeSql);
|
|
45
|
-
this.logger.debug('[CrudProExecuteSqlService]executeSqlCfgModel_postgres', pgSql, executeSqlArgs, sqlCfgModel.resPicker);
|
|
46
45
|
queryRes = await pgClient.query({
|
|
47
46
|
text: pgSql,
|
|
48
47
|
values: executeSqlArgs || [],
|
|
49
48
|
});
|
|
49
|
+
|
|
50
|
+
this.logger.debug('[CrudProExecuteSqlService] executeSqlCfgModel_postgres', pgSql, executeSqlArgs, sqlCfgModel.resPicker);
|
|
51
|
+
|
|
50
52
|
} else if (sqlCfgModel.sqlDbType === SqlDbType.sqlserver) {
|
|
51
53
|
// SQLServer
|
|
52
54
|
|
|
53
55
|
const mssql = replaceQuestionMarksForMssql(sqlCfgModel.executeSql);
|
|
54
|
-
this.logger.debug('[CrudProExecuteSqlService]executeSqlCfgModel_sqlserver', mssql, executeSqlArgs, sqlCfgModel.resPicker);
|
|
55
56
|
queryRes = await connection.query(mssql, executeSqlArgs);
|
|
57
|
+
this.logger.debug('[CrudProExecuteSqlService] executeSqlCfgModel_sqlserver', mssql, executeSqlArgs, sqlCfgModel.resPicker);
|
|
58
|
+
|
|
56
59
|
} else {
|
|
57
60
|
// MYSQL
|
|
58
|
-
|
|
59
|
-
this.logger.debug('[CrudProExecuteSqlService]executeSqlCfgModel_mysql', sqlCfgModel.executeSql, executeSqlArgs, sqlCfgModel.resPicker);
|
|
60
61
|
queryRes = await connection.query(sqlCfgModel.executeSql, executeSqlArgs);
|
|
62
|
+
this.logger.debug('[CrudProExecuteSqlService] executeSqlCfgModel_mysql', sqlCfgModel.executeSql, executeSqlArgs, sqlCfgModel.resPicker);
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
const sqlRes = pickAndConvertRowsByMix(queryRes, sqlCfgModel.sqlDbType);
|
|
@@ -130,37 +130,8 @@ export enum CacheLevelEnum {
|
|
|
130
130
|
DISK = 'DISK', // 磁盘缓存
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
export enum CacheNameEnum {
|
|
134
|
-
CurdMixByDict = 'CurdMixByDict',
|
|
135
|
-
CurdMixByLinkToCustom = 'CurdMixByLinkToCustom',
|
|
136
|
-
CurdMixBySysConfig = 'CurdMixBySysConfig',
|
|
137
|
-
CurdMixByWorkbench = 'CurdMixByWorkbench',
|
|
138
|
-
GetParsedCrudStdAppInfo = 'GetParsedCrudStdAppInfo',
|
|
139
|
-
GetWorkbenchMenu = 'GetWorkbenchMenu',
|
|
140
|
-
GetNavPageInfo = 'GetNavPageInfo',
|
|
141
|
-
GetEnumInfoByCode = 'GetEnumInfoByCode',
|
|
142
|
-
UserSessionBySessionId = 'UserSessionBySessionId',
|
|
143
|
-
UserSessionByAsyncTaskId = 'UserSessionByAsyncTaskId',
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
133
|
export interface IWorkbenchConfig {
|
|
148
134
|
nodeApiWhiteEnable?: boolean; // 接口白名单开关
|
|
149
135
|
nodeApiWhiteList?: string[]; // 接口白名单,完整匹配
|
|
150
136
|
nodeApiWhitePrefix?: string[]; // 接口白名单,根据前缀匹配
|
|
151
|
-
|
|
152
|
-
crudStdAppInfoCacheLevel?: CacheLevelEnum; // 零代码CRUD接口白名单开关. 默认: MEMORY
|
|
153
|
-
crudStdAppInfoCacheSecond?: number; // 零代码CRUD接口白名单缓存时间,单位:秒。 默认 5分钟
|
|
154
|
-
|
|
155
|
-
publicApiNavPageInfoCacheLevel?: CacheLevelEnum; // 公开API导航页缓存级别. 默认: MEMORY
|
|
156
|
-
publicApiNavPageInfoCacheSecond?: number; // 公开API导航页缓存时间,单位:秒。 默认 5分钟
|
|
157
|
-
|
|
158
|
-
publicApiMenuCacheLevel?: CacheLevelEnum; // 公开API菜单缓存级别. 默认: MEMORY
|
|
159
|
-
publicApiMenuCacheSecond?: number; // 公开API菜单缓存时间,单位:秒。 默认 5分钟
|
|
160
|
-
|
|
161
|
-
queryEnumInfoCacheLevel?: CacheLevelEnum; // 查询枚举缓存级别. 默认: MEMORY
|
|
162
|
-
queryEnumInfoCacheSecond?: number; // 查询枚举缓存时间,单位:秒。 默认 5分钟
|
|
163
|
-
|
|
164
|
-
curdMixByCommonCacheLevel?: CacheLevelEnum; // CrudMixService 缓存级别. 默认: MEMORY
|
|
165
|
-
curdMixByCommonCacheSecond?: number; // CrudMixService 缓存时间,单位:秒。 默认 5分钟
|
|
166
|
-
}
|
|
137
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { parseJsonObject } from "@/libs/utils/functions";
|
|
2
|
-
import { IWorkbenchConfig, IWorkbenchEntity
|
|
2
|
+
import { IWorkbenchConfig, IWorkbenchEntity} from "./SystemEntities";
|
|
3
|
+
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
export class WorkbenchInfoTools {
|
|
@@ -13,6 +14,6 @@ export class WorkbenchInfoTools {
|
|
|
13
14
|
}
|
|
14
15
|
const configObj: IWorkbenchConfig = parseJsonObject(this.workbenchInfo?.config_content);
|
|
15
16
|
this.parsedConfigContent = configObj || {};
|
|
16
|
-
return this.parsedConfigContent;
|
|
17
|
+
return this.parsedConfigContent;
|
|
17
18
|
}
|
|
18
19
|
}
|
package/src/models/bizmodels.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { IRequestCfgModel, IVisitor } from '
|
|
1
|
+
import { IRequestCfgModel, IVisitor } from '@/libs/crud-pro/interfaces';
|
|
2
|
+
import {CacheLevelEnum} from "@/models/SystemEntities";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* 实体表公共字段
|
|
@@ -133,7 +134,28 @@ export interface ICacheService {
|
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
|
|
137
|
+
export enum CacheNameEnum {
|
|
138
|
+
CurdMixByAccount = 'CurdMixByAccount',
|
|
139
|
+
CurdMixByDict = 'CurdMixByDict',
|
|
140
|
+
CurdMixByLinkToCustom = 'CurdMixByLinkToCustom',
|
|
141
|
+
CurdMixBySysConfig = 'CurdMixBySysConfig',
|
|
142
|
+
CurdMixByWorkbench = 'CurdMixByWorkbench',
|
|
143
|
+
GetParsedCrudStdAppInfo = 'GetParsedCrudStdAppInfo',
|
|
144
|
+
GetWorkbenchMenu = 'GetWorkbenchMenu',
|
|
145
|
+
GetNavPageInfo = 'GetNavPageInfo',
|
|
146
|
+
GetEnumInfoByCode = 'GetEnumInfoByCode',
|
|
147
|
+
UserSessionBySessionId = 'UserSessionBySessionId', // 只能是Redis
|
|
148
|
+
UserSessionByAsyncTaskId = 'UserSessionByAsyncTaskId', // 只能是Redis
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
export interface IWorkbenchConfigCacheLevel {
|
|
153
|
+
cacheLevel: CacheLevelEnum;
|
|
154
|
+
cacheSecond: number;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
136
158
|
export interface IfatcmsCacheConfig {
|
|
137
|
-
|
|
138
|
-
|
|
159
|
+
diskCacheDir: string;
|
|
160
|
+
cacheConfig?: Record<CacheNameEnum, IWorkbenchConfigCacheLevel>
|
|
139
161
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { parseConfigContentToEnumInfo
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
1
|
+
import {Inject, Provide} from '@midwayjs/core';
|
|
2
|
+
import {Context} from '@midwayjs/koa';
|
|
3
|
+
import {KeysOfSimpleSQL} from '@/libs/crud-pro/models/keys';
|
|
4
|
+
import {CurdProService} from './curd/CurdProService';
|
|
5
|
+
import {RelatedType} from './curd/CurdMixUtils';
|
|
6
|
+
import {SystemTables} from '@/models/SystemTables';
|
|
7
|
+
import {IEnumInfo, parseConfigContentToEnumInfo} from '@/libs/utils/parseConfig';
|
|
8
|
+
import {CurdMixByLinkToCustomService} from './curd/CurdMixByLinkToCustomService';
|
|
9
|
+
import {GLOBAL_STATIC_CONFIG} from '@/libs/global-config/global-config';
|
|
10
|
+
import {CacheServiceFactory} from './base/cache/CacheServiceFactory';
|
|
11
|
+
import { CacheNameEnum } from "@/models/bizmodels";
|
|
12
12
|
|
|
13
13
|
interface IQueryEnumInfo {
|
|
14
14
|
type: RelatedType;
|
|
@@ -24,8 +24,6 @@ function filterEmpty(e: IEnumInfo): boolean {
|
|
|
24
24
|
return e.label && typeof e.value !== 'undefined';
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const DEFAULT_CACHE_LEVEL = CacheLevelEnum.MEMORY;
|
|
28
|
-
const DEFAULT_CACHE_SECOND = 60 * 5;
|
|
29
27
|
|
|
30
28
|
|
|
31
29
|
@Provide()
|
|
@@ -42,7 +40,6 @@ export class EnumInfoService {
|
|
|
42
40
|
private cacheServiceFactory: CacheServiceFactory;
|
|
43
41
|
|
|
44
42
|
async queryEnumInfo(codeList: IQueryEnumInfo[], refreshCache: boolean): Promise<IQueryEnumResult[]> {
|
|
45
|
-
const { queryEnumInfoCacheLevel, queryEnumInfoCacheSecond } = this.ctx.workbenchInfoTools.getWorkbenchConfig() || {};
|
|
46
43
|
|
|
47
44
|
const getEnumInfoByCode = async (type: RelatedType, code: string) => {
|
|
48
45
|
if (type === RelatedType.linkToCustom) {
|
|
@@ -50,9 +47,7 @@ export class EnumInfoService {
|
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
const cacheKey = `${type}@@${code}`;
|
|
53
|
-
|
|
54
|
-
cacheLevel: queryEnumInfoCacheLevel || DEFAULT_CACHE_LEVEL,
|
|
55
|
-
cacheSecond: queryEnumInfoCacheSecond || DEFAULT_CACHE_SECOND,
|
|
50
|
+
return await this.cacheServiceFactory.getJsonObjectCache({
|
|
56
51
|
cacheKey,
|
|
57
52
|
refreshCache,
|
|
58
53
|
cacheName: CacheNameEnum.GetEnumInfoByCode,
|
|
@@ -65,7 +60,6 @@ export class EnumInfoService {
|
|
|
65
60
|
return [];
|
|
66
61
|
},
|
|
67
62
|
});
|
|
68
|
-
return emums;
|
|
69
63
|
};
|
|
70
64
|
|
|
71
65
|
const result = [];
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { ICacheService } from '@/models/bizmodels';
|
|
1
|
+
import {Config, Inject, Provide} from '@midwayjs/core';
|
|
2
|
+
import {Context} from '@midwayjs/koa';
|
|
3
|
+
import {parseJsonObject} from '@/libs/utils/functions';
|
|
4
|
+
import {ISessionInfo, SESSION_ID_KEY, sessionCookieCfg} from '@/models/userSession';
|
|
5
|
+
import {HEADER_KEY_RUN_BY_ASYNC_TASK_ID} from '@/models/AsyncTaskModel';
|
|
6
|
+
import {CurdProService} from './curd/CurdProService';
|
|
7
|
+
import {KeysOfSimpleSQL} from '@/libs/crud-pro/models/keys';
|
|
8
|
+
import {SystemTables} from '@/models/SystemTables';
|
|
9
|
+
import {GLOBAL_STATIC_CONFIG} from '@/libs/global-config/global-config';
|
|
10
|
+
import {CacheServiceFactory} from './base/cache/CacheServiceFactory';
|
|
11
|
+
import {ICacheService , CacheNameEnum} from '@/models/bizmodels';
|
|
13
12
|
|
|
14
13
|
function pickUserAvatar(avatar: any): string {
|
|
15
14
|
if (!avatar) {
|
|
@@ -71,7 +70,7 @@ export class UserSessionService {
|
|
|
71
70
|
* @returns
|
|
72
71
|
*/
|
|
73
72
|
private getUserSessionCacheService(): ICacheService {
|
|
74
|
-
return this.cacheServiceFactory.
|
|
73
|
+
return this.cacheServiceFactory.getCacheServiceByName(CacheNameEnum.UserSessionBySessionId);
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
/**
|
|
@@ -140,15 +139,11 @@ export class UserSessionService {
|
|
|
140
139
|
return parseJsonObject(asyncTaskObj.created_user_session);
|
|
141
140
|
};
|
|
142
141
|
|
|
143
|
-
|
|
144
|
-
cacheLevel: CacheLevelEnum.REDIS,
|
|
142
|
+
return await this.cacheServiceFactory.getJsonObjectCache({
|
|
145
143
|
cacheName: CacheNameEnum.UserSessionByAsyncTaskId,
|
|
146
144
|
cacheKey: taskSessionCacheKey,
|
|
147
|
-
cacheSecond: 3600,
|
|
148
145
|
getter: loadSessionInfo,
|
|
149
146
|
});
|
|
150
|
-
|
|
151
|
-
return sessionInfo1;
|
|
152
147
|
}
|
|
153
148
|
|
|
154
149
|
/**
|