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,73 +0,0 @@
1
- import { IConnectionPool, IPoolConnectionClient } from '../interfaces';
2
- import { SqlDbType } from './keys';
3
- import { TransactionMySQL } from './TransactionMySQL';
4
- import { TransactionPostgres } from './TransactionPostgres';
5
- import { TransactionSqlServer } from './TransactionSqlServer';
6
-
7
- class Transaction {
8
- private transactionMySQL: TransactionMySQL = new TransactionMySQL();
9
- private transactionPostgres: TransactionPostgres = new TransactionPostgres();
10
- private transactionSqlServer: TransactionSqlServer = new TransactionSqlServer();
11
-
12
- private getTxObj(pool: IConnectionPool): TransactionMySQL | TransactionPostgres | TransactionSqlServer {
13
- if (pool.dbType === SqlDbType.postgres) {
14
- return this.transactionPostgres;
15
- }
16
-
17
- if (pool.dbType === SqlDbType.sqlserver) {
18
- return this.transactionSqlServer;
19
- }
20
-
21
- if (!pool.dbType || pool.dbType === SqlDbType.mysql) {
22
- return this.transactionMySQL;
23
- }
24
- return null;
25
- }
26
-
27
- /**
28
- * 获取链接对象
29
- * @param pool
30
- */
31
- public async getTxConnection(pool: IConnectionPool): Promise<IPoolConnectionClient> {
32
- const txObj = this.getTxObj(pool);
33
- return txObj.getTxConnection(pool);
34
- }
35
-
36
- /**
37
- * 开始事务
38
- */
39
- public beginTx() {
40
- this.transactionMySQL.beginTx();
41
- this.transactionPostgres.beginTx();
42
- this.transactionSqlServer.beginTx();
43
- }
44
-
45
- /**
46
- * 提交事务
47
- */
48
- public async commitTx() {
49
- await this.transactionMySQL.commitTx();
50
- await this.transactionPostgres.commitTx();
51
- await this.transactionSqlServer.commitTx();
52
- }
53
-
54
- /**
55
- * 事务回滚
56
- */
57
- public async rollbackTx() {
58
- await this.transactionMySQL.rollbackTx();
59
- await this.transactionPostgres.rollbackTx();
60
- await this.transactionSqlServer.rollbackTx();
61
- }
62
-
63
- /**
64
- * 释放连接
65
- */
66
- public async releaseTx() {
67
- await this.transactionMySQL.releaseTx();
68
- await this.transactionPostgres.releaseTx();
69
- await this.transactionSqlServer.releaseTx();
70
- }
71
- }
72
-
73
- export { Transaction };
@@ -1,79 +0,0 @@
1
- import { PoolConnection, Pool } from 'mysql2/promise';
2
- import { IConnectionPool } from '../interfaces';
3
-
4
- class TransactionMySQL {
5
- private isBeginTransaction = false;
6
- private connectionMap: Record<string, PoolConnection> = {};
7
-
8
- /**
9
- * 获取链接对象
10
- * @param pool
11
- */
12
- public async getTxConnection(pool: IConnectionPool): Promise<PoolConnection> {
13
- let connection = this.connectionMap[pool.poolName];
14
- if (!connection) {
15
- const poolInstance: Pool = pool.poolInstance as any;
16
- connection = await poolInstance.getConnection();
17
- this.connectionMap[pool.poolName] = connection;
18
- // 开启了事务
19
- if (this.isBeginTransaction) {
20
- await connection.beginTransaction();
21
- }
22
- }
23
- return connection;
24
- }
25
-
26
- /**
27
- * 开始事务
28
- */
29
- public beginTx() {
30
- this.isBeginTransaction = true;
31
- }
32
-
33
- /**
34
- * 提交事务
35
- */
36
- public async commitTx() {
37
- if (!this.isBeginTransaction) {
38
- return;
39
- }
40
- const connections = Object.values(this.connectionMap);
41
- for (let i = 0; i < connections.length; i++) {
42
- const connection = connections[i];
43
- await connection.commit();
44
- }
45
- }
46
-
47
- /**
48
- * 事务回滚
49
- */
50
- public async rollbackTx() {
51
- if (!this.isBeginTransaction) {
52
- return;
53
- }
54
- const connections = Object.values(this.connectionMap);
55
- for (let i = 0; i < connections.length; i++) {
56
- const connection = connections[i];
57
- await connection.rollback();
58
- }
59
- }
60
-
61
- /**
62
- * 释放连接
63
- */
64
- public async releaseTx() {
65
- // 不管有没有开启事务,都要释放连接。
66
- const connections = Object.values(this.connectionMap);
67
- for (let i = 0; i < connections.length; i++) {
68
- const connection = connections[i];
69
- try {
70
- await connection.release();
71
- } catch (e) {
72
- console.error(e);
73
- }
74
- }
75
- this.connectionMap = {};
76
- }
77
- }
78
-
79
- export { TransactionMySQL };
@@ -1,91 +0,0 @@
1
- import { PoolClient, Pool } from 'pg';
2
- import { IConnectionPool } from '../interfaces';
3
-
4
- async function beginTransaction(connection: PoolClient) {
5
- return await connection.query('BEGIN');
6
- }
7
-
8
- async function commit(connection: PoolClient) {
9
- return await connection.query('COMMIT');
10
- }
11
-
12
- async function rollback(connection: PoolClient) {
13
- return await connection.query('ROLLBACK');
14
- }
15
-
16
- class TransactionPostgres {
17
- private isBeginTransaction = false;
18
- private connectionMap: Record<string, PoolClient> = {};
19
-
20
- /**
21
- * 获取链接对象
22
- * @param pool
23
- */
24
- public async getTxConnection(pool: IConnectionPool): Promise<PoolClient> {
25
- let connection = this.connectionMap[pool.poolName];
26
- if (!connection) {
27
- const poolInstance: Pool = pool.poolInstance as any;
28
- connection = await poolInstance.connect();
29
- this.connectionMap[pool.poolName] = connection;
30
- // 开启了事务
31
- if (this.isBeginTransaction) {
32
- await beginTransaction(connection);
33
- }
34
- }
35
- return connection;
36
- }
37
-
38
- /**
39
- * 开始事务
40
- */
41
- public beginTx() {
42
- this.isBeginTransaction = true;
43
- }
44
-
45
- /**
46
- * 提交事务
47
- */
48
- public async commitTx() {
49
- if (!this.isBeginTransaction) {
50
- return;
51
- }
52
- const connections = Object.values(this.connectionMap);
53
- for (let i = 0; i < connections.length; i++) {
54
- const connection = connections[i];
55
- await commit(connection);
56
- }
57
- }
58
-
59
- /**
60
- * 事务回滚
61
- */
62
- public async rollbackTx() {
63
- if (!this.isBeginTransaction) {
64
- return;
65
- }
66
- const connections = Object.values(this.connectionMap);
67
- for (let i = 0; i < connections.length; i++) {
68
- const connection = connections[i];
69
- await rollback(connection);
70
- }
71
- }
72
-
73
- /**
74
- * 释放连接
75
- */
76
- public async releaseTx() {
77
- // 不管有没有开启事务,都要释放连接。
78
- const connections = Object.values(this.connectionMap);
79
- for (let i = 0; i < connections.length; i++) {
80
- const connection = connections[i];
81
- try {
82
- await connection.release();
83
- } catch (e) {
84
- console.error(e);
85
- }
86
- }
87
- this.connectionMap = {};
88
- }
89
- }
90
-
91
- export { TransactionPostgres };
@@ -1,102 +0,0 @@
1
- import { ConnectionPool, Request, Transaction } from 'mssql';
2
- import { IConnectionPool, IPoolConnectionClient } from '../interfaces';
3
-
4
- interface ISqlServerConnection extends IPoolConnectionClient {
5
- originConnection: ConnectionPool;
6
- }
7
-
8
- class TransactionSqlServer {
9
- private isBeginTransaction = false;
10
- private connectionMap: Record<string, ISqlServerConnection> = {};
11
- private transactionMap: Record<string, Transaction> = {};
12
-
13
- /**
14
- * 获取链接对象
15
- * @param pool
16
- */
17
- public async getTxConnection(pool: IConnectionPool): Promise<ISqlServerConnection> {
18
- let connection = this.connectionMap[pool.poolName];
19
- if (!connection) {
20
- connection = await this.connectAndCreateConnection(pool);
21
- this.connectionMap[pool.poolName] = connection;
22
-
23
- // 开启了事务
24
- if (this.isBeginTransaction) {
25
- await this.beginTransaction(pool.poolName);
26
- }
27
- }
28
- return connection;
29
- }
30
-
31
- private async connectAndCreateConnection(pool: IConnectionPool): Promise<ISqlServerConnection> {
32
- const poolInstance: ConnectionPool = pool.poolInstance as any;
33
- const originConnection = await poolInstance.connect();
34
- return {
35
- originConnection,
36
- query: (sql: string, values: any): Promise<any> => {
37
- const request = new Request(originConnection);
38
- if (Array.isArray(values)) {
39
- for (let i = 0; i < values.length; i++) {
40
- const index = i + 1;
41
- const value = values[i];
42
- request.input(`fatcms_ms${index}`, value);
43
- }
44
- }
45
- return request.query(sql);
46
- },
47
- };
48
- }
49
-
50
- /**
51
- * 开始事务
52
- */
53
- public beginTx() {
54
- this.isBeginTransaction = true;
55
- }
56
-
57
- /**
58
- * 提交事务
59
- */
60
- public async commitTx() {
61
- if (!this.isBeginTransaction) {
62
- return;
63
- }
64
- const transactions = Object.values(this.transactionMap);
65
- for (let i = 0; i < transactions.length; i++) {
66
- const tmpTx = transactions[i];
67
- await tmpTx.commit();
68
- }
69
- }
70
-
71
- /**
72
- * 事务回滚
73
- */
74
- public async rollbackTx() {
75
- if (!this.isBeginTransaction) {
76
- return;
77
- }
78
- const transactions = Object.values(this.transactionMap);
79
- for (let i = 0; i < transactions.length; i++) {
80
- const tmpTx = transactions[i];
81
- await tmpTx.rollback();
82
- }
83
- }
84
-
85
- /**
86
- * 释放连接
87
- */
88
- public async releaseTx() {
89
- this.connectionMap = {};
90
- this.transactionMap = {};
91
- }
92
-
93
- private async beginTransaction(poolName: string) {
94
- const connection = this.connectionMap[poolName];
95
- const originConnection: ConnectionPool = connection.originConnection;
96
- const tmpTx = new Transaction(originConnection);
97
- this.transactionMap[poolName] = tmpTx;
98
- return await tmpTx.begin();
99
- }
100
- }
101
-
102
- export { TransactionSqlServer };
@@ -1,159 +0,0 @@
1
- export enum SqlDbType {
2
- mysql = 'mysql',
3
- postgres = 'postgres',
4
- sqlserver = 'sqlserver', //微软 SQL Server
5
- }
6
-
7
- export enum KeysOfFunCtx {
8
- FUNC_CTX = '$',
9
- CURRENT_VALUE = '$current',
10
- VISITOR = 'visitor',
11
- VISITOR_ATTR = 'visitor.',
12
- REQUEST = 'req.',
13
- RESULT = 'res.',
14
- }
15
-
16
- //鉴权类型;free无需鉴权,login仅登录即可,byRoleCode校验角色,byFuncCode校验功能点
17
- export enum KeysOfAuthType {
18
- free = 'free', // 无需任何校验
19
- login = 'login', // 仅仅登录即可
20
- byRoleCode = 'byRoleCode', // 根据角色校验
21
- byFuncCode = 'byFuncCode', // 根据功能点校验
22
- }
23
-
24
- export enum KeysOfValidators {
25
- REQUIRED = 'required',
26
- BOOLEAN = 'boolean', // 布尔值类型
27
- OBJECT = 'object', // 普通对象类型类型
28
- ARRAY = 'array', // 数组
29
- ARRAY_STRING = 'array:string', // 数组
30
- ARRAY_NUMBER = 'array:number', // 数组
31
- STRING = 'string', // 字符串类型
32
- EMAIL = 'email',
33
- NAME = 'name', //必须以字母开头,只能包含:字母/数字/下划线
34
- PHONE_CN = 'phone:cn', // 中国手机号:11位
35
- INTEGER = 'integer', // long,int,short,bigInteger
36
- NUMBER = 'number', // long,int,short,float,double
37
- NUMERIC = 'numeric', //long,int,short,float,double或只包含数字的字符串
38
- MOMENT = 'moment:', // moment:YYYY-MM-DD HH:mm:ss 时间日期格式校验
39
- SCALE = 'scale:', // 判断参数是否位于这个区间:scale:[1,3] ; scale:(1,3) ; scale:(1,3] ;
40
- LENGTH = 'length:', // length:1,5 ; length >=1 and length <=5
41
- REG_EXP = 'regexp:', // regexp:[a-zA-Z-_.]
42
- ENUM = 'enum:', // enum : 1,2,3,4,5,6,aa,bb,cc :比较时用字符串比较
43
- }
44
-
45
- export enum KeyOfCrudTypes {
46
- SELECT = 'SELECT',
47
- UPDATE = 'UPDATE',
48
- INSERT = 'INSERT',
49
- DELETE = 'DELETE',
50
- NOT_CRUD = 'NOT_CRUD',
51
- EMPTY_SQL = 'EMPTY_SQL',
52
- SYS_QUERY = 'SYS_QUERY',
53
- }
54
-
55
- export enum KeysOfSimpleSQL {
56
- SIMPLE_QUERY = 'SIMPLE_QUERY', // select * from xx where @condition limit 100,
57
- SIMPLE_QUERY_ONE = 'SIMPLE_QUERY_ONE', //只查询一条 select * from xx where @condition limit 1,
58
- SIMPLE_QUERY_PAGE = 'SIMPLE_QUERY_PAGE', //分页查询 select * from xx where @condition limit 100 offset 100,
59
- SIMPLE_QUERY_COUNT = 'SIMPLE_QUERY_COUNT', //查询数量 select count(0) as totalCount from xx where @condition,
60
- SIMPLE_UPDATE = 'SIMPLE_UPDATE', // update xx set @data where @condition limit 1
61
- SIMPLE_INSERT = 'SIMPLE_INSERT', // insert into xx values @datas
62
- SIMPLE_DELETE = 'SIMPLE_DELETE', // delete from xx values where @condition limit 1
63
- SIMPLE_INSERT_ON_DUPLICATE_UPDATE = 'SIMPLE_INSERT_ON_DUPLICATE_UPDATE',
64
- SIMPLE_INSERT_OR_UPDATE = 'SIMPLE_INSERT_OR_UPDATE',
65
- CUSTOM = 'CUSTOM',
66
- }
67
-
68
- export enum KeysOfSqlResPicker {
69
- UPDATE_RESULT = 'UPDATE_RESULT', // update/insert/delete 产生影响的结果
70
- RESULT_FIRST_ROW = 'RESULT_FIRST_ROW', // $ResultSet[0], 只取第一行的数据返回。返回JSONObject
71
- RESULT_TOTAL_COUNT = 'RESULT_TOTAL_COUNT', // $ResultSet[0].total_count , 只取第一行的的total_count。返回long
72
- RESULT_ONE_VALUE = 'RESULT_ONE_VALUE', // $ResultSet[0].total_count , 只取第一行的的total_count。返回long
73
- }
74
-
75
- export const KeysOfCustomSQL = {
76
- SQL_COLUMNS: '@@columns',
77
- SQL_TABLE: '@@table', // 只有简单查询才能用得到
78
- SQL_OFFSET_LIMIT: '@@offsetLimit',
79
- SQL_ORDER_BYS: '@@orderBys',
80
-
81
- SQL_AS_WHERE: '@@asWhere:', // @@asWhere:condition , @@asWhere:condition_zhangsan
82
- SQL_AS_UPDATE: '@@asUpdate:', // @@asUpdate:data, @@asWhere:data_zhangsan
83
- SQL_AS_INSERT_KEYS: '@@asInsertKeys:', // @@asInsertKeys:data, @@asInsertKeys:data_zhangsan
84
- SQL_AS_INSERT_VALUES: '@@asInsertValues:', // @@asInsertValues:data, @@asInsertValues:data_zhangsan
85
-
86
- // 从Req中取值:单独取Data中的某个字段:获取单个值。
87
- SQL_GET_DATA_ATTR_START: '@@data', // // select * from fa_lang_faq where id = @@data.id
88
- SQL_GET_CONDITION_ATTR_START: '@@condition', // select * from fa_lang_faq where id = @@condition.id
89
-
90
- // 从Res中取值
91
- SQL_PICK_RES_AS_NUMBER: '@@pickResAsNumber:', // select * from fa_lang_faq where id = @@pickResAsNumber:rows[0].id
92
- SQL_PICK_RES_AS_STRING: '@@pickResAsString:', // select * from fa_lang_faq where lang_code = @@pickResAsString:row.lang_code
93
-
94
- // 使用java函数:获取单个值
95
- SQL_FUNCTION: '@@function:', // @@function:aaa
96
- };
97
-
98
- /**
99
- * 查询条件中允许出现的关键词
100
- * 与MongoDB的语法完全一致
101
- */
102
- export const KeysOfConditions = {
103
- $OR: '$or', //或
104
-
105
- $NE: '$ne', //不等于
106
- $LT: '$lt', //小于
107
- $LTE: '$lte', //小于或等于
108
- $GT: '$gt', //大于
109
- $GTE: '$gte', //大于或等于
110
- $IN: '$in', //in
111
- $NIN: '$nin', // not in
112
- $NOT_NULL: '$notNull', // is not null
113
- $NULL: '$null', // is null
114
- $RANGE: '$range', // between 1 and 2
115
- $LIKE: '$like', // A% 以A开头 {age:1, name:{"$like":"张"} }
116
- $NOT_LIKE: '$notLike', // A% 以A开头 {age:1, name:{"$notLike":"张"} }
117
-
118
- $LIKE_INCLUDE: '$likeInclude', // %A% 包含A {age:1, name:{"$like":"张"} }
119
- $NOT_LIKE_INCLUDE: '$notLikeInclude', // %A% 包含A {age:1, name:{"$notLike":"张"} }
120
-
121
- $MATCH: '$match', // 全文索引 {age:1, name:{"$match":"张"} }
122
- $MATCH_BOOL: '$matchBool', // 全文索引 {age:1, name:{"$matchBool":"张"} }
123
-
124
- COMPARE_KEYS: new Set<string>([]),
125
- ALL_KEYS: new Set<string>([]),
126
- };
127
-
128
- function initKeysOfConditions() {
129
- const addIgnoreCase = (keys: Set<string>, key: string) => {
130
- keys.add(key);
131
- keys.add(key.toUpperCase());
132
- keys.add(key.toLowerCase());
133
- };
134
-
135
- // 比较操作符, 支持忽略大小写
136
- KeysOfConditions.COMPARE_KEYS = new Set([]);
137
- addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$NE);
138
- addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$LT);
139
- addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$LTE);
140
- addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$GT);
141
- addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$GTE);
142
- addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$IN);
143
- addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$NIN);
144
- addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$LIKE);
145
- addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$LIKE_INCLUDE);
146
- addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$NOT_LIKE);
147
- addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$NOT_LIKE_INCLUDE);
148
- addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$MATCH);
149
- addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$MATCH_BOOL);
150
- addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$RANGE);
151
- addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$NULL);
152
- addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$NOT_NULL);
153
-
154
- // 所有操作符
155
- KeysOfConditions.ALL_KEYS = new Set([...KeysOfConditions.COMPARE_KEYS]);
156
- addIgnoreCase(KeysOfConditions.ALL_KEYS, KeysOfConditions.$OR);
157
- }
158
-
159
- initKeysOfConditions();
@@ -1,83 +0,0 @@
1
- import { camelizeKeys } from 'humps';
2
- import { CrudProServiceBase } from './CrudProServiceBase';
3
- import { IRequestCfgModel } from '../interfaces';
4
- import { MixinUtils } from '../utils/MixinUtils';
5
- import { ICurdProServiceHub } from '../models/ServiceHub';
6
- import { pickAndConvertRowsByMix } from '../utils/sqlConvert/convertMix';
7
- import MemoryRefreshCache from '../utils/MemoryRefreshCache';
8
-
9
- const methodCache = new MemoryRefreshCache();
10
-
11
- function parseMethodInfo(methodInfo: any): any {
12
- const row: any = camelizeKeys(methodInfo as object); //转换成驼峰
13
- const configObject = MixinUtils.parseJsonObject(row.moreConfig) || {};
14
- const sqlCfgList = MixinUtils.parseJsonObject(row.sqlCfgList) || [];
15
- return { ...configObject, ...row, sqlCfgList };
16
- }
17
-
18
- class CrudProCachedCfgService extends CrudProServiceBase {
19
- constructor(serviceHub: ICurdProServiceHub) {
20
- super(serviceHub);
21
- }
22
-
23
- public async getCachedCfgByMethod(method: string, isEnableCache: boolean): Promise<IRequestCfgModel | null> {
24
- const methodInfo = await this.getCachedCfgByMethodInner(method, isEnableCache);
25
- if (!methodInfo) {
26
- return null;
27
- }
28
- return { ...methodInfo };
29
- }
30
-
31
- private async getCachedCfgByMethodInner(method: string, isEnableCache: boolean): Promise<IRequestCfgModel | null> {
32
- // 不使用缓存
33
- if (!isEnableCache) {
34
- return await this.loadMethodInfo(method);
35
- }
36
-
37
- methodCache.setProps({
38
- keepTime: 1000 * 60 * 2, // 2分钟
39
- requestFn: () => this.loadMethodInfoList(),
40
- getKeyFn: item => item.method,
41
- });
42
- const methodInfo = await methodCache.getItem(method);
43
- if (methodInfo) {
44
- return methodInfo;
45
- }
46
- return await this.loadMethodInfo(method);
47
- }
48
-
49
- private async loadMethodInfo(method: string): Promise<any> {
50
- const { methodsTableName, sysDatabaseName, sysDatabaseDbType } = this.getContextCfg();
51
- const sql = `select * from ${methodsTableName} where method = ? `; // 全部加载到内存
52
-
53
- const baseInfo = {
54
- sqlTable: methodsTableName,
55
- sqlDatabase: sysDatabaseName,
56
- sqlDbType: sysDatabaseDbType,
57
- };
58
-
59
- const queryRes = await this.executeUnsafeQuery(baseInfo, sql, [method]);
60
- const rows2: any[] = pickAndConvertRowsByMix(queryRes, sysDatabaseDbType);
61
- if (rows2.length > 0) {
62
- return parseMethodInfo(rows2[0]);
63
- }
64
- return null;
65
- }
66
-
67
- private async loadMethodInfoList(): Promise<any[]> {
68
- const { methodsTableName, sysDatabaseName, sysDatabaseDbType } = this.getContextCfg();
69
- const sql = `select * from ${methodsTableName}`; // 全部加载到内存
70
- const baseInfo = {
71
- sqlTable: methodsTableName,
72
- sqlDatabase: sysDatabaseName,
73
- sqlDbType: sysDatabaseDbType,
74
- };
75
- const queryRes = await this.executeUnsafeQuery(baseInfo, sql);
76
- const rows2: any[] = pickAndConvertRowsByMix(queryRes, sysDatabaseDbType);
77
- return rows2.map(row => {
78
- return parseMethodInfo(row);
79
- });
80
- }
81
- }
82
-
83
- export { CrudProCachedCfgService };