midway-fatcms 0.0.1-beta.46 → 0.0.1-beta.49
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/manage/CrudStandardDesignApi.js +11 -3
- package/dist/controller/manage/UserAccountManageApi.js +1 -1
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.js +4 -0
- package/dist/service/crudstd/CrudStdRelationService.js +63 -36
- package/dist/service/crudstd/CrudStdService.d.ts +6 -2
- package/dist/service/crudstd/CrudStdService.js +25 -0
- package/dist/service/curd/CurdMixByAccountService.js +0 -1
- package/dist/service/curd/CurdMixUtils.js +8 -6
- package/dist/service/curd/fixCfgModel.d.ts +1 -1
- package/dist/service/curd/fixCfgModel.js +2 -6
- package/package.json +1 -1
|
@@ -20,11 +20,19 @@ const SystemTables_1 = require("../../models/SystemTables");
|
|
|
20
20
|
const exceptions_1 = require("../../libs/crud-pro/exceptions");
|
|
21
21
|
const DatabaseName_1 = require("../../libs/crud-pro/utils/DatabaseName");
|
|
22
22
|
const common_dto_1 = require("../../libs/utils/common-dto");
|
|
23
|
+
function getObjectKeysWithValue(obj) {
|
|
24
|
+
const keys = Object.keys(obj || {});
|
|
25
|
+
return keys.filter((key) => {
|
|
26
|
+
const valueObj = obj[key];
|
|
27
|
+
const valueKeys = Object.keys(valueObj || {});
|
|
28
|
+
return valueKeys.length > 0;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
23
31
|
let CrudStandardDesignApi = class CrudStandardDesignApi extends BaseApiController_1.BaseApiController {
|
|
24
32
|
async getDataBaseList() {
|
|
25
|
-
const mysqlList =
|
|
26
|
-
const postgresList =
|
|
27
|
-
const sqlServerList =
|
|
33
|
+
const mysqlList = getObjectKeysWithValue(this.mysql2Config);
|
|
34
|
+
const postgresList = getObjectKeysWithValue(this.postgres2Config);
|
|
35
|
+
const sqlServerList = getObjectKeysWithValue(this.sqlserver2Config);
|
|
28
36
|
const toSelectList = (dbCfgNameList, dbType) => {
|
|
29
37
|
return dbCfgNameList.map(dbName => {
|
|
30
38
|
const value = (0, DatabaseName_1.toDatabaseNameStr)(dbType, dbName);
|
|
@@ -48,7 +48,7 @@ let UserAccountManageApi = class UserAccountManageApi extends BaseApiController_
|
|
|
48
48
|
'data.nick_name': [keys_1.KeysOfValidators.STRING, 'length:3,20', checkAccountCreateBlacklist],
|
|
49
49
|
},
|
|
50
50
|
allowCfg: {
|
|
51
|
-
data: ['login_name', 'nick_name', 'avatar', 'status'],
|
|
51
|
+
data: ['login_name', 'nick_name', 'avatar', 'status', 'modified_at', 'created_at'],
|
|
52
52
|
},
|
|
53
53
|
});
|
|
54
54
|
}
|
|
@@ -79,10 +79,12 @@ class ExportExcelByStdCrudHandler {
|
|
|
79
79
|
return selectedRowKeys.length;
|
|
80
80
|
}
|
|
81
81
|
const lastQueryParams = (_b = this.inputParams) === null || _b === void 0 ? void 0 : _b.lastQueryParams;
|
|
82
|
+
const filterValue = _.get(lastQueryParams, 'filterValue');
|
|
82
83
|
const crudStdService = await this.getCrudStdService();
|
|
83
84
|
const appCode = this.appCode;
|
|
84
85
|
const params = {
|
|
85
86
|
condition: (lastQueryParams === null || lastQueryParams === void 0 ? void 0 : lastQueryParams.condition) || {},
|
|
87
|
+
filterValue,
|
|
86
88
|
pageSize: 1,
|
|
87
89
|
pageNo: 1,
|
|
88
90
|
};
|
|
@@ -107,10 +109,12 @@ class ExportExcelByStdCrudHandler {
|
|
|
107
109
|
const selectedRowKeys = this.inputParams.selectedRowKeys || [];
|
|
108
110
|
const primaryKey = this.inputParams.primaryKey || 'id';
|
|
109
111
|
const lastQueryParams = this.inputParams.lastQueryParams;
|
|
112
|
+
const filterValue = _.get(lastQueryParams, 'filterValue');
|
|
110
113
|
const crudStdService = await this.getCrudStdService();
|
|
111
114
|
const appCode = this.appCode;
|
|
112
115
|
const params = {
|
|
113
116
|
condition: (lastQueryParams === null || lastQueryParams === void 0 ? void 0 : lastQueryParams.condition) || {},
|
|
117
|
+
filterValue: filterValue,
|
|
114
118
|
pageSize: pageSize,
|
|
115
119
|
pageNo: pageNo,
|
|
116
120
|
orderBy: lastQueryParams === null || lastQueryParams === void 0 ? void 0 : lastQueryParams.orderBy,
|
|
@@ -10,62 +10,89 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CrudStdRelationService = void 0;
|
|
13
|
+
/* eslint-disable prettier/prettier */
|
|
13
14
|
const core_1 = require("@midwayjs/core");
|
|
14
15
|
const _ = require("lodash");
|
|
15
16
|
const CurdMixService_1 = require("../curd/CurdMixService");
|
|
16
17
|
const BaseService_1 = require("../base/BaseService");
|
|
17
18
|
const CrudStdConstant_1 = require("./CrudStdConstant");
|
|
18
19
|
const CurdMixUtils_1 = require("../curd/CurdMixUtils");
|
|
20
|
+
class ColumnsRelationMaker {
|
|
21
|
+
constructor(cfgModel, appInfo) {
|
|
22
|
+
cfgModel.columnsRelation = [];
|
|
23
|
+
this.cfgModel = cfgModel;
|
|
24
|
+
this.appInfo = appInfo;
|
|
25
|
+
}
|
|
26
|
+
addColumnRelationByAccount(dataIndex) {
|
|
27
|
+
const columnsRelation = this.cfgModel.columnsRelation;
|
|
28
|
+
columnsRelation.push({
|
|
29
|
+
relatedType: CurdMixUtils_1.RelatedType.accountBasic,
|
|
30
|
+
sourceColumn: dataIndex,
|
|
31
|
+
targetColumns: [], // 使用默认
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
addColumnRelationByDictEnumStatus(dataIndex) {
|
|
35
|
+
var _a;
|
|
36
|
+
const appInfo = this.appInfo;
|
|
37
|
+
const tableFields = ((_a = appInfo === null || appInfo === void 0 ? void 0 : appInfo.stdCrudCfgObj) === null || _a === void 0 ? void 0 : _a.tableFields) || [];
|
|
38
|
+
const columnsRelation = this.cfgModel.columnsRelation;
|
|
39
|
+
const fieldCfg = tableFields.find(f => {
|
|
40
|
+
return f.fieldIndex === dataIndex;
|
|
41
|
+
});
|
|
42
|
+
if (fieldCfg && fieldCfg.linkToType === CrudStdConstant_1.fieldLinkToTypes.linkToCustom) {
|
|
43
|
+
columnsRelation.push({
|
|
44
|
+
relatedType: CurdMixUtils_1.RelatedType.linkToCustom,
|
|
45
|
+
relatedCode: fieldCfg.linkToCustom,
|
|
46
|
+
sourceColumn: dataIndex,
|
|
47
|
+
targetColumns: [], // 使用默认
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (fieldCfg && fieldCfg.linkToType === CrudStdConstant_1.fieldLinkToTypes.linkToSysCfgEnum) {
|
|
51
|
+
columnsRelation.push({
|
|
52
|
+
relatedType: CurdMixUtils_1.RelatedType.sysCfgEnum,
|
|
53
|
+
relatedCode: fieldCfg.linkToSysCfgEnumCode,
|
|
54
|
+
sourceColumn: dataIndex,
|
|
55
|
+
targetColumns: [], // 使用默认
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (fieldCfg && fieldCfg.linkToType === CrudStdConstant_1.fieldLinkToTypes.linkToDict) {
|
|
59
|
+
columnsRelation.push({
|
|
60
|
+
relatedType: CurdMixUtils_1.RelatedType.dict,
|
|
61
|
+
relatedCode: fieldCfg.linkToDictCode,
|
|
62
|
+
sourceColumn: dataIndex,
|
|
63
|
+
targetColumns: [], // 使用默认
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
19
68
|
let CrudStdRelationService = class CrudStdRelationService extends BaseService_1.BaseService {
|
|
20
69
|
async addCfgModelColumnsRelation(cfgModel, appInfo) {
|
|
21
|
-
var _a
|
|
70
|
+
var _a;
|
|
22
71
|
const tableColumns = (_a = appInfo === null || appInfo === void 0 ? void 0 : appInfo.stdCrudCfgObj) === null || _a === void 0 ? void 0 : _a.tableColumns;
|
|
23
|
-
|
|
24
|
-
if (!Array.isArray(tableColumns)) {
|
|
72
|
+
if (!Array.isArray(tableColumns) || tableColumns.length === 0) {
|
|
25
73
|
return;
|
|
26
74
|
}
|
|
27
|
-
const
|
|
28
|
-
cfgModel.columnsRelation = columnsRelation;
|
|
75
|
+
const maker = new ColumnsRelationMaker(cfgModel, appInfo);
|
|
29
76
|
for (let i = 0; i < tableColumns.length; i++) {
|
|
30
77
|
const tableColumn = tableColumns[i];
|
|
31
78
|
const dataIndex = _.get(tableColumn, 'dataIndex');
|
|
32
79
|
const componentName = _.get(tableColumn, 'component.componentName');
|
|
33
80
|
// 关联用户信息
|
|
34
81
|
if (componentName === CrudStdConstant_1.tableColumnRenders.RenderUserInfo) {
|
|
35
|
-
|
|
36
|
-
relatedType: CurdMixUtils_1.RelatedType.accountBasic,
|
|
37
|
-
sourceColumn: dataIndex,
|
|
38
|
-
targetColumns: [], // 使用默认
|
|
39
|
-
});
|
|
82
|
+
maker.addColumnRelationByAccount(dataIndex);
|
|
40
83
|
}
|
|
41
84
|
// 关联枚举文案/状态标签颜色
|
|
42
85
|
if (componentName === CrudStdConstant_1.tableColumnRenders.RenderDictEnumText || componentName === CrudStdConstant_1.tableColumnRenders.RenderDictEnumStatus) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (fieldCfg && fieldCfg.linkToType === CrudStdConstant_1.fieldLinkToTypes.linkToSysCfgEnum) {
|
|
55
|
-
columnsRelation.push({
|
|
56
|
-
relatedType: CurdMixUtils_1.RelatedType.sysCfgEnum,
|
|
57
|
-
relatedCode: fieldCfg.linkToSysCfgEnumCode,
|
|
58
|
-
sourceColumn: dataIndex,
|
|
59
|
-
targetColumns: [], // 使用默认
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
if (fieldCfg && fieldCfg.linkToType === CrudStdConstant_1.fieldLinkToTypes.linkToDict) {
|
|
63
|
-
columnsRelation.push({
|
|
64
|
-
relatedType: CurdMixUtils_1.RelatedType.dict,
|
|
65
|
-
relatedCode: fieldCfg.linkToDictCode,
|
|
66
|
-
sourceColumn: dataIndex,
|
|
67
|
-
targetColumns: [], // 使用默认
|
|
68
|
-
});
|
|
86
|
+
maker.addColumnRelationByDictEnumStatus(dataIndex);
|
|
87
|
+
}
|
|
88
|
+
// 子属性的配置
|
|
89
|
+
const balloonTipFields = _.get(tableColumn, 'component.props.balloonTipFields');
|
|
90
|
+
if (Array.isArray(balloonTipFields) && balloonTipFields.length > 0) {
|
|
91
|
+
for (let j = 0; j < balloonTipFields.length; j++) {
|
|
92
|
+
const { component, name } = balloonTipFields[j] || {};
|
|
93
|
+
if (component === CrudStdConstant_1.tableColumnRenders.RenderUserInfo) {
|
|
94
|
+
maker.addColumnRelationByAccount(name);
|
|
95
|
+
}
|
|
69
96
|
}
|
|
70
97
|
}
|
|
71
98
|
}
|
|
@@ -16,6 +16,9 @@ export interface ICrudStdActionParams {
|
|
|
16
16
|
settingKey?: string;
|
|
17
17
|
buttonSettingKey?: string;
|
|
18
18
|
}
|
|
19
|
+
export interface IRequestModelCrudProExt extends IRequestModel {
|
|
20
|
+
filterValue: string | number;
|
|
21
|
+
}
|
|
19
22
|
export declare class CrudStdService extends ApiBaseService {
|
|
20
23
|
protected ctx: Context;
|
|
21
24
|
protected curdMixService: CurdMixService;
|
|
@@ -24,7 +27,7 @@ export declare class CrudStdService extends ApiBaseService {
|
|
|
24
27
|
/**
|
|
25
28
|
* 执行普通CRUD
|
|
26
29
|
*/
|
|
27
|
-
executeStdQuery(stdAction: ICrudStdActionParams, params:
|
|
30
|
+
executeStdQuery(stdAction: ICrudStdActionParams, params: IRequestModelCrudProExt, sqlSimpleName: KeysOfSimpleSQL): Promise<ExecuteContext>;
|
|
28
31
|
/**
|
|
29
32
|
* 获取appInfo 并且拿到当前settingKey相关的信息
|
|
30
33
|
* @param appCode
|
|
@@ -37,7 +40,7 @@ export declare class CrudStdService extends ApiBaseService {
|
|
|
37
40
|
* @param stdAction
|
|
38
41
|
* @param params
|
|
39
42
|
*/
|
|
40
|
-
executeStdActionByReq(stdAction: ICrudStdActionParams, params:
|
|
43
|
+
executeStdActionByReq(stdAction: ICrudStdActionParams, params: IRequestModelCrudProExt): Promise<ExecuteContext>;
|
|
41
44
|
/**
|
|
42
45
|
* 查询APP信息
|
|
43
46
|
* @param appCode
|
|
@@ -57,6 +60,7 @@ export declare class CrudStdService extends ApiBaseService {
|
|
|
57
60
|
*/
|
|
58
61
|
private getParsedCrudStdAppInfoPrivate;
|
|
59
62
|
private hasOperationPerm;
|
|
63
|
+
private fixCfgModelByFilterValue;
|
|
60
64
|
private fixSubmitDataByKeepSubmitData;
|
|
61
65
|
private fixDataFieldTypeBySqlTableField;
|
|
62
66
|
}
|
|
@@ -59,6 +59,7 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
59
59
|
sqlDbType: dbType,
|
|
60
60
|
sqlTable: getExecuteTableNameBySettingKey(appInfo, stdAction),
|
|
61
61
|
sqlSimpleName,
|
|
62
|
+
updateCfg: {}
|
|
62
63
|
};
|
|
63
64
|
// 接口返回最大值
|
|
64
65
|
const maxLimit = _.get(stdCrudCfgObj, 'othersSetting.values.maxLimit');
|
|
@@ -70,6 +71,8 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
70
71
|
}
|
|
71
72
|
// 根据用户配置,设置关联查询的数据信息。
|
|
72
73
|
await this.crudStdRelationService.addCfgModelColumnsRelation(cfgModel, appInfo);
|
|
74
|
+
// 根据FilterValue参数,设置updateCfg
|
|
75
|
+
await this.fixCfgModelByFilterValue(params, cfgModel, appInfo, { dbType, dbName });
|
|
73
76
|
// 根据用户配置的keepSubmitData字段修改提交的数据
|
|
74
77
|
await this.fixSubmitDataByKeepSubmitData(params, cfgModel, appInfo, { dbType, dbName });
|
|
75
78
|
// 根据表结构的数据类型,修正数据类型
|
|
@@ -208,6 +211,28 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
208
211
|
}
|
|
209
212
|
return true; // 无需鉴权
|
|
210
213
|
}
|
|
214
|
+
async fixCfgModelByFilterValue(params, cfgModel, appInfo, arg3) {
|
|
215
|
+
const { filterValue } = params || {};
|
|
216
|
+
if (!filterValue && filterValue !== 0) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const filterList = _.get(appInfo, 'stdCrudCfgObj.filterList');
|
|
220
|
+
if (!Array.isArray(filterList) || filterList.length === 0) {
|
|
221
|
+
this.logWarn('filterValue存在,但是filterList没有设置');
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const filterItem = filterList.find(item => item.value === filterValue);
|
|
225
|
+
if (!filterItem) {
|
|
226
|
+
this.logWarn('filterValue存在,但是filterList中没有找到此配置项');
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const partialCondition = _.get(filterItem, 'partialCondition');
|
|
230
|
+
if (!partialCondition) {
|
|
231
|
+
this.logWarn('filterValue存在,但是filterList中的配置项没有设置partialCondition');
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
Object.assign(cfgModel.updateCfg, partialCondition);
|
|
235
|
+
}
|
|
211
236
|
async fixSubmitDataByKeepSubmitData(params, cfgModel, appInfo, arg3) {
|
|
212
237
|
if (cfgModel.sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT || cfgModel.sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE) {
|
|
213
238
|
const submitData = params.data || {};
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RelatedType = exports.CrudMixUtils = void 0;
|
|
4
4
|
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
5
5
|
const MixinUtils_1 = require("../../libs/crud-pro/utils/MixinUtils");
|
|
6
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
6
7
|
const _ = require("lodash");
|
|
7
8
|
const functions_1 = require("../../libs/utils/functions");
|
|
8
9
|
var RelatedType;
|
|
@@ -248,15 +249,16 @@ class CrudMixUtils {
|
|
|
248
249
|
* @param columnRelation
|
|
249
250
|
*/
|
|
250
251
|
copyUserInfoToRowNoRelatedCode(row, map, columnRelation) {
|
|
251
|
-
const { targetColumns } = columnRelation;
|
|
252
|
+
const { targetColumns, sourceColumn } = columnRelation;
|
|
252
253
|
if (!targetColumns) {
|
|
253
254
|
return;
|
|
254
255
|
}
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
if (!sourceValue) {
|
|
256
|
+
const accountId = _.get(row, sourceColumn);
|
|
257
|
+
if (!accountId) {
|
|
258
258
|
return;
|
|
259
259
|
}
|
|
260
|
+
const { toFatcmsUserAccountId } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
261
|
+
const fatcmsUserAccountId = toFatcmsUserAccountId(accountId);
|
|
260
262
|
const getValue = (code) => {
|
|
261
263
|
if (!map) {
|
|
262
264
|
return null;
|
|
@@ -266,9 +268,9 @@ class CrudMixUtils {
|
|
|
266
268
|
}
|
|
267
269
|
return map[code];
|
|
268
270
|
};
|
|
269
|
-
const isSetArray = copyByArraySourceValue(row,
|
|
271
|
+
const isSetArray = copyByArraySourceValue(row, fatcmsUserAccountId, targetColumns, getValue);
|
|
270
272
|
if (!isSetArray) {
|
|
271
|
-
copyBySingleSourceValue(row,
|
|
273
|
+
copyBySingleSourceValue(row, fatcmsUserAccountId, targetColumns, getValue);
|
|
272
274
|
}
|
|
273
275
|
}
|
|
274
276
|
}
|
|
@@ -4,10 +4,7 @@ exports.fixCfgModel = void 0;
|
|
|
4
4
|
const bizmodels_1 = require("../../models/bizmodels");
|
|
5
5
|
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
6
6
|
function isSimpleQuery(sqlSimpleName) {
|
|
7
|
-
return sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_QUERY ||
|
|
8
|
-
sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_COUNT ||
|
|
9
|
-
sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_PAGE ||
|
|
10
|
-
sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE;
|
|
7
|
+
return sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_QUERY || sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_COUNT || sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_PAGE || sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE;
|
|
11
8
|
}
|
|
12
9
|
function fixCfgModel(cfgModel) {
|
|
13
10
|
if (!cfgModel.method) {
|
|
@@ -94,8 +91,7 @@ function fixCfgModel(cfgModel) {
|
|
|
94
91
|
Object.assign(cfgModel.updateCfg, updateCfgObj2);
|
|
95
92
|
}
|
|
96
93
|
// 插入或更新
|
|
97
|
-
if (sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT_OR_UPDATE ||
|
|
98
|
-
sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT_ON_DUPLICATE_UPDATE) {
|
|
94
|
+
if (sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT_OR_UPDATE || sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT_ON_DUPLICATE_UPDATE) {
|
|
99
95
|
const updateCfgObj1 = buildUpdateCfgBy(dataCfgArray, 'data.created');
|
|
100
96
|
const updateCfgObj2 = buildUpdateCfgBy(dataCfgArray, 'data.modified');
|
|
101
97
|
const updateCfgObj3 = buildUpdateCfgBy(conditionCfgArray, 'condition.created'); // 更新用户本人创建的
|