midway-fatcms 0.0.1-beta.57 → 0.0.1-beta.58
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.
|
@@ -29,17 +29,27 @@ exports.SPECIAL_SETTING_KEY = {
|
|
|
29
29
|
QUERY_LIST: 'QUERY_LIST',
|
|
30
30
|
QUERY_ONE: 'QUERY_ONE',
|
|
31
31
|
};
|
|
32
|
+
function isNotEmptyStr(str) {
|
|
33
|
+
return typeof str === 'string' && str.trim().length > 0;
|
|
34
|
+
}
|
|
32
35
|
function getExecuteTableNameBySettingKey(appInfo, stdAction) {
|
|
33
36
|
const { settingKey } = stdAction || {};
|
|
34
37
|
const stdCrudCfgObj = appInfo.stdCrudCfgObj;
|
|
35
38
|
const actionsMap = appInfo.actionsMap || {};
|
|
39
|
+
// 操作按钮单独设置了mainTableName字段
|
|
36
40
|
const actionCfg = actionsMap[settingKey];
|
|
37
41
|
if (actionCfg) {
|
|
38
42
|
const mainTableName = _.get(actionCfg, 'component.props.mainTableName');
|
|
39
|
-
if (
|
|
43
|
+
if (isNotEmptyStr(mainTableName)) {
|
|
40
44
|
return mainTableName.trim();
|
|
41
45
|
}
|
|
42
46
|
}
|
|
47
|
+
// 全局配置了mainTableName字段
|
|
48
|
+
const globalMainTableName = _.get(stdCrudCfgObj, 'othersSetting.values.globalMainTableName');
|
|
49
|
+
if (isNotEmptyStr(globalMainTableName)) {
|
|
50
|
+
return globalMainTableName.trim();
|
|
51
|
+
}
|
|
52
|
+
// 视图中配置的表。
|
|
43
53
|
return stdCrudCfgObj.tableBaseInfo.tableName;
|
|
44
54
|
}
|
|
45
55
|
let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseService {
|
package/package.json
CHANGED
|
@@ -36,6 +36,9 @@ export interface IRequestModelCrudProExt extends IRequestModel {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
|
|
39
|
+
function isNotEmptyStr(str: any): boolean {
|
|
40
|
+
return typeof str === 'string' && str.trim().length > 0;
|
|
41
|
+
}
|
|
39
42
|
|
|
40
43
|
function getExecuteTableNameBySettingKey(appInfo: ICrudStdAppInfoForSettingKey, stdAction: ICrudStdActionParams): string {
|
|
41
44
|
const { settingKey } = stdAction || {};
|
|
@@ -43,14 +46,23 @@ function getExecuteTableNameBySettingKey(appInfo: ICrudStdAppInfoForSettingKey,
|
|
|
43
46
|
const stdCrudCfgObj = appInfo.stdCrudCfgObj;
|
|
44
47
|
const actionsMap = appInfo.actionsMap || {};
|
|
45
48
|
|
|
49
|
+
|
|
50
|
+
// 操作按钮单独设置了mainTableName字段
|
|
46
51
|
const actionCfg = actionsMap[settingKey];
|
|
47
52
|
if (actionCfg) {
|
|
48
53
|
const mainTableName = _.get(actionCfg, 'component.props.mainTableName');
|
|
49
|
-
if (
|
|
54
|
+
if (isNotEmptyStr(mainTableName)) {
|
|
50
55
|
return mainTableName.trim();
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
58
|
|
|
59
|
+
// 全局配置了mainTableName字段
|
|
60
|
+
const globalMainTableName: string = _.get(stdCrudCfgObj, 'othersSetting.values.globalMainTableName');
|
|
61
|
+
if (isNotEmptyStr(globalMainTableName)) {
|
|
62
|
+
return globalMainTableName.trim();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 视图中配置的表。
|
|
54
66
|
return stdCrudCfgObj.tableBaseInfo.tableName;
|
|
55
67
|
}
|
|
56
68
|
|
|
@@ -342,16 +354,16 @@ export class CrudStdService extends ApiBaseService {
|
|
|
342
354
|
const stdCrudCfgObj = appInfo.stdCrudCfgObj;
|
|
343
355
|
//删除策略
|
|
344
356
|
const deleteStrategy = _.get(stdCrudCfgObj, 'othersSetting.values.deleteStrategy');
|
|
345
|
-
|
|
346
|
-
if(deleteStrategy !== 'soft') {
|
|
357
|
+
|
|
358
|
+
if (deleteStrategy !== 'soft') {
|
|
347
359
|
return;
|
|
348
360
|
}
|
|
349
361
|
|
|
350
362
|
// 删除操作,如果是软删除修改为update语句。
|
|
351
363
|
// 标准软删除:deleted_at 字段为0代表未删除,有任意时间字段代表已删除。
|
|
352
|
-
if(KeysOfSimpleSQL.SIMPLE_DELETE === sqlSimpleName) {
|
|
353
|
-
const userSession =
|
|
354
|
-
if(!params.data) {
|
|
364
|
+
if (KeysOfSimpleSQL.SIMPLE_DELETE === sqlSimpleName) {
|
|
365
|
+
const userSession = this.ctx?.userSession?.getSessionInfo();
|
|
366
|
+
if (!params.data) {
|
|
355
367
|
params.data = {};
|
|
356
368
|
}
|
|
357
369
|
params.data.deleted_at = Date.now(); // 默认值为 0; 0代表未删除
|
|
@@ -360,14 +372,14 @@ export class CrudStdService extends ApiBaseService {
|
|
|
360
372
|
// 执行update操作
|
|
361
373
|
cfgModel.sqlSimpleName = KeysOfSimpleSQL.SIMPLE_UPDATE;
|
|
362
374
|
|
|
363
|
-
if(!params.condition || Object.keys(params.condition).length === 0) {
|
|
375
|
+
if (!params.condition || Object.keys(params.condition).length === 0) {
|
|
364
376
|
throw new Error('执行删除操作,必须指定删除条件')
|
|
365
377
|
}
|
|
366
378
|
}
|
|
367
379
|
|
|
368
380
|
// 查询操作。强制查询未删除的。
|
|
369
381
|
if (KeysOfSimpleSQL.SIMPLE_QUERY_ONE === sqlSimpleName || KeysOfSimpleSQL.SIMPLE_QUERY_PAGE === sqlSimpleName) {
|
|
370
|
-
if(!params.condition) {
|
|
382
|
+
if (!params.condition) {
|
|
371
383
|
params.condition = {};
|
|
372
384
|
}
|
|
373
385
|
params.condition.deleted_at = 0; // 未删除
|