@kne/fastify-account 1.0.0-alpha.20 → 1.0.0-alpha.22
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 +463 -185
- package/index.js +1 -1
- package/libs/controllers/adminTenant.js +116 -27
- package/libs/controllers/requestLog.js +1 -1
- package/libs/services/tenant-user.js +5 -1
- package/libs/services/tenant.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ npm i --save @kne/fastify-account
|
|
|
22
22
|
### API
|
|
23
23
|
|
|
24
24
|
---
|
|
25
|
-
title: "@kne/fastify-account v1.0.0-alpha.
|
|
25
|
+
title: "@kne/fastify-account v1.0.0-alpha.21"
|
|
26
26
|
language_tabs:
|
|
27
27
|
- shell: Shell
|
|
28
28
|
- http: HTTP
|
|
@@ -42,7 +42,7 @@ headingLevel: 2
|
|
|
42
42
|
|
|
43
43
|
<!-- Generator: Widdershins v4.0.1 -->
|
|
44
44
|
|
|
45
|
-
<h1 id="-kne-fastify-account">@kne/fastify-account v1.0.0-alpha.
|
|
45
|
+
<h1 id="-kne-fastify-account">@kne/fastify-account v1.0.0-alpha.21</h1>
|
|
46
46
|
|
|
47
47
|
> Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.
|
|
48
48
|
|
|
@@ -64,127 +64,9 @@ fastify的用户管理账号等实现
|
|
|
64
64
|
This operation does not require authentication
|
|
65
65
|
</aside>
|
|
66
66
|
|
|
67
|
-
##
|
|
68
|
-
|
|
69
|
-
`GET /api/v1/account/admin/getAllTenantList`
|
|
70
|
-
|
|
71
|
-
<h3 id="get__api_v1_account_admin_getalltenantlist-parameters">Parameters</h3>
|
|
72
|
-
|
|
73
|
-
|Name|In|Type|Required|Description|
|
|
74
|
-
|---|---|---|---|---|
|
|
75
|
-
|name|query|string|false|none|
|
|
76
|
-
|serviceStartTime|query|string(date-time)|false|none|
|
|
77
|
-
|serviceEndTime|query|string(date-time)|false|none|
|
|
78
|
-
|perPage|query|number|false|none|
|
|
79
|
-
|currentPage|query|number|false|none|
|
|
80
|
-
|
|
81
|
-
<h3 id="get__api_v1_account_admin_getalltenantlist-responses">Responses</h3>
|
|
82
|
-
|
|
83
|
-
|Status|Meaning|Description|Schema|
|
|
84
|
-
|---|---|---|---|
|
|
85
|
-
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|None|
|
|
86
|
-
|
|
87
|
-
<aside class="success">
|
|
88
|
-
This operation does not require authentication
|
|
89
|
-
</aside>
|
|
90
|
-
|
|
91
|
-
## get__api_v1_account_admin_getTenantInfo
|
|
92
|
-
|
|
93
|
-
`GET /api/v1/account/admin/getTenantInfo`
|
|
94
|
-
|
|
95
|
-
<h3 id="get__api_v1_account_admin_gettenantinfo-parameters">Parameters</h3>
|
|
96
|
-
|
|
97
|
-
|Name|In|Type|Required|Description|
|
|
98
|
-
|---|---|---|---|---|
|
|
99
|
-
|id|query|string|false|none|
|
|
100
|
-
|
|
101
|
-
<h3 id="get__api_v1_account_admin_gettenantinfo-responses">Responses</h3>
|
|
102
|
-
|
|
103
|
-
|Status|Meaning|Description|Schema|
|
|
104
|
-
|---|---|---|---|
|
|
105
|
-
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|None|
|
|
106
|
-
|
|
107
|
-
<aside class="success">
|
|
108
|
-
This operation does not require authentication
|
|
109
|
-
</aside>
|
|
110
|
-
|
|
111
|
-
## post__api_v1_account_admin_closeTenant
|
|
112
|
-
|
|
113
|
-
`POST /api/v1/account/admin/closeTenant`
|
|
114
|
-
|
|
115
|
-
> Body parameter
|
|
116
|
-
|
|
117
|
-
```json
|
|
118
|
-
{
|
|
119
|
-
"type": "object",
|
|
120
|
-
"required": [
|
|
121
|
-
"tenantId"
|
|
122
|
-
],
|
|
123
|
-
"properties": {
|
|
124
|
-
"tenantId": {
|
|
125
|
-
"type": "string"
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
<h3 id="post__api_v1_account_admin_closetenant-parameters">Parameters</h3>
|
|
132
|
-
|
|
133
|
-
|Name|In|Type|Required|Description|
|
|
134
|
-
|---|---|---|---|---|
|
|
135
|
-
|body|body|object|true|none|
|
|
136
|
-
|» tenantId|body|string|true|none|
|
|
137
|
-
|
|
138
|
-
<h3 id="post__api_v1_account_admin_closetenant-responses">Responses</h3>
|
|
139
|
-
|
|
140
|
-
|Status|Meaning|Description|Schema|
|
|
141
|
-
|---|---|---|---|
|
|
142
|
-
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|None|
|
|
143
|
-
|
|
144
|
-
<aside class="success">
|
|
145
|
-
This operation does not require authentication
|
|
146
|
-
</aside>
|
|
147
|
-
|
|
148
|
-
## post__api_v1_account_admin_openTenant
|
|
149
|
-
|
|
150
|
-
`POST /api/v1/account/admin/openTenant`
|
|
151
|
-
|
|
152
|
-
> Body parameter
|
|
153
|
-
|
|
154
|
-
```json
|
|
155
|
-
{
|
|
156
|
-
"type": "object",
|
|
157
|
-
"required": [
|
|
158
|
-
"tenantId"
|
|
159
|
-
],
|
|
160
|
-
"properties": {
|
|
161
|
-
"tenantId": {
|
|
162
|
-
"type": "string"
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
<h3 id="post__api_v1_account_admin_opentenant-parameters">Parameters</h3>
|
|
169
|
-
|
|
170
|
-
|Name|In|Type|Required|Description|
|
|
171
|
-
|---|---|---|---|---|
|
|
172
|
-
|body|body|object|true|none|
|
|
173
|
-
|» tenantId|body|string|true|none|
|
|
174
|
-
|
|
175
|
-
<h3 id="post__api_v1_account_admin_opentenant-responses">Responses</h3>
|
|
176
|
-
|
|
177
|
-
|Status|Meaning|Description|Schema|
|
|
178
|
-
|---|---|---|---|
|
|
179
|
-
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|None|
|
|
180
|
-
|
|
181
|
-
<aside class="success">
|
|
182
|
-
This operation does not require authentication
|
|
183
|
-
</aside>
|
|
184
|
-
|
|
185
|
-
## post__api_v1_account_admin_addTenant
|
|
67
|
+
## post__api_v1_account_admin_saveTenant
|
|
186
68
|
|
|
187
|
-
`POST /api/v1/account/admin/
|
|
69
|
+
`POST /api/v1/account/admin/saveTenant`
|
|
188
70
|
|
|
189
71
|
> Body parameter
|
|
190
72
|
|
|
@@ -192,104 +74,81 @@ This operation does not require authentication
|
|
|
192
74
|
{
|
|
193
75
|
"type": "object",
|
|
194
76
|
"required": [
|
|
77
|
+
"id",
|
|
195
78
|
"name",
|
|
196
79
|
"accountNumber",
|
|
197
80
|
"serviceStartTime",
|
|
198
81
|
"serviceEndTime"
|
|
199
82
|
],
|
|
200
83
|
"properties": {
|
|
84
|
+
"id": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"description": "租户id"
|
|
87
|
+
},
|
|
201
88
|
"name": {
|
|
202
|
-
"type": "string"
|
|
89
|
+
"type": "string",
|
|
90
|
+
"description": "租户名称"
|
|
203
91
|
},
|
|
204
|
-
"
|
|
205
|
-
"type": "
|
|
92
|
+
"description": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"description": "租户简介"
|
|
206
95
|
},
|
|
207
96
|
"serviceStartTime": {
|
|
208
97
|
"type": "string",
|
|
209
|
-
"
|
|
98
|
+
"description": "服务开始时间"
|
|
210
99
|
},
|
|
211
100
|
"serviceEndTime": {
|
|
212
101
|
"type": "string",
|
|
213
|
-
"
|
|
102
|
+
"description": "服务结束时间"
|
|
103
|
+
},
|
|
104
|
+
"accountNumber": {
|
|
105
|
+
"type": "number",
|
|
106
|
+
"description": "最大租户用户数量"
|
|
214
107
|
}
|
|
215
108
|
}
|
|
216
109
|
}
|
|
217
110
|
```
|
|
218
111
|
|
|
219
|
-
<h3 id="
|
|
112
|
+
<h3 id="post__api_v1_account_admin_savetenant-parameters">Parameters</h3>
|
|
220
113
|
|
|
221
114
|
|Name|In|Type|Required|Description|
|
|
222
115
|
|---|---|---|---|---|
|
|
223
116
|
|body|body|object|true|none|
|
|
224
|
-
|»
|
|
225
|
-
|»
|
|
226
|
-
|»
|
|
227
|
-
|»
|
|
228
|
-
|
|
229
|
-
|
|
117
|
+
|» id|body|string|true|租户id|
|
|
118
|
+
|» name|body|string|true|租户名称|
|
|
119
|
+
|» description|body|string|false|租户简介|
|
|
120
|
+
|» serviceStartTime|body|string|true|服务开始时间|
|
|
121
|
+
|» serviceEndTime|body|string|true|服务结束时间|
|
|
122
|
+
|» accountNumber|body|number|true|最大租户用户数量|
|
|
230
123
|
|
|
231
|
-
|
|
232
|
-
|---|---|---|---|
|
|
233
|
-
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|None|
|
|
234
|
-
|
|
235
|
-
<aside class="success">
|
|
236
|
-
This operation does not require authentication
|
|
237
|
-
</aside>
|
|
238
|
-
|
|
239
|
-
## post__api_v1_account_admin_saveTenant
|
|
240
|
-
|
|
241
|
-
`POST /api/v1/account/admin/saveTenant`
|
|
124
|
+
> Example responses
|
|
242
125
|
|
|
243
|
-
>
|
|
126
|
+
> 200 Response
|
|
244
127
|
|
|
245
128
|
```json
|
|
246
129
|
{
|
|
247
130
|
"type": "object",
|
|
248
|
-
"required": [
|
|
249
|
-
"id",
|
|
250
|
-
"name",
|
|
251
|
-
"accountNumber",
|
|
252
|
-
"serviceStartTime",
|
|
253
|
-
"serviceEndTime"
|
|
254
|
-
],
|
|
255
131
|
"properties": {
|
|
256
|
-
"
|
|
257
|
-
"
|
|
258
|
-
},
|
|
259
|
-
"name": {
|
|
260
|
-
"type": "string"
|
|
261
|
-
},
|
|
262
|
-
"accountNumber": {
|
|
263
|
-
"type": "number"
|
|
264
|
-
},
|
|
265
|
-
"serviceStartTime": {
|
|
266
|
-
"type": "string",
|
|
267
|
-
"format": "date-time"
|
|
268
|
-
},
|
|
269
|
-
"serviceEndTime": {
|
|
270
|
-
"type": "string",
|
|
271
|
-
"format": "date-time"
|
|
132
|
+
"content": {
|
|
133
|
+
"application/json": {}
|
|
272
134
|
}
|
|
273
135
|
}
|
|
274
136
|
}
|
|
275
137
|
```
|
|
276
138
|
|
|
277
|
-
<h3 id="post__api_v1_account_admin_savetenant-parameters">Parameters</h3>
|
|
278
|
-
|
|
279
|
-
|Name|In|Type|Required|Description|
|
|
280
|
-
|---|---|---|---|---|
|
|
281
|
-
|body|body|object|true|none|
|
|
282
|
-
|» id|body|string|true|none|
|
|
283
|
-
|» name|body|string|true|none|
|
|
284
|
-
|» accountNumber|body|number|true|none|
|
|
285
|
-
|» serviceStartTime|body|string(date-time)|true|none|
|
|
286
|
-
|» serviceEndTime|body|string(date-time)|true|none|
|
|
287
|
-
|
|
288
139
|
<h3 id="post__api_v1_account_admin_savetenant-responses">Responses</h3>
|
|
289
140
|
|
|
290
141
|
|Status|Meaning|Description|Schema|
|
|
291
142
|
|---|---|---|---|
|
|
292
|
-
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|
|
|
143
|
+
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|Inline|
|
|
144
|
+
|
|
145
|
+
<h3 id="post__api_v1_account_admin_savetenant-responseschema">Response Schema</h3>
|
|
146
|
+
|
|
147
|
+
Status Code **200**
|
|
148
|
+
|
|
149
|
+
|Name|Type|Required|Restrictions|Description|
|
|
150
|
+
|---|---|---|---|---|
|
|
151
|
+
|» content|any|false|none|none|
|
|
293
152
|
|
|
294
153
|
<aside class="success">
|
|
295
154
|
This operation does not require authentication
|
|
@@ -2773,9 +2632,9 @@ This operation does not require authentication
|
|
|
2773
2632
|
This operation does not require authentication
|
|
2774
2633
|
</aside>
|
|
2775
2634
|
|
|
2776
|
-
##
|
|
2635
|
+
## post__api_v1_account_tenant_getTenantOperationLogList
|
|
2777
2636
|
|
|
2778
|
-
`POST /api/v1/account/
|
|
2637
|
+
`POST /api/v1/account/tenant/getTenantOperationLogList`
|
|
2779
2638
|
|
|
2780
2639
|
*获取租户操作日志列表*
|
|
2781
2640
|
|
|
@@ -2802,7 +2661,7 @@ This operation does not require authentication
|
|
|
2802
2661
|
}
|
|
2803
2662
|
```
|
|
2804
2663
|
|
|
2805
|
-
<h3 id="
|
|
2664
|
+
<h3 id="post__api_v1_account_tenant_gettenantoperationloglist-parameters">Parameters</h3>
|
|
2806
2665
|
|
|
2807
2666
|
|Name|In|Type|Required|Description|
|
|
2808
2667
|
|---|---|---|---|---|
|
|
@@ -2812,7 +2671,7 @@ This operation does not require authentication
|
|
|
2812
2671
|
|» perPage|body|number|false|none|
|
|
2813
2672
|
|» currentPage|body|number|false|none|
|
|
2814
2673
|
|
|
2815
|
-
<h3 id="
|
|
2674
|
+
<h3 id="post__api_v1_account_tenant_gettenantoperationloglist-responses">Responses</h3>
|
|
2816
2675
|
|
|
2817
2676
|
|Status|Meaning|Description|Schema|
|
|
2818
2677
|
|---|---|---|---|
|
|
@@ -3519,6 +3378,425 @@ This operation does not require authentication
|
|
|
3519
3378
|
This operation does not require authentication
|
|
3520
3379
|
</aside>
|
|
3521
3380
|
|
|
3381
|
+
<h1 id="-kne-fastify-account--">管理后台-租户</h1>
|
|
3382
|
+
|
|
3383
|
+
## get__api_v1_account_admin_getAllTenantList
|
|
3384
|
+
|
|
3385
|
+
`GET /api/v1/account/admin/getAllTenantList`
|
|
3386
|
+
|
|
3387
|
+
*获取租户列表*
|
|
3388
|
+
|
|
3389
|
+
<h3 id="get__api_v1_account_admin_getalltenantlist-parameters">Parameters</h3>
|
|
3390
|
+
|
|
3391
|
+
|Name|In|Type|Required|Description|
|
|
3392
|
+
|---|---|---|---|---|
|
|
3393
|
+
|name|query|string|false|租户名|
|
|
3394
|
+
|serviceStartTime|query|string(date-time)|false|服务开始时间|
|
|
3395
|
+
|serviceEndTime|query|string(date-time)|false|服务结束时间|
|
|
3396
|
+
|perPage|query|number|false|每页条数|
|
|
3397
|
+
|currentPage|query|number|false|页数|
|
|
3398
|
+
|
|
3399
|
+
> Example responses
|
|
3400
|
+
|
|
3401
|
+
> 200 Response
|
|
3402
|
+
|
|
3403
|
+
```json
|
|
3404
|
+
{
|
|
3405
|
+
"type": "object",
|
|
3406
|
+
"properties": {
|
|
3407
|
+
"pageData": {
|
|
3408
|
+
"type": "array",
|
|
3409
|
+
"items": {
|
|
3410
|
+
"type": "object",
|
|
3411
|
+
"properties": {
|
|
3412
|
+
"id": {
|
|
3413
|
+
"type": "string",
|
|
3414
|
+
"description": "租户id"
|
|
3415
|
+
},
|
|
3416
|
+
"name": {
|
|
3417
|
+
"type": "string",
|
|
3418
|
+
"description": "租户名称"
|
|
3419
|
+
},
|
|
3420
|
+
"description": {
|
|
3421
|
+
"type": "string",
|
|
3422
|
+
"description": "租户简介"
|
|
3423
|
+
},
|
|
3424
|
+
"serviceStartTime": {
|
|
3425
|
+
"type": "string",
|
|
3426
|
+
"description": "服务开始时间"
|
|
3427
|
+
},
|
|
3428
|
+
"serviceEndTime": {
|
|
3429
|
+
"type": "string",
|
|
3430
|
+
"description": "服务结束时间"
|
|
3431
|
+
},
|
|
3432
|
+
"accountNumber": {
|
|
3433
|
+
"type": "number",
|
|
3434
|
+
"description": "最大租户用户数量"
|
|
3435
|
+
},
|
|
3436
|
+
"status": {
|
|
3437
|
+
"type": "number",
|
|
3438
|
+
"description": "0:正常,10:过期被关闭,11:已禁用,12:已关闭"
|
|
3439
|
+
},
|
|
3440
|
+
"createdAt": {
|
|
3441
|
+
"type": "string",
|
|
3442
|
+
"description": "创建时间"
|
|
3443
|
+
},
|
|
3444
|
+
"updatedAt": {
|
|
3445
|
+
"type": "string",
|
|
3446
|
+
"description": "更新时间"
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
}
|
|
3450
|
+
},
|
|
3451
|
+
"totalCount": {
|
|
3452
|
+
"type": "number",
|
|
3453
|
+
"description": "总数量"
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
```
|
|
3458
|
+
|
|
3459
|
+
<h3 id="get__api_v1_account_admin_getalltenantlist-responses">Responses</h3>
|
|
3460
|
+
|
|
3461
|
+
|Status|Meaning|Description|Schema|
|
|
3462
|
+
|---|---|---|---|
|
|
3463
|
+
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|Inline|
|
|
3464
|
+
|
|
3465
|
+
<h3 id="get__api_v1_account_admin_getalltenantlist-responseschema">Response Schema</h3>
|
|
3466
|
+
|
|
3467
|
+
Status Code **200**
|
|
3468
|
+
|
|
3469
|
+
|Name|Type|Required|Restrictions|Description|
|
|
3470
|
+
|---|---|---|---|---|
|
|
3471
|
+
|» pageData|[object]|false|none|none|
|
|
3472
|
+
|»» id|string|false|none|租户id|
|
|
3473
|
+
|»» name|string|false|none|租户名称|
|
|
3474
|
+
|»» description|string|false|none|租户简介|
|
|
3475
|
+
|»» serviceStartTime|string|false|none|服务开始时间|
|
|
3476
|
+
|»» serviceEndTime|string|false|none|服务结束时间|
|
|
3477
|
+
|»» accountNumber|number|false|none|最大租户用户数量|
|
|
3478
|
+
|»» status|number|false|none|0:正常,10:过期被关闭,11:已禁用,12:已关闭|
|
|
3479
|
+
|»» createdAt|string|false|none|创建时间|
|
|
3480
|
+
|»» updatedAt|string|false|none|更新时间|
|
|
3481
|
+
|» totalCount|number|false|none|总数量|
|
|
3482
|
+
|
|
3483
|
+
<aside class="success">
|
|
3484
|
+
This operation does not require authentication
|
|
3485
|
+
</aside>
|
|
3486
|
+
|
|
3487
|
+
## get__api_v1_account_admin_getTenantInfo
|
|
3488
|
+
|
|
3489
|
+
`GET /api/v1/account/admin/getTenantInfo`
|
|
3490
|
+
|
|
3491
|
+
*获取租户基本信息*
|
|
3492
|
+
|
|
3493
|
+
<h3 id="get__api_v1_account_admin_gettenantinfo-parameters">Parameters</h3>
|
|
3494
|
+
|
|
3495
|
+
|Name|In|Type|Required|Description|
|
|
3496
|
+
|---|---|---|---|---|
|
|
3497
|
+
|id|query|string|false|租户id|
|
|
3498
|
+
|
|
3499
|
+
> Example responses
|
|
3500
|
+
|
|
3501
|
+
> 200 Response
|
|
3502
|
+
|
|
3503
|
+
```json
|
|
3504
|
+
{
|
|
3505
|
+
"type": "object",
|
|
3506
|
+
"properties": {
|
|
3507
|
+
"id": {
|
|
3508
|
+
"type": "string",
|
|
3509
|
+
"description": "租户id"
|
|
3510
|
+
},
|
|
3511
|
+
"name": {
|
|
3512
|
+
"type": "string",
|
|
3513
|
+
"description": "租户名称"
|
|
3514
|
+
},
|
|
3515
|
+
"description": {
|
|
3516
|
+
"type": "string",
|
|
3517
|
+
"description": "租户简介"
|
|
3518
|
+
},
|
|
3519
|
+
"serviceStartTime": {
|
|
3520
|
+
"type": "string",
|
|
3521
|
+
"description": "服务开始时间"
|
|
3522
|
+
},
|
|
3523
|
+
"serviceEndTime": {
|
|
3524
|
+
"type": "string",
|
|
3525
|
+
"description": "服务结束时间"
|
|
3526
|
+
},
|
|
3527
|
+
"accountNumber": {
|
|
3528
|
+
"type": "number",
|
|
3529
|
+
"description": "最大租户用户数量"
|
|
3530
|
+
},
|
|
3531
|
+
"status": {
|
|
3532
|
+
"type": "number",
|
|
3533
|
+
"description": "0:正常,10:过期被关闭,11:已禁用,12:已关闭"
|
|
3534
|
+
},
|
|
3535
|
+
"createdAt": {
|
|
3536
|
+
"type": "string",
|
|
3537
|
+
"description": "创建时间"
|
|
3538
|
+
},
|
|
3539
|
+
"updatedAt": {
|
|
3540
|
+
"type": "string",
|
|
3541
|
+
"description": "更新时间"
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
}
|
|
3545
|
+
```
|
|
3546
|
+
|
|
3547
|
+
<h3 id="get__api_v1_account_admin_gettenantinfo-responses">Responses</h3>
|
|
3548
|
+
|
|
3549
|
+
|Status|Meaning|Description|Schema|
|
|
3550
|
+
|---|---|---|---|
|
|
3551
|
+
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|Inline|
|
|
3552
|
+
|
|
3553
|
+
<h3 id="get__api_v1_account_admin_gettenantinfo-responseschema">Response Schema</h3>
|
|
3554
|
+
|
|
3555
|
+
Status Code **200**
|
|
3556
|
+
|
|
3557
|
+
|Name|Type|Required|Restrictions|Description|
|
|
3558
|
+
|---|---|---|---|---|
|
|
3559
|
+
|» id|string|false|none|租户id|
|
|
3560
|
+
|» name|string|false|none|租户名称|
|
|
3561
|
+
|» description|string|false|none|租户简介|
|
|
3562
|
+
|» serviceStartTime|string|false|none|服务开始时间|
|
|
3563
|
+
|» serviceEndTime|string|false|none|服务结束时间|
|
|
3564
|
+
|» accountNumber|number|false|none|最大租户用户数量|
|
|
3565
|
+
|» status|number|false|none|0:正常,10:过期被关闭,11:已禁用,12:已关闭|
|
|
3566
|
+
|» createdAt|string|false|none|创建时间|
|
|
3567
|
+
|» updatedAt|string|false|none|更新时间|
|
|
3568
|
+
|
|
3569
|
+
<aside class="success">
|
|
3570
|
+
This operation does not require authentication
|
|
3571
|
+
</aside>
|
|
3572
|
+
|
|
3573
|
+
## post__api_v1_account_admin_closeTenant
|
|
3574
|
+
|
|
3575
|
+
`POST /api/v1/account/admin/closeTenant`
|
|
3576
|
+
|
|
3577
|
+
*关闭租户*
|
|
3578
|
+
|
|
3579
|
+
> Body parameter
|
|
3580
|
+
|
|
3581
|
+
```json
|
|
3582
|
+
{
|
|
3583
|
+
"type": "object",
|
|
3584
|
+
"required": [
|
|
3585
|
+
"tenantId"
|
|
3586
|
+
],
|
|
3587
|
+
"properties": {
|
|
3588
|
+
"tenantId": {
|
|
3589
|
+
"type": "string",
|
|
3590
|
+
"description": "租户id"
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
```
|
|
3595
|
+
|
|
3596
|
+
<h3 id="post__api_v1_account_admin_closetenant-parameters">Parameters</h3>
|
|
3597
|
+
|
|
3598
|
+
|Name|In|Type|Required|Description|
|
|
3599
|
+
|---|---|---|---|---|
|
|
3600
|
+
|body|body|object|true|none|
|
|
3601
|
+
|» tenantId|body|string|true|租户id|
|
|
3602
|
+
|
|
3603
|
+
> Example responses
|
|
3604
|
+
|
|
3605
|
+
> 200 Response
|
|
3606
|
+
|
|
3607
|
+
```json
|
|
3608
|
+
{
|
|
3609
|
+
"type": "object",
|
|
3610
|
+
"properties": {
|
|
3611
|
+
"content": {
|
|
3612
|
+
"application/json": {}
|
|
3613
|
+
}
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
```
|
|
3617
|
+
|
|
3618
|
+
<h3 id="post__api_v1_account_admin_closetenant-responses">Responses</h3>
|
|
3619
|
+
|
|
3620
|
+
|Status|Meaning|Description|Schema|
|
|
3621
|
+
|---|---|---|---|
|
|
3622
|
+
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|Inline|
|
|
3623
|
+
|
|
3624
|
+
<h3 id="post__api_v1_account_admin_closetenant-responseschema">Response Schema</h3>
|
|
3625
|
+
|
|
3626
|
+
Status Code **200**
|
|
3627
|
+
|
|
3628
|
+
|Name|Type|Required|Restrictions|Description|
|
|
3629
|
+
|---|---|---|---|---|
|
|
3630
|
+
|» content|any|false|none|none|
|
|
3631
|
+
|
|
3632
|
+
<aside class="success">
|
|
3633
|
+
This operation does not require authentication
|
|
3634
|
+
</aside>
|
|
3635
|
+
|
|
3636
|
+
## post__api_v1_account_admin_openTenant
|
|
3637
|
+
|
|
3638
|
+
`POST /api/v1/account/admin/openTenant`
|
|
3639
|
+
|
|
3640
|
+
*开启租户*
|
|
3641
|
+
|
|
3642
|
+
> Body parameter
|
|
3643
|
+
|
|
3644
|
+
```json
|
|
3645
|
+
{
|
|
3646
|
+
"type": "object",
|
|
3647
|
+
"required": [
|
|
3648
|
+
"tenantId"
|
|
3649
|
+
],
|
|
3650
|
+
"properties": {
|
|
3651
|
+
"tenantId": {
|
|
3652
|
+
"type": "string",
|
|
3653
|
+
"description": "租户id"
|
|
3654
|
+
}
|
|
3655
|
+
}
|
|
3656
|
+
}
|
|
3657
|
+
```
|
|
3658
|
+
|
|
3659
|
+
<h3 id="post__api_v1_account_admin_opentenant-parameters">Parameters</h3>
|
|
3660
|
+
|
|
3661
|
+
|Name|In|Type|Required|Description|
|
|
3662
|
+
|---|---|---|---|---|
|
|
3663
|
+
|body|body|object|true|none|
|
|
3664
|
+
|» tenantId|body|string|true|租户id|
|
|
3665
|
+
|
|
3666
|
+
> Example responses
|
|
3667
|
+
|
|
3668
|
+
> 200 Response
|
|
3669
|
+
|
|
3670
|
+
```json
|
|
3671
|
+
{
|
|
3672
|
+
"type": "object",
|
|
3673
|
+
"properties": {
|
|
3674
|
+
"content": {
|
|
3675
|
+
"application/json": {}
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3679
|
+
```
|
|
3680
|
+
|
|
3681
|
+
<h3 id="post__api_v1_account_admin_opentenant-responses">Responses</h3>
|
|
3682
|
+
|
|
3683
|
+
|Status|Meaning|Description|Schema|
|
|
3684
|
+
|---|---|---|---|
|
|
3685
|
+
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|Inline|
|
|
3686
|
+
|
|
3687
|
+
<h3 id="post__api_v1_account_admin_opentenant-responseschema">Response Schema</h3>
|
|
3688
|
+
|
|
3689
|
+
Status Code **200**
|
|
3690
|
+
|
|
3691
|
+
|Name|Type|Required|Restrictions|Description|
|
|
3692
|
+
|---|---|---|---|---|
|
|
3693
|
+
|» content|any|false|none|none|
|
|
3694
|
+
|
|
3695
|
+
<aside class="success">
|
|
3696
|
+
This operation does not require authentication
|
|
3697
|
+
</aside>
|
|
3698
|
+
|
|
3699
|
+
## post__api_v1_account_admin_addTenant
|
|
3700
|
+
|
|
3701
|
+
`POST /api/v1/account/admin/addTenant`
|
|
3702
|
+
|
|
3703
|
+
*添加租户*
|
|
3704
|
+
|
|
3705
|
+
> Body parameter
|
|
3706
|
+
|
|
3707
|
+
```json
|
|
3708
|
+
{
|
|
3709
|
+
"type": "object",
|
|
3710
|
+
"required": [
|
|
3711
|
+
"name",
|
|
3712
|
+
"accountNumber",
|
|
3713
|
+
"serviceStartTime",
|
|
3714
|
+
"serviceEndTime"
|
|
3715
|
+
],
|
|
3716
|
+
"properties": {
|
|
3717
|
+
"name": {
|
|
3718
|
+
"type": "string",
|
|
3719
|
+
"description": "租户名称"
|
|
3720
|
+
},
|
|
3721
|
+
"description": {
|
|
3722
|
+
"type": "string",
|
|
3723
|
+
"description": "租户简介"
|
|
3724
|
+
},
|
|
3725
|
+
"serviceStartTime": {
|
|
3726
|
+
"type": "string",
|
|
3727
|
+
"description": "服务开始时间"
|
|
3728
|
+
},
|
|
3729
|
+
"serviceEndTime": {
|
|
3730
|
+
"type": "string",
|
|
3731
|
+
"description": "服务结束时间"
|
|
3732
|
+
},
|
|
3733
|
+
"accountNumber": {
|
|
3734
|
+
"type": "number",
|
|
3735
|
+
"description": "最大租户用户数量"
|
|
3736
|
+
},
|
|
3737
|
+
"status": {
|
|
3738
|
+
"type": "number",
|
|
3739
|
+
"description": "0:正常,10:过期被关闭,11:已禁用,12:已关闭"
|
|
3740
|
+
},
|
|
3741
|
+
"createdAt": {
|
|
3742
|
+
"type": "string",
|
|
3743
|
+
"description": "创建时间"
|
|
3744
|
+
},
|
|
3745
|
+
"updatedAt": {
|
|
3746
|
+
"type": "string",
|
|
3747
|
+
"description": "更新时间"
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
}
|
|
3751
|
+
```
|
|
3752
|
+
|
|
3753
|
+
<h3 id="post__api_v1_account_admin_addtenant-parameters">Parameters</h3>
|
|
3754
|
+
|
|
3755
|
+
|Name|In|Type|Required|Description|
|
|
3756
|
+
|---|---|---|---|---|
|
|
3757
|
+
|body|body|object|true|none|
|
|
3758
|
+
|» name|body|string|true|租户名称|
|
|
3759
|
+
|» description|body|string|false|租户简介|
|
|
3760
|
+
|» serviceStartTime|body|string|true|服务开始时间|
|
|
3761
|
+
|» serviceEndTime|body|string|true|服务结束时间|
|
|
3762
|
+
|» accountNumber|body|number|true|最大租户用户数量|
|
|
3763
|
+
|» status|body|number|false|0:正常,10:过期被关闭,11:已禁用,12:已关闭|
|
|
3764
|
+
|» createdAt|body|string|false|创建时间|
|
|
3765
|
+
|» updatedAt|body|string|false|更新时间|
|
|
3766
|
+
|
|
3767
|
+
> Example responses
|
|
3768
|
+
|
|
3769
|
+
> 200 Response
|
|
3770
|
+
|
|
3771
|
+
```json
|
|
3772
|
+
{
|
|
3773
|
+
"type": "object",
|
|
3774
|
+
"properties": {
|
|
3775
|
+
"content": {
|
|
3776
|
+
"application/json": {}
|
|
3777
|
+
}
|
|
3778
|
+
}
|
|
3779
|
+
}
|
|
3780
|
+
```
|
|
3781
|
+
|
|
3782
|
+
<h3 id="post__api_v1_account_admin_addtenant-responses">Responses</h3>
|
|
3783
|
+
|
|
3784
|
+
|Status|Meaning|Description|Schema|
|
|
3785
|
+
|---|---|---|---|
|
|
3786
|
+
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|Inline|
|
|
3787
|
+
|
|
3788
|
+
<h3 id="post__api_v1_account_admin_addtenant-responseschema">Response Schema</h3>
|
|
3789
|
+
|
|
3790
|
+
Status Code **200**
|
|
3791
|
+
|
|
3792
|
+
|Name|Type|Required|Restrictions|Description|
|
|
3793
|
+
|---|---|---|---|---|
|
|
3794
|
+
|» content|any|false|none|none|
|
|
3795
|
+
|
|
3796
|
+
<aside class="success">
|
|
3797
|
+
This operation does not require authentication
|
|
3798
|
+
</aside>
|
|
3799
|
+
|
|
3522
3800
|
<h1 id="-kne-fastify-account--">租户平台</h1>
|
|
3523
3801
|
|
|
3524
3802
|
## get__api_v1_account_tenant_getCompanyInfo
|
package/index.js
CHANGED
|
@@ -7,7 +7,6 @@ const { Unauthorized, Forbidden } = require('http-errors');
|
|
|
7
7
|
|
|
8
8
|
module.exports = fp(
|
|
9
9
|
async function (fastify, options) {
|
|
10
|
-
await fastify.sequelize.addModels(path.resolve(__dirname, './models'));
|
|
11
10
|
options = merge(
|
|
12
11
|
{
|
|
13
12
|
prefix: `/api/v${packageJson.version.split('.')[0]}/account`, //如果为true,发送邮件和短信将不调用,验证码随response返回
|
|
@@ -17,6 +16,7 @@ module.exports = fp(
|
|
|
17
16
|
secret: 'super-secret',
|
|
18
17
|
expires: null
|
|
19
18
|
},
|
|
19
|
+
defaultPassword: 'Aa000000!',
|
|
20
20
|
sendMessage: async () => {}
|
|
21
21
|
},
|
|
22
22
|
options
|
|
@@ -7,25 +7,63 @@ module.exports = fp(async (fastify, options) => {
|
|
|
7
7
|
{
|
|
8
8
|
onRequest: [authenticate.user, authenticate.admin],
|
|
9
9
|
schema: {
|
|
10
|
+
tags: ['管理后台-租户'],
|
|
11
|
+
summary: '获取租户列表',
|
|
10
12
|
query: {
|
|
11
13
|
type: 'object',
|
|
12
14
|
properties: {
|
|
13
15
|
name: {
|
|
14
|
-
type: 'string'
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: '租户名'
|
|
15
18
|
},
|
|
16
19
|
serviceStartTime: {
|
|
17
20
|
type: 'string',
|
|
18
|
-
format: 'date-time'
|
|
21
|
+
format: 'date-time',
|
|
22
|
+
description: '服务开始时间'
|
|
19
23
|
},
|
|
20
24
|
serviceEndTime: {
|
|
21
25
|
type: 'string',
|
|
22
|
-
format: 'date-time'
|
|
26
|
+
format: 'date-time',
|
|
27
|
+
description: '服务结束时间'
|
|
23
28
|
},
|
|
24
29
|
perPage: {
|
|
25
|
-
type: 'number'
|
|
30
|
+
type: 'number',
|
|
31
|
+
description: '每页条数'
|
|
26
32
|
},
|
|
27
33
|
currentPage: {
|
|
28
|
-
type: 'number'
|
|
34
|
+
type: 'number',
|
|
35
|
+
description: '页数'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
response: {
|
|
40
|
+
200: {
|
|
41
|
+
content: {
|
|
42
|
+
'application/json': {
|
|
43
|
+
schema: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
pageData: {
|
|
47
|
+
type: 'array',
|
|
48
|
+
items: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
properties: {
|
|
51
|
+
id: { type: 'string', description: '租户id' },
|
|
52
|
+
name: { type: 'string', description: '租户名称' },
|
|
53
|
+
description: { type: 'string', description: '租户简介' },
|
|
54
|
+
serviceStartTime: { type: 'string', description: '服务开始时间' },
|
|
55
|
+
serviceEndTime: { type: 'string', description: '服务结束时间' },
|
|
56
|
+
accountNumber: { type: 'number', description: '最大租户用户数量' },
|
|
57
|
+
status: { type: 'number', description: '0:正常,10:过期被关闭,11:已禁用,12:已关闭' },
|
|
58
|
+
createdAt: { type: 'string', description: '创建时间' },
|
|
59
|
+
updatedAt: { type: 'string', description: '更新时间' }
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
totalCount: { type: 'number', description: '总数量' }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
29
67
|
}
|
|
30
68
|
}
|
|
31
69
|
}
|
|
@@ -52,10 +90,34 @@ module.exports = fp(async (fastify, options) => {
|
|
|
52
90
|
{
|
|
53
91
|
onRequest: [authenticate.user, authenticate.admin],
|
|
54
92
|
schema: {
|
|
93
|
+
tags: ['管理后台-租户'],
|
|
94
|
+
summary: '获取租户基本信息',
|
|
55
95
|
query: {
|
|
56
96
|
type: 'object',
|
|
57
97
|
properties: {
|
|
58
|
-
id: { type: 'string' }
|
|
98
|
+
id: { type: 'string', description: '租户id' }
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
response: {
|
|
102
|
+
200: {
|
|
103
|
+
content: {
|
|
104
|
+
'application/json': {
|
|
105
|
+
schema: {
|
|
106
|
+
type: 'object',
|
|
107
|
+
properties: {
|
|
108
|
+
id: { type: 'string', description: '租户id' },
|
|
109
|
+
name: { type: 'string', description: '租户名称' },
|
|
110
|
+
description: { type: 'string', description: '租户简介' },
|
|
111
|
+
serviceStartTime: { type: 'string', description: '服务开始时间' },
|
|
112
|
+
serviceEndTime: { type: 'string', description: '服务结束时间' },
|
|
113
|
+
accountNumber: { type: 'number', description: '最大租户用户数量' },
|
|
114
|
+
status: { type: 'number', description: '0:正常,10:过期被关闭,11:已禁用,12:已关闭' },
|
|
115
|
+
createdAt: { type: 'string', description: '创建时间' },
|
|
116
|
+
updatedAt: { type: 'string', description: '更新时间' }
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
59
121
|
}
|
|
60
122
|
}
|
|
61
123
|
}
|
|
@@ -71,11 +133,20 @@ module.exports = fp(async (fastify, options) => {
|
|
|
71
133
|
{
|
|
72
134
|
onRequest: [authenticate.user, authenticate.admin],
|
|
73
135
|
schema: {
|
|
136
|
+
tags: ['管理后台-租户'],
|
|
137
|
+
summary: '关闭租户',
|
|
74
138
|
body: {
|
|
75
139
|
type: 'object',
|
|
76
140
|
required: ['tenantId'],
|
|
77
141
|
properties: {
|
|
78
|
-
tenantId: { type: 'string' }
|
|
142
|
+
tenantId: { type: 'string', description: '租户id' }
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
response: {
|
|
146
|
+
200: {
|
|
147
|
+
content: {
|
|
148
|
+
'application/json': {}
|
|
149
|
+
}
|
|
79
150
|
}
|
|
80
151
|
}
|
|
81
152
|
}
|
|
@@ -92,11 +163,20 @@ module.exports = fp(async (fastify, options) => {
|
|
|
92
163
|
{
|
|
93
164
|
onRequest: [authenticate.user, authenticate.admin],
|
|
94
165
|
schema: {
|
|
166
|
+
tags: ['管理后台-租户'],
|
|
167
|
+
summary: '开启租户',
|
|
95
168
|
body: {
|
|
96
169
|
type: 'object',
|
|
97
170
|
required: ['tenantId'],
|
|
98
171
|
properties: {
|
|
99
|
-
tenantId: { type: 'string' }
|
|
172
|
+
tenantId: { type: 'string', description: '租户id' }
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
response: {
|
|
176
|
+
200: {
|
|
177
|
+
content: {
|
|
178
|
+
'application/json': {}
|
|
179
|
+
}
|
|
100
180
|
}
|
|
101
181
|
}
|
|
102
182
|
}
|
|
@@ -113,19 +193,26 @@ module.exports = fp(async (fastify, options) => {
|
|
|
113
193
|
{
|
|
114
194
|
onRequest: [authenticate.user, authenticate.admin],
|
|
115
195
|
schema: {
|
|
196
|
+
tags: ['管理后台-租户'],
|
|
197
|
+
summary: '添加租户',
|
|
116
198
|
body: {
|
|
117
199
|
type: 'object',
|
|
118
200
|
required: ['name', 'accountNumber', 'serviceStartTime', 'serviceEndTime'],
|
|
119
201
|
properties: {
|
|
120
|
-
name: { type: 'string' },
|
|
121
|
-
|
|
122
|
-
serviceStartTime: {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
202
|
+
name: { type: 'string', description: '租户名称' },
|
|
203
|
+
description: { type: 'string', description: '租户简介' },
|
|
204
|
+
serviceStartTime: { type: 'string', description: '服务开始时间' },
|
|
205
|
+
serviceEndTime: { type: 'string', description: '服务结束时间' },
|
|
206
|
+
accountNumber: { type: 'number', description: '最大租户用户数量' },
|
|
207
|
+
status: { type: 'number', description: '0:正常,10:过期被关闭,11:已禁用,12:已关闭' },
|
|
208
|
+
createdAt: { type: 'string', description: '创建时间' },
|
|
209
|
+
updatedAt: { type: 'string', description: '更新时间' }
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
response: {
|
|
213
|
+
200: {
|
|
214
|
+
content: {
|
|
215
|
+
'application/json': {}
|
|
129
216
|
}
|
|
130
217
|
}
|
|
131
218
|
}
|
|
@@ -146,16 +233,18 @@ module.exports = fp(async (fastify, options) => {
|
|
|
146
233
|
type: 'object',
|
|
147
234
|
required: ['id', 'name', 'accountNumber', 'serviceStartTime', 'serviceEndTime'],
|
|
148
235
|
properties: {
|
|
149
|
-
id: { type: 'string' },
|
|
150
|
-
name: { type: 'string' },
|
|
151
|
-
|
|
152
|
-
serviceStartTime: {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
236
|
+
id: { type: 'string', description: '租户id' },
|
|
237
|
+
name: { type: 'string', description: '租户名称' },
|
|
238
|
+
description: { type: 'string', description: '租户简介' },
|
|
239
|
+
serviceStartTime: { type: 'string', description: '服务开始时间' },
|
|
240
|
+
serviceEndTime: { type: 'string', description: '服务结束时间' },
|
|
241
|
+
accountNumber: { type: 'number', description: '最大租户用户数量' }
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
response: {
|
|
245
|
+
200: {
|
|
246
|
+
content: {
|
|
247
|
+
'application/json': {}
|
|
159
248
|
}
|
|
160
249
|
}
|
|
161
250
|
}
|
|
@@ -40,7 +40,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
40
40
|
);
|
|
41
41
|
|
|
42
42
|
fastify.post(
|
|
43
|
-
`${options.prefix}/
|
|
43
|
+
`${options.prefix}/tenant/getTenantOperationLogList`,
|
|
44
44
|
{
|
|
45
45
|
onRequest: [authenticate.user, authenticate.tenant],
|
|
46
46
|
schema: {
|
|
@@ -139,12 +139,16 @@ module.exports = fp(async (fastify, options) => {
|
|
|
139
139
|
};
|
|
140
140
|
|
|
141
141
|
const getTenantUserByUserId = async ({ userInfo: user, appName }) => {
|
|
142
|
-
if (!user
|
|
142
|
+
if (!user?.currentTenantId) {
|
|
143
143
|
throw new Unauthorized('没有找到当前绑定租户');
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
const tenant = await services.tenant.getTenant({ id: user.currentTenantId });
|
|
147
147
|
|
|
148
|
+
if (!tenant) {
|
|
149
|
+
throw new Error('当前租户不能使用');
|
|
150
|
+
}
|
|
151
|
+
|
|
148
152
|
const tenantApplications = await services.application.getApplicationList({ tenantId: tenant.id, appName });
|
|
149
153
|
|
|
150
154
|
if (appName && !tenantApplications.some(item => item.code === appName)) {
|
package/libs/services/tenant.js
CHANGED
|
@@ -3,7 +3,7 @@ const fp = require('fastify-plugin');
|
|
|
3
3
|
module.exports = fp(async (fastify, options) => {
|
|
4
4
|
const { models, services } = fastify.account;
|
|
5
5
|
|
|
6
|
-
const getTenantInstance = async ({ id }) => {
|
|
6
|
+
const getTenantInstance = async ({ id, isClose = false }) => {
|
|
7
7
|
const tenant = await models.tenant.findOne({
|
|
8
8
|
where: {
|
|
9
9
|
uuid: id
|
|
@@ -13,7 +13,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
13
13
|
throw new Error('租户不存在');
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
if (tenant.status !== 0) {
|
|
16
|
+
if (tenant.status !== 0 && !isClose) {
|
|
17
17
|
throw new Error('租户已关闭');
|
|
18
18
|
}
|
|
19
19
|
return tenant;
|
|
@@ -26,13 +26,13 @@ module.exports = fp(async (fastify, options) => {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
const closeTenant = async ({ tenantId }) => {
|
|
29
|
-
const tenant = await
|
|
29
|
+
const tenant = await getTenantInstance({ id: tenantId });
|
|
30
30
|
tenant.status = 12;
|
|
31
31
|
await tenant.save();
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
const openTenant = async ({ tenantId }) => {
|
|
35
|
-
const tenant = await
|
|
35
|
+
const tenant = await getTenantInstance({ id: tenantId, isClose: true });
|
|
36
36
|
tenant.status = 0;
|
|
37
37
|
await tenant.save();
|
|
38
38
|
};
|