midway-fatcms 0.0.1-beta.5 → 0.0.1-beta.6
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.
|
@@ -13,7 +13,13 @@ exports.default = (appInfo) => {
|
|
|
13
13
|
* 内置超级管理员用户
|
|
14
14
|
* 可以使用这个工具生成:http://127.0.0.1:7002/ns/api/helpers/generateDatabasePassword?loginName=xxxx&pw0=xxxx
|
|
15
15
|
*/
|
|
16
|
-
superAdminList: [
|
|
16
|
+
superAdminList: [
|
|
17
|
+
{
|
|
18
|
+
pwd_salt: 'c837f8c6de7261de228ec58b1b3ca9fa1htbvgm88',
|
|
19
|
+
pwd_md5: 'e334410fca1fd49972f63bf91f3be1be',
|
|
20
|
+
login_name: 'superadmin',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
17
23
|
// use for cookie sign key, should change to your own and keep security
|
|
18
24
|
keys: '1715169944707_323',
|
|
19
25
|
koa: {
|
|
@@ -29,7 +35,11 @@ exports.default = (appInfo) => {
|
|
|
29
35
|
jsonLimit: '1mb',
|
|
30
36
|
textLimit: '1mb',
|
|
31
37
|
xmlLimit: '1mb',
|
|
32
|
-
ignore: [
|
|
38
|
+
ignore: [
|
|
39
|
+
'/ns/gw/proxy/*',
|
|
40
|
+
'/ns/gw/file/uploadFile',
|
|
41
|
+
'/ns/api/manage/deploy/uploadAssets',
|
|
42
|
+
], // 忽略代理路径的 body 解析
|
|
33
43
|
},
|
|
34
44
|
mysql2: {
|
|
35
45
|
fatcms: {
|
|
@@ -45,7 +55,7 @@ exports.default = (appInfo) => {
|
|
|
45
55
|
},
|
|
46
56
|
},
|
|
47
57
|
postgres2: {
|
|
48
|
-
|
|
58
|
+
postgres_test_fatcms_inner_demo_config: {
|
|
49
59
|
user: 'postgres',
|
|
50
60
|
host: '127.0.0.1',
|
|
51
61
|
database: 'postgres',
|
|
@@ -54,10 +64,10 @@ exports.default = (appInfo) => {
|
|
|
54
64
|
max: 20,
|
|
55
65
|
idleTimeoutMillis: 30000,
|
|
56
66
|
connectionTimeoutMillis: 2000, // 连接超时时间(毫秒)
|
|
57
|
-
}
|
|
67
|
+
},
|
|
58
68
|
},
|
|
59
69
|
sqlserver2: {
|
|
60
|
-
|
|
70
|
+
sqlserver_master_fatcms_inner_demo_config: {
|
|
61
71
|
user: 'sa',
|
|
62
72
|
password: '123456',
|
|
63
73
|
server: '127.0.0.1',
|
|
@@ -65,19 +75,19 @@ exports.default = (appInfo) => {
|
|
|
65
75
|
database: 'master',
|
|
66
76
|
options: {
|
|
67
77
|
encrypt: false,
|
|
68
|
-
trustServerCertificate: true // 信任自签名证书
|
|
78
|
+
trustServerCertificate: true, // 信任自签名证书
|
|
69
79
|
},
|
|
70
80
|
pool: {
|
|
71
81
|
max: 30,
|
|
72
82
|
min: 1,
|
|
73
|
-
idleTimeoutMillis: 30000 // 连接空闲超时时间(毫秒)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
83
|
+
idleTimeoutMillis: 30000, // 连接空闲超时时间(毫秒)
|
|
84
|
+
},
|
|
85
|
+
},
|
|
76
86
|
},
|
|
77
87
|
redis: {
|
|
78
88
|
client: {
|
|
79
89
|
port: 6379,
|
|
80
|
-
host:
|
|
90
|
+
host: '127.0.0.1', // Redis host
|
|
81
91
|
},
|
|
82
92
|
},
|
|
83
93
|
oss: {
|
|
@@ -105,7 +115,34 @@ exports.default = (appInfo) => {
|
|
|
105
115
|
fileSize: '20mb',
|
|
106
116
|
limit: '20mb',
|
|
107
117
|
// whitelist: string[],文件扩展名白名单
|
|
108
|
-
whitelist: [
|
|
118
|
+
whitelist: [
|
|
119
|
+
'.jpg',
|
|
120
|
+
'.jpeg',
|
|
121
|
+
'.png',
|
|
122
|
+
'.gif',
|
|
123
|
+
'.pdf',
|
|
124
|
+
'.zip',
|
|
125
|
+
'.xlsx',
|
|
126
|
+
'.docx',
|
|
127
|
+
'.pptx',
|
|
128
|
+
'.txt',
|
|
129
|
+
'.md',
|
|
130
|
+
'.json',
|
|
131
|
+
'.js',
|
|
132
|
+
'.cjs',
|
|
133
|
+
'.ejs',
|
|
134
|
+
'.jsx',
|
|
135
|
+
'.css',
|
|
136
|
+
'.java',
|
|
137
|
+
'.ts',
|
|
138
|
+
'.tsx',
|
|
139
|
+
'.less',
|
|
140
|
+
'.scss',
|
|
141
|
+
'.html',
|
|
142
|
+
'.ttf',
|
|
143
|
+
'.map',
|
|
144
|
+
'.svg',
|
|
145
|
+
],
|
|
109
146
|
// tmpdir: string,上传的文件临时存储路径
|
|
110
147
|
tmpdir: (0, path_1.join)((0, os_1.tmpdir)(), 'fatcms-upload-files'),
|
|
111
148
|
// cleanTimeout: number,上传的文件在临时目录中多久之后自动删除,默认为 5 分钟
|
|
@@ -26,8 +26,7 @@ let CrudStandardDesignApi = class CrudStandardDesignApi extends BaseApiControlle
|
|
|
26
26
|
const postgresList = Object.keys(this.postgres2Config || {});
|
|
27
27
|
const sqlServerList = Object.keys(this.sqlserver2Config || {});
|
|
28
28
|
const toSelectList = (dbCfgNameList, dbType) => {
|
|
29
|
-
return dbCfgNameList.map(
|
|
30
|
-
const dbName = item;
|
|
29
|
+
return dbCfgNameList.map(dbName => {
|
|
31
30
|
const value = (0, DatabaseName_1.toDatabaseNameStr)(dbType, dbName);
|
|
32
31
|
return { value, label: value, dbName, dbType };
|
|
33
32
|
});
|
|
@@ -35,7 +34,14 @@ let CrudStandardDesignApi = class CrudStandardDesignApi extends BaseApiControlle
|
|
|
35
34
|
const mysqlObjList = toSelectList(mysqlList, keys_1.SqlDbType.mysql);
|
|
36
35
|
const postgresObjList = toSelectList(postgresList, keys_1.SqlDbType.postgres);
|
|
37
36
|
const sqlserverObjList = toSelectList(sqlServerList, keys_1.SqlDbType.sqlserver);
|
|
38
|
-
const databaseList = [
|
|
37
|
+
const databaseList = [
|
|
38
|
+
...mysqlObjList,
|
|
39
|
+
...postgresObjList,
|
|
40
|
+
...sqlserverObjList,
|
|
41
|
+
].filter((obj) => {
|
|
42
|
+
const value = '' + obj.value;
|
|
43
|
+
return !value.endsWith('_fatcms_inner_demo_config');
|
|
44
|
+
});
|
|
39
45
|
return {
|
|
40
46
|
success: true,
|
|
41
47
|
data: databaseList,
|
|
@@ -131,13 +137,10 @@ let CrudStandardDesignApi = class CrudStandardDesignApi extends BaseApiControlle
|
|
|
131
137
|
async getTableListOfSqlserver(dbName) {
|
|
132
138
|
const dbConfig = this.sqlserver2Config[dbName];
|
|
133
139
|
if (!dbConfig) {
|
|
134
|
-
throw new exceptions_1.CommonException(
|
|
140
|
+
throw new exceptions_1.CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
|
|
135
141
|
}
|
|
136
142
|
const dbType = keys_1.SqlDbType.sqlserver;
|
|
137
|
-
const sql =
|
|
138
|
-
"SELECT name as tablename \n" +
|
|
139
|
-
"FROM sys.tables" +
|
|
140
|
-
"";
|
|
143
|
+
const sql = 'SELECT name as tablename FROM sys.tables';
|
|
141
144
|
const arr = await this.curdMixService.executeSQL({
|
|
142
145
|
executeSql: sql,
|
|
143
146
|
sqlDatabase: dbName,
|
|
@@ -150,8 +153,9 @@ let CrudStandardDesignApi = class CrudStandardDesignApi extends BaseApiControlle
|
|
|
150
153
|
return {
|
|
151
154
|
value: tableName,
|
|
152
155
|
label: tableName,
|
|
153
|
-
dbName,
|
|
154
|
-
|
|
156
|
+
dbName,
|
|
157
|
+
dbType,
|
|
158
|
+
tableName,
|
|
155
159
|
};
|
|
156
160
|
});
|
|
157
161
|
return common_dto_1.CommonResult.successRes(tableNames);
|
|
@@ -159,65 +163,76 @@ let CrudStandardDesignApi = class CrudStandardDesignApi extends BaseApiControlle
|
|
|
159
163
|
async getTableListOfPostgreSQL(dbName) {
|
|
160
164
|
const dbConfig = this.postgres2Config[dbName];
|
|
161
165
|
if (!dbConfig) {
|
|
162
|
-
throw new exceptions_1.CommonException(
|
|
166
|
+
throw new exceptions_1.CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
|
|
163
167
|
}
|
|
164
|
-
const schemaname = "public";
|
|
165
|
-
const sql = "" +
|
|
166
|
-
"SELECT tablename\n" +
|
|
167
|
-
"FROM pg_tables\n" +
|
|
168
|
-
`WHERE schemaname = '${schemaname}' \n` +
|
|
169
|
-
"ORDER BY tablename;";
|
|
170
168
|
const dbType = keys_1.SqlDbType.postgres;
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
169
|
+
const schemaname = 'public';
|
|
170
|
+
const tableListSql = '' +
|
|
171
|
+
'SELECT tablename\n' +
|
|
172
|
+
'FROM pg_tables\n' +
|
|
173
|
+
`WHERE schemaname = '${schemaname}' \n` +
|
|
174
|
+
'ORDER BY tablename;';
|
|
175
|
+
const viewListSql = '' +
|
|
176
|
+
'SELECT viewname as tablename\n' +
|
|
177
|
+
'FROM pg_views\n' +
|
|
178
|
+
`WHERE schemaname = '${schemaname}' \n` +
|
|
179
|
+
'ORDER BY viewname;';
|
|
180
|
+
const toSelectOptions = async (executeSql, tableType) => {
|
|
181
|
+
const arr = await this.curdMixService.executeSQL({
|
|
182
|
+
executeSql: executeSql,
|
|
183
|
+
sqlDatabase: dbName,
|
|
184
|
+
sqlDdType: dbType,
|
|
185
|
+
crudType: keys_1.KeyOfCrudTypes.SYS_QUERY,
|
|
186
|
+
executeSqlArgs: [],
|
|
187
|
+
});
|
|
188
|
+
return arr.map(v => {
|
|
189
|
+
const tableName = v.tablename;
|
|
190
|
+
return {
|
|
191
|
+
value: tableName,
|
|
192
|
+
label: tableName,
|
|
193
|
+
dbName,
|
|
194
|
+
dbType,
|
|
195
|
+
tableName,
|
|
196
|
+
tableType,
|
|
197
|
+
};
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
const tableNames = await toSelectOptions(tableListSql, 'table');
|
|
201
|
+
const viewNames = await toSelectOptions(viewListSql, 'view');
|
|
202
|
+
const tableNameMerge = [...tableNames, ...viewNames];
|
|
203
|
+
return common_dto_1.CommonResult.successRes(tableNameMerge);
|
|
188
204
|
}
|
|
189
205
|
async getTableFieldsOfSqlServer(dbName, tableName) {
|
|
190
206
|
const dbConfig = this.sqlserver2Config[dbName];
|
|
191
207
|
if (!dbConfig) {
|
|
192
|
-
throw new exceptions_1.CommonException(
|
|
208
|
+
throw new exceptions_1.CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
|
|
193
209
|
}
|
|
194
|
-
const columnArraySql =
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
"WHERE\n" +
|
|
210
|
+
const columnArraySql = '' +
|
|
211
|
+
'SELECT\n' +
|
|
212
|
+
' c.name AS column_name,\n' +
|
|
213
|
+
' t.name AS data_type,\n' +
|
|
214
|
+
' c.max_length AS max_length,\n' +
|
|
215
|
+
' c.precision,\n' +
|
|
216
|
+
' c.scale,\n' +
|
|
217
|
+
' c.is_nullable,\n' +
|
|
218
|
+
' c.is_identity,\n' +
|
|
219
|
+
' dc.definition AS column_default, \n' +
|
|
220
|
+
' ep.value AS column_description \n' +
|
|
221
|
+
'FROM\n' +
|
|
222
|
+
' sys.columns c\n' +
|
|
223
|
+
' JOIN\n' +
|
|
224
|
+
' sys.types t ON c.user_type_id = t.user_type_id\n' +
|
|
225
|
+
' LEFT JOIN\n' +
|
|
226
|
+
' sys.default_constraints dc\n' +
|
|
227
|
+
' ON c.default_object_id = dc.object_id \n' +
|
|
228
|
+
' LEFT JOIN\n' +
|
|
229
|
+
' sys.extended_properties ep\n' +
|
|
230
|
+
' ON c.object_id = ep.major_id\n' +
|
|
231
|
+
' AND c.column_id = ep.minor_id\n' +
|
|
232
|
+
'WHERE\n' +
|
|
218
233
|
` c.object_id = OBJECT_ID('${tableName}') \n` +
|
|
219
|
-
|
|
220
|
-
|
|
234
|
+
' ORDER BY\n' +
|
|
235
|
+
' c.column_id;';
|
|
221
236
|
const dbType = keys_1.SqlDbType.sqlserver;
|
|
222
237
|
const columnArray = await this.curdMixService.executeSQL({
|
|
223
238
|
executeSql: columnArraySql,
|
|
@@ -232,11 +247,11 @@ let CrudStandardDesignApi = class CrudStandardDesignApi extends BaseApiControlle
|
|
|
232
247
|
fieldIndex: column_name || '',
|
|
233
248
|
fieldTitle: column_description || column_name || '',
|
|
234
249
|
isNullable: is_nullable,
|
|
235
|
-
defaultValue: column_default ||
|
|
250
|
+
defaultValue: column_default || '',
|
|
236
251
|
extra: others,
|
|
237
252
|
// key: column_name, // 索引
|
|
238
253
|
type: data_type,
|
|
239
|
-
is_identity: is_identity
|
|
254
|
+
is_identity: is_identity,
|
|
240
255
|
};
|
|
241
256
|
});
|
|
242
257
|
return common_dto_1.CommonResult.successRes({
|
|
@@ -248,9 +263,9 @@ let CrudStandardDesignApi = class CrudStandardDesignApi extends BaseApiControlle
|
|
|
248
263
|
async getTableFieldsOfPostgreSQL(dbName, tableName) {
|
|
249
264
|
const dbConfig = this.postgres2Config[dbName];
|
|
250
265
|
if (!dbConfig) {
|
|
251
|
-
throw new exceptions_1.CommonException(
|
|
266
|
+
throw new exceptions_1.CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
|
|
252
267
|
}
|
|
253
|
-
const schemaname =
|
|
268
|
+
const schemaname = 'public';
|
|
254
269
|
const columnArraySql = `
|
|
255
270
|
|
|
256
271
|
SELECT
|
|
@@ -259,7 +274,7 @@ let CrudStandardDesignApi = class CrudStandardDesignApi extends BaseApiControlle
|
|
|
259
274
|
WHERE table_schema = $1 and table_name = $2
|
|
260
275
|
ORDER BY ordinal_position;
|
|
261
276
|
|
|
262
|
-
`.trim();
|
|
277
|
+
`.trim();
|
|
263
278
|
const dbType = keys_1.SqlDbType.postgres;
|
|
264
279
|
const columnArray = await this.curdMixService.executeSQL({
|
|
265
280
|
executeSql: columnArraySql,
|
|
@@ -274,11 +289,11 @@ let CrudStandardDesignApi = class CrudStandardDesignApi extends BaseApiControlle
|
|
|
274
289
|
fieldIndex: column_name || '',
|
|
275
290
|
fieldTitle: column_name || '',
|
|
276
291
|
isNullable: is_nullable,
|
|
277
|
-
defaultValue: column_default ||
|
|
292
|
+
defaultValue: column_default || '',
|
|
278
293
|
extra: others,
|
|
279
294
|
// key: column_name, // 索引
|
|
280
295
|
type: data_type,
|
|
281
|
-
is_identity: is_identity
|
|
296
|
+
is_identity: is_identity,
|
|
282
297
|
};
|
|
283
298
|
});
|
|
284
299
|
return {
|
package/package.json
CHANGED
|
@@ -3,24 +3,25 @@ import { tmpdir } from 'os';
|
|
|
3
3
|
import { join } from 'path';
|
|
4
4
|
import { readFileSync } from 'fs';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
6
|
export default (appInfo: any) => {
|
|
9
7
|
return {
|
|
10
|
-
|
|
11
8
|
siteFile: {
|
|
12
9
|
favicon: readFileSync(join(__dirname, '../views/static/favicon.ico')),
|
|
13
10
|
},
|
|
14
11
|
|
|
15
|
-
encryptedFieldList: [
|
|
16
|
-
|
|
17
|
-
],
|
|
12
|
+
encryptedFieldList: [],
|
|
18
13
|
|
|
19
14
|
/**
|
|
20
15
|
* 内置超级管理员用户
|
|
21
16
|
* 可以使用这个工具生成:http://127.0.0.1:7002/ns/api/helpers/generateDatabasePassword?loginName=xxxx&pw0=xxxx
|
|
22
17
|
*/
|
|
23
|
-
superAdminList: [
|
|
18
|
+
superAdminList: [
|
|
19
|
+
{
|
|
20
|
+
pwd_salt: 'c837f8c6de7261de228ec58b1b3ca9fa1htbvgm88',
|
|
21
|
+
pwd_md5: 'e334410fca1fd49972f63bf91f3be1be',
|
|
22
|
+
login_name: 'superadmin',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
24
25
|
|
|
25
26
|
// use for cookie sign key, should change to your own and keep security
|
|
26
27
|
keys: '1715169944707_323',
|
|
@@ -40,7 +41,11 @@ export default (appInfo: any) => {
|
|
|
40
41
|
jsonLimit: '1mb',
|
|
41
42
|
textLimit: '1mb',
|
|
42
43
|
xmlLimit: '1mb',
|
|
43
|
-
ignore: [
|
|
44
|
+
ignore: [
|
|
45
|
+
'/ns/gw/proxy/*',
|
|
46
|
+
'/ns/gw/file/uploadFile',
|
|
47
|
+
'/ns/api/manage/deploy/uploadAssets',
|
|
48
|
+
], // 忽略代理路径的 body 解析
|
|
44
49
|
},
|
|
45
50
|
|
|
46
51
|
mysql2: {
|
|
@@ -57,7 +62,7 @@ export default (appInfo: any) => {
|
|
|
57
62
|
},
|
|
58
63
|
},
|
|
59
64
|
postgres2: {
|
|
60
|
-
|
|
65
|
+
postgres_test_fatcms_inner_demo_config: {
|
|
61
66
|
user: 'postgres',
|
|
62
67
|
host: '127.0.0.1',
|
|
63
68
|
database: 'postgres',
|
|
@@ -66,12 +71,11 @@ export default (appInfo: any) => {
|
|
|
66
71
|
max: 20, // 连接池最大连接数
|
|
67
72
|
idleTimeoutMillis: 30000, // 空闲连接超时时间(毫秒)
|
|
68
73
|
connectionTimeoutMillis: 2000, // 连接超时时间(毫秒)
|
|
69
|
-
}
|
|
74
|
+
},
|
|
70
75
|
},
|
|
71
76
|
|
|
72
|
-
|
|
73
77
|
sqlserver2: {
|
|
74
|
-
|
|
78
|
+
sqlserver_master_fatcms_inner_demo_config: {
|
|
75
79
|
user: 'sa',
|
|
76
80
|
password: '123456', // 你的SA密码
|
|
77
81
|
server: '127.0.0.1',
|
|
@@ -79,20 +83,20 @@ export default (appInfo: any) => {
|
|
|
79
83
|
database: 'master', // 默认数据库
|
|
80
84
|
options: {
|
|
81
85
|
encrypt: false, // Docker容器内通常不需要加密
|
|
82
|
-
trustServerCertificate: true // 信任自签名证书
|
|
86
|
+
trustServerCertificate: true, // 信任自签名证书
|
|
83
87
|
},
|
|
84
88
|
pool: {
|
|
85
|
-
max: 30,
|
|
86
|
-
min: 1,
|
|
87
|
-
idleTimeoutMillis: 30000
|
|
88
|
-
}
|
|
89
|
-
}
|
|
89
|
+
max: 30, // 最大连接数
|
|
90
|
+
min: 1, // 最小连接数
|
|
91
|
+
idleTimeoutMillis: 30000, // 连接空闲超时时间(毫秒)
|
|
92
|
+
},
|
|
93
|
+
},
|
|
90
94
|
},
|
|
91
95
|
|
|
92
96
|
redis: {
|
|
93
97
|
client: {
|
|
94
98
|
port: 6379, // Redis port
|
|
95
|
-
host:
|
|
99
|
+
host: '127.0.0.1', // Redis host
|
|
96
100
|
},
|
|
97
101
|
},
|
|
98
102
|
|
|
@@ -122,7 +126,34 @@ export default (appInfo: any) => {
|
|
|
122
126
|
fileSize: '20mb',
|
|
123
127
|
limit: '20mb',
|
|
124
128
|
// whitelist: string[],文件扩展名白名单
|
|
125
|
-
whitelist: [
|
|
129
|
+
whitelist: [
|
|
130
|
+
'.jpg',
|
|
131
|
+
'.jpeg',
|
|
132
|
+
'.png',
|
|
133
|
+
'.gif',
|
|
134
|
+
'.pdf',
|
|
135
|
+
'.zip',
|
|
136
|
+
'.xlsx',
|
|
137
|
+
'.docx',
|
|
138
|
+
'.pptx',
|
|
139
|
+
'.txt',
|
|
140
|
+
'.md',
|
|
141
|
+
'.json',
|
|
142
|
+
'.js',
|
|
143
|
+
'.cjs',
|
|
144
|
+
'.ejs',
|
|
145
|
+
'.jsx',
|
|
146
|
+
'.css',
|
|
147
|
+
'.java',
|
|
148
|
+
'.ts',
|
|
149
|
+
'.tsx',
|
|
150
|
+
'.less',
|
|
151
|
+
'.scss',
|
|
152
|
+
'.html',
|
|
153
|
+
'.ttf',
|
|
154
|
+
'.map',
|
|
155
|
+
'.svg',
|
|
156
|
+
],
|
|
126
157
|
// tmpdir: string,上传的文件临时存储路径
|
|
127
158
|
tmpdir: join(tmpdir(), 'fatcms-upload-files'),
|
|
128
159
|
// cleanTimeout: number,上传的文件在临时目录中多久之后自动删除,默认为 5 分钟
|
|
@@ -148,7 +179,9 @@ export default (appInfo: any) => {
|
|
|
148
179
|
ejs: {},
|
|
149
180
|
|
|
150
181
|
info: {
|
|
151
|
-
infoPath: `/_my_info_${Date.now()}_${Math.floor(
|
|
182
|
+
infoPath: `/_my_info_${Date.now()}_${Math.floor(
|
|
183
|
+
Math.random() * 1000000
|
|
184
|
+
)}`, // 实际上隐藏了info路径
|
|
152
185
|
},
|
|
153
186
|
|
|
154
187
|
// 使用浏览器插件配置header信息:插件名:ModHeader - Modify HTTP headers
|
|
@@ -166,7 +199,5 @@ export default (appInfo: any) => {
|
|
|
166
199
|
|
|
167
200
|
// 是否启用内置的定时任务
|
|
168
201
|
fatcmsScheduleService: true,
|
|
169
|
-
|
|
170
|
-
|
|
171
202
|
} as MidwayConfig;
|
|
172
203
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {Controller, Get, Inject} from '@midwayjs/core';
|
|
2
|
-
import {Context} from '@midwayjs/koa';
|
|
3
|
-
import {BaseApiController} from './base/BaseApiController';
|
|
4
|
-
import {WorkbenchService} from '../service/WorkbenchService';
|
|
5
|
-
import {createRenderUtils} from "../libs/utils/render-utils";
|
|
6
|
-
import {privateAES} from "../libs/utils/crypto-utils";
|
|
1
|
+
import { Controller, Get, Inject } from '@midwayjs/core';
|
|
2
|
+
import { Context } from '@midwayjs/koa';
|
|
3
|
+
import { BaseApiController } from './base/BaseApiController';
|
|
4
|
+
import { WorkbenchService } from '../service/WorkbenchService';
|
|
5
|
+
import { createRenderUtils } from "../libs/utils/render-utils";
|
|
6
|
+
import { privateAES } from "../libs/utils/crypto-utils";
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -4,13 +4,11 @@ import { BaseApiController } from '../base/BaseApiController';
|
|
|
4
4
|
import { parseCreateSqlToTitleMap } from '../../libs/utils/parseCreateSql';
|
|
5
5
|
import { checkPermission } from '../../middleware/permission.middleware';
|
|
6
6
|
import { SystemFuncCode } from '../../models/SystemPerm';
|
|
7
|
-
import {KeyOfCrudTypes, KeysOfSimpleSQL, SqlDbType} from '../../libs/crud-pro/models/keys';
|
|
7
|
+
import { KeyOfCrudTypes, KeysOfSimpleSQL, SqlDbType } from '../../libs/crud-pro/models/keys';
|
|
8
8
|
import { SystemTables } from '../../models/SystemTables';
|
|
9
|
-
import {CommonException} from "../../libs/crud-pro/exceptions";
|
|
10
|
-
import {parseDatabaseName, toDatabaseNameStr} from "../../libs/crud-pro/utils/DatabaseName";
|
|
11
|
-
import {CommonResult} from "../../libs/utils/common-dto";
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
import { CommonException } from "../../libs/crud-pro/exceptions";
|
|
10
|
+
import { parseDatabaseName, toDatabaseNameStr } from "../../libs/crud-pro/utils/DatabaseName";
|
|
11
|
+
import { CommonResult } from "../../libs/utils/common-dto";
|
|
14
12
|
|
|
15
13
|
|
|
16
14
|
@Controller('/ns/api/manage/CrudStandardDesignApi', { middleware: [checkPermission(SystemFuncCode.CrudStandardDesignRead)] })
|
|
@@ -30,19 +28,25 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
30
28
|
const postgresList = Object.keys(this.postgres2Config || {});
|
|
31
29
|
const sqlServerList = Object.keys(this.sqlserver2Config || {});
|
|
32
30
|
|
|
33
|
-
const toSelectList= (dbCfgNameList:string[], dbType: SqlDbType)=> {
|
|
34
|
-
return dbCfgNameList.map(
|
|
35
|
-
const dbName = item;
|
|
31
|
+
const toSelectList = (dbCfgNameList: string[], dbType: SqlDbType) => {
|
|
32
|
+
return dbCfgNameList.map(dbName => {
|
|
36
33
|
const value = toDatabaseNameStr(dbType, dbName);
|
|
37
|
-
return {value, label: value, dbName, dbType}
|
|
34
|
+
return { value, label: value, dbName, dbType };
|
|
38
35
|
});
|
|
39
|
-
}
|
|
36
|
+
};
|
|
40
37
|
|
|
41
38
|
const mysqlObjList = toSelectList(mysqlList, SqlDbType.mysql);
|
|
42
39
|
const postgresObjList = toSelectList(postgresList, SqlDbType.postgres);
|
|
43
40
|
const sqlserverObjList = toSelectList(sqlServerList, SqlDbType.sqlserver);
|
|
44
41
|
|
|
45
|
-
const databaseList = [
|
|
42
|
+
const databaseList = [
|
|
43
|
+
...mysqlObjList,
|
|
44
|
+
...postgresObjList,
|
|
45
|
+
...sqlserverObjList,
|
|
46
|
+
].filter((obj: any) => {
|
|
47
|
+
const value = '' + obj.value;
|
|
48
|
+
return !value.endsWith('_fatcms_inner_demo_config');
|
|
49
|
+
});
|
|
46
50
|
|
|
47
51
|
return {
|
|
48
52
|
success: true,
|
|
@@ -51,7 +55,7 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
@Post('/getTableList')
|
|
54
|
-
async getTableList():
|
|
58
|
+
async getTableList(): Promise<CommonResult> {
|
|
55
59
|
const { databaseName } = this.ctx.request.body as any;
|
|
56
60
|
const { dbType, dbName } = parseDatabaseName(databaseName);
|
|
57
61
|
|
|
@@ -144,7 +148,10 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
144
148
|
*/
|
|
145
149
|
@Post('/getRoleOptionsList')
|
|
146
150
|
async getRoleOptionsList() {
|
|
147
|
-
return this.executeSysSimpleSQL(
|
|
151
|
+
return this.executeSysSimpleSQL(
|
|
152
|
+
SystemTables.sys_perm_role,
|
|
153
|
+
KeysOfSimpleSQL.SIMPLE_QUERY_PAGE
|
|
154
|
+
);
|
|
148
155
|
}
|
|
149
156
|
|
|
150
157
|
/**
|
|
@@ -152,21 +159,24 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
152
159
|
*/
|
|
153
160
|
@Post('/getFuncOptionsList')
|
|
154
161
|
async getFuncOptionsList() {
|
|
155
|
-
return this.executeSysSimpleSQL(
|
|
162
|
+
return this.executeSysSimpleSQL(
|
|
163
|
+
SystemTables.sys_perm_func,
|
|
164
|
+
KeysOfSimpleSQL.SIMPLE_QUERY_PAGE
|
|
165
|
+
);
|
|
156
166
|
}
|
|
157
167
|
|
|
158
168
|
private async getTableListOfSqlserver(dbName: string): Promise<CommonResult> {
|
|
159
169
|
const dbConfig = this.sqlserver2Config[dbName];
|
|
160
170
|
if (!dbConfig) {
|
|
161
|
-
throw new CommonException(
|
|
171
|
+
throw new CommonException(
|
|
172
|
+
'DB_NOT_FOUND',
|
|
173
|
+
'数据库配置没有找到:' + dbName
|
|
174
|
+
);
|
|
162
175
|
}
|
|
163
176
|
|
|
164
177
|
const dbType = SqlDbType.sqlserver;
|
|
165
178
|
|
|
166
|
-
const sql =
|
|
167
|
-
"SELECT name as tablename \n" +
|
|
168
|
-
"FROM sys.tables" +
|
|
169
|
-
"";
|
|
179
|
+
const sql = 'SELECT name as tablename FROM sys.tables';
|
|
170
180
|
const arr = await this.curdMixService.executeSQL({
|
|
171
181
|
executeSql: sql,
|
|
172
182
|
sqlDatabase: dbName,
|
|
@@ -177,92 +187,111 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
177
187
|
|
|
178
188
|
|
|
179
189
|
const tableNames: string[] = arr.map(v => {
|
|
180
|
-
const tableName = v.tablename
|
|
190
|
+
const tableName = v.tablename;
|
|
181
191
|
return {
|
|
182
|
-
value: tableName
|
|
192
|
+
value: tableName, //[dbName, dbType, tableName].join(SPLIT_CONST),
|
|
183
193
|
label: tableName,
|
|
184
|
-
dbName,
|
|
185
|
-
|
|
186
|
-
|
|
194
|
+
dbName,
|
|
195
|
+
dbType,
|
|
196
|
+
tableName,
|
|
197
|
+
};
|
|
187
198
|
});
|
|
188
199
|
return CommonResult.successRes(tableNames);
|
|
189
|
-
|
|
190
200
|
}
|
|
191
201
|
|
|
192
|
-
|
|
193
202
|
private async getTableListOfPostgreSQL(dbName: string): Promise<CommonResult> {
|
|
194
203
|
|
|
195
204
|
const dbConfig = this.postgres2Config[dbName];
|
|
196
205
|
if (!dbConfig) {
|
|
197
|
-
throw new CommonException(
|
|
206
|
+
throw new CommonException(
|
|
207
|
+
'DB_NOT_FOUND',
|
|
208
|
+
'数据库配置没有找到:' + dbName
|
|
209
|
+
);
|
|
198
210
|
}
|
|
199
211
|
|
|
212
|
+
const dbType = SqlDbType.postgres;
|
|
213
|
+
const schemaname = 'public';
|
|
200
214
|
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
"FROM pg_tables\n" +
|
|
215
|
+
const tableListSql =
|
|
216
|
+
'' +
|
|
217
|
+
'SELECT tablename\n' +
|
|
218
|
+
'FROM pg_tables\n' +
|
|
206
219
|
`WHERE schemaname = '${schemaname}' \n` +
|
|
207
|
-
|
|
220
|
+
'ORDER BY tablename;';
|
|
208
221
|
|
|
209
|
-
const
|
|
222
|
+
const viewListSql =
|
|
223
|
+
'' +
|
|
224
|
+
'SELECT viewname as tablename\n' +
|
|
225
|
+
'FROM pg_views\n' +
|
|
226
|
+
`WHERE schemaname = '${schemaname}' \n` +
|
|
227
|
+
'ORDER BY viewname;';
|
|
228
|
+
|
|
229
|
+
const toSelectOptions = async (executeSql: string, tableType: string) => {
|
|
230
|
+
const arr = await this.curdMixService.executeSQL({
|
|
231
|
+
executeSql: executeSql,
|
|
232
|
+
sqlDatabase: dbName,
|
|
233
|
+
sqlDdType: dbType,
|
|
234
|
+
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
235
|
+
executeSqlArgs: [],
|
|
236
|
+
});
|
|
237
|
+
return arr.map(v => {
|
|
238
|
+
const tableName = v.tablename;
|
|
239
|
+
return {
|
|
240
|
+
value: tableName, //[dbName, dbType, tableName].join(SPLIT_CONST),
|
|
241
|
+
label: tableName,
|
|
242
|
+
dbName,
|
|
243
|
+
dbType,
|
|
244
|
+
tableName,
|
|
245
|
+
tableType,
|
|
246
|
+
};
|
|
247
|
+
});
|
|
248
|
+
};
|
|
210
249
|
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
sqlDatabase: dbName,
|
|
214
|
-
sqlDdType: dbType,
|
|
215
|
-
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
216
|
-
executeSqlArgs: [],
|
|
217
|
-
});
|
|
250
|
+
const tableNames: any[] = await toSelectOptions(tableListSql, 'table');
|
|
251
|
+
const viewNames: any[] = await toSelectOptions(viewListSql, 'view');
|
|
218
252
|
|
|
253
|
+
const tableNameMerge = [...tableNames, ...viewNames];
|
|
219
254
|
|
|
220
|
-
|
|
221
|
-
const tableName = v.tablename
|
|
222
|
-
return {
|
|
223
|
-
value: tableName , //[dbName, dbType, tableName].join(SPLIT_CONST),
|
|
224
|
-
label: tableName,
|
|
225
|
-
dbName, dbType,
|
|
226
|
-
tableName
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
return CommonResult.successRes(tableNames);
|
|
255
|
+
return CommonResult.successRes(tableNameMerge);
|
|
230
256
|
}
|
|
231
257
|
|
|
232
258
|
|
|
233
259
|
private async getTableFieldsOfSqlServer(dbName: string, tableName: string): Promise<CommonResult> {
|
|
234
260
|
const dbConfig = this.sqlserver2Config[dbName];
|
|
235
261
|
if (!dbConfig) {
|
|
236
|
-
throw new CommonException(
|
|
262
|
+
throw new CommonException(
|
|
263
|
+
'DB_NOT_FOUND',
|
|
264
|
+
'数据库配置没有找到:' + dbName
|
|
265
|
+
);
|
|
237
266
|
}
|
|
238
267
|
|
|
239
|
-
const columnArraySql =
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
268
|
+
const columnArraySql =
|
|
269
|
+
'' +
|
|
270
|
+
'SELECT\n' +
|
|
271
|
+
' c.name AS column_name,\n' +
|
|
272
|
+
' t.name AS data_type,\n' +
|
|
273
|
+
' c.max_length AS max_length,\n' +
|
|
274
|
+
' c.precision,\n' +
|
|
275
|
+
' c.scale,\n' +
|
|
276
|
+
' c.is_nullable,\n' +
|
|
277
|
+
' c.is_identity,\n' +
|
|
278
|
+
' dc.definition AS column_default, \n' +
|
|
279
|
+
' ep.value AS column_description \n' +
|
|
280
|
+
'FROM\n' +
|
|
281
|
+
' sys.columns c\n' +
|
|
282
|
+
' JOIN\n' +
|
|
283
|
+
' sys.types t ON c.user_type_id = t.user_type_id\n' +
|
|
284
|
+
' LEFT JOIN\n' +
|
|
285
|
+
' sys.default_constraints dc\n' +
|
|
286
|
+
' ON c.default_object_id = dc.object_id \n' +
|
|
287
|
+
' LEFT JOIN\n' +
|
|
288
|
+
' sys.extended_properties ep\n' +
|
|
289
|
+
' ON c.object_id = ep.major_id\n' +
|
|
290
|
+
' AND c.column_id = ep.minor_id\n' +
|
|
291
|
+
'WHERE\n' +
|
|
263
292
|
` c.object_id = OBJECT_ID('${tableName}') \n` +
|
|
264
|
-
|
|
265
|
-
|
|
293
|
+
' ORDER BY\n' +
|
|
294
|
+
' c.column_id;';
|
|
266
295
|
|
|
267
296
|
const dbType = SqlDbType.sqlserver;
|
|
268
297
|
|
|
@@ -275,16 +304,25 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
275
304
|
});
|
|
276
305
|
|
|
277
306
|
const fields = columnArray.map(columnObj => {
|
|
278
|
-
const {
|
|
307
|
+
const {
|
|
308
|
+
column_name,
|
|
309
|
+
is_nullable,
|
|
310
|
+
column_default,
|
|
311
|
+
data_type,
|
|
312
|
+
is_identity,
|
|
313
|
+
column_description,
|
|
314
|
+
...others
|
|
315
|
+
} = columnObj;
|
|
316
|
+
|
|
279
317
|
return {
|
|
280
318
|
fieldIndex: column_name || '',
|
|
281
|
-
fieldTitle: column_description || column_name ||
|
|
319
|
+
fieldTitle: column_description || column_name || '',
|
|
282
320
|
isNullable: is_nullable,
|
|
283
|
-
defaultValue: column_default ||
|
|
321
|
+
defaultValue: column_default || '',
|
|
284
322
|
extra: others,
|
|
285
323
|
// key: column_name, // 索引
|
|
286
324
|
type: data_type,
|
|
287
|
-
is_identity: is_identity
|
|
325
|
+
is_identity: is_identity,
|
|
288
326
|
};
|
|
289
327
|
});
|
|
290
328
|
|
|
@@ -293,17 +331,18 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
293
331
|
tableName,
|
|
294
332
|
tableTitle: tableName,
|
|
295
333
|
});
|
|
296
|
-
|
|
297
|
-
|
|
298
334
|
}
|
|
299
335
|
|
|
300
336
|
private async getTableFieldsOfPostgreSQL(dbName: string, tableName: string) {
|
|
301
337
|
const dbConfig = this.postgres2Config[dbName];
|
|
302
338
|
if (!dbConfig) {
|
|
303
|
-
throw new CommonException(
|
|
339
|
+
throw new CommonException(
|
|
340
|
+
'DB_NOT_FOUND',
|
|
341
|
+
'数据库配置没有找到:' + dbName
|
|
342
|
+
);
|
|
304
343
|
}
|
|
305
344
|
|
|
306
|
-
const schemaname =
|
|
345
|
+
const schemaname = 'public';
|
|
307
346
|
|
|
308
347
|
const columnArraySql = `
|
|
309
348
|
|
|
@@ -313,7 +352,7 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
313
352
|
WHERE table_schema = $1 and table_name = $2
|
|
314
353
|
ORDER BY ordinal_position;
|
|
315
354
|
|
|
316
|
-
`.trim();
|
|
355
|
+
`.trim();
|
|
317
356
|
|
|
318
357
|
const dbType = SqlDbType.postgres;
|
|
319
358
|
|
|
@@ -322,22 +361,28 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
322
361
|
sqlDatabase: dbName,
|
|
323
362
|
sqlDdType: dbType,
|
|
324
363
|
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
325
|
-
executeSqlArgs: [
|
|
364
|
+
executeSqlArgs: [schemaname, tableName],
|
|
326
365
|
});
|
|
327
366
|
|
|
328
|
-
|
|
329
|
-
|
|
330
367
|
const fields = columnArray.map(columnObj => {
|
|
331
|
-
const {
|
|
368
|
+
const {
|
|
369
|
+
column_name,
|
|
370
|
+
is_nullable,
|
|
371
|
+
column_default,
|
|
372
|
+
data_type,
|
|
373
|
+
is_identity,
|
|
374
|
+
...others
|
|
375
|
+
} = columnObj;
|
|
376
|
+
|
|
332
377
|
return {
|
|
333
378
|
fieldIndex: column_name || '',
|
|
334
379
|
fieldTitle: column_name || '',
|
|
335
380
|
isNullable: is_nullable,
|
|
336
|
-
defaultValue: column_default ||
|
|
381
|
+
defaultValue: column_default || '',
|
|
337
382
|
extra: others,
|
|
338
383
|
// key: column_name, // 索引
|
|
339
384
|
type: data_type,
|
|
340
|
-
is_identity: is_identity
|
|
385
|
+
is_identity: is_identity,
|
|
341
386
|
};
|
|
342
387
|
});
|
|
343
388
|
|