midway-fatcms 0.0.1-beta.2 → 0.0.1-beta.22
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 +12 -0
- package/.prettierrc.js +4 -0
- package/README.md +7 -0
- package/dist/config/config.default.js +52 -15
- package/dist/configuration.d.ts +1 -0
- package/dist/configuration.js +33 -8
- package/dist/controller/base/BaseApiController.d.ts +1 -1
- package/dist/controller/base/BaseApiController.js +14 -6
- package/dist/controller/gateway/AsyncTaskController.d.ts +14 -0
- package/dist/controller/gateway/AsyncTaskController.js +108 -0
- package/dist/controller/gateway/CrudMtdGatewayController.d.ts +3 -3
- package/dist/controller/gateway/CrudMtdGatewayController.js +9 -6
- package/dist/controller/gateway/CrudStdGatewayController.d.ts +5 -5
- package/dist/controller/gateway/DocGatewayController.js +14 -9
- package/dist/controller/gateway/PublicApiController.js +4 -6
- package/dist/controller/gateway/StaticController.d.ts +2 -0
- package/dist/controller/gateway/StaticController.js +59 -40
- package/dist/controller/helpers.controller.d.ts +1 -1
- package/dist/controller/home.controller.js +2 -2
- 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 +1 -1
- package/dist/controller/manage/CrudStandardDesignApi.js +78 -75
- 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 +2 -2
- package/dist/controller/manage/UserAccountManageApi.js +7 -2
- 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 +10 -4
- package/dist/controller/test.controller.d.ts +1 -1
- package/dist/controller/test.controller.js +5 -5
- package/dist/index.d.ts +34 -4
- package/dist/index.js +34 -4
- 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 +2 -1
- 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/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 +13 -17
- 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 +3 -2
- 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/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 +45 -0
- package/dist/libs/global-config/global-config.js +33 -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/middleware/forbidden.middleware.js +4 -20
- package/dist/middleware/global.middleware.js +8 -1
- package/dist/models/AsyncTaskModel.d.ts +69 -0
- package/dist/models/AsyncTaskModel.js +26 -0
- package/dist/models/RedisKeys.d.ts +8 -0
- package/dist/models/RedisKeys.js +11 -0
- package/dist/models/SystemTables.d.ts +1 -3
- package/dist/models/SystemTables.js +2 -4
- package/dist/schedule/anonymousContext.d.ts +13 -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 +15 -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 +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/UserSessionService.js +2 -1
- package/dist/service/VisitStatService.d.ts +1 -1
- package/dist/service/VisitStatService.js +20 -27
- package/dist/service/WorkbenchService.js +4 -2
- package/dist/service/anyapi/AnyApiService.js +4 -2
- package/dist/service/asyncTask/AsyncTaskRunnerService.d.ts +37 -0
- package/dist/service/asyncTask/AsyncTaskRunnerService.js +232 -0
- package/dist/service/asyncTask/AsyncTaskService.d.ts +7 -0
- package/dist/service/asyncTask/AsyncTaskService.js +34 -0
- package/dist/service/crudstd/CrudStdService.d.ts +2 -1
- package/dist/service/crudstd/CrudStdService.js +48 -3
- package/dist/service/curd/CrudProQuick.d.ts +24 -0
- package/dist/service/curd/CrudProQuick.js +105 -0
- package/dist/service/curd/CurdMixByAccountService.js +12 -6
- package/dist/service/curd/CurdMixByDictService.js +4 -2
- package/dist/service/curd/CurdMixByLinkToCustomService.d.ts +10 -1
- package/dist/service/curd/CurdMixByLinkToCustomService.js +72 -24
- package/dist/service/curd/CurdMixBySysConfigService.js +4 -2
- package/dist/service/curd/CurdMixByWorkbenchService.js +4 -2
- package/dist/service/curd/CurdMixService.d.ts +1 -1
- package/dist/service/curd/CurdMixService.js +2 -2
- package/dist/service/curd/CurdMixUtils.d.ts +7 -0
- package/dist/service/curd/CurdMixUtils.js +65 -28
- package/dist/service/curd/CurdProService.d.ts +2 -10
- package/dist/service/curd/CurdProService.js +31 -146
- package/dist/service/curd/fixCfgModel.d.ts +3 -0
- package/dist/service/curd/fixCfgModel.js +107 -0
- 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 +9 -2
- package/src/config/config.default.ts +58 -27
- package/src/configuration.ts +42 -9
- package/src/controller/base/BaseApiController.ts +26 -19
- package/src/controller/gateway/AnyApiGatewayController.ts +1 -1
- package/src/controller/gateway/AsyncTaskController.ts +83 -0
- package/src/controller/gateway/CrudMtdGatewayController.ts +17 -13
- package/src/controller/gateway/CrudStdGatewayController.ts +4 -4
- package/src/controller/gateway/DocGatewayController.ts +25 -17
- package/src/controller/gateway/FileController.ts +8 -9
- package/src/controller/gateway/ProxyApiGatewayController.ts +4 -4
- package/src/controller/gateway/PublicApiController.ts +19 -22
- package/src/controller/gateway/StaticController.ts +234 -242
- package/src/controller/helpers.controller.ts +1 -1
- package/src/controller/home.controller.ts +8 -15
- package/src/controller/manage/AnyApiMangeApi.ts +11 -11
- package/src/controller/manage/AppLogMangeApi.ts +5 -5
- package/src/controller/manage/AppMangeApi.ts +7 -7
- package/src/controller/manage/AppPageMangeApi.ts +5 -5
- package/src/controller/manage/AppSchemaHistoryApi.ts +3 -3
- package/src/controller/manage/CrudMethodsMangeApi.ts +5 -5
- package/src/controller/manage/CrudStandardDesignApi.ts +106 -113
- package/src/controller/manage/DataDictManageApi.ts +5 -5
- package/src/controller/manage/DeployManageApi.ts +85 -89
- package/src/controller/manage/DocLibManageApi.ts +5 -5
- package/src/controller/manage/DocManageApi.ts +10 -10
- package/src/controller/manage/FileManageApi.ts +1 -1
- package/src/controller/manage/LowCodeTplManageApi.ts +2 -2
- package/src/controller/manage/MenuManageApi.ts +10 -15
- package/src/controller/manage/ProxyApiMangeApi.ts +2 -2
- package/src/controller/manage/SuperAdminManageApi.ts +14 -13
- package/src/controller/manage/SysConfigMangeApi.ts +11 -11
- package/src/controller/manage/SystemInfoManageApi.ts +11 -6
- package/src/controller/manage/UserAccountManageApi.ts +10 -4
- package/src/controller/manage/WorkbenchMangeApi.ts +8 -8
- package/src/controller/myinfo/AuthController.ts +6 -72
- package/src/controller/render/AppRenderController.ts +24 -21
- package/src/controller/test.controller.ts +18 -18
- package/src/index.ts +38 -4
- package/src/libs/crud-pro/CrudPro.ts +7 -0
- package/src/libs/crud-pro/defaultConfigs.ts +2 -0
- package/src/libs/crud-pro/interfaces.ts +10 -3
- package/src/libs/crud-pro/models/ExecuteContext.ts +3 -3
- package/src/libs/crud-pro/models/ExecuteContextFunc.ts +11 -1
- package/src/libs/crud-pro/models/RequestCfgModel.ts +1 -1
- package/src/libs/crud-pro/models/RequestModel.ts +1 -1
- package/src/libs/crud-pro/models/ResModel.ts +19 -0
- package/src/libs/crud-pro/models/SqlCfgModel.ts +2 -2
- package/src/libs/crud-pro/models/Transaction.ts +8 -9
- package/src/libs/crud-pro/models/TransactionPostgres.ts +1 -1
- package/src/libs/crud-pro/models/TransactionSqlServer.ts +8 -13
- package/src/libs/crud-pro/services/CrudProCachedCfgService.ts +32 -23
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +38 -54
- package/src/libs/crud-pro/services/CrudProGenSqlCondition.ts +26 -45
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +23 -40
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +25 -29
- package/src/libs/crud-pro/services/CrudProServiceBase.ts +5 -9
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +36 -9
- package/src/libs/crud-pro/utils/DatabaseName.ts +35 -15
- package/src/libs/crud-pro/utils/DateTimeUtils.ts +2 -2
- package/src/libs/crud-pro/utils/MixinUtils.ts +1 -1
- package/src/libs/crud-pro/utils/ValidateUtils.ts +1 -3
- package/src/libs/crud-pro/utils/pool/MySQLUtils.ts +1 -1
- package/src/libs/crud-pro/utils/pool/PostgresUtils.ts +3 -3
- package/src/libs/crud-pro/utils/pool/SqlServerUtils.ts +3 -3
- package/src/libs/crud-pro/utils/sqlConvert/convertColumnName.ts +2 -2
- package/src/libs/crud-pro/utils/sqlConvert/convertMix.ts +26 -0
- package/src/libs/global-config/global-config.ts +78 -0
- package/src/libs/utils/crypto-utils.ts +2 -4
- package/src/libs/utils/errorToString.ts +61 -0
- package/src/libs/utils/fatcms-request.ts +9 -21
- package/src/libs/utils/ordernum-utils.ts +2 -6
- package/src/libs/utils/parseConfig.ts +7 -15
- package/src/middleware/forbidden.middleware.ts +6 -25
- package/src/middleware/global.middleware.ts +18 -16
- package/src/models/AsyncTaskModel.ts +79 -0
- package/src/models/RedisKeys.ts +13 -0
- package/src/models/SystemTables.ts +1 -4
- package/src/models/bizmodels.ts +1 -2
- package/src/schedule/anonymousContext.ts +79 -0
- package/src/schedule/index.ts +11 -72
- package/src/schedule/runSchedule.ts +83 -0
- package/src/schedule/scheduleNames.ts +21 -0
- package/src/service/AuthService.ts +13 -8
- package/src/service/EnumInfoService.ts +8 -3
- package/src/service/FileCenterService.ts +12 -6
- package/src/service/SysConfigService.ts +10 -6
- package/src/service/UserAccountService.ts +14 -4
- package/src/service/UserSessionService.ts +5 -4
- package/src/service/VisitStatService.ts +57 -70
- package/src/service/WorkbenchService.ts +7 -2
- package/src/service/anyapi/AnyApiService.ts +11 -8
- package/src/service/asyncTask/AsyncTaskRunnerService.ts +255 -0
- package/src/service/asyncTask/AsyncTaskService.ts +21 -0
- package/src/service/base/BaseService.ts +2 -2
- package/src/service/crudstd/CrudStdService.ts +60 -5
- package/src/service/curd/CrudProQuick.ts +137 -0
- package/src/service/curd/CurdMixByAccountService.ts +14 -6
- package/src/service/curd/CurdMixByDictService.ts +8 -2
- package/src/service/curd/CurdMixByLinkToCustomService.ts +101 -50
- package/src/service/curd/CurdMixBySysConfigService.ts +7 -2
- package/src/service/curd/CurdMixByWorkbenchService.ts +6 -2
- package/src/service/curd/CurdMixService.ts +3 -3
- package/src/service/curd/CurdMixUtils.ts +82 -39
- package/src/service/curd/CurdProService.ts +45 -189
- package/src/service/curd/fixCfgModel.ts +139 -0
- package/src/service/proxyapi/ProxyApiLoadService.ts +12 -3
- package/src/views/404_app.html +31 -0
- package/src/views/404_workbench.html +34 -0
- package/src/views/static/favicon.ico +0 -0
- package/tsconfig.json +32 -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
package/src/configuration.ts
CHANGED
|
@@ -13,10 +13,11 @@ import { join } from 'path';
|
|
|
13
13
|
// import { NotFoundFilter } from './filter/notfound.filter';
|
|
14
14
|
import { GlobalMiddleware } from './middleware/global.middleware';
|
|
15
15
|
import { ForbiddenMiddleware } from './middleware/forbidden.middleware';
|
|
16
|
-
import {
|
|
16
|
+
import { SCHEDULE_QUEUE , ANONYMOUS_CONTEXT, INNER_SCHEDULE_INTERVAL } from './schedule';
|
|
17
17
|
import { privateAES } from './libs/utils/crypto-utils';
|
|
18
18
|
|
|
19
19
|
@Configuration({
|
|
20
|
+
// namespace: 'fatcms',
|
|
20
21
|
imports: [
|
|
21
22
|
koa,
|
|
22
23
|
validate,
|
|
@@ -62,16 +63,16 @@ export class ContainerLifeCycle {
|
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
async onReady() {
|
|
65
|
-
const logger = this.app.getLogger();
|
|
66
|
-
const config = this.app.getConfig();
|
|
67
66
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
logger.info('ContainerLifeCycle ==> onReady 启动定时任务 ' );
|
|
73
|
-
}
|
|
67
|
+
/**
|
|
68
|
+
* 让ANONYMOUS_CONTEXT获取app对象
|
|
69
|
+
*/
|
|
70
|
+
ANONYMOUS_CONTEXT.setApp(this.app);
|
|
74
71
|
|
|
72
|
+
/**
|
|
73
|
+
* 启动定时任务
|
|
74
|
+
*/
|
|
75
|
+
await this.startScheduleOnReady();
|
|
75
76
|
|
|
76
77
|
// add middleware
|
|
77
78
|
this.app.useMiddleware(ForbiddenMiddleware);
|
|
@@ -80,4 +81,36 @@ export class ContainerLifeCycle {
|
|
|
80
81
|
// add filter
|
|
81
82
|
// this.app.useFilter([NotFoundFilter, DefaultErrorFilter]);
|
|
82
83
|
}
|
|
84
|
+
|
|
85
|
+
private async startScheduleOnReady() {
|
|
86
|
+
const logger = this.app.getLogger();
|
|
87
|
+
const config = this.app.getConfig();
|
|
88
|
+
const fatcmsScheduleService: boolean | any = config.fatcmsScheduleService;
|
|
89
|
+
|
|
90
|
+
// 关闭定时任务
|
|
91
|
+
if (fatcmsScheduleService === false || fatcmsScheduleService === null) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let scheduleIntervalCfg = INNER_SCHEDULE_INTERVAL;
|
|
96
|
+
if (typeof fatcmsScheduleService === "object") {
|
|
97
|
+
scheduleIntervalCfg = fatcmsScheduleService
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const keys = Object.keys(scheduleIntervalCfg);
|
|
101
|
+
for (let i = 0; i < keys.length; i++) {
|
|
102
|
+
const service = keys[i];
|
|
103
|
+
const interval = scheduleIntervalCfg[service];
|
|
104
|
+
if (typeof interval !== "number") {
|
|
105
|
+
throw new Error('Invalid scheduleIntervalCfg ' + service + ", interval must be a number");
|
|
106
|
+
}
|
|
107
|
+
SCHEDULE_QUEUE.setScheduleTask(service, interval);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
await SCHEDULE_QUEUE.startScheduleLoop();
|
|
111
|
+
logger.info('ContainerLifeCycle ==> onReady 启动定时任务 : ' + JSON.stringify(scheduleIntervalCfg));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
83
116
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Controller, Inject } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { CurdMixService } from '
|
|
4
|
-
import { IFuncCfgModel, IRequestCfgModel, IValidatorCfgItem } from '
|
|
5
|
-
import {KeyOfCrudTypes, KeysOfSimpleSQL} from '
|
|
6
|
-
import {
|
|
7
|
-
import { UserAccountService } from '
|
|
8
|
-
import { RelatedType } from '
|
|
9
|
-
import { BaseService } from '
|
|
3
|
+
import { CurdMixService } from '@/service/curd/CurdMixService';
|
|
4
|
+
import { IFuncCfgModel, IRequestCfgModel, IValidatorCfgItem } from '@/libs/crud-pro/interfaces';
|
|
5
|
+
import { KeyOfCrudTypes, KeysOfSimpleSQL } from '@/libs/crud-pro/models/keys';
|
|
6
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
7
|
+
import { UserAccountService } from '@/service/UserAccountService';
|
|
8
|
+
import { RelatedType } from '@/service/curd/CurdMixUtils';
|
|
9
|
+
import { BaseService } from '@/service/base/BaseService';
|
|
10
|
+
import * as moment from 'moment';
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
export interface IExecuteSimpleSqlParams {
|
|
12
14
|
updateCfg?: Record<string, IFuncCfgModel>;
|
|
@@ -27,7 +29,6 @@ export class BaseApiController extends BaseService {
|
|
|
27
29
|
@Inject()
|
|
28
30
|
protected userAccountService: UserAccountService;
|
|
29
31
|
|
|
30
|
-
|
|
31
32
|
protected getUserSessionInfo() {
|
|
32
33
|
if (!this.ctx.userSession) {
|
|
33
34
|
return null;
|
|
@@ -35,16 +36,15 @@ export class BaseApiController extends BaseService {
|
|
|
35
36
|
return this.ctx.userSession.getSessionInfo();
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
async executeSysSQL(executeSql:string, executeSqlArgs: any[]){
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
);
|
|
39
|
+
async executeSysSQL(executeSql: string, executeSqlArgs: any[]) {
|
|
40
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
41
|
+
return await this.curdMixService.executeSQL({
|
|
42
|
+
executeSql: executeSql,
|
|
43
|
+
executeSqlArgs: executeSqlArgs,
|
|
44
|
+
sqlDatabase: SystemDbName,
|
|
45
|
+
sqlDbType: SystemDbType,
|
|
46
|
+
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
47
|
+
});
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
@@ -55,6 +55,7 @@ export class BaseApiController extends BaseService {
|
|
|
55
55
|
* @protected
|
|
56
56
|
*/
|
|
57
57
|
protected async executeSysSimpleSQL(sqlTable: string, sqlSimpleName: KeysOfSimpleSQL, params?: IExecuteSimpleSqlParams) {
|
|
58
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
58
59
|
const body = this.ctx.request.body as any;
|
|
59
60
|
const req = this.ctx.req;
|
|
60
61
|
const cfgModel: IRequestCfgModel = {
|
|
@@ -62,7 +63,7 @@ export class BaseApiController extends BaseService {
|
|
|
62
63
|
sqlTable,
|
|
63
64
|
sqlSimpleName,
|
|
64
65
|
sqlDatabase: SystemDbName,
|
|
65
|
-
|
|
66
|
+
sqlDbType: SystemDbType,
|
|
66
67
|
updateCfg: {},
|
|
67
68
|
};
|
|
68
69
|
|
|
@@ -76,10 +77,16 @@ export class BaseApiController extends BaseService {
|
|
|
76
77
|
//自动关联工作台基本信息
|
|
77
78
|
this.addWorkbenchBasicInfoCfgModel(cfgModel);
|
|
78
79
|
|
|
80
|
+
//sys系统表都是标准的,都有modified_at字段。
|
|
81
|
+
if(sqlSimpleName === KeysOfSimpleSQL.SIMPLE_UPDATE && body.data) {
|
|
82
|
+
body.data['modified_at'] = moment(Date.now()).format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
83
|
+
}
|
|
84
|
+
|
|
79
85
|
return await this.curdMixService.executeCrudByCfg(body, cfgModel);
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
protected get sysDBUtil() {
|
|
89
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
83
90
|
return this.curdMixService.getBbUtil(SystemDbName, SystemDbType);
|
|
84
91
|
}
|
|
85
92
|
|
|
@@ -2,7 +2,7 @@ import { All, Controller, Inject, Param } from '@midwayjs/core';
|
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import { BaseApiController } from '../base/BaseApiController';
|
|
4
4
|
import * as _ from 'lodash';
|
|
5
|
-
import { AnyApiService } from '
|
|
5
|
+
import { AnyApiService } from '@/service/anyapi/AnyApiService';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* FaaS方式配置的接口
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Controller, Inject, Post, Query } from '@midwayjs/core';
|
|
2
|
+
|
|
3
|
+
import { Context } from '@midwayjs/koa';
|
|
4
|
+
import { BaseApiController } from '../base/BaseApiController';
|
|
5
|
+
import { AsyncTaskService } from '@/service/asyncTask/AsyncTaskService';
|
|
6
|
+
import { SysAsyncTaskEntity, SysAsyncTaskStatus } from '@/models/AsyncTaskModel';
|
|
7
|
+
import { KeysOfSimpleSQL } from '@/libs/crud-pro/models/keys';
|
|
8
|
+
import { SystemTables } from '@/models/SystemTables';
|
|
9
|
+
import { CommonException } from '@/libs/crud-pro/exceptions';
|
|
10
|
+
import { checkLogin } from '@/middleware/permission.middleware';
|
|
11
|
+
|
|
12
|
+
function fixMyTasksCondition(body: any, ctx: Context) {
|
|
13
|
+
if (!body.condition) {
|
|
14
|
+
throw new CommonException('参数不正确');
|
|
15
|
+
}
|
|
16
|
+
body.condition.created_by = ctx.userSession.getSessionInfo().accountId;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function fixCancelBodyData(body: any, id: number) {
|
|
20
|
+
if (!body.data || !body.condition) {
|
|
21
|
+
throw new CommonException('参数不正确');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// fix condition
|
|
25
|
+
const conditionObj: SysAsyncTaskEntity = (body.condition || {}) as any;
|
|
26
|
+
conditionObj.id = id;
|
|
27
|
+
body.condition = conditionObj;
|
|
28
|
+
|
|
29
|
+
// fix data
|
|
30
|
+
const dataObj: SysAsyncTaskEntity = (body.data || {}) as any;
|
|
31
|
+
dataObj.task_status = SysAsyncTaskStatus.CANCELLED;
|
|
32
|
+
body.data = dataObj;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function fixCreateBodyData(body: any, ctx: Context) {
|
|
36
|
+
if (!body.data) {
|
|
37
|
+
throw new CommonException('参数不正确');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const sessionInfo = ctx.userSession.getSessionInfo();
|
|
41
|
+
// fix data
|
|
42
|
+
const dataObj: SysAsyncTaskEntity = (body.data || {}) as any;
|
|
43
|
+
dataObj.task_status = SysAsyncTaskStatus.PENDING;
|
|
44
|
+
dataObj.created_by = sessionInfo.accountId;
|
|
45
|
+
dataObj.created_user_session = JSON.stringify(sessionInfo); // 创建人的session信息。用于执行时的鉴权。
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 异步任务框架
|
|
50
|
+
*/
|
|
51
|
+
@Controller('/ns/gw/AsyncTask', { middleware: [checkLogin()] })
|
|
52
|
+
export class AsyncTaskController extends BaseApiController {
|
|
53
|
+
@Inject()
|
|
54
|
+
protected ctx: Context;
|
|
55
|
+
|
|
56
|
+
@Inject()
|
|
57
|
+
private asyncTaskService: AsyncTaskService;
|
|
58
|
+
|
|
59
|
+
// 获取任务列表
|
|
60
|
+
@Post('/getMyTasks')
|
|
61
|
+
async getMyTasks() {
|
|
62
|
+
fixMyTasksCondition(this.ctx.request.body, this.ctx);
|
|
63
|
+
return this.executeSysSimpleSQL(SystemTables.sys_async_tasks, KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 创建任务
|
|
67
|
+
@Post('/createTask')
|
|
68
|
+
async createTask() {
|
|
69
|
+
fixCreateBodyData(this.ctx.request.body, this.ctx);
|
|
70
|
+
const res = await this.executeSysSimpleSQL(SystemTables.sys_async_tasks, KeysOfSimpleSQL.SIMPLE_INSERT);
|
|
71
|
+
await this.asyncTaskService.startTask();
|
|
72
|
+
return res;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 取消任务
|
|
76
|
+
@Post('/cancelTask')
|
|
77
|
+
async cancelTask(@Query('id') id: number) {
|
|
78
|
+
fixCancelBodyData(this.ctx.request.body, id);
|
|
79
|
+
await this.asyncTaskService.cancelTask(id);
|
|
80
|
+
await this.executeSysSimpleSQL(SystemTables.sys_async_tasks, KeysOfSimpleSQL.SIMPLE_UPDATE);
|
|
81
|
+
return { success: true };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -2,13 +2,14 @@ import * as _ from 'lodash';
|
|
|
2
2
|
import { decamelizeKeys } from 'humps';
|
|
3
3
|
import { Controller, Inject, Param, All } from '@midwayjs/core';
|
|
4
4
|
import { Context } from '@midwayjs/koa';
|
|
5
|
-
import { CommonResult } from '
|
|
6
|
-
import { WorkbenchService } from '
|
|
7
|
-
import { API_BASE_TYPE, ApiBaseService } from '
|
|
8
|
-
import { CurdProService } from '
|
|
9
|
-
import { CurdMixService } from '
|
|
10
|
-
import { IRequestCfgModel2 } from '
|
|
11
|
-
import {parseDatabaseName} from
|
|
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
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
12
13
|
|
|
13
14
|
const QUERY_AS_LIST = ['condition', 'data'];
|
|
14
15
|
|
|
@@ -20,11 +21,11 @@ function pickAsQuery(query_as_pick: string, query: any): any {
|
|
|
20
21
|
return query;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
// /ns/gw/
|
|
24
|
+
// /ns/gw/crudApi/getUser?__query_as_condition__=id&_query_as_data__=name&&id=1&name=22
|
|
24
25
|
/**
|
|
25
|
-
* query形式1:GET: /ns/gw/
|
|
26
|
-
* query形式2:GET: /ns/gw/
|
|
27
|
-
* query形式3:GET: /ns/gw/
|
|
26
|
+
* query形式1:GET: /ns/gw/crudApi/getUser?__query_json__=%7B%22condition%22%3A%7B%22id%22%3A2%7D%7D
|
|
27
|
+
* query形式2:GET: /ns/gw/crudApi/getUser?__query_as__=condition&id=1&name=22
|
|
28
|
+
* query形式3:GET: /ns/gw/crudApi/createUser?__query_as__=data&__query_pick__=id,name&id=1&name=22
|
|
28
29
|
*
|
|
29
30
|
* 执行单个配置的接口
|
|
30
31
|
*/
|
|
@@ -56,7 +57,7 @@ export class CrudMtdGatewayController extends ApiBaseService {
|
|
|
56
57
|
return CommonResult.errorRes('接口不存在或已下线: ' + methodCode);
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
this.logInfo(
|
|
60
|
+
this.logInfo('methodInfo=== ', methodInfo);
|
|
60
61
|
|
|
61
62
|
const workbench_code_array = methodInfo.workbench_code_array || methodInfo.workbenchCodeArray;
|
|
62
63
|
const isSupport = await this.workbenchService.isSupportCurrentWorkbench(workbench_code_array);
|
|
@@ -100,7 +101,10 @@ export class CrudMtdGatewayController extends ApiBaseService {
|
|
|
100
101
|
const cfgModel = methodInfo as IRequestCfgModel2;
|
|
101
102
|
const { dbType, dbName } = parseDatabaseName(cfgModel.sqlDatabase);
|
|
102
103
|
cfgModel.sqlDatabase = dbName;
|
|
103
|
-
cfgModel.
|
|
104
|
+
cfgModel.sqlDbType = dbType;
|
|
105
|
+
|
|
106
|
+
// 业务系统自定义的修改cfgModel
|
|
107
|
+
await GLOBAL_STATIC_CONFIG.getConfig().bizUpdateCfgModelForCrudMtd(reqJson, cfgModel, methodInfo, this.ctx);
|
|
104
108
|
|
|
105
109
|
return this.curdMixService.executeCrudByCfg(reqJson, cfgModel);
|
|
106
110
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Controller, Inject, Post } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
-
import { CrudStdService, SPECIAL_SETTING_KEY } from '
|
|
5
|
-
import { KeysOfSimpleSQL } from '
|
|
6
|
-
import { IRequestModel } from '
|
|
7
|
-
import { CommonResult } from '
|
|
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
8
|
|
|
9
9
|
interface ICrudStdActionParams {
|
|
10
10
|
appCode: string;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {Get, Controller, Inject, Query} from '@midwayjs/core';
|
|
2
|
-
import {Context} from '@midwayjs/koa';
|
|
3
|
-
import {BaseApiController} from '../base/BaseApiController';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { Get, Controller, Inject, Query } from '@midwayjs/core';
|
|
2
|
+
import { Context } from '@midwayjs/koa';
|
|
3
|
+
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
+
import { SystemTables } from '@/models/SystemTables';
|
|
5
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
6
|
+
import { KeysOfSimpleSQL } from '@/libs/crud-pro/models/keys';
|
|
7
|
+
import { WorkbenchService } from '@/service/WorkbenchService';
|
|
8
|
+
import { CommonResult } from '@/libs/utils/common-dto';
|
|
8
9
|
|
|
9
10
|
function checkIsNumber(value: string, name: string) {
|
|
10
11
|
if (!value) {
|
|
@@ -27,19 +28,21 @@ export class DocGatewayController extends BaseApiController {
|
|
|
27
28
|
@Inject()
|
|
28
29
|
protected workbenchService: WorkbenchService;
|
|
29
30
|
|
|
30
|
-
|
|
31
31
|
private async updateDocPV(docId: string, docLibId: string, pv: number) {
|
|
32
32
|
const ip = this.ctx.headers['x-real-ip'];
|
|
33
33
|
const lockKey = `doc_ip_pv_${docId}_${ip}`;
|
|
34
34
|
const EXPIRE_TIME = 5 * 60 * 1000; // 在五分钟内,同一个IP地址重复刷新同一篇文章,认为是一个PV
|
|
35
|
-
const nxRes = await this.redisService.set(lockKey, 1, 'EX', EXPIRE_TIME, 'NX')
|
|
35
|
+
const nxRes = await this.redisService.set(lockKey, 1, 'EX', EXPIRE_TIME, 'NX');
|
|
36
36
|
if (nxRes !== 'OK') {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
41
|
+
|
|
42
|
+
await this.curdMixService.executeCrudByCfg(
|
|
43
|
+
{
|
|
41
44
|
data: {
|
|
42
|
-
pv: pv + 1
|
|
45
|
+
pv: pv + 1,
|
|
43
46
|
},
|
|
44
47
|
condition: {
|
|
45
48
|
id: parseInt(docId),
|
|
@@ -50,11 +53,11 @@ export class DocGatewayController extends BaseApiController {
|
|
|
50
53
|
sqlTable: SystemTables.sys_doc,
|
|
51
54
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
52
55
|
sqlDatabase: SystemDbName,
|
|
53
|
-
|
|
54
|
-
}
|
|
56
|
+
sqlDbType: SystemDbType,
|
|
57
|
+
}
|
|
58
|
+
);
|
|
55
59
|
}
|
|
56
60
|
|
|
57
|
-
|
|
58
61
|
/**
|
|
59
62
|
* @param docId
|
|
60
63
|
* @param docLibId 文档库
|
|
@@ -69,6 +72,7 @@ export class DocGatewayController extends BaseApiController {
|
|
|
69
72
|
return docLibInfoRes;
|
|
70
73
|
}
|
|
71
74
|
|
|
75
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
72
76
|
|
|
73
77
|
const res = await this.curdMixService.executeCrudByCfg(
|
|
74
78
|
{
|
|
@@ -81,7 +85,7 @@ export class DocGatewayController extends BaseApiController {
|
|
|
81
85
|
sqlTable: SystemTables.sys_doc,
|
|
82
86
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
83
87
|
sqlDatabase: SystemDbName,
|
|
84
|
-
|
|
88
|
+
sqlDbType: SystemDbType,
|
|
85
89
|
}
|
|
86
90
|
);
|
|
87
91
|
|
|
@@ -107,6 +111,8 @@ export class DocGatewayController extends BaseApiController {
|
|
|
107
111
|
return docLibInfoRes;
|
|
108
112
|
}
|
|
109
113
|
|
|
114
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
115
|
+
|
|
110
116
|
return this.curdMixService.executeCrudByCfg(
|
|
111
117
|
{
|
|
112
118
|
columns: 'id,title,doc_category_code,sort_index',
|
|
@@ -122,7 +128,7 @@ export class DocGatewayController extends BaseApiController {
|
|
|
122
128
|
sqlTable: SystemTables.sys_doc,
|
|
123
129
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
124
130
|
sqlDatabase: SystemDbName,
|
|
125
|
-
|
|
131
|
+
sqlDbType: SystemDbType,
|
|
126
132
|
}
|
|
127
133
|
);
|
|
128
134
|
}
|
|
@@ -135,6 +141,8 @@ export class DocGatewayController extends BaseApiController {
|
|
|
135
141
|
async getDocLibInfo(@Query('docLibId') docLibId: string) {
|
|
136
142
|
checkIsNumber(docLibId, 'docLibId');
|
|
137
143
|
|
|
144
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
145
|
+
|
|
138
146
|
const s = await this.curdMixService.executeCrudByCfg(
|
|
139
147
|
{
|
|
140
148
|
condition: {
|
|
@@ -145,7 +153,7 @@ export class DocGatewayController extends BaseApiController {
|
|
|
145
153
|
sqlTable: SystemTables.sys_doc_lib,
|
|
146
154
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
147
155
|
sqlDatabase: SystemDbName,
|
|
148
|
-
|
|
156
|
+
sqlDbType: SystemDbType,
|
|
149
157
|
}
|
|
150
158
|
);
|
|
151
159
|
const docLibInfo = s.getOneObj();
|
|
@@ -2,18 +2,17 @@ import { Get, Post, Inject, Controller, Files, Fields, Param, Query } from '@mid
|
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import * as _ from 'lodash';
|
|
4
4
|
import { BaseApiController } from '../base/BaseApiController';
|
|
5
|
-
import { BizException } from '
|
|
6
|
-
import {AccessType, FILE_GET_TYPES} from '
|
|
7
|
-
import { FileCenterService, PATH_PREFIX, toDownloadPaths, isImageFile } from '
|
|
8
|
-
import { checkPermission } from '
|
|
9
|
-
import { CommonResult } from '
|
|
10
|
-
import {SystemFuncCode} from
|
|
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
11
|
|
|
12
12
|
function isTrue(obj: any) {
|
|
13
13
|
return obj === true || obj === 'true';
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
/**
|
|
18
17
|
* 文件上传下载服务
|
|
19
18
|
*/
|
|
@@ -31,7 +30,7 @@ export class FileController extends BaseApiController {
|
|
|
31
30
|
* @param fields
|
|
32
31
|
* @param queryData
|
|
33
32
|
*/
|
|
34
|
-
@Post('/uploadFile',
|
|
33
|
+
@Post('/uploadFile', { middleware: [checkPermission([SystemFuncCode.DocMangeWrite, SystemFuncCode.FileMangeWrite, SystemFuncCode.UserAccountMangeWrite])] })
|
|
35
34
|
async uploadFile(@Files() files, @Fields() fields, @Query() queryData): Promise<CommonResult> {
|
|
36
35
|
const accessType = queryData?.accessType || fields?.accessType || AccessType.open;
|
|
37
36
|
const referer = this.ctx.req.headers.referer;
|
|
@@ -64,7 +63,7 @@ export class FileController extends BaseApiController {
|
|
|
64
63
|
* @param streaming 是否直接返回流,默认返回 302 跳转
|
|
65
64
|
*/
|
|
66
65
|
@Get('/get/:byMethod/:fileKey*')
|
|
67
|
-
async downloadFile(@Param('byMethod') byMethod: string
|
|
66
|
+
async downloadFile(@Param('byMethod') byMethod: string, @Param('fileKey') fileKey: string) {
|
|
68
67
|
if (!fileKey) {
|
|
69
68
|
throw new BizException('fileKey不能为空');
|
|
70
69
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { All, Controller, Inject, Query } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
-
import { ProxyApiService } from '
|
|
5
|
-
import { WorkbenchService } from '
|
|
6
|
-
import { CommonResult } from '
|
|
7
|
-
import { ProxyApiLoadService } from '
|
|
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
8
|
|
|
9
9
|
/**
|
|
10
10
|
* 只支持前缀匹配
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {Controller, Get, Inject, Post} from '@midwayjs/core';
|
|
2
|
-
import {Context} from '@midwayjs/koa';
|
|
1
|
+
import { Controller, Get, Inject, Post } from '@midwayjs/core';
|
|
2
|
+
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import * as _ from 'lodash';
|
|
4
|
-
import {BaseApiController} from '../base/BaseApiController';
|
|
5
|
-
import {SystemTables} from '
|
|
6
|
-
import {EnumInfoService} from '
|
|
7
|
-
import {CommonResult} from '
|
|
8
|
-
import {parseJsonObject} from '
|
|
9
|
-
import {WorkbenchService} from '
|
|
10
|
-
import {SystemRoleCode} from
|
|
11
|
-
import {KeysOfAuthType} from
|
|
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
12
|
|
|
13
13
|
/**
|
|
14
14
|
* 公开的API,无需鉴权,所有人可以直接访问
|
|
@@ -52,12 +52,12 @@ export class PublicApiController extends BaseApiController {
|
|
|
52
52
|
return CommonResult.errorRes('param workbenchMenuCode is null');
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const workbenchMenuCodeStr =
|
|
56
|
-
const workbenchMenuCodeArray =
|
|
55
|
+
const workbenchMenuCodeStr = '' + workbenchMenuCode;
|
|
56
|
+
const workbenchMenuCodeArray = workbenchMenuCodeStr.split(',');
|
|
57
57
|
|
|
58
58
|
const condition = {
|
|
59
59
|
menu_code: {
|
|
60
|
-
|
|
60
|
+
$in: workbenchMenuCodeArray,
|
|
61
61
|
},
|
|
62
62
|
};
|
|
63
63
|
const rows = await this.sysDBUtil.getList({ condition }, SystemTables.sys_menus);
|
|
@@ -72,22 +72,19 @@ export class PublicApiController extends BaseApiController {
|
|
|
72
72
|
const view_auth_config = rowElement.view_auth_config;
|
|
73
73
|
const view_auth_type = rowElement.view_auth_type;
|
|
74
74
|
|
|
75
|
-
const hasPermission
|
|
75
|
+
const hasPermission = this.ctx.userSession.isAuthPass(view_auth_type, view_auth_config);
|
|
76
76
|
|
|
77
77
|
const menu_config_content = rowElement.menu_config_content;
|
|
78
78
|
delete rowElement.menu_config_content;
|
|
79
79
|
const menu_list = parseJsonObject(menu_config_content) || [];
|
|
80
|
-
map[menu_code] = { ...rowElement, menu_list, hasPermission }
|
|
80
|
+
map[menu_code] = { ...rowElement, menu_list, hasPermission };
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
84
83
|
// 特殊的devops菜单
|
|
85
84
|
map['devops'] = {
|
|
86
85
|
menu_list: [], // 这个特殊的菜单在前端写死。
|
|
87
|
-
hasPermission: this.ctx.userSession.isAuthPass(KeysOfAuthType.byRoleCode, [
|
|
88
|
-
|
|
89
|
-
])
|
|
90
|
-
}
|
|
86
|
+
hasPermission: this.ctx.userSession.isAuthPass(KeysOfAuthType.byRoleCode, [SystemRoleCode.DevOpsWriter, SystemRoleCode.DevOpsViewer, SystemRoleCode.SuperAdmin]),
|
|
87
|
+
};
|
|
91
88
|
|
|
92
89
|
return CommonResult.successRes(map);
|
|
93
90
|
}
|
|
@@ -108,7 +105,7 @@ export class PublicApiController extends BaseApiController {
|
|
|
108
105
|
if (oneData && oneData['app_schema']) {
|
|
109
106
|
oneData['app_schema'] = parseJsonObject(oneData['app_schema']);
|
|
110
107
|
}
|
|
111
|
-
resultData[key] = oneData
|
|
108
|
+
resultData[key] = oneData;
|
|
112
109
|
}
|
|
113
110
|
};
|
|
114
111
|
|
|
@@ -126,7 +123,7 @@ export class PublicApiController extends BaseApiController {
|
|
|
126
123
|
const body = this.ctx.request.body as any;
|
|
127
124
|
const query = this.ctx.query || {};
|
|
128
125
|
let codeList = _.get(body, 'codeList');
|
|
129
|
-
|
|
126
|
+
const refreshCache = `${_.get(body, 'refreshCache')}` === 'true' || query.refreshCache === 'true';
|
|
130
127
|
|
|
131
128
|
if (query.codeList) {
|
|
132
129
|
//codeList=dict@@SexEnum,sysCfgEnum@@EntityStatusEnum
|