@kne/fastify-account 1.0.0-alpha.19 → 1.0.0-alpha.20
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 +327 -47
- package/index.js +5 -0
- package/libs/controllers/adminPermission.js +1 -0
- package/libs/controllers/adminTenantCompany.js +53 -0
- package/libs/controllers/adminTenantUser.js +1 -0
- package/libs/controllers/requestLog.js +77 -0
- package/libs/controllers/tenantCompany.js +54 -0
- package/libs/models/request-log.js +4 -0
- package/libs/services/request-log.js +19 -1
- package/libs/services/tenant-company.js +54 -0
- package/libs/services/tenant-user.js +2 -2
- package/libs/services/user.js +14 -1
- 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.18"
|
|
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.18</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
|
|
|
@@ -667,7 +667,7 @@ This operation does not require authentication
|
|
|
667
667
|
|
|
668
668
|
|Name|In|Type|Required|Description|
|
|
669
669
|
|---|---|---|---|---|
|
|
670
|
-
|tenantId|query|string|
|
|
670
|
+
|tenantId|query|string|true|none|
|
|
671
671
|
|filter|query|object|false|none|
|
|
672
672
|
|currentPage|query|number|false|none|
|
|
673
673
|
|perPage|query|number|false|none|
|
|
@@ -2124,51 +2124,21 @@ This operation does not require authentication
|
|
|
2124
2124
|
|
|
2125
2125
|
```json
|
|
2126
2126
|
{
|
|
2127
|
-
"
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
"
|
|
2136
|
-
"email": {
|
|
2137
|
-
"type": "string",
|
|
2138
|
-
"description": "邮箱"
|
|
2139
|
-
},
|
|
2140
|
-
"newPwd": {
|
|
2141
|
-
"type": "string",
|
|
2142
|
-
"description": "新密码"
|
|
2143
|
-
},
|
|
2144
|
-
"token": {
|
|
2145
|
-
"type": "string",
|
|
2146
|
-
"description": "验证token"
|
|
2147
|
-
}
|
|
2148
|
-
}
|
|
2127
|
+
"type": "object",
|
|
2128
|
+
"required": [
|
|
2129
|
+
"newPwd",
|
|
2130
|
+
"token"
|
|
2131
|
+
],
|
|
2132
|
+
"properties": {
|
|
2133
|
+
"newPwd": {
|
|
2134
|
+
"type": "string",
|
|
2135
|
+
"description": "新密码"
|
|
2149
2136
|
},
|
|
2150
|
-
{
|
|
2151
|
-
"type": "
|
|
2152
|
-
"
|
|
2153
|
-
"phone",
|
|
2154
|
-
"newPwd"
|
|
2155
|
-
],
|
|
2156
|
-
"properties": {
|
|
2157
|
-
"phone": {
|
|
2158
|
-
"type": "string",
|
|
2159
|
-
"description": "手机号"
|
|
2160
|
-
},
|
|
2161
|
-
"newPwd": {
|
|
2162
|
-
"type": "string",
|
|
2163
|
-
"description": "新密码"
|
|
2164
|
-
},
|
|
2165
|
-
"token": {
|
|
2166
|
-
"type": "string",
|
|
2167
|
-
"description": "验证token"
|
|
2168
|
-
}
|
|
2169
|
-
}
|
|
2137
|
+
"token": {
|
|
2138
|
+
"type": "string",
|
|
2139
|
+
"description": "验证token"
|
|
2170
2140
|
}
|
|
2171
|
-
|
|
2141
|
+
}
|
|
2172
2142
|
}
|
|
2173
2143
|
```
|
|
2174
2144
|
|
|
@@ -2176,7 +2146,9 @@ This operation does not require authentication
|
|
|
2176
2146
|
|
|
2177
2147
|
|Name|In|Type|Required|Description|
|
|
2178
2148
|
|---|---|---|---|---|
|
|
2179
|
-
|body|body|
|
|
2149
|
+
|body|body|object|true|none|
|
|
2150
|
+
|» newPwd|body|string|true|新密码|
|
|
2151
|
+
|» token|body|string|true|验证token|
|
|
2180
2152
|
|
|
2181
2153
|
<h3 id="post__api_v1_account_resetpassword-responses">Responses</h3>
|
|
2182
2154
|
|
|
@@ -2670,6 +2642,186 @@ This operation does not require authentication
|
|
|
2670
2642
|
This operation does not require authentication
|
|
2671
2643
|
</aside>
|
|
2672
2644
|
|
|
2645
|
+
## get__api_v1_account_admin_getCompanyInfo
|
|
2646
|
+
|
|
2647
|
+
`GET /api/v1/account/admin/getCompanyInfo`
|
|
2648
|
+
|
|
2649
|
+
*获取租户管理的公司信息*
|
|
2650
|
+
|
|
2651
|
+
<h3 id="get__api_v1_account_admin_getcompanyinfo-parameters">Parameters</h3>
|
|
2652
|
+
|
|
2653
|
+
|Name|In|Type|Required|Description|
|
|
2654
|
+
|---|---|---|---|---|
|
|
2655
|
+
|tenantId|query|string|false|none|
|
|
2656
|
+
|
|
2657
|
+
<h3 id="get__api_v1_account_admin_getcompanyinfo-responses">Responses</h3>
|
|
2658
|
+
|
|
2659
|
+
|Status|Meaning|Description|Schema|
|
|
2660
|
+
|---|---|---|---|
|
|
2661
|
+
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|None|
|
|
2662
|
+
|
|
2663
|
+
<aside class="success">
|
|
2664
|
+
This operation does not require authentication
|
|
2665
|
+
</aside>
|
|
2666
|
+
|
|
2667
|
+
## post__api_v1_account_admin_saveCompanyInfo
|
|
2668
|
+
|
|
2669
|
+
`POST /api/v1/account/admin/saveCompanyInfo`
|
|
2670
|
+
|
|
2671
|
+
*修改租户管理的公司信息*
|
|
2672
|
+
|
|
2673
|
+
> Body parameter
|
|
2674
|
+
|
|
2675
|
+
```json
|
|
2676
|
+
{
|
|
2677
|
+
"type": "object",
|
|
2678
|
+
"properties": {
|
|
2679
|
+
"id": {
|
|
2680
|
+
"type": "number"
|
|
2681
|
+
},
|
|
2682
|
+
"tenantId": {
|
|
2683
|
+
"type": "string"
|
|
2684
|
+
},
|
|
2685
|
+
"name": {
|
|
2686
|
+
"type": "string"
|
|
2687
|
+
},
|
|
2688
|
+
"shortName": {
|
|
2689
|
+
"type": "string"
|
|
2690
|
+
},
|
|
2691
|
+
"themeColor": {
|
|
2692
|
+
"type": "string"
|
|
2693
|
+
},
|
|
2694
|
+
"logo": {
|
|
2695
|
+
"type": "string"
|
|
2696
|
+
},
|
|
2697
|
+
"description": {
|
|
2698
|
+
"type": "string"
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
```
|
|
2703
|
+
|
|
2704
|
+
<h3 id="post__api_v1_account_admin_savecompanyinfo-parameters">Parameters</h3>
|
|
2705
|
+
|
|
2706
|
+
|Name|In|Type|Required|Description|
|
|
2707
|
+
|---|---|---|---|---|
|
|
2708
|
+
|body|body|object|false|none|
|
|
2709
|
+
|» id|body|number|false|none|
|
|
2710
|
+
|» tenantId|body|string|false|none|
|
|
2711
|
+
|» name|body|string|false|none|
|
|
2712
|
+
|» shortName|body|string|false|none|
|
|
2713
|
+
|» themeColor|body|string|false|none|
|
|
2714
|
+
|» logo|body|string|false|none|
|
|
2715
|
+
|» description|body|string|false|none|
|
|
2716
|
+
|
|
2717
|
+
<h3 id="post__api_v1_account_admin_savecompanyinfo-responses">Responses</h3>
|
|
2718
|
+
|
|
2719
|
+
|Status|Meaning|Description|Schema|
|
|
2720
|
+
|---|---|---|---|
|
|
2721
|
+
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|None|
|
|
2722
|
+
|
|
2723
|
+
<aside class="success">
|
|
2724
|
+
This operation does not require authentication
|
|
2725
|
+
</aside>
|
|
2726
|
+
|
|
2727
|
+
## post__api_v1_account_admin_getAllOperationLogList
|
|
2728
|
+
|
|
2729
|
+
`POST /api/v1/account/admin/getAllOperationLogList`
|
|
2730
|
+
|
|
2731
|
+
*获取所有操作日志列表*
|
|
2732
|
+
|
|
2733
|
+
> Body parameter
|
|
2734
|
+
|
|
2735
|
+
```json
|
|
2736
|
+
{
|
|
2737
|
+
"type": "object",
|
|
2738
|
+
"required": [],
|
|
2739
|
+
"properties": {
|
|
2740
|
+
"filter": {
|
|
2741
|
+
"type": "object"
|
|
2742
|
+
},
|
|
2743
|
+
"type": {
|
|
2744
|
+
"type": "string"
|
|
2745
|
+
},
|
|
2746
|
+
"perPage": {
|
|
2747
|
+
"type": "number"
|
|
2748
|
+
},
|
|
2749
|
+
"currentPage": {
|
|
2750
|
+
"type": "number"
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
```
|
|
2755
|
+
|
|
2756
|
+
<h3 id="post__api_v1_account_admin_getalloperationloglist-parameters">Parameters</h3>
|
|
2757
|
+
|
|
2758
|
+
|Name|In|Type|Required|Description|
|
|
2759
|
+
|---|---|---|---|---|
|
|
2760
|
+
|body|body|object|false|none|
|
|
2761
|
+
|» filter|body|object|false|none|
|
|
2762
|
+
|» type|body|string|false|none|
|
|
2763
|
+
|» perPage|body|number|false|none|
|
|
2764
|
+
|» currentPage|body|number|false|none|
|
|
2765
|
+
|
|
2766
|
+
<h3 id="post__api_v1_account_admin_getalloperationloglist-responses">Responses</h3>
|
|
2767
|
+
|
|
2768
|
+
|Status|Meaning|Description|Schema|
|
|
2769
|
+
|---|---|---|---|
|
|
2770
|
+
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|None|
|
|
2771
|
+
|
|
2772
|
+
<aside class="success">
|
|
2773
|
+
This operation does not require authentication
|
|
2774
|
+
</aside>
|
|
2775
|
+
|
|
2776
|
+
## post__api_v1_account_admin_getTenantOperationLogList
|
|
2777
|
+
|
|
2778
|
+
`POST /api/v1/account/admin/getTenantOperationLogList`
|
|
2779
|
+
|
|
2780
|
+
*获取租户操作日志列表*
|
|
2781
|
+
|
|
2782
|
+
> Body parameter
|
|
2783
|
+
|
|
2784
|
+
```json
|
|
2785
|
+
{
|
|
2786
|
+
"type": "object",
|
|
2787
|
+
"required": [],
|
|
2788
|
+
"properties": {
|
|
2789
|
+
"filter": {
|
|
2790
|
+
"type": "object"
|
|
2791
|
+
},
|
|
2792
|
+
"type": {
|
|
2793
|
+
"type": "string"
|
|
2794
|
+
},
|
|
2795
|
+
"perPage": {
|
|
2796
|
+
"type": "number"
|
|
2797
|
+
},
|
|
2798
|
+
"currentPage": {
|
|
2799
|
+
"type": "number"
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
```
|
|
2804
|
+
|
|
2805
|
+
<h3 id="post__api_v1_account_admin_gettenantoperationloglist-parameters">Parameters</h3>
|
|
2806
|
+
|
|
2807
|
+
|Name|In|Type|Required|Description|
|
|
2808
|
+
|---|---|---|---|---|
|
|
2809
|
+
|body|body|object|false|none|
|
|
2810
|
+
|» filter|body|object|false|none|
|
|
2811
|
+
|» type|body|string|false|none|
|
|
2812
|
+
|» perPage|body|number|false|none|
|
|
2813
|
+
|» currentPage|body|number|false|none|
|
|
2814
|
+
|
|
2815
|
+
<h3 id="post__api_v1_account_admin_gettenantoperationloglist-responses">Responses</h3>
|
|
2816
|
+
|
|
2817
|
+
|Status|Meaning|Description|Schema|
|
|
2818
|
+
|---|---|---|---|
|
|
2819
|
+
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|None|
|
|
2820
|
+
|
|
2821
|
+
<aside class="success">
|
|
2822
|
+
This operation does not require authentication
|
|
2823
|
+
</aside>
|
|
2824
|
+
|
|
2673
2825
|
<h1 id="-kne-fastify-account--">管理后台-权限</h1>
|
|
2674
2826
|
|
|
2675
2827
|
## post__api_v1_account_admin_addApplication
|
|
@@ -3323,6 +3475,134 @@ This operation does not require authentication
|
|
|
3323
3475
|
This operation does not require authentication
|
|
3324
3476
|
</aside>
|
|
3325
3477
|
|
|
3478
|
+
## post__api_v1_account_admin_copyPermissions
|
|
3479
|
+
|
|
3480
|
+
`POST /api/v1/account/admin/copyPermissions`
|
|
3481
|
+
|
|
3482
|
+
*复制应用权限到目标应用*
|
|
3483
|
+
|
|
3484
|
+
> Body parameter
|
|
3485
|
+
|
|
3486
|
+
```json
|
|
3487
|
+
{
|
|
3488
|
+
"type": "object",
|
|
3489
|
+
"required": [
|
|
3490
|
+
"applicationId",
|
|
3491
|
+
"originApplicationId"
|
|
3492
|
+
],
|
|
3493
|
+
"properties": {
|
|
3494
|
+
"applicationId": {
|
|
3495
|
+
"type": "string"
|
|
3496
|
+
},
|
|
3497
|
+
"originApplicationId": {
|
|
3498
|
+
"type": "string"
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
}
|
|
3502
|
+
```
|
|
3503
|
+
|
|
3504
|
+
<h3 id="post__api_v1_account_admin_copypermissions-parameters">Parameters</h3>
|
|
3505
|
+
|
|
3506
|
+
|Name|In|Type|Required|Description|
|
|
3507
|
+
|---|---|---|---|---|
|
|
3508
|
+
|body|body|object|true|none|
|
|
3509
|
+
|» applicationId|body|string|true|none|
|
|
3510
|
+
|» originApplicationId|body|string|true|none|
|
|
3511
|
+
|
|
3512
|
+
<h3 id="post__api_v1_account_admin_copypermissions-responses">Responses</h3>
|
|
3513
|
+
|
|
3514
|
+
|Status|Meaning|Description|Schema|
|
|
3515
|
+
|---|---|---|---|
|
|
3516
|
+
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|None|
|
|
3517
|
+
|
|
3518
|
+
<aside class="success">
|
|
3519
|
+
This operation does not require authentication
|
|
3520
|
+
</aside>
|
|
3521
|
+
|
|
3522
|
+
<h1 id="-kne-fastify-account--">租户平台</h1>
|
|
3523
|
+
|
|
3524
|
+
## get__api_v1_account_tenant_getCompanyInfo
|
|
3525
|
+
|
|
3526
|
+
`GET /api/v1/account/tenant/getCompanyInfo`
|
|
3527
|
+
|
|
3528
|
+
*获取租户的公司信息*
|
|
3529
|
+
|
|
3530
|
+
<h3 id="get__api_v1_account_tenant_getcompanyinfo-parameters">Parameters</h3>
|
|
3531
|
+
|
|
3532
|
+
|Name|In|Type|Required|Description|
|
|
3533
|
+
|---|---|---|---|---|
|
|
3534
|
+
|currentPage|query|number|false|none|
|
|
3535
|
+
|perPage|query|number|false|none|
|
|
3536
|
+
|
|
3537
|
+
<h3 id="get__api_v1_account_tenant_getcompanyinfo-responses">Responses</h3>
|
|
3538
|
+
|
|
3539
|
+
|Status|Meaning|Description|Schema|
|
|
3540
|
+
|---|---|---|---|
|
|
3541
|
+
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|None|
|
|
3542
|
+
|
|
3543
|
+
<aside class="success">
|
|
3544
|
+
This operation does not require authentication
|
|
3545
|
+
</aside>
|
|
3546
|
+
|
|
3547
|
+
## post__api_v1_account_tenant_saveCompanyInfo
|
|
3548
|
+
|
|
3549
|
+
`POST /api/v1/account/tenant/saveCompanyInfo`
|
|
3550
|
+
|
|
3551
|
+
*修改租户的公司信息*
|
|
3552
|
+
|
|
3553
|
+
> Body parameter
|
|
3554
|
+
|
|
3555
|
+
```json
|
|
3556
|
+
{
|
|
3557
|
+
"type": "object",
|
|
3558
|
+
"required": [
|
|
3559
|
+
"id"
|
|
3560
|
+
],
|
|
3561
|
+
"properties": {
|
|
3562
|
+
"id": {
|
|
3563
|
+
"type": "number"
|
|
3564
|
+
},
|
|
3565
|
+
"name": {
|
|
3566
|
+
"type": "string"
|
|
3567
|
+
},
|
|
3568
|
+
"shortName": {
|
|
3569
|
+
"type": "string"
|
|
3570
|
+
},
|
|
3571
|
+
"themeColor": {
|
|
3572
|
+
"type": "string"
|
|
3573
|
+
},
|
|
3574
|
+
"logo": {
|
|
3575
|
+
"type": "string"
|
|
3576
|
+
},
|
|
3577
|
+
"description": {
|
|
3578
|
+
"type": "string"
|
|
3579
|
+
}
|
|
3580
|
+
}
|
|
3581
|
+
}
|
|
3582
|
+
```
|
|
3583
|
+
|
|
3584
|
+
<h3 id="post__api_v1_account_tenant_savecompanyinfo-parameters">Parameters</h3>
|
|
3585
|
+
|
|
3586
|
+
|Name|In|Type|Required|Description|
|
|
3587
|
+
|---|---|---|---|---|
|
|
3588
|
+
|body|body|object|true|none|
|
|
3589
|
+
|» id|body|number|true|none|
|
|
3590
|
+
|» name|body|string|false|none|
|
|
3591
|
+
|» shortName|body|string|false|none|
|
|
3592
|
+
|» themeColor|body|string|false|none|
|
|
3593
|
+
|» logo|body|string|false|none|
|
|
3594
|
+
|» description|body|string|false|none|
|
|
3595
|
+
|
|
3596
|
+
<h3 id="post__api_v1_account_tenant_savecompanyinfo-responses">Responses</h3>
|
|
3597
|
+
|
|
3598
|
+
|Status|Meaning|Description|Schema|
|
|
3599
|
+
|---|---|---|---|
|
|
3600
|
+
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Default Response|None|
|
|
3601
|
+
|
|
3602
|
+
<aside class="success">
|
|
3603
|
+
This operation does not require authentication
|
|
3604
|
+
</aside>
|
|
3605
|
+
|
|
3326
3606
|
<h1 id="-kne-fastify-account--">租户管理-权限</h1>
|
|
3327
3607
|
|
|
3328
3608
|
## get__api_v1_account_tenant_getApplicationList
|
package/index.js
CHANGED
|
@@ -56,10 +56,14 @@ module.exports = fp(
|
|
|
56
56
|
});
|
|
57
57
|
},
|
|
58
58
|
tenant: async request => {
|
|
59
|
+
request.appName = request.headers['x-app-name'];
|
|
59
60
|
request.tenantInfo = await fastify.account.services.tenantUser.getTenantUserByUserId({
|
|
60
61
|
userInfo: request.userInfo,
|
|
61
62
|
appName: request.appName
|
|
62
63
|
});
|
|
64
|
+
request.tenantInfo.companyInfo = await fastify.account.services.tenantCompany.getTenantCompanyInfo({
|
|
65
|
+
tenantId: request.tenantInfo.tenant.id
|
|
66
|
+
});
|
|
63
67
|
await fastify.account.services.requestLog.addRequestLog({
|
|
64
68
|
userInfo: request.userInfo,
|
|
65
69
|
tenantId: request.tenantInfo.tenant.id,
|
|
@@ -73,6 +77,7 @@ module.exports = fp(
|
|
|
73
77
|
if (!(await fastify.account.services.admin.checkIsSuperAdmin(request.userInfo))) {
|
|
74
78
|
throw Unauthorized('不能执行该操作,需要超级管理员权限');
|
|
75
79
|
}
|
|
80
|
+
request.appName = request.headers['x-app-name'];
|
|
76
81
|
await fastify.account.services.requestLog.addRequestLog({
|
|
77
82
|
userInfo: request.userInfo,
|
|
78
83
|
appName: request.appName,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const fp = require('fastify-plugin');
|
|
2
|
+
|
|
3
|
+
module.exports = fp(async (fastify, options) => {
|
|
4
|
+
const { authenticate, services } = fastify.account;
|
|
5
|
+
|
|
6
|
+
fastify.get(
|
|
7
|
+
`${options.prefix}/admin/getCompanyInfo`,
|
|
8
|
+
{
|
|
9
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
10
|
+
schema: {
|
|
11
|
+
tags: ['管理后台'],
|
|
12
|
+
summary: '获取租户管理的公司信息',
|
|
13
|
+
required: ['tenantId'],
|
|
14
|
+
query: {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
tenantId: { type: 'string' }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
async request => {
|
|
23
|
+
return await services.tenantCompany.getTenantCompanyInfo(request.query);
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
fastify.post(
|
|
28
|
+
`${options.prefix}/admin/saveCompanyInfo`,
|
|
29
|
+
{
|
|
30
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
31
|
+
schema: {
|
|
32
|
+
tags: ['管理后台'],
|
|
33
|
+
summary: '修改租户管理的公司信息',
|
|
34
|
+
required: ['tenantId', 'id'],
|
|
35
|
+
body: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
id: { type: 'number' },
|
|
39
|
+
tenantId: { type: 'string' },
|
|
40
|
+
name: { type: 'string' },
|
|
41
|
+
shortName: { type: 'string' },
|
|
42
|
+
themeColor: { type: 'string' },
|
|
43
|
+
logo: { type: 'string' },
|
|
44
|
+
description: { type: 'string' }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
async request => {
|
|
50
|
+
return await services.tenantCompany.saveTenantCompanyInfo(request.body);
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const fp = require('fastify-plugin');
|
|
2
|
+
|
|
3
|
+
module.exports = fp(async (fastify, options) => {
|
|
4
|
+
const { authenticate, services } = fastify.account;
|
|
5
|
+
|
|
6
|
+
fastify.post(
|
|
7
|
+
`${options.prefix}/admin/getAllOperationLogList`,
|
|
8
|
+
{
|
|
9
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
10
|
+
schema: {
|
|
11
|
+
tags: ['管理后台'],
|
|
12
|
+
summary: '获取所有操作日志列表',
|
|
13
|
+
body: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
required: [],
|
|
16
|
+
properties: {
|
|
17
|
+
filter: { type: 'object' },
|
|
18
|
+
type: { type: 'string' },
|
|
19
|
+
perPage: { type: 'number' },
|
|
20
|
+
currentPage: { type: 'number' }
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
async request => {
|
|
26
|
+
const { filter, type, perPage, currentPage } = Object.assign(
|
|
27
|
+
{
|
|
28
|
+
perPage: 20,
|
|
29
|
+
currentPage: 1
|
|
30
|
+
},
|
|
31
|
+
request.body
|
|
32
|
+
);
|
|
33
|
+
return await services.requestLog.getRequestLogList({
|
|
34
|
+
filter,
|
|
35
|
+
type,
|
|
36
|
+
perPage,
|
|
37
|
+
currentPage
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
fastify.post(
|
|
43
|
+
`${options.prefix}/admin/getTenantOperationLogList`,
|
|
44
|
+
{
|
|
45
|
+
onRequest: [authenticate.user, authenticate.tenant],
|
|
46
|
+
schema: {
|
|
47
|
+
tags: ['管理后台'],
|
|
48
|
+
summary: '获取租户操作日志列表',
|
|
49
|
+
body: {
|
|
50
|
+
type: 'object',
|
|
51
|
+
required: [],
|
|
52
|
+
properties: {
|
|
53
|
+
filter: { type: 'object' },
|
|
54
|
+
type: { type: 'string' },
|
|
55
|
+
perPage: { type: 'number' },
|
|
56
|
+
currentPage: { type: 'number' }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
async request => {
|
|
62
|
+
const { filter, type, perPage, currentPage } = Object.assign(
|
|
63
|
+
{
|
|
64
|
+
perPage: 20,
|
|
65
|
+
currentPage: 1
|
|
66
|
+
},
|
|
67
|
+
request.body
|
|
68
|
+
);
|
|
69
|
+
return await services.requestLog.getRequestLogList({
|
|
70
|
+
filter,
|
|
71
|
+
type,
|
|
72
|
+
perPage,
|
|
73
|
+
currentPage
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const fp = require('fastify-plugin');
|
|
2
|
+
|
|
3
|
+
module.exports = fp(async (fastify, options) => {
|
|
4
|
+
const { authenticate, services } = fastify.account;
|
|
5
|
+
|
|
6
|
+
fastify.get(
|
|
7
|
+
`${options.prefix}/tenant/getCompanyInfo`,
|
|
8
|
+
{
|
|
9
|
+
onRequest: [authenticate.user, authenticate.tenant],
|
|
10
|
+
schema: {
|
|
11
|
+
tags: ['租户平台'],
|
|
12
|
+
summary: '获取租户的公司信息',
|
|
13
|
+
query: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
currentPage: { type: 'number' },
|
|
17
|
+
perPage: { type: 'number' }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
async request => {
|
|
23
|
+
const { id: tenantId } = request.tenantInfo.tenant;
|
|
24
|
+
return await services.tenantCompany.getTenantCompanyInfo({ tenantId });
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
fastify.post(
|
|
29
|
+
`${options.prefix}/tenant/saveCompanyInfo`,
|
|
30
|
+
{
|
|
31
|
+
onRequest: [authenticate.user, authenticate.tenant],
|
|
32
|
+
schema: {
|
|
33
|
+
tags: ['租户平台'],
|
|
34
|
+
summary: '修改租户的公司信息',
|
|
35
|
+
body: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
required: ['id'],
|
|
38
|
+
properties: {
|
|
39
|
+
id: { type: 'number' },
|
|
40
|
+
name: { type: 'string' },
|
|
41
|
+
shortName: { type: 'string' },
|
|
42
|
+
themeColor: { type: 'string' },
|
|
43
|
+
logo: { type: 'string' },
|
|
44
|
+
description: { type: 'string' }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
async request => {
|
|
50
|
+
const { id: tenantId } = request.tenantInfo.tenant;
|
|
51
|
+
return await services.tenantCompany.saveTenantCompanyInfo(Object.assign({}, request.body, { tenantId }));
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
});
|
|
@@ -34,6 +34,10 @@ module.exports = ({ DataTypes }) => {
|
|
|
34
34
|
fields: ['action', 'type']
|
|
35
35
|
}
|
|
36
36
|
]
|
|
37
|
+
},
|
|
38
|
+
associate: ({ requestLog, application, user }) => {
|
|
39
|
+
requestLog.belongsTo(application, { targetKey: 'uuid', constraints: false });
|
|
40
|
+
requestLog.belongsTo(user, { targetKey: 'uuid', constraints: false });
|
|
37
41
|
}
|
|
38
42
|
};
|
|
39
43
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const fp = require('fastify-plugin');
|
|
2
|
+
|
|
2
3
|
module.exports = fp(async (fastify, options) => {
|
|
3
4
|
const { models, services } = fastify.account;
|
|
4
5
|
|
|
@@ -15,5 +16,22 @@ module.exports = fp(async (fastify, options) => {
|
|
|
15
16
|
return {};
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
const getRequestLogList = async ({ filter, type, perPage, currentPage }) => {
|
|
20
|
+
const { count, rows } = await models.requestLog.findAndCountAll({
|
|
21
|
+
include: [models.application, models.user],
|
|
22
|
+
order: [['createdAt', 'DESC']],
|
|
23
|
+
where: Object.assign({}, filter, { type }),
|
|
24
|
+
offset: perPage * (currentPage - 1),
|
|
25
|
+
limit: perPage
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
pageData: rows,
|
|
29
|
+
totalCount: count
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
services.requestLog = {
|
|
34
|
+
addRequestLog,
|
|
35
|
+
getRequestLogList
|
|
36
|
+
};
|
|
19
37
|
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const fp = require('fastify-plugin');
|
|
2
|
+
const isNil = require('lodash/isNil');
|
|
3
|
+
|
|
4
|
+
module.exports = fp(async (fastify, options) => {
|
|
5
|
+
const { models, services } = fastify.account;
|
|
6
|
+
|
|
7
|
+
const addCompanyInfo = async companyInfo => {
|
|
8
|
+
const currentCompanyInfo = await models.companyInfo.create(companyInfo);
|
|
9
|
+
return Object.assign({}, currentCompanyInfo.get({ plain: true }), {
|
|
10
|
+
id: currentCompanyInfo.uuid
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const getTenantCompanyInfoInstance = async ({ tenantId }) => {
|
|
15
|
+
const currentTenantCompanyInfo = await models.companyInfo.findOne({
|
|
16
|
+
where: {
|
|
17
|
+
tenantId
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
if (!currentTenantCompanyInfo) {
|
|
21
|
+
return await addCompanyInfo({ tenantId });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return currentTenantCompanyInfo;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const getTenantCompanyInfo = async ({ tenantId }) => {
|
|
28
|
+
return await getTenantCompanyInfoInstance({ tenantId });
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const saveTenantCompanyInfo = async ({ tenantId, id, ...others }) => {
|
|
32
|
+
const tenantCompanyInfo = await models.companyInfo.findOne({
|
|
33
|
+
where: {
|
|
34
|
+
id
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
if (tenantId !== tenantCompanyInfo.tenantId) {
|
|
38
|
+
throw new Error('租户Id和当前租户用户的租户Id不一致');
|
|
39
|
+
}
|
|
40
|
+
['name', 'shortName', 'themeColor', 'logo', 'description'].forEach(name => {
|
|
41
|
+
if (!isNil(others[name])) {
|
|
42
|
+
tenantCompanyInfo[name] = others[name];
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
await tenantCompanyInfo.save();
|
|
47
|
+
return tenantCompanyInfo;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
services.tenantCompany = {
|
|
51
|
+
getTenantCompanyInfo,
|
|
52
|
+
saveTenantCompanyInfo
|
|
53
|
+
};
|
|
54
|
+
});
|
|
@@ -480,8 +480,8 @@ module.exports = fp(async (fastify, options) => {
|
|
|
480
480
|
}
|
|
481
481
|
});
|
|
482
482
|
|
|
483
|
-
const { count, rows } = await
|
|
484
|
-
include: [
|
|
483
|
+
const { count, rows } = await models.tenantUser.findAndCountAll({
|
|
484
|
+
include: [models.tenantRole, models.tenantOrg, models.user],
|
|
485
485
|
where: Object.assign({}, queryFilter, { tenantId }),
|
|
486
486
|
offset: perPage * (currentPage - 1),
|
|
487
487
|
limit: perPage
|
package/libs/services/user.js
CHANGED
|
@@ -10,6 +10,7 @@ function userNameIsEmail(username) {
|
|
|
10
10
|
|
|
11
11
|
module.exports = fp(async (fastify, options) => {
|
|
12
12
|
const { models, services } = fastify.account;
|
|
13
|
+
const { Op } = fastify.sequelize.Sequelize;
|
|
13
14
|
|
|
14
15
|
const getUserInstance = async ({ id }) => {
|
|
15
16
|
const user = await models.user.findOne({
|
|
@@ -141,6 +142,15 @@ module.exports = fp(async (fastify, options) => {
|
|
|
141
142
|
};
|
|
142
143
|
|
|
143
144
|
const getAllUserList = async ({ filter, perPage, currentPage }) => {
|
|
145
|
+
const queryFilter = {};
|
|
146
|
+
|
|
147
|
+
['nickname'].forEach(key => {
|
|
148
|
+
if (filter && filter[key]) {
|
|
149
|
+
queryFilter[key] = {
|
|
150
|
+
[Op.like]: `%${filter[key]}%`
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
});
|
|
144
154
|
const { count, rows } = await models.user.findAndCountAll({
|
|
145
155
|
include: [
|
|
146
156
|
{
|
|
@@ -150,7 +160,10 @@ module.exports = fp(async (fastify, options) => {
|
|
|
150
160
|
{
|
|
151
161
|
model: models.tenant
|
|
152
162
|
}
|
|
153
|
-
]
|
|
163
|
+
],
|
|
164
|
+
where: queryFilter,
|
|
165
|
+
offset: perPage * (currentPage - 1),
|
|
166
|
+
limit: perPage
|
|
154
167
|
});
|
|
155
168
|
return {
|
|
156
169
|
pageData: rows.map(item => {
|