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
|
@@ -1,9 +1,9 @@
|
|
|
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 '
|
|
5
|
+
import { checkPermission } from '@/middleware/permission.middleware';
|
|
6
|
+
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
7
7
|
|
|
8
8
|
@Controller('/ns/api/manage/app', { middleware: [checkPermission(SystemFuncCode.AppMangeRead)] })
|
|
9
9
|
export class AppMangeApi extends BaseApiController {
|
|
@@ -31,7 +31,7 @@ export class AppMangeApi extends BaseApiController {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
@Post('/updateApp',{ middleware: [checkPermission(SystemFuncCode.AppMangeWrite)] })
|
|
34
|
+
@Post('/updateApp', { middleware: [checkPermission(SystemFuncCode.AppMangeWrite)] })
|
|
35
35
|
async updateApp() {
|
|
36
36
|
return this.executeSysSimpleSQL('sys_app', KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
37
37
|
validateCfg: {
|
|
@@ -41,7 +41,7 @@ export class AppMangeApi extends BaseApiController {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
@Post('/deleteApp',{ middleware: [checkPermission(SystemFuncCode.AppMangeWrite)] })
|
|
44
|
+
@Post('/deleteApp', { middleware: [checkPermission(SystemFuncCode.AppMangeWrite)] })
|
|
45
45
|
async deleteApp() {
|
|
46
46
|
return this.executeSysSimpleSQL('sys_app', KeysOfSimpleSQL.SIMPLE_DELETE, {
|
|
47
47
|
validateCfg: {
|
|
@@ -1,9 +1,9 @@
|
|
|
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 '
|
|
5
|
+
import { checkPermission } from '@/middleware/permission.middleware';
|
|
6
|
+
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
7
7
|
|
|
8
8
|
@Controller('/ns/api/manage/appPage', { middleware: [checkPermission(SystemFuncCode.AppPageMangeRead)] })
|
|
9
9
|
export class AppPageMangeApi extends BaseApiController {
|
|
@@ -1,6 +1,6 @@
|
|
|
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
5
|
|
|
6
6
|
const tableName = 'sys_app_schema_history';
|
|
@@ -1,9 +1,9 @@
|
|
|
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 '
|
|
5
|
+
import { checkPermission } from '@/middleware/permission.middleware';
|
|
6
|
+
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
7
7
|
|
|
8
8
|
@Controller('/ns/api/manage/crudMethod', { middleware: [checkPermission(SystemFuncCode.CrudMethodApiRead)] })
|
|
9
9
|
export class CrudMethodsMangeApi extends BaseApiController {
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import * as _ from 'lodash';
|
|
2
1
|
import { Config, Controller, Post } from '@midwayjs/core';
|
|
3
2
|
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
-
import { parseCreateSqlToTitleMap } from '
|
|
5
|
-
import { checkPermission } from '
|
|
6
|
-
import { SystemFuncCode } from '
|
|
7
|
-
import { KeyOfCrudTypes, KeysOfSimpleSQL, SqlDbType } from '
|
|
8
|
-
import { SystemTables } from '
|
|
9
|
-
import { CommonException } from
|
|
10
|
-
import { parseDatabaseName, toDatabaseNameStr } from
|
|
11
|
-
import { CommonResult } from
|
|
12
|
-
|
|
3
|
+
import { parseCreateSqlToTitleMap } from '@/libs/utils/parseCreateSql';
|
|
4
|
+
import { checkPermission } from '@/middleware/permission.middleware';
|
|
5
|
+
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
6
|
+
import { KeyOfCrudTypes, KeysOfSimpleSQL, SqlDbType } from '@/libs/crud-pro/models/keys';
|
|
7
|
+
import { SystemTables } from '@/models/SystemTables';
|
|
8
|
+
import { CommonException } from '@/libs/crud-pro/exceptions';
|
|
9
|
+
import { parseDatabaseName, toDatabaseNameStr } from '@/libs/crud-pro/utils/DatabaseName';
|
|
10
|
+
import { CommonResult } from '@/libs/utils/common-dto';
|
|
13
11
|
|
|
14
12
|
@Controller('/ns/api/manage/CrudStandardDesignApi', { middleware: [checkPermission(SystemFuncCode.CrudStandardDesignRead)] })
|
|
15
13
|
export class CrudStandardDesignApi extends BaseApiController {
|
|
@@ -39,11 +37,7 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
39
37
|
const postgresObjList = toSelectList(postgresList, SqlDbType.postgres);
|
|
40
38
|
const sqlserverObjList = toSelectList(sqlServerList, SqlDbType.sqlserver);
|
|
41
39
|
|
|
42
|
-
const databaseList = [
|
|
43
|
-
...mysqlObjList,
|
|
44
|
-
...postgresObjList,
|
|
45
|
-
...sqlserverObjList,
|
|
46
|
-
].filter((obj: any) => {
|
|
40
|
+
const databaseList = [...mysqlObjList, ...postgresObjList, ...sqlserverObjList].filter((obj: any) => {
|
|
47
41
|
const value = '' + obj.value;
|
|
48
42
|
return !value.endsWith('_fatcms_inner_demo_config');
|
|
49
43
|
});
|
|
@@ -60,11 +54,11 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
60
54
|
const { dbType, dbName } = parseDatabaseName(databaseName);
|
|
61
55
|
|
|
62
56
|
if (dbType === SqlDbType.postgres) {
|
|
63
|
-
return this.getTableListOfPostgreSQL(dbName)
|
|
57
|
+
return this.getTableListOfPostgreSQL(dbName);
|
|
64
58
|
}
|
|
65
59
|
|
|
66
60
|
if (dbType === SqlDbType.sqlserver) {
|
|
67
|
-
return this.getTableListOfSqlserver(dbName)
|
|
61
|
+
return this.getTableListOfSqlserver(dbName);
|
|
68
62
|
}
|
|
69
63
|
|
|
70
64
|
const res = await this.curdMixService.executeSQL({
|
|
@@ -83,8 +77,8 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
83
77
|
label: tableName,
|
|
84
78
|
dbName,
|
|
85
79
|
dbType,
|
|
86
|
-
tableName
|
|
87
|
-
}
|
|
80
|
+
tableName,
|
|
81
|
+
};
|
|
88
82
|
});
|
|
89
83
|
return CommonResult.successRes(tableNames);
|
|
90
84
|
}
|
|
@@ -95,11 +89,11 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
95
89
|
const { dbType, dbName } = parseDatabaseName(databaseName);
|
|
96
90
|
|
|
97
91
|
if (dbType === SqlDbType.postgres) {
|
|
98
|
-
return this.getTableFieldsOfPostgreSQL(dbName, tableName)
|
|
92
|
+
return this.getTableFieldsOfPostgreSQL(dbName, tableName);
|
|
99
93
|
}
|
|
100
94
|
|
|
101
95
|
if (dbType === SqlDbType.sqlserver) {
|
|
102
|
-
return this.getTableFieldsOfSqlServer(dbName, tableName)
|
|
96
|
+
return this.getTableFieldsOfSqlServer(dbName, tableName);
|
|
103
97
|
}
|
|
104
98
|
|
|
105
99
|
const tableDescribe = await this.curdMixService.executeSQL({
|
|
@@ -148,10 +142,7 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
148
142
|
*/
|
|
149
143
|
@Post('/getRoleOptionsList')
|
|
150
144
|
async getRoleOptionsList() {
|
|
151
|
-
return this.executeSysSimpleSQL(
|
|
152
|
-
SystemTables.sys_perm_role,
|
|
153
|
-
KeysOfSimpleSQL.SIMPLE_QUERY_PAGE
|
|
154
|
-
);
|
|
145
|
+
return this.executeSysSimpleSQL(SystemTables.sys_perm_role, KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
|
|
155
146
|
}
|
|
156
147
|
|
|
157
148
|
/**
|
|
@@ -159,19 +150,13 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
159
150
|
*/
|
|
160
151
|
@Post('/getFuncOptionsList')
|
|
161
152
|
async getFuncOptionsList() {
|
|
162
|
-
return this.executeSysSimpleSQL(
|
|
163
|
-
SystemTables.sys_perm_func,
|
|
164
|
-
KeysOfSimpleSQL.SIMPLE_QUERY_PAGE
|
|
165
|
-
);
|
|
153
|
+
return this.executeSysSimpleSQL(SystemTables.sys_perm_func, KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
|
|
166
154
|
}
|
|
167
155
|
|
|
168
156
|
private async getTableListOfSqlserver(dbName: string): Promise<CommonResult> {
|
|
169
157
|
const dbConfig = this.sqlserver2Config[dbName];
|
|
170
158
|
if (!dbConfig) {
|
|
171
|
-
throw new CommonException(
|
|
172
|
-
'DB_NOT_FOUND',
|
|
173
|
-
'数据库配置没有找到:' + dbName
|
|
174
|
-
);
|
|
159
|
+
throw new CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
|
|
175
160
|
}
|
|
176
161
|
|
|
177
162
|
const dbType = SqlDbType.sqlserver;
|
|
@@ -185,7 +170,6 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
185
170
|
executeSqlArgs: [],
|
|
186
171
|
});
|
|
187
172
|
|
|
188
|
-
|
|
189
173
|
const tableNames: string[] = arr.map(v => {
|
|
190
174
|
const tableName = v.tablename;
|
|
191
175
|
return {
|
|
@@ -200,31 +184,17 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
200
184
|
}
|
|
201
185
|
|
|
202
186
|
private async getTableListOfPostgreSQL(dbName: string): Promise<CommonResult> {
|
|
203
|
-
|
|
204
187
|
const dbConfig = this.postgres2Config[dbName];
|
|
205
188
|
if (!dbConfig) {
|
|
206
|
-
throw new CommonException(
|
|
207
|
-
'DB_NOT_FOUND',
|
|
208
|
-
'数据库配置没有找到:' + dbName
|
|
209
|
-
);
|
|
189
|
+
throw new CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
|
|
210
190
|
}
|
|
211
191
|
|
|
212
192
|
const dbType = SqlDbType.postgres;
|
|
213
193
|
const schemaname = 'public';
|
|
214
194
|
|
|
215
|
-
const tableListSql =
|
|
216
|
-
'' +
|
|
217
|
-
'SELECT tablename\n' +
|
|
218
|
-
'FROM pg_tables\n' +
|
|
219
|
-
`WHERE schemaname = '${schemaname}' \n` +
|
|
220
|
-
'ORDER BY tablename;';
|
|
195
|
+
const tableListSql = '' + 'SELECT tablename\n' + 'FROM pg_tables\n' + `WHERE schemaname = '${schemaname}' \n` + 'ORDER BY tablename;';
|
|
221
196
|
|
|
222
|
-
const viewListSql =
|
|
223
|
-
'' +
|
|
224
|
-
'SELECT viewname as tablename\n' +
|
|
225
|
-
'FROM pg_views\n' +
|
|
226
|
-
`WHERE schemaname = '${schemaname}' \n` +
|
|
227
|
-
'ORDER BY viewname;';
|
|
197
|
+
const viewListSql = '' + 'SELECT viewname as tablename\n' + 'FROM pg_views\n' + `WHERE schemaname = '${schemaname}' \n` + 'ORDER BY viewname;';
|
|
228
198
|
|
|
229
199
|
const toSelectOptions = async (executeSql: string, tableType: string) => {
|
|
230
200
|
const arr = await this.curdMixService.executeSQL({
|
|
@@ -255,14 +225,10 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
255
225
|
return CommonResult.successRes(tableNameMerge);
|
|
256
226
|
}
|
|
257
227
|
|
|
258
|
-
|
|
259
228
|
private async getTableFieldsOfSqlServer(dbName: string, tableName: string): Promise<CommonResult> {
|
|
260
229
|
const dbConfig = this.sqlserver2Config[dbName];
|
|
261
230
|
if (!dbConfig) {
|
|
262
|
-
throw new CommonException(
|
|
263
|
-
'DB_NOT_FOUND',
|
|
264
|
-
'数据库配置没有找到:' + dbName
|
|
265
|
-
);
|
|
231
|
+
throw new CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
|
|
266
232
|
}
|
|
267
233
|
|
|
268
234
|
const columnArraySql =
|
|
@@ -304,15 +270,7 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
304
270
|
});
|
|
305
271
|
|
|
306
272
|
const fields = columnArray.map(columnObj => {
|
|
307
|
-
const {
|
|
308
|
-
column_name,
|
|
309
|
-
is_nullable,
|
|
310
|
-
column_default,
|
|
311
|
-
data_type,
|
|
312
|
-
is_identity,
|
|
313
|
-
column_description,
|
|
314
|
-
...others
|
|
315
|
-
} = columnObj;
|
|
273
|
+
const { column_name, is_nullable, column_default, data_type, is_identity, column_description, ...others } = columnObj;
|
|
316
274
|
|
|
317
275
|
return {
|
|
318
276
|
fieldIndex: column_name || '',
|
|
@@ -336,10 +294,7 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
336
294
|
private async getTableFieldsOfPostgreSQL(dbName: string, tableName: string) {
|
|
337
295
|
const dbConfig = this.postgres2Config[dbName];
|
|
338
296
|
if (!dbConfig) {
|
|
339
|
-
throw new CommonException(
|
|
340
|
-
'DB_NOT_FOUND',
|
|
341
|
-
'数据库配置没有找到:' + dbName
|
|
342
|
-
);
|
|
297
|
+
throw new CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
|
|
343
298
|
}
|
|
344
299
|
|
|
345
300
|
const schemaname = 'public';
|
|
@@ -365,14 +320,7 @@ export class CrudStandardDesignApi extends BaseApiController {
|
|
|
365
320
|
});
|
|
366
321
|
|
|
367
322
|
const fields = columnArray.map(columnObj => {
|
|
368
|
-
const {
|
|
369
|
-
column_name,
|
|
370
|
-
is_nullable,
|
|
371
|
-
column_default,
|
|
372
|
-
data_type,
|
|
373
|
-
is_identity,
|
|
374
|
-
...others
|
|
375
|
-
} = columnObj;
|
|
323
|
+
const { column_name, is_nullable, column_default, data_type, is_identity, ...others } = columnObj;
|
|
376
324
|
|
|
377
325
|
return {
|
|
378
326
|
fieldIndex: column_name || '',
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Inject, Controller, 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 '
|
|
5
|
+
import { checkPermission } from '@/middleware/permission.middleware';
|
|
6
|
+
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
7
7
|
|
|
8
8
|
@Controller('/ns/api/manage/dataDict', { middleware: [checkPermission(SystemFuncCode.DataDictMangeRead)] })
|
|
9
9
|
export class DataDictManageApi extends BaseApiController {
|
|
10
10
|
@Inject()
|
|
11
|
-
ctx: Context;
|
|
11
|
+
protected ctx: Context;
|
|
12
12
|
|
|
13
13
|
@Post('/getDataDictList')
|
|
14
14
|
async getDataDictList() {
|
|
@@ -1,72 +1,70 @@
|
|
|
1
|
-
import {Controller, Fields, Files, Inject, Post, Query} from '@midwayjs/core';
|
|
2
|
-
import {Context} from '@midwayjs/koa';
|
|
3
|
-
import {BaseApiController} from '../base/BaseApiController';
|
|
4
|
-
import {checkPermission} from '../../middleware/permission.middleware';
|
|
5
|
-
import {SystemFuncCode} from '../../models/SystemPerm';
|
|
6
|
-
import {CommonResult} from
|
|
7
|
-
import {AccessType, UploadCategoryType} from
|
|
8
|
-
import {BizException} from
|
|
9
|
-
import {FileCenterService, toDownloadPaths} from '../../service/FileCenterService';
|
|
10
|
-
import {SystemTables} from
|
|
11
|
-
import {KeysOfSimpleSQL} from
|
|
12
|
-
import {WorkbenchService} from
|
|
1
|
+
import { Controller, Fields, Files, Inject, Post, Query } from '@midwayjs/core';
|
|
2
|
+
import { Context } from '@midwayjs/koa';
|
|
3
|
+
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
+
import { checkPermission } from '../../middleware/permission.middleware';
|
|
5
|
+
import { SystemFuncCode } from '../../models/SystemPerm';
|
|
6
|
+
import { CommonResult } from '../../libs/utils/common-dto';
|
|
7
|
+
import { AccessType, UploadCategoryType } from '../../models/bizmodels';
|
|
8
|
+
import { BizException } from '../../models/devops';
|
|
9
|
+
import { FileCenterService, toDownloadPaths } from '../../service/FileCenterService';
|
|
10
|
+
import { SystemTables } from '../../models/SystemTables';
|
|
11
|
+
import { KeysOfSimpleSQL } from '../../libs/crud-pro/models/keys';
|
|
12
|
+
import { WorkbenchService } from '../../service/WorkbenchService';
|
|
13
13
|
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
interface IReleaseAssetsParams {
|
|
17
|
-
cdnResources: any[]
|
|
18
|
-
packageName: string
|
|
19
|
-
packageVersion: string
|
|
16
|
+
cdnResources: any[];
|
|
17
|
+
packageName: string;
|
|
18
|
+
packageVersion: string;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
|
|
23
21
|
function toAssetsSchema(fileList: any) {
|
|
24
22
|
for (let i = 0; i < fileList.length; i++) {
|
|
25
23
|
const fileListElement = fileList[i];
|
|
26
|
-
fileListElement.settingKey =
|
|
24
|
+
fileListElement.settingKey = 'assets' + i;
|
|
27
25
|
}
|
|
28
26
|
return {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
27
|
+
schema: [
|
|
28
|
+
{
|
|
29
|
+
title: '资源配置',
|
|
30
|
+
name: 'fileList',
|
|
31
|
+
type: 'array',
|
|
32
|
+
properties: {
|
|
33
|
+
fileUrl: { label: '文件URL', component: 'Input', xProps: { hasClear: true }, width: 500 },
|
|
34
|
+
fileType: {
|
|
35
|
+
label: '文件类型',
|
|
36
|
+
component: 'Select',
|
|
37
|
+
enums: [
|
|
38
|
+
{ label: 'js', value: 'js' },
|
|
39
|
+
{ label: 'css', value: 'css' },
|
|
40
|
+
],
|
|
41
|
+
xProps: {
|
|
42
|
+
hasClear: true,
|
|
43
|
+
},
|
|
44
|
+
width: 500,
|
|
44
45
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
isModule: {
|
|
47
|
+
label: 'isModule',
|
|
48
|
+
component: 'Select',
|
|
49
|
+
enums: [
|
|
50
|
+
{ label: 'true', value: true },
|
|
51
|
+
{ label: 'false', value: false },
|
|
52
|
+
],
|
|
53
|
+
xProps: {
|
|
54
|
+
hasClear: true,
|
|
55
|
+
},
|
|
56
|
+
width: 500,
|
|
56
57
|
},
|
|
57
|
-
width: 500
|
|
58
58
|
},
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
data: {
|
|
62
|
+
fileList: fileList,
|
|
63
|
+
},
|
|
65
64
|
};
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
|
|
69
|
-
@Controller('/ns/api/manage/deploy', { middleware: [checkPermission([ SystemFuncCode.AppMangeRead, SystemFuncCode.WorkbenchMangeRead])] })
|
|
67
|
+
@Controller('/ns/api/manage/deploy', { middleware: [checkPermission([SystemFuncCode.AppMangeRead, SystemFuncCode.WorkbenchMangeRead])] })
|
|
70
68
|
export class DeployManageApi extends BaseApiController {
|
|
71
69
|
@Inject()
|
|
72
70
|
protected ctx: Context;
|
|
@@ -109,7 +107,6 @@ export class DeployManageApi extends BaseApiController {
|
|
|
109
107
|
return CommonResult.successRes(data);
|
|
110
108
|
}
|
|
111
109
|
|
|
112
|
-
|
|
113
110
|
/**
|
|
114
111
|
* 资源文件让其生效
|
|
115
112
|
*/
|
|
@@ -124,59 +121,55 @@ export class DeployManageApi extends BaseApiController {
|
|
|
124
121
|
throw new BizException('packageName参数小于5');
|
|
125
122
|
}
|
|
126
123
|
|
|
127
|
-
const cdnResources = params.cdnResources
|
|
124
|
+
const cdnResources = params.cdnResources;
|
|
128
125
|
if (!Array.isArray(cdnResources) || cdnResources.length === 0) {
|
|
129
126
|
throw new BizException('cdnResources参数不存在');
|
|
130
127
|
}
|
|
131
128
|
|
|
132
|
-
const {SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
133
|
-
|
|
134
|
-
const workbench = await this.curdMixService.executeCrudByCfg(
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
130
|
+
|
|
131
|
+
const workbench = await this.curdMixService.executeCrudByCfg(
|
|
132
|
+
{
|
|
133
|
+
data: {
|
|
134
|
+
package_assets: JSON.stringify(toAssetsSchema(cdnResources)),
|
|
135
|
+
},
|
|
136
|
+
condition: {
|
|
137
|
+
package_name: params.packageName,
|
|
138
|
+
},
|
|
137
139
|
},
|
|
138
|
-
|
|
139
|
-
|
|
140
|
+
{
|
|
141
|
+
sqlTable: SystemTables.sys_workbench,
|
|
142
|
+
sqlDatabase: SystemDbName,
|
|
143
|
+
sqlDbType: SystemDbType,
|
|
144
|
+
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
140
145
|
}
|
|
141
|
-
|
|
142
|
-
sqlTable: SystemTables.sys_workbench,
|
|
143
|
-
sqlDatabase: SystemDbName,
|
|
144
|
-
sqlDbType: SystemDbType,
|
|
145
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE
|
|
146
|
-
});
|
|
146
|
+
);
|
|
147
147
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
const app = await this.curdMixService.executeCrudByCfg(
|
|
149
|
+
{
|
|
150
|
+
data: {
|
|
151
|
+
package_assets: JSON.stringify(toAssetsSchema(cdnResources)),
|
|
152
|
+
},
|
|
153
|
+
condition: {
|
|
154
|
+
package_name: params.packageName,
|
|
155
|
+
},
|
|
153
156
|
},
|
|
154
|
-
|
|
155
|
-
|
|
157
|
+
{
|
|
158
|
+
sqlTable: SystemTables.sys_app,
|
|
159
|
+
sqlDatabase: SystemDbName,
|
|
160
|
+
sqlDbType: SystemDbType,
|
|
161
|
+
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
156
162
|
}
|
|
157
|
-
|
|
158
|
-
sqlTable: SystemTables.sys_app,
|
|
159
|
-
sqlDatabase: SystemDbName,
|
|
160
|
-
sqlDbType: SystemDbType,
|
|
161
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE
|
|
162
|
-
});
|
|
163
|
-
|
|
163
|
+
);
|
|
164
164
|
|
|
165
165
|
this.workbenchService.clearCache();
|
|
166
166
|
|
|
167
167
|
const workbenchAffected = workbench.getResModelItem('affected') || {};
|
|
168
168
|
const appAffected = app.getResModelItem('affected') || {};
|
|
169
169
|
|
|
170
|
-
const result = CommonResult.successRes({workbenchAffected, appAffected});
|
|
170
|
+
const result = CommonResult.successRes({ workbenchAffected, appAffected });
|
|
171
171
|
|
|
172
|
-
result.message = `${cdnResources.length}个文件,更新到${workbenchAffected.affectedRows}个站点模版;更新到${appAffected.affectedRows}
|
|
172
|
+
result.message = `${cdnResources.length}个文件,更新到${workbenchAffected.affectedRows}个站点模版;更新到${appAffected.affectedRows}个应用模版,`;
|
|
173
173
|
return result;
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
175
|
}
|
|
@@ -30,7 +30,7 @@ export class DocLibManageApi extends BaseApiController {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
@Post('/createDocLib',
|
|
33
|
+
@Post('/createDocLib', { middleware: [checkPermission(SystemFuncCode.DocMangeWrite)] })
|
|
34
34
|
async createDocLib() {
|
|
35
35
|
return this.executeSysSimpleSQL(SystemTables.sys_doc_lib, KeysOfSimpleSQL.SIMPLE_INSERT, {
|
|
36
36
|
validateCfg: {
|
|
@@ -42,7 +42,7 @@ export class DocLibManageApi extends BaseApiController {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
@Post('/updateDocLib',
|
|
45
|
+
@Post('/updateDocLib', { middleware: [checkPermission(SystemFuncCode.DocMangeWrite)] })
|
|
46
46
|
async updateDocLib() {
|
|
47
47
|
return this.executeSysSimpleSQL(SystemTables.sys_doc_lib, KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
48
48
|
validateCfg: {
|
|
@@ -55,7 +55,7 @@ export class DocLibManageApi extends BaseApiController {
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
@Post('/deleteDocLib',
|
|
58
|
+
@Post('/deleteDocLib', { middleware: [checkPermission(SystemFuncCode.DocMangeWrite)] })
|
|
59
59
|
async deleteDocLib() {
|
|
60
60
|
return this.executeSysSimpleSQL(SystemTables.sys_doc_lib, KeysOfSimpleSQL.SIMPLE_DELETE, {
|
|
61
61
|
validateCfg: {
|
|
@@ -57,7 +57,7 @@ export class DocManageApi extends BaseApiController {
|
|
|
57
57
|
return false;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
@Post('/createDoc',
|
|
60
|
+
@Post('/createDoc', { middleware: [checkPermission(SystemFuncCode.DocMangeWrite)] })
|
|
61
61
|
async createDoc() {
|
|
62
62
|
const isPublish = this.setReleaseData();
|
|
63
63
|
return this.executeSysSimpleSQL('sys_doc', KeysOfSimpleSQL.SIMPLE_INSERT, {
|
|
@@ -70,7 +70,7 @@ export class DocManageApi extends BaseApiController {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
@Post('/updateDoc',
|
|
73
|
+
@Post('/updateDoc', { middleware: [checkPermission(SystemFuncCode.DocMangeWrite)] })
|
|
74
74
|
async updateDoc() {
|
|
75
75
|
const isPublish = this.setReleaseData();
|
|
76
76
|
const updateCfg = isPublish ? publishUpdateCfg : {};
|
|
@@ -85,7 +85,7 @@ export class DocManageApi extends BaseApiController {
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
@Post('/deleteDoc',
|
|
88
|
+
@Post('/deleteDoc', { middleware: [checkPermission(SystemFuncCode.DocMangeWrite)] })
|
|
89
89
|
async deleteDoc() {
|
|
90
90
|
return this.executeSysSimpleSQL('sys_doc', KeysOfSimpleSQL.SIMPLE_DELETE, {
|
|
91
91
|
validateCfg: {
|
|
@@ -14,50 +14,45 @@ export class MenuManageApi extends BaseApiController {
|
|
|
14
14
|
@Post('/getMenuList')
|
|
15
15
|
async getMenuList() {
|
|
16
16
|
return this.executeSysSimpleSQL(SystemTables.sys_menus, KeysOfSimpleSQL.SIMPLE_QUERY_PAGE, {
|
|
17
|
-
updateCfg: {
|
|
18
|
-
},
|
|
17
|
+
updateCfg: {},
|
|
19
18
|
});
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
@Post('/getMenuOne')
|
|
23
22
|
async getMenuOne() {
|
|
24
23
|
return this.executeSysSimpleSQL(SystemTables.sys_menus, KeysOfSimpleSQL.SIMPLE_QUERY_ONE, {
|
|
25
|
-
updateCfg: {
|
|
26
|
-
},
|
|
24
|
+
updateCfg: {},
|
|
27
25
|
});
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
@Post('/createMenu',
|
|
28
|
+
@Post('/createMenu', { middleware: [checkPermission(SystemFuncCode.MenuMangeWrite)] })
|
|
31
29
|
async createMenu() {
|
|
32
30
|
return this.executeSysSimpleSQL(SystemTables.sys_menus, KeysOfSimpleSQL.SIMPLE_INSERT, {
|
|
33
31
|
validateCfg: {
|
|
34
32
|
'data.menu_code': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
|
|
35
33
|
'data.menu_title': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
|
|
36
34
|
},
|
|
37
|
-
updateCfg: {
|
|
38
|
-
},
|
|
35
|
+
updateCfg: {},
|
|
39
36
|
});
|
|
40
37
|
}
|
|
41
38
|
|
|
42
|
-
@Post('/updateMenu',
|
|
39
|
+
@Post('/updateMenu', { middleware: [checkPermission(SystemFuncCode.MenuMangeWrite)] })
|
|
43
40
|
async updateMenu() {
|
|
44
41
|
return this.executeSysSimpleSQL(SystemTables.sys_menus, KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
45
42
|
validateCfg: {
|
|
46
|
-
'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.INTEGER]
|
|
47
|
-
},
|
|
48
|
-
updateCfg: {
|
|
43
|
+
'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.INTEGER],
|
|
49
44
|
},
|
|
45
|
+
updateCfg: {},
|
|
50
46
|
});
|
|
51
47
|
}
|
|
52
48
|
|
|
53
|
-
@Post('/deleteMenu',
|
|
49
|
+
@Post('/deleteMenu', { middleware: [checkPermission(SystemFuncCode.MenuMangeWrite)] })
|
|
54
50
|
async deleteMenu() {
|
|
55
51
|
return this.executeSysSimpleSQL(SystemTables.sys_menus, KeysOfSimpleSQL.SIMPLE_DELETE, {
|
|
56
52
|
validateCfg: {
|
|
57
53
|
'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.INTEGER],
|
|
58
54
|
},
|
|
59
|
-
updateCfg: {
|
|
60
|
-
},
|
|
55
|
+
updateCfg: {},
|
|
61
56
|
});
|
|
62
57
|
}
|
|
63
58
|
}
|