@kne/fastify-account 1.0.0-alpha.21 → 1.0.0-alpha.23

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 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.21"
25
+ title: "@kne/fastify-account v1.0.0-alpha.22"
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.21</h1>
45
+ <h1 id="-kne-fastify-account">@kne/fastify-account v1.0.0-alpha.22</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
- ## get__api_v1_account_admin_getAllTenantList
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/addTenant`
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
- "accountNumber": {
205
- "type": "number"
92
+ "description": {
93
+ "type": "string",
94
+ "description": "租户简介"
206
95
  },
207
96
  "serviceStartTime": {
208
97
  "type": "string",
209
- "format": "date-time"
98
+ "description": "服务开始时间"
210
99
  },
211
100
  "serviceEndTime": {
212
101
  "type": "string",
213
- "format": "date-time"
102
+ "description": "服务结束时间"
103
+ },
104
+ "accountNumber": {
105
+ "type": "number",
106
+ "description": "最大租户用户数量"
214
107
  }
215
108
  }
216
109
  }
217
110
  ```
218
111
 
219
- <h3 id="post__api_v1_account_admin_addtenant-parameters">Parameters</h3>
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
- name|body|string|true|none|
225
- accountNumber|body|number|true|none|
226
- serviceStartTime|body|string(date-time)|true|none|
227
- serviceEndTime|body|string(date-time)|true|none|
228
-
229
- <h3 id="post__api_v1_account_admin_addtenant-responses">Responses</h3>
230
-
231
- |Status|Meaning|Description|Schema|
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
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|最大租户用户数量|
240
123
 
241
- `POST /api/v1/account/admin/saveTenant`
124
+ > Example responses
242
125
 
243
- > Body parameter
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
- "id": {
257
- "type": "string"
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|None|
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
@@ -975,20 +834,6 @@ This operation does not require authentication
975
834
  This operation does not require authentication
976
835
  </aside>
977
836
 
978
- ## get__api_v1_account_tenant_getTenantUserInfo
979
-
980
- `GET /api/v1/account/tenant/getTenantUserInfo`
981
-
982
- <h3 id="get__api_v1_account_tenant_gettenantuserinfo-responses">Responses</h3>
983
-
984
- |Status|Meaning|Description|Schema|
985
- |---|---|---|---|
986
- |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|None|
987
-
988
- <aside class="success">
989
- This operation does not require authentication
990
- </aside>
991
-
992
837
  ## post__api_v1_account_tenant_addOrg
993
838
 
994
839
  `POST /api/v1/account/tenant/addOrg`
@@ -2822,6 +2667,31 @@ This operation does not require authentication
2822
2667
  This operation does not require authentication
2823
2668
  </aside>
2824
2669
 
2670
+ ## get__api_v1_account_tenant_getTenantUserInfo
2671
+
2672
+ `GET /api/v1/account/tenant/getTenantUserInfo`
2673
+
2674
+ *获取租户用户所有操作日志列表*
2675
+
2676
+ <h3 id="get__api_v1_account_tenant_gettenantuserinfo-parameters">Parameters</h3>
2677
+
2678
+ |Name|In|Type|Required|Description|
2679
+ |---|---|---|---|---|
2680
+ |filter|path|object|true|none|
2681
+ |type|path|string|true|none|
2682
+ |perPage|path|number|true|none|
2683
+ |currentPage|path|number|true|none|
2684
+
2685
+ <h3 id="get__api_v1_account_tenant_gettenantuserinfo-responses">Responses</h3>
2686
+
2687
+ |Status|Meaning|Description|Schema|
2688
+ |---|---|---|---|
2689
+ |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|None|
2690
+
2691
+ <aside class="success">
2692
+ This operation does not require authentication
2693
+ </aside>
2694
+
2825
2695
  <h1 id="-kne-fastify-account--">管理后台-权限</h1>
2826
2696
 
2827
2697
  ## post__api_v1_account_admin_addApplication
@@ -3519,6 +3389,426 @@ This operation does not require authentication
3519
3389
  This operation does not require authentication
3520
3390
  </aside>
3521
3391
 
3392
+ <h1 id="-kne-fastify-account--">管理后台-租户</h1>
3393
+
3394
+ ## get__api_v1_account_admin_getAllTenantList
3395
+
3396
+ `GET /api/v1/account/admin/getAllTenantList`
3397
+
3398
+ *获取租户列表*
3399
+
3400
+ <h3 id="get__api_v1_account_admin_getalltenantlist-parameters">Parameters</h3>
3401
+
3402
+ |Name|In|Type|Required|Description|
3403
+ |---|---|---|---|---|
3404
+ |name|query|string|false|租户名|
3405
+ |status|query|number|false|状态|
3406
+ |serviceStartTime|query|string(date-time)|false|服务开始时间|
3407
+ |serviceEndTime|query|string(date-time)|false|服务结束时间|
3408
+ |perPage|query|number|false|每页条数|
3409
+ |currentPage|query|number|false|页数|
3410
+
3411
+ > Example responses
3412
+
3413
+ > 200 Response
3414
+
3415
+ ```json
3416
+ {
3417
+ "type": "object",
3418
+ "properties": {
3419
+ "pageData": {
3420
+ "type": "array",
3421
+ "items": {
3422
+ "type": "object",
3423
+ "properties": {
3424
+ "id": {
3425
+ "type": "string",
3426
+ "description": "租户id"
3427
+ },
3428
+ "name": {
3429
+ "type": "string",
3430
+ "description": "租户名称"
3431
+ },
3432
+ "description": {
3433
+ "type": "string",
3434
+ "description": "租户简介"
3435
+ },
3436
+ "serviceStartTime": {
3437
+ "type": "string",
3438
+ "description": "服务开始时间"
3439
+ },
3440
+ "serviceEndTime": {
3441
+ "type": "string",
3442
+ "description": "服务结束时间"
3443
+ },
3444
+ "accountNumber": {
3445
+ "type": "number",
3446
+ "description": "最大租户用户数量"
3447
+ },
3448
+ "status": {
3449
+ "type": "number",
3450
+ "description": "0:正常,10:过期被关闭,11:已禁用,12:已关闭"
3451
+ },
3452
+ "createdAt": {
3453
+ "type": "string",
3454
+ "description": "创建时间"
3455
+ },
3456
+ "updatedAt": {
3457
+ "type": "string",
3458
+ "description": "更新时间"
3459
+ }
3460
+ }
3461
+ }
3462
+ },
3463
+ "totalCount": {
3464
+ "type": "number",
3465
+ "description": "总数量"
3466
+ }
3467
+ }
3468
+ }
3469
+ ```
3470
+
3471
+ <h3 id="get__api_v1_account_admin_getalltenantlist-responses">Responses</h3>
3472
+
3473
+ |Status|Meaning|Description|Schema|
3474
+ |---|---|---|---|
3475
+ |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|Inline|
3476
+
3477
+ <h3 id="get__api_v1_account_admin_getalltenantlist-responseschema">Response Schema</h3>
3478
+
3479
+ Status Code **200**
3480
+
3481
+ |Name|Type|Required|Restrictions|Description|
3482
+ |---|---|---|---|---|
3483
+ |» pageData|[object]|false|none|none|
3484
+ |»» id|string|false|none|租户id|
3485
+ |»» name|string|false|none|租户名称|
3486
+ |»» description|string|false|none|租户简介|
3487
+ |»» serviceStartTime|string|false|none|服务开始时间|
3488
+ |»» serviceEndTime|string|false|none|服务结束时间|
3489
+ |»» accountNumber|number|false|none|最大租户用户数量|
3490
+ |»» status|number|false|none|0:正常,10:过期被关闭,11:已禁用,12:已关闭|
3491
+ |»» createdAt|string|false|none|创建时间|
3492
+ |»» updatedAt|string|false|none|更新时间|
3493
+ |» totalCount|number|false|none|总数量|
3494
+
3495
+ <aside class="success">
3496
+ This operation does not require authentication
3497
+ </aside>
3498
+
3499
+ ## get__api_v1_account_admin_getTenantInfo
3500
+
3501
+ `GET /api/v1/account/admin/getTenantInfo`
3502
+
3503
+ *获取租户基本信息*
3504
+
3505
+ <h3 id="get__api_v1_account_admin_gettenantinfo-parameters">Parameters</h3>
3506
+
3507
+ |Name|In|Type|Required|Description|
3508
+ |---|---|---|---|---|
3509
+ |id|query|string|false|租户id|
3510
+
3511
+ > Example responses
3512
+
3513
+ > 200 Response
3514
+
3515
+ ```json
3516
+ {
3517
+ "type": "object",
3518
+ "properties": {
3519
+ "id": {
3520
+ "type": "string",
3521
+ "description": "租户id"
3522
+ },
3523
+ "name": {
3524
+ "type": "string",
3525
+ "description": "租户名称"
3526
+ },
3527
+ "description": {
3528
+ "type": "string",
3529
+ "description": "租户简介"
3530
+ },
3531
+ "serviceStartTime": {
3532
+ "type": "string",
3533
+ "description": "服务开始时间"
3534
+ },
3535
+ "serviceEndTime": {
3536
+ "type": "string",
3537
+ "description": "服务结束时间"
3538
+ },
3539
+ "accountNumber": {
3540
+ "type": "number",
3541
+ "description": "最大租户用户数量"
3542
+ },
3543
+ "status": {
3544
+ "type": "number",
3545
+ "description": "0:正常,10:过期被关闭,11:已禁用,12:已关闭"
3546
+ },
3547
+ "createdAt": {
3548
+ "type": "string",
3549
+ "description": "创建时间"
3550
+ },
3551
+ "updatedAt": {
3552
+ "type": "string",
3553
+ "description": "更新时间"
3554
+ }
3555
+ }
3556
+ }
3557
+ ```
3558
+
3559
+ <h3 id="get__api_v1_account_admin_gettenantinfo-responses">Responses</h3>
3560
+
3561
+ |Status|Meaning|Description|Schema|
3562
+ |---|---|---|---|
3563
+ |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|Inline|
3564
+
3565
+ <h3 id="get__api_v1_account_admin_gettenantinfo-responseschema">Response Schema</h3>
3566
+
3567
+ Status Code **200**
3568
+
3569
+ |Name|Type|Required|Restrictions|Description|
3570
+ |---|---|---|---|---|
3571
+ |» id|string|false|none|租户id|
3572
+ |» name|string|false|none|租户名称|
3573
+ |» description|string|false|none|租户简介|
3574
+ |» serviceStartTime|string|false|none|服务开始时间|
3575
+ |» serviceEndTime|string|false|none|服务结束时间|
3576
+ |» accountNumber|number|false|none|最大租户用户数量|
3577
+ |» status|number|false|none|0:正常,10:过期被关闭,11:已禁用,12:已关闭|
3578
+ |» createdAt|string|false|none|创建时间|
3579
+ |» updatedAt|string|false|none|更新时间|
3580
+
3581
+ <aside class="success">
3582
+ This operation does not require authentication
3583
+ </aside>
3584
+
3585
+ ## post__api_v1_account_admin_closeTenant
3586
+
3587
+ `POST /api/v1/account/admin/closeTenant`
3588
+
3589
+ *关闭租户*
3590
+
3591
+ > Body parameter
3592
+
3593
+ ```json
3594
+ {
3595
+ "type": "object",
3596
+ "required": [
3597
+ "tenantId"
3598
+ ],
3599
+ "properties": {
3600
+ "tenantId": {
3601
+ "type": "string",
3602
+ "description": "租户id"
3603
+ }
3604
+ }
3605
+ }
3606
+ ```
3607
+
3608
+ <h3 id="post__api_v1_account_admin_closetenant-parameters">Parameters</h3>
3609
+
3610
+ |Name|In|Type|Required|Description|
3611
+ |---|---|---|---|---|
3612
+ |body|body|object|true|none|
3613
+ |» tenantId|body|string|true|租户id|
3614
+
3615
+ > Example responses
3616
+
3617
+ > 200 Response
3618
+
3619
+ ```json
3620
+ {
3621
+ "type": "object",
3622
+ "properties": {
3623
+ "content": {
3624
+ "application/json": {}
3625
+ }
3626
+ }
3627
+ }
3628
+ ```
3629
+
3630
+ <h3 id="post__api_v1_account_admin_closetenant-responses">Responses</h3>
3631
+
3632
+ |Status|Meaning|Description|Schema|
3633
+ |---|---|---|---|
3634
+ |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|Inline|
3635
+
3636
+ <h3 id="post__api_v1_account_admin_closetenant-responseschema">Response Schema</h3>
3637
+
3638
+ Status Code **200**
3639
+
3640
+ |Name|Type|Required|Restrictions|Description|
3641
+ |---|---|---|---|---|
3642
+ |» content|any|false|none|none|
3643
+
3644
+ <aside class="success">
3645
+ This operation does not require authentication
3646
+ </aside>
3647
+
3648
+ ## post__api_v1_account_admin_openTenant
3649
+
3650
+ `POST /api/v1/account/admin/openTenant`
3651
+
3652
+ *开启租户*
3653
+
3654
+ > Body parameter
3655
+
3656
+ ```json
3657
+ {
3658
+ "type": "object",
3659
+ "required": [
3660
+ "tenantId"
3661
+ ],
3662
+ "properties": {
3663
+ "tenantId": {
3664
+ "type": "string",
3665
+ "description": "租户id"
3666
+ }
3667
+ }
3668
+ }
3669
+ ```
3670
+
3671
+ <h3 id="post__api_v1_account_admin_opentenant-parameters">Parameters</h3>
3672
+
3673
+ |Name|In|Type|Required|Description|
3674
+ |---|---|---|---|---|
3675
+ |body|body|object|true|none|
3676
+ |» tenantId|body|string|true|租户id|
3677
+
3678
+ > Example responses
3679
+
3680
+ > 200 Response
3681
+
3682
+ ```json
3683
+ {
3684
+ "type": "object",
3685
+ "properties": {
3686
+ "content": {
3687
+ "application/json": {}
3688
+ }
3689
+ }
3690
+ }
3691
+ ```
3692
+
3693
+ <h3 id="post__api_v1_account_admin_opentenant-responses">Responses</h3>
3694
+
3695
+ |Status|Meaning|Description|Schema|
3696
+ |---|---|---|---|
3697
+ |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|Inline|
3698
+
3699
+ <h3 id="post__api_v1_account_admin_opentenant-responseschema">Response Schema</h3>
3700
+
3701
+ Status Code **200**
3702
+
3703
+ |Name|Type|Required|Restrictions|Description|
3704
+ |---|---|---|---|---|
3705
+ |» content|any|false|none|none|
3706
+
3707
+ <aside class="success">
3708
+ This operation does not require authentication
3709
+ </aside>
3710
+
3711
+ ## post__api_v1_account_admin_addTenant
3712
+
3713
+ `POST /api/v1/account/admin/addTenant`
3714
+
3715
+ *添加租户*
3716
+
3717
+ > Body parameter
3718
+
3719
+ ```json
3720
+ {
3721
+ "type": "object",
3722
+ "required": [
3723
+ "name",
3724
+ "accountNumber",
3725
+ "serviceStartTime",
3726
+ "serviceEndTime"
3727
+ ],
3728
+ "properties": {
3729
+ "name": {
3730
+ "type": "string",
3731
+ "description": "租户名称"
3732
+ },
3733
+ "description": {
3734
+ "type": "string",
3735
+ "description": "租户简介"
3736
+ },
3737
+ "serviceStartTime": {
3738
+ "type": "string",
3739
+ "description": "服务开始时间"
3740
+ },
3741
+ "serviceEndTime": {
3742
+ "type": "string",
3743
+ "description": "服务结束时间"
3744
+ },
3745
+ "accountNumber": {
3746
+ "type": "number",
3747
+ "description": "最大租户用户数量"
3748
+ },
3749
+ "status": {
3750
+ "type": "number",
3751
+ "description": "0:正常,10:过期被关闭,11:已禁用,12:已关闭"
3752
+ },
3753
+ "createdAt": {
3754
+ "type": "string",
3755
+ "description": "创建时间"
3756
+ },
3757
+ "updatedAt": {
3758
+ "type": "string",
3759
+ "description": "更新时间"
3760
+ }
3761
+ }
3762
+ }
3763
+ ```
3764
+
3765
+ <h3 id="post__api_v1_account_admin_addtenant-parameters">Parameters</h3>
3766
+
3767
+ |Name|In|Type|Required|Description|
3768
+ |---|---|---|---|---|
3769
+ |body|body|object|true|none|
3770
+ |» name|body|string|true|租户名称|
3771
+ |» description|body|string|false|租户简介|
3772
+ |» serviceStartTime|body|string|true|服务开始时间|
3773
+ |» serviceEndTime|body|string|true|服务结束时间|
3774
+ |» accountNumber|body|number|true|最大租户用户数量|
3775
+ |» status|body|number|false|0:正常,10:过期被关闭,11:已禁用,12:已关闭|
3776
+ |» createdAt|body|string|false|创建时间|
3777
+ |» updatedAt|body|string|false|更新时间|
3778
+
3779
+ > Example responses
3780
+
3781
+ > 200 Response
3782
+
3783
+ ```json
3784
+ {
3785
+ "type": "object",
3786
+ "properties": {
3787
+ "content": {
3788
+ "application/json": {}
3789
+ }
3790
+ }
3791
+ }
3792
+ ```
3793
+
3794
+ <h3 id="post__api_v1_account_admin_addtenant-responses">Responses</h3>
3795
+
3796
+ |Status|Meaning|Description|Schema|
3797
+ |---|---|---|---|
3798
+ |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|Inline|
3799
+
3800
+ <h3 id="post__api_v1_account_admin_addtenant-responseschema">Response Schema</h3>
3801
+
3802
+ Status Code **200**
3803
+
3804
+ |Name|Type|Required|Restrictions|Description|
3805
+ |---|---|---|---|---|
3806
+ |» content|any|false|none|none|
3807
+
3808
+ <aside class="success">
3809
+ This operation does not require authentication
3810
+ </aside>
3811
+
3522
3812
  <h1 id="-kne-fastify-account--">租户平台</h1>
3523
3813
 
3524
3814
  ## get__api_v1_account_tenant_getCompanyInfo
package/index.js CHANGED
@@ -16,6 +16,7 @@ module.exports = fp(
16
16
  secret: 'super-secret',
17
17
  expires: null
18
18
  },
19
+ defaultPassword: 'Aa000000!',
19
20
  sendMessage: async () => {}
20
21
  },
21
22
  options
@@ -7,32 +7,74 @@ 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: '租户名'
18
+ },
19
+ status: {
20
+ type: 'number',
21
+ description: '状态'
15
22
  },
16
23
  serviceStartTime: {
17
24
  type: 'string',
18
- format: 'date-time'
25
+ format: 'date-time',
26
+ description: '服务开始时间'
19
27
  },
20
28
  serviceEndTime: {
21
29
  type: 'string',
22
- format: 'date-time'
30
+ format: 'date-time',
31
+ description: '服务结束时间'
23
32
  },
24
33
  perPage: {
25
- type: 'number'
34
+ type: 'number',
35
+ description: '每页条数'
26
36
  },
27
37
  currentPage: {
28
- type: 'number'
38
+ type: 'number',
39
+ description: '页数'
40
+ }
41
+ }
42
+ },
43
+ response: {
44
+ 200: {
45
+ content: {
46
+ 'application/json': {
47
+ schema: {
48
+ type: 'object',
49
+ properties: {
50
+ pageData: {
51
+ type: 'array',
52
+ items: {
53
+ type: 'object',
54
+ properties: {
55
+ id: { type: 'string', description: '租户id' },
56
+ name: { type: 'string', description: '租户名称' },
57
+ description: { type: 'string', description: '租户简介' },
58
+ serviceStartTime: { type: 'string', description: '服务开始时间' },
59
+ serviceEndTime: { type: 'string', description: '服务结束时间' },
60
+ accountNumber: { type: 'number', description: '最大租户用户数量' },
61
+ status: { type: 'number', description: '0:正常,10:过期被关闭,11:已禁用,12:已关闭' },
62
+ createdAt: { type: 'string', description: '创建时间' },
63
+ updatedAt: { type: 'string', description: '更新时间' }
64
+ }
65
+ }
66
+ },
67
+ totalCount: { type: 'number', description: '总数量' }
68
+ }
69
+ }
70
+ }
29
71
  }
30
72
  }
31
73
  }
32
74
  }
33
75
  },
34
76
  async request => {
35
- const { name, perPage, currentPage } = Object.assign(
77
+ const { name, status, perPage, currentPage } = Object.assign(
36
78
  {
37
79
  perPage: 20,
38
80
  currentPage: 1
@@ -40,7 +82,7 @@ module.exports = fp(async (fastify, options) => {
40
82
  request.query
41
83
  );
42
84
  return await services.tenant.getAllTenantList({
43
- filter: { name },
85
+ filter: { name, status },
44
86
  perPage,
45
87
  currentPage
46
88
  });
@@ -52,10 +94,34 @@ module.exports = fp(async (fastify, options) => {
52
94
  {
53
95
  onRequest: [authenticate.user, authenticate.admin],
54
96
  schema: {
97
+ tags: ['管理后台-租户'],
98
+ summary: '获取租户基本信息',
55
99
  query: {
56
100
  type: 'object',
57
101
  properties: {
58
- id: { type: 'string' }
102
+ id: { type: 'string', description: '租户id' }
103
+ }
104
+ },
105
+ response: {
106
+ 200: {
107
+ content: {
108
+ 'application/json': {
109
+ schema: {
110
+ type: 'object',
111
+ properties: {
112
+ id: { type: 'string', description: '租户id' },
113
+ name: { type: 'string', description: '租户名称' },
114
+ description: { type: 'string', description: '租户简介' },
115
+ serviceStartTime: { type: 'string', description: '服务开始时间' },
116
+ serviceEndTime: { type: 'string', description: '服务结束时间' },
117
+ accountNumber: { type: 'number', description: '最大租户用户数量' },
118
+ status: { type: 'number', description: '0:正常,10:过期被关闭,11:已禁用,12:已关闭' },
119
+ createdAt: { type: 'string', description: '创建时间' },
120
+ updatedAt: { type: 'string', description: '更新时间' }
121
+ }
122
+ }
123
+ }
124
+ }
59
125
  }
60
126
  }
61
127
  }
@@ -71,11 +137,20 @@ module.exports = fp(async (fastify, options) => {
71
137
  {
72
138
  onRequest: [authenticate.user, authenticate.admin],
73
139
  schema: {
140
+ tags: ['管理后台-租户'],
141
+ summary: '关闭租户',
74
142
  body: {
75
143
  type: 'object',
76
144
  required: ['tenantId'],
77
145
  properties: {
78
- tenantId: { type: 'string' }
146
+ tenantId: { type: 'string', description: '租户id' }
147
+ }
148
+ },
149
+ response: {
150
+ 200: {
151
+ content: {
152
+ 'application/json': {}
153
+ }
79
154
  }
80
155
  }
81
156
  }
@@ -92,11 +167,20 @@ module.exports = fp(async (fastify, options) => {
92
167
  {
93
168
  onRequest: [authenticate.user, authenticate.admin],
94
169
  schema: {
170
+ tags: ['管理后台-租户'],
171
+ summary: '开启租户',
95
172
  body: {
96
173
  type: 'object',
97
174
  required: ['tenantId'],
98
175
  properties: {
99
- tenantId: { type: 'string' }
176
+ tenantId: { type: 'string', description: '租户id' }
177
+ }
178
+ },
179
+ response: {
180
+ 200: {
181
+ content: {
182
+ 'application/json': {}
183
+ }
100
184
  }
101
185
  }
102
186
  }
@@ -113,19 +197,26 @@ module.exports = fp(async (fastify, options) => {
113
197
  {
114
198
  onRequest: [authenticate.user, authenticate.admin],
115
199
  schema: {
200
+ tags: ['管理后台-租户'],
201
+ summary: '添加租户',
116
202
  body: {
117
203
  type: 'object',
118
204
  required: ['name', 'accountNumber', 'serviceStartTime', 'serviceEndTime'],
119
205
  properties: {
120
- name: { type: 'string' },
121
- accountNumber: { type: 'number' },
122
- serviceStartTime: {
123
- type: 'string',
124
- format: 'date-time'
125
- },
126
- serviceEndTime: {
127
- type: 'string',
128
- format: 'date-time'
206
+ name: { type: 'string', description: '租户名称' },
207
+ description: { type: 'string', description: '租户简介' },
208
+ serviceStartTime: { type: 'string', description: '服务开始时间' },
209
+ serviceEndTime: { type: 'string', description: '服务结束时间' },
210
+ accountNumber: { type: 'number', description: '最大租户用户数量' },
211
+ status: { type: 'number', description: '0:正常,10:过期被关闭,11:已禁用,12:已关闭' },
212
+ createdAt: { type: 'string', description: '创建时间' },
213
+ updatedAt: { type: 'string', description: '更新时间' }
214
+ }
215
+ },
216
+ response: {
217
+ 200: {
218
+ content: {
219
+ 'application/json': {}
129
220
  }
130
221
  }
131
222
  }
@@ -146,16 +237,18 @@ module.exports = fp(async (fastify, options) => {
146
237
  type: 'object',
147
238
  required: ['id', 'name', 'accountNumber', 'serviceStartTime', 'serviceEndTime'],
148
239
  properties: {
149
- id: { type: 'string' },
150
- name: { type: 'string' },
151
- accountNumber: { type: 'number' },
152
- serviceStartTime: {
153
- type: 'string',
154
- format: 'date-time'
155
- },
156
- serviceEndTime: {
157
- type: 'string',
158
- format: 'date-time'
240
+ id: { type: 'string', description: '租户id' },
241
+ name: { type: 'string', description: '租户名称' },
242
+ description: { type: 'string', description: '租户简介' },
243
+ serviceStartTime: { type: 'string', description: '服务开始时间' },
244
+ serviceEndTime: { type: 'string', description: '服务结束时间' },
245
+ accountNumber: { type: 'number', description: '最大租户用户数量' }
246
+ }
247
+ },
248
+ response: {
249
+ 200: {
250
+ content: {
251
+ 'application/json': {}
159
252
  }
160
253
  }
161
254
  }
@@ -25,7 +25,7 @@ module.exports = fp(async (fastify, options) => {
25
25
  }
26
26
  },
27
27
  async request => {
28
- const { filter, tenantId, perPage, currentPage } = Object.assign(
28
+ const { filter, tenantId, withoutDefaultRole, perPage, currentPage } = Object.assign(
29
29
  {
30
30
  perPage: 20,
31
31
  currentPage: 1,
@@ -33,7 +33,7 @@ module.exports = fp(async (fastify, options) => {
33
33
  },
34
34
  request.query
35
35
  );
36
- return await services.tenantRole.getTenantRoleList({ tenantId, perPage, currentPage, filter });
36
+ return await services.tenantRole.getTenantRoleList({ tenantId, withoutDefaultRole, perPage, currentPage, filter });
37
37
  }
38
38
  );
39
39
 
@@ -15,7 +15,8 @@ module.exports = fp(async (fastify, options) => {
15
15
  filter: {
16
16
  type: 'object',
17
17
  properties: {
18
- name: { type: 'string' }
18
+ name: { type: 'string' },
19
+ roleIds: { type: 'array', items: { type: 'number' }, default: [] }
19
20
  }
20
21
  },
21
22
  currentPage: { type: 'number' },
@@ -10,11 +10,34 @@ module.exports = fp(async (fastify, options) => {
10
10
  return await services.tenantUser.getUserTenant(request.authenticatePayload);
11
11
  }
12
12
  );
13
+ fastify.get(
14
+ `${options.prefix}/tenant/getTenantInfo`,
15
+ {
16
+ onRequest: [authenticate.user]
17
+ },
18
+ async request => {
19
+ return await services.tenant.getTenantInfo(request.query);
20
+ }
21
+ );
13
22
 
14
23
  fastify.get(
15
24
  `${options.prefix}/tenant/getTenantUserInfo`,
16
25
  {
17
- onRequest: [authenticate.user, authenticate.tenant]
26
+ onRequest: [authenticate.user, authenticate.tenant],
27
+ schema: {
28
+ tags: ['管理后台'],
29
+ summary: '获取租户用户所有操作日志列表',
30
+ params: {
31
+ type: 'object',
32
+ required: [],
33
+ properties: {
34
+ filter: { type: 'object' },
35
+ type: { type: 'string' },
36
+ perPage: { type: 'number' },
37
+ currentPage: { type: 'number' }
38
+ }
39
+ }
40
+ }
18
41
  },
19
42
  async request => {
20
43
  return request.tenantInfo;
@@ -42,6 +42,7 @@ module.exports = ({ DataTypes }) => {
42
42
  options: {
43
43
  indexes: [
44
44
  {
45
+ name:'code_key',
45
46
  unique: true,
46
47
  fields: ['code', 'application_id', 'pid', 'deleted_at']
47
48
  }
@@ -17,6 +17,7 @@ module.exports = ({ DataTypes }) => {
17
17
  options: {
18
18
  indexes: [
19
19
  {
20
+ name:'tenant_key',
20
21
  unique: true,
21
22
  fields: ['tenant_id', 'application_id', 'deleted_at']
22
23
  }
@@ -17,6 +17,7 @@ module.exports = ({ DataTypes }) => {
17
17
  options: {
18
18
  indexes: [
19
19
  {
20
+ name:'tenant_key',
20
21
  unique: true,
21
22
  fields: ['tenant_id', 'permission_id', 'deleted_at']
22
23
  }
@@ -21,6 +21,7 @@ module.exports = ({ DataTypes }) => {
21
21
  options: {
22
22
  indexes: [
23
23
  {
24
+ name:'tenant_key',
24
25
  unique: true,
25
26
  fields: ['tenant_id', 'token', 'type', 'deleted_at']
26
27
  }
@@ -19,7 +19,7 @@ module.exports = ({ DataTypes }) => {
19
19
  },
20
20
  status: {
21
21
  type: DataTypes.INTEGER,
22
- defaultValue: 0 //0:正常,10:初始化未激活,需要用户设置密码后使用,11:已禁用,12:已关闭,
22
+ defaultValue: 0 //0:正常,1:初始化未激活,需要用户设置密码后使用,11:已禁用,12:已关闭,
23
23
  },
24
24
  currentTenantId: {
25
25
  type: DataTypes.UUID
@@ -29,6 +29,9 @@ module.exports = fp(async (fastify, options) => {
29
29
  };
30
30
 
31
31
  const addUser = async ({ avatar, nickname, phone, email, password, description }) => {
32
+ if (!email && !phone) {
33
+ throw new Error('请输入邮箱或手机号');
34
+ }
32
35
  return await services.user.addUser({
33
36
  avatar,
34
37
  nickname,
@@ -1,14 +1,21 @@
1
1
  const fp = require('fastify-plugin');
2
2
  const isNil = require('lodash/isNil');
3
+ const isEmpty = require('lodash/isEmpty');
4
+
3
5
  module.exports = fp(async (fastify, options) => {
4
6
  const { models, services } = fastify.account;
5
7
  const { Op } = fastify.sequelize.Sequelize;
6
8
 
7
- const getTenantRoleList = async ({ tenantId, currentPage, perPage, filter }) => {
9
+ const getTenantRoleList = async ({ tenantId, withoutDefaultRole, currentPage, perPage, filter }) => {
8
10
  const queryFilter = {};
9
11
  if (!isNil(filter?.type)) {
10
12
  queryFilter.type = filter.type;
11
13
  }
14
+ if (!isEmpty(withoutDefaultRole) && withoutDefaultRole === 'true') {
15
+ queryFilter.type = {
16
+ [Op.not]: 1
17
+ };
18
+ }
12
19
  const { count, rows } = await models.tenantRole.findAndCountAll({
13
20
  where: Object.assign({}, queryFilter, { tenantId }),
14
21
  offset: perPage * (currentPage - 1),
@@ -4,6 +4,7 @@ const groupBy = require('lodash/groupBy');
4
4
  const { Unauthorized } = require('http-errors');
5
5
  const pick = require('lodash/pick');
6
6
  const isNil = require('lodash/isNil');
7
+ const isEmpty = require('lodash/isEmpty');
7
8
  module.exports = fp(async (fastify, options) => {
8
9
  const { models, services } = fastify.account;
9
10
  const { Op } = fastify.sequelize.Sequelize;
@@ -483,6 +484,24 @@ module.exports = fp(async (fastify, options) => {
483
484
  };
484
485
  }
485
486
  });
487
+ if (filter && !isEmpty(filter.status)) {
488
+ queryFilter['status'] = {
489
+ [Op.eq]: filter.status
490
+ };
491
+ }
492
+ if (!isEmpty(filter.roleIds)) {
493
+ const defaultTenant = await models.tenantUserRole.findAll({
494
+ where: {
495
+ tenantRoleId: {
496
+ [Op.in]: !isEmpty(filter.roleIds) ? filter.roleIds : []
497
+ },
498
+ tenantId: tenantId
499
+ }
500
+ });
501
+ queryFilter['uuid'] = {
502
+ [Op.in]: (defaultTenant || []).map(item => item.tenantUserId)
503
+ };
504
+ }
486
505
 
487
506
  const { count, rows } = await models.tenantUser.findAndCountAll({
488
507
  include: [models.tenantRole, models.tenantOrg, models.user],
@@ -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;
@@ -24,15 +24,20 @@ module.exports = fp(async (fastify, options) => {
24
24
 
25
25
  return Object.assign({}, tenant.get({ plain: true }), { id: tenant.uuid });
26
26
  };
27
+ const getTenantInfo = async ({ id }) => {
28
+ const tenantInfo = await services.tenant.getTenant({ id: id });
29
+ // console.log('getTenantInfo=======>\n', tenantInfo);
30
+ return tenantInfo;
31
+ };
27
32
 
28
33
  const closeTenant = async ({ tenantId }) => {
29
- const tenant = await getTenant({ id: tenantId });
34
+ const tenant = await getTenantInstance({ id: tenantId });
30
35
  tenant.status = 12;
31
36
  await tenant.save();
32
37
  };
33
38
 
34
39
  const openTenant = async ({ tenantId }) => {
35
- const tenant = await getTenant({ id: tenantId });
40
+ const tenant = await getTenantInstance({ id: tenantId, isClose: true });
36
41
  tenant.status = 0;
37
42
  await tenant.save();
38
43
  };
@@ -83,6 +88,11 @@ module.exports = fp(async (fastify, options) => {
83
88
  [fastify.sequelize.Sequelize.Op.like]: `%${filter.name}%`
84
89
  };
85
90
  }
91
+ if (filter?.status) {
92
+ queryFilter.status = {
93
+ [fastify.sequelize.Sequelize.Op.like]: filter.status
94
+ };
95
+ }
86
96
 
87
97
  if (filter?.serviceStartTime) {
88
98
  queryFilter.serviceStartTime = {
@@ -123,6 +133,7 @@ module.exports = fp(async (fastify, options) => {
123
133
  services.tenant = {
124
134
  getTenantInstance,
125
135
  getTenant,
136
+ getTenantInfo,
126
137
  closeTenant,
127
138
  openTenant,
128
139
  saveTenant,
@@ -3,6 +3,7 @@ const { Unauthorized } = require('http-errors');
3
3
  const get = require('lodash/get');
4
4
  const pick = require('lodash/pick');
5
5
  const isNil = require('lodash/isNil');
6
+ const isEmpty = require('lodash/isEmpty');
6
7
 
7
8
  function userNameIsEmail(username) {
8
9
  return /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(username);
@@ -107,8 +108,10 @@ module.exports = fp(async (fastify, options) => {
107
108
  };
108
109
 
109
110
  const saveUser = async ({ id, ...otherInfo }) => {
111
+ if (!otherInfo.email && !otherInfo.phone) {
112
+ throw new Error('请输入邮箱或手机号');
113
+ }
110
114
  const user = await getUserInstance({ id });
111
-
112
115
  if ((await accountIsExists({ phone: otherInfo.phone, email: otherInfo.email }, user)) > 0) {
113
116
  throw new Error('手机号或者邮箱都不能重复');
114
117
  }
@@ -142,20 +145,33 @@ module.exports = fp(async (fastify, options) => {
142
145
  };
143
146
 
144
147
  const getAllUserList = async ({ filter, perPage, currentPage }) => {
145
- const queryFilter = {};
148
+ const queryFilter = {},
149
+ roleQueryFilter = {};
146
150
 
147
- ['nickname'].forEach(key => {
151
+ ['nickname', 'email', 'phone'].forEach(key => {
148
152
  if (filter && filter[key]) {
149
153
  queryFilter[key] = {
150
154
  [Op.like]: `%${filter[key]}%`
151
155
  };
152
156
  }
153
157
  });
158
+ if (filter && !isEmpty(filter.status)) {
159
+ queryFilter['status'] = {
160
+ [Op.eq]: filter.status
161
+ };
162
+ }
163
+ if (!isEmpty(filter?.isSuperAdmin)) {
164
+ roleQueryFilter['role'] = {
165
+ [Op.eq]: filter.isSuperAdmin === 'false' ? 'Common' : 'SuperAdmin'
166
+ };
167
+ }
154
168
  const { count, rows } = await models.user.findAndCountAll({
155
169
  include: [
156
170
  {
157
171
  attributes: ['role'],
158
- model: models.adminRole
172
+ model: models.adminRole,
173
+ where: roleQueryFilter,
174
+ required: !!roleQueryFilter.role
159
175
  },
160
176
  {
161
177
  model: models.tenant
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-account",
3
- "version": "1.0.0-alpha.21",
3
+ "version": "1.0.0-alpha.23",
4
4
  "description": "fastify的用户管理账号等实现",
5
5
  "main": "index.js",
6
6
  "scripts": {