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
|
@@ -148,6 +148,13 @@ exports.default = (appInfo) => {
|
|
|
148
148
|
headerKey: 'fatcmsSAEnable',
|
|
149
149
|
headerSecret: '222',
|
|
150
150
|
},
|
|
151
|
+
/**
|
|
152
|
+
* 磁盘缓存配置
|
|
153
|
+
*/
|
|
154
|
+
fatcmsCache: {
|
|
155
|
+
diskCacheDir: (0, path_1.join)((0, os_1.tmpdir)(), 'fatcms-disk-cache'),
|
|
156
|
+
keyPrefix: 'fv1:',
|
|
157
|
+
},
|
|
151
158
|
// 用户会话保持时间,单位秒
|
|
152
159
|
fatcmsUserSessionKeepTimeSecond: 3600 * 24 * 30,
|
|
153
160
|
// 是否启用内置的定时任务
|
|
@@ -11,6 +11,10 @@ export interface IExecuteSimpleSqlParams {
|
|
|
11
11
|
validateCfg?: Record<string, IValidatorCfgItem[]>;
|
|
12
12
|
columns?: string | string[];
|
|
13
13
|
}
|
|
14
|
+
export interface ISecretBody {
|
|
15
|
+
secretPayload: string;
|
|
16
|
+
secretKey: string;
|
|
17
|
+
}
|
|
14
18
|
export declare class BaseApiController extends BaseService {
|
|
15
19
|
protected ctx: Context;
|
|
16
20
|
protected curdMixService: CurdMixService;
|
|
@@ -34,4 +38,5 @@ export declare class BaseApiController extends BaseService {
|
|
|
34
38
|
protected get sysDBUtil(): import("../..").CrudProQuick;
|
|
35
39
|
private addAccountBasicInfoCfgModel;
|
|
36
40
|
private addWorkbenchBasicInfoCfgModel;
|
|
41
|
+
protected decodeBodyBySession<T>(body: any): Promise<any>;
|
|
37
42
|
}
|
|
@@ -20,6 +20,9 @@ const BaseService_1 = require("../../service/base/BaseService");
|
|
|
20
20
|
const moment = require("moment");
|
|
21
21
|
const exceptions_1 = require("../../libs/crud-pro/exceptions");
|
|
22
22
|
const RedisKeys_1 = require("../../models/RedisKeys");
|
|
23
|
+
const aes_128_cbc_1 = require("aes-128-cbc");
|
|
24
|
+
const md5 = require("md5");
|
|
25
|
+
const AsymmetricCrypto_1 = require("../../libs/utils/AsymmetricCrypto");
|
|
23
26
|
let BaseApiController = class BaseApiController extends BaseService_1.BaseService {
|
|
24
27
|
/**
|
|
25
28
|
* 检查用户是否在指定时间内重复执行了某个操作
|
|
@@ -145,6 +148,28 @@ let BaseApiController = class BaseApiController extends BaseService_1.BaseServic
|
|
|
145
148
|
columnsRelation.push(createdByRelation2);
|
|
146
149
|
}
|
|
147
150
|
}
|
|
151
|
+
async decodeBodyBySession(body) {
|
|
152
|
+
const sessionInfo = this.getUserSessionInfo();
|
|
153
|
+
const sessionId = sessionInfo === null || sessionInfo === void 0 ? void 0 : sessionInfo.sessionId;
|
|
154
|
+
if (!sessionId) {
|
|
155
|
+
throw new Error('[decodeBodyBySessionId] sessionId is null');
|
|
156
|
+
}
|
|
157
|
+
const secretBody = body;
|
|
158
|
+
if (!secretBody.secretPayload || !secretBody.secretKey) {
|
|
159
|
+
return body;
|
|
160
|
+
}
|
|
161
|
+
const { privateKey } = sessionInfo;
|
|
162
|
+
const secretPayload = secretBody.secretPayload;
|
|
163
|
+
const secretKey = secretBody.secretKey; // 使用RSA加密的AES密钥
|
|
164
|
+
const aesKey = await AsymmetricCrypto_1.AsymmetricCrypto.decrypt(privateKey, secretKey); // 解密AES密钥
|
|
165
|
+
const createAes128 = () => {
|
|
166
|
+
const iv = md5(aesKey + sessionId);
|
|
167
|
+
return new aes_128_cbc_1.Aes128CBC(aesKey, iv);
|
|
168
|
+
};
|
|
169
|
+
const aes128 = createAes128();
|
|
170
|
+
const decryptedPayload = await aes128.time_decrypt_base64_utf8(secretPayload);
|
|
171
|
+
return JSON.parse(decryptedPayload);
|
|
172
|
+
}
|
|
148
173
|
};
|
|
149
174
|
__decorate([
|
|
150
175
|
(0, core_1.Inject)(),
|
|
@@ -2,7 +2,7 @@ import { Context } from '@midwayjs/koa';
|
|
|
2
2
|
import { BaseApiController } from '../base/BaseApiController';
|
|
3
3
|
import { CommonResult } from '../../libs/utils/common-dto';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* 零代码配置的界面,相关的接口的执行。这里的接口都需要登录。
|
|
6
6
|
*/
|
|
7
7
|
export declare class CrudStdGatewayController extends BaseApiController {
|
|
8
8
|
protected ctx: Context;
|
|
@@ -15,24 +15,40 @@ const BaseApiController_1 = require("../base/BaseApiController");
|
|
|
15
15
|
const CrudStdService_1 = require("../../service/crudstd/CrudStdService");
|
|
16
16
|
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
17
17
|
const common_dto_1 = require("../../libs/utils/common-dto");
|
|
18
|
+
const permission_middleware_1 = require("../../middleware/permission.middleware");
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
+
* 零代码配置的界面,相关的接口的执行。这里的接口都需要登录。
|
|
20
21
|
*/
|
|
21
22
|
let CrudStdGatewayController = class CrudStdGatewayController extends BaseApiController_1.BaseApiController {
|
|
22
23
|
/**
|
|
23
24
|
* 获取零代码应用基本信息
|
|
24
25
|
*/
|
|
25
26
|
async getParsedCrudStdAppInfo() {
|
|
26
|
-
const
|
|
27
|
+
const decodeBody = await this.decodeBodyBySession(this.ctx.request.body);
|
|
28
|
+
const body = decodeBody;
|
|
27
29
|
const appCode = body.stdAction.appCode;
|
|
28
30
|
const parsedAppInfo = await this.crudStdService.getParsedCrudStdAppInfo(appCode);
|
|
29
|
-
|
|
31
|
+
if (parsedAppInfo) {
|
|
32
|
+
const parsedAppInfo2 = { ...parsedAppInfo };
|
|
33
|
+
delete parsedAppInfo2.created_at;
|
|
34
|
+
delete parsedAppInfo2.created_by;
|
|
35
|
+
delete parsedAppInfo2.workbench_code_array;
|
|
36
|
+
delete parsedAppInfo2.modified_at;
|
|
37
|
+
delete parsedAppInfo2.modified_by;
|
|
38
|
+
delete parsedAppInfo2.modified_desc;
|
|
39
|
+
delete parsedAppInfo2.std_crud_db;
|
|
40
|
+
delete parsedAppInfo2.std_crud_tbl;
|
|
41
|
+
return common_dto_1.CommonResult.successNotNull(parsedAppInfo2);
|
|
42
|
+
}
|
|
43
|
+
return common_dto_1.CommonResult.successNotNull(null);
|
|
30
44
|
}
|
|
31
45
|
/**
|
|
32
46
|
* 列表查询: 分页查询
|
|
33
47
|
*/
|
|
34
48
|
async getObjectList() {
|
|
35
|
-
const
|
|
49
|
+
const decodeBody = await this.decodeBodyBySession(this.ctx.request.body);
|
|
50
|
+
const body = decodeBody;
|
|
51
|
+
const { stdAction, ...otherParams } = body;
|
|
36
52
|
stdAction.settingKey = CrudStdService_1.SPECIAL_SETTING_KEY.QUERY_LIST;
|
|
37
53
|
return this.crudStdService.executeStdQuery(stdAction, otherParams, keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
|
|
38
54
|
}
|
|
@@ -40,7 +56,9 @@ let CrudStdGatewayController = class CrudStdGatewayController extends BaseApiCon
|
|
|
40
56
|
* 单个查询
|
|
41
57
|
*/
|
|
42
58
|
async getObjectOne() {
|
|
43
|
-
const
|
|
59
|
+
const decodeBody = await this.decodeBodyBySession(this.ctx.request.body);
|
|
60
|
+
const body = decodeBody;
|
|
61
|
+
const { stdAction, ...otherParams } = body;
|
|
44
62
|
stdAction.settingKey = CrudStdService_1.SPECIAL_SETTING_KEY.QUERY_ONE;
|
|
45
63
|
return this.crudStdService.executeStdQuery(stdAction, otherParams, keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE);
|
|
46
64
|
}
|
|
@@ -48,28 +66,36 @@ let CrudStdGatewayController = class CrudStdGatewayController extends BaseApiCon
|
|
|
48
66
|
* 单个删除
|
|
49
67
|
*/
|
|
50
68
|
async deleteObject() {
|
|
51
|
-
const
|
|
69
|
+
const decodeBody = await this.decodeBodyBySession(this.ctx.request.body);
|
|
70
|
+
const body = decodeBody;
|
|
71
|
+
const { stdAction, ...otherParams } = body;
|
|
52
72
|
return this.crudStdService.executeStdQuery(stdAction, otherParams, keys_1.KeysOfSimpleSQL.SIMPLE_DELETE);
|
|
53
73
|
}
|
|
54
74
|
/**
|
|
55
75
|
* 单个创建
|
|
56
76
|
*/
|
|
57
77
|
async createObject() {
|
|
58
|
-
const
|
|
78
|
+
const decodeBody = await this.decodeBodyBySession(this.ctx.request.body);
|
|
79
|
+
const body = decodeBody;
|
|
80
|
+
const { stdAction, ...otherParams } = body;
|
|
59
81
|
return this.crudStdService.executeStdQuery(stdAction, otherParams, keys_1.KeysOfSimpleSQL.SIMPLE_INSERT);
|
|
60
82
|
}
|
|
61
83
|
/**
|
|
62
84
|
* 单个更新
|
|
63
85
|
*/
|
|
64
86
|
async updateObject() {
|
|
65
|
-
const
|
|
87
|
+
const decodeBody = await this.decodeBodyBySession(this.ctx.request.body);
|
|
88
|
+
const body = decodeBody;
|
|
89
|
+
const { stdAction, ...otherParams } = body;
|
|
66
90
|
return this.crudStdService.executeStdQuery(stdAction, otherParams, keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE);
|
|
67
91
|
}
|
|
68
92
|
/**
|
|
69
93
|
* 执行操作
|
|
70
94
|
*/
|
|
71
95
|
async executeStdAction() {
|
|
72
|
-
const
|
|
96
|
+
const decodeBody = await this.decodeBodyBySession(this.ctx.request.body);
|
|
97
|
+
const body = decodeBody;
|
|
98
|
+
const { stdAction, ...otherParams } = body;
|
|
73
99
|
return await this.crudStdService.executeStdActionByReq(stdAction, otherParams);
|
|
74
100
|
}
|
|
75
101
|
};
|
|
@@ -124,6 +150,6 @@ __decorate([
|
|
|
124
150
|
__metadata("design:returntype", Promise)
|
|
125
151
|
], CrudStdGatewayController.prototype, "executeStdAction", null);
|
|
126
152
|
CrudStdGatewayController = __decorate([
|
|
127
|
-
(0, core_1.Controller)('/ns/gw/api/crudStd')
|
|
153
|
+
(0, core_1.Controller)('/ns/gw/api/crudStd', { middleware: [(0, permission_middleware_1.checkLogin)()] })
|
|
128
154
|
], CrudStdGatewayController);
|
|
129
155
|
exports.CrudStdGatewayController = CrudStdGatewayController;
|
|
@@ -22,6 +22,7 @@ const FileCenterService_1 = require("../../service/FileCenterService");
|
|
|
22
22
|
const permission_middleware_1 = require("../../middleware/permission.middleware");
|
|
23
23
|
const common_dto_1 = require("../../libs/utils/common-dto");
|
|
24
24
|
const SystemPerm_1 = require("../../models/SystemPerm");
|
|
25
|
+
const format_url_1 = require("../../libs/utils/format-url");
|
|
25
26
|
function isTrue(obj) {
|
|
26
27
|
return obj === true || obj === 'true';
|
|
27
28
|
}
|
|
@@ -48,7 +49,7 @@ let FileController = class FileController extends BaseApiController_1.BaseApiCon
|
|
|
48
49
|
throw new devops_1.BizException(`仅支持 ${Object.keys(bizmodels_1.AccessType).join('、')} 上传模式`);
|
|
49
50
|
}
|
|
50
51
|
const { fileKey, filename, storageUrl } = await this.fileCenterService.uploadFileToOSS(files, accessType, referer);
|
|
51
|
-
const origin = this.ctx.request.origin;
|
|
52
|
+
const origin = (0, format_url_1.formatHost)(this.ctx.request.origin);
|
|
52
53
|
const downloadUrls = (0, FileCenterService_1.toDownloadPaths)(origin, fileKey);
|
|
53
54
|
const data = {
|
|
54
55
|
fileKey,
|
|
@@ -21,6 +21,11 @@ const functions_1 = require("../../libs/utils/functions");
|
|
|
21
21
|
const WorkbenchService_1 = require("../../service/WorkbenchService");
|
|
22
22
|
const SystemPerm_1 = require("../../models/SystemPerm");
|
|
23
23
|
const keys_2 = require("../../libs/crud-pro/models/keys");
|
|
24
|
+
const CacheServiceFactory_1 = require("../../service/base/cache/CacheServiceFactory");
|
|
25
|
+
const md5 = require("md5");
|
|
26
|
+
const SystemEntities_1 = require("../../models/SystemEntities");
|
|
27
|
+
const DEFAULT_CACHE_LEVEL = SystemEntities_1.CacheLevelEnum.MEMORY;
|
|
28
|
+
const DEFAULT_CACHE_SECOND = 60 * 5;
|
|
24
29
|
/**
|
|
25
30
|
* 公开的API,无需鉴权,所有人可以直接访问
|
|
26
31
|
*/
|
|
@@ -49,32 +54,42 @@ let PublicApiController = class PublicApiController extends BaseApiController_1.
|
|
|
49
54
|
if (!workbenchMenuCode) {
|
|
50
55
|
return common_dto_1.CommonResult.errorRes('param workbenchMenuCode is null');
|
|
51
56
|
}
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
57
|
+
const { publicApiMenuCacheLevel, publicApiMenuCacheSecond } = this.ctx.workbenchInfoTools.getWorkbenchConfig();
|
|
58
|
+
const mapResult = await this.cacheServiceFactory.getJsonObjectCache({
|
|
59
|
+
cacheLevel: publicApiMenuCacheLevel || DEFAULT_CACHE_LEVEL,
|
|
60
|
+
cacheKey: "" + workbenchMenuCode,
|
|
61
|
+
cacheSecond: publicApiMenuCacheSecond || DEFAULT_CACHE_SECOND,
|
|
62
|
+
cacheName: SystemEntities_1.CacheNameEnum.GetWorkbenchMenu,
|
|
63
|
+
getter: async () => {
|
|
64
|
+
const workbenchMenuCodeStr = '' + workbenchMenuCode;
|
|
65
|
+
const workbenchMenuCodeArray = workbenchMenuCodeStr.split(',');
|
|
66
|
+
const condition = {
|
|
67
|
+
menu_code: {
|
|
68
|
+
$in: workbenchMenuCodeArray,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
const rows = await this.sysDBUtil.getList({ condition }, SystemTables_1.SystemTables.sys_menus);
|
|
72
|
+
const map = {};
|
|
73
|
+
for (let i = 0; i < rows.length; i++) {
|
|
74
|
+
const rowElement = rows[i];
|
|
75
|
+
const menu_code = rowElement.menu_code;
|
|
76
|
+
const view_auth_config = rowElement.view_auth_config;
|
|
77
|
+
const view_auth_type = rowElement.view_auth_type;
|
|
78
|
+
const hasPermission = this.ctx.userSession.isAuthPass(view_auth_type, view_auth_config);
|
|
79
|
+
const menu_config_content = rowElement.menu_config_content;
|
|
80
|
+
delete rowElement.menu_config_content;
|
|
81
|
+
const menu_list = (0, functions_1.parseJsonObject)(menu_config_content) || [];
|
|
82
|
+
map[menu_code] = { ...rowElement, menu_list, hasPermission };
|
|
83
|
+
}
|
|
84
|
+
// 特殊的devops菜单
|
|
85
|
+
map['devops'] = {
|
|
86
|
+
menu_list: [],
|
|
87
|
+
hasPermission: this.ctx.userSession.isAuthPass(keys_2.KeysOfAuthType.byRoleCode, [SystemPerm_1.SystemRoleCode.DevOpsWriter, SystemPerm_1.SystemRoleCode.DevOpsViewer, SystemPerm_1.SystemRoleCode.SuperAdmin]),
|
|
88
|
+
};
|
|
89
|
+
return map;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return common_dto_1.CommonResult.successRes(mapResult);
|
|
78
93
|
}
|
|
79
94
|
/**
|
|
80
95
|
* 获取页面信息
|
|
@@ -83,14 +98,31 @@ let PublicApiController = class PublicApiController extends BaseApiController_1.
|
|
|
83
98
|
const body = this.ctx.request.body;
|
|
84
99
|
const { workbenchCode, appCode, pathname } = body;
|
|
85
100
|
const resultData = {};
|
|
86
|
-
const
|
|
101
|
+
const getOneImpl = async (condition, tableName) => {
|
|
87
102
|
const values = Object.values(condition).filter(Boolean);
|
|
88
103
|
// 查询条件不能为空
|
|
89
104
|
if (values.length > 0) {
|
|
90
|
-
const oneData = await this.sysDBUtil.getOne({ condition },
|
|
105
|
+
const oneData = await this.sysDBUtil.getOne({ condition }, tableName);
|
|
91
106
|
if (oneData && oneData['app_schema']) {
|
|
92
107
|
oneData['app_schema'] = (0, functions_1.parseJsonObject)(oneData['app_schema']);
|
|
93
108
|
}
|
|
109
|
+
return oneData;
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
};
|
|
113
|
+
const { publicApiNavPageInfoCacheLevel, publicApiNavPageInfoCacheSecond } = this.ctx.workbenchInfoTools.getWorkbenchConfig();
|
|
114
|
+
const getOne = async (condition, tableName, key) => {
|
|
115
|
+
const cacheKey = md5(tableName + ':' + JSON.stringify(condition) + ":" + key);
|
|
116
|
+
const oneData = await this.cacheServiceFactory.getJsonObjectCache({
|
|
117
|
+
cacheLevel: publicApiNavPageInfoCacheLevel || DEFAULT_CACHE_LEVEL,
|
|
118
|
+
cacheSecond: publicApiNavPageInfoCacheSecond || DEFAULT_CACHE_SECOND,
|
|
119
|
+
cacheKey,
|
|
120
|
+
cacheName: SystemEntities_1.CacheNameEnum.GetNavPageInfo,
|
|
121
|
+
getter: async () => {
|
|
122
|
+
return await getOneImpl(condition, tableName);
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
if (oneData) {
|
|
94
126
|
resultData[key] = oneData;
|
|
95
127
|
}
|
|
96
128
|
};
|
|
@@ -143,6 +175,10 @@ __decorate([
|
|
|
143
175
|
(0, core_1.Inject)(),
|
|
144
176
|
__metadata("design:type", WorkbenchService_1.WorkbenchService)
|
|
145
177
|
], PublicApiController.prototype, "workbenchService", void 0);
|
|
178
|
+
__decorate([
|
|
179
|
+
(0, core_1.Inject)(),
|
|
180
|
+
__metadata("design:type", CacheServiceFactory_1.CacheServiceFactory)
|
|
181
|
+
], PublicApiController.prototype, "cacheServiceFactory", void 0);
|
|
146
182
|
__decorate([
|
|
147
183
|
(0, core_1.Get)('/getAllWorkbenchInfoList'),
|
|
148
184
|
__metadata("design:type", Function),
|
package/dist/index.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export * from './service/anyapi/AnyApiSandboxService';
|
|
|
54
54
|
export * from './service/anyapi/AnyApiService';
|
|
55
55
|
export * from './service/base/ApiBaseService';
|
|
56
56
|
export * from './service/base/BaseService';
|
|
57
|
-
export * from './service/base/
|
|
57
|
+
export * from './service/base/cache/FatcmsBaseRedisCache';
|
|
58
58
|
export * from './service/crudstd/CrudStdActionService';
|
|
59
59
|
export * from './service/crudstd/CrudStdRelationService';
|
|
60
60
|
export * from './service/crudstd/CrudStdService';
|
package/dist/index.js
CHANGED
|
@@ -72,7 +72,7 @@ __exportStar(require("./service/anyapi/AnyApiSandboxService"), exports);
|
|
|
72
72
|
__exportStar(require("./service/anyapi/AnyApiService"), exports);
|
|
73
73
|
__exportStar(require("./service/base/ApiBaseService"), exports);
|
|
74
74
|
__exportStar(require("./service/base/BaseService"), exports);
|
|
75
|
-
__exportStar(require("./service/base/
|
|
75
|
+
__exportStar(require("./service/base/cache/FatcmsBaseRedisCache"), exports);
|
|
76
76
|
__exportStar(require("./service/crudstd/CrudStdActionService"), exports);
|
|
77
77
|
__exportStar(require("./service/crudstd/CrudStdRelationService"), exports);
|
|
78
78
|
__exportStar(require("./service/crudstd/CrudStdService"), exports);
|
package/dist/interface.d.ts
CHANGED
|
@@ -3,11 +3,13 @@ import { Transaction } from './libs/crud-pro/models/Transaction';
|
|
|
3
3
|
import { UserSessionInfo } from './models/userSession';
|
|
4
4
|
import { ContextLogger } from './models/contextLogger';
|
|
5
5
|
import { IWorkbenchEntity } from './models/SystemEntities';
|
|
6
|
+
import { WorkbenchInfoTools } from './models/WorkbenchInfoTools';
|
|
6
7
|
declare module '@midwayjs/core' {
|
|
7
8
|
interface Context {
|
|
8
9
|
transaction: Transaction;
|
|
9
10
|
userSession: UserSessionInfo;
|
|
10
11
|
workbenchInfo: IWorkbenchEntity;
|
|
12
|
+
workbenchInfoTools: WorkbenchInfoTools;
|
|
11
13
|
contextLogger: ContextLogger;
|
|
12
14
|
}
|
|
13
15
|
}
|
|
@@ -44,6 +44,8 @@ export declare enum Exceptions {
|
|
|
44
44
|
CFG_PARSE_ERROR = "CFG_PARSE_ERROR",
|
|
45
45
|
CFG_ERROR_POSTGRES_UNIQUE_COLUMNS_NULL = "CFG_ERROR_POSTGRES_UNIQUE_COLUMNS_NULL",
|
|
46
46
|
CFG_UNIQUE_COLUMN_COUNT_MUST_ONE = "CFG_UNIQUE_COLUMN_COUNT_MUST_ONE",
|
|
47
|
+
CFG_ORDER_BY_TYPE_ERROR = "CFG_ORDER_BY_TYPE_ERROR",
|
|
48
|
+
CFG_ERROR_POSTGRES_COLUMN_NAME_INVALID = "CFG_ERROR_POSTGRES_COLUMN_NAME_INVALID",
|
|
47
49
|
/**
|
|
48
50
|
* 数据传错
|
|
49
51
|
*/
|
|
@@ -48,6 +48,8 @@ var Exceptions;
|
|
|
48
48
|
Exceptions["CFG_PARSE_ERROR"] = "CFG_PARSE_ERROR";
|
|
49
49
|
Exceptions["CFG_ERROR_POSTGRES_UNIQUE_COLUMNS_NULL"] = "CFG_ERROR_POSTGRES_UNIQUE_COLUMNS_NULL";
|
|
50
50
|
Exceptions["CFG_UNIQUE_COLUMN_COUNT_MUST_ONE"] = "CFG_UNIQUE_COLUMN_COUNT_MUST_ONE";
|
|
51
|
+
Exceptions["CFG_ORDER_BY_TYPE_ERROR"] = "CFG_ORDER_BY_TYPE_ERROR";
|
|
52
|
+
Exceptions["CFG_ERROR_POSTGRES_COLUMN_NAME_INVALID"] = "CFG_ERROR_POSTGRES_COLUMN_NAME_INVALID";
|
|
51
53
|
/**
|
|
52
54
|
* 数据传错
|
|
53
55
|
*/
|
|
@@ -102,7 +102,7 @@ export declare const KeysOfConditions: {
|
|
|
102
102
|
$MATCH: string;
|
|
103
103
|
$MATCH_BOOL: string;
|
|
104
104
|
/**
|
|
105
|
-
* SELECT * FROM
|
|
105
|
+
* SELECT * FROM table WHERE JSON_CONTAINS(`related_user1`, JSON_ARRAY('aaaaa'), '$');
|
|
106
106
|
*/
|
|
107
107
|
$JSON_ARRAY_CONTAINS: string;
|
|
108
108
|
COMPARE_KEYS: Set<string>;
|
|
@@ -116,7 +116,7 @@ exports.KeysOfConditions = {
|
|
|
116
116
|
$MATCH: '$match',
|
|
117
117
|
$MATCH_BOOL: '$matchBool',
|
|
118
118
|
/**
|
|
119
|
-
* SELECT * FROM
|
|
119
|
+
* SELECT * FROM table WHERE JSON_CONTAINS(`related_user1`, JSON_ARRAY('aaaaa'), '$');
|
|
120
120
|
*/
|
|
121
121
|
$JSON_ARRAY_CONTAINS: '$jsonArrayContains',
|
|
122
122
|
COMPARE_KEYS: new Set([]),
|
|
@@ -211,8 +211,13 @@ class CrudProOriginToExecuteSql extends CrudProServiceBase_1.CrudProServiceBase
|
|
|
211
211
|
if (MixinUtils_1.MixinUtils.isEmpty(orderBys)) {
|
|
212
212
|
return null;
|
|
213
213
|
}
|
|
214
|
+
const ORDER_BY_TYPE_ARR = ['asc', 'desc'];
|
|
214
215
|
const orderByArr = orderBys.map(orderBy => {
|
|
215
|
-
|
|
216
|
+
const orderType = (orderBy.orderType || 'asc').toLowerCase();
|
|
217
|
+
if (!ORDER_BY_TYPE_ARR.includes(orderType)) {
|
|
218
|
+
throw new exceptions_1.CommonException(exceptions_1.Exceptions.CFG_ORDER_BY_TYPE_ERROR, 'orderType must be asc or desc : ' + orderType);
|
|
219
|
+
}
|
|
220
|
+
return (0, convertColumnName_1.toSqlColumnName)(orderBy.fieldName, sqlCfgModel) + ' ' + orderType;
|
|
216
221
|
});
|
|
217
222
|
const sql = 'order by ' + orderByArr.join(',');
|
|
218
223
|
return new SqlSegArg_1.SqlSegArg(sql);
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toSqlColumnNamesJoin = exports.toSqlColumnName = void 0;
|
|
4
|
+
const exceptions_1 = require("../../exceptions");
|
|
4
5
|
const keys_1 = require("../../models/keys");
|
|
6
|
+
const COLUMN_NAME_REGEX = /^[a-zA-Z0-9_]+$/;
|
|
7
|
+
function isColumnNameValid(str) {
|
|
8
|
+
if (typeof str !== 'string') {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (str === '') {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return COLUMN_NAME_REGEX.test(str);
|
|
15
|
+
}
|
|
5
16
|
function toSqlColumnName(columnName, sqlCfgModel) {
|
|
17
|
+
if (!isColumnNameValid(columnName)) {
|
|
18
|
+
throw new exceptions_1.CommonException(exceptions_1.Exceptions.CFG_ERROR_POSTGRES_COLUMN_NAME_INVALID, 'column name is invalid : ' + columnName);
|
|
19
|
+
}
|
|
6
20
|
if (sqlCfgModel.sqlDbType === keys_1.SqlDbType.postgres) {
|
|
7
21
|
return '"' + columnName + '"';
|
|
8
22
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
declare class AsymmetricCrypto {
|
|
2
|
+
/**
|
|
3
|
+
* 生成RSA密钥对并返回字符串格式的公钥和私钥
|
|
4
|
+
* @param {number} modulusLength - 密钥长度,默认2048
|
|
5
|
+
* @returns {Promise<{publicKey: string, privateKey: string}>} PEM格式的密钥字符串
|
|
6
|
+
*/
|
|
7
|
+
static generateKeyPair(modulusLength?: number): Promise<{
|
|
8
|
+
publicKey: string;
|
|
9
|
+
privateKey: string;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* 使用公钥加密字符串
|
|
13
|
+
* @param {string} publicKeyPem - PEM格式的公钥字符串
|
|
14
|
+
* @param {string} data - 要加密的字符串数据
|
|
15
|
+
* @returns {Promise<string>} Base64编码的加密字符串
|
|
16
|
+
*/
|
|
17
|
+
static encrypt(publicKeyPem: string, data: string): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* 使用私钥解密字符串
|
|
20
|
+
* @param {string} privateKeyPem - PEM格式的私钥字符串
|
|
21
|
+
* @param {string} encryptedData - Base64编码的加密字符串
|
|
22
|
+
* @returns {Promise<string>} 解密后的原始字符串
|
|
23
|
+
*/
|
|
24
|
+
static decrypt(privateKeyPem: string, encryptedData: string): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* 导入PEM格式的公钥字符串为CryptoKey对象
|
|
27
|
+
* @param {string} publicKeyPem - PEM格式的公钥字符串
|
|
28
|
+
* @returns {Promise<CryptoKey>}
|
|
29
|
+
*/
|
|
30
|
+
static importPublicKey(publicKeyPem: string): Promise<CryptoKey>;
|
|
31
|
+
/**
|
|
32
|
+
* 导入PEM格式的私钥字符串为CryptoKey对象
|
|
33
|
+
* @param {string} privateKeyPem - PEM格式的私钥字符串
|
|
34
|
+
* @returns {Promise<CryptoKey>}
|
|
35
|
+
*/
|
|
36
|
+
static importPrivateKey(privateKeyPem: string): Promise<CryptoKey>;
|
|
37
|
+
/**
|
|
38
|
+
* 获取公钥支持的最大加密长度(字节数)
|
|
39
|
+
* @param {string} publicKeyPem - PEM格式的公钥字符串
|
|
40
|
+
* @returns {number} 最大加密字节数
|
|
41
|
+
*/
|
|
42
|
+
static getMaxEncryptLength(publicKeyPem: string): number;
|
|
43
|
+
/**
|
|
44
|
+
* 将DER格式转换为PEM格式字符串
|
|
45
|
+
* @param {ArrayBuffer} der - DER格式的密钥数据
|
|
46
|
+
* @param {string} type - 密钥类型 ('PUBLIC' 或 'PRIVATE')
|
|
47
|
+
* @returns {string} PEM格式的密钥字符串
|
|
48
|
+
*/
|
|
49
|
+
static derToPem(der: ArrayBuffer, type: 'PUBLIC' | 'PRIVATE'): string;
|
|
50
|
+
/**
|
|
51
|
+
* 将PEM格式字符串转换为DER格式
|
|
52
|
+
* @param {string} pem - PEM格式的密钥字符串
|
|
53
|
+
* @returns {ArrayBuffer} DER格式的密钥数据
|
|
54
|
+
*/
|
|
55
|
+
static pemToDer(pem: string): ArrayBuffer;
|
|
56
|
+
/**
|
|
57
|
+
* ArrayBuffer转Base64字符串
|
|
58
|
+
* @param {ArrayBuffer} buffer
|
|
59
|
+
* @returns {string}
|
|
60
|
+
*/
|
|
61
|
+
static arrayBufferToBase64(buffer: ArrayBuffer): string;
|
|
62
|
+
/**
|
|
63
|
+
* Base64字符串转ArrayBuffer
|
|
64
|
+
* @param {string} base64
|
|
65
|
+
* @returns {ArrayBuffer}
|
|
66
|
+
*/
|
|
67
|
+
static base64ToArrayBuffer(base64: string): ArrayBuffer;
|
|
68
|
+
/**
|
|
69
|
+
* 验证PEM格式的密钥字符串
|
|
70
|
+
* @param {string} pem - PEM格式的密钥字符串
|
|
71
|
+
* @param {'PUBLIC'|'PRIVATE'} expectedType - 期望的密钥类型
|
|
72
|
+
* @returns {boolean} 是否为有效的PEM格式
|
|
73
|
+
*/
|
|
74
|
+
static validatePemFormat(pem: string, expectedType: 'PUBLIC' | 'PRIVATE'): boolean;
|
|
75
|
+
}
|
|
76
|
+
export { AsymmetricCrypto };
|