midway-fatcms 0.0.4 → 0.0.6
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/README.md +635 -352
- package/dist/controller/manage/CrudStandardDesignApi.d.ts +0 -2
- package/dist/controller/manage/CrudStandardDesignApi.js +11 -85
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/libs/crud-pro/CrudPro.d.ts +9 -1
- package/dist/libs/crud-pro/CrudPro.js +15 -0
- package/dist/libs/crud-pro/README.md +809 -0
- package/dist/libs/crud-pro/README_FUNC.md +193 -0
- package/dist/libs/crud-pro/exceptions.d.ts +2 -0
- package/dist/libs/crud-pro/exceptions.js +2 -0
- package/dist/libs/crud-pro/interfaces.d.ts +34 -1
- package/dist/libs/crud-pro/models/ExecuteContext.d.ts +3 -3
- package/dist/libs/crud-pro/models/ExecuteContext.js +2 -0
- package/dist/libs/crud-pro/models/RequestModel.d.ts +41 -1
- package/dist/libs/crud-pro/models/RequestModel.js +103 -39
- package/dist/libs/crud-pro/models/ResModel.d.ts +6 -4
- package/dist/libs/crud-pro/models/ServiceHub.d.ts +1 -0
- package/dist/libs/crud-pro/models/keys.d.ts +6 -1
- package/dist/libs/crud-pro/models/keys.js +5 -0
- package/dist/libs/crud-pro/services/CrudProDataTypeConvertService.d.ts +52 -0
- package/dist/libs/crud-pro/services/CrudProDataTypeConvertService.js +158 -0
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +20 -1
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.d.ts +7 -0
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.js +32 -0
- package/dist/libs/crud-pro/services/CrudProGenSqlService.d.ts +13 -0
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +44 -7
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.d.ts +43 -0
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +132 -1
- package/dist/libs/crud-pro/services/CrudProTableMetaService.d.ts +15 -1
- package/dist/libs/crud-pro/services/CrudProTableMetaService.js +107 -0
- package/dist/libs/crud-pro/services/CurdProServiceHub.d.ts +5 -1
- package/dist/libs/crud-pro/services/CurdProServiceHub.js +11 -0
- package/dist/libs/crud-pro/utils/DateTimeUtils.d.ts +1 -0
- package/dist/libs/crud-pro/utils/DateTimeUtils.js +3 -0
- package/dist/libs/crud-pro/utils/MixinUtils.d.ts +32 -0
- package/dist/libs/crud-pro/utils/MixinUtils.js +85 -1
- package/dist/libs/crud-pro/utils/ValidateUtils.js +1 -1
- package/dist/libs/crud-sharding/ROUTING_LOGIC.md +944 -0
- package/dist/libs/crud-sharding/ShardingConfig.d.ts +218 -0
- package/dist/libs/crud-sharding/ShardingConfig.js +32 -0
- package/dist/libs/crud-sharding/ShardingCountCache.d.ts +69 -0
- package/dist/libs/crud-sharding/ShardingCountCache.js +160 -0
- package/dist/libs/crud-sharding/ShardingCrudPro.d.ts +363 -0
- package/dist/libs/crud-sharding/ShardingCrudPro.js +699 -0
- package/dist/libs/crud-sharding/ShardingMerger.d.ts +130 -0
- package/dist/libs/crud-sharding/ShardingMerger.js +280 -0
- package/dist/libs/crud-sharding/ShardingRouter.d.ts +69 -0
- package/dist/libs/crud-sharding/ShardingRouter.js +377 -0
- package/dist/libs/crud-sharding/ShardingTableCreator.d.ts +146 -0
- package/dist/libs/crud-sharding/ShardingTableCreator.js +805 -0
- package/dist/libs/crud-sharding/ShardingUtils.d.ts +38 -0
- package/dist/libs/crud-sharding/ShardingUtils.js +77 -0
- package/dist/libs/crud-sharding/index.d.ts +45 -0
- package/dist/libs/crud-sharding/index.js +55 -0
- package/dist/models/StandardColumns.d.ts +71 -0
- package/dist/models/StandardColumns.js +28 -0
- package/dist/service/SysAppService.js +2 -2
- package/dist/service/SysConfigService.js +1 -1
- package/dist/service/SysDictDataService.js +2 -2
- package/dist/service/SysMenuService.js +1 -1
- package/dist/service/UserAccountService.d.ts +1 -1
- package/dist/service/crudstd/CrudStdService.d.ts +0 -1
- package/dist/service/crudstd/CrudStdService.js +0 -27
- package/dist/service/curd/CrudProQuick.d.ts +134 -4
- package/dist/service/curd/CrudProQuick.js +155 -3
- package/dist/service/curd/CurdMixService.d.ts +2 -1
- package/dist/service/curd/CurdMixService.js +5 -1
- package/dist/service/curd/CurdProService.d.ts +44 -2
- package/dist/service/curd/CurdProService.js +53 -1
- package/dist/service/curd/README.md +1001 -0
- package/dist/service/curd/fixSoftDelete.d.ts +14 -0
- package/dist/service/curd/fixSoftDelete.js +29 -11
- package/dist/service/flow/FlowConfigService.js +1 -1
- package/dist/service/flow/FlowInstanceCrudService.js +1 -1
- package/package.json +3 -1
- package/src/controller/gateway/AsyncTaskController.ts +1 -1
- package/src/controller/manage/CrudStandardDesignApi.ts +16 -100
- package/src/index.ts +3 -0
- package/src/libs/crud-pro/CrudPro.ts +19 -1
- package/src/libs/crud-pro/README.md +809 -0
- package/src/libs/crud-pro/README_FUNC.md +193 -0
- package/src/libs/crud-pro/exceptions.ts +2 -0
- package/src/libs/crud-pro/interfaces.ts +38 -1
- package/src/libs/crud-pro/models/ExecuteContext.ts +6 -3
- package/src/libs/crud-pro/models/RequestModel.ts +108 -44
- package/src/libs/crud-pro/models/ResModel.ts +10 -4
- package/src/libs/crud-pro/models/ServiceHub.ts +2 -0
- package/src/libs/crud-pro/models/keys.ts +5 -0
- package/src/libs/crud-pro/services/CrudProDataTypeConvertService.ts +171 -0
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +24 -1
- package/src/libs/crud-pro/services/CrudProFieldValidateService.ts +53 -1
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +51 -7
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +159 -2
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +139 -1
- package/src/libs/crud-pro/services/CurdProServiceHub.ts +16 -1
- package/src/libs/crud-pro/utils/DateTimeUtils.ts +3 -0
- package/src/libs/crud-pro/utils/MixinUtils.ts +97 -1
- package/src/libs/crud-pro/utils/ValidateUtils.ts +1 -1
- package/src/libs/crud-sharding/ROUTING_LOGIC.md +944 -0
- package/src/libs/crud-sharding/ShardingConfig.ts +240 -0
- package/src/libs/crud-sharding/ShardingCountCache.ts +200 -0
- package/src/libs/crud-sharding/ShardingCrudPro.ts +856 -0
- package/src/libs/crud-sharding/ShardingMerger.ts +382 -0
- package/src/libs/crud-sharding/ShardingRouter.ts +512 -0
- package/src/libs/crud-sharding/ShardingTableCreator.ts +1007 -0
- package/src/libs/crud-sharding/ShardingUtils.ts +84 -0
- package/src/libs/crud-sharding/index.ts +64 -0
- package/src/models/StandardColumns.ts +76 -0
- package/src/service/FileCenterService.ts +1 -1
- package/src/service/SysAppService.ts +2 -2
- package/src/service/SysConfigService.ts +1 -1
- package/src/service/SysDictDataService.ts +2 -2
- package/src/service/SysMenuService.ts +2 -2
- package/src/service/WorkbenchService.ts +1 -1
- package/src/service/anyapi/AnyApiService.ts +1 -1
- package/src/service/asyncTask/AsyncTaskRunnerService.ts +1 -1
- package/src/service/crudstd/CrudStdService.ts +0 -32
- package/src/service/curd/CrudProQuick.ts +164 -5
- package/src/service/curd/CurdMixService.ts +7 -2
- package/src/service/curd/CurdProService.ts +62 -3
- package/src/service/curd/README.md +1001 -0
- package/src/service/curd/fixCfgModel.ts +1 -2
- package/src/service/curd/fixSoftDelete.ts +38 -16
- package/src/service/flow/FlowConfigService.ts +1 -1
- package/src/service/flow/FlowInstanceCrudService.ts +1 -1
package/README.md
CHANGED
|
@@ -1,407 +1,690 @@
|
|
|
1
1
|
# Midway FatCMS
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
-
|
|
186
|
-
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
-
|
|
200
|
-
-
|
|
201
|
-
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
-
|
|
206
|
-
-
|
|
207
|
-
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
-
|
|
225
|
-
-
|
|
226
|
-
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
-
|
|
230
|
-
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
-
|
|
255
|
-
-
|
|
256
|
-
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
-
|
|
265
|
-
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
-
|
|
276
|
-
-
|
|
277
|
-
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
-
|
|
282
|
-
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong>Enterprise-Grade Low-Code / Zero-Code Development Platform</strong>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
Build production-ready enterprise applications in minutes, not months.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="#-quick-start">Quick Start</a> · <a href="#-core-engines">Core Engines</a> · <a href="#-architecture">Architecture</a> · <a href="#-api-reference">API Reference</a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Why Midway FatCMS?
|
|
18
|
+
|
|
19
|
+
Stop writing repetitive CRUD boilerplate. Stop struggling with API versioning. Stop worrying about multi-tenant data isolation.
|
|
20
|
+
|
|
21
|
+
**Midway FatCMS** is a battle-tested, enterprise-grade low-code platform that transforms weeks of development into hours of configuration. Built on top of the robust Midway.js framework, it empowers teams to ship faster without sacrificing security, scalability, or control.
|
|
22
|
+
|
|
23
|
+
### The Problem We Solve
|
|
24
|
+
|
|
25
|
+
| Traditional Development | With Midway FatCMS |
|
|
26
|
+
|------------------------|-------------------|
|
|
27
|
+
| 2 weeks to build a CRUD module | 15 minutes of configuration |
|
|
28
|
+
| Manual API documentation | Auto-generated, always in sync |
|
|
29
|
+
| Complex multi-tenant logic | Built-in tenant isolation |
|
|
30
|
+
| Hand-coded sharding & pagination | Cross-shard queries out of the box |
|
|
31
|
+
| Reinventing the wheel | Production-ready building blocks |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Core Engines
|
|
36
|
+
|
|
37
|
+
### CRUD-Pro Engine — Zero-Code Data Operations
|
|
38
|
+
|
|
39
|
+
Transform database tables into fully functional REST APIs with zero code. CRUD-Pro is the heart of Midway FatCMS, providing configuration-driven SQL execution with built-in validation, security, and multi-database support.
|
|
40
|
+
|
|
41
|
+
**Features:**
|
|
42
|
+
|
|
43
|
+
- **Instant CRUD** — Auto-generated Create, Read, Update, Delete endpoints via `sqlSimpleName`
|
|
44
|
+
- **Advanced Querying** — Pagination, sorting, filtering, joins, and MongoDB-style query operators
|
|
45
|
+
- **Field-Level Security** — Granular control over visibility (`allowCfg`), read-only, and rejected fields (`rejectCfg`)
|
|
46
|
+
- **Built-in Validation** — 20+ validators (email, phone, date, regex, length, range, enum, etc.)
|
|
47
|
+
- **Smart Relations** — Automatic data enrichment via `columnsRelation` (dict, sysConfig, account, workbench, custom)
|
|
48
|
+
- **Soft Delete** — Logical deletion with recovery support (`enableSoftDelete`)
|
|
49
|
+
- **Audit Trail** — Automatic tracking of creators, modifiers, and timestamps (`enableStandardUpdateCfg`)
|
|
50
|
+
- **Data Type Conversion** — Auto-convert JS arrays to PostgreSQL array literals, JSON strings parsed automatically
|
|
51
|
+
- **Multi-Database** — MySQL, PostgreSQL, SQL Server support with dialect-aware SQL generation
|
|
52
|
+
- **Custom SQL** — Template-based SQL with `@@placeholder` syntax for complex queries
|
|
53
|
+
- **Transaction Support** — Built-in transaction management with configurable isolation levels
|
|
54
|
+
- **Configuration Cache** — Database-stored configurations with TTL-based caching
|
|
55
|
+
|
|
56
|
+
**10-Step Execution Pipeline:**
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
1. Receive Request (RequestModel)
|
|
60
|
+
↓
|
|
61
|
+
2. Load Configuration (RequestCfgModel)
|
|
62
|
+
↓
|
|
63
|
+
3. Field Filtering (filterDataByTableMeta) — Remove non-existent columns based on table schema
|
|
64
|
+
↓
|
|
65
|
+
4. Data Type Conversion (convertDataTypeByTableMeta) — Auto-convert based on column types (e.g. PG ARRAY)
|
|
66
|
+
↓
|
|
67
|
+
5. Data Validation (validateByAllow/rejectCfg/validateCfg)
|
|
68
|
+
↓
|
|
69
|
+
6. Permission Check (validateByAuthCfg)
|
|
70
|
+
↓
|
|
71
|
+
7. Default Value Setting (updateByCfg)
|
|
72
|
+
↓
|
|
73
|
+
8. Generate SQL (generateSQLList)
|
|
74
|
+
↓
|
|
75
|
+
9. Execute SQL (executeSQLList)
|
|
76
|
+
↓
|
|
77
|
+
10. Return Result (ExecuteContext)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Quick Example:**
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
const cfgJson: IRequestCfgModel = {
|
|
84
|
+
method: 'article.list',
|
|
85
|
+
sqlTable: 'article',
|
|
86
|
+
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_PAGE,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const reqJson: IRequestModel = {
|
|
90
|
+
columns: 'id,title,content,author_id,created_at',
|
|
91
|
+
condition: {
|
|
92
|
+
status: 1,
|
|
93
|
+
category_id: { $in: [1, 2, 3] },
|
|
94
|
+
created_at: { $gte: '2024-01-01' },
|
|
95
|
+
},
|
|
96
|
+
pageNo: 1,
|
|
97
|
+
pageSize: 20,
|
|
98
|
+
orderBy: 'created_at-',
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const ctx = await crudPro.executeCrudByCfg(reqJson, cfgJson);
|
|
102
|
+
const { rows, total_count } = ctx.getResModelForQueryPage();
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
> Full CRUD-Pro documentation: [src/libs/crud-pro/README.md](src/libs/crud-pro/README.md) · Built-in Functions: [src/libs/crud-pro/README_FUNC.md](src/libs/crud-pro/README_FUNC.md)
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### Sharding Engine — Scalable Table Partitioning
|
|
110
|
+
|
|
111
|
+
Built on top of CRUD-Pro, the Sharding Engine provides transparent table partitioning with automatic routing, cross-shard pagination, and smart result merging — zero code changes required.
|
|
112
|
+
|
|
113
|
+
**Sharding Strategies:**
|
|
114
|
+
|
|
115
|
+
| Strategy | Enum | Suffix Example | Best For |
|
|
116
|
+
|----------|------|----------------|----------|
|
|
117
|
+
| By Year | `ShardingType.YEAR` | `_2024`, `_2025` | Annual reports, yearly archives |
|
|
118
|
+
| By Month | `ShardingType.MONTH` | `_202401`, `_202402` | Order systems, log tables |
|
|
119
|
+
| By Day | `ShardingType.DAY` | `_20240101` | High-volume daily logs |
|
|
120
|
+
| By Range | `ShardingType.RANGE` | `_0` ~ `_99` | Numeric ID-based partitioning |
|
|
121
|
+
| By Hash | `ShardingType.HASH` | `_01` ~ `_16` | Even distribution, user-based |
|
|
122
|
+
| Custom | `ShardingType.CUSTOM` | User-defined | Tenant-based, business-specific |
|
|
123
|
+
|
|
124
|
+
**Key Features:**
|
|
125
|
+
|
|
126
|
+
- **Automatic Routing** — Insert/update/delete routed to the correct shard based on data fields
|
|
127
|
+
- **Cross-Shard Pagination** — Transparent `queryPage()` across multiple shards with direct-offset optimization
|
|
128
|
+
- **Smart Batch Insert** — `batchInsert()` auto-groups data by shard, parallel writes across tables
|
|
129
|
+
- **COUNT Query Cache** — LRU + TTL cache for historical shard COUNT queries, real-time for current period
|
|
130
|
+
- **Table Existence Filtering** — Non-existent shards silently skipped in queries, error on insert
|
|
131
|
+
- **Multi-Sort Support** — Primary time-based sort + secondary field sorts within each shard
|
|
132
|
+
|
|
133
|
+
**Quick Example:**
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
const sharding = curdProService.getShardingCrud('mydb', SqlDbType.mysql, {
|
|
137
|
+
type: ShardingType.MONTH,
|
|
138
|
+
baseTable: 't_order',
|
|
139
|
+
timeColumn: 'created_at',
|
|
140
|
+
autoCreateTable: true,
|
|
141
|
+
countCache: { ttlSeconds: 300, maxSize: 1000 },
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Insert — auto-routes to t_order_202403
|
|
145
|
+
await sharding.insert({
|
|
146
|
+
data: { order_id: '001', amount: 100, created_at: '2024-03-15' }
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// Cross-shard pagination — automatic merging
|
|
150
|
+
const page = await sharding.queryPage({
|
|
151
|
+
condition: { status: 'paid' },
|
|
152
|
+
pageNo: 1,
|
|
153
|
+
pageSize: 10,
|
|
154
|
+
orderBy: 'created_at DESC',
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
> Full Sharding documentation: [src/libs/crud-sharding/ROUTING_LOGIC.md](src/libs/crud-sharding/ROUTING_LOGIC.md)
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
### Any API — Three Ways to Build APIs
|
|
163
|
+
|
|
164
|
+
Whether you need a simple query or complex business logic, we've got you covered.
|
|
165
|
+
|
|
166
|
+
#### 1. SQL Query API
|
|
167
|
+
Write SQL, get REST. It's that simple.
|
|
168
|
+
- Native SQL with automatic parameter binding
|
|
169
|
+
- SQL injection protection built-in
|
|
170
|
+
- Ideal for complex reports and data analytics
|
|
171
|
+
|
|
172
|
+
#### 2. Sandbox Script API
|
|
173
|
+
Safe, sandboxed Node.js execution.
|
|
174
|
+
- Isolated VM environment for secure code execution
|
|
175
|
+
- Pre-loaded utilities (axios, lodash, moment)
|
|
176
|
+
- Direct access to database, Redis, and OSS
|
|
177
|
+
|
|
178
|
+
#### 3. Custom Code API
|
|
179
|
+
Full control when you need it.
|
|
180
|
+
- Serverless-like function deployment
|
|
181
|
+
- Hot-reload without service restart
|
|
182
|
+
- Complete business logic freedom
|
|
183
|
+
|
|
184
|
+
**Enterprise Security:**
|
|
185
|
+
- JWT authentication & role-based access control
|
|
186
|
+
- Token bucket rate limiting
|
|
187
|
+
- Circuit breaker & timeout protection
|
|
188
|
+
- IP whitelist/blacklist
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
### API Gateway & Proxy — Enterprise-Grade Traffic Management
|
|
193
|
+
|
|
194
|
+
A full-featured API gateway that handles the complexity so you don't have to.
|
|
195
|
+
|
|
196
|
+
#### Load Balancing Strategies
|
|
197
|
+
- Round Robin
|
|
198
|
+
- Weighted Round Robin
|
|
199
|
+
- Random & Weighted Random
|
|
200
|
+
- IP Hash (sticky sessions by IP)
|
|
201
|
+
- User Hash (sticky sessions by user)
|
|
202
|
+
- Session Hash (sticky sessions by session)
|
|
203
|
+
|
|
204
|
+
#### Traffic Control
|
|
205
|
+
- Request rate limiting
|
|
206
|
+
- Configurable timeouts
|
|
207
|
+
- Automatic retry mechanisms
|
|
208
|
+
- Circuit breaker & fallback
|
|
209
|
+
|
|
210
|
+
#### Security & Context
|
|
211
|
+
- Real IP forwarding through proxies
|
|
212
|
+
- User context propagation
|
|
213
|
+
- Customizable headers (Host, Origin)
|
|
214
|
+
- Request/response header manipulation
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
### Multi-Tenant Architecture — True SaaS-Ready
|
|
219
|
+
|
|
220
|
+
Deploy once, serve unlimited customers. Complete tenant isolation without the complexity.
|
|
221
|
+
|
|
222
|
+
**Tenant Isolation:**
|
|
223
|
+
- **Domain Recognition** — Automatic tenant detection by domain
|
|
224
|
+
- **Data Separation** — Complete data isolation between tenants
|
|
225
|
+
- **Permission Boundaries** — Independent user, role, and permission management
|
|
226
|
+
- **Resource Isolation** — Files, configurations, and apps are tenant-scoped
|
|
227
|
+
|
|
228
|
+
**Flexible Configuration:**
|
|
229
|
+
- Primary domain + 2 backup domains per tenant
|
|
230
|
+
- Wildcard domain support
|
|
231
|
+
- Tenant templates for rapid onboarding
|
|
232
|
+
- Customizable tenant branding
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
### Workflow Engine — Automate Business Processes
|
|
237
|
+
|
|
238
|
+
Streamline approvals and business flows with a flexible workflow engine.
|
|
239
|
+
|
|
240
|
+
- Visual process definition
|
|
241
|
+
- Process instance tracking
|
|
242
|
+
- Task assignment and approval workflows
|
|
243
|
+
- Real-time status monitoring
|
|
244
|
+
- Historical flow records
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
### Document Management System — Enterprise Knowledge Base
|
|
249
|
+
|
|
250
|
+
A complete document management solution with version control and analytics.
|
|
251
|
+
|
|
252
|
+
- **Document Libraries** — Multiple document repositories
|
|
253
|
+
- **Hierarchical Structure** — Tree-based organization
|
|
254
|
+
- **Version Control** — Full document versioning
|
|
255
|
+
- **Analytics** — PV/UV tracking with IP deduplication
|
|
256
|
+
- **Access Control** — Document-level permissions
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
### File Service — Complete File Management
|
|
261
|
+
|
|
262
|
+
Enterprise file handling with cloud storage integration.
|
|
263
|
+
|
|
264
|
+
- **Upload & Download** — Single and batch file uploads
|
|
265
|
+
- **Cloud Storage** — Alibaba Cloud OSS integration (public & private buckets)
|
|
266
|
+
- **File Preview** — Images, PDFs, Office documents
|
|
267
|
+
- **Access Control** — Time-limited secure URLs
|
|
268
|
+
- **Organization** — Categories and tags
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
### System Management — Everything You Need
|
|
273
|
+
|
|
274
|
+
**User & Permissions:**
|
|
275
|
+
- User account management
|
|
276
|
+
- Role-based access control
|
|
277
|
+
- Feature-level permissions
|
|
278
|
+
- Permission allocation workflows
|
|
279
|
+
|
|
280
|
+
**Application Management:**
|
|
281
|
+
- Application registry
|
|
282
|
+
- Page management
|
|
283
|
+
- Menu configuration
|
|
284
|
+
- Low-code templates
|
|
285
|
+
|
|
286
|
+
**System Configuration:**
|
|
287
|
+
- Data dictionaries
|
|
288
|
+
- System parameters
|
|
289
|
+
- Enumeration management
|
|
290
|
+
- Scheduled tasks
|
|
291
|
+
|
|
292
|
+
**Monitoring & Operations:**
|
|
293
|
+
- Access statistics
|
|
294
|
+
- Operation logs
|
|
295
|
+
- System health info
|
|
296
|
+
- Deployment management
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Security First
|
|
301
|
+
|
|
302
|
+
We take security seriously. Built-in protection at every layer:
|
|
303
|
+
|
|
304
|
+
### Access Control
|
|
305
|
+
- JWT Token authentication
|
|
306
|
+
- Session management with Redis
|
|
307
|
+
- Super admin mechanism
|
|
308
|
+
- Granular permission control (`authType: free | login | byRoleCode | byFuncCode`)
|
|
309
|
+
|
|
310
|
+
### Attack Prevention
|
|
311
|
+
- SQL injection protection (parameterized queries)
|
|
312
|
+
- XSS protection
|
|
313
|
+
- CSRF token validation
|
|
314
|
+
- Path traversal prevention
|
|
315
|
+
- User-Agent blacklisting (scanner detection)
|
|
316
|
+
- IP-based rate limiting
|
|
317
|
+
|
|
318
|
+
### Data Protection
|
|
319
|
+
- AES-128-CBC encryption
|
|
320
|
+
- Asymmetric encryption support
|
|
321
|
+
- Sensitive field encryption
|
|
322
|
+
- Salted password hashing
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## Architecture
|
|
327
|
+
|
|
328
|
+
### Technology Stack
|
|
329
|
+
|
|
330
|
+
| Layer | Technology |
|
|
331
|
+
|-------|-----------|
|
|
332
|
+
| **Framework** | Midway.js 3.x (Enterprise Node.js) |
|
|
333
|
+
| **Web Server** | Koa |
|
|
334
|
+
| **Language** | TypeScript |
|
|
335
|
+
| **Database** | MySQL / PostgreSQL / SQL Server |
|
|
336
|
+
| **Cache** | Redis |
|
|
337
|
+
| **File Storage** | Alibaba Cloud OSS / S3-compatible |
|
|
338
|
+
|
|
339
|
+
### Core Middleware
|
|
340
|
+
|
|
341
|
+
**Global Middleware:**
|
|
342
|
+
- User session management
|
|
343
|
+
- Multi-tenant isolation
|
|
344
|
+
- Transaction management
|
|
345
|
+
- Request-level logging
|
|
346
|
+
- Unified response formatting
|
|
347
|
+
- Real IP extraction
|
|
348
|
+
|
|
349
|
+
**Security Middleware:**
|
|
350
|
+
- Login verification (`checkLogin`)
|
|
351
|
+
- Role verification (`checkRole`)
|
|
352
|
+
- Permission verification (`checkPermission`)
|
|
353
|
+
- Path blacklist (`Forbidden`)
|
|
354
|
+
- Distributed locking (`RedisLock`)
|
|
355
|
+
- Response caching (`RedisCache`)
|
|
356
|
+
|
|
357
|
+
### Project Structure
|
|
358
|
+
|
|
359
|
+
```
|
|
360
|
+
midway-fatcms/
|
|
361
|
+
├── src/
|
|
362
|
+
│ ├── config/ # Configuration files
|
|
363
|
+
│ ├── controller/ # Controllers
|
|
364
|
+
│ │ ├── base/ # Base controllers
|
|
365
|
+
│ │ ├── gateway/ # Gateway APIs (CRUD, AnyAPI, Proxy, etc.)
|
|
366
|
+
│ │ ├── manage/ # Management APIs
|
|
367
|
+
│ │ ├── myinfo/ # Personal info & Auth APIs
|
|
368
|
+
│ │ └── render/ # Rendering APIs
|
|
369
|
+
│ ├── filter/ # Exception filters
|
|
370
|
+
│ ├── libs/ # Core libraries
|
|
371
|
+
│ │ ├── crud-pro/ # CRUD-Pro engine (SQL generation, validation, execution)
|
|
372
|
+
│ │ ├── crud-sharding/ # Sharding engine (routing, merging, caching)
|
|
373
|
+
│ │ ├── global-config/ # Global configuration
|
|
374
|
+
│ │ └── utils/ # Shared utilities
|
|
375
|
+
│ ├── middleware/ # Middleware (auth, permission, tx, cache, lock)
|
|
376
|
+
│ ├── models/ # Data models & type definitions
|
|
377
|
+
│ ├── schedule/ # Scheduled tasks
|
|
378
|
+
│ ├── service/ # Business services
|
|
379
|
+
│ │ ├── anyapi/ # Dynamic API (SQL, Sandbox, Custom Code)
|
|
380
|
+
│ │ ├── asyncTask/ # Async task runner
|
|
381
|
+
│ │ ├── base/ # Base services (cache, rate limiter)
|
|
382
|
+
│ │ ├── crudstd/ # Standard CRUD (gateway-level)
|
|
383
|
+
│ │ ├── curd/ # CRUD service layer (context injection, soft delete, relations)
|
|
384
|
+
│ │ ├── flow/ # Workflow engine
|
|
385
|
+
│ │ └── proxyapi/ # Proxy API gateway
|
|
386
|
+
│ └── views/ # View templates
|
|
387
|
+
├── ddl/ # Database initialization scripts
|
|
388
|
+
├── scripts/ # Utility scripts
|
|
389
|
+
└── package.json # Project configuration
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Service Layer Architecture
|
|
393
|
+
|
|
394
|
+
```
|
|
395
|
+
Business Code
|
|
396
|
+
│
|
|
397
|
+
├── CurdMixService (orchestrator: CRUD + relation enrichment)
|
|
398
|
+
│ ├── CurdMixByDictService → relatedType: 'dict'
|
|
399
|
+
│ ├── CurdMixBySysConfigService → relatedType: 'sysCfgEnum'
|
|
400
|
+
│ ├── CurdMixByAccountService → relatedType: 'accountBasic'
|
|
401
|
+
│ ├── CurdMixByWorkbenchService → relatedType: 'workbenchBasic'
|
|
402
|
+
│ └── CurdMixByLinkToCustomService → relatedType: 'linkToCustom'
|
|
403
|
+
│
|
|
404
|
+
└── CurdProService (core service layer)
|
|
405
|
+
├── CrudProQuick → Quick CRUD (fluent API)
|
|
406
|
+
├── ShardingCrudPro → Sharded CRUD
|
|
407
|
+
├── fixCfgModel() → Standard field auto-fill
|
|
408
|
+
└── fixSoftDelete() → Soft delete handling
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
> Full service layer documentation: [src/service/curd/README.md](src/service/curd/README.md)
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
## API Reference
|
|
416
|
+
|
|
417
|
+
### CrudProQuick — Fluent CRUD API
|
|
418
|
+
|
|
419
|
+
The quickest way to perform database operations. All methods automatically inherit context (visitor, transaction, soft delete, standard fields).
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
const quick = curdProService.getQuickCrud('mydb', SqlDbType.mysql, 't_user');
|
|
423
|
+
|
|
424
|
+
// Query methods
|
|
425
|
+
const users = await quick.getList({ condition: { status: 'active' } });
|
|
426
|
+
const page = await quick.getListPage({ condition: { status: 'active' }, pageNo: 1, pageSize: 20 });
|
|
427
|
+
const user = await quick.getUniqueOne({ condition: { email: 'user@example.com' } });
|
|
428
|
+
const exists = await quick.isExist({ condition: { phone: '13800138000' } });
|
|
429
|
+
const count = await quick.getTotalCount({ condition: { status: 'active' } });
|
|
430
|
+
|
|
431
|
+
// Write methods
|
|
432
|
+
const result = await quick.insertObject({ data: { name: 'Alice', email: 'a@b.com' } });
|
|
433
|
+
const batch = await quick.batchInsert({ data: [{ name: 'A' }, { name: 'B' }] });
|
|
434
|
+
const updated = await quick.updateObject({ condition: { id: 1 }, data: { name: 'Bob' } });
|
|
435
|
+
const deleted = await quick.deleteObject({ condition: { id: 1 } });
|
|
436
|
+
const upserted = await quick.insertOnDuplicate({ data: { id: 1, name: 'A' } }, ['id']);
|
|
437
|
+
|
|
438
|
+
// Raw SQL
|
|
439
|
+
const rows = await quick.executeSQL('SELECT * FROM t_user WHERE status = ?', ['active']);
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### Query Condition Operators
|
|
443
|
+
|
|
444
|
+
MongoDB-style operators for powerful queries:
|
|
445
|
+
|
|
446
|
+
```typescript
|
|
447
|
+
const condition = {
|
|
448
|
+
status: 1, // Equal
|
|
449
|
+
age: { $gt: 18, $lt: 60 }, // Greater than / Less than
|
|
450
|
+
id: { $in: [1, 2, 3] }, // IN
|
|
451
|
+
code: { $nin: ['a', 'b'] }, // NOT IN
|
|
452
|
+
amount: { $between: [100, 500] }, // BETWEEN
|
|
453
|
+
name: { $like: '张' }, // Prefix match
|
|
454
|
+
title: { $likeInclude: '文章' }, // Contains match
|
|
455
|
+
deleted_at: { $isNull: true }, // IS NULL
|
|
456
|
+
updated_at: { $isNotNull: true }, // IS NOT NULL
|
|
457
|
+
$or: [{ name: { $like: '张' } }, { name: { $like: '李' } }], // OR
|
|
458
|
+
};
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
### Sorting Syntax
|
|
462
|
+
|
|
463
|
+
```typescript
|
|
464
|
+
// Standard SQL format
|
|
465
|
+
orderBy: 'created_at DESC, amount ASC'
|
|
466
|
+
|
|
467
|
+
// Shorthand format (+ ascending, - descending)
|
|
468
|
+
orderBy: 'created_at-, amount+'
|
|
469
|
+
|
|
470
|
+
// Array format (mixed strings & objects)
|
|
471
|
+
orderBy: ['order_id', { fieldName: 'created_at', orderType: 'desc' }, 'amount+']
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
### ShardingCrudPro API
|
|
475
|
+
|
|
476
|
+
| Method | Returns | Description |
|
|
477
|
+
|--------|---------|-------------|
|
|
478
|
+
| `insert(reqJson)` | `ExecuteContext` | Insert single record (auto-route) |
|
|
479
|
+
| `batchInsert(reqJson)` | `IShardingSmartBatchInsertResult` | Batch insert (cross-shard, parallel) |
|
|
480
|
+
| `update(reqJson)` | `ExecuteContext` | Update data |
|
|
481
|
+
| `delete(reqJson)` | `ExecuteContext` | Delete data |
|
|
482
|
+
| `insertOrUpdate(reqJson)` | `ExecuteContext` | Insert or update |
|
|
483
|
+
| `insertOnDuplicateUpdate(reqJson)` | `ExecuteContext` | Native upsert |
|
|
484
|
+
| `queryOne(reqJson)` | `any \| null` | Query single record |
|
|
485
|
+
| `query(reqJson)` | `any[]` | List query (auto-merge shards) |
|
|
486
|
+
| `queryPage(reqJson)` | `IShardingPageQueryResult` | Cross-shard pagination |
|
|
487
|
+
| `queryCount(reqJson)` | `number` | Count across shards |
|
|
488
|
+
| `isExist(reqJson)` | `boolean` | Existence check across shards |
|
|
489
|
+
|
|
490
|
+
### Built-in Functions
|
|
491
|
+
|
|
492
|
+
CrudPro provides 30+ built-in functions for `updateCfg`, `validateCfg`, `executeWhen`, and `validate`:
|
|
493
|
+
|
|
494
|
+
**DateTime:** `getCurrentTimeStampMs`, `getCurrentTimeStampSecond`, `getCurrentTimeString`, `getCurrentDateFormat`, `getYesterdayDateFormat`
|
|
495
|
+
|
|
496
|
+
**Compare:** `eq`, `ne`, `gt`, `gte`, `lt`, `lte`
|
|
497
|
+
|
|
498
|
+
**Utility:** `isNil`, `isNotNil`, `isEmpty`, `isNotEmpty`, `equals`, `equalsIgnoreCase`, `startsWith`, `isValidFieldName`, `selectNotEmpty`, `hasAny`, `parseValueByType`, `sleepMs`, `uuid`, `generateSnowflakeId`
|
|
499
|
+
|
|
500
|
+
**Type Check:** `isBasicType`, `isBoolean`, `isString`, `isInteger`, `isNumber`, `isNumeric`, `isValidName`, `isChinesePhone`, `isEmailStrValid`, `pickNumber`
|
|
501
|
+
|
|
502
|
+
> Full function reference: [src/libs/crud-pro/README_FUNC.md](src/libs/crud-pro/README_FUNC.md)
|
|
503
|
+
|
|
504
|
+
### Soft Delete
|
|
505
|
+
|
|
506
|
+
When `enableSoftDelete: true`, operations are automatically rewritten:
|
|
507
|
+
|
|
508
|
+
| Operation | Original | With Soft Delete |
|
|
509
|
+
|-----------|----------|-----------------|
|
|
510
|
+
| INSERT | Normal insert | Auto-set `data.deleted_at = 0` |
|
|
511
|
+
| DELETE | Physical DELETE | UPDATE: `deleted_at = timestamp`, `deleted_by = userId` |
|
|
512
|
+
| QUERY | Normal query | Auto-append `condition.deleted_at = 0` |
|
|
513
|
+
|
|
514
|
+
### Standard Field Auto-Fill
|
|
515
|
+
|
|
516
|
+
When `enableStandardUpdateCfg: true`, standard fields are automatically populated:
|
|
517
|
+
|
|
518
|
+
| Operation | Auto-Filled Fields |
|
|
519
|
+
|-----------|--------------------|
|
|
520
|
+
| INSERT | `created_by`, `created_avatar`, `created_nickname`, `created_account_type` |
|
|
521
|
+
| UPDATE | `modified_by`, `modified_avatar`, `modified_nickname`, `modified_account_type` |
|
|
522
|
+
| DELETE | — (condition auto-includes `created_by` for ownership check) |
|
|
523
|
+
|
|
524
|
+
### Data Type Auto-Conversion
|
|
525
|
+
|
|
526
|
+
CrudPro automatically converts data types based on table schema before INSERT/UPDATE:
|
|
527
|
+
|
|
528
|
+
**PostgreSQL ARRAY** — JS arrays are automatically converted to PG array literal format:
|
|
529
|
+
|
|
530
|
+
| Input | Converted | Description |
|
|
531
|
+
|-------|-----------|-------------|
|
|
532
|
+
| `["a","b","c"]` | `{"a","b","c"}` | String arrays: double-quoted |
|
|
533
|
+
| `[1,2,3]` | `{1,2,3}` | Number arrays: no quotes |
|
|
534
|
+
| `[true,false]` | `{t,f}` | Boolean arrays: t/f notation |
|
|
535
|
+
| `[1,null,3]` | `{1,NULL,3}` | Null handling |
|
|
536
|
+
| `[]` | `{}` | Empty arrays |
|
|
537
|
+
| `['he"llo']` | `{"he\"llo"}` | Special character escaping |
|
|
538
|
+
|
|
539
|
+
> Only applies to PostgreSQL; MySQL and SQL Server drivers handle type conversion natively.
|
|
540
|
+
|
|
541
|
+
---
|
|
542
|
+
|
|
543
|
+
## Quick Start
|
|
544
|
+
|
|
545
|
+
### Prerequisites
|
|
297
546
|
|
|
298
547
|
- Node.js >= 10
|
|
299
548
|
- MySQL >= 5.7 / PostgreSQL >= 8 / SQL Server >= 11
|
|
300
549
|
- Redis >= 3.0
|
|
301
550
|
|
|
302
|
-
###
|
|
551
|
+
### Installation
|
|
303
552
|
|
|
304
553
|
```bash
|
|
554
|
+
# Clone the repository
|
|
555
|
+
git clone <repository-url>
|
|
556
|
+
cd midway-fatcms
|
|
557
|
+
|
|
558
|
+
# Install dependencies
|
|
305
559
|
npm install
|
|
306
560
|
```
|
|
307
561
|
|
|
308
|
-
###
|
|
562
|
+
### Configuration
|
|
309
563
|
|
|
310
|
-
1.
|
|
311
|
-
2.
|
|
312
|
-
3.
|
|
313
|
-
4.
|
|
564
|
+
1. Configure database connection in `src/config/config.default.ts`
|
|
565
|
+
2. Set up Redis connection
|
|
566
|
+
3. Configure OSS (optional)
|
|
567
|
+
4. Configure workbench information
|
|
314
568
|
|
|
315
|
-
###
|
|
569
|
+
### Database Setup
|
|
316
570
|
|
|
317
571
|
```sql
|
|
318
|
-
--
|
|
572
|
+
-- Run initialization SQL
|
|
319
573
|
source ddl/2025-12-20.sql
|
|
320
574
|
```
|
|
321
575
|
|
|
322
|
-
###
|
|
576
|
+
### Start Development
|
|
323
577
|
|
|
324
578
|
```bash
|
|
325
|
-
#
|
|
579
|
+
# Development mode with hot reload
|
|
326
580
|
npm run dev
|
|
327
581
|
|
|
328
|
-
#
|
|
582
|
+
# Build for production
|
|
329
583
|
npm run build
|
|
330
584
|
|
|
331
|
-
#
|
|
585
|
+
# Start production server
|
|
332
586
|
npm start
|
|
333
587
|
```
|
|
334
588
|
|
|
335
|
-
###
|
|
589
|
+
### Code Quality
|
|
336
590
|
|
|
337
591
|
```bash
|
|
338
|
-
#
|
|
592
|
+
# Check code style
|
|
339
593
|
npm run lint
|
|
340
594
|
|
|
341
|
-
#
|
|
595
|
+
# Auto-fix issues
|
|
342
596
|
npm run lint:fix
|
|
343
597
|
```
|
|
344
598
|
|
|
345
|
-
###
|
|
599
|
+
### Testing
|
|
346
600
|
|
|
347
601
|
```bash
|
|
348
|
-
#
|
|
602
|
+
# Run tests
|
|
349
603
|
npm test
|
|
350
604
|
|
|
351
|
-
#
|
|
605
|
+
# Generate coverage report
|
|
352
606
|
npm run cov
|
|
353
607
|
```
|
|
354
608
|
|
|
355
|
-
|
|
609
|
+
---
|
|
610
|
+
|
|
611
|
+
## Use Cases
|
|
612
|
+
|
|
613
|
+
### Enterprise Back-Office Systems
|
|
614
|
+
- Rapid admin dashboard creation
|
|
615
|
+
- Business system configuration hubs
|
|
616
|
+
- Internal tool platforms
|
|
617
|
+
|
|
618
|
+
### SaaS Platforms
|
|
619
|
+
- Multi-tenant applications
|
|
620
|
+
- White-label products
|
|
621
|
+
- Industry-specific solutions
|
|
356
622
|
|
|
357
|
-
###
|
|
623
|
+
### API Platforms
|
|
624
|
+
- API management & gateways
|
|
625
|
+
- Data open platforms
|
|
626
|
+
- Microservice aggregation
|
|
627
|
+
|
|
628
|
+
### High-Volume Data Systems
|
|
629
|
+
- Sharded order management (millions of records per month)
|
|
630
|
+
- Time-series log storage with auto-routing
|
|
631
|
+
- Real-time analytics across partitioned tables
|
|
632
|
+
|
|
633
|
+
### Low-Code Development
|
|
634
|
+
- Rapid business system development
|
|
635
|
+
- Form-driven applications
|
|
636
|
+
- Data analysis platforms
|
|
637
|
+
|
|
638
|
+
### Content Management
|
|
639
|
+
- Document repositories
|
|
640
|
+
- Knowledge bases
|
|
641
|
+
- Content publishing platforms
|
|
642
|
+
|
|
643
|
+
---
|
|
644
|
+
|
|
645
|
+
## Utility Endpoints
|
|
646
|
+
|
|
647
|
+
### Encryption Helper
|
|
358
648
|
|
|
359
649
|
```
|
|
360
650
|
http://127.0.0.1:7002/ns/api/helpers/cryptoAes128CBC?input=123
|
|
361
651
|
```
|
|
362
652
|
|
|
363
|
-
|
|
653
|
+
---
|
|
364
654
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
│ │ ├── asyncTask/ # 异步任务
|
|
386
|
-
│ │ ├── base/ # 基础服务
|
|
387
|
-
│ │ ├── crudstd/ # CRUD 标准
|
|
388
|
-
│ │ ├── curd/ # CRUD 服务
|
|
389
|
-
│ │ ├── flow/ # 工作流
|
|
390
|
-
│ │ └── proxyapi/ # 代理 API
|
|
391
|
-
│ └── views/ # 视图模板
|
|
392
|
-
├── ddl/ # 数据库脚本
|
|
393
|
-
├── scripts/ # 脚本工具
|
|
394
|
-
└── package.json # 项目配置
|
|
395
|
-
```
|
|
655
|
+
## Documentation Index
|
|
656
|
+
|
|
657
|
+
| Document | Description |
|
|
658
|
+
|----------|-------------|
|
|
659
|
+
| [CRUD-Pro Guide](src/libs/crud-pro/README.md) | Configuration-driven CRUD operations, validation, permissions |
|
|
660
|
+
| [Built-in Functions](src/libs/crud-pro/README_FUNC.md) | 30+ functions: date, compare, utility, type check |
|
|
661
|
+
| [Service Layer Guide](src/service/curd/README.md) | Context injection, soft delete, quick CRUD, sharding, relations |
|
|
662
|
+
| [Sharding Routing Logic](src/libs/crud-sharding/ROUTING_LOGIC.md) | Shard strategies, cross-shard pagination, COUNT cache |
|
|
663
|
+
|
|
664
|
+
---
|
|
665
|
+
|
|
666
|
+
## Version
|
|
667
|
+
|
|
668
|
+
Current Version: `0.0.1-beta.82`
|
|
669
|
+
|
|
670
|
+
---
|
|
671
|
+
|
|
672
|
+
## License
|
|
673
|
+
|
|
674
|
+
MIT License — Use it freely, contribute often.
|
|
396
675
|
|
|
397
|
-
|
|
676
|
+
---
|
|
398
677
|
|
|
399
|
-
|
|
678
|
+
## Contributing
|
|
400
679
|
|
|
401
|
-
|
|
680
|
+
We welcome contributions! Whether it's bug reports, feature requests, or pull requests, your input helps make Midway FatCMS better for everyone.
|
|
402
681
|
|
|
403
|
-
|
|
682
|
+
---
|
|
404
683
|
|
|
405
|
-
|
|
684
|
+
<p align="center">
|
|
685
|
+
<strong>Built with care by the Enterprise Low-Code Development Team</strong>
|
|
686
|
+
</p>
|
|
406
687
|
|
|
407
|
-
|
|
688
|
+
<p align="center">
|
|
689
|
+
Ready to ship faster? Let's build something amazing together.
|
|
690
|
+
</p>
|