midway-fatcms 0.0.1-beta.44 → 0.0.1-beta.46
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/controller/gateway/CrudStdGatewayController.js +8 -16
- package/dist/controller/manage/CrudStandardDesignApi.d.ts +8 -0
- package/dist/controller/manage/CrudStandardDesignApi.js +54 -9
- package/dist/libs/global-config/global-config.d.ts +13 -2
- package/dist/libs/global-config/global-config.js +2 -1
- package/dist/libs/utils/functions.js +6 -2
- package/dist/libs/utils/parseCreateSql.d.ts +6 -1
- package/dist/libs/utils/parseCreateSql.js +2 -1
- package/dist/models/bizmodels.d.ts +1 -0
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.js +10 -2
- package/dist/service/crudstd/CrudStdService.d.ts +9 -4
- package/dist/service/crudstd/CrudStdService.js +49 -18
- package/dist/service/curd/CurdMixService.d.ts +3 -2
- package/package.json +1 -1
|
@@ -33,52 +33,44 @@ let CrudStdGatewayController = class CrudStdGatewayController extends BaseApiCon
|
|
|
33
33
|
*/
|
|
34
34
|
async getObjectList() {
|
|
35
35
|
const { stdAction, ...otherParams } = this.ctx.request.body;
|
|
36
|
-
|
|
37
|
-
return this.crudStdService.executeStdQuery(
|
|
36
|
+
stdAction.settingKey = CrudStdService_1.SPECIAL_SETTING_KEY.QUERY_LIST;
|
|
37
|
+
return this.crudStdService.executeStdQuery(stdAction, otherParams, keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* 单个查询
|
|
41
41
|
*/
|
|
42
42
|
async getObjectOne() {
|
|
43
43
|
const { stdAction, ...otherParams } = this.ctx.request.body;
|
|
44
|
-
|
|
45
|
-
return this.crudStdService.executeStdQuery(
|
|
44
|
+
stdAction.settingKey = CrudStdService_1.SPECIAL_SETTING_KEY.QUERY_ONE;
|
|
45
|
+
return this.crudStdService.executeStdQuery(stdAction, otherParams, keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE);
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* 单个删除
|
|
49
49
|
*/
|
|
50
50
|
async deleteObject() {
|
|
51
51
|
const { stdAction, ...otherParams } = this.ctx.request.body;
|
|
52
|
-
|
|
53
|
-
const settingKey = stdAction.settingKey;
|
|
54
|
-
return this.crudStdService.executeStdQuery(appCode, settingKey, otherParams, keys_1.KeysOfSimpleSQL.SIMPLE_DELETE);
|
|
52
|
+
return this.crudStdService.executeStdQuery(stdAction, otherParams, keys_1.KeysOfSimpleSQL.SIMPLE_DELETE);
|
|
55
53
|
}
|
|
56
54
|
/**
|
|
57
55
|
* 单个创建
|
|
58
56
|
*/
|
|
59
57
|
async createObject() {
|
|
60
58
|
const { stdAction, ...otherParams } = this.ctx.request.body;
|
|
61
|
-
|
|
62
|
-
const settingKey = stdAction.settingKey;
|
|
63
|
-
return this.crudStdService.executeStdQuery(appCode, settingKey, otherParams, keys_1.KeysOfSimpleSQL.SIMPLE_INSERT);
|
|
59
|
+
return this.crudStdService.executeStdQuery(stdAction, otherParams, keys_1.KeysOfSimpleSQL.SIMPLE_INSERT);
|
|
64
60
|
}
|
|
65
61
|
/**
|
|
66
62
|
* 单个更新
|
|
67
63
|
*/
|
|
68
64
|
async updateObject() {
|
|
69
65
|
const { stdAction, ...otherParams } = this.ctx.request.body;
|
|
70
|
-
|
|
71
|
-
const settingKey = stdAction.settingKey;
|
|
72
|
-
return this.crudStdService.executeStdQuery(appCode, settingKey, otherParams, keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE);
|
|
66
|
+
return this.crudStdService.executeStdQuery(stdAction, otherParams, keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE);
|
|
73
67
|
}
|
|
74
68
|
/**
|
|
75
69
|
* 执行操作
|
|
76
70
|
*/
|
|
77
71
|
async executeStdAction() {
|
|
78
72
|
const { stdAction, ...otherParams } = this.ctx.request.body;
|
|
79
|
-
|
|
80
|
-
const settingKey = stdAction.settingKey;
|
|
81
|
-
return await this.crudStdService.executeStdActionByReq(appCode, settingKey, otherParams);
|
|
73
|
+
return await this.crudStdService.executeStdActionByReq(stdAction, otherParams);
|
|
82
74
|
}
|
|
83
75
|
};
|
|
84
76
|
__decorate([
|
|
@@ -35,4 +35,12 @@ export declare class CrudStandardDesignApi extends BaseApiController {
|
|
|
35
35
|
private getTableListOfPostgreSQL;
|
|
36
36
|
private getTableFieldsOfSqlServer;
|
|
37
37
|
private getTableFieldsOfPostgreSQL;
|
|
38
|
+
/**
|
|
39
|
+
* 获取PostgreSQL建表语句的注释
|
|
40
|
+
* @param dbName
|
|
41
|
+
* @param schemaname
|
|
42
|
+
* @param tableName
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
private getTableFieldsCommentsMapOfPostgreSQL;
|
|
38
46
|
}
|
|
@@ -254,14 +254,14 @@ let CrudStandardDesignApi = class CrudStandardDesignApi extends BaseApiControlle
|
|
|
254
254
|
throw new exceptions_1.CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
|
|
255
255
|
}
|
|
256
256
|
const schemaname = 'public';
|
|
257
|
-
const columnArraySql = `
|
|
258
|
-
|
|
259
|
-
SELECT
|
|
260
|
-
*
|
|
261
|
-
FROM information_schema.columns
|
|
262
|
-
WHERE table_schema = $1 and table_name = $2
|
|
263
|
-
ORDER BY ordinal_position;
|
|
264
|
-
|
|
257
|
+
const columnArraySql = `
|
|
258
|
+
|
|
259
|
+
SELECT
|
|
260
|
+
*
|
|
261
|
+
FROM information_schema.columns
|
|
262
|
+
WHERE table_schema = $1 and table_name = $2
|
|
263
|
+
ORDER BY ordinal_position;
|
|
264
|
+
|
|
265
265
|
`.trim();
|
|
266
266
|
const dbType = keys_1.SqlDbType.postgres;
|
|
267
267
|
const columnArray = await this.curdMixService.executeSQL({
|
|
@@ -271,11 +271,12 @@ let CrudStandardDesignApi = class CrudStandardDesignApi extends BaseApiControlle
|
|
|
271
271
|
crudType: keys_1.KeyOfCrudTypes.SYS_QUERY,
|
|
272
272
|
executeSqlArgs: [schemaname, tableName],
|
|
273
273
|
});
|
|
274
|
+
const commentMap = await this.getTableFieldsCommentsMapOfPostgreSQL(dbName, schemaname, tableName);
|
|
274
275
|
const fields = columnArray.map(columnObj => {
|
|
275
276
|
const { column_name, is_nullable, column_default, data_type, is_identity, ...others } = columnObj;
|
|
276
277
|
return {
|
|
277
278
|
fieldIndex: column_name || '',
|
|
278
|
-
fieldTitle: column_name || '',
|
|
279
|
+
fieldTitle: commentMap[column_name] || column_name || '',
|
|
279
280
|
isNullable: is_nullable,
|
|
280
281
|
defaultValue: column_default || '',
|
|
281
282
|
extra: others,
|
|
@@ -293,6 +294,50 @@ let CrudStandardDesignApi = class CrudStandardDesignApi extends BaseApiControlle
|
|
|
293
294
|
},
|
|
294
295
|
};
|
|
295
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* 获取PostgreSQL建表语句的注释
|
|
299
|
+
* @param dbName
|
|
300
|
+
* @param schemaname
|
|
301
|
+
* @param tableName
|
|
302
|
+
* @returns
|
|
303
|
+
*/
|
|
304
|
+
async getTableFieldsCommentsMapOfPostgreSQL(dbName, schemaname, tableName) {
|
|
305
|
+
const commentArraySql = `
|
|
306
|
+
SELECT
|
|
307
|
+
n.nspname AS schema_name,
|
|
308
|
+
c.relname AS table_name,
|
|
309
|
+
a.attname AS column_name,
|
|
310
|
+
d.description AS column_comment
|
|
311
|
+
FROM
|
|
312
|
+
pg_class c
|
|
313
|
+
JOIN
|
|
314
|
+
pg_namespace n ON c.relnamespace = n.oid
|
|
315
|
+
JOIN
|
|
316
|
+
pg_attribute a ON c.oid = a.attrelid
|
|
317
|
+
LEFT JOIN
|
|
318
|
+
pg_description d ON c.oid = d.objoid AND a.attnum = d.objsubid
|
|
319
|
+
WHERE
|
|
320
|
+
n.nspname = $1
|
|
321
|
+
AND c.relname = $2
|
|
322
|
+
AND a.attnum > 0
|
|
323
|
+
ORDER BY
|
|
324
|
+
a.attnum
|
|
325
|
+
`;
|
|
326
|
+
const dbType = keys_1.SqlDbType.postgres;
|
|
327
|
+
const commentArray = await this.curdMixService.executeSQL({
|
|
328
|
+
executeSql: commentArraySql,
|
|
329
|
+
sqlDatabase: dbName,
|
|
330
|
+
sqlDbType: dbType,
|
|
331
|
+
crudType: keys_1.KeyOfCrudTypes.SYS_QUERY,
|
|
332
|
+
executeSqlArgs: [schemaname, tableName],
|
|
333
|
+
});
|
|
334
|
+
const map = {};
|
|
335
|
+
commentArray.forEach(commentObj => {
|
|
336
|
+
const { column_name, column_comment } = commentObj;
|
|
337
|
+
map[column_name] = (0, parseCreateSql_1.parseTableFieldTitleFromComment)(column_comment);
|
|
338
|
+
});
|
|
339
|
+
return map;
|
|
340
|
+
}
|
|
296
341
|
};
|
|
297
342
|
__decorate([
|
|
298
343
|
(0, core_1.Config)('mysql2'),
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
+
import { IRequestCfgModel, IRequestModel } from '../crud-pro/interfaces';
|
|
2
|
+
import { ExecuteContext } from '../crud-pro/models/ExecuteContext';
|
|
1
3
|
import { SqlDbType } from '../crud-pro/models/keys';
|
|
4
|
+
import { Context } from '@midwayjs/koa';
|
|
2
5
|
interface IGlobalStaticConfig {
|
|
3
6
|
/**
|
|
4
|
-
* CrudStd:
|
|
7
|
+
* CrudStd: 业务系统自定义的修改:查询前的查询条件:cfgModel
|
|
5
8
|
* @param reqJson
|
|
6
9
|
* @param cfgModel
|
|
7
10
|
* @param appInfo
|
|
8
11
|
* @param ctx
|
|
9
12
|
*/
|
|
10
|
-
bizUpdateCfgModelForCrudStd(reqJson:
|
|
13
|
+
bizUpdateCfgModelForCrudStd(reqJson: IRequestModel, cfgModel: IRequestCfgModel, appInfo: any, ctx: Context): Promise<any>;
|
|
14
|
+
/**
|
|
15
|
+
* CrudStd: 业务系统自定义的修改:查询后的返回值。
|
|
16
|
+
* @param reqJson
|
|
17
|
+
* @param cfgModel
|
|
18
|
+
* @param appInfo
|
|
19
|
+
* @param ctx
|
|
20
|
+
*/
|
|
21
|
+
bizUpdateExecuteContextForCrudStd(reqJson: IRequestModel, cfgModel: IRequestCfgModel, appInfo: any, ctx: Context, executeContext: ExecuteContext): Promise<any>;
|
|
11
22
|
/**
|
|
12
23
|
* CrudMtd: 业务系统自定义的修改cfgModel
|
|
13
24
|
* @param reqJson
|
|
@@ -9,6 +9,7 @@ class GlobalStaticConfig {
|
|
|
9
9
|
constructor() {
|
|
10
10
|
this.configObject = {
|
|
11
11
|
bizUpdateCfgModelForCrudStd: noop,
|
|
12
|
+
bizUpdateExecuteContextForCrudStd: noop,
|
|
12
13
|
bizUpdateCfgModelForCrudMtd: noop,
|
|
13
14
|
bizUpdateCfgModelForCrudPro: noop,
|
|
14
15
|
generateUserAccountId: null,
|
|
@@ -17,7 +18,7 @@ class GlobalStaticConfig {
|
|
|
17
18
|
},
|
|
18
19
|
SystemDbName: 'fatcms',
|
|
19
20
|
SystemDbType: keys_1.SqlDbType.mysql,
|
|
20
|
-
maxPageSizeOfExportExcel: 1000
|
|
21
|
+
maxPageSizeOfExportExcel: 1000,
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
24
|
getConfig() {
|
|
@@ -12,10 +12,14 @@ function createUniqueId() {
|
|
|
12
12
|
}
|
|
13
13
|
exports.createUniqueId = createUniqueId;
|
|
14
14
|
function parseJsonObject(str) {
|
|
15
|
-
|
|
15
|
+
const typeofStr = typeof str;
|
|
16
|
+
if (str === null || typeofStr === 'undefined') {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
if (typeofStr === 'object') {
|
|
16
20
|
return str;
|
|
17
21
|
}
|
|
18
|
-
if (
|
|
22
|
+
if (typeofStr === 'string') {
|
|
19
23
|
str = str.trim();
|
|
20
24
|
if (str.startsWith('{') || str.startsWith('[')) {
|
|
21
25
|
try {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 移除引号
|
|
3
|
+
* @param s
|
|
4
|
+
*/
|
|
5
|
+
declare function parseTableFieldTitleFromComment(s: string): string;
|
|
1
6
|
declare function parseCreateSqlToTitleMap(createSqlStr: string): {
|
|
2
7
|
tableTitle: string;
|
|
3
8
|
fieldsTitleMap: {};
|
|
4
9
|
};
|
|
5
|
-
export { parseCreateSqlToTitleMap };
|
|
10
|
+
export { parseCreateSqlToTitleMap, parseTableFieldTitleFromComment };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCreateSqlToTitleMap = void 0;
|
|
3
|
+
exports.parseTableFieldTitleFromComment = exports.parseCreateSqlToTitleMap = void 0;
|
|
4
4
|
function isChineseChar(char) {
|
|
5
5
|
const reg = /[\u4e00-\u9fff]/;
|
|
6
6
|
return reg.test(char);
|
|
@@ -34,6 +34,7 @@ function parseTableFieldTitleFromComment(s) {
|
|
|
34
34
|
}
|
|
35
35
|
return arr.join('');
|
|
36
36
|
}
|
|
37
|
+
exports.parseTableFieldTitleFromComment = parseTableFieldTitleFromComment;
|
|
37
38
|
/**
|
|
38
39
|
* 从最后一行中提取表格的标题
|
|
39
40
|
* @param arr
|
|
@@ -90,7 +90,11 @@ class ExportExcelByStdCrudHandler {
|
|
|
90
90
|
this.ctx.innerHeaders = {};
|
|
91
91
|
}
|
|
92
92
|
Object.assign(this.ctx.innerHeaders, this.inputParams.headers || {});
|
|
93
|
-
const
|
|
93
|
+
const stdAction = {
|
|
94
|
+
appCode: appCode,
|
|
95
|
+
settingKey: CrudStdService_1.SPECIAL_SETTING_KEY.QUERY_LIST,
|
|
96
|
+
};
|
|
97
|
+
const a = await crudStdService.executeStdQuery(stdAction, params, keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
|
|
94
98
|
return pickData(a, 'total_count');
|
|
95
99
|
}
|
|
96
100
|
/**
|
|
@@ -116,7 +120,11 @@ class ExportExcelByStdCrudHandler {
|
|
|
116
120
|
$in: selectedRowKeys,
|
|
117
121
|
};
|
|
118
122
|
}
|
|
119
|
-
const
|
|
123
|
+
const stdAction = {
|
|
124
|
+
appCode: appCode,
|
|
125
|
+
settingKey: CrudStdService_1.SPECIAL_SETTING_KEY.QUERY_LIST,
|
|
126
|
+
};
|
|
127
|
+
const a = await crudStdService.executeStdQuery(stdAction, params, keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
|
|
120
128
|
return pickData(a, 'rows');
|
|
121
129
|
}
|
|
122
130
|
}
|
|
@@ -11,6 +11,11 @@ export declare const SPECIAL_SETTING_KEY: {
|
|
|
11
11
|
QUERY_LIST: string;
|
|
12
12
|
QUERY_ONE: string;
|
|
13
13
|
};
|
|
14
|
+
export interface ICrudStdActionParams {
|
|
15
|
+
appCode: string;
|
|
16
|
+
settingKey?: string;
|
|
17
|
+
buttonSettingKey?: string;
|
|
18
|
+
}
|
|
14
19
|
export declare class CrudStdService extends ApiBaseService {
|
|
15
20
|
protected ctx: Context;
|
|
16
21
|
protected curdMixService: CurdMixService;
|
|
@@ -19,7 +24,7 @@ export declare class CrudStdService extends ApiBaseService {
|
|
|
19
24
|
/**
|
|
20
25
|
* 执行普通CRUD
|
|
21
26
|
*/
|
|
22
|
-
executeStdQuery(
|
|
27
|
+
executeStdQuery(stdAction: ICrudStdActionParams, params: IRequestModel, sqlSimpleName: KeysOfSimpleSQL): Promise<ExecuteContext>;
|
|
23
28
|
/**
|
|
24
29
|
* 获取appInfo 并且拿到当前settingKey相关的信息
|
|
25
30
|
* @param appCode
|
|
@@ -29,11 +34,10 @@ export declare class CrudStdService extends ApiBaseService {
|
|
|
29
34
|
private getParsedCrudStdAppForSettingKey;
|
|
30
35
|
/**
|
|
31
36
|
* 执行动作
|
|
32
|
-
* @param
|
|
33
|
-
* @param settingKey
|
|
37
|
+
* @param stdAction
|
|
34
38
|
* @param params
|
|
35
39
|
*/
|
|
36
|
-
executeStdActionByReq(
|
|
40
|
+
executeStdActionByReq(stdAction: ICrudStdActionParams, params: IRequestModel): Promise<ExecuteContext>;
|
|
37
41
|
/**
|
|
38
42
|
* 查询APP信息
|
|
39
43
|
* @param appCode
|
|
@@ -53,5 +57,6 @@ export declare class CrudStdService extends ApiBaseService {
|
|
|
53
57
|
*/
|
|
54
58
|
private getParsedCrudStdAppInfoPrivate;
|
|
55
59
|
private hasOperationPerm;
|
|
60
|
+
private fixSubmitDataByKeepSubmitData;
|
|
56
61
|
private fixDataFieldTypeBySqlTableField;
|
|
57
62
|
}
|
|
@@ -10,6 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CrudStdService = exports.SPECIAL_SETTING_KEY = void 0;
|
|
13
|
+
/* eslint-disable prettier/prettier */
|
|
13
14
|
const _ = require("lodash");
|
|
14
15
|
const core_1 = require("@midwayjs/core");
|
|
15
16
|
const CurdMixService_1 = require("../curd/CurdMixService");
|
|
@@ -27,7 +28,8 @@ exports.SPECIAL_SETTING_KEY = {
|
|
|
27
28
|
QUERY_LIST: 'QUERY_LIST',
|
|
28
29
|
QUERY_ONE: 'QUERY_ONE',
|
|
29
30
|
};
|
|
30
|
-
function getExecuteTableNameBySettingKey(appInfo,
|
|
31
|
+
function getExecuteTableNameBySettingKey(appInfo, stdAction) {
|
|
32
|
+
const { settingKey } = stdAction || {};
|
|
31
33
|
const stdCrudCfgObj = appInfo.stdCrudCfgObj;
|
|
32
34
|
const actionsMap = appInfo.actionsMap || {};
|
|
33
35
|
const actionCfg = actionsMap[settingKey];
|
|
@@ -43,8 +45,9 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
43
45
|
/**
|
|
44
46
|
* 执行普通CRUD
|
|
45
47
|
*/
|
|
46
|
-
async executeStdQuery(
|
|
47
|
-
const
|
|
48
|
+
async executeStdQuery(stdAction, params, sqlSimpleName) {
|
|
49
|
+
const appCode = stdAction.appCode;
|
|
50
|
+
const appInfo = await this.getParsedCrudStdAppForSettingKey(stdAction);
|
|
48
51
|
const stdCrudCfgObj = appInfo.stdCrudCfgObj;
|
|
49
52
|
if (!appInfo || appInfo.status !== 1) {
|
|
50
53
|
throw new devops_1.BizException('应用不存在或已下线:' + appCode);
|
|
@@ -54,7 +57,7 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
54
57
|
const cfgModel = {
|
|
55
58
|
sqlDatabase: dbName,
|
|
56
59
|
sqlDbType: dbType,
|
|
57
|
-
sqlTable: getExecuteTableNameBySettingKey(appInfo,
|
|
60
|
+
sqlTable: getExecuteTableNameBySettingKey(appInfo, stdAction),
|
|
58
61
|
sqlSimpleName,
|
|
59
62
|
};
|
|
60
63
|
// 接口返回最大值
|
|
@@ -67,11 +70,16 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
67
70
|
}
|
|
68
71
|
// 根据用户配置,设置关联查询的数据信息。
|
|
69
72
|
await this.crudStdRelationService.addCfgModelColumnsRelation(cfgModel, appInfo);
|
|
73
|
+
// 根据用户配置的keepSubmitData字段修改提交的数据
|
|
74
|
+
await this.fixSubmitDataByKeepSubmitData(params, cfgModel, appInfo, { dbType, dbName });
|
|
70
75
|
// 根据表结构的数据类型,修正数据类型
|
|
71
76
|
await this.fixDataFieldTypeBySqlTableField(params, cfgModel, appInfo, { dbType, dbName });
|
|
72
|
-
//
|
|
77
|
+
// 业务系统自定义的修改:查询前的查询条件:cfgModel
|
|
73
78
|
await global_config_1.GLOBAL_STATIC_CONFIG.getConfig().bizUpdateCfgModelForCrudStd(params, cfgModel, appInfo, this.ctx);
|
|
74
|
-
|
|
79
|
+
const crudExeCtx = await this.curdMixService.executeCrudByCfg(params, cfgModel);
|
|
80
|
+
// 业务系统自定义的修改:查询后的返回值。
|
|
81
|
+
await global_config_1.GLOBAL_STATIC_CONFIG.getConfig().bizUpdateExecuteContextForCrudStd(params, cfgModel, appInfo, this.ctx, crudExeCtx);
|
|
82
|
+
return crudExeCtx;
|
|
75
83
|
}
|
|
76
84
|
/**
|
|
77
85
|
* 获取appInfo 并且拿到当前settingKey相关的信息
|
|
@@ -79,7 +87,8 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
79
87
|
* @param settingKey
|
|
80
88
|
* @private
|
|
81
89
|
*/
|
|
82
|
-
async getParsedCrudStdAppForSettingKey(
|
|
90
|
+
async getParsedCrudStdAppForSettingKey(stdAction) {
|
|
91
|
+
const { appCode, settingKey, buttonSettingKey } = stdAction || {};
|
|
83
92
|
if (!appCode) {
|
|
84
93
|
throw new devops_1.BizException('缺少参数:curdStdAppCode');
|
|
85
94
|
}
|
|
@@ -107,18 +116,20 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
107
116
|
}
|
|
108
117
|
appInfo.settingKeyActionCfg = actionCfg;
|
|
109
118
|
}
|
|
119
|
+
if (buttonSettingKey) {
|
|
120
|
+
appInfo.buttonSettingKeyActionCfg = actionsMap[buttonSettingKey];
|
|
121
|
+
}
|
|
110
122
|
return appInfo;
|
|
111
123
|
}
|
|
112
124
|
/**
|
|
113
125
|
* 执行动作
|
|
114
|
-
* @param
|
|
115
|
-
* @param settingKey
|
|
126
|
+
* @param stdAction
|
|
116
127
|
* @param params
|
|
117
128
|
*/
|
|
118
|
-
async executeStdActionByReq(
|
|
119
|
-
const appInfo = await this.getParsedCrudStdAppForSettingKey(
|
|
129
|
+
async executeStdActionByReq(stdAction, params) {
|
|
130
|
+
const appInfo = await this.getParsedCrudStdAppForSettingKey(stdAction);
|
|
120
131
|
if (!appInfo || appInfo.status !== 1) {
|
|
121
|
-
throw new devops_1.BizException('应用不存在或已下线:' + appCode);
|
|
132
|
+
throw new devops_1.BizException('应用不存在或已下线:' + stdAction.appCode);
|
|
122
133
|
}
|
|
123
134
|
const actionsMap = appInfo.actionsMap;
|
|
124
135
|
const actionCfg = appInfo.settingKeyActionCfg;
|
|
@@ -167,12 +178,7 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
167
178
|
}
|
|
168
179
|
const { app_schema, ...others } = row;
|
|
169
180
|
const stdCrudCfgObj = (0, functions_1.parseJsonObject)(app_schema);
|
|
170
|
-
|
|
171
|
-
const actionsMap = {};
|
|
172
|
-
const keys = Object.keys(stdCrudCfgObj);
|
|
173
|
-
for (let i = 0; i < keys.length; i++) {
|
|
174
|
-
const key = keys[i];
|
|
175
|
-
const arrayCfg = stdCrudCfgObj[key];
|
|
181
|
+
const handleArrayCfg = (arrayCfg) => {
|
|
176
182
|
if (Array.isArray(arrayCfg)) {
|
|
177
183
|
for (let j = 0; j < arrayCfg.length; j++) {
|
|
178
184
|
const actionCfg = arrayCfg[j];
|
|
@@ -180,8 +186,18 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
180
186
|
if (actionCfg.settingKey) {
|
|
181
187
|
actionsMap[actionCfg.settingKey] = actionCfg;
|
|
182
188
|
}
|
|
189
|
+
const submitButtonCfg = _.get(actionCfg, 'component.props.submitButtonCfg');
|
|
190
|
+
handleArrayCfg(submitButtonCfg);
|
|
183
191
|
}
|
|
184
192
|
}
|
|
193
|
+
};
|
|
194
|
+
// 为了方便查找到action对象
|
|
195
|
+
const actionsMap = {};
|
|
196
|
+
const keys = Object.keys(stdCrudCfgObj);
|
|
197
|
+
for (let i = 0; i < keys.length; i++) {
|
|
198
|
+
const key = keys[i];
|
|
199
|
+
const arrayCfg = stdCrudCfgObj[key];
|
|
200
|
+
handleArrayCfg(arrayCfg);
|
|
185
201
|
}
|
|
186
202
|
return { ...others, stdCrudCfgObj, actionsMap };
|
|
187
203
|
}
|
|
@@ -192,6 +208,21 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
192
208
|
}
|
|
193
209
|
return true; // 无需鉴权
|
|
194
210
|
}
|
|
211
|
+
async fixSubmitDataByKeepSubmitData(params, cfgModel, appInfo, arg3) {
|
|
212
|
+
if (cfgModel.sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT || cfgModel.sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE) {
|
|
213
|
+
const submitData = params.data || {};
|
|
214
|
+
//1. 按钮中配置的keepSubmitData
|
|
215
|
+
const buttonActionCfg = appInfo.buttonSettingKeyActionCfg || {};
|
|
216
|
+
const keepSubmitDataByButtonStr = _.get(buttonActionCfg, 'keepSubmitData');
|
|
217
|
+
const keepSubmitDataByButton = (0, functions_1.parseJsonObject)(keepSubmitDataByButtonStr);
|
|
218
|
+
//2. 全局配置的keepSubmitData
|
|
219
|
+
const keepSubmitDataByGlobalStr = _.get(appInfo, 'stdCrudCfgObj.othersSetting.values.keepSubmitData');
|
|
220
|
+
const keepSubmitDataByGlobal = (0, functions_1.parseJsonObject)(keepSubmitDataByGlobalStr);
|
|
221
|
+
//3. 合并
|
|
222
|
+
Object.assign(submitData, keepSubmitDataByButton);
|
|
223
|
+
Object.assign(submitData, keepSubmitDataByGlobal);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
195
226
|
async fixDataFieldTypeBySqlTableField(params, cfgModel, appInfo, arg3) {
|
|
196
227
|
const tableFields = _.get(appInfo, 'stdCrudCfgObj.tableFields');
|
|
197
228
|
const tableFieldMap = MixinUtils_1.MixinUtils.toMap(tableFields, (e) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ColumnRelation, IRequestCfgModel, IRequestModel, ISqlCfgModel } from '../../libs/crud-pro/interfaces';
|
|
2
2
|
import { IRequestCfgModel2 } from '../../models/bizmodels';
|
|
3
3
|
import { SqlDbType } from '../../libs/crud-pro/models/keys';
|
|
4
|
+
import { ExecuteContext } from '../../libs/crud-pro/models/ExecuteContext';
|
|
4
5
|
export interface ILinkColumnRelationParam {
|
|
5
6
|
columnsRelations: ColumnRelation[];
|
|
6
7
|
}
|
|
@@ -12,10 +13,10 @@ export declare class CurdMixService {
|
|
|
12
13
|
private curdMixByWorkbenchService;
|
|
13
14
|
private curdMixByLinkToCustomService;
|
|
14
15
|
private prepare;
|
|
15
|
-
executeCrudByCfg(reqJson: IRequestModel, cfgModel: IRequestCfgModel2): Promise<
|
|
16
|
+
executeCrudByCfg(reqJson: IRequestModel, cfgModel: IRequestCfgModel2): Promise<ExecuteContext>;
|
|
16
17
|
getBbUtil(sqlDatabase: string, sqlDbType: SqlDbType, sqlTable?: string): import("./CrudProQuick").CrudProQuick;
|
|
17
18
|
executeSQL(sqlCfgModel: ISqlCfgModel): Promise<any>;
|
|
18
|
-
executeCrud(reqJson: IRequestModel): Promise<
|
|
19
|
+
executeCrud(reqJson: IRequestModel): Promise<ExecuteContext>;
|
|
19
20
|
getCachedCfgByMethod(method: string): Promise<IRequestCfgModel>;
|
|
20
21
|
/**
|
|
21
22
|
* 根据配置的关联关系,直接关联数据
|