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,72 +0,0 @@
1
- class MultiKeyMap {
2
- private readonly _multiMap: Record<string, Record<string, any>> = {};
3
- private _rowsLength = 0;
4
-
5
- constructor(rows?: any[], keyName1?: string, keyName2?: string) {
6
- if (rows && keyName1 && keyName2) {
7
- this.addRows(rows, keyName1, keyName2);
8
- }
9
- }
10
-
11
- public isEmpty() {
12
- return this._rowsLength === 0;
13
- }
14
-
15
- public getValue(key1: string, key2: string) {
16
- const map1 = this._multiMap[key1];
17
- if (!map1) {
18
- return null;
19
- }
20
- return map1[key2];
21
- }
22
-
23
- public getValue1(key1: string): Record<string, any> {
24
- return this._multiMap[key1];
25
- }
26
-
27
- public addRowsValue1(rows: any[], value1: string, keyName2: string) {
28
- if (!Array.isArray(rows) || rows.length === 0) {
29
- return;
30
- }
31
-
32
- this._rowsLength = this._rowsLength + rows.length;
33
- const dictMap: Record<string, Record<string, any>> = this._multiMap;
34
-
35
- for (let i = 0; i < rows.length; i++) {
36
- const row = rows[i] || {};
37
- const value2 = row[keyName2];
38
- let dictItemMap = dictMap[value1];
39
- if (!dictItemMap) {
40
- dictItemMap = {};
41
- dictMap[value1] = dictItemMap;
42
- }
43
- dictItemMap[value2] = row;
44
-
45
- // 继续遍历children
46
- this.addRowsValue1(row.children, value1, keyName2);
47
- }
48
- }
49
-
50
- public addRows(rows: any[], keyName1: string, keyName2: string) {
51
- if (!Array.isArray(rows)) {
52
- return;
53
- }
54
-
55
- this._rowsLength = this._rowsLength + rows.length;
56
- const dictMap: Record<string, Record<string, any>> = this._multiMap;
57
-
58
- for (let i = 0; i < rows.length; i++) {
59
- const row = rows[i] || {};
60
- const value1 = row[keyName1];
61
- const value2 = row[keyName2];
62
- let dictItemMap = dictMap[value1];
63
- if (!dictItemMap) {
64
- dictItemMap = {};
65
- dictMap[value1] = dictItemMap;
66
- }
67
- dictItemMap[value2] = row;
68
- }
69
- }
70
- }
71
-
72
- export { MultiKeyMap };
@@ -1,29 +0,0 @@
1
- const SQL_FUNC_MAP = {
2
- NOW: 'NOW()',
3
- };
4
-
5
- /**
6
- * data: {
7
- * xxTime: {$sqlFunc:"NOW"}
8
- * }
9
- * @param arg
10
- */
11
- function getSqlFuncName(arg: any): string {
12
- if (arg && typeof arg === 'object' && typeof arg['$sqlFunc'] === 'string') {
13
- const sqlFunKey = arg['$sqlFunc'];
14
- return SQL_FUNC_MAP[sqlFunKey];
15
- }
16
- return null;
17
- }
18
-
19
- const sqlFuncUtils = {
20
- isSqlFuncArg: (arg: any): boolean => {
21
- const sqlFuncName = getSqlFuncName(arg);
22
- return !!sqlFuncName;
23
- },
24
- toFuncSQL: (arg: any): string => {
25
- return getSqlFuncName(arg);
26
- },
27
- };
28
-
29
- export { sqlFuncUtils };
@@ -1,188 +0,0 @@
1
- import { CommonException, Exceptions } from '../exceptions';
2
-
3
- const TypeUtils = {
4
- assertJsonArray(value: any, errorCode: string) {
5
- if (!Array.isArray(value)) {
6
- throw new CommonException(errorCode, JSON.stringify(value));
7
- }
8
- },
9
-
10
- assertBasicType(value: any, errorCode: string) {
11
- if (!TypeUtils.isBasicType(value)) {
12
- throw new CommonException(errorCode, JSON.stringify(value));
13
- }
14
- },
15
-
16
- isBasicType(value: any): boolean {
17
- if (value == null) {
18
- return true;
19
- }
20
-
21
- const valueType = typeof value;
22
- return valueType === 'boolean' || valueType === 'string' || valueType === 'number';
23
- },
24
- isBoolean(itemValue: any): boolean {
25
- return typeof itemValue === 'boolean';
26
- },
27
- isString(itemValue: any) {
28
- return typeof itemValue === 'string';
29
- },
30
- isInteger(x: any) {
31
- return typeof x === 'number' && Math.floor(x) === x;
32
- },
33
- isNumber(x: any) {
34
- return typeof x === 'number';
35
- },
36
-
37
- isNumeric(itemValue: any) {
38
- if (typeof itemValue === 'number') {
39
- return true;
40
- }
41
- if (typeof itemValue === 'string' && itemValue.length > 0) {
42
- return !isNaN(Number(itemValue));
43
- }
44
- return false;
45
- },
46
-
47
- /**
48
- * 是否是合法的name类型:以字母开头,只能包含(字母、数字、下划线)的非空字符串
49
- * @param itemValue
50
- */
51
- isValidName(itemValue: any): boolean {
52
- if (typeof itemValue === 'string' && itemValue.length > 0) {
53
- const reg = /^\w+$/; // --已经验证OK
54
- return reg.test(itemValue);
55
- }
56
- return false;
57
- },
58
-
59
- /**
60
- * 是否是合法中文手机号
61
- * @param itemValue
62
- */
63
- isChinesePhone(itemValue: string) {
64
- if (typeof itemValue === 'string' && itemValue.length > 0) {
65
- return TypeUtils.isNumeric(itemValue) && itemValue.length === 11;
66
- }
67
- return false;
68
- },
69
-
70
- /**
71
- * 是否是合法的email地址
72
- * @param itemValue
73
- */
74
- isEmailStrValid(itemValue: string) {
75
- if (typeof itemValue === 'string' && itemValue.length > 0) {
76
- const regExpStr = '^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$';
77
- const reg = new RegExp(regExpStr);
78
- return reg.test(itemValue);
79
- }
80
- return false;
81
- },
82
-
83
- /**
84
- * 从字符串中提取数字部分。
85
- * @param s
86
- */
87
- pickNumber(s: string): number | null {
88
- if (typeof s === 'undefined' || s === null) {
89
- return null;
90
- }
91
-
92
- s = s.trim();
93
-
94
- const length = s.length;
95
-
96
- if (length === 0) {
97
- return null;
98
- }
99
-
100
- const sb = [];
101
-
102
- for (let i = 0; i < length; i++) {
103
- const c = s.charAt(i);
104
- // 0到9或小数点,或负号
105
- if (TypeUtils.isNumberChar(c) || c === '.' || c === '-') {
106
- sb.push(c);
107
- }
108
- }
109
-
110
- const s2 = sb.join('');
111
- if (s2.length === 0) {
112
- return null;
113
- }
114
-
115
- const num = Number(s2);
116
- if (isNaN(num)) {
117
- return null;
118
- }
119
- return num;
120
- },
121
-
122
- isNumberChar(c: string): boolean {
123
- const charCode = c.charCodeAt(0);
124
- return charCode >= 48 && charCode <= 57; // 0 ~ 9
125
- },
126
-
127
- isNil(obj: any): boolean {
128
- return typeof obj === 'undefined' || obj === null;
129
- },
130
-
131
- /**
132
- * 判断数字是否满足范围表达式
133
- * @param scaleExpress :
134
- * 范围表达式:(0,1) 开区间,[0,1] 闭区间,(0,1] 前开后闭,[0,1) 前闭后开; 若没有大小括号,则默认闭区间
135
- * @param numberValue: 数字
136
- */
137
- isNumberScaleValid(scaleExpress: string, numberValue: number): boolean {
138
- if (typeof numberValue !== 'number') {
139
- return false;
140
- }
141
-
142
- const specials = ['(', ')', '[', ']', ' '];
143
- const scale = scaleExpress.trim();
144
-
145
- const scaleNumbersArray = (() => {
146
- const scaleNumbers = [];
147
- for (let i = 0; i < scale.length; i++) {
148
- const char = scale[i];
149
- if (specials.indexOf(char) < 0) {
150
- scaleNumbers.push(char);
151
- }
152
- }
153
- return scaleNumbers
154
- .join('')
155
- .split(',')
156
- .map(s => {
157
- return Number(s);
158
- });
159
- })();
160
-
161
- if (scaleNumbersArray.length !== 2) {
162
- throw new CommonException(Exceptions.CFG_VALIDATE_SCALE_ERROR, '范围匹配表达式不正确:' + scaleExpress);
163
- }
164
-
165
- const isStartOpen = scale.startsWith('(');
166
- const isEndOpen = scale.endsWith(')');
167
- const startNumber = scaleNumbersArray[0];
168
- const endNumber = scaleNumbersArray[1];
169
-
170
- let isStartOk = false;
171
- let isEndOk = false;
172
- if (isStartOpen) {
173
- isStartOk = startNumber < numberValue;
174
- } else {
175
- isStartOk = startNumber <= numberValue;
176
- }
177
-
178
- if (isEndOpen) {
179
- isEndOk = endNumber > numberValue;
180
- } else {
181
- isEndOk = endNumber >= numberValue;
182
- }
183
-
184
- return isStartOk && isEndOk;
185
- },
186
- };
187
-
188
- export { TypeUtils };
@@ -1,165 +0,0 @@
1
- import * as moment from 'moment';
2
- import { KeysOfValidators } from '../models/keys';
3
- import { CommonException, Exceptions } from '../exceptions';
4
- import { MixinUtils } from './MixinUtils';
5
- import { TypeUtils } from './TypeUtils';
6
- const { isEmpty } = MixinUtils;
7
-
8
- const validatorUtils = {
9
- /**
10
- * 字符串长度
11
- * @param itemCfg
12
- * @param itemValue
13
- */
14
- isLengthValid(itemCfg: string, itemValue: any): boolean {
15
- if (typeof itemValue === 'string') {
16
- const cfgPart = itemCfg.substring(KeysOfValidators.LENGTH.length);
17
- return TypeUtils.isNumberScaleValid(cfgPart, itemValue.length);
18
- }
19
- return false;
20
- },
21
-
22
- /**
23
- * 数字范围
24
- * @param itemCfg
25
- * @param itemValue
26
- */
27
- isNumberScaleValid(itemCfg: string, itemValue: any) {
28
- if (typeof itemValue === 'number') {
29
- const cfgPart = itemCfg.substring(KeysOfValidators.SCALE.length).trim();
30
- return TypeUtils.isNumberScaleValid(cfgPart, itemValue);
31
- } else if (TypeUtils.isNumeric(itemValue)) {
32
- const cfgPart = itemCfg.substring(KeysOfValidators.SCALE.length).trim();
33
- return TypeUtils.isNumberScaleValid(cfgPart, Number(itemValue));
34
- }
35
- return false;
36
- },
37
-
38
- /**
39
- * 正则表达式
40
- * @param itemCfg
41
- * @param itemValue
42
- */
43
- isRegExpValid(itemCfg: string, itemValue: any): boolean {
44
- if (typeof itemValue === 'string') {
45
- const cfgPart = itemCfg.substring(KeysOfValidators.REG_EXP.length);
46
- const regexp = new RegExp(cfgPart);
47
- return regexp.test(itemValue);
48
- }
49
- return false;
50
- },
51
-
52
- isMomentValid(itemCfg: string, itemValue: any): boolean {
53
- const cfgPart = itemCfg.substring(KeysOfValidators.ENUM.length).trim();
54
- return moment(itemValue, cfgPart, true).isValid();
55
- },
56
-
57
- isEnumValid(itemCfg: string, itemValue: any): boolean {
58
- const cfgPart = itemCfg.substring(KeysOfValidators.ENUM.length).trim();
59
- const cfgArr = cfgPart.split(','); // 1,2,3,4
60
- const enumStrArr = cfgArr.map(s => s.trim()).filter(s => !!s);
61
-
62
- // 枚举值的配置不能为空
63
- if (isEmpty(enumStrArr)) {
64
- throw new CommonException(Exceptions.CFG_VALIDATE_ENUM_ERROR, itemCfg);
65
- }
66
-
67
- // 值:不能为空
68
- if (itemValue == null) {
69
- return false;
70
- }
71
-
72
- // 值:不能为空
73
- const itemValueString = itemValue.toString();
74
- if (isEmpty(itemValueString)) {
75
- return false;
76
- }
77
-
78
- for (let i = 0; i < enumStrArr.length; i++) {
79
- const enumStr = enumStrArr[i];
80
- if (enumStr === itemValueString) {
81
- return true;
82
- }
83
- }
84
-
85
- return false;
86
- },
87
- };
88
-
89
- function validateByCfgStringInner(validateCfg: KeysOfValidators | string, itemValue: any): boolean {
90
- if (KeysOfValidators.ARRAY === validateCfg) {
91
- return itemValue !== null && Array.isArray(itemValue);
92
- } else if (KeysOfValidators.ARRAY_STRING === validateCfg) {
93
- return (
94
- itemValue !== null &&
95
- Array.isArray(itemValue) &&
96
- MixinUtils.isElementAllMatch(itemValue, e => {
97
- return typeof e === 'string';
98
- })
99
- );
100
- } else if (KeysOfValidators.ARRAY_NUMBER === validateCfg) {
101
- return (
102
- itemValue !== null &&
103
- Array.isArray(itemValue) &&
104
- MixinUtils.isElementAllMatch(itemValue, e => {
105
- return typeof e === 'number';
106
- })
107
- );
108
- } else if (KeysOfValidators.OBJECT === validateCfg) {
109
- return itemValue !== null && typeof itemValue === 'object';
110
- } else if (KeysOfValidators.BOOLEAN === validateCfg) {
111
- return TypeUtils.isBoolean(itemValue);
112
- } else if (KeysOfValidators.STRING === validateCfg) {
113
- return TypeUtils.isString(itemValue);
114
- } else if (KeysOfValidators.INTEGER === validateCfg) {
115
- return TypeUtils.isInteger(itemValue);
116
- } else if (KeysOfValidators.NUMBER === validateCfg) {
117
- return TypeUtils.isNumber(itemValue);
118
- } else if (KeysOfValidators.NUMERIC === validateCfg) {
119
- return TypeUtils.isNumeric(itemValue);
120
- } else if (KeysOfValidators.NAME === validateCfg) {
121
- return TypeUtils.isValidName(itemValue);
122
- } else if (KeysOfValidators.PHONE_CN === validateCfg) {
123
- return TypeUtils.isChinesePhone(itemValue.toString());
124
- } else if (KeysOfValidators.EMAIL === validateCfg) {
125
- return TypeUtils.isEmailStrValid(itemValue);
126
- } else if (validateCfg.startsWith(KeysOfValidators.LENGTH)) {
127
- return validatorUtils.isLengthValid(validateCfg, itemValue);
128
- } else if (validateCfg.startsWith(KeysOfValidators.REG_EXP)) {
129
- return validatorUtils.isRegExpValid(validateCfg, itemValue);
130
- } else if (validateCfg.startsWith(KeysOfValidators.SCALE)) {
131
- return validatorUtils.isNumberScaleValid(validateCfg, itemValue);
132
- } else if (validateCfg.startsWith(KeysOfValidators.ENUM)) {
133
- return validatorUtils.isEnumValid(validateCfg, itemValue);
134
- } else if (validateCfg.startsWith(KeysOfValidators.MOMENT)) {
135
- return validatorUtils.isMomentValid(validateCfg, itemValue);
136
- }
137
- throw new CommonException(Exceptions.CFG_VALIDATE_NOT_SUPPORT, validateCfg);
138
- }
139
-
140
- function validateByCfgString(validateCfg: KeysOfValidators | string, itemValue: any, errPath: string) {
141
- if (isEmpty(validateCfg)) {
142
- // 没有配置,不需要校验
143
- return;
144
- }
145
-
146
- // 必填
147
- if ('required' === validateCfg) {
148
- if (isEmpty(itemValue)) {
149
- throw new CommonException(Exceptions.VALIDATE_ERR, "'参数校验错误,字段 " + errPath + ' 不满足校验配置:' + validateCfg);
150
- }
151
- return;
152
- }
153
-
154
- // 没有填写的话,不需要校验。
155
- if (isEmpty(itemValue)) {
156
- return;
157
- }
158
-
159
- // 校验失败
160
- if (!validateByCfgStringInner(validateCfg, itemValue)) {
161
- throw new CommonException(Exceptions.VALIDATE_ERR, "'参数校验错误,字段 " + errPath + ' 不满足校验配置:' + validateCfg);
162
- }
163
- }
164
-
165
- export { validateByCfgString };
@@ -1,20 +0,0 @@
1
- import { createPool } from 'mysql2/promise';
2
- import { IConnectionPool } from '../../interfaces';
3
- import { SqlDbType } from '../../models/keys';
4
-
5
- const POOL_CACHE_MAP: Record<string, IConnectionPool> = {};
6
-
7
- function getConnectionPool(poolName: string, poolOptions: any): IConnectionPool {
8
- let pool = POOL_CACHE_MAP[poolName];
9
- if (!pool) {
10
- pool = {
11
- dbType: SqlDbType.mysql,
12
- poolName: poolName,
13
- poolInstance: createPool(poolOptions),
14
- };
15
- POOL_CACHE_MAP[poolName] = pool;
16
- }
17
- return pool;
18
- }
19
-
20
- export { getConnectionPool };
@@ -1,22 +0,0 @@
1
- import { Pool } from 'pg';
2
- import { IConnectionPool } from '../../interfaces';
3
- import { SqlDbType } from '../../models/keys';
4
-
5
- const POOL_CACHE_MAP: Record<string, IConnectionPool> = {};
6
-
7
- function getConnectionPool(poolName: string, poolOptions: any): IConnectionPool {
8
- let pool = POOL_CACHE_MAP[poolName];
9
- if (!pool) {
10
- const poolObj = new Pool(poolOptions);
11
-
12
- pool = {
13
- dbType: SqlDbType.postgres,
14
- poolName: poolName,
15
- poolInstance: poolObj,
16
- };
17
- POOL_CACHE_MAP[poolName] = pool;
18
- }
19
- return pool;
20
- }
21
-
22
- export { getConnectionPool };
@@ -1,22 +0,0 @@
1
- import { ConnectionPool } from 'mssql';
2
- import { IConnectionPool } from '../../interfaces';
3
- import { SqlDbType } from '../../models/keys';
4
-
5
- const POOL_CACHE_MAP: Record<string, IConnectionPool> = {};
6
-
7
- function getConnectionPool(poolName: string, poolOptions: any): IConnectionPool {
8
- let pool = POOL_CACHE_MAP[poolName];
9
- if (!pool) {
10
- const poolObj = new ConnectionPool(poolOptions);
11
-
12
- pool = {
13
- dbType: SqlDbType.sqlserver,
14
- poolName: poolName,
15
- poolInstance: poolObj,
16
- };
17
- POOL_CACHE_MAP[poolName] = pool;
18
- }
19
- return pool;
20
- }
21
-
22
- export { getConnectionPool };
@@ -1,26 +0,0 @@
1
- import {SqlCfgModel} from "../../models/SqlCfgModel";
2
- import {SqlDbType} from "../../models/keys";
3
-
4
-
5
- function toSqlColumnName(columnName: string, sqlCfgModel: SqlCfgModel): string {
6
- if (sqlCfgModel.sqlDbType === SqlDbType.postgres) {
7
- return '"' + columnName + '"';
8
- }
9
- if (sqlCfgModel.sqlDbType === SqlDbType.sqlserver) {
10
- return '[' + columnName + ']';
11
- }
12
- return '`' + columnName + '`';
13
- }
14
-
15
- function toSqlColumnNamesJoin(columns: string[], sqlCfgModel: SqlCfgModel): string {
16
- const columns2 = columns.map(col => {
17
- return toSqlColumnName(col.trim(), sqlCfgModel);
18
- });
19
- return columns2.join(',');
20
- }
21
-
22
-
23
- export {
24
- toSqlColumnName,
25
- toSqlColumnNamesJoin
26
- }
@@ -1,26 +0,0 @@
1
- import { SqlDbType } from "../../models/keys";
2
- import { pickAndConvertPgRows } from "./convertPgType";
3
- import * as _ from 'lodash'
4
-
5
- function pickAndConvertRowsByMix(connectionQueryRes: any, sqlDbType: SqlDbType): any[] | any {
6
- if (!connectionQueryRes) {
7
- throw new Error('[pickAndConvertRowsByMix] error, connectionQueryRes is null ')
8
- }
9
-
10
- if (sqlDbType === SqlDbType.postgres) {
11
- return pickAndConvertPgRows(connectionQueryRes);
12
- }
13
-
14
- if (sqlDbType === SqlDbType.mysql) {
15
- return connectionQueryRes[0];
16
- }
17
-
18
- if (sqlDbType === SqlDbType.sqlserver) {
19
- return _.get(connectionQueryRes, 'recordsets[0]') || [];
20
- }
21
- throw new Error('[pickAndConvertRowsByMix] error sqlDbType, sqlDbType = ' + sqlDbType)
22
- }
23
-
24
- export {
25
- pickAndConvertRowsByMix
26
- }
@@ -1,11 +0,0 @@
1
- function replaceQuestionMarksForMssql(sql:string): string {
2
- let count = 0;
3
- return sql.replace(/\?/g, () => {
4
- count = count+ 1;
5
- return `@fatcms_ms${count}`
6
- });
7
- }
8
-
9
- export {
10
- replaceQuestionMarksForMssql,
11
- }
@@ -1,11 +0,0 @@
1
- function replaceQuestionMarks(sql:string): string {
2
- let count = 0;
3
- return sql.replace(/\?/g, () => {
4
- count = count+ 1;
5
- return `$${count}`
6
- });
7
- }
8
-
9
- export {
10
- replaceQuestionMarks,
11
- }