midway-fatcms 0.0.1-beta.17 → 0.0.1-beta.19
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 +3 -1
- package/dist/configuration.js +18 -7
- package/dist/controller/gateway/AsyncTaskController.js +3 -3
- package/dist/controller/gateway/DocGatewayController.js +1 -1
- package/dist/controller/gateway/PublicApiController.js +4 -6
- package/dist/controller/gateway/StaticController.js +25 -22
- package/dist/controller/helpers.controller.d.ts +1 -1
- package/dist/controller/manage/CrudStandardDesignApi.d.ts +1 -1
- package/dist/controller/manage/CrudStandardDesignApi.js +4 -16
- package/dist/controller/manage/DataDictManageApi.d.ts +1 -1
- package/dist/controller/manage/DeployManageApi.d.ts +1 -1
- package/dist/controller/manage/DeployManageApi.js +32 -30
- package/dist/controller/manage/MenuManageApi.js +1 -1
- package/dist/controller/manage/SuperAdminManageApi.d.ts +2 -2
- package/dist/controller/manage/SysConfigMangeApi.d.ts +1 -1
- package/dist/controller/manage/SysConfigMangeApi.js +3 -3
- 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/WorkbenchMangeApi.js +1 -1
- package/dist/controller/myinfo/AuthController.js +1 -1
- package/dist/controller/render/AppRenderController.js +6 -2
- package/dist/controller/test.controller.d.ts +1 -1
- package/dist/controller/test.controller.js +4 -4
- package/dist/libs/crud-pro/models/ExecuteContext.d.ts +1 -1
- package/dist/libs/crud-pro/models/TransactionSqlServer.js +1 -1
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.js +1 -1
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +7 -6
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.d.ts +1 -1
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +2 -4
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +6 -15
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +5 -4
- package/dist/libs/crud-pro/services/CrudProTableMetaService.js +2 -2
- package/dist/libs/crud-pro/utils/MixinUtils.js +1 -1
- package/dist/libs/crud-pro/utils/ValidateUtils.js +1 -1
- package/dist/libs/utils/fatcms-request.js +2 -2
- package/dist/middleware/forbidden.middleware.js +4 -20
- package/dist/middleware/global.middleware.js +1 -4
- package/dist/models/AsyncTaskModel.d.ts +2 -1
- package/dist/models/RedisKeys.d.ts +8 -0
- package/dist/models/RedisKeys.js +11 -0
- package/dist/schedule/index.d.ts +3 -3
- package/dist/schedule/index.js +3 -4
- package/dist/schedule/runSchedule.d.ts +11 -2
- package/dist/schedule/runSchedule.js +49 -15
- package/dist/schedule/scheduleNames.d.ts +8 -3
- package/dist/schedule/scheduleNames.js +12 -12
- package/dist/service/UserSessionService.js +2 -1
- package/dist/service/VisitStatService.d.ts +1 -1
- package/dist/service/VisitStatService.js +16 -25
- package/dist/service/asyncTask/AsyncTaskRunnerService.d.ts +9 -3
- package/dist/service/asyncTask/AsyncTaskRunnerService.js +57 -21
- package/dist/service/asyncTask/AsyncTaskService.d.ts +1 -1
- package/dist/service/asyncTask/AsyncTaskService.js +4 -3
- package/package.json +1 -1
- package/src/configuration.ts +23 -11
- package/src/controller/base/BaseApiController.ts +6 -6
- package/src/controller/gateway/AsyncTaskController.ts +17 -22
- package/src/controller/gateway/CrudMtdGatewayController.ts +7 -7
- package/src/controller/gateway/CrudStdGatewayController.ts +4 -4
- package/src/controller/gateway/DocGatewayController.ts +17 -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 -264
- package/src/controller/helpers.controller.ts +1 -1
- package/src/controller/home.controller.ts +0 -5
- package/src/controller/manage/AnyApiMangeApi.ts +4 -4
- package/src/controller/manage/AppLogMangeApi.ts +3 -3
- package/src/controller/manage/AppMangeApi.ts +5 -5
- package/src/controller/manage/AppPageMangeApi.ts +3 -3
- package/src/controller/manage/AppSchemaHistoryApi.ts +1 -1
- package/src/controller/manage/CrudMethodsMangeApi.ts +3 -3
- package/src/controller/manage/CrudStandardDesignApi.ts +25 -77
- package/src/controller/manage/DataDictManageApi.ts +4 -4
- package/src/controller/manage/DeployManageApi.ts +84 -91
- package/src/controller/manage/DocLibManageApi.ts +3 -3
- package/src/controller/manage/DocManageApi.ts +3 -3
- package/src/controller/manage/MenuManageApi.ts +9 -14
- package/src/controller/manage/SuperAdminManageApi.ts +2 -10
- package/src/controller/manage/SysConfigMangeApi.ts +8 -11
- package/src/controller/manage/SystemInfoManageApi.ts +11 -6
- package/src/controller/manage/UserAccountManageApi.ts +2 -2
- package/src/controller/manage/WorkbenchMangeApi.ts +6 -6
- package/src/controller/myinfo/AuthController.ts +4 -8
- package/src/controller/render/AppRenderController.ts +8 -8
- package/src/controller/test.controller.ts +17 -17
- package/src/index.ts +0 -1
- package/src/libs/crud-pro/CrudPro.ts +0 -1
- package/src/libs/crud-pro/interfaces.ts +1 -3
- package/src/libs/crud-pro/models/ExecuteContext.ts +1 -4
- package/src/libs/crud-pro/models/ExecuteContextFunc.ts +1 -2
- package/src/libs/crud-pro/models/RequestModel.ts +1 -1
- package/src/libs/crud-pro/models/ResModel.ts +7 -12
- package/src/libs/crud-pro/models/SqlCfgModel.ts +1 -1
- 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 +1 -3
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +36 -48
- package/src/libs/crud-pro/services/CrudProGenSqlCondition.ts +19 -38
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +15 -32
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +23 -27
- package/src/libs/crud-pro/services/CrudProServiceBase.ts +1 -2
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +6 -14
- 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/global-config/global-config.ts +0 -5
- package/src/libs/utils/crypto-utils.ts +2 -4
- package/src/libs/utils/errorToString.ts +3 -8
- 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 +10 -21
- package/src/models/AsyncTaskModel.ts +3 -2
- package/src/models/RedisKeys.ts +13 -0
- package/src/models/bizmodels.ts +1 -2
- package/src/schedule/index.ts +4 -6
- package/src/schedule/runSchedule.ts +65 -17
- package/src/schedule/scheduleNames.ts +12 -11
- package/src/service/UserSessionService.ts +5 -4
- package/src/service/VisitStatService.ts +55 -72
- package/src/service/anyapi/AnyApiService.ts +7 -7
- package/src/service/asyncTask/AsyncTaskRunnerService.ts +118 -87
- package/src/service/asyncTask/AsyncTaskService.ts +10 -10
- package/src/service/proxyapi/ProxyApiLoadService.ts +4 -3
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Controller, Inject, Post, Get } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { VisitStatService } from
|
|
3
|
+
import { VisitStatService } from '../../service/VisitStatService';
|
|
4
4
|
import { KeysOfSimpleSQL } from '../../libs/crud-pro/models/keys';
|
|
5
5
|
import { BaseApiController } from '../base/BaseApiController';
|
|
6
6
|
import { checkRole } from '../../middleware/permission.middleware';
|
|
7
7
|
import { SystemFuncCodeNameMap, SystemRoleCode, SystemRoleCodeNameMap } from '../../models/SystemPerm';
|
|
8
8
|
import { SystemTables } from '../../models/SystemTables';
|
|
9
|
-
import { CommonResult } from
|
|
9
|
+
import { CommonResult } from '../../libs/utils/common-dto';
|
|
10
10
|
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
11
11
|
|
|
12
12
|
@Controller('/ns/api/manage/superAdmin', { middleware: [checkRole(SystemRoleCode.SuperAdmin)] })
|
|
@@ -17,7 +17,6 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
17
17
|
@Inject()
|
|
18
18
|
protected visitStatService: VisitStatService;
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
/**
|
|
22
21
|
* 预设系统内置功能点数据
|
|
23
22
|
*/
|
|
@@ -46,7 +45,6 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
46
45
|
);
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
|
|
50
48
|
return CommonResult.successRes();
|
|
51
49
|
}
|
|
52
50
|
|
|
@@ -55,7 +53,6 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
55
53
|
*/
|
|
56
54
|
@Post('/presetsRoleCode')
|
|
57
55
|
async presetsRoleCode() {
|
|
58
|
-
|
|
59
56
|
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
60
57
|
|
|
61
58
|
const roleCodeList = [SystemRoleCode.DevOpsViewer, SystemRoleCode.DevOpsWriter];
|
|
@@ -88,7 +85,6 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
88
85
|
*/
|
|
89
86
|
@Post('/presetsRoleFuncList')
|
|
90
87
|
async presetsRoleFuncList() {
|
|
91
|
-
|
|
92
88
|
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
93
89
|
|
|
94
90
|
const funcCodeList = Object.keys(SystemFuncCodeNameMap);
|
|
@@ -133,7 +129,6 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
133
129
|
return CommonResult.successRes();
|
|
134
130
|
}
|
|
135
131
|
|
|
136
|
-
|
|
137
132
|
/**
|
|
138
133
|
* 将每天的访问数据,更新到数据库中
|
|
139
134
|
*/
|
|
@@ -141,7 +136,4 @@ export class SuperAdminManageApi extends BaseApiController {
|
|
|
141
136
|
async flushVisitStatToDB() {
|
|
142
137
|
return this.visitStatService.flushVisitStatToDB();
|
|
143
138
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
139
|
}
|
|
@@ -5,8 +5,8 @@ import { BaseApiController } from '../base/BaseApiController';
|
|
|
5
5
|
import { checkPermission } from '../../middleware/permission.middleware';
|
|
6
6
|
import { SystemFuncCode } from '../../models/SystemPerm';
|
|
7
7
|
import { CTX_WORKBENCH_CODE } from '../../models/bizmodels';
|
|
8
|
-
import {SystemTables} from
|
|
9
|
-
import {CommonResult} from
|
|
8
|
+
import { SystemTables } from '../../models/SystemTables';
|
|
9
|
+
import { CommonResult } from '../../libs/utils/common-dto';
|
|
10
10
|
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
11
11
|
|
|
12
12
|
@Controller('/ns/api/manage/sysconfig', { middleware: [checkPermission(SystemFuncCode.SysConfigMangeRead)] })
|
|
@@ -49,30 +49,27 @@ export class SysConfigMangeApi extends BaseApiController {
|
|
|
49
49
|
|
|
50
50
|
@Post('/updateSysConfig', { middleware: [checkPermission(SystemFuncCode.SysConfigMangeWrite)] })
|
|
51
51
|
async updateSysConfig() {
|
|
52
|
-
|
|
53
|
-
const {SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
52
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
54
53
|
|
|
55
54
|
const body = this.ctx.request.body as any;
|
|
56
55
|
const id = body.condition.id;
|
|
57
56
|
if (!id) {
|
|
58
|
-
return CommonResult.errorRes(
|
|
57
|
+
return CommonResult.errorRes('id不能为空');
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
const sysConfig = await this.curdMixService.getBbUtil(SystemDbName, SystemDbType).getOne({condition: body.condition}, SystemTables.sys_configs)
|
|
60
|
+
const sysConfig = await this.curdMixService.getBbUtil(SystemDbName, SystemDbType).getOne({ condition: body.condition }, SystemTables.sys_configs);
|
|
62
61
|
if (!sysConfig) {
|
|
63
|
-
return CommonResult.errorRes(
|
|
62
|
+
return CommonResult.errorRes('配置项不存在');
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
const {edit_auth_type, edit_auth_config} = sysConfig;
|
|
65
|
+
const { edit_auth_type, edit_auth_config } = sysConfig;
|
|
67
66
|
if (edit_auth_type) {
|
|
68
67
|
const isOK = this.ctx.userSession.isAuthPass(edit_auth_type, edit_auth_config);
|
|
69
68
|
if (!isOK) {
|
|
70
|
-
return CommonResult.errorRes(
|
|
69
|
+
return CommonResult.errorRes('编辑权限校验不通过:' + JSON.stringify({ edit_auth_type, edit_auth_config }));
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
72
|
|
|
74
|
-
|
|
75
|
-
|
|
76
73
|
return this.executeSysSimpleSQL('sys_configs', KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
77
74
|
validateCfg: {
|
|
78
75
|
'data.workbench_code': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING, 'length:1,64'],
|
|
@@ -2,9 +2,9 @@ import { Controller, Inject, Get } from '@midwayjs/core';
|
|
|
2
2
|
import { InfoService } from '@midwayjs/info';
|
|
3
3
|
import { Context } from '@midwayjs/koa';
|
|
4
4
|
import { BaseApiController } from '../base/BaseApiController';
|
|
5
|
-
import {checkPermission} from '../../middleware/permission.middleware';
|
|
6
|
-
import {SystemFuncCode} from '../../models/SystemPerm';
|
|
7
|
-
import {CommonResult} from
|
|
5
|
+
import { checkPermission } from '../../middleware/permission.middleware';
|
|
6
|
+
import { SystemFuncCode } from '../../models/SystemPerm';
|
|
7
|
+
import { CommonResult } from '../../libs/utils/common-dto';
|
|
8
8
|
|
|
9
9
|
@Controller('/ns/api/manage/systemInfo', { middleware: [checkPermission(SystemFuncCode.SystemInfoManageApiRead)] })
|
|
10
10
|
export class SystemInfoManageApi extends BaseApiController {
|
|
@@ -41,8 +41,13 @@ export class SystemInfoManageApi extends BaseApiController {
|
|
|
41
41
|
const networkInfo = this.infoService.networkInfo();
|
|
42
42
|
|
|
43
43
|
return CommonResult.successRes({
|
|
44
|
-
projectInfo,
|
|
45
|
-
|
|
44
|
+
projectInfo,
|
|
45
|
+
systemInfo,
|
|
46
|
+
resourceOccupationInfo,
|
|
47
|
+
softwareInfo,
|
|
48
|
+
timeInfo,
|
|
49
|
+
envInfo,
|
|
50
|
+
networkInfo,
|
|
51
|
+
});
|
|
46
52
|
}
|
|
47
|
-
|
|
48
53
|
}
|
|
@@ -19,12 +19,12 @@ function checkAccountCreateBlacklist(value: string) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const LOGIN_NAME_VALIDATE =
|
|
22
|
+
const LOGIN_NAME_VALIDATE = [KeysOfValidators.STRING, KeysOfValidators.NAME, 'length:6,50', checkAccountCreateBlacklist];
|
|
23
23
|
|
|
24
24
|
@Controller('/ns/api/manage/userAccount', { middleware: [checkPermission(SystemFuncCode.UserAccountMangeRead)] })
|
|
25
25
|
export class UserAccountManageApi extends BaseApiController {
|
|
26
26
|
@Inject()
|
|
27
|
-
ctx: Context;
|
|
27
|
+
protected ctx: Context;
|
|
28
28
|
|
|
29
29
|
@Post('/getUserAccountList')
|
|
30
30
|
async getUserAccountList() {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Controller, Inject, Post } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { KeysOfSimpleSQL, KeysOfValidators } from '
|
|
3
|
+
import { KeysOfSimpleSQL, KeysOfValidators } from '@/libs/crud-pro/models/keys';
|
|
4
4
|
import { BaseApiController } from '../base/BaseApiController';
|
|
5
|
-
import { checkPermission } from '
|
|
6
|
-
import { SystemFuncCode } from '
|
|
7
|
-
import { SystemTables } from '
|
|
8
|
-
import { WorkbenchService } from '
|
|
5
|
+
import { checkPermission } from '@/middleware/permission.middleware';
|
|
6
|
+
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
7
|
+
import { SystemTables } from '@/models/SystemTables';
|
|
8
|
+
import { WorkbenchService } from '@/service/WorkbenchService';
|
|
9
9
|
|
|
10
10
|
@Controller('/ns/api/manage/workbench', { middleware: [checkPermission(SystemFuncCode.WorkbenchMangeRead)] })
|
|
11
11
|
export class WorkbenchMangeApi extends BaseApiController {
|
|
@@ -33,7 +33,7 @@ export class WorkbenchMangeApi extends BaseApiController {
|
|
|
33
33
|
const body = this.ctx.request.body as any;
|
|
34
34
|
const dataObj: any = body.data || {};
|
|
35
35
|
|
|
36
|
-
dataObj.html_content = dataObj.html_content ||
|
|
36
|
+
dataObj.html_content = dataObj.html_content || '<html>hello</html>';
|
|
37
37
|
|
|
38
38
|
return this.executeSysSimpleSQL(SystemTables.sys_workbench, KeysOfSimpleSQL.SIMPLE_INSERT, {
|
|
39
39
|
validateCfg: {
|
|
@@ -5,9 +5,9 @@ import { AuthService } from '../../service/AuthService';
|
|
|
5
5
|
import { ISessionInfo, SESSION_ID_KEY, sessionCookieCfg } from '../../models/userSession';
|
|
6
6
|
import { CommonResult } from '../../libs/utils/common-dto';
|
|
7
7
|
import { checkLogin } from '../../middleware/permission.middleware';
|
|
8
|
-
import { assertCsrfToken } from
|
|
9
|
-
import { WorkbenchService } from
|
|
10
|
-
import { CommonException } from
|
|
8
|
+
import { assertCsrfToken } from '../../libs/utils/fatcms-request';
|
|
9
|
+
import { WorkbenchService } from '../../service/WorkbenchService';
|
|
10
|
+
import { CommonException } from '../../libs/crud-pro/exceptions';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* 支持使用明文密码和Hash后密码登录。
|
|
@@ -22,7 +22,6 @@ export class AuthController extends BaseApiController {
|
|
|
22
22
|
@Inject()
|
|
23
23
|
private authService: AuthService;
|
|
24
24
|
|
|
25
|
-
|
|
26
25
|
@Inject()
|
|
27
26
|
private workbenchService: WorkbenchService;
|
|
28
27
|
|
|
@@ -53,7 +52,6 @@ export class AuthController extends BaseApiController {
|
|
|
53
52
|
throw new CommonException('WORKBENCH_IS_NOT_FOUND', '站点未找到');
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
|
|
57
55
|
const userSessionInfo = await this.authService.createUserSession(loginName, workbench.workbench_code);
|
|
58
56
|
|
|
59
57
|
this.ctx.cookies.set(SESSION_ID_KEY, userSessionInfo.sessionId, sessionCookieCfg);
|
|
@@ -72,7 +70,6 @@ export class AuthController extends BaseApiController {
|
|
|
72
70
|
return CommonResult.successMsg('退出成功');
|
|
73
71
|
}
|
|
74
72
|
|
|
75
|
-
|
|
76
73
|
/**
|
|
77
74
|
* 避免Session过期,前端需要定时调用此接口刷新
|
|
78
75
|
*/
|
|
@@ -84,7 +81,6 @@ export class AuthController extends BaseApiController {
|
|
|
84
81
|
return CommonResult.successRes(newSessionInfo);
|
|
85
82
|
}
|
|
86
83
|
|
|
87
|
-
|
|
88
84
|
/**
|
|
89
85
|
* 修改我自己的密码
|
|
90
86
|
*/
|
|
@@ -94,7 +90,7 @@ export class AuthController extends BaseApiController {
|
|
|
94
90
|
const loginName = this.ctx.userSession.getSessionInfo().loginName;
|
|
95
91
|
|
|
96
92
|
if (loginName === 'devopsviewer') {
|
|
97
|
-
return CommonResult.errorRes(
|
|
93
|
+
return CommonResult.errorRes('开放体验账号不支持修改密码');
|
|
98
94
|
}
|
|
99
95
|
|
|
100
96
|
return this.userAccountService.chgUserPassword(loginName, unsaltedPwd);
|
|
@@ -4,11 +4,10 @@ import { BaseApiController } from '../base/BaseApiController';
|
|
|
4
4
|
import { KeysOfSimpleSQL } from '../../libs/crud-pro/models/keys';
|
|
5
5
|
import { SystemTables } from '../../models/SystemTables';
|
|
6
6
|
import { WorkbenchService } from '../../service/WorkbenchService';
|
|
7
|
-
import { createRenderUtils } from
|
|
8
|
-
import { privateAES } from
|
|
7
|
+
import { createRenderUtils } from '../../libs/utils/render-utils';
|
|
8
|
+
import { privateAES } from '../../libs/utils/crypto-utils';
|
|
9
9
|
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
10
10
|
|
|
11
|
-
|
|
12
11
|
/**
|
|
13
12
|
* 渲染独立外部应用
|
|
14
13
|
*/
|
|
@@ -58,18 +57,19 @@ export class AppRenderController extends BaseApiController {
|
|
|
58
57
|
|
|
59
58
|
const html_content = appInfo.html_content || '<b style="color: red">错误:未配置HTML模版,请检查!!</b>';
|
|
60
59
|
const userInfo = this.getUserSessionInfo();
|
|
61
|
-
const fatcmscsrftoken = await privateAES.time_encrypt_utf8_base64(
|
|
60
|
+
const fatcmscsrftoken = await privateAES.time_encrypt_utf8_base64('' + Date.now());
|
|
62
61
|
|
|
63
62
|
const utils = createRenderUtils({
|
|
64
63
|
ctx: this.ctx,
|
|
65
|
-
appInfo,
|
|
64
|
+
appInfo,
|
|
65
|
+
workbenchInfo,
|
|
66
|
+
userInfo,
|
|
67
|
+
package_assets: appInfo.package_assets,
|
|
68
|
+
fatcmscsrftoken,
|
|
66
69
|
});
|
|
67
70
|
return this.ctx.renderString(html_content, { appInfo, workbenchInfo, userInfo, utils }, { viewEngine: 'ejs' });
|
|
68
71
|
}
|
|
69
72
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
73
|
private async isSupportCurrentWorkbench(appInfo: any): Promise<boolean> {
|
|
74
74
|
if (this.isLocalEnv()) {
|
|
75
75
|
return true;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {Controller, Get, Inject} from '@midwayjs/core';
|
|
2
|
-
import {Context} from '@midwayjs/koa';
|
|
3
|
-
import {CurdMixService} from '../service/curd/CurdMixService';
|
|
4
|
-
import {BaseApiController} from
|
|
5
|
-
import {IRequestCfgModel} from
|
|
6
|
-
import {KeysOfSimpleSQL, SqlDbType} from
|
|
7
|
-
|
|
1
|
+
import { Controller, Get, Inject } from '@midwayjs/core';
|
|
2
|
+
import { Context } from '@midwayjs/koa';
|
|
3
|
+
import { CurdMixService } from '../service/curd/CurdMixService';
|
|
4
|
+
import { BaseApiController } from './base/BaseApiController';
|
|
5
|
+
import { IRequestCfgModel } from '../libs/crud-pro/interfaces';
|
|
6
|
+
import { KeysOfSimpleSQL, SqlDbType } from '../libs/crud-pro/models/keys';
|
|
8
7
|
|
|
9
8
|
// http://127.0.0.1:7002/ns/api/test/testPgQuery
|
|
10
9
|
|
|
11
10
|
@Controller('/ns/api/test')
|
|
12
|
-
export class TestApiController extends BaseApiController{
|
|
11
|
+
export class TestApiController extends BaseApiController {
|
|
13
12
|
@Inject()
|
|
14
13
|
protected ctx: Context;
|
|
15
14
|
|
|
@@ -19,19 +18,20 @@ export class TestApiController extends BaseApiController{
|
|
|
19
18
|
@Get('/testPgQuery')
|
|
20
19
|
async testPgQuery() {
|
|
21
20
|
const cfgModel: IRequestCfgModel = {
|
|
22
|
-
sqlTable:
|
|
21
|
+
sqlTable: 'test_table1',
|
|
23
22
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
24
|
-
sqlDatabase:
|
|
23
|
+
sqlDatabase: 'postgres_test1',
|
|
25
24
|
sqlDbType: SqlDbType.postgres,
|
|
26
25
|
updateCfg: {},
|
|
27
26
|
};
|
|
28
27
|
|
|
29
|
-
return this.curdMixService.executeCrudByCfg(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
return this.curdMixService.executeCrudByCfg(
|
|
29
|
+
{
|
|
30
|
+
condition: {
|
|
31
|
+
int4: '222',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
cfgModel
|
|
35
|
+
);
|
|
35
36
|
}
|
|
36
|
-
|
|
37
37
|
}
|
package/src/index.ts
CHANGED
|
@@ -79,7 +79,6 @@ export * from './models/SystemTables';
|
|
|
79
79
|
export * from './models/AsyncTaskModel';
|
|
80
80
|
export * from './schedule/index';
|
|
81
81
|
|
|
82
|
-
|
|
83
82
|
export * from './libs/utils/common-dto';
|
|
84
83
|
export * from './libs/utils/crypto-utils';
|
|
85
84
|
export * from './libs/utils/fatcms-request';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// import { Pool as MysqlPool } from 'mysql2/promise';
|
|
2
2
|
// import { Pool as PostgresPool } from 'pg';
|
|
3
|
-
import {KeysOfAuthType, KeysOfSimpleSQL, KeysOfValidators, SqlDbType} from './models/keys';
|
|
3
|
+
import { KeysOfAuthType, KeysOfSimpleSQL, KeysOfValidators, SqlDbType } from './models/keys';
|
|
4
4
|
|
|
5
5
|
export interface ICrudProCfg {
|
|
6
6
|
sysDatabaseName?: string; // 默认系统数据库名称,默认 fatcms
|
|
@@ -183,8 +183,6 @@ export interface ILogger {
|
|
|
183
183
|
warn(msg: any, ...args: any[]): void;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
|
|
188
186
|
export interface IExecuteUnsafeQueryCtx {
|
|
189
187
|
sqlTable: string;
|
|
190
188
|
sqlDatabase: string;
|
|
@@ -7,8 +7,7 @@ import { Transaction } from './Transaction';
|
|
|
7
7
|
import { ICrudProCfg, ILogger, IVisitor } from '../interfaces';
|
|
8
8
|
import { IExecuteContextFunc } from './ExecuteContextFunc';
|
|
9
9
|
import { defaultCrudProCfg } from '../defaultConfigs';
|
|
10
|
-
import { ResModelFlexible } from
|
|
11
|
-
|
|
10
|
+
import { ResModelFlexible } from './ResModel';
|
|
12
11
|
|
|
13
12
|
class ExecuteContext {
|
|
14
13
|
// 运行前设置的
|
|
@@ -109,6 +108,4 @@ interface IExecuteContextHandler {
|
|
|
109
108
|
handleExecuteContext(executeContext: ExecuteContext): Promise<void>;
|
|
110
109
|
}
|
|
111
110
|
|
|
112
|
-
|
|
113
|
-
|
|
114
111
|
export { ExecuteContext, IExecuteContextHandler };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {IConnectionPool, IRequestCfgModel, IRequestModel} from '../interfaces';
|
|
1
|
+
import { IConnectionPool, IRequestCfgModel, IRequestModel } from '../interfaces';
|
|
2
2
|
import { ExecuteContext } from './ExecuteContext';
|
|
3
3
|
import { SqlCfgModel } from './SqlCfgModel';
|
|
4
4
|
import { RequestCfgModel } from './RequestCfgModel';
|
|
@@ -77,7 +77,6 @@ export class BaseExecuteContextFunc implements IExecuteContextFunc {
|
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
81
80
|
/**
|
|
82
81
|
* 在执行之前可以根据业务需要修改需要执行的内容
|
|
83
82
|
* @param reqJson
|
|
@@ -2,7 +2,7 @@ import * as _ from 'lodash';
|
|
|
2
2
|
import { ILimitOffset, IOrderByItem, IRequestModel, IVisitor } from '../interfaces';
|
|
3
3
|
import { MixinUtils } from '../utils/MixinUtils';
|
|
4
4
|
import { CommonException, Exceptions } from '../exceptions';
|
|
5
|
-
import {DEFAULT_LIMIT} from
|
|
5
|
+
import { DEFAULT_LIMIT } from '../defaultConfigs';
|
|
6
6
|
|
|
7
7
|
class RequestModel {
|
|
8
8
|
visitor: IVisitor;
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
|
|
2
1
|
interface ResModelAffected {
|
|
3
2
|
insertId?: string | number;
|
|
4
3
|
affectedRows: number;
|
|
5
4
|
}
|
|
6
5
|
|
|
7
6
|
interface ResModelStandard {
|
|
8
|
-
row?: any
|
|
9
|
-
rows?: any[]
|
|
10
|
-
total_count?: number
|
|
11
|
-
affected?: ResModelAffected
|
|
12
|
-
insert_affected?: ResModelAffected
|
|
13
|
-
update_affected?: ResModelAffected
|
|
7
|
+
row?: any;
|
|
8
|
+
rows?: any[];
|
|
9
|
+
total_count?: number;
|
|
10
|
+
affected?: ResModelAffected;
|
|
11
|
+
insert_affected?: ResModelAffected;
|
|
12
|
+
update_affected?: ResModelAffected;
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
type ResModelFlexible = ResModelStandard & {
|
|
17
16
|
[key: string]: any;
|
|
18
17
|
};
|
|
19
18
|
|
|
20
|
-
export {
|
|
21
|
-
ResModelAffected,
|
|
22
|
-
ResModelStandard,
|
|
23
|
-
ResModelFlexible
|
|
24
|
-
}
|
|
19
|
+
export { ResModelAffected, ResModelStandard, ResModelFlexible };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ColumnRelation, IFuncCfgModel, ISqlCfgModel } from '../interfaces';
|
|
2
2
|
import { MixinUtils } from '../utils/MixinUtils';
|
|
3
|
-
import { KeyOfCrudTypes, KeysOfSqlResPicker, SqlDbType} from './keys';
|
|
3
|
+
import { KeyOfCrudTypes, KeysOfSqlResPicker, SqlDbType } from './keys';
|
|
4
4
|
import { parseJsonObject } from '../../utils/functions';
|
|
5
5
|
|
|
6
6
|
const { isEmpty } = MixinUtils;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {IConnectionPool, IPoolConnectionClient} from '../interfaces';
|
|
2
|
-
import {SqlDbType} from
|
|
3
|
-
import {TransactionMySQL} from
|
|
4
|
-
import {TransactionPostgres} from
|
|
5
|
-
import {TransactionSqlServer} from
|
|
1
|
+
import { IConnectionPool, IPoolConnectionClient } from '../interfaces';
|
|
2
|
+
import { SqlDbType } from './keys';
|
|
3
|
+
import { TransactionMySQL } from './TransactionMySQL';
|
|
4
|
+
import { TransactionPostgres } from './TransactionPostgres';
|
|
5
|
+
import { TransactionSqlServer } from './TransactionSqlServer';
|
|
6
6
|
|
|
7
7
|
class Transaction {
|
|
8
|
-
|
|
9
|
-
private
|
|
10
|
-
private
|
|
11
|
-
private transactionSqlServer : TransactionSqlServer = new TransactionSqlServer();
|
|
8
|
+
private transactionMySQL: TransactionMySQL = new TransactionMySQL();
|
|
9
|
+
private transactionPostgres: TransactionPostgres = new TransactionPostgres();
|
|
10
|
+
private transactionSqlServer: TransactionSqlServer = new TransactionSqlServer();
|
|
12
11
|
|
|
13
12
|
private getTxObj(pool: IConnectionPool): TransactionMySQL | TransactionPostgres | TransactionSqlServer {
|
|
14
13
|
if (pool.dbType === SqlDbType.postgres) {
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { ConnectionPool, Request, Transaction } from 'mssql';
|
|
2
2
|
import { IConnectionPool, IPoolConnectionClient } from '../interfaces';
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
interface ISqlServerConnection extends IPoolConnectionClient {
|
|
6
|
-
originConnection: ConnectionPool
|
|
5
|
+
originConnection: ConnectionPool;
|
|
7
6
|
}
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
8
|
class TransactionSqlServer {
|
|
12
9
|
private isBeginTransaction = false;
|
|
13
10
|
private connectionMap: Record<string, ISqlServerConnection> = {};
|
|
@@ -31,23 +28,23 @@ class TransactionSqlServer {
|
|
|
31
28
|
return connection;
|
|
32
29
|
}
|
|
33
30
|
|
|
34
|
-
private async connectAndCreateConnection(pool: IConnectionPool)
|
|
31
|
+
private async connectAndCreateConnection(pool: IConnectionPool): Promise<ISqlServerConnection> {
|
|
35
32
|
const poolInstance: ConnectionPool = pool.poolInstance as any;
|
|
36
33
|
const originConnection = await poolInstance.connect();
|
|
37
34
|
return {
|
|
38
35
|
originConnection,
|
|
39
|
-
query: (sql:string, values: any)
|
|
36
|
+
query: (sql: string, values: any): Promise<any> => {
|
|
40
37
|
const request = new Request(originConnection);
|
|
41
38
|
if (Array.isArray(values)) {
|
|
42
39
|
for (let i = 0; i < values.length; i++) {
|
|
43
|
-
const index = i+1;
|
|
40
|
+
const index = i + 1;
|
|
44
41
|
const value = values[i];
|
|
45
42
|
request.input(`fatcms_ms${index}`, value);
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
45
|
return request.query(sql);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
46
|
+
},
|
|
47
|
+
};
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
/**
|
|
@@ -93,15 +90,13 @@ class TransactionSqlServer {
|
|
|
93
90
|
this.transactionMap = {};
|
|
94
91
|
}
|
|
95
92
|
|
|
96
|
-
|
|
97
93
|
private async beginTransaction(poolName: string) {
|
|
98
94
|
const connection = this.connectionMap[poolName];
|
|
99
95
|
const originConnection: ConnectionPool = connection.originConnection;
|
|
100
|
-
const tmpTx =
|
|
96
|
+
const tmpTx = new Transaction(originConnection);
|
|
101
97
|
this.transactionMap[poolName] = tmpTx;
|
|
102
|
-
return await tmpTx.begin()
|
|
98
|
+
return await tmpTx.begin();
|
|
103
99
|
}
|
|
104
|
-
|
|
105
100
|
}
|
|
106
101
|
|
|
107
102
|
export { TransactionSqlServer };
|
|
@@ -63,15 +63,13 @@ class CrudProCachedCfgService extends CrudProServiceBase {
|
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
66
|
private async loadMethodInfoList(): Promise<any[]> {
|
|
69
67
|
const { methodsTableName, sysDatabaseName, sysDatabaseDbType } = this.getContextCfg();
|
|
70
68
|
const sql = `select * from ${methodsTableName}`; // 全部加载到内存
|
|
71
69
|
const baseInfo = {
|
|
72
70
|
sqlTable: methodsTableName,
|
|
73
71
|
sqlDatabase: sysDatabaseName,
|
|
74
|
-
sqlDbType: sysDatabaseDbType
|
|
72
|
+
sqlDbType: sysDatabaseDbType,
|
|
75
73
|
};
|
|
76
74
|
const [rows] = await this.executeUnsafeQuery(baseInfo, sql);
|
|
77
75
|
const rows2: any[] = rows as object[];
|