midway-fatcms 0.0.1-beta.1 → 0.0.1-beta.10
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 +3 -0
- 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 +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/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/index.d.ts +28 -4
- package/dist/index.js +28 -4
- 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 +6 -2
- package/dist/service/curd/CurdMixByAccountService.js +12 -6
- 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/curd/CurdMixUtils.d.ts +7 -0
- package/dist/service/curd/CurdMixUtils.js +31 -1
- 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 +13 -13
- package/src/controller/gateway/CrudMtdGatewayController.ts +5 -1
- package/src/controller/gateway/DocGatewayController.ts +9 -1
- package/src/controller/gateway/StaticController.ts +50 -25
- 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/manage/UserAccountManageApi.ts +6 -0
- package/src/controller/myinfo/AuthController.ts +4 -66
- package/src/controller/render/AppRenderController.ts +17 -14
- package/src/index.ts +33 -4
- package/src/libs/global-config/global-config.ts +72 -0
- package/src/models/SystemTables.ts +0 -4
- package/src/service/AuthService.ts +11 -6
- 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 +4 -1
- package/src/service/crudstd/CrudStdService.ts +11 -1
- package/src/service/curd/CurdMixByAccountService.ts +13 -5
- 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/curd/CurdMixUtils.ts +42 -12
- package/src/service/proxyapi/ProxyApiLoadService.ts +9 -1
- 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
|
|
|
@@ -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
|
|
|
@@ -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)),
|
|
@@ -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];
|
|
@@ -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++) {
|
|
@@ -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];
|
|
@@ -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);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {Inject, Controller, Get, Param} from '@midwayjs/core';
|
|
2
|
-
import {Context} from '@midwayjs/koa';
|
|
3
|
-
import {BaseApiController} from '../base/BaseApiController';
|
|
4
|
-
import {KeysOfSimpleSQL} from '../../libs/crud-pro/models/keys';
|
|
5
|
-
import {
|
|
6
|
-
import {WorkbenchService} from '../../service/WorkbenchService';
|
|
7
|
-
import {createRenderUtils} from "../../libs/utils/render-utils";
|
|
8
|
-
import {privateAES} from "../../libs/utils/crypto-utils";
|
|
1
|
+
import { Inject, Controller, Get, Param } from '@midwayjs/core';
|
|
2
|
+
import { Context } from '@midwayjs/koa';
|
|
3
|
+
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
+
import { KeysOfSimpleSQL } from '../../libs/crud-pro/models/keys';
|
|
5
|
+
import { SystemTables } from '../../models/SystemTables';
|
|
6
|
+
import { WorkbenchService } from '../../service/WorkbenchService';
|
|
7
|
+
import { createRenderUtils } from "../../libs/utils/render-utils";
|
|
8
|
+
import { privateAES } from "../../libs/utils/crypto-utils";
|
|
9
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -21,11 +22,13 @@ export class AppRenderController extends BaseApiController {
|
|
|
21
22
|
|
|
22
23
|
@Get('/:appPath+')
|
|
23
24
|
async home(@Param('appPath') appPath: string): Promise<string> {
|
|
25
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
26
|
+
|
|
24
27
|
const appPathArr = appPath.split('/');
|
|
25
28
|
const appCode = appPathArr[0];
|
|
26
29
|
|
|
27
30
|
const res = await this.curdMixService.executeCrudByCfg(
|
|
28
|
-
{condition: {app_code: appCode}},
|
|
31
|
+
{ condition: { app_code: appCode } },
|
|
29
32
|
{
|
|
30
33
|
sqlTable: SystemTables.sys_app,
|
|
31
34
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
@@ -34,21 +37,21 @@ export class AppRenderController extends BaseApiController {
|
|
|
34
37
|
}
|
|
35
38
|
);
|
|
36
39
|
|
|
37
|
-
const {row: appInfo} = res.getResModel();
|
|
40
|
+
const { row: appInfo } = res.getResModel();
|
|
38
41
|
if (!appInfo) {
|
|
39
42
|
this.ctx.status = 404;
|
|
40
|
-
return this.ctx.render('404_app', {appCode, errorMsg: ' 应用不存在'});
|
|
43
|
+
return this.ctx.render('404_app', { appCode, errorMsg: ' 应用不存在' });
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
if (appInfo.status !== 1) {
|
|
44
47
|
this.ctx.status = 404;
|
|
45
|
-
return this.ctx.render('404_app', {appCode, errorMsg: ' 应用已下线'});
|
|
48
|
+
return this.ctx.render('404_app', { appCode, errorMsg: ' 应用已下线' });
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
const isSupportWorkbench = await this.isSupportCurrentWorkbench(appInfo);
|
|
49
52
|
if (!isSupportWorkbench) {
|
|
50
53
|
this.ctx.status = 404;
|
|
51
|
-
return this.ctx.render('404_app', {appCode, errorMsg: ' 应用没有绑定此站点'});
|
|
54
|
+
return this.ctx.render('404_app', { appCode, errorMsg: ' 应用没有绑定此站点' });
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
const workbenchInfo = await this.workbenchService.getCurrentHostWorkbenchInfo();
|
|
@@ -61,7 +64,7 @@ export class AppRenderController extends BaseApiController {
|
|
|
61
64
|
ctx: this.ctx,
|
|
62
65
|
appInfo, workbenchInfo, userInfo, package_assets: appInfo.package_assets, fatcmscsrftoken
|
|
63
66
|
});
|
|
64
|
-
return this.ctx.renderString(html_content, {appInfo, workbenchInfo, userInfo, utils}, {viewEngine: 'ejs'});
|
|
67
|
+
return this.ctx.renderString(html_content, { appInfo, workbenchInfo, userInfo, utils }, { viewEngine: 'ejs' });
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
|