midway-fatcms 0.0.1-beta.1 → 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/config/config.default.js +52 -15
- package/dist/controller/base/BaseApiController.js +9 -6
- package/dist/controller/gateway/CrudMtdGatewayController.js +4 -1
- package/dist/controller/gateway/DocGatewayController.js +13 -8
- package/dist/controller/gateway/StaticController.d.ts +3 -0
- package/dist/controller/gateway/StaticController.js +41 -21
- package/dist/controller/home.controller.js +2 -2
- package/dist/controller/manage/CrudStandardDesignApi.js +89 -74
- 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/manage/UserAccountManageApi.d.ts +1 -1
- package/dist/controller/manage/UserAccountManageApi.js +5 -0
- package/dist/controller/myinfo/AuthController.d.ts +0 -4
- package/dist/controller/myinfo/AuthController.js +0 -53
- package/dist/controller/render/AppRenderController.js +4 -2
- package/dist/controller/test.controller.js +1 -1
- package/dist/index.d.ts +28 -4
- package/dist/index.js +28 -4
- 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/libs/global-config/global-config.d.ts +39 -0
- package/dist/libs/global-config/global-config.js +32 -0
- package/dist/models/SystemTables.d.ts +0 -3
- package/dist/models/SystemTables.js +1 -4
- package/dist/service/AuthService.js +8 -5
- 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 +7 -3
- package/dist/service/curd/CurdMixByAccountService.js +12 -6
- package/dist/service/curd/CurdMixByDictService.js +4 -2
- package/dist/service/curd/CurdMixByLinkToCustomService.js +1 -1
- package/dist/service/curd/CurdMixBySysConfigService.js +4 -2
- package/dist/service/curd/CurdMixByWorkbenchService.js +4 -2
- package/dist/service/curd/CurdMixService.d.ts +1 -1
- package/dist/service/curd/CurdMixService.js +2 -2
- package/dist/service/curd/CurdMixUtils.d.ts +7 -0
- package/dist/service/curd/CurdMixUtils.js +31 -1
- package/dist/service/curd/CurdProService.d.ts +3 -3
- package/dist/service/curd/CurdProService.js +9 -9
- package/dist/service/proxyapi/ProxyApiLoadService.js +7 -4
- package/dist/views/404_app.html +31 -0
- package/dist/views/404_workbench.html +34 -0
- package/dist/views/static/favicon.ico +0 -0
- package/package.json +5 -1
- package/src/config/config.default.ts +58 -27
- package/src/controller/base/BaseApiController.ts +14 -14
- package/src/controller/gateway/CrudMtdGatewayController.ts +6 -2
- package/src/controller/gateway/DocGatewayController.ts +13 -5
- package/src/controller/gateway/StaticController.ts +50 -25
- package/src/controller/home.controller.ts +8 -10
- package/src/controller/manage/CrudStandardDesignApi.ts +145 -100
- package/src/controller/manage/DeployManageApi.ts +6 -3
- package/src/controller/manage/SuperAdminManageApi.ts +15 -6
- package/src/controller/manage/SysConfigMangeApi.ts +4 -1
- package/src/controller/manage/UserAccountManageApi.ts +6 -0
- package/src/controller/myinfo/AuthController.ts +4 -66
- package/src/controller/render/AppRenderController.ts +18 -15
- package/src/controller/test.controller.ts +1 -1
- package/src/index.ts +33 -4
- 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/libs/global-config/global-config.ts +72 -0
- package/src/models/SystemTables.ts +0 -4
- package/src/service/AuthService.ts +13 -8
- package/src/service/EnumInfoService.ts +8 -3
- package/src/service/FileCenterService.ts +12 -6
- package/src/service/SysConfigService.ts +10 -6
- package/src/service/UserAccountService.ts +14 -4
- package/src/service/VisitStatService.ts +6 -2
- package/src/service/WorkbenchService.ts +7 -2
- package/src/service/anyapi/AnyApiService.ts +5 -2
- package/src/service/crudstd/CrudStdService.ts +13 -3
- package/src/service/curd/CurdMixByAccountService.ts +14 -6
- package/src/service/curd/CurdMixByDictService.ts +8 -2
- package/src/service/curd/CurdMixByLinkToCustomService.ts +1 -1
- package/src/service/curd/CurdMixBySysConfigService.ts +7 -2
- package/src/service/curd/CurdMixByWorkbenchService.ts +6 -2
- package/src/service/curd/CurdMixService.ts +2 -2
- package/src/service/curd/CurdMixUtils.ts +42 -12
- package/src/service/curd/CurdProService.ts +10 -10
- package/src/service/proxyapi/ProxyApiLoadService.ts +11 -3
- package/src/views/404_app.html +31 -0
- package/src/views/404_workbench.html +34 -0
- package/src/views/static/favicon.ico +0 -0
- package/dist/controller/medstatistic/MedAdminController.d.ts +0 -35
- package/dist/controller/medstatistic/MedAdminController.js +0 -205
- package/dist/controller/medstatistic/MedClientController.d.ts +0 -28
- package/dist/controller/medstatistic/MedClientController.js +0 -188
- package/dist/controller/medstatistic/MedMessageService.d.ts +0 -19
- package/dist/controller/medstatistic/MedMessageService.js +0 -95
- package/dist/controller/medstatistic/MedScoreService.d.ts +0 -21
- package/dist/controller/medstatistic/MedScoreService.js +0 -107
- package/dist/controller/medstatistic/constants.d.ts +0 -32
- package/dist/controller/medstatistic/constants.js +0 -43
- package/src/controller/medstatistic/MedAdminController.ts +0 -221
- package/src/controller/medstatistic/MedClientController.ts +0 -188
- package/src/controller/medstatistic/MedMessageService.ts +0 -89
- package/src/controller/medstatistic/MedScoreService.ts +0 -108
- package/src/controller/medstatistic/constants.ts +0 -63
|
@@ -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
|
|
|
@@ -66,7 +70,7 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
66
70
|
const res = await this.curdMixService.executeSQL({
|
|
67
71
|
executeSql: 'SHOW TABLES',
|
|
68
72
|
sqlDatabase: dbName,
|
|
69
|
-
|
|
73
|
+
sqlDbType: SqlDbType.mysql,
|
|
70
74
|
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
71
75
|
});
|
|
72
76
|
|
|
@@ -101,13 +105,13 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
101
105
|
const tableDescribe = await this.curdMixService.executeSQL({
|
|
102
106
|
executeSql: 'describe ' + tableName,
|
|
103
107
|
sqlDatabase: dbName,
|
|
104
|
-
|
|
108
|
+
sqlDbType: SqlDbType.mysql,
|
|
105
109
|
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
106
110
|
});
|
|
107
111
|
const tableCreate = await this.curdMixService.executeSQL({
|
|
108
112
|
executeSql: 'show create table ' + tableName,
|
|
109
113
|
sqlDatabase: dbName,
|
|
110
|
-
|
|
114
|
+
sqlDbType: SqlDbType.mysql,
|
|
111
115
|
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
112
116
|
});
|
|
113
117
|
|
|
@@ -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,139 +159,170 @@ 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,
|
|
173
|
-
|
|
183
|
+
sqlDbType: dbType,
|
|
174
184
|
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
175
185
|
executeSqlArgs: [],
|
|
176
186
|
});
|
|
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
|
|
215
|
+
const tableListSql =
|
|
216
|
+
'' +
|
|
217
|
+
'SELECT tablename\n' +
|
|
218
|
+
'FROM pg_tables\n' +
|
|
219
|
+
`WHERE schemaname = '${schemaname}' \n` +
|
|
220
|
+
'ORDER BY tablename;';
|
|
202
221
|
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
222
|
+
const viewListSql =
|
|
223
|
+
'' +
|
|
224
|
+
'SELECT viewname as tablename\n' +
|
|
225
|
+
'FROM pg_views\n' +
|
|
206
226
|
`WHERE schemaname = '${schemaname}' \n` +
|
|
207
|
-
|
|
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
|
+
sqlDbType: 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
|
+
};
|
|
208
249
|
|
|
209
|
-
const
|
|
250
|
+
const tableNames: any[] = await toSelectOptions(tableListSql, 'table');
|
|
251
|
+
const viewNames: any[] = await toSelectOptions(viewListSql, 'view');
|
|
210
252
|
|
|
211
|
-
const
|
|
212
|
-
executeSql: sql,
|
|
213
|
-
sqlDatabase: dbName,
|
|
214
|
-
sqlDdType: dbType,
|
|
215
|
-
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
216
|
-
executeSqlArgs: [],
|
|
217
|
-
});
|
|
253
|
+
const tableNameMerge = [...tableNames, ...viewNames];
|
|
218
254
|
|
|
219
|
-
|
|
220
|
-
const tableNames: string[] = arr.map(v => {
|
|
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
|
|
|
269
298
|
const columnArray = await this.curdMixService.executeSQL({
|
|
270
299
|
executeSql: columnArraySql,
|
|
271
300
|
sqlDatabase: dbName,
|
|
272
|
-
|
|
301
|
+
sqlDbType: dbType,
|
|
273
302
|
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
274
303
|
executeSqlArgs: [],
|
|
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,31 +352,37 @@ 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
|
|
|
320
359
|
const columnArray = await this.curdMixService.executeSQL({
|
|
321
360
|
executeSql: columnArraySql,
|
|
322
361
|
sqlDatabase: dbName,
|
|
323
|
-
|
|
362
|
+
sqlDbType: 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
|
|
|
@@ -7,9 +7,10 @@ import {CommonResult} from "../../libs/utils/common-dto";
|
|
|
7
7
|
import {AccessType, UploadCategoryType} from "../../models/bizmodels";
|
|
8
8
|
import {BizException} from "../../models/devops";
|
|
9
9
|
import {FileCenterService, toDownloadPaths} from '../../service/FileCenterService';
|
|
10
|
-
import {
|
|
10
|
+
import {SystemTables} from "../../models/SystemTables";
|
|
11
11
|
import {KeysOfSimpleSQL} from "../../libs/crud-pro/models/keys";
|
|
12
12
|
import {WorkbenchService} from "../../service/WorkbenchService";
|
|
13
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
interface IReleaseAssetsParams {
|
|
@@ -128,6 +129,8 @@ export class DeployManageApi extends BaseApiController {
|
|
|
128
129
|
throw new BizException('cdnResources参数不存在');
|
|
129
130
|
}
|
|
130
131
|
|
|
132
|
+
const {SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
133
|
+
|
|
131
134
|
const workbench = await this.curdMixService.executeCrudByCfg({
|
|
132
135
|
data: {
|
|
133
136
|
package_assets: JSON.stringify(toAssetsSchema(cdnResources)),
|
|
@@ -138,7 +141,7 @@ export class DeployManageApi extends BaseApiController {
|
|
|
138
141
|
},{
|
|
139
142
|
sqlTable: SystemTables.sys_workbench,
|
|
140
143
|
sqlDatabase: SystemDbName,
|
|
141
|
-
|
|
144
|
+
sqlDbType: SystemDbType,
|
|
142
145
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE
|
|
143
146
|
});
|
|
144
147
|
|
|
@@ -154,7 +157,7 @@ export class DeployManageApi extends BaseApiController {
|
|
|
154
157
|
},{
|
|
155
158
|
sqlTable: SystemTables.sys_app,
|
|
156
159
|
sqlDatabase: SystemDbName,
|
|
157
|
-
|
|
160
|
+
sqlDbType: SystemDbType,
|
|
158
161
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE
|
|
159
162
|
});
|
|
160
163
|
|
|
@@ -5,8 +5,9 @@ import { KeysOfSimpleSQL } from '../../libs/crud-pro/models/keys';
|
|
|
5
5
|
import { BaseApiController } from '../base/BaseApiController';
|
|
6
6
|
import { checkRole } from '../../middleware/permission.middleware';
|
|
7
7
|
import { SystemFuncCodeNameMap, SystemRoleCode, SystemRoleCodeNameMap } from '../../models/SystemPerm';
|
|
8
|
-
import {
|
|
9
|
-
import {CommonResult} from "../../libs/utils/common-dto";
|
|
8
|
+
import { SystemTables } from '../../models/SystemTables';
|
|
9
|
+
import { CommonResult } from "../../libs/utils/common-dto";
|
|
10
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
10
11
|
|
|
11
12
|
@Controller('/ns/api/manage/superAdmin', { middleware: [checkRole(SystemRoleCode.SuperAdmin)] })
|
|
12
13
|
export class SuperAdminManageApi extends BaseApiController {
|
|
@@ -22,6 +23,8 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
22
23
|
*/
|
|
23
24
|
@Post('/presetsFuncCode')
|
|
24
25
|
async presetsFuncCode() {
|
|
26
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
27
|
+
|
|
25
28
|
const funcCodeList = Object.keys(SystemFuncCodeNameMap);
|
|
26
29
|
for (let i = 0; i < funcCodeList.length; i++) {
|
|
27
30
|
const funcCode = funcCodeList[i];
|
|
@@ -38,7 +41,7 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
38
41
|
sqlTable: SystemTables.sys_perm_func,
|
|
39
42
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
40
43
|
sqlDatabase: SystemDbName,
|
|
41
|
-
|
|
44
|
+
sqlDbType: SystemDbType,
|
|
42
45
|
}
|
|
43
46
|
);
|
|
44
47
|
}
|
|
@@ -52,6 +55,9 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
52
55
|
*/
|
|
53
56
|
@Post('/presetsRoleCode')
|
|
54
57
|
async presetsRoleCode() {
|
|
58
|
+
|
|
59
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
60
|
+
|
|
55
61
|
const roleCodeList = [SystemRoleCode.DevOpsViewer, SystemRoleCode.DevOpsWriter];
|
|
56
62
|
|
|
57
63
|
for (let i = 0; i < roleCodeList.length; i++) {
|
|
@@ -69,7 +75,7 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
69
75
|
sqlTable: SystemTables.sys_perm_role,
|
|
70
76
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
71
77
|
sqlDatabase: SystemDbName,
|
|
72
|
-
|
|
78
|
+
sqlDbType: SystemDbType,
|
|
73
79
|
}
|
|
74
80
|
);
|
|
75
81
|
}
|
|
@@ -82,6 +88,9 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
82
88
|
*/
|
|
83
89
|
@Post('/presetsRoleFuncList')
|
|
84
90
|
async presetsRoleFuncList() {
|
|
91
|
+
|
|
92
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
93
|
+
|
|
85
94
|
const funcCodeList = Object.keys(SystemFuncCodeNameMap);
|
|
86
95
|
for (let i = 0; i < funcCodeList.length; i++) {
|
|
87
96
|
const funcCode = funcCodeList[i];
|
|
@@ -97,7 +106,7 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
97
106
|
sqlTable: SystemTables.sys_perm_role_func,
|
|
98
107
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
99
108
|
sqlDatabase: SystemDbName,
|
|
100
|
-
|
|
109
|
+
sqlDbType: SystemDbType,
|
|
101
110
|
}
|
|
102
111
|
);
|
|
103
112
|
}
|
|
@@ -116,7 +125,7 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
116
125
|
sqlTable: SystemTables.sys_perm_role_func,
|
|
117
126
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
118
127
|
sqlDatabase: SystemDbName,
|
|
119
|
-
|
|
128
|
+
sqlDbType: SystemDbType,
|
|
120
129
|
}
|
|
121
130
|
);
|
|
122
131
|
}
|
|
@@ -5,8 +5,9 @@ import { BaseApiController } from '../base/BaseApiController';
|
|
|
5
5
|
import { checkPermission } from '../../middleware/permission.middleware';
|
|
6
6
|
import { SystemFuncCode } from '../../models/SystemPerm';
|
|
7
7
|
import { CTX_WORKBENCH_CODE } from '../../models/bizmodels';
|
|
8
|
-
import {
|
|
8
|
+
import {SystemTables} from "../../models/SystemTables";
|
|
9
9
|
import {CommonResult} from "../../libs/utils/common-dto";
|
|
10
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
10
11
|
|
|
11
12
|
@Controller('/ns/api/manage/sysconfig', { middleware: [checkPermission(SystemFuncCode.SysConfigMangeRead)] })
|
|
12
13
|
export class SysConfigMangeApi extends BaseApiController {
|
|
@@ -48,6 +49,8 @@ export class SysConfigMangeApi extends BaseApiController {
|
|
|
48
49
|
|
|
49
50
|
@Post('/updateSysConfig', { middleware: [checkPermission(SystemFuncCode.SysConfigMangeWrite)] })
|
|
50
51
|
async updateSysConfig() {
|
|
52
|
+
|
|
53
|
+
const {SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
51
54
|
|
|
52
55
|
const body = this.ctx.request.body as any;
|
|
53
56
|
const id = body.condition.id;
|
|
@@ -7,6 +7,7 @@ import { checkPermission } from '../../middleware/permission.middleware';
|
|
|
7
7
|
import { SystemFuncCode } from '../../models/SystemPerm';
|
|
8
8
|
import { CommonException, Exceptions } from '../../libs/crud-pro/exceptions';
|
|
9
9
|
import { SystemTables } from '../../models/SystemTables';
|
|
10
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
10
11
|
|
|
11
12
|
const accountNameBlacklist = new Set(['sa', 'root', 'admin', 'superadmin', 'administrator', 'sys', 'sysop', 'schedule_user']);
|
|
12
13
|
function checkAccountCreateBlacklist(value: string) {
|
|
@@ -58,6 +59,11 @@ export class UserAccountManageApi extends BaseApiController {
|
|
|
58
59
|
const body = this.ctx.request.body as any;
|
|
59
60
|
body.data.account_id = createUniqueId();
|
|
60
61
|
|
|
62
|
+
const { generateUserAccountId } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
63
|
+
if (typeof generateUserAccountId === 'function') {
|
|
64
|
+
body.data.account_id = await generateUserAccountId(body.data);
|
|
65
|
+
}
|
|
66
|
+
|
|
61
67
|
return this.executeSysSimpleSQL(SystemTables.sys_user_account, KeysOfSimpleSQL.SIMPLE_INSERT, {
|
|
62
68
|
validateCfg: {
|
|
63
69
|
'data.login_name': LOGIN_NAME_VALIDATE,
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { Controller, Inject, Post } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import axios from 'axios';
|
|
4
3
|
import { BaseApiController } from '../base/BaseApiController';
|
|
5
4
|
import { AuthService } from '../../service/AuthService';
|
|
6
|
-
import {
|
|
5
|
+
import { ISessionInfo, SESSION_ID_KEY, sessionCookieCfg } from '../../models/userSession';
|
|
7
6
|
import { CommonResult } from '../../libs/utils/common-dto';
|
|
8
7
|
import { checkLogin } from '../../middleware/permission.middleware';
|
|
9
8
|
import { assertCsrfToken } from "../../libs/utils/fatcms-request";
|
|
10
|
-
import {WorkbenchService} from "../../service/WorkbenchService";
|
|
11
|
-
import {CommonException} from "../../libs/crud-pro/exceptions";
|
|
9
|
+
import { WorkbenchService } from "../../service/WorkbenchService";
|
|
10
|
+
import { CommonException } from "../../libs/crud-pro/exceptions";
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* 支持使用明文密码和Hash后密码登录。
|
|
@@ -62,67 +61,6 @@ export class AuthController extends BaseApiController {
|
|
|
62
61
|
return CommonResult.successMsg('登录成功', userSessionInfo);
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* 使用https://medstatistic.com/账号登录
|
|
68
|
-
*/
|
|
69
|
-
@Post('/loginByMedStatistic')
|
|
70
|
-
async loginByMedStatistic(): Promise<CommonResult> {
|
|
71
|
-
|
|
72
|
-
const { medStatisticToken } = this.ctx.request.body as any;
|
|
73
|
-
if (!medStatisticToken) {
|
|
74
|
-
return CommonResult.errorRes("medStatisticToken is null")
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const workbench = await this.workbenchService.getCurrentHostWorkbenchInfo();
|
|
78
|
-
if (!workbench) {
|
|
79
|
-
throw new CommonException('WORKBENCH_IS_NOT_FOUND', '站点未找到');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// 先删除之前的cookie
|
|
83
|
-
const sessionId = this.ctx.cookies.get(SESSION_ID_KEY, sessionCookieCfg);
|
|
84
|
-
await this.authService.removeUserSession(sessionId);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
let userInfoRes: any = null;
|
|
88
|
-
try {
|
|
89
|
-
userInfoRes = await axios.get("https://console.medstatistic.com/api/user/index?lang=zh-cn", {
|
|
90
|
-
headers: {
|
|
91
|
-
host: "console.medstatistic.com",
|
|
92
|
-
origin: "https://console.medstatistic.com",
|
|
93
|
-
token: medStatisticToken
|
|
94
|
-
},
|
|
95
|
-
responseType: 'json'
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
} catch (e) {
|
|
99
|
-
return CommonResult.errorRes(e?.message || '');
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const userInfo = userInfoRes?.data?.data;
|
|
103
|
-
|
|
104
|
-
if (!userInfo || !userInfo.id) {
|
|
105
|
-
return CommonResult.errorRes("USER_NOT_EXIST")
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const consumerUserInfo: IConsumerUserInfo = {
|
|
109
|
-
workbenchCode: workbench.workbench_code,
|
|
110
|
-
accountType: 'medstatistic',
|
|
111
|
-
accountId: userInfo.id,
|
|
112
|
-
nickName: userInfo.nickname,
|
|
113
|
-
loginName: `${userInfo.id}_${userInfo.username}`,
|
|
114
|
-
avatar: userInfo.avatar,
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const userSessionInfo = await this.authService.createUserSessionForConsumer(consumerUserInfo);
|
|
118
|
-
|
|
119
|
-
this.ctx.cookies.set(SESSION_ID_KEY, userSessionInfo.sessionId, sessionCookieCfg);
|
|
120
|
-
|
|
121
|
-
return CommonResult.successMsg('登录成功', userSessionInfo);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
64
|
/**
|
|
127
65
|
* 退出
|
|
128
66
|
*/
|
|
@@ -140,7 +78,7 @@ export class AuthController extends BaseApiController {
|
|
|
140
78
|
*/
|
|
141
79
|
@Post('/refreshSession', { middleware: [checkLogin()] })
|
|
142
80
|
async refreshSession(): Promise<CommonResult> {
|
|
143
|
-
const sessionInfo:ISessionInfo = this.ctx.userSession.getSessionInfo();
|
|
81
|
+
const sessionInfo: ISessionInfo = this.ctx.userSession.getSessionInfo();
|
|
144
82
|
const newSessionInfo: ISessionInfo = await this.authService.refreshSession(sessionInfo);
|
|
145
83
|
this.ctx.cookies.set(SESSION_ID_KEY, newSessionInfo.sessionId, sessionCookieCfg);
|
|
146
84
|
return CommonResult.successRes(newSessionInfo);
|