midway-fatcms 0.0.1-beta.26 → 0.0.1-beta.28

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.
Files changed (171) hide show
  1. package/dist/controller/home.controller.js +2 -1
  2. package/dist/controller/render/AppRenderController.js +2 -1
  3. package/dist/models/bizmodels.d.ts +1 -0
  4. package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.js +1 -1
  5. package/dist/service/crudstd/CrudStdService.d.ts +0 -6
  6. package/dist/service/crudstd/CrudStdService.js +13 -33
  7. package/package.json +1 -5
  8. package/src/config/config.default.ts +0 -207
  9. package/src/config/seed/aeskey.txt +0 -1
  10. package/src/config/utils.ts +0 -22
  11. package/src/configuration.ts +0 -109
  12. package/src/controller/base/BaseApiController.ts +0 -170
  13. package/src/controller/gateway/AnyApiGatewayController.ts +0 -33
  14. package/src/controller/gateway/AsyncTaskController.ts +0 -157
  15. package/src/controller/gateway/CrudMtdGatewayController.ts +0 -111
  16. package/src/controller/gateway/CrudStdGatewayController.ts +0 -101
  17. package/src/controller/gateway/DocGatewayController.ts +0 -173
  18. package/src/controller/gateway/FileController.ts +0 -109
  19. package/src/controller/gateway/ProxyApiGatewayController.ts +0 -47
  20. package/src/controller/gateway/PublicApiController.ts +0 -142
  21. package/src/controller/gateway/StaticController.ts +0 -298
  22. package/src/controller/helpers.controller.ts +0 -161
  23. package/src/controller/home.controller.ts +0 -64
  24. package/src/controller/manage/AnyApiMangeApi.ts +0 -66
  25. package/src/controller/manage/AppLogMangeApi.ts +0 -53
  26. package/src/controller/manage/AppMangeApi.ts +0 -53
  27. package/src/controller/manage/AppPageMangeApi.ts +0 -52
  28. package/src/controller/manage/AppSchemaHistoryApi.ts +0 -49
  29. package/src/controller/manage/CrudMethodsMangeApi.ts +0 -49
  30. package/src/controller/manage/CrudStandardDesignApi.ts +0 -346
  31. package/src/controller/manage/DataDictManageApi.ts +0 -78
  32. package/src/controller/manage/DeployManageApi.ts +0 -175
  33. package/src/controller/manage/DocLibManageApi.ts +0 -69
  34. package/src/controller/manage/DocManageApi.ts +0 -99
  35. package/src/controller/manage/FileManageApi.ts +0 -45
  36. package/src/controller/manage/LowCodeTplManageApi.ts +0 -52
  37. package/src/controller/manage/MenuManageApi.ts +0 -58
  38. package/src/controller/manage/ProxyApiMangeApi.ts +0 -52
  39. package/src/controller/manage/SuperAdminManageApi.ts +0 -139
  40. package/src/controller/manage/SysConfigMangeApi.ts +0 -95
  41. package/src/controller/manage/SystemInfoManageApi.ts +0 -53
  42. package/src/controller/manage/UserAccountManageApi.ts +0 -94
  43. package/src/controller/manage/WorkbenchMangeApi.ts +0 -72
  44. package/src/controller/myinfo/AuthController.ts +0 -108
  45. package/src/controller/myinfo/MyInfoController.ts +0 -32
  46. package/src/controller/render/AppRenderController.ts +0 -79
  47. package/src/controller/test.controller.ts +0 -37
  48. package/src/filter/default.filter.ts +0 -13
  49. package/src/filter/notfound.filter.ts +0 -10
  50. package/src/index.ts +0 -106
  51. package/src/interface.ts +0 -31
  52. package/src/libs/crud-pro/CrudPro.ts +0 -165
  53. package/src/libs/crud-pro/defaultConfigs.ts +0 -15
  54. package/src/libs/crud-pro/exceptions.ts +0 -124
  55. package/src/libs/crud-pro/interfaces.ts +0 -190
  56. package/src/libs/crud-pro/models/ExecuteContext.ts +0 -120
  57. package/src/libs/crud-pro/models/ExecuteContextFunc.ts +0 -96
  58. package/src/libs/crud-pro/models/FuncContext.ts +0 -21
  59. package/src/libs/crud-pro/models/RequestCfgModel.ts +0 -141
  60. package/src/libs/crud-pro/models/RequestModel.ts +0 -141
  61. package/src/libs/crud-pro/models/ResModel.ts +0 -19
  62. package/src/libs/crud-pro/models/ServiceHub.ts +0 -32
  63. package/src/libs/crud-pro/models/SqlCfgModel.ts +0 -52
  64. package/src/libs/crud-pro/models/SqlSegArg.ts +0 -13
  65. package/src/libs/crud-pro/models/Transaction.ts +0 -73
  66. package/src/libs/crud-pro/models/TransactionMySQL.ts +0 -79
  67. package/src/libs/crud-pro/models/TransactionPostgres.ts +0 -91
  68. package/src/libs/crud-pro/models/TransactionSqlServer.ts +0 -102
  69. package/src/libs/crud-pro/models/keys.ts +0 -159
  70. package/src/libs/crud-pro/services/CrudProCachedCfgService.ts +0 -83
  71. package/src/libs/crud-pro/services/CrudProExecuteFuncService.ts +0 -128
  72. package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +0 -262
  73. package/src/libs/crud-pro/services/CrudProFieldUpdateService.ts +0 -60
  74. package/src/libs/crud-pro/services/CrudProFieldValidateService.ts +0 -180
  75. package/src/libs/crud-pro/services/CrudProGenSqlCondition.ts +0 -354
  76. package/src/libs/crud-pro/services/CrudProGenSqlService.ts +0 -185
  77. package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +0 -393
  78. package/src/libs/crud-pro/services/CrudProServiceBase.ts +0 -94
  79. package/src/libs/crud-pro/services/CrudProTableMetaService.ts +0 -86
  80. package/src/libs/crud-pro/services/CurdProServiceHub.ts +0 -92
  81. package/src/libs/crud-pro/sql.txt +0 -120
  82. package/src/libs/crud-pro/utils/CompareUtils.ts +0 -23
  83. package/src/libs/crud-pro/utils/DatabaseName.ts +0 -60
  84. package/src/libs/crud-pro/utils/DateTimeUtils.ts +0 -20
  85. package/src/libs/crud-pro/utils/MemoryRefreshCache.ts +0 -64
  86. package/src/libs/crud-pro/utils/MessageParseUtils.ts +0 -33
  87. package/src/libs/crud-pro/utils/MixinUtils.ts +0 -285
  88. package/src/libs/crud-pro/utils/ModelUtils.ts +0 -55
  89. package/src/libs/crud-pro/utils/MultiKeyMap.ts +0 -72
  90. package/src/libs/crud-pro/utils/SqlFuncUtils.ts +0 -29
  91. package/src/libs/crud-pro/utils/TypeUtils.ts +0 -188
  92. package/src/libs/crud-pro/utils/ValidateUtils.ts +0 -165
  93. package/src/libs/crud-pro/utils/pool/MySQLUtils.ts +0 -20
  94. package/src/libs/crud-pro/utils/pool/PostgresUtils.ts +0 -22
  95. package/src/libs/crud-pro/utils/pool/SqlServerUtils.ts +0 -22
  96. package/src/libs/crud-pro/utils/sqlConvert/convertColumnName.ts +0 -26
  97. package/src/libs/crud-pro/utils/sqlConvert/convertMix.ts +0 -26
  98. package/src/libs/crud-pro/utils/sqlConvert/convertMsSql.ts +0 -11
  99. package/src/libs/crud-pro/utils/sqlConvert/convertPgSql.ts +0 -11
  100. package/src/libs/crud-pro/utils/sqlConvert/convertPgType.ts +0 -129
  101. package/src/libs/global-config/global-config.ts +0 -78
  102. package/src/libs/utils/common-dto.ts +0 -52
  103. package/src/libs/utils/crypto-utils.ts +0 -50
  104. package/src/libs/utils/errorToString.ts +0 -61
  105. package/src/libs/utils/fatcms-request.ts +0 -103
  106. package/src/libs/utils/functions.ts +0 -73
  107. package/src/libs/utils/ordernum-utils.ts +0 -14
  108. package/src/libs/utils/parseConfig.ts +0 -54
  109. package/src/libs/utils/parseCreateSql.ts +0 -91
  110. package/src/libs/utils/render-utils.ts +0 -184
  111. package/src/middleware/forbidden.middleware.ts +0 -52
  112. package/src/middleware/global.middleware.ts +0 -280
  113. package/src/middleware/permission.middleware.ts +0 -80
  114. package/src/middleware/tx.middleware.ts +0 -30
  115. package/src/models/AsyncTaskModel.ts +0 -82
  116. package/src/models/RedisKeys.ts +0 -13
  117. package/src/models/SystemEntities.ts +0 -115
  118. package/src/models/SystemPerm.ts +0 -105
  119. package/src/models/SystemTables.ts +0 -27
  120. package/src/models/bizmodels.ts +0 -120
  121. package/src/models/contextLogger.ts +0 -132
  122. package/src/models/devops.ts +0 -17
  123. package/src/models/userSession.ts +0 -216
  124. package/src/schedule/anonymousContext.ts +0 -73
  125. package/src/schedule/index.ts +0 -12
  126. package/src/schedule/runSchedule.ts +0 -82
  127. package/src/schedule/scheduleNames.ts +0 -21
  128. package/src/service/AuthService.ts +0 -272
  129. package/src/service/EnumInfoService.ts +0 -130
  130. package/src/service/FileCenterService.ts +0 -395
  131. package/src/service/SysConfigService.ts +0 -37
  132. package/src/service/UserAccountService.ts +0 -107
  133. package/src/service/UserSessionService.ts +0 -78
  134. package/src/service/VisitStatService.ts +0 -166
  135. package/src/service/WorkbenchService.ts +0 -165
  136. package/src/service/anyapi/AnyApiSandboxService.ts +0 -121
  137. package/src/service/anyapi/AnyApiService.ts +0 -186
  138. package/src/service/asyncTask/AsyncTaskRunnerService.ts +0 -266
  139. package/src/service/asyncTask/AsyncTaskService.ts +0 -21
  140. package/src/service/asyncTask/handler/ExcelInfoModel.ts +0 -11
  141. package/src/service/asyncTask/handler/ExportExcelAsyncTaskHandler.ts +0 -245
  142. package/src/service/asyncTask/handler/ExportExcelByInnerHttpHandler.ts +0 -147
  143. package/src/service/asyncTask/handler/ExportExcelByStdCrudHandler.ts +0 -138
  144. package/src/service/base/ApiBaseService.ts +0 -42
  145. package/src/service/base/ApiRateLimiter.ts +0 -59
  146. package/src/service/base/BaseService.ts +0 -100
  147. package/src/service/base/RedisCacheService.ts +0 -38
  148. package/src/service/crudstd/CrudStdActionService.ts +0 -27
  149. package/src/service/crudstd/CrudStdConstant.ts +0 -62
  150. package/src/service/crudstd/CrudStdRelationService.ts +0 -78
  151. package/src/service/crudstd/CrudStdService.ts +0 -283
  152. package/src/service/curd/CrudProQuick.ts +0 -131
  153. package/src/service/curd/CurdMixByAccountService.ts +0 -90
  154. package/src/service/curd/CurdMixByDictService.ts +0 -114
  155. package/src/service/curd/CurdMixByLinkToCustomService.ts +0 -219
  156. package/src/service/curd/CurdMixBySysConfigService.ts +0 -78
  157. package/src/service/curd/CurdMixByWorkbenchService.ts +0 -71
  158. package/src/service/curd/CurdMixService.ts +0 -97
  159. package/src/service/curd/CurdMixUtils.ts +0 -311
  160. package/src/service/curd/CurdProService.ts +0 -229
  161. package/src/service/curd/fixCfgModel.ts +0 -139
  162. package/src/service/proxyapi/ProxyApiLoadService.ts +0 -174
  163. package/src/service/proxyapi/ProxyApiService.ts +0 -262
  164. package/src/service/proxyapi/ProxyApiUtils.ts +0 -32
  165. package/src/service/proxyapi/RouteHandler.ts +0 -8
  166. package/src/service/proxyapi/RouteTrie.ts +0 -74
  167. package/src/service/proxyapi/WeightedRandom.ts +0 -37
  168. package/src/service/proxyapi/WeightedRoundRobin.ts +0 -44
  169. package/src/views/404_app.html +0 -31
  170. package/src/views/404_workbench.html +0 -34
  171. package/src/views/static/favicon.ico +0 -0
@@ -1,52 +0,0 @@
1
- import { Controller, Inject, Post } from '@midwayjs/core';
2
- import { Context } from '@midwayjs/koa';
3
- import { KeysOfSimpleSQL, KeysOfValidators } from '@/libs/crud-pro/models/keys';
4
- import { BaseApiController } from '../base/BaseApiController';
5
- import { checkPermission } from '@/middleware/permission.middleware';
6
- import { SystemFuncCode } from '@/models/SystemPerm';
7
-
8
- @Controller('/ns/api/manage/appPage', { middleware: [checkPermission(SystemFuncCode.AppPageMangeRead)] })
9
- export class AppPageMangeApi extends BaseApiController {
10
- @Inject()
11
- ctx: Context;
12
-
13
- @Post('/getAppPageList')
14
- async getAppPageList() {
15
- return this.executeSysSimpleSQL('sys_app_page', KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
16
- }
17
-
18
- @Post('/getAppPageOne')
19
- async getAppPageOne() {
20
- return this.executeSysSimpleSQL('sys_app_page', KeysOfSimpleSQL.SIMPLE_QUERY_ONE);
21
- }
22
-
23
- @Post('/createAppPage', { middleware: [checkPermission(SystemFuncCode.AppPageMangeWrite)] })
24
- async createAppPage() {
25
- return this.executeSysSimpleSQL('sys_app_page', KeysOfSimpleSQL.SIMPLE_INSERT, {
26
- validateCfg: {
27
- 'data.app_code': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
28
- 'data.app_name': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
29
- 'data.page_path': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
30
- 'data.page_name': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
31
- },
32
- });
33
- }
34
-
35
- @Post('/updateAppPage', { middleware: [checkPermission(SystemFuncCode.AppPageMangeWrite)] })
36
- async updateAppPage() {
37
- return this.executeSysSimpleSQL('sys_app_page', KeysOfSimpleSQL.SIMPLE_UPDATE, {
38
- validateCfg: {
39
- 'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
40
- },
41
- });
42
- }
43
-
44
- @Post('/deleteAppPage', { middleware: [checkPermission(SystemFuncCode.AppPageMangeWrite)] })
45
- async deleteAppPage() {
46
- return this.executeSysSimpleSQL('sys_app_page', KeysOfSimpleSQL.SIMPLE_DELETE, {
47
- validateCfg: {
48
- 'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
49
- },
50
- });
51
- }
52
- }
@@ -1,49 +0,0 @@
1
- import { Controller, Inject, Post } from '@midwayjs/core';
2
- import { Context } from '@midwayjs/koa';
3
- import { KeysOfSimpleSQL, KeysOfValidators } from '@/libs/crud-pro/models/keys';
4
- import { BaseApiController } from '../base/BaseApiController';
5
-
6
- const tableName = 'sys_app_schema_history';
7
-
8
- @Controller('/ns/api/manage/AppSchemaHistory')
9
- export class AppSchemaHistoryApi extends BaseApiController {
10
- @Inject()
11
- ctx: Context;
12
-
13
- @Post('/getAppSchemaHistoryList')
14
- async getAppSchemaHistoryList() {
15
- return this.executeSysSimpleSQL(tableName, KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
16
- }
17
-
18
- @Post('/getAppSchemaHistoryOne')
19
- async getAppSchemaHistoryOne() {
20
- return this.executeSysSimpleSQL(tableName, KeysOfSimpleSQL.SIMPLE_QUERY_ONE);
21
- }
22
-
23
- @Post('/createAppSchemaHistory')
24
- async createAppSchemaHistory() {
25
- return this.executeSysSimpleSQL(tableName, KeysOfSimpleSQL.SIMPLE_INSERT, {
26
- validateCfg: {
27
- 'data.app_code': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
28
- },
29
- });
30
- }
31
-
32
- @Post('/updateAppSchemaHistory')
33
- async updateAppSchemaHistory() {
34
- return this.executeSysSimpleSQL(tableName, KeysOfSimpleSQL.SIMPLE_UPDATE, {
35
- validateCfg: {
36
- 'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
37
- },
38
- });
39
- }
40
-
41
- @Post('/deleteAppSchemaHistory')
42
- async deleteAppSchemaHistory() {
43
- return this.executeSysSimpleSQL(tableName, KeysOfSimpleSQL.SIMPLE_DELETE, {
44
- validateCfg: {
45
- 'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
46
- },
47
- });
48
- }
49
- }
@@ -1,49 +0,0 @@
1
- import { Controller, Inject, Post } from '@midwayjs/core';
2
- import { Context } from '@midwayjs/koa';
3
- import { KeysOfSimpleSQL, KeysOfValidators } from '@/libs/crud-pro/models/keys';
4
- import { BaseApiController } from '../base/BaseApiController';
5
- import { checkPermission } from '@/middleware/permission.middleware';
6
- import { SystemFuncCode } from '@/models/SystemPerm';
7
-
8
- @Controller('/ns/api/manage/crudMethod', { middleware: [checkPermission(SystemFuncCode.CrudMethodApiRead)] })
9
- export class CrudMethodsMangeApi extends BaseApiController {
10
- @Inject()
11
- ctx: Context;
12
-
13
- @Post('/getCrudMethodList')
14
- async getCrudMethodList() {
15
- return this.executeSysSimpleSQL('sys_crud_methods', KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
16
- }
17
-
18
- @Post('/getCrudMethodOne')
19
- async getCrudMethodOne() {
20
- return this.executeSysSimpleSQL('sys_crud_methods', KeysOfSimpleSQL.SIMPLE_QUERY_ONE);
21
- }
22
-
23
- @Post('/createCrudMethod', { middleware: [checkPermission(SystemFuncCode.CrudMethodApiWrite)] })
24
- async createCrudMethod() {
25
- return this.executeSysSimpleSQL('sys_crud_methods', KeysOfSimpleSQL.SIMPLE_INSERT, {
26
- validateCfg: {
27
- 'data.method': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
28
- },
29
- });
30
- }
31
-
32
- @Post('/updateCrudMethod', { middleware: [checkPermission(SystemFuncCode.CrudMethodApiWrite)] })
33
- async updateCrudMethod() {
34
- return this.executeSysSimpleSQL('sys_crud_methods', KeysOfSimpleSQL.SIMPLE_UPDATE, {
35
- validateCfg: {
36
- 'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
37
- },
38
- });
39
- }
40
-
41
- @Post('/deleteCrudMethod', { middleware: [checkPermission(SystemFuncCode.CrudMethodApiWrite)] })
42
- async deleteCrudMethod() {
43
- return this.executeSysSimpleSQL('sys_crud_methods', KeysOfSimpleSQL.SIMPLE_DELETE, {
44
- validateCfg: {
45
- 'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
46
- },
47
- });
48
- }
49
- }
@@ -1,346 +0,0 @@
1
- import { Config, Controller, Post } from '@midwayjs/core';
2
- import { BaseApiController } from '../base/BaseApiController';
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';
11
-
12
- @Controller('/ns/api/manage/CrudStandardDesignApi', { middleware: [checkPermission(SystemFuncCode.CrudStandardDesignRead)] })
13
- export class CrudStandardDesignApi extends BaseApiController {
14
- @Config('mysql2')
15
- private mysql2Config: any;
16
-
17
- @Config('postgres2')
18
- private postgres2Config: any;
19
-
20
- @Config('sqlserver2')
21
- private sqlserver2Config: any;
22
-
23
- @Post('/getDataBaseList')
24
- async getDataBaseList() {
25
- const mysqlList = Object.keys(this.mysql2Config || {});
26
- const postgresList = Object.keys(this.postgres2Config || {});
27
- const sqlServerList = Object.keys(this.sqlserver2Config || {});
28
-
29
- const toSelectList = (dbCfgNameList: string[], dbType: SqlDbType) => {
30
- return dbCfgNameList.map(dbName => {
31
- const value = toDatabaseNameStr(dbType, dbName);
32
- return { value, label: value, dbName, dbType };
33
- });
34
- };
35
-
36
- const mysqlObjList = toSelectList(mysqlList, SqlDbType.mysql);
37
- const postgresObjList = toSelectList(postgresList, SqlDbType.postgres);
38
- const sqlserverObjList = toSelectList(sqlServerList, SqlDbType.sqlserver);
39
-
40
- const databaseList = [...mysqlObjList, ...postgresObjList, ...sqlserverObjList].filter((obj: any) => {
41
- const value = '' + obj.value;
42
- return !value.endsWith('_fatcms_inner_demo_config');
43
- });
44
-
45
- return {
46
- success: true,
47
- data: databaseList,
48
- };
49
- }
50
-
51
- @Post('/getTableList')
52
- async getTableList(): Promise<CommonResult> {
53
- const { databaseName } = this.ctx.request.body as any;
54
- const { dbType, dbName } = parseDatabaseName(databaseName);
55
-
56
- if (dbType === SqlDbType.postgres) {
57
- return this.getTableListOfPostgreSQL(dbName);
58
- }
59
-
60
- if (dbType === SqlDbType.sqlserver) {
61
- return this.getTableListOfSqlserver(dbName);
62
- }
63
-
64
- const res = await this.curdMixService.executeSQL({
65
- executeSql: 'SHOW TABLES',
66
- sqlDatabase: dbName,
67
- sqlDbType: SqlDbType.mysql,
68
- crudType: KeyOfCrudTypes.SYS_QUERY,
69
- });
70
-
71
- const arr = JSON.parse(JSON.stringify(res));
72
- const tableNames: string[] = arr.map(a => {
73
- const v = Object.values(a);
74
- const tableName = v[0];
75
- return {
76
- value: tableName,
77
- label: tableName,
78
- dbName,
79
- dbType,
80
- tableName,
81
- };
82
- });
83
- return CommonResult.successRes(tableNames);
84
- }
85
-
86
- @Post('/getTableFields')
87
- async getTableFields() {
88
- const { databaseName, tableName } = this.ctx.request.body as any;
89
- const { dbType, dbName } = parseDatabaseName(databaseName);
90
-
91
- if (dbType === SqlDbType.postgres) {
92
- return this.getTableFieldsOfPostgreSQL(dbName, tableName);
93
- }
94
-
95
- if (dbType === SqlDbType.sqlserver) {
96
- return this.getTableFieldsOfSqlServer(dbName, tableName);
97
- }
98
-
99
- const tableDescribe = await this.curdMixService.executeSQL({
100
- executeSql: 'describe ' + tableName,
101
- sqlDatabase: dbName,
102
- sqlDbType: SqlDbType.mysql,
103
- crudType: KeyOfCrudTypes.SYS_QUERY,
104
- });
105
- const tableCreate = await this.curdMixService.executeSQL({
106
- executeSql: 'show create table ' + tableName,
107
- sqlDatabase: dbName,
108
- sqlDbType: SqlDbType.mysql,
109
- crudType: KeyOfCrudTypes.SYS_QUERY,
110
- });
111
-
112
- const tableCreateStr = tableCreate[0]['Create Table'];
113
- const { fieldsTitleMap, tableTitle } = parseCreateSqlToTitleMap(tableCreateStr);
114
-
115
- const tableDescribe2 = JSON.parse(JSON.stringify(tableDescribe));
116
- const fields = tableDescribe2.map(fieldObj => {
117
- const { Default, Extra, Field, Key, Null, Type } = fieldObj;
118
- const fieldTitle = fieldsTitleMap[Field];
119
- return {
120
- fieldIndex: Field || '',
121
- fieldTitle: fieldTitle || Field || '',
122
- isNullable: Null,
123
- defaultValue: Default,
124
- extra: Extra,
125
- key: Key,
126
- type: Type,
127
- };
128
- });
129
-
130
- return {
131
- success: true,
132
- data: {
133
- fields,
134
- tableName,
135
- tableTitle,
136
- },
137
- };
138
- }
139
-
140
- /**
141
- * 获取角色列表
142
- */
143
- @Post('/getRoleOptionsList')
144
- async getRoleOptionsList() {
145
- return this.executeSysSimpleSQL(SystemTables.sys_perm_role, KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
146
- }
147
-
148
- /**
149
- * 获取功能点列表
150
- */
151
- @Post('/getFuncOptionsList')
152
- async getFuncOptionsList() {
153
- return this.executeSysSimpleSQL(SystemTables.sys_perm_func, KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
154
- }
155
-
156
- private async getTableListOfSqlserver(dbName: string): Promise<CommonResult> {
157
- const dbConfig = this.sqlserver2Config[dbName];
158
- if (!dbConfig) {
159
- throw new CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
160
- }
161
-
162
- const dbType = SqlDbType.sqlserver;
163
-
164
- const sql = 'SELECT name as tablename FROM sys.tables';
165
- const arr = await this.curdMixService.executeSQL({
166
- executeSql: sql,
167
- sqlDatabase: dbName,
168
- sqlDbType: dbType,
169
- crudType: KeyOfCrudTypes.SYS_QUERY,
170
- executeSqlArgs: [],
171
- });
172
-
173
- const tableNames: string[] = arr.map(v => {
174
- const tableName = v.tablename;
175
- return {
176
- value: tableName, //[dbName, dbType, tableName].join(SPLIT_CONST),
177
- label: tableName,
178
- dbName,
179
- dbType,
180
- tableName,
181
- };
182
- });
183
- return CommonResult.successRes(tableNames);
184
- }
185
-
186
- private async getTableListOfPostgreSQL(dbName: string): Promise<CommonResult> {
187
- const dbConfig = this.postgres2Config[dbName];
188
- if (!dbConfig) {
189
- throw new CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
190
- }
191
-
192
- const dbType = SqlDbType.postgres;
193
- const schemaname = 'public';
194
-
195
- const tableListSql = '' + 'SELECT tablename\n' + 'FROM pg_tables\n' + `WHERE schemaname = '${schemaname}' \n` + 'ORDER BY tablename;';
196
-
197
- const viewListSql = '' + 'SELECT viewname as tablename\n' + 'FROM pg_views\n' + `WHERE schemaname = '${schemaname}' \n` + 'ORDER BY viewname;';
198
-
199
- const toSelectOptions = async (executeSql: string, tableType: string) => {
200
- const arr = await this.curdMixService.executeSQL({
201
- executeSql: executeSql,
202
- sqlDatabase: dbName,
203
- sqlDbType: dbType,
204
- crudType: KeyOfCrudTypes.SYS_QUERY,
205
- executeSqlArgs: [],
206
- });
207
- return arr.map(v => {
208
- const tableName = v.tablename;
209
- return {
210
- value: tableName, //[dbName, dbType, tableName].join(SPLIT_CONST),
211
- label: tableName,
212
- dbName,
213
- dbType,
214
- tableName,
215
- tableType,
216
- };
217
- });
218
- };
219
-
220
- const tableNames: any[] = await toSelectOptions(tableListSql, 'table');
221
- const viewNames: any[] = await toSelectOptions(viewListSql, 'view');
222
-
223
- const tableNameMerge = [...tableNames, ...viewNames];
224
-
225
- return CommonResult.successRes(tableNameMerge);
226
- }
227
-
228
- private async getTableFieldsOfSqlServer(dbName: string, tableName: string): Promise<CommonResult> {
229
- const dbConfig = this.sqlserver2Config[dbName];
230
- if (!dbConfig) {
231
- throw new CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
232
- }
233
-
234
- const columnArraySql =
235
- '' +
236
- 'SELECT\n' +
237
- ' c.name AS column_name,\n' +
238
- ' t.name AS data_type,\n' +
239
- ' c.max_length AS max_length,\n' +
240
- ' c.precision,\n' +
241
- ' c.scale,\n' +
242
- ' c.is_nullable,\n' +
243
- ' c.is_identity,\n' +
244
- ' dc.definition AS column_default, \n' +
245
- ' ep.value AS column_description \n' +
246
- 'FROM\n' +
247
- ' sys.columns c\n' +
248
- ' JOIN\n' +
249
- ' sys.types t ON c.user_type_id = t.user_type_id\n' +
250
- ' LEFT JOIN\n' +
251
- ' sys.default_constraints dc\n' +
252
- ' ON c.default_object_id = dc.object_id \n' +
253
- ' LEFT JOIN\n' +
254
- ' sys.extended_properties ep\n' +
255
- ' ON c.object_id = ep.major_id\n' +
256
- ' AND c.column_id = ep.minor_id\n' +
257
- 'WHERE\n' +
258
- ` c.object_id = OBJECT_ID('${tableName}') \n` +
259
- ' ORDER BY\n' +
260
- ' c.column_id;';
261
-
262
- const dbType = SqlDbType.sqlserver;
263
-
264
- const columnArray = await this.curdMixService.executeSQL({
265
- executeSql: columnArraySql,
266
- sqlDatabase: dbName,
267
- sqlDbType: dbType,
268
- crudType: KeyOfCrudTypes.SYS_QUERY,
269
- executeSqlArgs: [],
270
- });
271
-
272
- const fields = columnArray.map(columnObj => {
273
- const { column_name, is_nullable, column_default, data_type, is_identity, column_description, ...others } = columnObj;
274
-
275
- return {
276
- fieldIndex: column_name || '',
277
- fieldTitle: column_description || column_name || '',
278
- isNullable: is_nullable,
279
- defaultValue: column_default || '',
280
- extra: others,
281
- // key: column_name, // 索引
282
- type: data_type,
283
- is_identity: is_identity,
284
- };
285
- });
286
-
287
- return CommonResult.successRes({
288
- fields,
289
- tableName,
290
- tableTitle: tableName,
291
- });
292
- }
293
-
294
- private async getTableFieldsOfPostgreSQL(dbName: string, tableName: string) {
295
- const dbConfig = this.postgres2Config[dbName];
296
- if (!dbConfig) {
297
- throw new CommonException('DB_NOT_FOUND', '数据库配置没有找到:' + dbName);
298
- }
299
-
300
- const schemaname = 'public';
301
-
302
- const columnArraySql = `
303
-
304
- SELECT
305
- *
306
- FROM information_schema.columns
307
- WHERE table_schema = $1 and table_name = $2
308
- ORDER BY ordinal_position;
309
-
310
- `.trim();
311
-
312
- const dbType = SqlDbType.postgres;
313
-
314
- const columnArray = await this.curdMixService.executeSQL({
315
- executeSql: columnArraySql,
316
- sqlDatabase: dbName,
317
- sqlDbType: dbType,
318
- crudType: KeyOfCrudTypes.SYS_QUERY,
319
- executeSqlArgs: [schemaname, tableName],
320
- });
321
-
322
- const fields = columnArray.map(columnObj => {
323
- const { column_name, is_nullable, column_default, data_type, is_identity, ...others } = columnObj;
324
-
325
- return {
326
- fieldIndex: column_name || '',
327
- fieldTitle: column_name || '',
328
- isNullable: is_nullable,
329
- defaultValue: column_default || '',
330
- extra: others,
331
- // key: column_name, // 索引
332
- type: data_type,
333
- is_identity: is_identity,
334
- };
335
- });
336
-
337
- return {
338
- success: true,
339
- data: {
340
- fields,
341
- tableName,
342
- tableTitle: tableName,
343
- },
344
- };
345
- }
346
- }
@@ -1,78 +0,0 @@
1
- import { Inject, Controller, Post } from '@midwayjs/core';
2
- import { Context } from '@midwayjs/koa';
3
- import { KeysOfSimpleSQL, KeysOfValidators } from '@/libs/crud-pro/models/keys';
4
- import { BaseApiController } from '../base/BaseApiController';
5
- import { checkPermission } from '@/middleware/permission.middleware';
6
- import { SystemFuncCode } from '@/models/SystemPerm';
7
-
8
- @Controller('/ns/api/manage/dataDict', { middleware: [checkPermission(SystemFuncCode.DataDictMangeRead)] })
9
- export class DataDictManageApi extends BaseApiController {
10
- @Inject()
11
- protected ctx: Context;
12
-
13
- @Post('/getDataDictList')
14
- async getDataDictList() {
15
- return this.executeSysSimpleSQL('sys_data_dict', KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
16
- }
17
-
18
- @Post('/getDataDictOne')
19
- async getDataDictOne() {
20
- return this.executeSysSimpleSQL('sys_data_dict', KeysOfSimpleSQL.SIMPLE_QUERY_ONE);
21
- }
22
-
23
- @Post('/createDataDict', { middleware: [checkPermission(SystemFuncCode.DataDictMangeWrite)] })
24
- async createDataDict() {
25
- return this.executeSysSimpleSQL('sys_data_dict', KeysOfSimpleSQL.SIMPLE_INSERT, {
26
- validateCfg: {
27
- 'data.dict_code': [KeysOfValidators.REQUIRED],
28
- },
29
- });
30
- }
31
-
32
- @Post('/updateDataDict', { middleware: [checkPermission(SystemFuncCode.DataDictMangeWrite)] })
33
- async updateDataDict() {
34
- return this.executeSysSimpleSQL('sys_data_dict', KeysOfSimpleSQL.SIMPLE_UPDATE, {
35
- validateCfg: {
36
- 'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMERIC],
37
- },
38
- });
39
- }
40
-
41
- @Post('/deleteDataDict', { middleware: [checkPermission(SystemFuncCode.DataDictMangeWrite)] })
42
- async deleteDataDict() {
43
- return this.executeSysSimpleSQL('sys_data_dict', KeysOfSimpleSQL.SIMPLE_DELETE, {
44
- validateCfg: {
45
- 'condition.dict_code': [KeysOfValidators.REQUIRED],
46
- },
47
- });
48
- }
49
-
50
- @Post('/getDataDictItemList')
51
- async getDataDictItemList() {
52
- return this.executeSysSimpleSQL('sys_data_dict_item', KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
53
- }
54
-
55
- @Post('/getDataDictItemOne')
56
- async getDataDictItemOne() {
57
- return this.executeSysSimpleSQL('sys_data_dict_item', KeysOfSimpleSQL.SIMPLE_QUERY_ONE);
58
- }
59
-
60
- @Post('/createDataDictItem', { middleware: [checkPermission(SystemFuncCode.DataDictMangeWrite)] })
61
- async createDataDictItem() {
62
- return this.executeSysSimpleSQL('sys_data_dict_item', KeysOfSimpleSQL.SIMPLE_INSERT);
63
- }
64
-
65
- @Post('/updateDataDictItem', { middleware: [checkPermission(SystemFuncCode.DataDictMangeWrite)] })
66
- async updateDataDictItem() {
67
- return this.executeSysSimpleSQL('sys_data_dict_item', KeysOfSimpleSQL.SIMPLE_UPDATE);
68
- }
69
-
70
- @Post('/deleteDataDictItem', { middleware: [checkPermission(SystemFuncCode.DataDictMangeWrite)] })
71
- async deleteDataDictItem() {
72
- return this.executeSysSimpleSQL('sys_data_dict_item', KeysOfSimpleSQL.SIMPLE_DELETE, {
73
- validateCfg: {
74
- 'condition.dict_code': [KeysOfValidators.REQUIRED],
75
- },
76
- });
77
- }
78
- }