midway-fatcms 0.0.1-beta.18 → 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/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/runSchedule.d.ts +1 -0
- package/dist/schedule/runSchedule.js +9 -6
- 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 +3 -2
- package/package.json +1 -1
- 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/runSchedule.ts +16 -11
- package/src/service/UserSessionService.ts +5 -4
- package/src/service/VisitStatService.ts +55 -71
- package/src/service/asyncTask/AsyncTaskRunnerService.ts +119 -88
- package/src/service/asyncTask/AsyncTaskService.ts +9 -9
package/.eslintrc.json
CHANGED
|
@@ -23,13 +23,13 @@ const exceptions_1 = require("../../libs/crud-pro/exceptions");
|
|
|
23
23
|
const permission_middleware_1 = require("../../middleware/permission.middleware");
|
|
24
24
|
function fixMyTasksCondition(body, ctx) {
|
|
25
25
|
if (!body.condition) {
|
|
26
|
-
throw new exceptions_1.CommonException(
|
|
26
|
+
throw new exceptions_1.CommonException('参数不正确');
|
|
27
27
|
}
|
|
28
28
|
body.condition.created_by = ctx.userSession.getSessionInfo().accountId;
|
|
29
29
|
}
|
|
30
30
|
function fixCancelBodyData(body, id) {
|
|
31
31
|
if (!body.data || !body.condition) {
|
|
32
|
-
throw new exceptions_1.CommonException(
|
|
32
|
+
throw new exceptions_1.CommonException('参数不正确');
|
|
33
33
|
}
|
|
34
34
|
// fix condition
|
|
35
35
|
const conditionObj = (body.condition || {});
|
|
@@ -42,7 +42,7 @@ function fixCancelBodyData(body, id) {
|
|
|
42
42
|
}
|
|
43
43
|
function fixCreateBodyData(body, ctx) {
|
|
44
44
|
if (!body.data) {
|
|
45
|
-
throw new exceptions_1.CommonException(
|
|
45
|
+
throw new exceptions_1.CommonException('参数不正确');
|
|
46
46
|
}
|
|
47
47
|
const sessionInfo = ctx.userSession.getSessionInfo();
|
|
48
48
|
// fix data
|
|
@@ -44,7 +44,7 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
|
|
|
44
44
|
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
45
45
|
await this.curdMixService.executeCrudByCfg({
|
|
46
46
|
data: {
|
|
47
|
-
pv: pv + 1
|
|
47
|
+
pv: pv + 1,
|
|
48
48
|
},
|
|
49
49
|
condition: {
|
|
50
50
|
id: parseInt(docId),
|
|
@@ -48,11 +48,11 @@ let PublicApiController = class PublicApiController extends BaseApiController_1.
|
|
|
48
48
|
if (!workbenchMenuCode) {
|
|
49
49
|
return common_dto_1.CommonResult.errorRes('param workbenchMenuCode is null');
|
|
50
50
|
}
|
|
51
|
-
const workbenchMenuCodeStr =
|
|
51
|
+
const workbenchMenuCodeStr = '' + workbenchMenuCode;
|
|
52
52
|
const workbenchMenuCodeArray = workbenchMenuCodeStr.split(',');
|
|
53
53
|
const condition = {
|
|
54
54
|
menu_code: {
|
|
55
|
-
|
|
55
|
+
$in: workbenchMenuCodeArray,
|
|
56
56
|
},
|
|
57
57
|
};
|
|
58
58
|
const rows = await this.sysDBUtil.getList({ condition }, SystemTables_1.SystemTables.sys_menus);
|
|
@@ -74,9 +74,7 @@ let PublicApiController = class PublicApiController extends BaseApiController_1.
|
|
|
74
74
|
// 特殊的devops菜单
|
|
75
75
|
map['devops'] = {
|
|
76
76
|
menu_list: [],
|
|
77
|
-
hasPermission: this.ctx.userSession.isAuthPass(keys_1.KeysOfAuthType.byRoleCode, [
|
|
78
|
-
SystemPerm_1.SystemRoleCode.DevOpsWriter, SystemPerm_1.SystemRoleCode.DevOpsViewer, SystemPerm_1.SystemRoleCode.SuperAdmin
|
|
79
|
-
])
|
|
77
|
+
hasPermission: this.ctx.userSession.isAuthPass(keys_1.KeysOfAuthType.byRoleCode, [SystemPerm_1.SystemRoleCode.DevOpsWriter, SystemPerm_1.SystemRoleCode.DevOpsViewer, SystemPerm_1.SystemRoleCode.SuperAdmin]),
|
|
80
78
|
};
|
|
81
79
|
return common_dto_1.CommonResult.successRes(map);
|
|
82
80
|
}
|
|
@@ -109,7 +107,7 @@ let PublicApiController = class PublicApiController extends BaseApiController_1.
|
|
|
109
107
|
const body = this.ctx.request.body;
|
|
110
108
|
const query = this.ctx.query || {};
|
|
111
109
|
let codeList = _.get(body, 'codeList');
|
|
112
|
-
|
|
110
|
+
const refreshCache = `${_.get(body, 'refreshCache')}` === 'true' || query.refreshCache === 'true';
|
|
113
111
|
if (query.codeList) {
|
|
114
112
|
//codeList=dict@@SexEnum,sysCfgEnum@@EntityStatusEnum
|
|
115
113
|
const codeListStr = query.codeList;
|
|
@@ -22,10 +22,10 @@ const https = require("https");
|
|
|
22
22
|
const functions_1 = require("../../libs/utils/functions");
|
|
23
23
|
function getPathConfig(ossName) {
|
|
24
24
|
const remoteBaseUrlMap = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
cdnjsx: 'https://cdnjsx.oss-cn-shanghai.aliyuncs.com',
|
|
26
|
+
'i.alicdn.com': 'https://i.alicdn.com',
|
|
27
|
+
'img.alicdn.com': 'https://img.alicdn.com',
|
|
28
|
+
'at.alicdn.com': 'https://at.alicdn.com',
|
|
29
29
|
};
|
|
30
30
|
let remoteBaseUrl = remoteBaseUrlMap[ossName];
|
|
31
31
|
if (!remoteBaseUrl) {
|
|
@@ -53,7 +53,7 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
|
|
|
53
53
|
const notFoundListFile = path.join(localDir, '__404__list.json'); // 404列表文件
|
|
54
54
|
return {
|
|
55
55
|
localDir,
|
|
56
|
-
notFoundListFile
|
|
56
|
+
notFoundListFile,
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
async initNotFoundList() {
|
|
@@ -77,8 +77,8 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
|
|
|
77
77
|
}
|
|
78
78
|
async responseLocalFile(localFilePath, localHeaderPath, relativePath) {
|
|
79
79
|
const headers = {
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
'Cache-Control': 'public, max-age=31536000',
|
|
81
|
+
Expires: new Date(Date.now() + 31536000000).toUTCString(),
|
|
82
82
|
};
|
|
83
83
|
try {
|
|
84
84
|
// 检查本地文件是否存在.头文件
|
|
@@ -87,16 +87,17 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
|
|
|
87
87
|
const headerDataStr = await fs.readFile(localHeaderPath, 'utf8');
|
|
88
88
|
const headerData = (0, functions_1.parseJsonObject)(headerDataStr);
|
|
89
89
|
if (headerData) {
|
|
90
|
-
headers[
|
|
91
|
-
headers[
|
|
92
|
-
headers[
|
|
93
|
-
headers[
|
|
94
|
-
headers[
|
|
95
|
-
headers[
|
|
90
|
+
headers['content-type'] = headerData['content-type'];
|
|
91
|
+
headers['content-length'] = headerData['content-length'];
|
|
92
|
+
headers['last-modified'] = headerData['last-modified'];
|
|
93
|
+
headers['etag'] = headerData['etag'];
|
|
94
|
+
headers['cache-control'] = headerData['cache-control'];
|
|
95
|
+
headers['accept-ranges'] = headerData['accept-ranges'];
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
catch (error) {
|
|
100
|
+
console.debug('[StaticController]responseLocalFile', error);
|
|
100
101
|
}
|
|
101
102
|
try {
|
|
102
103
|
// 检查本地文件是否存在
|
|
@@ -127,8 +128,8 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
|
|
|
127
128
|
const { localDir } = this.getLocalPaths();
|
|
128
129
|
const PATH_CONFIG = getPathConfig(ossName);
|
|
129
130
|
// 构建本地路径和远程路径
|
|
130
|
-
const localFilePath = path.join(localDir,
|
|
131
|
-
const localHeaderPath = path.join(localDir,
|
|
131
|
+
const localFilePath = path.join(localDir, 'files', ossName, relativePath);
|
|
132
|
+
const localHeaderPath = path.join(localDir, 'headers', ossName, relativePath);
|
|
132
133
|
const remoteUrl = `${PATH_CONFIG.remoteBaseUrl}/${relativePath}`;
|
|
133
134
|
// 检查是否在404列表中
|
|
134
135
|
if (notFoundList.has(relativePath)) {
|
|
@@ -175,7 +176,7 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
|
|
|
175
176
|
return this.ctx.render('500', { errorMsg: msg });
|
|
176
177
|
}
|
|
177
178
|
this.ctx.status = 500;
|
|
178
|
-
return this.ctx.render('500', { errorMsg:
|
|
179
|
+
return this.ctx.render('500', { errorMsg: '未知异常' });
|
|
179
180
|
}
|
|
180
181
|
// 保存404列表
|
|
181
182
|
async saveNotFoundList() {
|
|
@@ -193,13 +194,15 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
|
|
|
193
194
|
// 封装https请求为异步函数
|
|
194
195
|
async httpsGet(url) {
|
|
195
196
|
return new Promise((resolve, reject) => {
|
|
196
|
-
https
|
|
197
|
+
https
|
|
198
|
+
.get(url, res => {
|
|
197
199
|
resolve({
|
|
198
200
|
statusCode: res.statusCode || 500,
|
|
199
201
|
headers: res.headers,
|
|
200
|
-
body: res
|
|
202
|
+
body: res,
|
|
201
203
|
});
|
|
202
|
-
})
|
|
204
|
+
})
|
|
205
|
+
.on('error', err => {
|
|
203
206
|
reject(err);
|
|
204
207
|
});
|
|
205
208
|
});
|
|
@@ -222,11 +225,11 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
|
|
|
222
225
|
// 使用管道将响应流写入文件
|
|
223
226
|
await new Promise((resolve, reject) => {
|
|
224
227
|
body.pipe(fileStream);
|
|
225
|
-
body.on('error',
|
|
228
|
+
body.on('error', err => {
|
|
226
229
|
reject(new Error(`读取响应流失败: ${err.message}`));
|
|
227
230
|
});
|
|
228
231
|
fileStream.on('finish', resolve);
|
|
229
|
-
fileStream.on('error',
|
|
232
|
+
fileStream.on('error', err => {
|
|
230
233
|
reject(new Error(`写入文件失败: ${err.message}`));
|
|
231
234
|
});
|
|
232
235
|
});
|
|
@@ -261,7 +264,7 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
|
|
|
261
264
|
'.txt': 'text/plain',
|
|
262
265
|
'.pdf': 'application/pdf',
|
|
263
266
|
'.mp4': 'video/mp4',
|
|
264
|
-
'.ico': 'image/x-icon'
|
|
267
|
+
'.ico': 'image/x-icon',
|
|
265
268
|
};
|
|
266
269
|
return mimeTypes[extname] || 'application/octet-stream';
|
|
267
270
|
}
|
|
@@ -3,7 +3,7 @@ import { Context } from '@midwayjs/koa';
|
|
|
3
3
|
import { CurdMixService } from '../service/curd/CurdMixService';
|
|
4
4
|
import { CommonResult } from '../libs/utils/common-dto';
|
|
5
5
|
export declare class HelpersApi {
|
|
6
|
-
ctx: Context;
|
|
6
|
+
protected ctx: Context;
|
|
7
7
|
private midwayWebRouterService;
|
|
8
8
|
protected curdMixService: CurdMixService;
|
|
9
9
|
getApiEnv(): Promise<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseApiController } from '../base/BaseApiController';
|
|
2
2
|
import { SqlDbType } from '../../libs/crud-pro/models/keys';
|
|
3
|
-
import { CommonResult } from
|
|
3
|
+
import { CommonResult } from '../../libs/utils/common-dto';
|
|
4
4
|
export declare class CrudStandardDesignApi extends BaseApiController {
|
|
5
5
|
private mysql2Config;
|
|
6
6
|
private postgres2Config;
|
|
@@ -34,11 +34,7 @@ let CrudStandardDesignApi = class CrudStandardDesignApi extends BaseApiControlle
|
|
|
34
34
|
const mysqlObjList = toSelectList(mysqlList, keys_1.SqlDbType.mysql);
|
|
35
35
|
const postgresObjList = toSelectList(postgresList, keys_1.SqlDbType.postgres);
|
|
36
36
|
const sqlserverObjList = toSelectList(sqlServerList, keys_1.SqlDbType.sqlserver);
|
|
37
|
-
const databaseList = [
|
|
38
|
-
...mysqlObjList,
|
|
39
|
-
...postgresObjList,
|
|
40
|
-
...sqlserverObjList,
|
|
41
|
-
].filter((obj) => {
|
|
37
|
+
const databaseList = [...mysqlObjList, ...postgresObjList, ...sqlserverObjList].filter((obj) => {
|
|
42
38
|
const value = '' + obj.value;
|
|
43
39
|
return !value.endsWith('_fatcms_inner_demo_config');
|
|
44
40
|
});
|
|
@@ -71,7 +67,7 @@ let CrudStandardDesignApi = class CrudStandardDesignApi extends BaseApiControlle
|
|
|
71
67
|
label: tableName,
|
|
72
68
|
dbName,
|
|
73
69
|
dbType,
|
|
74
|
-
tableName
|
|
70
|
+
tableName,
|
|
75
71
|
};
|
|
76
72
|
});
|
|
77
73
|
return common_dto_1.CommonResult.successRes(tableNames);
|
|
@@ -167,16 +163,8 @@ let CrudStandardDesignApi = class CrudStandardDesignApi extends BaseApiControlle
|
|
|
167
163
|
}
|
|
168
164
|
const dbType = keys_1.SqlDbType.postgres;
|
|
169
165
|
const schemaname = 'public';
|
|
170
|
-
const tableListSql = '' +
|
|
171
|
-
|
|
172
|
-
'FROM pg_tables\n' +
|
|
173
|
-
`WHERE schemaname = '${schemaname}' \n` +
|
|
174
|
-
'ORDER BY tablename;';
|
|
175
|
-
const viewListSql = '' +
|
|
176
|
-
'SELECT viewname as tablename\n' +
|
|
177
|
-
'FROM pg_views\n' +
|
|
178
|
-
`WHERE schemaname = '${schemaname}' \n` +
|
|
179
|
-
'ORDER BY viewname;';
|
|
166
|
+
const tableListSql = '' + 'SELECT tablename\n' + 'FROM pg_tables\n' + `WHERE schemaname = '${schemaname}' \n` + 'ORDER BY tablename;';
|
|
167
|
+
const viewListSql = '' + 'SELECT viewname as tablename\n' + 'FROM pg_views\n' + `WHERE schemaname = '${schemaname}' \n` + 'ORDER BY viewname;';
|
|
180
168
|
const toSelectOptions = async (executeSql, tableType) => {
|
|
181
169
|
const arr = await this.curdMixService.executeSQL({
|
|
182
170
|
executeSql: executeSql,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
2
|
import { BaseApiController } from '../base/BaseApiController';
|
|
3
3
|
export declare class DataDictManageApi extends BaseApiController {
|
|
4
|
-
ctx: Context;
|
|
4
|
+
protected ctx: Context;
|
|
5
5
|
getDataDictList(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
6
6
|
getDataDictOne(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
7
7
|
createDataDict(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
2
|
import { BaseApiController } from '../base/BaseApiController';
|
|
3
|
-
import { CommonResult } from
|
|
3
|
+
import { CommonResult } from '../../libs/utils/common-dto';
|
|
4
4
|
export declare class DeployManageApi extends BaseApiController {
|
|
5
5
|
protected ctx: Context;
|
|
6
6
|
private fileCenterService;
|
|
@@ -28,44 +28,46 @@ const global_config_1 = require("../../libs/global-config/global-config");
|
|
|
28
28
|
function toAssetsSchema(fileList) {
|
|
29
29
|
for (let i = 0; i < fileList.length; i++) {
|
|
30
30
|
const fileListElement = fileList[i];
|
|
31
|
-
fileListElement.settingKey =
|
|
31
|
+
fileListElement.settingKey = 'assets' + i;
|
|
32
32
|
}
|
|
33
33
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
schema: [
|
|
35
|
+
{
|
|
36
|
+
title: '资源配置',
|
|
37
|
+
name: 'fileList',
|
|
38
|
+
type: 'array',
|
|
39
|
+
properties: {
|
|
40
|
+
fileUrl: { label: '文件URL', component: 'Input', xProps: { hasClear: true }, width: 500 },
|
|
41
|
+
fileType: {
|
|
42
|
+
label: '文件类型',
|
|
43
|
+
component: 'Select',
|
|
43
44
|
enums: [
|
|
44
45
|
{ label: 'js', value: 'js' },
|
|
45
46
|
{ label: 'css', value: 'css' },
|
|
46
47
|
],
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
xProps: {
|
|
49
|
+
hasClear: true,
|
|
49
50
|
},
|
|
50
|
-
width: 500
|
|
51
|
+
width: 500,
|
|
51
52
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
isModule: {
|
|
54
|
+
label: 'isModule',
|
|
55
|
+
component: 'Select',
|
|
55
56
|
enums: [
|
|
56
57
|
{ label: 'true', value: true },
|
|
57
58
|
{ label: 'false', value: false },
|
|
58
59
|
],
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
xProps: {
|
|
61
|
+
hasClear: true,
|
|
61
62
|
},
|
|
62
|
-
width: 500
|
|
63
|
+
width: 500,
|
|
63
64
|
},
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
data: {
|
|
69
|
+
fileList: fileList,
|
|
70
|
+
},
|
|
69
71
|
};
|
|
70
72
|
}
|
|
71
73
|
let DeployManageApi = class DeployManageApi extends BaseApiController_1.BaseApiController {
|
|
@@ -116,26 +118,26 @@ let DeployManageApi = class DeployManageApi extends BaseApiController_1.BaseApiC
|
|
|
116
118
|
package_assets: JSON.stringify(toAssetsSchema(cdnResources)),
|
|
117
119
|
},
|
|
118
120
|
condition: {
|
|
119
|
-
package_name: params.packageName
|
|
120
|
-
}
|
|
121
|
+
package_name: params.packageName,
|
|
122
|
+
},
|
|
121
123
|
}, {
|
|
122
124
|
sqlTable: SystemTables_1.SystemTables.sys_workbench,
|
|
123
125
|
sqlDatabase: SystemDbName,
|
|
124
126
|
sqlDbType: SystemDbType,
|
|
125
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE
|
|
127
|
+
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
126
128
|
});
|
|
127
129
|
const app = await this.curdMixService.executeCrudByCfg({
|
|
128
130
|
data: {
|
|
129
131
|
package_assets: JSON.stringify(toAssetsSchema(cdnResources)),
|
|
130
132
|
},
|
|
131
133
|
condition: {
|
|
132
|
-
package_name: params.packageName
|
|
133
|
-
}
|
|
134
|
+
package_name: params.packageName,
|
|
135
|
+
},
|
|
134
136
|
}, {
|
|
135
137
|
sqlTable: SystemTables_1.SystemTables.sys_app,
|
|
136
138
|
sqlDatabase: SystemDbName,
|
|
137
139
|
sqlDbType: SystemDbType,
|
|
138
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE
|
|
140
|
+
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
139
141
|
});
|
|
140
142
|
this.workbenchService.clearCache();
|
|
141
143
|
const workbenchAffected = workbench.getResModelItem('affected') || {};
|
|
@@ -39,7 +39,7 @@ let MenuManageApi = class MenuManageApi extends BaseApiController_1.BaseApiContr
|
|
|
39
39
|
async updateMenu() {
|
|
40
40
|
return this.executeSysSimpleSQL(SystemTables_1.SystemTables.sys_menus, keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
41
41
|
validateCfg: {
|
|
42
|
-
'condition.id': [keys_1.KeysOfValidators.REQUIRED, keys_1.KeysOfValidators.INTEGER]
|
|
42
|
+
'condition.id': [keys_1.KeysOfValidators.REQUIRED, keys_1.KeysOfValidators.INTEGER],
|
|
43
43
|
},
|
|
44
44
|
updateCfg: {},
|
|
45
45
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
|
-
import { VisitStatService } from
|
|
2
|
+
import { VisitStatService } from '../../service/VisitStatService';
|
|
3
3
|
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
-
import { CommonResult } from
|
|
4
|
+
import { CommonResult } from '../../libs/utils/common-dto';
|
|
5
5
|
export declare class SuperAdminManageApi extends BaseApiController {
|
|
6
6
|
protected ctx: Context;
|
|
7
7
|
protected visitStatService: VisitStatService;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
2
|
import { BaseApiController } from '../base/BaseApiController';
|
|
3
|
-
import { CommonResult } from
|
|
3
|
+
import { CommonResult } from '../../libs/utils/common-dto';
|
|
4
4
|
export declare class SysConfigMangeApi extends BaseApiController {
|
|
5
5
|
ctx: Context;
|
|
6
6
|
getSysConfigList(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
@@ -52,17 +52,17 @@ let SysConfigMangeApi = class SysConfigMangeApi extends BaseApiController_1.Base
|
|
|
52
52
|
const body = this.ctx.request.body;
|
|
53
53
|
const id = body.condition.id;
|
|
54
54
|
if (!id) {
|
|
55
|
-
return common_dto_1.CommonResult.errorRes(
|
|
55
|
+
return common_dto_1.CommonResult.errorRes('id不能为空');
|
|
56
56
|
}
|
|
57
57
|
const sysConfig = await this.curdMixService.getBbUtil(SystemDbName, SystemDbType).getOne({ condition: body.condition }, SystemTables_1.SystemTables.sys_configs);
|
|
58
58
|
if (!sysConfig) {
|
|
59
|
-
return common_dto_1.CommonResult.errorRes(
|
|
59
|
+
return common_dto_1.CommonResult.errorRes('配置项不存在');
|
|
60
60
|
}
|
|
61
61
|
const { edit_auth_type, edit_auth_config } = sysConfig;
|
|
62
62
|
if (edit_auth_type) {
|
|
63
63
|
const isOK = this.ctx.userSession.isAuthPass(edit_auth_type, edit_auth_config);
|
|
64
64
|
if (!isOK) {
|
|
65
|
-
return common_dto_1.CommonResult.errorRes(
|
|
65
|
+
return common_dto_1.CommonResult.errorRes('编辑权限校验不通过:' + JSON.stringify({ edit_auth_type, edit_auth_config }));
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
return this.executeSysSimpleSQL('sys_configs', keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InfoService } from '@midwayjs/info';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
-
import { CommonResult } from
|
|
4
|
+
import { CommonResult } from '../../libs/utils/common-dto';
|
|
5
5
|
export declare class SystemInfoManageApi extends BaseApiController {
|
|
6
6
|
protected ctx: Context;
|
|
7
7
|
protected infoService: InfoService;
|
|
@@ -42,7 +42,13 @@ let SystemInfoManageApi = class SystemInfoManageApi extends BaseApiController_1.
|
|
|
42
42
|
// 网络信息
|
|
43
43
|
const networkInfo = this.infoService.networkInfo();
|
|
44
44
|
return common_dto_1.CommonResult.successRes({
|
|
45
|
-
projectInfo,
|
|
45
|
+
projectInfo,
|
|
46
|
+
systemInfo,
|
|
47
|
+
resourceOccupationInfo,
|
|
48
|
+
softwareInfo,
|
|
49
|
+
timeInfo,
|
|
50
|
+
envInfo,
|
|
51
|
+
networkInfo,
|
|
46
52
|
});
|
|
47
53
|
}
|
|
48
54
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
2
|
import { BaseApiController } from '../base/BaseApiController';
|
|
3
3
|
export declare class UserAccountManageApi extends BaseApiController {
|
|
4
|
-
ctx: Context;
|
|
4
|
+
protected ctx: Context;
|
|
5
5
|
getUserAccountList(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
6
6
|
getUserAccountOne(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
7
7
|
updateUserAccount(): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
@@ -29,7 +29,7 @@ let WorkbenchMangeApi = class WorkbenchMangeApi extends BaseApiController_1.Base
|
|
|
29
29
|
this.workbenchService.clearCache();
|
|
30
30
|
const body = this.ctx.request.body;
|
|
31
31
|
const dataObj = body.data || {};
|
|
32
|
-
dataObj.html_content = dataObj.html_content ||
|
|
32
|
+
dataObj.html_content = dataObj.html_content || '<html>hello</html>';
|
|
33
33
|
return this.executeSysSimpleSQL(SystemTables_1.SystemTables.sys_workbench, keys_1.KeysOfSimpleSQL.SIMPLE_INSERT, {
|
|
34
34
|
validateCfg: {
|
|
35
35
|
'data.workbench_code': [keys_1.KeysOfValidators.REQUIRED, keys_1.KeysOfValidators.STRING],
|
|
@@ -75,7 +75,7 @@ let AuthController = class AuthController extends BaseApiController_1.BaseApiCon
|
|
|
75
75
|
const { unsaltedPwd } = this.ctx.request.body;
|
|
76
76
|
const loginName = this.ctx.userSession.getSessionInfo().loginName;
|
|
77
77
|
if (loginName === 'devopsviewer') {
|
|
78
|
-
return common_dto_1.CommonResult.errorRes(
|
|
78
|
+
return common_dto_1.CommonResult.errorRes('开放体验账号不支持修改密码');
|
|
79
79
|
}
|
|
80
80
|
return this.userAccountService.chgUserPassword(loginName, unsaltedPwd);
|
|
81
81
|
}
|
|
@@ -52,10 +52,14 @@ let AppRenderController = class AppRenderController extends BaseApiController_1.
|
|
|
52
52
|
const workbenchInfo = await this.workbenchService.getCurrentHostWorkbenchInfo();
|
|
53
53
|
const html_content = appInfo.html_content || '<b style="color: red">错误:未配置HTML模版,请检查!!</b>';
|
|
54
54
|
const userInfo = this.getUserSessionInfo();
|
|
55
|
-
const fatcmscsrftoken = await crypto_utils_1.privateAES.time_encrypt_utf8_base64(
|
|
55
|
+
const fatcmscsrftoken = await crypto_utils_1.privateAES.time_encrypt_utf8_base64('' + Date.now());
|
|
56
56
|
const utils = (0, render_utils_1.createRenderUtils)({
|
|
57
57
|
ctx: this.ctx,
|
|
58
|
-
appInfo,
|
|
58
|
+
appInfo,
|
|
59
|
+
workbenchInfo,
|
|
60
|
+
userInfo,
|
|
61
|
+
package_assets: appInfo.package_assets,
|
|
62
|
+
fatcmscsrftoken,
|
|
59
63
|
});
|
|
60
64
|
return this.ctx.renderString(html_content, { appInfo, workbenchInfo, userInfo, utils }, { viewEngine: 'ejs' });
|
|
61
65
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
2
|
import { CurdMixService } from '../service/curd/CurdMixService';
|
|
3
|
-
import { BaseApiController } from
|
|
3
|
+
import { BaseApiController } from './base/BaseApiController';
|
|
4
4
|
export declare class TestApiController extends BaseApiController {
|
|
5
5
|
protected ctx: Context;
|
|
6
6
|
protected curdMixService: CurdMixService;
|
|
@@ -18,16 +18,16 @@ const keys_1 = require("../libs/crud-pro/models/keys");
|
|
|
18
18
|
let TestApiController = class TestApiController extends BaseApiController_1.BaseApiController {
|
|
19
19
|
async testPgQuery() {
|
|
20
20
|
const cfgModel = {
|
|
21
|
-
sqlTable:
|
|
21
|
+
sqlTable: 'test_table1',
|
|
22
22
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
23
|
-
sqlDatabase:
|
|
23
|
+
sqlDatabase: 'postgres_test1',
|
|
24
24
|
sqlDbType: keys_1.SqlDbType.postgres,
|
|
25
25
|
updateCfg: {},
|
|
26
26
|
};
|
|
27
27
|
return this.curdMixService.executeCrudByCfg({
|
|
28
28
|
condition: {
|
|
29
|
-
int4:
|
|
30
|
-
}
|
|
29
|
+
int4: '222',
|
|
30
|
+
},
|
|
31
31
|
}, cfgModel);
|
|
32
32
|
}
|
|
33
33
|
};
|
|
@@ -4,7 +4,7 @@ import { SqlCfgModel } from './SqlCfgModel';
|
|
|
4
4
|
import { Transaction } from './Transaction';
|
|
5
5
|
import { ICrudProCfg, ILogger, IVisitor } from '../interfaces';
|
|
6
6
|
import { IExecuteContextFunc } from './ExecuteContextFunc';
|
|
7
|
-
import { ResModelFlexible } from
|
|
7
|
+
import { ResModelFlexible } from './ResModel';
|
|
8
8
|
declare class ExecuteContext {
|
|
9
9
|
private transaction;
|
|
10
10
|
private logger;
|
|
@@ -60,7 +60,7 @@ class CrudProCachedCfgService extends CrudProServiceBase_1.CrudProServiceBase {
|
|
|
60
60
|
const baseInfo = {
|
|
61
61
|
sqlTable: methodsTableName,
|
|
62
62
|
sqlDatabase: sysDatabaseName,
|
|
63
|
-
sqlDbType: sysDatabaseDbType
|
|
63
|
+
sqlDbType: sysDatabaseDbType,
|
|
64
64
|
};
|
|
65
65
|
const [rows] = await this.executeUnsafeQuery(baseInfo, sql);
|
|
66
66
|
const rows2 = rows;
|
|
@@ -32,13 +32,14 @@ class CrudProExecuteSqlService extends CrudProServiceBase_1.CrudProServiceBase {
|
|
|
32
32
|
const executeSqlArgs = this.handleExecuteSqlArgsByResModel(exeCtx, sqlCfgModel.executeSqlArgs || []);
|
|
33
33
|
let sqlRes;
|
|
34
34
|
let queryRes;
|
|
35
|
-
if (sqlCfgModel.sqlDbType === keys_1.SqlDbType.postgres) {
|
|
35
|
+
if (sqlCfgModel.sqlDbType === keys_1.SqlDbType.postgres) {
|
|
36
|
+
// import { PoolClient } from 'pg';
|
|
36
37
|
const pgClient = connection;
|
|
37
38
|
const pgSql = (0, convertPgSql_1.replaceQuestionMarks)(sqlCfgModel.executeSql);
|
|
38
39
|
this.logger.info('executeSqlCfgModel_postgres', pgSql, executeSqlArgs, sqlCfgModel.resPicker);
|
|
39
40
|
queryRes = await pgClient.query({
|
|
40
41
|
text: pgSql,
|
|
41
|
-
values: executeSqlArgs || []
|
|
42
|
+
values: executeSqlArgs || [],
|
|
42
43
|
});
|
|
43
44
|
sqlRes = (0, convertPgType_1.pickAndConvertPgRows)(queryRes);
|
|
44
45
|
}
|
|
@@ -59,7 +60,7 @@ class CrudProExecuteSqlService extends CrudProServiceBase_1.CrudProServiceBase {
|
|
|
59
60
|
exeCtx.setResModelItem(sqlCfgModel.resName, resObject);
|
|
60
61
|
}
|
|
61
62
|
handleExecuteSqlArgsByResModel(exeCtx, executeSqlArgs) {
|
|
62
|
-
return executeSqlArgs.map(
|
|
63
|
+
return executeSqlArgs.map(arg => {
|
|
63
64
|
if (arg && typeof arg === 'object' && typeof arg.___GENERATE_GET_RES_ATTR___ === 'string') {
|
|
64
65
|
const word = arg.___GENERATE_GET_RES_ATTR___;
|
|
65
66
|
if (word.startsWith(keys_1.KeysOfCustomSQL.SQL_PICK_RES_AS_NUMBER)) {
|
|
@@ -70,7 +71,7 @@ class CrudProExecuteSqlService extends CrudProServiceBase_1.CrudProServiceBase {
|
|
|
70
71
|
}
|
|
71
72
|
if (word.startsWith(keys_1.KeysOfCustomSQL.SQL_PICK_RES_AS_STRING)) {
|
|
72
73
|
const resName = MixinUtils_1.MixinUtils.removeStringPrefix(word, keys_1.KeysOfCustomSQL.SQL_PICK_RES_AS_STRING);
|
|
73
|
-
return String(exeCtx.getResModelItemLodash(resName) ||
|
|
74
|
+
return String(exeCtx.getResModelItemLodash(resName) || '');
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
return arg;
|
|
@@ -201,13 +202,13 @@ class CrudProExecuteSqlService extends CrudProServiceBase_1.CrudProServiceBase {
|
|
|
201
202
|
if (sqlCfgModel.sqlDbType === keys_1.SqlDbType.postgres) {
|
|
202
203
|
return {
|
|
203
204
|
insertId: _.get(queryRes, 'rows[0].id'),
|
|
204
|
-
affectedRows: _.get(queryRes, 'rowCount')
|
|
205
|
+
affectedRows: _.get(queryRes, 'rowCount'),
|
|
205
206
|
};
|
|
206
207
|
}
|
|
207
208
|
if (sqlCfgModel.sqlDbType === keys_1.SqlDbType.sqlserver) {
|
|
208
209
|
return {
|
|
209
210
|
insertId: _.get(queryRes, 'recordset[0].id'),
|
|
210
|
-
affectedRows: _.get(queryRes, 'rowsAffected[0]')
|
|
211
|
+
affectedRows: _.get(queryRes, 'rowsAffected[0]'),
|
|
211
212
|
};
|
|
212
213
|
}
|
|
213
214
|
return sqlRes;
|