midway-fatcms 0.0.1-beta.5 → 0.0.1-beta.7
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/config/config.default.js +48 -11
- package/dist/controller/base/BaseApiController.js +9 -6
- package/dist/controller/gateway/DocGatewayController.js +13 -8
- package/dist/controller/home.controller.js +2 -2
- package/dist/controller/manage/CrudStandardDesignApi.js +83 -68
- package/dist/controller/manage/DeployManageApi.js +6 -4
- package/dist/controller/manage/SuperAdminManageApi.js +12 -8
- package/dist/controller/manage/SysConfigMangeApi.js +3 -1
- package/dist/controller/render/AppRenderController.js +4 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/libs/global-config/global-config.d.ts +19 -0
- package/dist/libs/global-config/global-config.js +25 -0
- package/dist/models/SystemTables.d.ts +0 -3
- package/dist/models/SystemTables.js +1 -4
- package/dist/service/AuthService.js +7 -4
- package/dist/service/EnumInfoService.js +7 -4
- package/dist/service/FileCenterService.js +13 -9
- package/dist/service/SysConfigService.js +4 -2
- package/dist/service/UserAccountService.js +10 -6
- package/dist/service/VisitStatService.js +4 -2
- package/dist/service/WorkbenchService.js +4 -2
- package/dist/service/anyapi/AnyApiService.js +4 -2
- package/dist/service/crudstd/CrudStdService.js +6 -2
- package/dist/service/curd/CurdMixByAccountService.js +4 -2
- package/dist/service/curd/CurdMixByDictService.js +4 -2
- package/dist/service/curd/CurdMixBySysConfigService.js +4 -2
- package/dist/service/curd/CurdMixByWorkbenchService.js +4 -2
- package/dist/service/proxyapi/ProxyApiLoadService.js +7 -4
- package/package.json +1 -1
- package/src/config/config.default.ts +54 -23
- package/src/controller/base/BaseApiController.ts +13 -13
- package/src/controller/gateway/DocGatewayController.ts +9 -1
- package/src/controller/home.controller.ts +8 -10
- package/src/controller/manage/CrudStandardDesignApi.ts +139 -94
- package/src/controller/manage/DeployManageApi.ts +4 -1
- package/src/controller/manage/SuperAdminManageApi.ts +11 -2
- package/src/controller/manage/SysConfigMangeApi.ts +4 -1
- package/src/controller/render/AppRenderController.ts +17 -14
- package/src/index.ts +1 -1
- package/src/libs/global-config/global-config.ts +47 -0
- package/src/models/SystemTables.ts +0 -4
- package/src/service/AuthService.ts +10 -5
- package/src/service/EnumInfoService.ts +6 -1
- package/src/service/FileCenterService.ts +8 -2
- package/src/service/SysConfigService.ts +9 -5
- package/src/service/UserAccountService.ts +11 -1
- package/src/service/VisitStatService.ts +5 -1
- package/src/service/WorkbenchService.ts +6 -1
- package/src/service/anyapi/AnyApiService.ts +6 -1
- package/src/service/crudstd/CrudStdService.ts +11 -1
- package/src/service/curd/CurdMixByAccountService.ts +6 -1
- package/src/service/curd/CurdMixByDictService.ts +7 -1
- package/src/service/curd/CurdMixBySysConfigService.ts +6 -1
- package/src/service/curd/CurdMixByWorkbenchService.ts +5 -1
- package/src/service/proxyapi/ProxyApiLoadService.ts +9 -1
|
@@ -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 分钟
|
|
@@ -13,7 +13,7 @@ exports.BaseApiController = void 0;
|
|
|
13
13
|
const core_1 = require("@midwayjs/core");
|
|
14
14
|
const CurdMixService_1 = require("../../service/curd/CurdMixService");
|
|
15
15
|
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
16
|
-
const
|
|
16
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
17
17
|
const UserAccountService_1 = require("../../service/UserAccountService");
|
|
18
18
|
const CurdMixUtils_1 = require("../../service/curd/CurdMixUtils");
|
|
19
19
|
const BaseService_1 = require("../../service/base/BaseService");
|
|
@@ -25,11 +25,12 @@ let BaseApiController = class BaseApiController extends BaseService_1.BaseServic
|
|
|
25
25
|
return this.ctx.userSession.getSessionInfo();
|
|
26
26
|
}
|
|
27
27
|
async executeSysSQL(executeSql, executeSqlArgs) {
|
|
28
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
28
29
|
return await this.curdMixService.executeSQL({
|
|
29
30
|
executeSql: executeSql,
|
|
30
31
|
executeSqlArgs: executeSqlArgs,
|
|
31
|
-
sqlDatabase:
|
|
32
|
-
sqlDdType:
|
|
32
|
+
sqlDatabase: SystemDbName,
|
|
33
|
+
sqlDdType: SystemDbType,
|
|
33
34
|
crudType: keys_1.KeyOfCrudTypes.SYS_QUERY,
|
|
34
35
|
});
|
|
35
36
|
}
|
|
@@ -41,14 +42,15 @@ let BaseApiController = class BaseApiController extends BaseService_1.BaseServic
|
|
|
41
42
|
* @protected
|
|
42
43
|
*/
|
|
43
44
|
async executeSysSimpleSQL(sqlTable, sqlSimpleName, params) {
|
|
45
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
44
46
|
const body = this.ctx.request.body;
|
|
45
47
|
const req = this.ctx.req;
|
|
46
48
|
const cfgModel = {
|
|
47
49
|
method: `${req.method}:${req.url}`,
|
|
48
50
|
sqlTable,
|
|
49
51
|
sqlSimpleName,
|
|
50
|
-
sqlDatabase:
|
|
51
|
-
sqlDdType:
|
|
52
|
+
sqlDatabase: SystemDbName,
|
|
53
|
+
sqlDdType: SystemDbType,
|
|
52
54
|
updateCfg: {},
|
|
53
55
|
};
|
|
54
56
|
if (params && typeof params === 'object') {
|
|
@@ -61,7 +63,8 @@ let BaseApiController = class BaseApiController extends BaseService_1.BaseServic
|
|
|
61
63
|
return await this.curdMixService.executeCrudByCfg(body, cfgModel);
|
|
62
64
|
}
|
|
63
65
|
get sysDBUtil() {
|
|
64
|
-
|
|
66
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
67
|
+
return this.curdMixService.getBbUtil(SystemDbName, SystemDbType);
|
|
65
68
|
}
|
|
66
69
|
addAccountBasicInfoCfgModel(cfgModel) {
|
|
67
70
|
let columnsRelation = cfgModel.columnsRelation;
|
|
@@ -16,6 +16,7 @@ exports.DocGatewayController = void 0;
|
|
|
16
16
|
const core_1 = require("@midwayjs/core");
|
|
17
17
|
const BaseApiController_1 = require("../base/BaseApiController");
|
|
18
18
|
const SystemTables_1 = require("../../models/SystemTables");
|
|
19
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
19
20
|
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
20
21
|
const WorkbenchService_1 = require("../../service/WorkbenchService");
|
|
21
22
|
const common_dto_1 = require("../../libs/utils/common-dto");
|
|
@@ -40,6 +41,7 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
|
|
|
40
41
|
if (nxRes !== 'OK') {
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
44
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
43
45
|
await this.curdMixService.executeCrudByCfg({
|
|
44
46
|
data: {
|
|
45
47
|
pv: pv + 1
|
|
@@ -51,8 +53,8 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
|
|
|
51
53
|
}, {
|
|
52
54
|
sqlTable: SystemTables_1.SystemTables.sys_doc,
|
|
53
55
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
54
|
-
sqlDatabase:
|
|
55
|
-
sqlDdType:
|
|
56
|
+
sqlDatabase: SystemDbName,
|
|
57
|
+
sqlDdType: SystemDbType,
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
60
|
/**
|
|
@@ -66,6 +68,7 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
|
|
|
66
68
|
if (!docLibInfoRes.success) {
|
|
67
69
|
return docLibInfoRes;
|
|
68
70
|
}
|
|
71
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
69
72
|
const res = await this.curdMixService.executeCrudByCfg({
|
|
70
73
|
condition: {
|
|
71
74
|
id: parseInt(docId),
|
|
@@ -74,8 +77,8 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
|
|
|
74
77
|
}, {
|
|
75
78
|
sqlTable: SystemTables_1.SystemTables.sys_doc,
|
|
76
79
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
77
|
-
sqlDatabase:
|
|
78
|
-
sqlDdType:
|
|
80
|
+
sqlDatabase: SystemDbName,
|
|
81
|
+
sqlDdType: SystemDbType,
|
|
79
82
|
});
|
|
80
83
|
// 更新PV数据
|
|
81
84
|
const docObj = res.getOneObj();
|
|
@@ -94,6 +97,7 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
|
|
|
94
97
|
if (!docLibInfoRes.success) {
|
|
95
98
|
return docLibInfoRes;
|
|
96
99
|
}
|
|
100
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
97
101
|
return this.curdMixService.executeCrudByCfg({
|
|
98
102
|
columns: 'id,title,doc_category_code,sort_index',
|
|
99
103
|
orderBy: 'sort_index+,id-',
|
|
@@ -106,8 +110,8 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
|
|
|
106
110
|
}, {
|
|
107
111
|
sqlTable: SystemTables_1.SystemTables.sys_doc,
|
|
108
112
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
109
|
-
sqlDatabase:
|
|
110
|
-
sqlDdType:
|
|
113
|
+
sqlDatabase: SystemDbName,
|
|
114
|
+
sqlDdType: SystemDbType,
|
|
111
115
|
});
|
|
112
116
|
}
|
|
113
117
|
/**
|
|
@@ -116,6 +120,7 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
|
|
|
116
120
|
*/
|
|
117
121
|
async getDocLibInfo(docLibId) {
|
|
118
122
|
checkIsNumber(docLibId, 'docLibId');
|
|
123
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
119
124
|
const s = await this.curdMixService.executeCrudByCfg({
|
|
120
125
|
condition: {
|
|
121
126
|
id: parseInt(docLibId),
|
|
@@ -123,8 +128,8 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
|
|
|
123
128
|
}, {
|
|
124
129
|
sqlTable: SystemTables_1.SystemTables.sys_doc_lib,
|
|
125
130
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
126
|
-
sqlDatabase:
|
|
127
|
-
sqlDdType:
|
|
131
|
+
sqlDatabase: SystemDbName,
|
|
132
|
+
sqlDdType: SystemDbType,
|
|
128
133
|
});
|
|
129
134
|
const docLibInfo = s.getOneObj();
|
|
130
135
|
if (!docLibInfo) {
|
|
@@ -31,13 +31,13 @@ let HomeController = class HomeController extends BaseApiController_1.BaseApiCon
|
|
|
31
31
|
}
|
|
32
32
|
const html_content = workbenchInfo.html_content || '未配置HTML模版';
|
|
33
33
|
const userInfo = this.getUserSessionInfo();
|
|
34
|
-
const fatcmscsrftoken = await crypto_utils_1.privateAES.time_encrypt_utf8_base64(
|
|
34
|
+
const fatcmscsrftoken = await crypto_utils_1.privateAES.time_encrypt_utf8_base64('' + Date.now());
|
|
35
35
|
const utils = (0, render_utils_1.createRenderUtils)({
|
|
36
36
|
ctx: this.ctx,
|
|
37
37
|
userInfo,
|
|
38
38
|
workbenchInfo,
|
|
39
39
|
package_assets: workbenchInfo.package_assets,
|
|
40
|
-
fatcmscsrftoken
|
|
40
|
+
fatcmscsrftoken,
|
|
41
41
|
});
|
|
42
42
|
return this.ctx.renderString(html_content, { workbenchInfo, userInfo, utils }, { viewEngine: 'ejs' });
|
|
43
43
|
}
|
|
@@ -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 {
|
|
@@ -24,6 +24,7 @@ const FileCenterService_1 = require("../../service/FileCenterService");
|
|
|
24
24
|
const SystemTables_1 = require("../../models/SystemTables");
|
|
25
25
|
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
26
26
|
const WorkbenchService_1 = require("../../service/WorkbenchService");
|
|
27
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
27
28
|
function toAssetsSchema(fileList) {
|
|
28
29
|
for (let i = 0; i < fileList.length; i++) {
|
|
29
30
|
const fileListElement = fileList[i];
|
|
@@ -109,6 +110,7 @@ let DeployManageApi = class DeployManageApi extends BaseApiController_1.BaseApiC
|
|
|
109
110
|
if (!Array.isArray(cdnResources) || cdnResources.length === 0) {
|
|
110
111
|
throw new devops_1.BizException('cdnResources参数不存在');
|
|
111
112
|
}
|
|
113
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
112
114
|
const workbench = await this.curdMixService.executeCrudByCfg({
|
|
113
115
|
data: {
|
|
114
116
|
package_assets: JSON.stringify(toAssetsSchema(cdnResources)),
|
|
@@ -118,8 +120,8 @@ let DeployManageApi = class DeployManageApi extends BaseApiController_1.BaseApiC
|
|
|
118
120
|
}
|
|
119
121
|
}, {
|
|
120
122
|
sqlTable: SystemTables_1.SystemTables.sys_workbench,
|
|
121
|
-
sqlDatabase:
|
|
122
|
-
sqlDdType:
|
|
123
|
+
sqlDatabase: SystemDbName,
|
|
124
|
+
sqlDdType: SystemDbType,
|
|
123
125
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE
|
|
124
126
|
});
|
|
125
127
|
const app = await this.curdMixService.executeCrudByCfg({
|
|
@@ -131,8 +133,8 @@ let DeployManageApi = class DeployManageApi extends BaseApiController_1.BaseApiC
|
|
|
131
133
|
}
|
|
132
134
|
}, {
|
|
133
135
|
sqlTable: SystemTables_1.SystemTables.sys_app,
|
|
134
|
-
sqlDatabase:
|
|
135
|
-
sqlDdType:
|
|
136
|
+
sqlDatabase: SystemDbName,
|
|
137
|
+
sqlDdType: SystemDbType,
|
|
136
138
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE
|
|
137
139
|
});
|
|
138
140
|
this.workbenchService.clearCache();
|
|
@@ -18,11 +18,13 @@ const permission_middleware_1 = require("../../middleware/permission.middleware"
|
|
|
18
18
|
const SystemPerm_1 = require("../../models/SystemPerm");
|
|
19
19
|
const SystemTables_1 = require("../../models/SystemTables");
|
|
20
20
|
const common_dto_1 = require("../../libs/utils/common-dto");
|
|
21
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
21
22
|
let SuperAdminManageApi = class SuperAdminManageApi extends BaseApiController_1.BaseApiController {
|
|
22
23
|
/**
|
|
23
24
|
* 预设系统内置功能点数据
|
|
24
25
|
*/
|
|
25
26
|
async presetsFuncCode() {
|
|
27
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
26
28
|
const funcCodeList = Object.keys(SystemPerm_1.SystemFuncCodeNameMap);
|
|
27
29
|
for (let i = 0; i < funcCodeList.length; i++) {
|
|
28
30
|
const funcCode = funcCodeList[i];
|
|
@@ -36,8 +38,8 @@ let SuperAdminManageApi = class SuperAdminManageApi extends BaseApiController_1.
|
|
|
36
38
|
}, {
|
|
37
39
|
sqlTable: SystemTables_1.SystemTables.sys_perm_func,
|
|
38
40
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
39
|
-
sqlDatabase:
|
|
40
|
-
sqlDdType:
|
|
41
|
+
sqlDatabase: SystemDbName,
|
|
42
|
+
sqlDdType: SystemDbType,
|
|
41
43
|
});
|
|
42
44
|
}
|
|
43
45
|
return common_dto_1.CommonResult.successRes();
|
|
@@ -46,6 +48,7 @@ let SuperAdminManageApi = class SuperAdminManageApi extends BaseApiController_1.
|
|
|
46
48
|
* 预设系统内置角色数据
|
|
47
49
|
*/
|
|
48
50
|
async presetsRoleCode() {
|
|
51
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
49
52
|
const roleCodeList = [SystemPerm_1.SystemRoleCode.DevOpsViewer, SystemPerm_1.SystemRoleCode.DevOpsWriter];
|
|
50
53
|
for (let i = 0; i < roleCodeList.length; i++) {
|
|
51
54
|
const roleCode = roleCodeList[i];
|
|
@@ -59,8 +62,8 @@ let SuperAdminManageApi = class SuperAdminManageApi extends BaseApiController_1.
|
|
|
59
62
|
}, {
|
|
60
63
|
sqlTable: SystemTables_1.SystemTables.sys_perm_role,
|
|
61
64
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
62
|
-
sqlDatabase:
|
|
63
|
-
sqlDdType:
|
|
65
|
+
sqlDatabase: SystemDbName,
|
|
66
|
+
sqlDdType: SystemDbType,
|
|
64
67
|
});
|
|
65
68
|
}
|
|
66
69
|
return common_dto_1.CommonResult.successRes();
|
|
@@ -69,6 +72,7 @@ let SuperAdminManageApi = class SuperAdminManageApi extends BaseApiController_1.
|
|
|
69
72
|
* 预设系统内置:角色和功能点的关系
|
|
70
73
|
*/
|
|
71
74
|
async presetsRoleFuncList() {
|
|
75
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
72
76
|
const funcCodeList = Object.keys(SystemPerm_1.SystemFuncCodeNameMap);
|
|
73
77
|
for (let i = 0; i < funcCodeList.length; i++) {
|
|
74
78
|
const funcCode = funcCodeList[i];
|
|
@@ -81,8 +85,8 @@ let SuperAdminManageApi = class SuperAdminManageApi extends BaseApiController_1.
|
|
|
81
85
|
}, {
|
|
82
86
|
sqlTable: SystemTables_1.SystemTables.sys_perm_role_func,
|
|
83
87
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
84
|
-
sqlDatabase:
|
|
85
|
-
sqlDdType:
|
|
88
|
+
sqlDatabase: SystemDbName,
|
|
89
|
+
sqlDdType: SystemDbType,
|
|
86
90
|
});
|
|
87
91
|
}
|
|
88
92
|
for (let i = 0; i < funcCodeList.length; i++) {
|
|
@@ -97,8 +101,8 @@ let SuperAdminManageApi = class SuperAdminManageApi extends BaseApiController_1.
|
|
|
97
101
|
}, {
|
|
98
102
|
sqlTable: SystemTables_1.SystemTables.sys_perm_role_func,
|
|
99
103
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
100
|
-
sqlDatabase:
|
|
101
|
-
sqlDdType:
|
|
104
|
+
sqlDatabase: SystemDbName,
|
|
105
|
+
sqlDdType: SystemDbType,
|
|
102
106
|
});
|
|
103
107
|
}
|
|
104
108
|
}
|
|
@@ -18,6 +18,7 @@ const SystemPerm_1 = require("../../models/SystemPerm");
|
|
|
18
18
|
const bizmodels_1 = require("../../models/bizmodels");
|
|
19
19
|
const SystemTables_1 = require("../../models/SystemTables");
|
|
20
20
|
const common_dto_1 = require("../../libs/utils/common-dto");
|
|
21
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
21
22
|
let SysConfigMangeApi = class SysConfigMangeApi extends BaseApiController_1.BaseApiController {
|
|
22
23
|
async getSysConfigList() {
|
|
23
24
|
return this.executeSysSimpleSQL('sys_configs', keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_PAGE, {
|
|
@@ -47,12 +48,13 @@ let SysConfigMangeApi = class SysConfigMangeApi extends BaseApiController_1.Base
|
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
50
|
async updateSysConfig() {
|
|
51
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
50
52
|
const body = this.ctx.request.body;
|
|
51
53
|
const id = body.condition.id;
|
|
52
54
|
if (!id) {
|
|
53
55
|
return common_dto_1.CommonResult.errorRes("id不能为空");
|
|
54
56
|
}
|
|
55
|
-
const sysConfig = await this.curdMixService.getBbUtil(
|
|
57
|
+
const sysConfig = await this.curdMixService.getBbUtil(SystemDbName, SystemDbType).getOne({ condition: body.condition }, SystemTables_1.SystemTables.sys_configs);
|
|
56
58
|
if (!sysConfig) {
|
|
57
59
|
return common_dto_1.CommonResult.errorRes("配置项不存在");
|
|
58
60
|
}
|
|
@@ -20,18 +20,20 @@ const SystemTables_1 = require("../../models/SystemTables");
|
|
|
20
20
|
const WorkbenchService_1 = require("../../service/WorkbenchService");
|
|
21
21
|
const render_utils_1 = require("../../libs/utils/render-utils");
|
|
22
22
|
const crypto_utils_1 = require("../../libs/utils/crypto-utils");
|
|
23
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
23
24
|
/**
|
|
24
25
|
* 渲染独立外部应用
|
|
25
26
|
*/
|
|
26
27
|
let AppRenderController = class AppRenderController extends BaseApiController_1.BaseApiController {
|
|
27
28
|
async home(appPath) {
|
|
29
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
28
30
|
const appPathArr = appPath.split('/');
|
|
29
31
|
const appCode = appPathArr[0];
|
|
30
32
|
const res = await this.curdMixService.executeCrudByCfg({ condition: { app_code: appCode } }, {
|
|
31
33
|
sqlTable: SystemTables_1.SystemTables.sys_app,
|
|
32
34
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
33
|
-
sqlDatabase:
|
|
34
|
-
sqlDdType:
|
|
35
|
+
sqlDatabase: SystemDbName,
|
|
36
|
+
sqlDdType: SystemDbType,
|
|
35
37
|
});
|
|
36
38
|
const { row: appInfo } = res.getResModel();
|
|
37
39
|
if (!appInfo) {
|
package/dist/index.d.ts
CHANGED
|
@@ -91,3 +91,4 @@ export * from './libs/crud-pro/models/keys';
|
|
|
91
91
|
export * from './libs/crud-pro/models/ExecuteContextFunc';
|
|
92
92
|
export * from './libs/crud-pro/models/RequestCfgModel';
|
|
93
93
|
export * from './libs/crud-pro/models/SqlSegArg';
|
|
94
|
+
export * from './libs/global-config/global-config';
|