midway-fatcms 0.0.1-beta.64 → 0.0.1-beta.66
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 +7 -0
- package/dist/controller/base/BaseApiController.d.ts +5 -0
- package/dist/controller/base/BaseApiController.js +25 -0
- package/dist/controller/gateway/CrudStdGatewayController.d.ts +1 -1
- package/dist/controller/gateway/CrudStdGatewayController.js +36 -10
- package/dist/controller/gateway/FileController.js +2 -1
- package/dist/controller/gateway/PublicApiController.d.ts +1 -0
- package/dist/controller/gateway/PublicApiController.js +64 -28
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/interface.d.ts +2 -0
- package/dist/libs/crud-pro/exceptions.d.ts +2 -0
- package/dist/libs/crud-pro/exceptions.js +2 -0
- package/dist/libs/crud-pro/models/keys.d.ts +1 -1
- package/dist/libs/crud-pro/models/keys.js +1 -1
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +6 -1
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +14 -0
- package/dist/libs/utils/AsymmetricCrypto.d.ts +76 -0
- package/dist/libs/utils/AsymmetricCrypto.js +261 -0
- package/dist/libs/utils/format-url.d.ts +2 -0
- package/dist/libs/utils/format-url.js +13 -0
- package/dist/libs/utils/render-utils.d.ts +16 -7
- package/dist/libs/utils/render-utils.js +27 -6
- package/dist/middleware/global.middleware.js +7 -0
- package/dist/models/SystemEntities.d.ts +34 -0
- package/dist/models/SystemEntities.js +22 -1
- package/dist/models/WorkbenchInfoTools.d.ts +7 -0
- package/dist/models/WorkbenchInfoTools.js +20 -0
- package/dist/models/bizmodels.d.ts +9 -0
- package/dist/models/contextLogger.d.ts +2 -0
- package/dist/models/contextLogger.js +8 -1
- package/dist/models/userSession.d.ts +2 -0
- package/dist/models/userSession.js +2 -0
- package/dist/schedule/anonymousContext.js +2 -0
- package/dist/service/AuthService.js +7 -0
- package/dist/service/EnumInfoService.d.ts +1 -1
- package/dist/service/EnumInfoService.js +32 -26
- package/dist/service/UserSessionService.d.ts +6 -1
- package/dist/service/UserSessionService.js +26 -17
- package/dist/service/WorkbenchService.d.ts +1 -0
- package/dist/service/WorkbenchService.js +27 -1
- package/dist/service/base/cache/CacheServiceFactory.d.ts +20 -0
- package/dist/service/base/cache/CacheServiceFactory.js +67 -0
- package/dist/service/base/cache/FatcmsBaseCtxCache.d.ts +19 -0
- package/dist/service/base/cache/FatcmsBaseCtxCache.js +38 -0
- package/dist/service/base/cache/FatcmsBaseDiskCache.d.ts +24 -0
- package/dist/service/base/cache/FatcmsBaseDiskCache.js +81 -0
- package/dist/service/base/cache/FatcmsBaseMemoryCache.d.ts +18 -0
- package/dist/service/base/cache/FatcmsBaseMemoryCache.js +66 -0
- package/dist/service/base/cache/FatcmsBaseNoneCache.d.ts +10 -0
- package/dist/service/base/cache/FatcmsBaseNoneCache.js +19 -0
- package/dist/service/base/{RedisCacheService.d.ts → cache/FatcmsBaseRedisCache.d.ts} +6 -6
- package/dist/service/base/cache/FatcmsBaseRedisCache.js +39 -0
- package/dist/service/crudstd/CrudStdService.d.ts +6 -4
- package/dist/service/crudstd/CrudStdService.js +24 -10
- package/dist/service/curd/CurdMixByDictService.d.ts +1 -2
- package/dist/service/curd/CurdMixByDictService.js +12 -8
- package/dist/service/curd/CurdMixByLinkToCustomService.d.ts +1 -2
- package/dist/service/curd/CurdMixByLinkToCustomService.js +17 -13
- package/dist/service/curd/CurdMixBySysConfigService.d.ts +4 -0
- package/dist/service/curd/CurdMixBySysConfigService.js +50 -10
- package/dist/service/curd/CurdMixByWorkbenchService.d.ts +2 -1
- package/dist/service/curd/CurdMixByWorkbenchService.js +30 -22
- package/package.json +1 -1
- package/src/config/config.default.ts +8 -0
- package/src/controller/base/BaseApiController.ts +39 -0
- package/src/controller/gateway/CrudStdGatewayController.ts +42 -10
- package/src/controller/gateway/FileController.ts +2 -2
- package/src/controller/gateway/PublicApiController.ts +72 -28
- package/src/controller/manage/DocLibManageApi.ts +5 -5
- package/src/controller/manage/FileManageApi.ts +5 -5
- package/src/controller/manage/MenuManageApi.ts +4 -4
- package/src/index.ts +1 -1
- package/src/interface.ts +2 -0
- package/src/libs/crud-pro/exceptions.ts +2 -0
- package/src/libs/crud-pro/models/keys.ts +6 -6
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +7 -1
- package/src/libs/crud-pro/utils/sqlConvert/convertColumnName.ts +18 -0
- package/src/libs/utils/AsymmetricCrypto.ts +310 -0
- package/src/libs/utils/format-url.ts +16 -0
- package/src/libs/utils/render-utils.ts +56 -15
- package/src/middleware/global.middleware.ts +8 -0
- package/src/models/SystemEntities.ts +43 -0
- package/src/models/WorkbenchInfoTools.ts +18 -0
- package/src/models/bizmodels.ts +12 -0
- package/src/models/contextLogger.ts +10 -1
- package/src/models/userSession.ts +4 -0
- package/src/schedule/anonymousContext.ts +2 -0
- package/src/service/AuthService.ts +11 -0
- package/src/service/EnumInfoService.ts +35 -22
- package/src/service/UserSessionService.ts +29 -18
- package/src/service/WorkbenchService.ts +42 -2
- package/src/service/base/cache/CacheServiceFactory.ts +66 -0
- package/src/service/base/cache/FatcmsBaseCtxCache.ts +47 -0
- package/src/service/base/cache/FatcmsBaseDiskCache.ts +87 -0
- package/src/service/base/cache/FatcmsBaseMemoryCache.ts +74 -0
- package/src/service/base/cache/FatcmsBaseNoneCache.ts +24 -0
- package/src/service/base/cache/FatcmsBaseRedisCache.ts +48 -0
- package/src/service/crudstd/CrudStdService.ts +28 -12
- package/src/service/curd/CurdMixByAccountService.ts +1 -0
- package/src/service/curd/CurdMixByDictService.ts +14 -8
- package/src/service/curd/CurdMixByLinkToCustomService.ts +21 -12
- package/src/service/curd/CurdMixBySysConfigService.ts +60 -11
- package/src/service/curd/CurdMixByWorkbenchService.ts +31 -24
- package/src/service/proxyapi/WeightedRandom.ts +1 -1
- package/src/service/proxyapi/WeightedRoundRobin.ts +1 -1
- package/dist/service/base/RedisCacheService.js +0 -57
- package/src/service/base/RedisCacheService.ts +0 -42
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Inject, Provide } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import * as _ from 'lodash';
|
|
4
|
-
import { LRUCache } from 'lru-cache';
|
|
5
4
|
import { CurdProService } from './CurdProService';
|
|
6
5
|
import { HandleExecuteContextType, IExecuteContextHandler } from '@/libs/crud-pro/models/ExecuteContext';
|
|
7
6
|
import { CrudMixUtils, RelatedType } from './CurdMixUtils';
|
|
@@ -10,44 +9,52 @@ import { KeysOfSimpleSQL } from '@/libs/crud-pro/models/keys';
|
|
|
10
9
|
import { ColumnRelation } from '@/libs/crud-pro/interfaces';
|
|
11
10
|
import { MixinUtils } from '@/libs/crud-pro/utils/MixinUtils';
|
|
12
11
|
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
max: 500,
|
|
16
|
-
ttl: 1000 * 60 * 5,
|
|
17
|
-
ttlAutopurge: true,
|
|
18
|
-
});
|
|
12
|
+
import { CacheServiceFactory } from '../base/cache/CacheServiceFactory';
|
|
13
|
+
import { CacheLevelEnum, CacheNameEnum } from '@/models/SystemEntities';
|
|
19
14
|
|
|
20
15
|
const workbenchMixUtils = new CrudMixUtils(RelatedType.workbenchBasic);
|
|
21
16
|
|
|
22
17
|
const TMP_CTX_KEY = _.uniqueId('CurdMixByWorkbenchService');
|
|
23
18
|
|
|
19
|
+
const DEFAULT_CACHE_LEVEL = CacheLevelEnum.MEMORY;
|
|
20
|
+
const DEFAULT_CACHE_SECOND = 60 * 5;
|
|
21
|
+
|
|
24
22
|
@Provide()
|
|
25
23
|
export class CurdMixByWorkbenchService implements IExecuteContextHandler {
|
|
26
24
|
@Inject()
|
|
27
|
-
ctx: Context;
|
|
25
|
+
protected ctx: Context;
|
|
28
26
|
|
|
29
27
|
@Inject()
|
|
30
28
|
protected curdProService: CurdProService;
|
|
31
29
|
|
|
30
|
+
@Inject()
|
|
31
|
+
private cacheServiceFactory: CacheServiceFactory;
|
|
32
|
+
|
|
32
33
|
private async loadWorkbenchListMap() {
|
|
33
34
|
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
35
|
+
const { curdMixByCommonCacheLevel, curdMixByCommonCacheSecond } = this.ctx.workbenchInfoTools.getWorkbenchConfig() || {};
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
37
|
+
const workbenchListMap = await this.cacheServiceFactory.getJsonObjectCache({
|
|
38
|
+
cacheLevel: curdMixByCommonCacheLevel || DEFAULT_CACHE_LEVEL,
|
|
39
|
+
cacheSecond: curdMixByCommonCacheSecond || DEFAULT_CACHE_SECOND,
|
|
40
|
+
cacheKey: 'loadWorkbenchListMap',
|
|
41
|
+
refreshCache: false,
|
|
42
|
+
cacheName: CacheNameEnum.CurdMixByWorkbench,
|
|
43
|
+
getter: async () => {
|
|
44
|
+
const reqJson = {
|
|
45
|
+
columns: 'workbench_code,workbench_name,workbench_domain',
|
|
46
|
+
condition: {},
|
|
47
|
+
};
|
|
48
|
+
const res = await this.curdProService.executeCrudByCfg(reqJson, {
|
|
49
|
+
sqlTable: SystemTables.sys_workbench,
|
|
50
|
+
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
51
|
+
sqlDatabase: SystemDbName,
|
|
52
|
+
sqlDbType: SystemDbType,
|
|
53
|
+
});
|
|
54
|
+
const workbenchList = res.getResRows();
|
|
55
|
+
return MixinUtils.toNewMap(workbenchList, (obj: any) => obj.workbench_code);
|
|
56
|
+
},
|
|
57
|
+
});
|
|
51
58
|
return workbenchListMap;
|
|
52
59
|
}
|
|
53
60
|
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.RedisCacheService = void 0;
|
|
13
|
-
const core_1 = require("@midwayjs/core");
|
|
14
|
-
const redis_1 = require("@midwayjs/redis");
|
|
15
|
-
const oss_1 = require("@midwayjs/oss");
|
|
16
|
-
const koa = require("@midwayjs/koa");
|
|
17
|
-
const functions_1 = require("../../libs/utils/functions");
|
|
18
|
-
let RedisCacheService = class RedisCacheService {
|
|
19
|
-
async getJsonObject(key) {
|
|
20
|
-
const str = await this.redisService.get(key);
|
|
21
|
-
return (0, functions_1.parseJsonObject)(str);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* 设置缓存对象
|
|
25
|
-
* @param key
|
|
26
|
-
* @param obj
|
|
27
|
-
* @param expireSecond 过期时间,单位秒
|
|
28
|
-
* @returns
|
|
29
|
-
*/
|
|
30
|
-
async setJsonObject(key, obj, expireSecond) {
|
|
31
|
-
const str = JSON.stringify(obj);
|
|
32
|
-
return this.redisService.set(key, str, 'EX', expireSecond);
|
|
33
|
-
}
|
|
34
|
-
async removeItem(key) {
|
|
35
|
-
return await this.redisService.del(key);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
__decorate([
|
|
39
|
-
(0, core_1.Inject)(),
|
|
40
|
-
__metadata("design:type", Object)
|
|
41
|
-
], RedisCacheService.prototype, "ctx", void 0);
|
|
42
|
-
__decorate([
|
|
43
|
-
(0, core_1.App)(),
|
|
44
|
-
__metadata("design:type", Object)
|
|
45
|
-
], RedisCacheService.prototype, "app", void 0);
|
|
46
|
-
__decorate([
|
|
47
|
-
(0, core_1.Inject)(),
|
|
48
|
-
__metadata("design:type", redis_1.RedisService)
|
|
49
|
-
], RedisCacheService.prototype, "redisService", void 0);
|
|
50
|
-
__decorate([
|
|
51
|
-
(0, core_1.Inject)(),
|
|
52
|
-
__metadata("design:type", oss_1.OSSServiceFactory)
|
|
53
|
-
], RedisCacheService.prototype, "ossServiceFactory", void 0);
|
|
54
|
-
RedisCacheService = __decorate([
|
|
55
|
-
(0, core_1.Provide)()
|
|
56
|
-
], RedisCacheService);
|
|
57
|
-
exports.RedisCacheService = RedisCacheService;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Inject, Provide, App } from '@midwayjs/core';
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { RedisService } from '@midwayjs/redis';
|
|
4
|
-
import { OSSServiceFactory } from '@midwayjs/oss';
|
|
5
|
-
import * as koa from '@midwayjs/koa';
|
|
6
|
-
import { parseJsonObject } from '../../libs/utils/functions';
|
|
7
|
-
|
|
8
|
-
@Provide()
|
|
9
|
-
export class RedisCacheService {
|
|
10
|
-
@Inject()
|
|
11
|
-
protected ctx: Context;
|
|
12
|
-
|
|
13
|
-
@App()
|
|
14
|
-
protected app: koa.Application;
|
|
15
|
-
|
|
16
|
-
@Inject()
|
|
17
|
-
protected redisService: RedisService;
|
|
18
|
-
|
|
19
|
-
@Inject()
|
|
20
|
-
protected ossServiceFactory: OSSServiceFactory;
|
|
21
|
-
|
|
22
|
-
async getJsonObject(key: string): Promise<any> {
|
|
23
|
-
const str = await this.redisService.get(key);
|
|
24
|
-
return parseJsonObject(str);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 设置缓存对象
|
|
29
|
-
* @param key
|
|
30
|
-
* @param obj
|
|
31
|
-
* @param expireSecond 过期时间,单位秒
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
async setJsonObject(key: string, obj: any, expireSecond: number): Promise<any> {
|
|
35
|
-
const str = JSON.stringify(obj);
|
|
36
|
-
return this.redisService.set(key, str, 'EX', expireSecond);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async removeItem(key: string): Promise<any> {
|
|
40
|
-
return await this.redisService.del(key);
|
|
41
|
-
}
|
|
42
|
-
}
|