midway-fatcms 0.0.1-beta.5 → 0.0.1-beta.50
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/.eslintrc.json +14 -0
- package/.prettierrc.js +4 -0
- package/README.md +7 -0
- package/dist/config/config.default.js +25 -13
- package/dist/config/seed/aeskey.txt +1 -1
- package/dist/configuration.d.ts +1 -0
- package/dist/configuration.js +35 -11
- package/dist/controller/base/BaseApiController.d.ts +7 -1
- package/dist/controller/base/BaseApiController.js +32 -6
- package/dist/controller/gateway/AsyncTaskController.d.ts +20 -0
- package/dist/controller/gateway/AsyncTaskController.js +181 -0
- package/dist/controller/gateway/CrudMtdGatewayController.d.ts +3 -3
- package/dist/controller/gateway/CrudMtdGatewayController.js +9 -6
- package/dist/controller/gateway/CrudStdGatewayController.js +8 -16
- package/dist/controller/gateway/DocGatewayController.js +14 -9
- package/dist/controller/gateway/FileController.d.ts +3 -2
- package/dist/controller/gateway/PublicApiController.js +4 -6
- package/dist/controller/gateway/StaticController.d.ts +0 -1
- package/dist/controller/gateway/StaticController.js +40 -39
- package/dist/controller/helpers.controller.d.ts +1 -1
- package/dist/controller/home.controller.js +4 -3
- package/dist/controller/manage/AnyApiMangeApi.js +2 -2
- package/dist/controller/manage/AppLogMangeApi.js +2 -2
- package/dist/controller/manage/AppMangeApi.js +2 -2
- package/dist/controller/manage/AppPageMangeApi.js +2 -2
- package/dist/controller/manage/AppSchemaHistoryApi.js +2 -2
- package/dist/controller/manage/CrudMethodsMangeApi.js +2 -2
- package/dist/controller/manage/CrudStandardDesignApi.d.ts +9 -1
- package/dist/controller/manage/CrudStandardDesignApi.js +135 -79
- package/dist/controller/manage/DataDictManageApi.d.ts +1 -1
- package/dist/controller/manage/DataDictManageApi.js +1 -1
- package/dist/controller/manage/DeployManageApi.d.ts +1 -1
- package/dist/controller/manage/DeployManageApi.js +38 -34
- package/dist/controller/manage/DocLibManageApi.js +2 -2
- package/dist/controller/manage/DocManageApi.js +2 -2
- package/dist/controller/manage/FileManageApi.js +1 -1
- package/dist/controller/manage/LowCodeTplManageApi.js +2 -2
- package/dist/controller/manage/MenuManageApi.js +2 -2
- package/dist/controller/manage/ProxyApiMangeApi.js +2 -2
- package/dist/controller/manage/SuperAdminManageApi.d.ts +2 -2
- package/dist/controller/manage/SuperAdminManageApi.js +12 -8
- package/dist/controller/manage/SysConfigMangeApi.d.ts +1 -1
- package/dist/controller/manage/SysConfigMangeApi.js +8 -6
- package/dist/controller/manage/SystemInfoManageApi.d.ts +1 -1
- package/dist/controller/manage/SystemInfoManageApi.js +7 -1
- package/dist/controller/manage/UserAccountManageApi.d.ts +1 -1
- package/dist/controller/manage/UserAccountManageApi.js +9 -4
- package/dist/controller/manage/WorkbenchMangeApi.js +3 -3
- package/dist/controller/myinfo/AuthController.d.ts +0 -4
- package/dist/controller/myinfo/AuthController.js +1 -54
- package/dist/controller/render/AppRenderController.js +12 -5
- package/dist/controller/test.controller.d.ts +1 -1
- package/dist/controller/test.controller.js +5 -5
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/libs/crud-pro/CrudPro.d.ts +1 -0
- package/dist/libs/crud-pro/CrudPro.js +5 -0
- package/dist/libs/crud-pro/defaultConfigs.js +2 -0
- package/dist/libs/crud-pro/interfaces.d.ts +7 -1
- package/dist/libs/crud-pro/models/ExecuteContext.d.ts +12 -5
- package/dist/libs/crud-pro/models/ExecuteContextFunc.d.ts +8 -1
- package/dist/libs/crud-pro/models/ExecuteContextFunc.js +8 -0
- package/dist/libs/crud-pro/models/RequestCfgModel.d.ts +1 -1
- package/dist/libs/crud-pro/models/ResModel.d.ts +16 -0
- package/dist/libs/crud-pro/models/ResModel.js +2 -0
- package/dist/libs/crud-pro/models/SqlCfgModel.d.ts +1 -1
- package/dist/libs/crud-pro/models/Transaction.d.ts +1 -0
- package/dist/libs/crud-pro/models/Transaction.js +7 -0
- package/dist/libs/crud-pro/models/TransactionSqlServer.js +1 -1
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.d.ts +1 -0
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.js +27 -15
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +17 -19
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.d.ts +1 -1
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +10 -12
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +14 -23
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +7 -6
- package/dist/libs/crud-pro/services/CrudProServiceBase.d.ts +2 -6
- package/dist/libs/crud-pro/services/CrudProServiceBase.js +15 -3
- package/dist/libs/crud-pro/services/CrudProTableMetaService.d.ts +1 -0
- package/dist/libs/crud-pro/services/CrudProTableMetaService.js +32 -7
- package/dist/libs/crud-pro/sql.txt +120 -120
- package/dist/libs/crud-pro/utils/DatabaseName.js +24 -3
- package/dist/libs/crud-pro/utils/MixinUtils.js +1 -1
- package/dist/libs/crud-pro/utils/ValidateUtils.js +1 -1
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +2 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.d.ts +3 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.js +22 -0
- package/dist/libs/global-config/global-config.d.ts +60 -0
- package/dist/libs/global-config/global-config.js +35 -0
- package/dist/libs/utils/base64.d.ts +9 -0
- package/dist/libs/utils/base64.js +42 -0
- package/dist/libs/utils/errorToString.d.ts +2 -0
- package/dist/libs/utils/errorToString.js +57 -0
- package/dist/libs/utils/fatcms-request.js +2 -2
- package/dist/libs/utils/functions.d.ts +2 -1
- package/dist/libs/utils/functions.js +12 -3
- package/dist/libs/utils/parseCreateSql.d.ts +6 -1
- package/dist/libs/utils/parseCreateSql.js +2 -1
- package/dist/middleware/forbidden.middleware.js +6 -22
- package/dist/middleware/global.middleware.js +30 -10
- package/dist/middleware/permission.middleware.js +1 -1
- package/dist/middleware/rediscache.middleware.d.ts +3 -0
- package/dist/middleware/rediscache.middleware.js +77 -0
- package/dist/middleware/redislock.middleware.d.ts +7 -0
- package/dist/middleware/redislock.middleware.js +72 -0
- package/dist/models/AsyncTaskModel.d.ts +74 -0
- package/dist/models/AsyncTaskModel.js +31 -0
- package/dist/models/RedisKeys.d.ts +15 -0
- package/dist/models/RedisKeys.js +18 -0
- package/dist/models/SystemEntities.d.ts +8 -1
- package/dist/models/SystemEntities.js +7 -0
- package/dist/models/SystemTables.d.ts +1 -3
- package/dist/models/SystemTables.js +2 -4
- package/dist/models/bizmodels.d.ts +30 -0
- package/dist/models/bizmodels.js +6 -1
- package/dist/models/userSession.d.ts +1 -0
- package/dist/schedule/anonymousContext.d.ts +14 -0
- package/dist/schedule/anonymousContext.js +59 -0
- package/dist/schedule/index.d.ts +4 -3
- package/dist/schedule/index.js +8 -67
- package/dist/schedule/runSchedule.d.ts +12 -0
- package/dist/schedule/runSchedule.js +68 -0
- package/dist/schedule/scheduleNames.d.ts +13 -0
- package/dist/schedule/scheduleNames.js +17 -0
- package/dist/service/AuthService.js +8 -5
- package/dist/service/EnumInfoService.js +9 -5
- package/dist/service/FileCenterService.js +13 -9
- package/dist/service/SysConfigService.d.ts +1 -1
- package/dist/service/SysConfigService.js +4 -2
- package/dist/service/UserAccountService.js +10 -6
- package/dist/service/UserSessionService.d.ts +22 -0
- package/dist/service/UserSessionService.js +74 -2
- package/dist/service/VisitStatService.d.ts +1 -1
- package/dist/service/VisitStatService.js +20 -27
- package/dist/service/WorkbenchService.d.ts +33 -0
- package/dist/service/WorkbenchService.js +70 -12
- package/dist/service/anyapi/AnyApiSandboxService.js +12 -12
- package/dist/service/anyapi/AnyApiService.js +4 -2
- package/dist/service/asyncTask/AsyncTaskRunnerService.d.ts +50 -0
- package/dist/service/asyncTask/AsyncTaskRunnerService.js +287 -0
- package/dist/service/asyncTask/AsyncTaskService.d.ts +7 -0
- package/dist/service/asyncTask/AsyncTaskService.js +34 -0
- package/dist/service/asyncTask/handler/ExcelInfoModel.d.ts +10 -0
- package/dist/service/asyncTask/handler/ExcelInfoModel.js +2 -0
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.d.ts +7 -0
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.js +216 -0
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.d.ts +36 -0
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.js +141 -0
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.d.ts +46 -0
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.js +135 -0
- package/dist/service/base/BaseService.d.ts +12 -0
- package/dist/service/base/BaseService.js +22 -0
- package/dist/service/base/RedisCacheService.d.ts +7 -0
- package/dist/service/base/RedisCacheService.js +7 -0
- package/dist/service/crudstd/CrudStdRelationService.js +63 -36
- package/dist/service/crudstd/CrudStdService.d.ts +21 -5
- package/dist/service/crudstd/CrudStdService.js +135 -21
- package/dist/service/curd/CrudProQuick.d.ts +44 -0
- package/dist/service/curd/CrudProQuick.js +147 -0
- package/dist/service/curd/CurdMixByAccountService.d.ts +4 -4
- package/dist/service/curd/CurdMixByAccountService.js +11 -6
- package/dist/service/curd/CurdMixByDictService.d.ts +4 -4
- package/dist/service/curd/CurdMixByDictService.js +10 -7
- package/dist/service/curd/CurdMixByLinkToCustomService.d.ts +13 -4
- package/dist/service/curd/CurdMixByLinkToCustomService.js +73 -24
- package/dist/service/curd/CurdMixBySysConfigService.d.ts +3 -3
- package/dist/service/curd/CurdMixBySysConfigService.js +4 -2
- package/dist/service/curd/CurdMixByWorkbenchService.d.ts +3 -3
- package/dist/service/curd/CurdMixByWorkbenchService.js +4 -2
- package/dist/service/curd/CurdMixService.d.ts +16 -5
- package/dist/service/curd/CurdMixService.js +26 -2
- package/dist/service/curd/CurdMixUtils.d.ts +27 -4
- package/dist/service/curd/CurdMixUtils.js +117 -41
- package/dist/service/curd/CurdProService.d.ts +3 -10
- package/dist/service/curd/CurdProService.js +38 -148
- package/dist/service/curd/fixCfgModel.d.ts +3 -0
- package/dist/service/curd/fixCfgModel.js +103 -0
- package/dist/service/proxyapi/ProxyApiLoadService.js +7 -4
- package/dist/service/proxyapi/ProxyApiService.d.ts +1 -0
- package/dist/service/proxyapi/ProxyApiService.js +43 -9
- package/dist/views/404_app.html +31 -31
- package/dist/views/404_workbench.html +34 -34
- package/package.json +28 -24
- package/tsconfig.json +32 -0
- package/src/config/config.default.ts +0 -172
- package/src/config/seed/aeskey.txt +0 -1
- package/src/config/utils.ts +0 -23
- package/src/configuration.ts +0 -83
- package/src/controller/base/BaseApiController.ts +0 -145
- package/src/controller/gateway/AnyApiGatewayController.ts +0 -33
- package/src/controller/gateway/CrudMtdGatewayController.ts +0 -107
- package/src/controller/gateway/CrudStdGatewayController.ts +0 -101
- package/src/controller/gateway/DocGatewayController.ts +0 -165
- package/src/controller/gateway/FileController.ts +0 -110
- package/src/controller/gateway/ProxyApiGatewayController.ts +0 -47
- package/src/controller/gateway/PublicApiController.ts +0 -145
- package/src/controller/gateway/StaticController.ts +0 -328
- package/src/controller/helpers.controller.ts +0 -161
- package/src/controller/home.controller.ts +0 -71
- 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 -353
- package/src/controller/manage/DataDictManageApi.ts +0 -78
- package/src/controller/manage/DeployManageApi.ts +0 -179
- 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 -63
- package/src/controller/manage/ProxyApiMangeApi.ts +0 -52
- package/src/controller/manage/SuperAdminManageApi.ts +0 -138
- package/src/controller/manage/SysConfigMangeApi.ts +0 -95
- package/src/controller/manage/SystemInfoManageApi.ts +0 -48
- package/src/controller/manage/UserAccountManageApi.ts +0 -88
- package/src/controller/manage/WorkbenchMangeApi.ts +0 -72
- package/src/controller/myinfo/AuthController.ts +0 -174
- package/src/controller/myinfo/MyInfoController.ts +0 -32
- package/src/controller/render/AppRenderController.ts +0 -76
- 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 -99
- package/src/interface.ts +0 -31
- package/src/libs/crud-pro/CrudPro.ts +0 -158
- package/src/libs/crud-pro/defaultConfigs.ts +0 -13
- package/src/libs/crud-pro/exceptions.ts +0 -124
- package/src/libs/crud-pro/interfaces.ts +0 -183
- package/src/libs/crud-pro/models/ExecuteContext.ts +0 -111
- package/src/libs/crud-pro/models/ExecuteContextFunc.ts +0 -86
- 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/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 -74
- 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 -107
- package/src/libs/crud-pro/models/keys.ts +0 -159
- package/src/libs/crud-pro/services/CrudProCachedCfgService.ts +0 -75
- package/src/libs/crud-pro/services/CrudProExecuteFuncService.ts +0 -128
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +0 -279
- 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 -373
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +0 -202
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +0 -397
- package/src/libs/crud-pro/services/CrudProServiceBase.ts +0 -98
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +0 -59
- 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 -40
- 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 -167
- 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/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/utils/common-dto.ts +0 -52
- package/src/libs/utils/crypto-utils.ts +0 -52
- package/src/libs/utils/fatcms-request.ts +0 -115
- package/src/libs/utils/functions.ts +0 -67
- package/src/libs/utils/ordernum-utils.ts +0 -18
- package/src/libs/utils/parseConfig.ts +0 -62
- package/src/libs/utils/parseCreateSql.ts +0 -91
- package/src/libs/utils/render-utils.ts +0 -184
- package/src/middleware/forbidden.middleware.ts +0 -71
- package/src/middleware/global.middleware.ts +0 -278
- package/src/middleware/permission.middleware.ts +0 -81
- package/src/middleware/tx.middleware.ts +0 -30
- package/src/models/SystemEntities.ts +0 -115
- package/src/models/SystemPerm.ts +0 -105
- package/src/models/SystemTables.ts +0 -30
- package/src/models/bizmodels.ts +0 -89
- package/src/models/contextLogger.ts +0 -132
- package/src/models/devops.ts +0 -17
- package/src/models/userSession.ts +0 -216
- package/src/schedule/index.ts +0 -73
- package/src/service/AuthService.ts +0 -270
- package/src/service/EnumInfoService.ts +0 -129
- package/src/service/FileCenterService.ts +0 -394
- package/src/service/SysConfigService.ts +0 -34
- package/src/service/UserAccountService.ts +0 -100
- package/src/service/UserSessionService.ts +0 -81
- package/src/service/VisitStatService.ts +0 -179
- package/src/service/WorkbenchService.ts +0 -160
- package/src/service/anyapi/AnyApiSandboxService.ts +0 -121
- package/src/service/anyapi/AnyApiService.ts +0 -184
- package/src/service/base/ApiBaseService.ts +0 -42
- package/src/service/base/ApiRateLimiter.ts +0 -59
- package/src/service/base/BaseService.ts +0 -74
- 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 -188
- package/src/service/curd/CurdMixByAccountService.ts +0 -83
- package/src/service/curd/CurdMixByDictService.ts +0 -113
- package/src/service/curd/CurdMixByLinkToCustomService.ts +0 -167
- package/src/service/curd/CurdMixBySysConfigService.ts +0 -78
- package/src/service/curd/CurdMixByWorkbenchService.ts +0 -68
- package/src/service/curd/CurdMixService.ts +0 -65
- package/src/service/curd/CurdMixUtils.ts +0 -248
- package/src/service/curd/CurdProService.ts +0 -379
- package/src/service/proxyapi/ProxyApiLoadService.ts +0 -165
- 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,107 +0,0 @@
|
|
|
1
|
-
import * as _ from 'lodash';
|
|
2
|
-
import { decamelizeKeys } from 'humps';
|
|
3
|
-
import { Controller, Inject, Param, All } from '@midwayjs/core';
|
|
4
|
-
import { Context } from '@midwayjs/koa';
|
|
5
|
-
import { CommonResult } from '../../libs/utils/common-dto';
|
|
6
|
-
import { WorkbenchService } from '../../service/WorkbenchService';
|
|
7
|
-
import { API_BASE_TYPE, ApiBaseService } from '../../service/base/ApiBaseService';
|
|
8
|
-
import { CurdProService } from '../../service/curd/CurdProService';
|
|
9
|
-
import { CurdMixService } from '../../service/curd/CurdMixService';
|
|
10
|
-
import { IRequestCfgModel2 } from '../../models/bizmodels';
|
|
11
|
-
import {parseDatabaseName} from "../../libs/crud-pro/utils/DatabaseName";
|
|
12
|
-
|
|
13
|
-
const QUERY_AS_LIST = ['condition', 'data'];
|
|
14
|
-
|
|
15
|
-
function pickAsQuery(query_as_pick: string, query: any): any {
|
|
16
|
-
if (query_as_pick && typeof query_as_pick === 'string') {
|
|
17
|
-
const pickArray = query_as_pick.split(',');
|
|
18
|
-
return _.pick(query, pickArray);
|
|
19
|
-
}
|
|
20
|
-
return query;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// /ns/gw/api/crudMtd/getUser?__query_as_condition__=id&_query_as_data__=name&&id=1&name=22
|
|
24
|
-
/**
|
|
25
|
-
* query形式1:GET: /ns/gw/api/crudMtd/getUser?__query_json__=%7B%22condition%22%3A%7B%22id%22%3A2%7D%7D
|
|
26
|
-
* query形式2:GET: /ns/gw/api/crudMtd/getUser?__query_as__=condition&id=1&name=22
|
|
27
|
-
* query形式3:GET: /ns/gw/api/crudMtd/createUser?__query_as__=data&__query_pick__=id,name&id=1&name=22
|
|
28
|
-
*
|
|
29
|
-
* 执行单个配置的接口
|
|
30
|
-
*/
|
|
31
|
-
@Controller('/ns/gw/crudApi')
|
|
32
|
-
export class CrudMtdGatewayController extends ApiBaseService {
|
|
33
|
-
@Inject()
|
|
34
|
-
protected ctx: Context;
|
|
35
|
-
|
|
36
|
-
@Inject()
|
|
37
|
-
protected workbenchService: WorkbenchService;
|
|
38
|
-
|
|
39
|
-
@Inject()
|
|
40
|
-
private curdProService: CurdProService;
|
|
41
|
-
|
|
42
|
-
@Inject()
|
|
43
|
-
private curdMixService: CurdMixService;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* 执行配置出来的接口的接口。此接口本身不需要鉴权。鉴权信息在配置中由curdPro底层进行鉴权
|
|
47
|
-
*/
|
|
48
|
-
@All('/execute/:methodCode')
|
|
49
|
-
async executeCrudMethod(@Param('methodCode') methodCode: string) {
|
|
50
|
-
if (!methodCode) {
|
|
51
|
-
return CommonResult.errorRes('method参数不存在');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const methodInfo = (await this.curdProService.getCachedCfgByMethod(methodCode)) as any;
|
|
55
|
-
if (!methodInfo || methodInfo.status !== 1) {
|
|
56
|
-
return CommonResult.errorRes('接口不存在或已下线: ' + methodCode);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
this.logInfo("methodInfo=== ", methodInfo)
|
|
60
|
-
|
|
61
|
-
const workbench_code_array = methodInfo.workbench_code_array || methodInfo.workbenchCodeArray;
|
|
62
|
-
const isSupport = await this.workbenchService.isSupportCurrentWorkbench(workbench_code_array);
|
|
63
|
-
if (!isSupport) {
|
|
64
|
-
return CommonResult.errorRes('此接口不支持在当前站点打开');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// 权限等校验\服务降级\限流令牌桶
|
|
68
|
-
const entity = decamelizeKeys(methodInfo) as any;
|
|
69
|
-
await super.beforeCheckApiAccessibility(API_BASE_TYPE.CRUD_METHOD, entity);
|
|
70
|
-
|
|
71
|
-
const reqJson: any = {};
|
|
72
|
-
|
|
73
|
-
const body = this.ctx.request.body as any;
|
|
74
|
-
if (body && typeof body === 'object') {
|
|
75
|
-
Object.assign(reqJson, body);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const query = this.ctx.query || {};
|
|
79
|
-
|
|
80
|
-
const query_json = query['__query_json__'];
|
|
81
|
-
const query_as = query['__query_as__'] as string;
|
|
82
|
-
const query_pick = query['__query_pick__'] as string; // 以逗号分割的字段列表。只部分字段作为参数。。
|
|
83
|
-
|
|
84
|
-
delete query['__query_json__'];
|
|
85
|
-
delete query['__query_as__'];
|
|
86
|
-
delete query['__query_pick__'];
|
|
87
|
-
|
|
88
|
-
if (query_json && typeof query_json === 'string') {
|
|
89
|
-
const queryJson = JSON.parse(query_json);
|
|
90
|
-
Object.assign(reqJson, queryJson);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (query_as && QUERY_AS_LIST.includes(query_as)) {
|
|
94
|
-
const pickedQuery = pickAsQuery(query_pick, query);
|
|
95
|
-
_.set(reqJson, query_as, pickedQuery);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
Object.assign(reqJson, { method: methodCode });
|
|
99
|
-
|
|
100
|
-
const cfgModel = methodInfo as IRequestCfgModel2;
|
|
101
|
-
const { dbType, dbName } = parseDatabaseName(cfgModel.sqlDatabase);
|
|
102
|
-
cfgModel.sqlDatabase = dbName;
|
|
103
|
-
cfgModel.sqlDdType = dbType;
|
|
104
|
-
|
|
105
|
-
return this.curdMixService.executeCrudByCfg(reqJson, cfgModel);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { Controller, Inject, Post } from '@midwayjs/core';
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
-
import { CrudStdService, SPECIAL_SETTING_KEY } from '../../service/crudstd/CrudStdService';
|
|
5
|
-
import { KeysOfSimpleSQL } from '../../libs/crud-pro/models/keys';
|
|
6
|
-
import { IRequestModel } from '../../libs/crud-pro/interfaces';
|
|
7
|
-
import { CommonResult } from '../../libs/utils/common-dto';
|
|
8
|
-
|
|
9
|
-
interface ICrudStdActionParams {
|
|
10
|
-
appCode: string;
|
|
11
|
-
settingKey?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type ICrudStdParams = { stdAction: ICrudStdActionParams } & IRequestModel;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 零代码配置的界面,相关的接口的执行
|
|
18
|
-
*/
|
|
19
|
-
@Controller('/ns/gw/api/crudStd')
|
|
20
|
-
export class CrudStdGatewayController extends BaseApiController {
|
|
21
|
-
@Inject()
|
|
22
|
-
protected ctx: Context;
|
|
23
|
-
|
|
24
|
-
@Inject()
|
|
25
|
-
private crudStdService: CrudStdService;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 获取零代码应用基本信息
|
|
29
|
-
*/
|
|
30
|
-
@Post('/getParsedCrudStdAppInfo')
|
|
31
|
-
async getParsedCrudStdAppInfo(): Promise<CommonResult> {
|
|
32
|
-
const body = this.ctx.request.body as ICrudStdParams;
|
|
33
|
-
const appCode = body.stdAction.appCode;
|
|
34
|
-
const parsedAppInfo = await this.crudStdService.getParsedCrudStdAppInfo(appCode);
|
|
35
|
-
return CommonResult.successNotNull(parsedAppInfo);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 列表查询: 分页查询
|
|
40
|
-
*/
|
|
41
|
-
@Post('/getObjectList')
|
|
42
|
-
async getObjectList() {
|
|
43
|
-
const { stdAction, ...otherParams } = this.ctx.request.body as ICrudStdParams;
|
|
44
|
-
const appCode = stdAction.appCode;
|
|
45
|
-
return this.crudStdService.executeStdQuery(appCode, SPECIAL_SETTING_KEY.QUERY_LIST, otherParams, KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 单个查询
|
|
50
|
-
*/
|
|
51
|
-
@Post('/getObjectOne')
|
|
52
|
-
async getObjectOne() {
|
|
53
|
-
const { stdAction, ...otherParams } = this.ctx.request.body as ICrudStdParams;
|
|
54
|
-
const appCode = stdAction.appCode;
|
|
55
|
-
return this.crudStdService.executeStdQuery(appCode, SPECIAL_SETTING_KEY.QUERY_ONE, otherParams, KeysOfSimpleSQL.SIMPLE_QUERY_ONE);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* 单个删除
|
|
60
|
-
*/
|
|
61
|
-
@Post('/deleteObject')
|
|
62
|
-
async deleteObject() {
|
|
63
|
-
const { stdAction, ...otherParams } = this.ctx.request.body as ICrudStdParams;
|
|
64
|
-
const appCode = stdAction.appCode;
|
|
65
|
-
const settingKey = stdAction.settingKey;
|
|
66
|
-
return this.crudStdService.executeStdQuery(appCode, settingKey, otherParams, KeysOfSimpleSQL.SIMPLE_DELETE);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* 单个创建
|
|
71
|
-
*/
|
|
72
|
-
@Post('/createObject')
|
|
73
|
-
async createObject() {
|
|
74
|
-
const { stdAction, ...otherParams } = this.ctx.request.body as ICrudStdParams;
|
|
75
|
-
const appCode = stdAction.appCode;
|
|
76
|
-
const settingKey = stdAction.settingKey;
|
|
77
|
-
return this.crudStdService.executeStdQuery(appCode, settingKey, otherParams, KeysOfSimpleSQL.SIMPLE_INSERT);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* 单个更新
|
|
82
|
-
*/
|
|
83
|
-
@Post('/updateObject')
|
|
84
|
-
async updateObject() {
|
|
85
|
-
const { stdAction, ...otherParams } = this.ctx.request.body as ICrudStdParams;
|
|
86
|
-
const appCode = stdAction.appCode;
|
|
87
|
-
const settingKey = stdAction.settingKey;
|
|
88
|
-
return this.crudStdService.executeStdQuery(appCode, settingKey, otherParams, KeysOfSimpleSQL.SIMPLE_UPDATE);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* 执行操作
|
|
93
|
-
*/
|
|
94
|
-
@Post('/executeStdAction')
|
|
95
|
-
async executeStdAction() {
|
|
96
|
-
const { stdAction, ...otherParams } = this.ctx.request.body as ICrudStdParams;
|
|
97
|
-
const appCode = stdAction.appCode;
|
|
98
|
-
const settingKey = stdAction.settingKey;
|
|
99
|
-
return await this.crudStdService.executeStdActionByReq(appCode, settingKey, otherParams);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import {Get, Controller, Inject, Query} from '@midwayjs/core';
|
|
2
|
-
import {Context} from '@midwayjs/koa';
|
|
3
|
-
import {BaseApiController} from '../base/BaseApiController';
|
|
4
|
-
import {SystemDbName, SystemDbType, SystemTables} from '../../models/SystemTables';
|
|
5
|
-
import {KeysOfSimpleSQL} from '../../libs/crud-pro/models/keys';
|
|
6
|
-
import {WorkbenchService} from '../../service/WorkbenchService';
|
|
7
|
-
import {CommonResult} from '../../libs/utils/common-dto';
|
|
8
|
-
|
|
9
|
-
function checkIsNumber(value: string, name: string) {
|
|
10
|
-
if (!value) {
|
|
11
|
-
throw `${name}参数不存在`;
|
|
12
|
-
}
|
|
13
|
-
if (!parseInt(value)) {
|
|
14
|
-
throw `${name}参数不是一个整数`;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* C端用户接口。
|
|
20
|
-
* 对外开发接口。
|
|
21
|
-
*/
|
|
22
|
-
@Controller('/ns/gw/doc')
|
|
23
|
-
export class DocGatewayController extends BaseApiController {
|
|
24
|
-
@Inject()
|
|
25
|
-
protected ctx: Context;
|
|
26
|
-
|
|
27
|
-
@Inject()
|
|
28
|
-
protected workbenchService: WorkbenchService;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
private async updateDocPV(docId: string, docLibId: string, pv: number) {
|
|
32
|
-
const ip = this.ctx.headers['x-real-ip'];
|
|
33
|
-
const lockKey = `doc_ip_pv_${docId}_${ip}`;
|
|
34
|
-
const EXPIRE_TIME = 5 * 60 * 1000; // 在五分钟内,同一个IP地址重复刷新同一篇文章,认为是一个PV
|
|
35
|
-
const nxRes = await this.redisService.set(lockKey, 1, 'EX', EXPIRE_TIME, 'NX')
|
|
36
|
-
if (nxRes !== 'OK') {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
await this.curdMixService.executeCrudByCfg({
|
|
41
|
-
data: {
|
|
42
|
-
pv: pv + 1
|
|
43
|
-
},
|
|
44
|
-
condition: {
|
|
45
|
-
id: parseInt(docId),
|
|
46
|
-
doc_lib_id: parseInt(docLibId),
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
sqlTable: SystemTables.sys_doc,
|
|
51
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
52
|
-
sqlDatabase: SystemDbName,
|
|
53
|
-
sqlDdType: SystemDbType,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @param docId
|
|
60
|
-
* @param docLibId 文档库
|
|
61
|
-
*/
|
|
62
|
-
@Get('/getDocInfo')
|
|
63
|
-
async getDocInfo(@Query('docId') docId: string, @Query('docLibId') docLibId: string) {
|
|
64
|
-
checkIsNumber(docId, 'docId');
|
|
65
|
-
checkIsNumber(docLibId, 'docLibId');
|
|
66
|
-
|
|
67
|
-
const docLibInfoRes = await this.getDocLibInfo(docLibId);
|
|
68
|
-
if (!docLibInfoRes.success) {
|
|
69
|
-
return docLibInfoRes;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const res = await this.curdMixService.executeCrudByCfg(
|
|
74
|
-
{
|
|
75
|
-
condition: {
|
|
76
|
-
id: parseInt(docId),
|
|
77
|
-
doc_lib_id: parseInt(docLibId),
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
sqlTable: SystemTables.sys_doc,
|
|
82
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
83
|
-
sqlDatabase: SystemDbName,
|
|
84
|
-
sqlDdType: SystemDbType,
|
|
85
|
-
}
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
// 更新PV数据
|
|
89
|
-
const docObj = res.getOneObj();
|
|
90
|
-
if (docObj) {
|
|
91
|
-
const pv: number = parseInt(docObj.pv) || 0;
|
|
92
|
-
await this.updateDocPV(docId, docLibId, pv);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return res;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* @param docLibId
|
|
100
|
-
*/
|
|
101
|
-
@Get('/getDocList')
|
|
102
|
-
async getDocList(@Query('docLibId') docLibId: string) {
|
|
103
|
-
checkIsNumber(docLibId, 'docLibId');
|
|
104
|
-
|
|
105
|
-
const docLibInfoRes = await this.getDocLibInfo(docLibId);
|
|
106
|
-
if (!docLibInfoRes.success) {
|
|
107
|
-
return docLibInfoRes;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return this.curdMixService.executeCrudByCfg(
|
|
111
|
-
{
|
|
112
|
-
columns: 'id,title,doc_category_code,sort_index',
|
|
113
|
-
orderBy: 'sort_index+,id-',
|
|
114
|
-
condition: {
|
|
115
|
-
doc_lib_id: parseInt(docLibId),
|
|
116
|
-
doc_category_code: {
|
|
117
|
-
$notNull: '',
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
sqlTable: SystemTables.sys_doc,
|
|
123
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
124
|
-
sqlDatabase: SystemDbName,
|
|
125
|
-
sqlDdType: SystemDbType,
|
|
126
|
-
}
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* TODO 权限控制
|
|
132
|
-
* @param docLibId
|
|
133
|
-
*/
|
|
134
|
-
@Get('/getDocLibInfo')
|
|
135
|
-
async getDocLibInfo(@Query('docLibId') docLibId: string) {
|
|
136
|
-
checkIsNumber(docLibId, 'docLibId');
|
|
137
|
-
|
|
138
|
-
const s = await this.curdMixService.executeCrudByCfg(
|
|
139
|
-
{
|
|
140
|
-
condition: {
|
|
141
|
-
id: parseInt(docLibId),
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
sqlTable: SystemTables.sys_doc_lib,
|
|
146
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
147
|
-
sqlDatabase: SystemDbName,
|
|
148
|
-
sqlDdType: SystemDbType,
|
|
149
|
-
}
|
|
150
|
-
);
|
|
151
|
-
const docLibInfo = s.getOneObj();
|
|
152
|
-
|
|
153
|
-
if (!docLibInfo) {
|
|
154
|
-
throw '此文档库查询失败';
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const workbench_code_array = docLibInfo.workbench_code_array;
|
|
158
|
-
const isSupportCurrentWorkbench = await this.workbenchService.isSupportCurrentWorkbench(workbench_code_array);
|
|
159
|
-
if (!isSupportCurrentWorkbench) {
|
|
160
|
-
throw '此文档库不支持在当前站点打开';
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return CommonResult.successRes(docLibInfo);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { Get, Post, Inject, Controller, Files, Fields, Param, Query } from '@midwayjs/core';
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import * as _ from 'lodash';
|
|
4
|
-
import { BaseApiController } from '../base/BaseApiController';
|
|
5
|
-
import { BizException } from '../../models/devops';
|
|
6
|
-
import {AccessType, FILE_GET_TYPES} from '../../models/bizmodels';
|
|
7
|
-
import { FileCenterService, PATH_PREFIX, toDownloadPaths, isImageFile } from '../../service/FileCenterService';
|
|
8
|
-
import { checkPermission } from '../../middleware/permission.middleware';
|
|
9
|
-
import { CommonResult } from '../../libs/utils/common-dto';
|
|
10
|
-
import {SystemFuncCode} from "../../models/SystemPerm";
|
|
11
|
-
|
|
12
|
-
function isTrue(obj: any) {
|
|
13
|
-
return obj === true || obj === 'true';
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 文件上传下载服务
|
|
19
|
-
*/
|
|
20
|
-
@Controller(PATH_PREFIX)
|
|
21
|
-
export class FileController extends BaseApiController {
|
|
22
|
-
@Inject()
|
|
23
|
-
ctx: Context;
|
|
24
|
-
|
|
25
|
-
@Inject()
|
|
26
|
-
private fileCenterService: FileCenterService;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 上传普通文件。必须是登录用户才能上传。
|
|
30
|
-
* @param files
|
|
31
|
-
* @param fields
|
|
32
|
-
* @param queryData
|
|
33
|
-
*/
|
|
34
|
-
@Post('/uploadFile', { middleware: [checkPermission([SystemFuncCode.DocMangeWrite, SystemFuncCode.FileMangeWrite, SystemFuncCode.UserAccountMangeWrite])] } )
|
|
35
|
-
async uploadFile(@Files() files, @Fields() fields, @Query() queryData): Promise<CommonResult> {
|
|
36
|
-
const accessType = queryData?.accessType || fields?.accessType || AccessType.open;
|
|
37
|
-
const referer = this.ctx.req.headers.referer;
|
|
38
|
-
|
|
39
|
-
if (!Object.keys(AccessType).includes(accessType)) {
|
|
40
|
-
throw new BizException(`仅支持 ${Object.keys(AccessType).join('、')} 上传模式`);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const { fileKey, filename, storageUrl } = await this.fileCenterService.uploadFileToOSS(files, accessType, referer);
|
|
44
|
-
|
|
45
|
-
const origin = this.ctx.request.origin;
|
|
46
|
-
|
|
47
|
-
const downloadUrls = toDownloadPaths(origin, fileKey);
|
|
48
|
-
|
|
49
|
-
const data = {
|
|
50
|
-
fileKey,
|
|
51
|
-
filename,
|
|
52
|
-
storageUrl,
|
|
53
|
-
...downloadUrls,
|
|
54
|
-
};
|
|
55
|
-
return CommonResult.successRes(data);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// http://localhost:5173/ns/gw/file/get/download/6114718c6e2cb192bf6e99c3ede2b6d41743401594182.png&process=doc/preview
|
|
59
|
-
/**
|
|
60
|
-
* 文件下载或预览
|
|
61
|
-
* @param byMethod
|
|
62
|
-
* @param fileKey
|
|
63
|
-
* @param process 图片处理:https://help.aliyun.com/document_detail/44688.html
|
|
64
|
-
* @param streaming 是否直接返回流,默认返回 302 跳转
|
|
65
|
-
*/
|
|
66
|
-
@Get('/get/:byMethod/:fileKey*')
|
|
67
|
-
async downloadFile(@Param('byMethod') byMethod: string ,@Param('fileKey') fileKey: string) {
|
|
68
|
-
if (!fileKey) {
|
|
69
|
-
throw new BizException('fileKey不能为空');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const byMethodSet = new Set<string>(FILE_GET_TYPES);
|
|
73
|
-
if (!byMethodSet.has(byMethod)) {
|
|
74
|
-
throw new BizException('byMethod不正确');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// eslint-disable-next-line prefer-const
|
|
78
|
-
let { process, preview, streaming } = (this.ctx.query || {}) as any;
|
|
79
|
-
|
|
80
|
-
const isThumbnail = this.ctx.path.startsWith(`${PATH_PREFIX}/get/thumbnail/`);
|
|
81
|
-
const isPreview = this.ctx.path.startsWith(`${PATH_PREFIX}/get/preview/`) || isTrue(preview);
|
|
82
|
-
const isStreaming = isTrue(streaming);
|
|
83
|
-
|
|
84
|
-
if (isThumbnail && isImageFile(fileKey) && !process) {
|
|
85
|
-
// x-oss-process=image/resize,w_200,p_10/quality,q_60
|
|
86
|
-
process = 'image/resize,w_200'; //图片缩略图(小图片)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const isOutByStreaming = isStreaming || isPreview || isThumbnail;
|
|
90
|
-
|
|
91
|
-
const result = await this.fileCenterService.downloadFile(fileKey, isOutByStreaming, process);
|
|
92
|
-
|
|
93
|
-
if (isOutByStreaming) {
|
|
94
|
-
// 移除这些属性
|
|
95
|
-
const headers: any = _.omitBy(result.res.headers, (_v, key) => {
|
|
96
|
-
if (key === 'content-length') {
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
if ((isPreview || isThumbnail) && key.toLowerCase() === 'content-disposition') {
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
return key.startsWith('x-oss-meta-');
|
|
103
|
-
});
|
|
104
|
-
this.ctx.set(headers);
|
|
105
|
-
this.ctx.body = result.stream;
|
|
106
|
-
} else {
|
|
107
|
-
this.ctx.redirect(result.downloadURL);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { All, Controller, Inject, Query } from '@midwayjs/core';
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
-
import { ProxyApiService } from '../../service/proxyapi/ProxyApiService';
|
|
5
|
-
import { WorkbenchService } from '../../service/WorkbenchService';
|
|
6
|
-
import { CommonResult } from '../../libs/utils/common-dto';
|
|
7
|
-
import { ProxyApiLoadService } from '../../service/proxyapi/ProxyApiLoadService';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 只支持前缀匹配
|
|
11
|
-
* 【/ns/gw/proxy/[upstreamName]/】api/userinfo ==> http://127.0.0.1:3000/api/userinfo
|
|
12
|
-
* FaaS方式配置的接口
|
|
13
|
-
*/
|
|
14
|
-
@Controller('/ns/gw/proxy')
|
|
15
|
-
export class ProxyApiGatewayController extends BaseApiController {
|
|
16
|
-
@Inject()
|
|
17
|
-
protected ctx: Context;
|
|
18
|
-
|
|
19
|
-
@Inject()
|
|
20
|
-
private proxyApiService: ProxyApiService;
|
|
21
|
-
|
|
22
|
-
@Inject()
|
|
23
|
-
private workbenchService: WorkbenchService;
|
|
24
|
-
|
|
25
|
-
@Inject()
|
|
26
|
-
private proxyApiLoadService: ProxyApiLoadService;
|
|
27
|
-
/**
|
|
28
|
-
* 执行配置出来的接口的接口。此接口本身不需要鉴权。鉴权信息在配置中由curdPro底层进行鉴权
|
|
29
|
-
*/
|
|
30
|
-
@All('/*')
|
|
31
|
-
async executeProxyApi() {
|
|
32
|
-
const workbenchInfo = await this.workbenchService.getCurrentHostWorkbenchInfo();
|
|
33
|
-
if (!workbenchInfo) {
|
|
34
|
-
return CommonResult.errorRes('域名站点不存在');
|
|
35
|
-
}
|
|
36
|
-
const workbench_code = workbenchInfo.workbench_code;
|
|
37
|
-
// const path_prefix2 = '/' + entity.upstream_code + entity.path_prefix;
|
|
38
|
-
// 路由树的结构是 /${entity.upstream_code}${entity.path_prefix}
|
|
39
|
-
const path2 = this.ctx.path.replace(/^\/ns\/gw\/proxy/, '');
|
|
40
|
-
return this.proxyApiService.handleProxyRequest(workbench_code, path2);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@All('/buildRouteTrie')
|
|
44
|
-
async buildRouteTrie(@Query('workbench_code') workbench_code: string) {
|
|
45
|
-
return this.proxyApiLoadService.buildRouteTrie(workbench_code);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import {Controller, Get, Inject, Post} from '@midwayjs/core';
|
|
2
|
-
import {Context} from '@midwayjs/koa';
|
|
3
|
-
import * as _ from 'lodash';
|
|
4
|
-
import {BaseApiController} from '../base/BaseApiController';
|
|
5
|
-
import {SystemTables} from '../../models/SystemTables';
|
|
6
|
-
import {EnumInfoService} from '../../service/EnumInfoService';
|
|
7
|
-
import {CommonResult} from '../../libs/utils/common-dto';
|
|
8
|
-
import {parseJsonObject} from '../../libs/utils/functions';
|
|
9
|
-
import {WorkbenchService} from '../../service/WorkbenchService';
|
|
10
|
-
import {SystemRoleCode} from "../../models/SystemPerm";
|
|
11
|
-
import {KeysOfAuthType} from "../../libs/crud-pro/models/keys";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* 公开的API,无需鉴权,所有人可以直接访问
|
|
15
|
-
*/
|
|
16
|
-
@Controller('/ns/gw/api/publicApi')
|
|
17
|
-
export class PublicApiController extends BaseApiController {
|
|
18
|
-
@Inject()
|
|
19
|
-
protected ctx: Context;
|
|
20
|
-
|
|
21
|
-
@Inject()
|
|
22
|
-
private enumInfoService: EnumInfoService;
|
|
23
|
-
|
|
24
|
-
@Inject()
|
|
25
|
-
private workbenchService: WorkbenchService;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 获取所有站点列表
|
|
29
|
-
*/
|
|
30
|
-
@Get('/getAllWorkbenchInfoList')
|
|
31
|
-
async getAllWorkbenchInfoList(): Promise<CommonResult> {
|
|
32
|
-
const entities = await this.workbenchService.getAllWorkbenchInfoList(false);
|
|
33
|
-
const entities2 = entities.map(e => {
|
|
34
|
-
return {
|
|
35
|
-
workbench_domain: e.workbench_domain,
|
|
36
|
-
workbench_code: e.workbench_code,
|
|
37
|
-
workbench_desc: e.workbench_desc,
|
|
38
|
-
workbench_name: e.workbench_name,
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
return CommonResult.successRes(entities2);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* 获取菜单信息
|
|
46
|
-
*/
|
|
47
|
-
@Get('/getWorkbenchMenu')
|
|
48
|
-
async getWorkbenchMenu(): Promise<CommonResult> {
|
|
49
|
-
const query = this.ctx.query || {};
|
|
50
|
-
const workbenchMenuCode = query.workbenchMenuCode;
|
|
51
|
-
if (!workbenchMenuCode) {
|
|
52
|
-
return CommonResult.errorRes('param workbenchMenuCode is null');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const workbenchMenuCodeStr = "" + workbenchMenuCode;
|
|
56
|
-
const workbenchMenuCodeArray = workbenchMenuCodeStr.split(',');
|
|
57
|
-
|
|
58
|
-
const condition = {
|
|
59
|
-
menu_code: {
|
|
60
|
-
"$in": workbenchMenuCodeArray
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
const rows = await this.sysDBUtil.getList({ condition }, SystemTables.sys_menus);
|
|
64
|
-
if (!rows || rows.length === 0) {
|
|
65
|
-
return CommonResult.errorRes('sys_config is null', '', { condition });
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const map = {};
|
|
69
|
-
for (let i = 0; i < rows.length; i++) {
|
|
70
|
-
const rowElement = rows[i];
|
|
71
|
-
const menu_code = rowElement.menu_code;
|
|
72
|
-
const view_auth_config = rowElement.view_auth_config;
|
|
73
|
-
const view_auth_type = rowElement.view_auth_type;
|
|
74
|
-
|
|
75
|
-
const hasPermission = this.ctx.userSession.isAuthPass(view_auth_type, view_auth_config)
|
|
76
|
-
|
|
77
|
-
const menu_config_content = rowElement.menu_config_content;
|
|
78
|
-
delete rowElement.menu_config_content;
|
|
79
|
-
const menu_list = parseJsonObject(menu_config_content) || [];
|
|
80
|
-
map[menu_code] = { ...rowElement, menu_list, hasPermission }
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
// 特殊的devops菜单
|
|
85
|
-
map['devops'] = {
|
|
86
|
-
menu_list: [], // 这个特殊的菜单在前端写死。
|
|
87
|
-
hasPermission: this.ctx.userSession.isAuthPass(KeysOfAuthType.byRoleCode, [
|
|
88
|
-
SystemRoleCode.DevOpsWriter,SystemRoleCode.DevOpsViewer, SystemRoleCode.SuperAdmin
|
|
89
|
-
])
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return CommonResult.successRes(map);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* 获取页面信息
|
|
97
|
-
*/
|
|
98
|
-
@Post('/getNavPageInfo')
|
|
99
|
-
async getNavPageInfo(): Promise<CommonResult> {
|
|
100
|
-
const body = this.ctx.request.body as any;
|
|
101
|
-
const { workbenchCode, appCode, pathname } = body;
|
|
102
|
-
const resultData: any = {};
|
|
103
|
-
const getOne = async (condition: any, tablenName: string, key: string) => {
|
|
104
|
-
const values = Object.values(condition).filter(Boolean);
|
|
105
|
-
// 查询条件不能为空
|
|
106
|
-
if (values.length > 0) {
|
|
107
|
-
const oneData = await this.sysDBUtil.getOne({ condition }, tablenName);
|
|
108
|
-
if (oneData && oneData['app_schema']) {
|
|
109
|
-
oneData['app_schema'] = parseJsonObject(oneData['app_schema']);
|
|
110
|
-
}
|
|
111
|
-
resultData[key] = oneData
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
await getOne({ app_code: appCode }, SystemTables.sys_app, 'appData');
|
|
116
|
-
await getOne({ page_path: pathname, workbench_code: workbenchCode }, SystemTables.sys_app_page, 'pageData');
|
|
117
|
-
|
|
118
|
-
return CommonResult.successRes(resultData);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* 获取配置的枚举项信息: 都是无需鉴权的
|
|
123
|
-
*/
|
|
124
|
-
@Post('/getEnumInfo')
|
|
125
|
-
async getEnumInfo(): Promise<CommonResult> {
|
|
126
|
-
const body = this.ctx.request.body as any;
|
|
127
|
-
const query = this.ctx.query || {};
|
|
128
|
-
let codeList = _.get(body, 'codeList');
|
|
129
|
-
let refreshCache = `${_.get(body, 'refreshCache')}` === 'true' || query.refreshCache === 'true';
|
|
130
|
-
|
|
131
|
-
if (query.codeList) {
|
|
132
|
-
//codeList=dict@@SexEnum,sysCfgEnum@@EntityStatusEnum
|
|
133
|
-
const codeListStr: string = query.codeList as string;
|
|
134
|
-
codeList = codeListStr.split(',').map(str => {
|
|
135
|
-
const ss = str.split('@@');
|
|
136
|
-
return {
|
|
137
|
-
type: ss[0],
|
|
138
|
-
code: ss[1],
|
|
139
|
-
};
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
const enumInfos = await this.enumInfoService.queryEnumInfo(codeList, refreshCache);
|
|
143
|
-
return CommonResult.successRes(enumInfos);
|
|
144
|
-
}
|
|
145
|
-
}
|