midway-fatcms 0.0.1-beta.26 → 0.0.1-beta.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controller/home.controller.js +2 -1
- package/dist/controller/render/AppRenderController.js +2 -1
- package/dist/models/bizmodels.d.ts +1 -0
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.js +1 -1
- package/dist/service/crudstd/CrudStdService.d.ts +0 -6
- package/dist/service/crudstd/CrudStdService.js +13 -33
- package/package.json +1 -5
- package/src/config/config.default.ts +0 -207
- package/src/config/seed/aeskey.txt +0 -1
- package/src/config/utils.ts +0 -22
- package/src/configuration.ts +0 -109
- package/src/controller/base/BaseApiController.ts +0 -170
- package/src/controller/gateway/AnyApiGatewayController.ts +0 -33
- package/src/controller/gateway/AsyncTaskController.ts +0 -157
- package/src/controller/gateway/CrudMtdGatewayController.ts +0 -111
- package/src/controller/gateway/CrudStdGatewayController.ts +0 -101
- package/src/controller/gateway/DocGatewayController.ts +0 -173
- package/src/controller/gateway/FileController.ts +0 -109
- package/src/controller/gateway/ProxyApiGatewayController.ts +0 -47
- package/src/controller/gateway/PublicApiController.ts +0 -142
- package/src/controller/gateway/StaticController.ts +0 -298
- package/src/controller/helpers.controller.ts +0 -161
- package/src/controller/home.controller.ts +0 -64
- package/src/controller/manage/AnyApiMangeApi.ts +0 -66
- package/src/controller/manage/AppLogMangeApi.ts +0 -53
- package/src/controller/manage/AppMangeApi.ts +0 -53
- package/src/controller/manage/AppPageMangeApi.ts +0 -52
- package/src/controller/manage/AppSchemaHistoryApi.ts +0 -49
- package/src/controller/manage/CrudMethodsMangeApi.ts +0 -49
- package/src/controller/manage/CrudStandardDesignApi.ts +0 -346
- package/src/controller/manage/DataDictManageApi.ts +0 -78
- package/src/controller/manage/DeployManageApi.ts +0 -175
- package/src/controller/manage/DocLibManageApi.ts +0 -69
- package/src/controller/manage/DocManageApi.ts +0 -99
- package/src/controller/manage/FileManageApi.ts +0 -45
- package/src/controller/manage/LowCodeTplManageApi.ts +0 -52
- package/src/controller/manage/MenuManageApi.ts +0 -58
- package/src/controller/manage/ProxyApiMangeApi.ts +0 -52
- package/src/controller/manage/SuperAdminManageApi.ts +0 -139
- package/src/controller/manage/SysConfigMangeApi.ts +0 -95
- package/src/controller/manage/SystemInfoManageApi.ts +0 -53
- package/src/controller/manage/UserAccountManageApi.ts +0 -94
- package/src/controller/manage/WorkbenchMangeApi.ts +0 -72
- package/src/controller/myinfo/AuthController.ts +0 -108
- package/src/controller/myinfo/MyInfoController.ts +0 -32
- package/src/controller/render/AppRenderController.ts +0 -79
- package/src/controller/test.controller.ts +0 -37
- package/src/filter/default.filter.ts +0 -13
- package/src/filter/notfound.filter.ts +0 -10
- package/src/index.ts +0 -106
- package/src/interface.ts +0 -31
- package/src/libs/crud-pro/CrudPro.ts +0 -165
- package/src/libs/crud-pro/defaultConfigs.ts +0 -15
- package/src/libs/crud-pro/exceptions.ts +0 -124
- package/src/libs/crud-pro/interfaces.ts +0 -190
- package/src/libs/crud-pro/models/ExecuteContext.ts +0 -120
- package/src/libs/crud-pro/models/ExecuteContextFunc.ts +0 -96
- package/src/libs/crud-pro/models/FuncContext.ts +0 -21
- package/src/libs/crud-pro/models/RequestCfgModel.ts +0 -141
- package/src/libs/crud-pro/models/RequestModel.ts +0 -141
- package/src/libs/crud-pro/models/ResModel.ts +0 -19
- package/src/libs/crud-pro/models/ServiceHub.ts +0 -32
- package/src/libs/crud-pro/models/SqlCfgModel.ts +0 -52
- package/src/libs/crud-pro/models/SqlSegArg.ts +0 -13
- package/src/libs/crud-pro/models/Transaction.ts +0 -73
- package/src/libs/crud-pro/models/TransactionMySQL.ts +0 -79
- package/src/libs/crud-pro/models/TransactionPostgres.ts +0 -91
- package/src/libs/crud-pro/models/TransactionSqlServer.ts +0 -102
- package/src/libs/crud-pro/models/keys.ts +0 -159
- package/src/libs/crud-pro/services/CrudProCachedCfgService.ts +0 -83
- package/src/libs/crud-pro/services/CrudProExecuteFuncService.ts +0 -128
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +0 -262
- package/src/libs/crud-pro/services/CrudProFieldUpdateService.ts +0 -60
- package/src/libs/crud-pro/services/CrudProFieldValidateService.ts +0 -180
- package/src/libs/crud-pro/services/CrudProGenSqlCondition.ts +0 -354
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +0 -185
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +0 -393
- package/src/libs/crud-pro/services/CrudProServiceBase.ts +0 -94
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +0 -86
- package/src/libs/crud-pro/services/CurdProServiceHub.ts +0 -92
- package/src/libs/crud-pro/sql.txt +0 -120
- package/src/libs/crud-pro/utils/CompareUtils.ts +0 -23
- package/src/libs/crud-pro/utils/DatabaseName.ts +0 -60
- package/src/libs/crud-pro/utils/DateTimeUtils.ts +0 -20
- package/src/libs/crud-pro/utils/MemoryRefreshCache.ts +0 -64
- package/src/libs/crud-pro/utils/MessageParseUtils.ts +0 -33
- package/src/libs/crud-pro/utils/MixinUtils.ts +0 -285
- package/src/libs/crud-pro/utils/ModelUtils.ts +0 -55
- package/src/libs/crud-pro/utils/MultiKeyMap.ts +0 -72
- package/src/libs/crud-pro/utils/SqlFuncUtils.ts +0 -29
- package/src/libs/crud-pro/utils/TypeUtils.ts +0 -188
- package/src/libs/crud-pro/utils/ValidateUtils.ts +0 -165
- package/src/libs/crud-pro/utils/pool/MySQLUtils.ts +0 -20
- package/src/libs/crud-pro/utils/pool/PostgresUtils.ts +0 -22
- package/src/libs/crud-pro/utils/pool/SqlServerUtils.ts +0 -22
- package/src/libs/crud-pro/utils/sqlConvert/convertColumnName.ts +0 -26
- package/src/libs/crud-pro/utils/sqlConvert/convertMix.ts +0 -26
- package/src/libs/crud-pro/utils/sqlConvert/convertMsSql.ts +0 -11
- package/src/libs/crud-pro/utils/sqlConvert/convertPgSql.ts +0 -11
- package/src/libs/crud-pro/utils/sqlConvert/convertPgType.ts +0 -129
- package/src/libs/global-config/global-config.ts +0 -78
- package/src/libs/utils/common-dto.ts +0 -52
- package/src/libs/utils/crypto-utils.ts +0 -50
- package/src/libs/utils/errorToString.ts +0 -61
- package/src/libs/utils/fatcms-request.ts +0 -103
- package/src/libs/utils/functions.ts +0 -73
- package/src/libs/utils/ordernum-utils.ts +0 -14
- package/src/libs/utils/parseConfig.ts +0 -54
- package/src/libs/utils/parseCreateSql.ts +0 -91
- package/src/libs/utils/render-utils.ts +0 -184
- package/src/middleware/forbidden.middleware.ts +0 -52
- package/src/middleware/global.middleware.ts +0 -280
- package/src/middleware/permission.middleware.ts +0 -80
- package/src/middleware/tx.middleware.ts +0 -30
- package/src/models/AsyncTaskModel.ts +0 -82
- package/src/models/RedisKeys.ts +0 -13
- package/src/models/SystemEntities.ts +0 -115
- package/src/models/SystemPerm.ts +0 -105
- package/src/models/SystemTables.ts +0 -27
- package/src/models/bizmodels.ts +0 -120
- package/src/models/contextLogger.ts +0 -132
- package/src/models/devops.ts +0 -17
- package/src/models/userSession.ts +0 -216
- package/src/schedule/anonymousContext.ts +0 -73
- package/src/schedule/index.ts +0 -12
- package/src/schedule/runSchedule.ts +0 -82
- package/src/schedule/scheduleNames.ts +0 -21
- package/src/service/AuthService.ts +0 -272
- package/src/service/EnumInfoService.ts +0 -130
- package/src/service/FileCenterService.ts +0 -395
- package/src/service/SysConfigService.ts +0 -37
- package/src/service/UserAccountService.ts +0 -107
- package/src/service/UserSessionService.ts +0 -78
- package/src/service/VisitStatService.ts +0 -166
- package/src/service/WorkbenchService.ts +0 -165
- package/src/service/anyapi/AnyApiSandboxService.ts +0 -121
- package/src/service/anyapi/AnyApiService.ts +0 -186
- package/src/service/asyncTask/AsyncTaskRunnerService.ts +0 -266
- package/src/service/asyncTask/AsyncTaskService.ts +0 -21
- package/src/service/asyncTask/handler/ExcelInfoModel.ts +0 -11
- package/src/service/asyncTask/handler/ExportExcelAsyncTaskHandler.ts +0 -245
- package/src/service/asyncTask/handler/ExportExcelByInnerHttpHandler.ts +0 -147
- package/src/service/asyncTask/handler/ExportExcelByStdCrudHandler.ts +0 -138
- package/src/service/base/ApiBaseService.ts +0 -42
- package/src/service/base/ApiRateLimiter.ts +0 -59
- package/src/service/base/BaseService.ts +0 -100
- package/src/service/base/RedisCacheService.ts +0 -38
- package/src/service/crudstd/CrudStdActionService.ts +0 -27
- package/src/service/crudstd/CrudStdConstant.ts +0 -62
- package/src/service/crudstd/CrudStdRelationService.ts +0 -78
- package/src/service/crudstd/CrudStdService.ts +0 -283
- package/src/service/curd/CrudProQuick.ts +0 -131
- package/src/service/curd/CurdMixByAccountService.ts +0 -90
- package/src/service/curd/CurdMixByDictService.ts +0 -114
- package/src/service/curd/CurdMixByLinkToCustomService.ts +0 -219
- package/src/service/curd/CurdMixBySysConfigService.ts +0 -78
- package/src/service/curd/CurdMixByWorkbenchService.ts +0 -71
- package/src/service/curd/CurdMixService.ts +0 -97
- package/src/service/curd/CurdMixUtils.ts +0 -311
- package/src/service/curd/CurdProService.ts +0 -229
- package/src/service/curd/fixCfgModel.ts +0 -139
- package/src/service/proxyapi/ProxyApiLoadService.ts +0 -174
- package/src/service/proxyapi/ProxyApiService.ts +0 -262
- package/src/service/proxyapi/ProxyApiUtils.ts +0 -32
- package/src/service/proxyapi/RouteHandler.ts +0 -8
- package/src/service/proxyapi/RouteTrie.ts +0 -74
- package/src/service/proxyapi/WeightedRandom.ts +0 -37
- package/src/service/proxyapi/WeightedRoundRobin.ts +0 -44
- package/src/views/404_app.html +0 -31
- package/src/views/404_workbench.html +0 -34
- package/src/views/static/favicon.ico +0 -0
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Controller, Inject, Post } from '@midwayjs/core';
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { KeysOfSimpleSQL, KeysOfValidators } from '@/libs/crud-pro/models/keys';
|
|
4
|
-
import { BaseApiController } from '../base/BaseApiController';
|
|
5
|
-
import { checkPermission } from '@/middleware/permission.middleware';
|
|
6
|
-
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
7
|
-
|
|
8
|
-
@Controller('/ns/api/manage/appPage', { middleware: [checkPermission(SystemFuncCode.AppPageMangeRead)] })
|
|
9
|
-
export class AppPageMangeApi extends BaseApiController {
|
|
10
|
-
@Inject()
|
|
11
|
-
ctx: Context;
|
|
12
|
-
|
|
13
|
-
@Post('/getAppPageList')
|
|
14
|
-
async getAppPageList() {
|
|
15
|
-
return this.executeSysSimpleSQL('sys_app_page', KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@Post('/getAppPageOne')
|
|
19
|
-
async getAppPageOne() {
|
|
20
|
-
return this.executeSysSimpleSQL('sys_app_page', KeysOfSimpleSQL.SIMPLE_QUERY_ONE);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@Post('/createAppPage', { middleware: [checkPermission(SystemFuncCode.AppPageMangeWrite)] })
|
|
24
|
-
async createAppPage() {
|
|
25
|
-
return this.executeSysSimpleSQL('sys_app_page', KeysOfSimpleSQL.SIMPLE_INSERT, {
|
|
26
|
-
validateCfg: {
|
|
27
|
-
'data.app_code': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
|
|
28
|
-
'data.app_name': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
|
|
29
|
-
'data.page_path': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
|
|
30
|
-
'data.page_name': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@Post('/updateAppPage', { middleware: [checkPermission(SystemFuncCode.AppPageMangeWrite)] })
|
|
36
|
-
async updateAppPage() {
|
|
37
|
-
return this.executeSysSimpleSQL('sys_app_page', KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
38
|
-
validateCfg: {
|
|
39
|
-
'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@Post('/deleteAppPage', { middleware: [checkPermission(SystemFuncCode.AppPageMangeWrite)] })
|
|
45
|
-
async deleteAppPage() {
|
|
46
|
-
return this.executeSysSimpleSQL('sys_app_page', KeysOfSimpleSQL.SIMPLE_DELETE, {
|
|
47
|
-
validateCfg: {
|
|
48
|
-
'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Controller, Inject, Post } from '@midwayjs/core';
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { KeysOfSimpleSQL, KeysOfValidators } from '@/libs/crud-pro/models/keys';
|
|
4
|
-
import { BaseApiController } from '../base/BaseApiController';
|
|
5
|
-
|
|
6
|
-
const tableName = 'sys_app_schema_history';
|
|
7
|
-
|
|
8
|
-
@Controller('/ns/api/manage/AppSchemaHistory')
|
|
9
|
-
export class AppSchemaHistoryApi extends BaseApiController {
|
|
10
|
-
@Inject()
|
|
11
|
-
ctx: Context;
|
|
12
|
-
|
|
13
|
-
@Post('/getAppSchemaHistoryList')
|
|
14
|
-
async getAppSchemaHistoryList() {
|
|
15
|
-
return this.executeSysSimpleSQL(tableName, KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@Post('/getAppSchemaHistoryOne')
|
|
19
|
-
async getAppSchemaHistoryOne() {
|
|
20
|
-
return this.executeSysSimpleSQL(tableName, KeysOfSimpleSQL.SIMPLE_QUERY_ONE);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@Post('/createAppSchemaHistory')
|
|
24
|
-
async createAppSchemaHistory() {
|
|
25
|
-
return this.executeSysSimpleSQL(tableName, KeysOfSimpleSQL.SIMPLE_INSERT, {
|
|
26
|
-
validateCfg: {
|
|
27
|
-
'data.app_code': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@Post('/updateAppSchemaHistory')
|
|
33
|
-
async updateAppSchemaHistory() {
|
|
34
|
-
return this.executeSysSimpleSQL(tableName, KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
35
|
-
validateCfg: {
|
|
36
|
-
'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@Post('/deleteAppSchemaHistory')
|
|
42
|
-
async deleteAppSchemaHistory() {
|
|
43
|
-
return this.executeSysSimpleSQL(tableName, KeysOfSimpleSQL.SIMPLE_DELETE, {
|
|
44
|
-
validateCfg: {
|
|
45
|
-
'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Controller, Inject, Post } from '@midwayjs/core';
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { KeysOfSimpleSQL, KeysOfValidators } from '@/libs/crud-pro/models/keys';
|
|
4
|
-
import { BaseApiController } from '../base/BaseApiController';
|
|
5
|
-
import { checkPermission } from '@/middleware/permission.middleware';
|
|
6
|
-
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
7
|
-
|
|
8
|
-
@Controller('/ns/api/manage/crudMethod', { middleware: [checkPermission(SystemFuncCode.CrudMethodApiRead)] })
|
|
9
|
-
export class CrudMethodsMangeApi extends BaseApiController {
|
|
10
|
-
@Inject()
|
|
11
|
-
ctx: Context;
|
|
12
|
-
|
|
13
|
-
@Post('/getCrudMethodList')
|
|
14
|
-
async getCrudMethodList() {
|
|
15
|
-
return this.executeSysSimpleSQL('sys_crud_methods', KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@Post('/getCrudMethodOne')
|
|
19
|
-
async getCrudMethodOne() {
|
|
20
|
-
return this.executeSysSimpleSQL('sys_crud_methods', KeysOfSimpleSQL.SIMPLE_QUERY_ONE);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@Post('/createCrudMethod', { middleware: [checkPermission(SystemFuncCode.CrudMethodApiWrite)] })
|
|
24
|
-
async createCrudMethod() {
|
|
25
|
-
return this.executeSysSimpleSQL('sys_crud_methods', KeysOfSimpleSQL.SIMPLE_INSERT, {
|
|
26
|
-
validateCfg: {
|
|
27
|
-
'data.method': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@Post('/updateCrudMethod', { middleware: [checkPermission(SystemFuncCode.CrudMethodApiWrite)] })
|
|
33
|
-
async updateCrudMethod() {
|
|
34
|
-
return this.executeSysSimpleSQL('sys_crud_methods', KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
35
|
-
validateCfg: {
|
|
36
|
-
'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@Post('/deleteCrudMethod', { middleware: [checkPermission(SystemFuncCode.CrudMethodApiWrite)] })
|
|
42
|
-
async deleteCrudMethod() {
|
|
43
|
-
return this.executeSysSimpleSQL('sys_crud_methods', KeysOfSimpleSQL.SIMPLE_DELETE, {
|
|
44
|
-
validateCfg: {
|
|
45
|
-
'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
import { Config, Controller, Post } from '@midwayjs/core';
|
|
2
|
-
import { BaseApiController } from '../base/BaseApiController';
|
|
3
|
-
import { parseCreateSqlToTitleMap } from '@/libs/utils/parseCreateSql';
|
|
4
|
-
import { checkPermission } from '@/middleware/permission.middleware';
|
|
5
|
-
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
6
|
-
import { KeyOfCrudTypes, KeysOfSimpleSQL, SqlDbType } from '@/libs/crud-pro/models/keys';
|
|
7
|
-
import { SystemTables } from '@/models/SystemTables';
|
|
8
|
-
import { CommonException } from '@/libs/crud-pro/exceptions';
|
|
9
|
-
import { parseDatabaseName, toDatabaseNameStr } from '@/libs/crud-pro/utils/DatabaseName';
|
|
10
|
-
import { CommonResult } from '@/libs/utils/common-dto';
|
|
11
|
-
|
|
12
|
-
@Controller('/ns/api/manage/CrudStandardDesignApi', { middleware: [checkPermission(SystemFuncCode.CrudStandardDesignRead)] })
|
|
13
|
-
export class CrudStandardDesignApi extends BaseApiController {
|
|
14
|
-
@Config('mysql2')
|
|
15
|
-
private mysql2Config: any;
|
|
16
|
-
|
|
17
|
-
@Config('postgres2')
|
|
18
|
-
private postgres2Config: any;
|
|
19
|
-
|
|
20
|
-
@Config('sqlserver2')
|
|
21
|
-
private sqlserver2Config: any;
|
|
22
|
-
|
|
23
|
-
@Post('/getDataBaseList')
|
|
24
|
-
async getDataBaseList() {
|
|
25
|
-
const mysqlList = Object.keys(this.mysql2Config || {});
|
|
26
|
-
const postgresList = Object.keys(this.postgres2Config || {});
|
|
27
|
-
const sqlServerList = Object.keys(this.sqlserver2Config || {});
|
|
28
|
-
|
|
29
|
-
const toSelectList = (dbCfgNameList: string[], dbType: SqlDbType) => {
|
|
30
|
-
return dbCfgNameList.map(dbName => {
|
|
31
|
-
const value = toDatabaseNameStr(dbType, dbName);
|
|
32
|
-
return { value, label: value, dbName, dbType };
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const mysqlObjList = toSelectList(mysqlList, SqlDbType.mysql);
|
|
37
|
-
const postgresObjList = toSelectList(postgresList, SqlDbType.postgres);
|
|
38
|
-
const sqlserverObjList = toSelectList(sqlServerList, SqlDbType.sqlserver);
|
|
39
|
-
|
|
40
|
-
const databaseList = [...mysqlObjList, ...postgresObjList, ...sqlserverObjList].filter((obj: any) => {
|
|
41
|
-
const value = '' + obj.value;
|
|
42
|
-
return !value.endsWith('_fatcms_inner_demo_config');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
success: true,
|
|
47
|
-
data: databaseList,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@Post('/getTableList')
|
|
52
|
-
async getTableList(): Promise<CommonResult> {
|
|
53
|
-
const { databaseName } = this.ctx.request.body as any;
|
|
54
|
-
const { dbType, dbName } = parseDatabaseName(databaseName);
|
|
55
|
-
|
|
56
|
-
if (dbType === SqlDbType.postgres) {
|
|
57
|
-
return this.getTableListOfPostgreSQL(dbName);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (dbType === SqlDbType.sqlserver) {
|
|
61
|
-
return this.getTableListOfSqlserver(dbName);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const res = await this.curdMixService.executeSQL({
|
|
65
|
-
executeSql: 'SHOW TABLES',
|
|
66
|
-
sqlDatabase: dbName,
|
|
67
|
-
sqlDbType: SqlDbType.mysql,
|
|
68
|
-
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const arr = JSON.parse(JSON.stringify(res));
|
|
72
|
-
const tableNames: string[] = arr.map(a => {
|
|
73
|
-
const v = Object.values(a);
|
|
74
|
-
const tableName = v[0];
|
|
75
|
-
return {
|
|
76
|
-
value: tableName,
|
|
77
|
-
label: tableName,
|
|
78
|
-
dbName,
|
|
79
|
-
dbType,
|
|
80
|
-
tableName,
|
|
81
|
-
};
|
|
82
|
-
});
|
|
83
|
-
return CommonResult.successRes(tableNames);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
@Post('/getTableFields')
|
|
87
|
-
async getTableFields() {
|
|
88
|
-
const { databaseName, tableName } = this.ctx.request.body as any;
|
|
89
|
-
const { dbType, dbName } = parseDatabaseName(databaseName);
|
|
90
|
-
|
|
91
|
-
if (dbType === SqlDbType.postgres) {
|
|
92
|
-
return this.getTableFieldsOfPostgreSQL(dbName, tableName);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (dbType === SqlDbType.sqlserver) {
|
|
96
|
-
return this.getTableFieldsOfSqlServer(dbName, tableName);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const tableDescribe = await this.curdMixService.executeSQL({
|
|
100
|
-
executeSql: 'describe ' + tableName,
|
|
101
|
-
sqlDatabase: dbName,
|
|
102
|
-
sqlDbType: SqlDbType.mysql,
|
|
103
|
-
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
104
|
-
});
|
|
105
|
-
const tableCreate = await this.curdMixService.executeSQL({
|
|
106
|
-
executeSql: 'show create table ' + tableName,
|
|
107
|
-
sqlDatabase: dbName,
|
|
108
|
-
sqlDbType: SqlDbType.mysql,
|
|
109
|
-
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
const tableCreateStr = tableCreate[0]['Create Table'];
|
|
113
|
-
const { fieldsTitleMap, tableTitle } = parseCreateSqlToTitleMap(tableCreateStr);
|
|
114
|
-
|
|
115
|
-
const tableDescribe2 = JSON.parse(JSON.stringify(tableDescribe));
|
|
116
|
-
const fields = tableDescribe2.map(fieldObj => {
|
|
117
|
-
const { Default, Extra, Field, Key, Null, Type } = fieldObj;
|
|
118
|
-
const fieldTitle = fieldsTitleMap[Field];
|
|
119
|
-
return {
|
|
120
|
-
fieldIndex: Field || '',
|
|
121
|
-
fieldTitle: fieldTitle || Field || '',
|
|
122
|
-
isNullable: Null,
|
|
123
|
-
defaultValue: Default,
|
|
124
|
-
extra: Extra,
|
|
125
|
-
key: Key,
|
|
126
|
-
type: Type,
|
|
127
|
-
};
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
success: true,
|
|
132
|
-
data: {
|
|
133
|
-
fields,
|
|
134
|
-
tableName,
|
|
135
|
-
tableTitle,
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* 获取角色列表
|
|
142
|
-
*/
|
|
143
|
-
@Post('/getRoleOptionsList')
|
|
144
|
-
async getRoleOptionsList() {
|
|
145
|
-
return this.executeSysSimpleSQL(SystemTables.sys_perm_role, KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* 获取功能点列表
|
|
150
|
-
*/
|
|
151
|
-
@Post('/getFuncOptionsList')
|
|
152
|
-
async getFuncOptionsList() {
|
|
153
|
-
return this.executeSysSimpleSQL(SystemTables.sys_perm_func, KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
private async getTableListOfSqlserver(dbName: string): Promise<CommonResult> {
|
|
157
|
-
const dbConfig = this.sqlserver2Config[dbName];
|
|
158
|
-
if (!dbConfig) {
|
|
159
|
-
throw new CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const dbType = SqlDbType.sqlserver;
|
|
163
|
-
|
|
164
|
-
const sql = 'SELECT name as tablename FROM sys.tables';
|
|
165
|
-
const arr = await this.curdMixService.executeSQL({
|
|
166
|
-
executeSql: sql,
|
|
167
|
-
sqlDatabase: dbName,
|
|
168
|
-
sqlDbType: dbType,
|
|
169
|
-
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
170
|
-
executeSqlArgs: [],
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
const tableNames: string[] = arr.map(v => {
|
|
174
|
-
const tableName = v.tablename;
|
|
175
|
-
return {
|
|
176
|
-
value: tableName, //[dbName, dbType, tableName].join(SPLIT_CONST),
|
|
177
|
-
label: tableName,
|
|
178
|
-
dbName,
|
|
179
|
-
dbType,
|
|
180
|
-
tableName,
|
|
181
|
-
};
|
|
182
|
-
});
|
|
183
|
-
return CommonResult.successRes(tableNames);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
private async getTableListOfPostgreSQL(dbName: string): Promise<CommonResult> {
|
|
187
|
-
const dbConfig = this.postgres2Config[dbName];
|
|
188
|
-
if (!dbConfig) {
|
|
189
|
-
throw new CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const dbType = SqlDbType.postgres;
|
|
193
|
-
const schemaname = 'public';
|
|
194
|
-
|
|
195
|
-
const tableListSql = '' + 'SELECT tablename\n' + 'FROM pg_tables\n' + `WHERE schemaname = '${schemaname}' \n` + 'ORDER BY tablename;';
|
|
196
|
-
|
|
197
|
-
const viewListSql = '' + 'SELECT viewname as tablename\n' + 'FROM pg_views\n' + `WHERE schemaname = '${schemaname}' \n` + 'ORDER BY viewname;';
|
|
198
|
-
|
|
199
|
-
const toSelectOptions = async (executeSql: string, tableType: string) => {
|
|
200
|
-
const arr = await this.curdMixService.executeSQL({
|
|
201
|
-
executeSql: executeSql,
|
|
202
|
-
sqlDatabase: dbName,
|
|
203
|
-
sqlDbType: dbType,
|
|
204
|
-
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
205
|
-
executeSqlArgs: [],
|
|
206
|
-
});
|
|
207
|
-
return arr.map(v => {
|
|
208
|
-
const tableName = v.tablename;
|
|
209
|
-
return {
|
|
210
|
-
value: tableName, //[dbName, dbType, tableName].join(SPLIT_CONST),
|
|
211
|
-
label: tableName,
|
|
212
|
-
dbName,
|
|
213
|
-
dbType,
|
|
214
|
-
tableName,
|
|
215
|
-
tableType,
|
|
216
|
-
};
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
const tableNames: any[] = await toSelectOptions(tableListSql, 'table');
|
|
221
|
-
const viewNames: any[] = await toSelectOptions(viewListSql, 'view');
|
|
222
|
-
|
|
223
|
-
const tableNameMerge = [...tableNames, ...viewNames];
|
|
224
|
-
|
|
225
|
-
return CommonResult.successRes(tableNameMerge);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
private async getTableFieldsOfSqlServer(dbName: string, tableName: string): Promise<CommonResult> {
|
|
229
|
-
const dbConfig = this.sqlserver2Config[dbName];
|
|
230
|
-
if (!dbConfig) {
|
|
231
|
-
throw new CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const columnArraySql =
|
|
235
|
-
'' +
|
|
236
|
-
'SELECT\n' +
|
|
237
|
-
' c.name AS column_name,\n' +
|
|
238
|
-
' t.name AS data_type,\n' +
|
|
239
|
-
' c.max_length AS max_length,\n' +
|
|
240
|
-
' c.precision,\n' +
|
|
241
|
-
' c.scale,\n' +
|
|
242
|
-
' c.is_nullable,\n' +
|
|
243
|
-
' c.is_identity,\n' +
|
|
244
|
-
' dc.definition AS column_default, \n' +
|
|
245
|
-
' ep.value AS column_description \n' +
|
|
246
|
-
'FROM\n' +
|
|
247
|
-
' sys.columns c\n' +
|
|
248
|
-
' JOIN\n' +
|
|
249
|
-
' sys.types t ON c.user_type_id = t.user_type_id\n' +
|
|
250
|
-
' LEFT JOIN\n' +
|
|
251
|
-
' sys.default_constraints dc\n' +
|
|
252
|
-
' ON c.default_object_id = dc.object_id \n' +
|
|
253
|
-
' LEFT JOIN\n' +
|
|
254
|
-
' sys.extended_properties ep\n' +
|
|
255
|
-
' ON c.object_id = ep.major_id\n' +
|
|
256
|
-
' AND c.column_id = ep.minor_id\n' +
|
|
257
|
-
'WHERE\n' +
|
|
258
|
-
` c.object_id = OBJECT_ID('${tableName}') \n` +
|
|
259
|
-
' ORDER BY\n' +
|
|
260
|
-
' c.column_id;';
|
|
261
|
-
|
|
262
|
-
const dbType = SqlDbType.sqlserver;
|
|
263
|
-
|
|
264
|
-
const columnArray = await this.curdMixService.executeSQL({
|
|
265
|
-
executeSql: columnArraySql,
|
|
266
|
-
sqlDatabase: dbName,
|
|
267
|
-
sqlDbType: dbType,
|
|
268
|
-
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
269
|
-
executeSqlArgs: [],
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
const fields = columnArray.map(columnObj => {
|
|
273
|
-
const { column_name, is_nullable, column_default, data_type, is_identity, column_description, ...others } = columnObj;
|
|
274
|
-
|
|
275
|
-
return {
|
|
276
|
-
fieldIndex: column_name || '',
|
|
277
|
-
fieldTitle: column_description || column_name || '',
|
|
278
|
-
isNullable: is_nullable,
|
|
279
|
-
defaultValue: column_default || '',
|
|
280
|
-
extra: others,
|
|
281
|
-
// key: column_name, // 索引
|
|
282
|
-
type: data_type,
|
|
283
|
-
is_identity: is_identity,
|
|
284
|
-
};
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
return CommonResult.successRes({
|
|
288
|
-
fields,
|
|
289
|
-
tableName,
|
|
290
|
-
tableTitle: tableName,
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
private async getTableFieldsOfPostgreSQL(dbName: string, tableName: string) {
|
|
295
|
-
const dbConfig = this.postgres2Config[dbName];
|
|
296
|
-
if (!dbConfig) {
|
|
297
|
-
throw new CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
const schemaname = 'public';
|
|
301
|
-
|
|
302
|
-
const columnArraySql = `
|
|
303
|
-
|
|
304
|
-
SELECT
|
|
305
|
-
*
|
|
306
|
-
FROM information_schema.columns
|
|
307
|
-
WHERE table_schema = $1 and table_name = $2
|
|
308
|
-
ORDER BY ordinal_position;
|
|
309
|
-
|
|
310
|
-
`.trim();
|
|
311
|
-
|
|
312
|
-
const dbType = SqlDbType.postgres;
|
|
313
|
-
|
|
314
|
-
const columnArray = await this.curdMixService.executeSQL({
|
|
315
|
-
executeSql: columnArraySql,
|
|
316
|
-
sqlDatabase: dbName,
|
|
317
|
-
sqlDbType: dbType,
|
|
318
|
-
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
319
|
-
executeSqlArgs: [schemaname, tableName],
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
const fields = columnArray.map(columnObj => {
|
|
323
|
-
const { column_name, is_nullable, column_default, data_type, is_identity, ...others } = columnObj;
|
|
324
|
-
|
|
325
|
-
return {
|
|
326
|
-
fieldIndex: column_name || '',
|
|
327
|
-
fieldTitle: column_name || '',
|
|
328
|
-
isNullable: is_nullable,
|
|
329
|
-
defaultValue: column_default || '',
|
|
330
|
-
extra: others,
|
|
331
|
-
// key: column_name, // 索引
|
|
332
|
-
type: data_type,
|
|
333
|
-
is_identity: is_identity,
|
|
334
|
-
};
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
return {
|
|
338
|
-
success: true,
|
|
339
|
-
data: {
|
|
340
|
-
fields,
|
|
341
|
-
tableName,
|
|
342
|
-
tableTitle: tableName,
|
|
343
|
-
},
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Inject, Controller, Post } from '@midwayjs/core';
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { KeysOfSimpleSQL, KeysOfValidators } from '@/libs/crud-pro/models/keys';
|
|
4
|
-
import { BaseApiController } from '../base/BaseApiController';
|
|
5
|
-
import { checkPermission } from '@/middleware/permission.middleware';
|
|
6
|
-
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
7
|
-
|
|
8
|
-
@Controller('/ns/api/manage/dataDict', { middleware: [checkPermission(SystemFuncCode.DataDictMangeRead)] })
|
|
9
|
-
export class DataDictManageApi extends BaseApiController {
|
|
10
|
-
@Inject()
|
|
11
|
-
protected ctx: Context;
|
|
12
|
-
|
|
13
|
-
@Post('/getDataDictList')
|
|
14
|
-
async getDataDictList() {
|
|
15
|
-
return this.executeSysSimpleSQL('sys_data_dict', KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@Post('/getDataDictOne')
|
|
19
|
-
async getDataDictOne() {
|
|
20
|
-
return this.executeSysSimpleSQL('sys_data_dict', KeysOfSimpleSQL.SIMPLE_QUERY_ONE);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@Post('/createDataDict', { middleware: [checkPermission(SystemFuncCode.DataDictMangeWrite)] })
|
|
24
|
-
async createDataDict() {
|
|
25
|
-
return this.executeSysSimpleSQL('sys_data_dict', KeysOfSimpleSQL.SIMPLE_INSERT, {
|
|
26
|
-
validateCfg: {
|
|
27
|
-
'data.dict_code': [KeysOfValidators.REQUIRED],
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@Post('/updateDataDict', { middleware: [checkPermission(SystemFuncCode.DataDictMangeWrite)] })
|
|
33
|
-
async updateDataDict() {
|
|
34
|
-
return this.executeSysSimpleSQL('sys_data_dict', KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
35
|
-
validateCfg: {
|
|
36
|
-
'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@Post('/deleteDataDict', { middleware: [checkPermission(SystemFuncCode.DataDictMangeWrite)] })
|
|
42
|
-
async deleteDataDict() {
|
|
43
|
-
return this.executeSysSimpleSQL('sys_data_dict', KeysOfSimpleSQL.SIMPLE_DELETE, {
|
|
44
|
-
validateCfg: {
|
|
45
|
-
'condition.dict_code': [KeysOfValidators.REQUIRED],
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@Post('/getDataDictItemList')
|
|
51
|
-
async getDataDictItemList() {
|
|
52
|
-
return this.executeSysSimpleSQL('sys_data_dict_item', KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@Post('/getDataDictItemOne')
|
|
56
|
-
async getDataDictItemOne() {
|
|
57
|
-
return this.executeSysSimpleSQL('sys_data_dict_item', KeysOfSimpleSQL.SIMPLE_QUERY_ONE);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
@Post('/createDataDictItem', { middleware: [checkPermission(SystemFuncCode.DataDictMangeWrite)] })
|
|
61
|
-
async createDataDictItem() {
|
|
62
|
-
return this.executeSysSimpleSQL('sys_data_dict_item', KeysOfSimpleSQL.SIMPLE_INSERT);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
@Post('/updateDataDictItem', { middleware: [checkPermission(SystemFuncCode.DataDictMangeWrite)] })
|
|
66
|
-
async updateDataDictItem() {
|
|
67
|
-
return this.executeSysSimpleSQL('sys_data_dict_item', KeysOfSimpleSQL.SIMPLE_UPDATE);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
@Post('/deleteDataDictItem', { middleware: [checkPermission(SystemFuncCode.DataDictMangeWrite)] })
|
|
71
|
-
async deleteDataDictItem() {
|
|
72
|
-
return this.executeSysSimpleSQL('sys_data_dict_item', KeysOfSimpleSQL.SIMPLE_DELETE, {
|
|
73
|
-
validateCfg: {
|
|
74
|
-
'condition.dict_code': [KeysOfValidators.REQUIRED],
|
|
75
|
-
},
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|