midway-fatcms 0.0.1-beta.10 → 0.0.1-beta.11
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/base/BaseApiController.js +2 -2
- package/dist/controller/gateway/CrudMtdGatewayController.js +1 -1
- package/dist/controller/gateway/DocGatewayController.js +4 -4
- package/dist/controller/manage/CrudStandardDesignApi.js +7 -7
- package/dist/controller/manage/DeployManageApi.js +2 -2
- package/dist/controller/manage/SuperAdminManageApi.js +4 -4
- package/dist/controller/render/AppRenderController.js +1 -1
- package/dist/controller/test.controller.js +1 -1
- package/dist/libs/crud-pro/interfaces.d.ts +1 -1
- package/dist/libs/crud-pro/models/RequestCfgModel.d.ts +1 -1
- package/dist/libs/crud-pro/models/SqlCfgModel.d.ts +1 -1
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +4 -4
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +4 -4
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +8 -8
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +2 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +2 -2
- package/dist/service/AuthService.js +2 -2
- package/dist/service/EnumInfoService.js +2 -2
- package/dist/service/FileCenterService.js +4 -4
- package/dist/service/SysConfigService.js +1 -1
- package/dist/service/UserAccountService.js +3 -3
- package/dist/service/VisitStatService.js +1 -1
- package/dist/service/WorkbenchService.js +1 -1
- package/dist/service/anyapi/AnyApiService.js +1 -1
- package/dist/service/crudstd/CrudStdService.js +2 -2
- package/dist/service/curd/CurdMixByAccountService.js +1 -1
- package/dist/service/curd/CurdMixByDictService.js +1 -1
- package/dist/service/curd/CurdMixByLinkToCustomService.js +1 -1
- package/dist/service/curd/CurdMixBySysConfigService.js +1 -1
- package/dist/service/curd/CurdMixByWorkbenchService.js +1 -1
- package/dist/service/curd/CurdMixService.d.ts +1 -1
- package/dist/service/curd/CurdMixService.js +2 -2
- package/dist/service/curd/CurdProService.d.ts +3 -3
- package/dist/service/curd/CurdProService.js +9 -9
- package/dist/service/proxyapi/ProxyApiLoadService.js +2 -2
- package/package.json +1 -1
- package/src/controller/base/BaseApiController.ts +2 -2
- package/src/controller/gateway/CrudMtdGatewayController.ts +1 -1
- package/src/controller/gateway/DocGatewayController.ts +4 -4
- package/src/controller/manage/CrudStandardDesignApi.ts +7 -7
- package/src/controller/manage/DeployManageApi.ts +2 -2
- package/src/controller/manage/SuperAdminManageApi.ts +4 -4
- package/src/controller/render/AppRenderController.ts +1 -1
- package/src/controller/test.controller.ts +1 -1
- package/src/libs/crud-pro/interfaces.ts +1 -1
- package/src/libs/crud-pro/models/RequestCfgModel.ts +1 -1
- package/src/libs/crud-pro/models/SqlCfgModel.ts +1 -1
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +4 -4
- package/src/libs/crud-pro/services/CrudProGenSqlCondition.ts +4 -4
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +8 -8
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +2 -2
- package/src/libs/crud-pro/utils/sqlConvert/convertColumnName.ts +2 -2
- package/src/service/AuthService.ts +2 -2
- package/src/service/EnumInfoService.ts +2 -2
- package/src/service/FileCenterService.ts +4 -4
- package/src/service/SysConfigService.ts +1 -1
- package/src/service/UserAccountService.ts +3 -3
- package/src/service/VisitStatService.ts +1 -1
- package/src/service/WorkbenchService.ts +1 -1
- package/src/service/anyapi/AnyApiService.ts +1 -1
- package/src/service/crudstd/CrudStdService.ts +2 -2
- package/src/service/curd/CurdMixByAccountService.ts +1 -1
- package/src/service/curd/CurdMixByDictService.ts +1 -1
- package/src/service/curd/CurdMixByLinkToCustomService.ts +1 -1
- package/src/service/curd/CurdMixBySysConfigService.ts +1 -1
- package/src/service/curd/CurdMixByWorkbenchService.ts +1 -1
- package/src/service/curd/CurdMixService.ts +2 -2
- package/src/service/curd/CurdProService.ts +10 -10
- package/src/service/proxyapi/ProxyApiLoadService.ts +2 -2
|
@@ -7,9 +7,9 @@ import { BaseService } from '../base/BaseService';
|
|
|
7
7
|
import { IRequestCfgModel2 } from '../../models/bizmodels';
|
|
8
8
|
export declare class DBUtils {
|
|
9
9
|
private readonly sqlDatabase;
|
|
10
|
-
private readonly
|
|
10
|
+
private readonly sqlDbType;
|
|
11
11
|
private readonly curdProService;
|
|
12
|
-
constructor(sqlDatabase: string,
|
|
12
|
+
constructor(sqlDatabase: string, sqlDbType: SqlDbType, curdProService: CurdProService);
|
|
13
13
|
getOne(reqJson: IRequestModel, sqlTable: string): Promise<any>;
|
|
14
14
|
getList(reqJson: IRequestModel, sqlTable: string): Promise<any[]>;
|
|
15
15
|
}
|
|
@@ -34,6 +34,6 @@ export declare class CurdProService extends BaseService {
|
|
|
34
34
|
executeSQL(sqlCfgModel: ISqlCfgModel): Promise<any>;
|
|
35
35
|
executeCrudByCfg(reqJson: IRequestModel, cfgModel: IRequestCfgModel2): Promise<ExecuteContext>;
|
|
36
36
|
private applyStandardUpdateCfg;
|
|
37
|
-
getBbUtil(database: string,
|
|
37
|
+
getBbUtil(database: string, sqlDbType: SqlDbType): DBUtils;
|
|
38
38
|
getCachedCfgByMethod(method: string): Promise<IRequestCfgModel>;
|
|
39
39
|
}
|
|
@@ -65,15 +65,15 @@ class MyContextFunc extends ExecuteContextFunc_1.BaseExecuteContextFunc {
|
|
|
65
65
|
throw new exceptions_1.CommonException(exceptions_1.Exceptions.DB_QUERY_PARAM_EMPTY, '查询语句中未指定数据库');
|
|
66
66
|
}
|
|
67
67
|
const dataBaseName = sqlCfgModel.sqlDatabase;
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
68
|
+
const sqlDbType = sqlCfgModel.sqlDbType;
|
|
69
|
+
if (sqlDbType === keys_1.SqlDbType.postgres) {
|
|
70
70
|
const dbConfig = _.get(this.postgres2Config, dataBaseName);
|
|
71
71
|
if (!dbConfig) {
|
|
72
72
|
throw new exceptions_1.CommonException(exceptions_1.Exceptions.DB_NOT_FOUND, 'postgres配置中不存在此数据库:' + dataBaseName);
|
|
73
73
|
}
|
|
74
74
|
return (0, PostgresUtils_1.getConnectionPool)(dataBaseName, dbConfig);
|
|
75
75
|
}
|
|
76
|
-
if (
|
|
76
|
+
if (sqlDbType === keys_1.SqlDbType.sqlserver) {
|
|
77
77
|
const dbConfig = _.get(this.sqlserver2Config, dataBaseName);
|
|
78
78
|
if (!dbConfig) {
|
|
79
79
|
throw new exceptions_1.CommonException(exceptions_1.Exceptions.DB_NOT_FOUND, 'sqlserver配置中不存在此数据库:' + dataBaseName);
|
|
@@ -98,9 +98,9 @@ class MyContextFunc extends ExecuteContextFunc_1.BaseExecuteContextFunc {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
class DBUtils {
|
|
101
|
-
constructor(sqlDatabase,
|
|
101
|
+
constructor(sqlDatabase, sqlDbType, curdProService) {
|
|
102
102
|
this.sqlDatabase = sqlDatabase;
|
|
103
|
-
this.
|
|
103
|
+
this.sqlDbType = sqlDbType;
|
|
104
104
|
this.curdProService = curdProService;
|
|
105
105
|
}
|
|
106
106
|
async getOne(reqJson, sqlTable) {
|
|
@@ -108,7 +108,7 @@ class DBUtils {
|
|
|
108
108
|
sqlTable,
|
|
109
109
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
110
110
|
sqlDatabase: this.sqlDatabase,
|
|
111
|
-
|
|
111
|
+
sqlDbType: this.sqlDbType,
|
|
112
112
|
updateCfg: {},
|
|
113
113
|
};
|
|
114
114
|
const res = await this.curdProService.executeCrudByCfg(reqJson, cfgModel);
|
|
@@ -119,7 +119,7 @@ class DBUtils {
|
|
|
119
119
|
sqlTable,
|
|
120
120
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
121
121
|
sqlDatabase: this.sqlDatabase,
|
|
122
|
-
|
|
122
|
+
sqlDbType: this.sqlDbType,
|
|
123
123
|
updateCfg: {},
|
|
124
124
|
};
|
|
125
125
|
const res = await this.curdProService.executeCrudByCfg(reqJson, cfgModel);
|
|
@@ -287,8 +287,8 @@ let CurdProService = class CurdProService extends BaseService_1.BaseService {
|
|
|
287
287
|
Object.assign(cfgModel.updateCfg, updateCfgObj3);
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
|
-
getBbUtil(database,
|
|
291
|
-
return new DBUtils(database,
|
|
290
|
+
getBbUtil(database, sqlDbType) {
|
|
291
|
+
return new DBUtils(database, sqlDbType, this);
|
|
292
292
|
}
|
|
293
293
|
async getCachedCfgByMethod(method) {
|
|
294
294
|
const curdPro = this.getCrudPro();
|
|
@@ -89,7 +89,7 @@ let ProxyApiLoadService = class ProxyApiLoadService extends BaseService_1.BaseSe
|
|
|
89
89
|
}, {
|
|
90
90
|
sqlTable: SystemTables_1.SystemTables.sys_configs,
|
|
91
91
|
sqlDatabase: SystemDbName,
|
|
92
|
-
|
|
92
|
+
sqlDbType: SystemDbType,
|
|
93
93
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
94
94
|
});
|
|
95
95
|
const upstreamMap = {};
|
|
@@ -108,7 +108,7 @@ let ProxyApiLoadService = class ProxyApiLoadService extends BaseService_1.BaseSe
|
|
|
108
108
|
}, {
|
|
109
109
|
sqlTable: SystemTables_1.SystemTables.sys_proxyapi,
|
|
110
110
|
sqlDatabase: SystemDbName,
|
|
111
|
-
|
|
111
|
+
sqlDbType: SystemDbType,
|
|
112
112
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
113
113
|
});
|
|
114
114
|
const rows0 = res.getResRows();
|
package/package.json
CHANGED
|
@@ -40,7 +40,7 @@ export class BaseApiController extends BaseService {
|
|
|
40
40
|
executeSql: executeSql,
|
|
41
41
|
executeSqlArgs: executeSqlArgs,
|
|
42
42
|
sqlDatabase: SystemDbName,
|
|
43
|
-
|
|
43
|
+
sqlDbType: SystemDbType,
|
|
44
44
|
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
45
45
|
});
|
|
46
46
|
}
|
|
@@ -61,7 +61,7 @@ export class BaseApiController extends BaseService {
|
|
|
61
61
|
sqlTable,
|
|
62
62
|
sqlSimpleName,
|
|
63
63
|
sqlDatabase: SystemDbName,
|
|
64
|
-
|
|
64
|
+
sqlDbType: SystemDbType,
|
|
65
65
|
updateCfg: {},
|
|
66
66
|
};
|
|
67
67
|
|
|
@@ -101,7 +101,7 @@ export class CrudMtdGatewayController extends ApiBaseService {
|
|
|
101
101
|
const cfgModel = methodInfo as IRequestCfgModel2;
|
|
102
102
|
const { dbType, dbName } = parseDatabaseName(cfgModel.sqlDatabase);
|
|
103
103
|
cfgModel.sqlDatabase = dbName;
|
|
104
|
-
cfgModel.
|
|
104
|
+
cfgModel.sqlDbType = dbType;
|
|
105
105
|
|
|
106
106
|
// 业务系统自定义的修改cfgModel
|
|
107
107
|
await GLOBAL_STATIC_CONFIG.getConfig().bizUpdateCfgModelForCrudMtd(reqJson, cfgModel, methodInfo, this.ctx);
|
|
@@ -53,7 +53,7 @@ export class DocGatewayController extends BaseApiController {
|
|
|
53
53
|
sqlTable: SystemTables.sys_doc,
|
|
54
54
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
55
55
|
sqlDatabase: SystemDbName,
|
|
56
|
-
|
|
56
|
+
sqlDbType: SystemDbType,
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -85,7 +85,7 @@ export class DocGatewayController extends BaseApiController {
|
|
|
85
85
|
sqlTable: SystemTables.sys_doc,
|
|
86
86
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
87
87
|
sqlDatabase: SystemDbName,
|
|
88
|
-
|
|
88
|
+
sqlDbType: SystemDbType,
|
|
89
89
|
}
|
|
90
90
|
);
|
|
91
91
|
|
|
@@ -128,7 +128,7 @@ export class DocGatewayController extends BaseApiController {
|
|
|
128
128
|
sqlTable: SystemTables.sys_doc,
|
|
129
129
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
130
130
|
sqlDatabase: SystemDbName,
|
|
131
|
-
|
|
131
|
+
sqlDbType: SystemDbType,
|
|
132
132
|
}
|
|
133
133
|
);
|
|
134
134
|
}
|
|
@@ -153,7 +153,7 @@ export class DocGatewayController extends BaseApiController {
|
|
|
153
153
|
sqlTable: SystemTables.sys_doc_lib,
|
|
154
154
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
155
155
|
sqlDatabase: SystemDbName,
|
|
156
|
-
|
|
156
|
+
sqlDbType: SystemDbType,
|
|
157
157
|
}
|
|
158
158
|
);
|
|
159
159
|
const docLibInfo = s.getOneObj();
|
|
@@ -70,7 +70,7 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
70
70
|
const res = await this.curdMixService.executeSQL({
|
|
71
71
|
executeSql: 'SHOW TABLES',
|
|
72
72
|
sqlDatabase: dbName,
|
|
73
|
-
|
|
73
|
+
sqlDbType: SqlDbType.mysql,
|
|
74
74
|
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
75
75
|
});
|
|
76
76
|
|
|
@@ -105,13 +105,13 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
105
105
|
const tableDescribe = await this.curdMixService.executeSQL({
|
|
106
106
|
executeSql: 'describe ' + tableName,
|
|
107
107
|
sqlDatabase: dbName,
|
|
108
|
-
|
|
108
|
+
sqlDbType: SqlDbType.mysql,
|
|
109
109
|
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
110
110
|
});
|
|
111
111
|
const tableCreate = await this.curdMixService.executeSQL({
|
|
112
112
|
executeSql: 'show create table ' + tableName,
|
|
113
113
|
sqlDatabase: dbName,
|
|
114
|
-
|
|
114
|
+
sqlDbType: SqlDbType.mysql,
|
|
115
115
|
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
116
116
|
});
|
|
117
117
|
|
|
@@ -180,7 +180,7 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
180
180
|
const arr = await this.curdMixService.executeSQL({
|
|
181
181
|
executeSql: sql,
|
|
182
182
|
sqlDatabase: dbName,
|
|
183
|
-
|
|
183
|
+
sqlDbType: dbType,
|
|
184
184
|
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
185
185
|
executeSqlArgs: [],
|
|
186
186
|
});
|
|
@@ -230,7 +230,7 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
230
230
|
const arr = await this.curdMixService.executeSQL({
|
|
231
231
|
executeSql: executeSql,
|
|
232
232
|
sqlDatabase: dbName,
|
|
233
|
-
|
|
233
|
+
sqlDbType: dbType,
|
|
234
234
|
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
235
235
|
executeSqlArgs: [],
|
|
236
236
|
});
|
|
@@ -298,7 +298,7 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
298
298
|
const columnArray = await this.curdMixService.executeSQL({
|
|
299
299
|
executeSql: columnArraySql,
|
|
300
300
|
sqlDatabase: dbName,
|
|
301
|
-
|
|
301
|
+
sqlDbType: dbType,
|
|
302
302
|
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
303
303
|
executeSqlArgs: [],
|
|
304
304
|
});
|
|
@@ -359,7 +359,7 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
359
359
|
const columnArray = await this.curdMixService.executeSQL({
|
|
360
360
|
executeSql: columnArraySql,
|
|
361
361
|
sqlDatabase: dbName,
|
|
362
|
-
|
|
362
|
+
sqlDbType: dbType,
|
|
363
363
|
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
364
364
|
executeSqlArgs: [schemaname, tableName],
|
|
365
365
|
});
|
|
@@ -141,7 +141,7 @@ export class DeployManageApi extends BaseApiController {
|
|
|
141
141
|
},{
|
|
142
142
|
sqlTable: SystemTables.sys_workbench,
|
|
143
143
|
sqlDatabase: SystemDbName,
|
|
144
|
-
|
|
144
|
+
sqlDbType: SystemDbType,
|
|
145
145
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE
|
|
146
146
|
});
|
|
147
147
|
|
|
@@ -157,7 +157,7 @@ export class DeployManageApi extends BaseApiController {
|
|
|
157
157
|
},{
|
|
158
158
|
sqlTable: SystemTables.sys_app,
|
|
159
159
|
sqlDatabase: SystemDbName,
|
|
160
|
-
|
|
160
|
+
sqlDbType: SystemDbType,
|
|
161
161
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE
|
|
162
162
|
});
|
|
163
163
|
|
|
@@ -41,7 +41,7 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
41
41
|
sqlTable: SystemTables.sys_perm_func,
|
|
42
42
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
43
43
|
sqlDatabase: SystemDbName,
|
|
44
|
-
|
|
44
|
+
sqlDbType: SystemDbType,
|
|
45
45
|
}
|
|
46
46
|
);
|
|
47
47
|
}
|
|
@@ -75,7 +75,7 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
75
75
|
sqlTable: SystemTables.sys_perm_role,
|
|
76
76
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
77
77
|
sqlDatabase: SystemDbName,
|
|
78
|
-
|
|
78
|
+
sqlDbType: SystemDbType,
|
|
79
79
|
}
|
|
80
80
|
);
|
|
81
81
|
}
|
|
@@ -106,7 +106,7 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
106
106
|
sqlTable: SystemTables.sys_perm_role_func,
|
|
107
107
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
108
108
|
sqlDatabase: SystemDbName,
|
|
109
|
-
|
|
109
|
+
sqlDbType: SystemDbType,
|
|
110
110
|
}
|
|
111
111
|
);
|
|
112
112
|
}
|
|
@@ -125,7 +125,7 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
125
125
|
sqlTable: SystemTables.sys_perm_role_func,
|
|
126
126
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
127
127
|
sqlDatabase: SystemDbName,
|
|
128
|
-
|
|
128
|
+
sqlDbType: SystemDbType,
|
|
129
129
|
}
|
|
130
130
|
);
|
|
131
131
|
}
|
|
@@ -22,7 +22,7 @@ export class TestApiController extends BaseApiController{
|
|
|
22
22
|
sqlTable: "test_table1",
|
|
23
23
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
24
24
|
sqlDatabase: "postgres_test1",
|
|
25
|
-
|
|
25
|
+
sqlDbType: SqlDbType.postgres,
|
|
26
26
|
updateCfg: {},
|
|
27
27
|
};
|
|
28
28
|
|
|
@@ -102,7 +102,7 @@ export interface IBaseCfgModel {
|
|
|
102
102
|
sqlTable?: string; // 可以为空. originSql中不包含@@table时可以为空
|
|
103
103
|
sqlSchema?: string; // 可以为空
|
|
104
104
|
sqlDatabase?: string; // 可以为空,用此字段进行connection的选择和切换。配合getBizConnectionPool使用
|
|
105
|
-
|
|
105
|
+
sqlDbType?: SqlDbType; // 数据库类型,mysql(默认) 、postgres
|
|
106
106
|
maxLimit?: number; // 最大一次性返回的数量
|
|
107
107
|
columns?: string | string[]; // "columns": "id,name,age,sex,addr",
|
|
108
108
|
columnsRelation?: ColumnRelation[];
|
|
@@ -38,7 +38,7 @@ class RequestCfgModel {
|
|
|
38
38
|
sqlTable: string; // 可以为空. originSql中不包含@@table时可以为空
|
|
39
39
|
sqlSchema?: string; // 可以为空
|
|
40
40
|
sqlDatabase?: string; // 可以为空,用此字段进行connection的选择和切换。配合getBizConnectionPool使用
|
|
41
|
-
|
|
41
|
+
sqlDbType?: SqlDbType; // 数据库类型,mysql(默认) 、postgres
|
|
42
42
|
maxLimit = DEFAULT_MAX_LIMIT; // 最大一次性返回的数量
|
|
43
43
|
method: string; // 不能为空
|
|
44
44
|
transactionEnable: boolean; // 是否开启事务,默认不开启,每条语句都是autocommit
|
|
@@ -11,7 +11,7 @@ class SqlCfgModel {
|
|
|
11
11
|
sqlTable: string; // 可以为空. originSql中不包含@@table时可以为空
|
|
12
12
|
sqlSchema?: string; // 可以为空
|
|
13
13
|
sqlDatabase?: string; // 可以为空,用此字段进行connection的选择和切换。配合getBizConnectionPool使用
|
|
14
|
-
|
|
14
|
+
sqlDbType?: SqlDbType; // 数据库类型,mysql(默认) 、postgres
|
|
15
15
|
maxLimit: number; // 最大一次性返回的数量
|
|
16
16
|
resName: string;
|
|
17
17
|
resPicker: KeysOfSqlResPicker;
|
|
@@ -39,7 +39,7 @@ class CrudProExecuteSqlService extends CrudProServiceBase {
|
|
|
39
39
|
let sqlRes: any;
|
|
40
40
|
let queryRes : any;
|
|
41
41
|
|
|
42
|
-
if (sqlCfgModel.
|
|
42
|
+
if (sqlCfgModel.sqlDbType === SqlDbType.postgres) { // import { PoolClient } from 'pg';
|
|
43
43
|
|
|
44
44
|
const pgClient: PoolClient = connection as any;
|
|
45
45
|
const pgSql = replaceQuestionMarks(sqlCfgModel.executeSql);
|
|
@@ -55,7 +55,7 @@ class CrudProExecuteSqlService extends CrudProServiceBase {
|
|
|
55
55
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
else if (sqlCfgModel.
|
|
58
|
+
else if (sqlCfgModel.sqlDbType === SqlDbType.sqlserver) {
|
|
59
59
|
|
|
60
60
|
const mssql = replaceQuestionMarksForMssql(sqlCfgModel.executeSql);
|
|
61
61
|
|
|
@@ -245,14 +245,14 @@ class CrudProExecuteSqlService extends CrudProServiceBase {
|
|
|
245
245
|
|
|
246
246
|
// 增删改res的内容是修改结果:包括: insert\delete\update
|
|
247
247
|
if (KeysOfSqlResPicker.UPDATE_RESULT === resPicker) {
|
|
248
|
-
if (sqlCfgModel.
|
|
248
|
+
if (sqlCfgModel.sqlDbType === SqlDbType.postgres) {
|
|
249
249
|
return {
|
|
250
250
|
insertId: _.get(queryRes,'rows[0].id'),
|
|
251
251
|
affectedRows: _.get(queryRes,'rowCount')
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
if (sqlCfgModel.
|
|
255
|
+
if (sqlCfgModel.sqlDbType === SqlDbType.sqlserver) {
|
|
256
256
|
return {
|
|
257
257
|
insertId: _.get(queryRes,'recordset[0].id'),
|
|
258
258
|
affectedRows: _.get(queryRes,'rowsAffected[0]')
|
|
@@ -212,7 +212,7 @@ class CrudProGenSqlCondition {
|
|
|
212
212
|
tmpArgList.push(value0);
|
|
213
213
|
tmpSql = `${toSqlColumnName(key)} COLLATE UTF8MB4_GENERAL_CI like concat(?, '%')`; // like前缀匹配
|
|
214
214
|
|
|
215
|
-
if (this.sqlCfg.
|
|
215
|
+
if (this.sqlCfg.sqlDbType === SqlDbType.postgres) {
|
|
216
216
|
tmpSql = `${toSqlColumnName(key)} like concat(?, '%')`; // like前缀匹配
|
|
217
217
|
}
|
|
218
218
|
|
|
@@ -221,7 +221,7 @@ class CrudProGenSqlCondition {
|
|
|
221
221
|
tmpSql = `${toSqlColumnName(key)} COLLATE UTF8MB4_GENERAL_CI not like concat(?, '%')`;
|
|
222
222
|
|
|
223
223
|
|
|
224
|
-
if (this.sqlCfg.
|
|
224
|
+
if (this.sqlCfg.sqlDbType === SqlDbType.postgres) {
|
|
225
225
|
tmpSql = `${toSqlColumnName(key)} not like concat(?, '%')`;
|
|
226
226
|
}
|
|
227
227
|
|
|
@@ -232,7 +232,7 @@ class CrudProGenSqlCondition {
|
|
|
232
232
|
tmpArgList.push(value0);
|
|
233
233
|
tmpSql = `${toSqlColumnName(key)} COLLATE UTF8MB4_GENERAL_CI like concat('%', ?, '%')`; // like包含
|
|
234
234
|
|
|
235
|
-
if (this.sqlCfg.
|
|
235
|
+
if (this.sqlCfg.sqlDbType === SqlDbType.postgres) {
|
|
236
236
|
tmpSql = `${toSqlColumnName(key)} like concat('%', ?, '%')`; // like包含
|
|
237
237
|
}
|
|
238
238
|
|
|
@@ -240,7 +240,7 @@ class CrudProGenSqlCondition {
|
|
|
240
240
|
tmpArgList.push(value0);
|
|
241
241
|
tmpSql = `${toSqlColumnName(key)} COLLATE UTF8MB4_GENERAL_CI not like concat('%',?, '%')`; // like不包含
|
|
242
242
|
|
|
243
|
-
if (this.sqlCfg.
|
|
243
|
+
if (this.sqlCfg.sqlDbType === SqlDbType.postgres) {
|
|
244
244
|
tmpSql = `${toSqlColumnName(key)} not like concat('%',?, '%')`; // like不包含
|
|
245
245
|
}
|
|
246
246
|
|
|
@@ -97,10 +97,10 @@ class CrudProGenSqlService extends CrudProServiceBase {
|
|
|
97
97
|
* @private
|
|
98
98
|
*/
|
|
99
99
|
private generateOriginSqlForDelete(cfgModel: RequestCfgModel) : string {
|
|
100
|
-
if (cfgModel.
|
|
100
|
+
if (cfgModel.sqlDbType === SqlDbType.postgres) {
|
|
101
101
|
return 'delete from @@table where @@asWhere:condition ';
|
|
102
102
|
}
|
|
103
|
-
if (cfgModel.
|
|
103
|
+
if (cfgModel.sqlDbType === SqlDbType.sqlserver) {
|
|
104
104
|
return 'delete from @@table where @@asWhere:condition ';
|
|
105
105
|
}
|
|
106
106
|
return 'delete from @@table where @@asWhere:condition limit 100 '; // 删除操作,不能一次性删除太多
|
|
@@ -112,7 +112,7 @@ class CrudProGenSqlService extends CrudProServiceBase {
|
|
|
112
112
|
* @private
|
|
113
113
|
*/
|
|
114
114
|
private generateOriginSqlForDuplicateInsert(cfgModel: RequestCfgModel) : string {
|
|
115
|
-
if (cfgModel.
|
|
115
|
+
if (cfgModel.sqlDbType === SqlDbType.postgres) {
|
|
116
116
|
const uniqueColumn = cfgModel.uniqueColumn ; // id
|
|
117
117
|
if (!Array.isArray(uniqueColumn) || uniqueColumn.length === 0) {
|
|
118
118
|
throw new CommonException(Exceptions.CFG_ERROR_POSTGRES_UNIQUE_COLUMNS_NULL)
|
|
@@ -124,7 +124,7 @@ class CrudProGenSqlService extends CrudProServiceBase {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
|
|
127
|
-
if (cfgModel.
|
|
127
|
+
if (cfgModel.sqlDbType === SqlDbType.sqlserver) {
|
|
128
128
|
const uniqueColumn = cfgModel.uniqueColumn ; // id
|
|
129
129
|
if (uniqueColumn.length !== 1) {
|
|
130
130
|
throw new CommonException(Exceptions.CFG_UNIQUE_COLUMN_COUNT_MUST_ONE);
|
|
@@ -160,10 +160,10 @@ class CrudProGenSqlService extends CrudProServiceBase {
|
|
|
160
160
|
* @private
|
|
161
161
|
*/
|
|
162
162
|
private generateOriginSqlForInsert(cfgModel: RequestCfgModel): string {
|
|
163
|
-
if (cfgModel.
|
|
163
|
+
if (cfgModel.sqlDbType === SqlDbType.postgres) {
|
|
164
164
|
return 'insert into @@table ( @@asInsertKeys:data ) values( @@asInsertValues:data ) RETURNING * ';
|
|
165
165
|
}
|
|
166
|
-
if (cfgModel.
|
|
166
|
+
if (cfgModel.sqlDbType === SqlDbType.sqlserver) {
|
|
167
167
|
return 'insert into @@table ( @@asInsertKeys:data ) OUTPUT INSERTED.* values( @@asInsertValues:data ) ';
|
|
168
168
|
}
|
|
169
169
|
return 'insert into @@table ( @@asInsertKeys:data ) values( @@asInsertValues:data )'; // 关键字的前后,必须有空格
|
|
@@ -177,12 +177,12 @@ class CrudProGenSqlService extends CrudProServiceBase {
|
|
|
177
177
|
|
|
178
178
|
const reqCfgModel = exeCtx.getCfgModel();
|
|
179
179
|
const sqlCfgList = reqCfgModel.sqlCfgList || [];
|
|
180
|
-
const { sqlTable, sqlSchema, sqlDatabase,
|
|
180
|
+
const { sqlTable, sqlSchema, sqlDatabase, sqlDbType, maxLimit, columns, columnsRelation } = reqCfgModel;
|
|
181
181
|
|
|
182
182
|
for (let i = 0; i < sqlCfgList.length; i++) {
|
|
183
183
|
const sqlCfgModel = sqlCfgList[i];
|
|
184
184
|
|
|
185
|
-
sqlCfgModel.
|
|
185
|
+
sqlCfgModel.sqlDbType = MixinUtils.selectNotEmpty(sqlCfgModel.sqlDbType, sqlDbType);
|
|
186
186
|
sqlCfgModel.sqlDatabase = MixinUtils.selectNotEmpty(sqlCfgModel.sqlDatabase, sqlDatabase);
|
|
187
187
|
sqlCfgModel.sqlSchema = MixinUtils.selectNotEmpty(sqlCfgModel.sqlSchema, sqlSchema);
|
|
188
188
|
sqlCfgModel.sqlTable = MixinUtils.selectNotEmpty(sqlCfgModel.sqlTable, sqlTable);
|
|
@@ -226,11 +226,11 @@ class CrudProOriginToExecuteSql extends CrudProServiceBase {
|
|
|
226
226
|
const reqLimit = req.limit;
|
|
227
227
|
const limit = Math.min(maxLimit, reqLimit);
|
|
228
228
|
|
|
229
|
-
if (sqlCfg.
|
|
229
|
+
if (sqlCfg.sqlDbType === SqlDbType.postgres) {
|
|
230
230
|
return new SqlSegArg(' LIMIT ? OFFSET ? ', [limit, req.offset]);
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
if (sqlCfg.
|
|
233
|
+
if (sqlCfg.sqlDbType === SqlDbType.sqlserver) {
|
|
234
234
|
return new SqlSegArg(' OFFSET ? ROWS FETCH NEXT ? ROWS ONLY ', [ req.offset, limit]);
|
|
235
235
|
}
|
|
236
236
|
|
|
@@ -3,10 +3,10 @@ import {SqlDbType} from "../../models/keys";
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
function toSqlColumnName(columnName: string, sqlCfgModel: SqlCfgModel): string {
|
|
6
|
-
if (sqlCfgModel.
|
|
6
|
+
if (sqlCfgModel.sqlDbType === SqlDbType.postgres) {
|
|
7
7
|
return '"' + columnName + '"';
|
|
8
8
|
}
|
|
9
|
-
if (sqlCfgModel.
|
|
9
|
+
if (sqlCfgModel.sqlDbType === SqlDbType.sqlserver) {
|
|
10
10
|
return '[' + columnName + ']';
|
|
11
11
|
}
|
|
12
12
|
return '`' + columnName + '`';
|
|
@@ -215,7 +215,7 @@ export class AuthService {
|
|
|
215
215
|
sqlTable: SystemTables.sys_perm_user_role,
|
|
216
216
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
217
217
|
sqlDatabase: SystemDbName,
|
|
218
|
-
|
|
218
|
+
sqlDbType: SystemDbType,
|
|
219
219
|
}
|
|
220
220
|
);
|
|
221
221
|
const rows = res.getResModel().rows || [];
|
|
@@ -246,7 +246,7 @@ export class AuthService {
|
|
|
246
246
|
sqlTable: SystemTables.sys_perm_role_func,
|
|
247
247
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
248
248
|
sqlDatabase: SystemDbName,
|
|
249
|
-
|
|
249
|
+
sqlDbType: SystemDbType,
|
|
250
250
|
}
|
|
251
251
|
);
|
|
252
252
|
const rows = res.getResModel().rows || [];
|
|
@@ -99,7 +99,7 @@ export class EnumInfoService {
|
|
|
99
99
|
sqlTable: SystemTables.sys_configs,
|
|
100
100
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
101
101
|
sqlDatabase: SystemDbName,
|
|
102
|
-
|
|
102
|
+
sqlDbType: SystemDbType,
|
|
103
103
|
}
|
|
104
104
|
);
|
|
105
105
|
const obj = res1.getOneObj();
|
|
@@ -122,7 +122,7 @@ export class EnumInfoService {
|
|
|
122
122
|
sqlTable: SystemTables.sys_data_dict_item,
|
|
123
123
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
124
124
|
sqlDatabase: SystemDbName,
|
|
125
|
-
|
|
125
|
+
sqlDbType: SystemDbType,
|
|
126
126
|
}
|
|
127
127
|
);
|
|
128
128
|
const obj = res1.getResRows();
|
|
@@ -114,7 +114,7 @@ class FileDB {
|
|
|
114
114
|
sqlTable: 'sys_file',
|
|
115
115
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
116
116
|
sqlDatabase: SystemDbName,
|
|
117
|
-
|
|
117
|
+
sqlDbType: SystemDbType,
|
|
118
118
|
validateCfg: {
|
|
119
119
|
'condition.file_key': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
|
|
120
120
|
},
|
|
@@ -131,7 +131,7 @@ class FileDB {
|
|
|
131
131
|
sqlTable: 'sys_file',
|
|
132
132
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
133
133
|
sqlDatabase: SystemDbName,
|
|
134
|
-
|
|
134
|
+
sqlDbType: SystemDbType,
|
|
135
135
|
};
|
|
136
136
|
return await this.curdMixService.executeCrudByCfg(
|
|
137
137
|
{
|
|
@@ -150,7 +150,7 @@ class FileDB {
|
|
|
150
150
|
sqlTable: 'sys_assets_log',
|
|
151
151
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
152
152
|
sqlDatabase: SystemDbName,
|
|
153
|
-
|
|
153
|
+
sqlDbType: SystemDbType,
|
|
154
154
|
};
|
|
155
155
|
return await this.curdMixService.executeCrudByCfg({ data: fileInfo }, cfgModel);
|
|
156
156
|
}
|
|
@@ -161,7 +161,7 @@ class FileDB {
|
|
|
161
161
|
sqlTable: 'sys_file',
|
|
162
162
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_DELETE,
|
|
163
163
|
sqlDatabase: SystemDbName,
|
|
164
|
-
|
|
164
|
+
sqlDbType: SystemDbType,
|
|
165
165
|
validateCfg: {
|
|
166
166
|
'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMBER],
|
|
167
167
|
},
|
|
@@ -29,7 +29,7 @@ export class SysConfigService extends BaseService {
|
|
|
29
29
|
sqlTable: SystemTables.sys_configs,
|
|
30
30
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
31
31
|
sqlDatabase: SystemDbName,
|
|
32
|
-
|
|
32
|
+
sqlDbType: SystemDbType,
|
|
33
33
|
}
|
|
34
34
|
);
|
|
35
35
|
return res1.getOneObj();
|
|
@@ -34,7 +34,7 @@ export class UserAccountService {
|
|
|
34
34
|
sqlTable: SystemTables.sys_user_account,
|
|
35
35
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
36
36
|
sqlDatabase: SystemDbName,
|
|
37
|
-
|
|
37
|
+
sqlDbType: SystemDbType,
|
|
38
38
|
}
|
|
39
39
|
);
|
|
40
40
|
const { row } = query.getResModel();
|
|
@@ -63,7 +63,7 @@ export class UserAccountService {
|
|
|
63
63
|
sqlTable: SystemTables.sys_user_account,
|
|
64
64
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
65
65
|
sqlDatabase: SystemDbName,
|
|
66
|
-
|
|
66
|
+
sqlDbType: SystemDbType,
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
const reqJson: IRequestModel = {
|
|
@@ -102,7 +102,7 @@ export class UserAccountService {
|
|
|
102
102
|
sqlTable: SystemTables.sys_user_account,
|
|
103
103
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
104
104
|
sqlDatabase: SystemDbName,
|
|
105
|
-
|
|
105
|
+
sqlDbType: SystemDbType,
|
|
106
106
|
}
|
|
107
107
|
);
|
|
108
108
|
return CommonResult.successRes(res1.getResModel());
|
|
@@ -90,7 +90,7 @@ export class VisitStatService extends BaseService implements IScheduleService {
|
|
|
90
90
|
}, {
|
|
91
91
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
92
92
|
sqlDatabase: SystemDbName,
|
|
93
|
-
|
|
93
|
+
sqlDbType: SystemDbType,
|
|
94
94
|
sqlTable: SystemTables.sys_visit_stats,
|
|
95
95
|
})
|
|
96
96
|
|
|
@@ -54,7 +54,7 @@ export class WorkbenchService extends BaseService implements IScheduleService {
|
|
|
54
54
|
sqlTable: SystemTables.sys_workbench,
|
|
55
55
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
56
56
|
sqlDatabase: SystemDbName,
|
|
57
|
-
|
|
57
|
+
sqlDbType: SystemDbType,
|
|
58
58
|
});
|
|
59
59
|
listData = res.getResRows();
|
|
60
60
|
lruCache.set(CACHE_KEY_WORKBENCH_LIST, listData);
|
|
@@ -90,7 +90,7 @@ export class AnyApiService extends ApiBaseService {
|
|
|
90
90
|
method: `get_sys_anyapi_${methodCode}`,
|
|
91
91
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
92
92
|
sqlDatabase: SystemDbName,
|
|
93
|
-
|
|
93
|
+
sqlDbType: SystemDbType,
|
|
94
94
|
updateCfg: {},
|
|
95
95
|
}
|
|
96
96
|
);
|