@kne/fastify-account 1.0.0-alpha.2 → 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 +2506 -803
- package/index.js +61 -8
- package/libs/controllers/account.js +221 -37
- package/libs/controllers/admin.js +92 -17
- package/libs/controllers/adminPermission.js +188 -38
- package/libs/controllers/adminTenant.js +44 -257
- package/libs/controllers/adminTenantCompany.js +53 -0
- package/libs/controllers/adminTenantOrg.js +71 -0
- package/libs/controllers/{adminRole.js → adminTenantRole.js} +15 -12
- package/libs/controllers/adminTenantUser.js +169 -0
- package/libs/controllers/requestLog.js +77 -0
- package/libs/controllers/tenant.js +4 -14
- package/libs/controllers/tenantCompany.js +54 -0
- package/libs/controllers/tenantOrg.js +65 -0
- package/libs/controllers/tenantRole.js +219 -0
- package/libs/controllers/tenantUser.js +169 -0
- package/libs/controllers/user.js +4 -3
- package/libs/models/admin-role.js +4 -8
- package/libs/models/application.js +16 -10
- package/libs/models/company-info.js +25 -0
- package/libs/models/login-log.js +11 -9
- package/libs/models/permission.js +7 -9
- package/libs/models/request-log.js +43 -0
- package/libs/models/tenant-application.js +8 -10
- package/libs/models/tenant-org.js +5 -9
- package/libs/models/tenant-permission.js +7 -9
- package/libs/models/tenant-role-application.js +13 -13
- package/libs/models/tenant-role-permission.js +9 -14
- package/libs/models/tenant-role.js +5 -9
- package/libs/models/tenant-share-group-permission.js +5 -9
- package/libs/models/tenant-share-group.js +5 -9
- package/libs/models/tenant-source-user-share-group.js +5 -9
- package/libs/models/tenant-token.js +7 -9
- package/libs/models/tenant-user-org.js +11 -10
- package/libs/models/tenant-user-role.js +11 -10
- package/libs/models/tenant-user-share-group.js +6 -10
- package/libs/models/tenant-user.js +35 -16
- package/libs/models/tenant.js +17 -9
- package/libs/models/user-account.js +17 -9
- package/libs/models/user.js +27 -17
- package/libs/models/verification-code.js +8 -10
- package/libs/services/account.js +95 -71
- package/libs/services/admin.js +38 -122
- package/libs/services/application.js +170 -0
- package/libs/services/permission.js +161 -163
- package/libs/services/request-log.js +37 -0
- package/libs/services/tenant-company.js +54 -0
- package/libs/services/tenant-invite.js +62 -0
- package/libs/services/tenant-org.js +118 -0
- package/libs/services/tenant-role.js +109 -0
- package/libs/services/tenant-user.js +578 -0
- package/libs/services/tenant.js +69 -670
- package/libs/services/user.js +109 -33
- package/package.json +3 -3
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
const fp = require('fastify-plugin');
|
|
2
2
|
|
|
3
3
|
module.exports = fp(async (fastify, options) => {
|
|
4
|
+
const { authenticate, services } = fastify.account;
|
|
4
5
|
fastify.get(
|
|
5
6
|
`${options.prefix}/admin/getAllTenantList`,
|
|
6
7
|
{
|
|
7
|
-
onRequest: [
|
|
8
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
8
9
|
schema: {
|
|
9
10
|
query: {
|
|
10
11
|
type: 'object',
|
|
@@ -38,7 +39,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
38
39
|
},
|
|
39
40
|
request.query
|
|
40
41
|
);
|
|
41
|
-
return await
|
|
42
|
+
return await services.tenant.getAllTenantList({
|
|
42
43
|
filter: { name },
|
|
43
44
|
perPage,
|
|
44
45
|
currentPage
|
|
@@ -49,7 +50,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
49
50
|
fastify.get(
|
|
50
51
|
`${options.prefix}/admin/getTenantInfo`,
|
|
51
52
|
{
|
|
52
|
-
onRequest: [
|
|
53
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
53
54
|
schema: {
|
|
54
55
|
query: {
|
|
55
56
|
type: 'object',
|
|
@@ -61,243 +62,14 @@ module.exports = fp(async (fastify, options) => {
|
|
|
61
62
|
},
|
|
62
63
|
async request => {
|
|
63
64
|
const { id } = request.query;
|
|
64
|
-
return await
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
fastify.post(
|
|
69
|
-
`${options.prefix}/admin/addTenant`,
|
|
70
|
-
{
|
|
71
|
-
onRequest: [fastify.account.authenticate.user, fastify.account.authenticate.admin],
|
|
72
|
-
schema: {
|
|
73
|
-
body: {
|
|
74
|
-
type: 'object',
|
|
75
|
-
required: ['name', 'accountNumber', 'serviceStartTime', 'serviceEndTime'],
|
|
76
|
-
properties: {
|
|
77
|
-
name: { type: 'string' },
|
|
78
|
-
accountNumber: { type: 'number' },
|
|
79
|
-
serviceStartTime: {
|
|
80
|
-
type: 'string',
|
|
81
|
-
format: 'date-time'
|
|
82
|
-
},
|
|
83
|
-
serviceEndTime: {
|
|
84
|
-
type: 'string',
|
|
85
|
-
format: 'date-time'
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
async request => {
|
|
92
|
-
await fastify.account.services.admin.addTenant(request.body);
|
|
93
|
-
return {};
|
|
94
|
-
}
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
fastify.post(
|
|
98
|
-
`${options.prefix}/admin/saveTenant`,
|
|
99
|
-
{
|
|
100
|
-
onRequest: [fastify.account.authenticate.user, fastify.account.authenticate.admin],
|
|
101
|
-
schema: {
|
|
102
|
-
body: {
|
|
103
|
-
type: 'object',
|
|
104
|
-
required: ['id', 'name', 'accountNumber', 'serviceStartTime', 'serviceEndTime'],
|
|
105
|
-
properties: {
|
|
106
|
-
id: { type: 'string' },
|
|
107
|
-
name: { type: 'string' },
|
|
108
|
-
accountNumber: { type: 'number' },
|
|
109
|
-
serviceStartTime: {
|
|
110
|
-
type: 'string',
|
|
111
|
-
format: 'date-time'
|
|
112
|
-
},
|
|
113
|
-
serviceEndTime: {
|
|
114
|
-
type: 'string',
|
|
115
|
-
format: 'date-time'
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
async request => {
|
|
122
|
-
await fastify.account.services.admin.saveTenant(request.body);
|
|
123
|
-
return {};
|
|
124
|
-
}
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
fastify.post(
|
|
128
|
-
`${options.prefix}/admin/tenant/addOrg`,
|
|
129
|
-
{
|
|
130
|
-
onRequest: [fastify.account.authenticate.user, fastify.account.authenticate.admin],
|
|
131
|
-
required: ['name', 'tenantId', 'pid'],
|
|
132
|
-
properties: {
|
|
133
|
-
name: { type: 'string' },
|
|
134
|
-
tenantId: { type: 'string' },
|
|
135
|
-
pid: { type: 'number' }
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
async request => {
|
|
139
|
-
return await fastify.account.services.tenant.addTenantOrg(request.body);
|
|
140
|
-
}
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
fastify.get(
|
|
144
|
-
`${options.prefix}/admin/tenant/orgList`,
|
|
145
|
-
{
|
|
146
|
-
onRequest: [fastify.account.authenticate.user, fastify.account.authenticate.admin],
|
|
147
|
-
schema: {
|
|
148
|
-
query: {
|
|
149
|
-
type: 'object',
|
|
150
|
-
properties: {
|
|
151
|
-
id: { type: 'string' }
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
async request => {
|
|
157
|
-
const { tenantId } = request.query;
|
|
158
|
-
return await fastify.account.services.tenant.getTenantOrgList({ tenantId });
|
|
159
|
-
}
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
fastify.post(
|
|
163
|
-
`${options.prefix}/admin/tenant/editOrg`,
|
|
164
|
-
{
|
|
165
|
-
onRequest: [fastify.account.authenticate.user, fastify.account.authenticate.admin],
|
|
166
|
-
required: ['name', 'tenantId', 'pid'],
|
|
167
|
-
properties: {
|
|
168
|
-
name: { type: 'string' },
|
|
169
|
-
tenantId: { type: 'string' },
|
|
170
|
-
pid: { type: 'number' }
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
async request => {
|
|
174
|
-
await fastify.account.services.tenant.saveTenantOrg(request.body);
|
|
175
|
-
return {};
|
|
176
|
-
}
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
fastify.post(
|
|
180
|
-
`${options.prefix}/admin/tenant/removeOrg`,
|
|
181
|
-
{
|
|
182
|
-
onRequest: [fastify.account.authenticate.user, fastify.account.authenticate.admin],
|
|
183
|
-
required: ['tenantId', 'id'],
|
|
184
|
-
properties: {
|
|
185
|
-
tenantId: { type: 'string' },
|
|
186
|
-
id: { type: 'number' }
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
async request => {
|
|
190
|
-
await fastify.account.services.tenant.deleteTenantOrg(request.body);
|
|
191
|
-
return {};
|
|
192
|
-
}
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
fastify.get(
|
|
196
|
-
`${options.prefix}/admin/getTenantUserList`,
|
|
197
|
-
{
|
|
198
|
-
onRequest: [fastify.account.authenticate.user, fastify.account.authenticate.admin],
|
|
199
|
-
schema: {
|
|
200
|
-
query: {
|
|
201
|
-
type: 'object',
|
|
202
|
-
properties: {
|
|
203
|
-
tenantId: { type: 'string' }
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
async request => {
|
|
209
|
-
const { tenantId } = request.query;
|
|
210
|
-
return await fastify.account.services.tenant.getTenantUserList({ tenantId });
|
|
211
|
-
}
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
fastify.post(
|
|
215
|
-
`${options.prefix}/admin/addTenantUser`,
|
|
216
|
-
{
|
|
217
|
-
schema: {
|
|
218
|
-
body: {
|
|
219
|
-
type: 'object',
|
|
220
|
-
required: ['tenantId', 'userId', 'name'],
|
|
221
|
-
properties: {
|
|
222
|
-
tenantId: { type: 'string' },
|
|
223
|
-
roleIds: { type: 'array', items: { type: 'number' }, default: [] },
|
|
224
|
-
orgIds: {
|
|
225
|
-
type: 'array',
|
|
226
|
-
items: { type: 'number' },
|
|
227
|
-
default: []
|
|
228
|
-
},
|
|
229
|
-
userId: { type: 'string' },
|
|
230
|
-
name: { type: 'string' },
|
|
231
|
-
avatar: { type: 'string' },
|
|
232
|
-
phone: { type: 'string' },
|
|
233
|
-
email: { type: 'string' },
|
|
234
|
-
description: { type: 'string' }
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
async request => {
|
|
240
|
-
await fastify.account.services.tenant.addTenantUser(request.body);
|
|
241
|
-
return {};
|
|
242
|
-
}
|
|
243
|
-
);
|
|
244
|
-
|
|
245
|
-
fastify.post(
|
|
246
|
-
`${options.prefix}/admin/saveTenantUser`,
|
|
247
|
-
{
|
|
248
|
-
schema: {
|
|
249
|
-
body: {
|
|
250
|
-
type: 'object',
|
|
251
|
-
required: ['tenantId', 'name'],
|
|
252
|
-
properties: {
|
|
253
|
-
tenantId: { type: 'string' },
|
|
254
|
-
roleIds: { type: 'array', items: { type: 'number' }, default: [] },
|
|
255
|
-
orgIds: {
|
|
256
|
-
type: 'array',
|
|
257
|
-
items: { type: 'number' },
|
|
258
|
-
default: []
|
|
259
|
-
},
|
|
260
|
-
name: { type: 'string' },
|
|
261
|
-
avatar: { type: 'string' },
|
|
262
|
-
phone: { type: 'string' },
|
|
263
|
-
email: { type: 'string' },
|
|
264
|
-
description: { type: 'string' }
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
},
|
|
269
|
-
async request => {
|
|
270
|
-
await fastify.account.services.tenant.saveTenantUser(request.body);
|
|
271
|
-
return {};
|
|
272
|
-
}
|
|
273
|
-
);
|
|
274
|
-
|
|
275
|
-
fastify.post(
|
|
276
|
-
`${options.prefix}/admin/deleteTenantUser`,
|
|
277
|
-
{
|
|
278
|
-
onRequest: [fastify.account.authenticate.user, fastify.account.authenticate.admin],
|
|
279
|
-
schema: {
|
|
280
|
-
body: {
|
|
281
|
-
type: 'object',
|
|
282
|
-
required: ['tenantId', 'tenantUserId'],
|
|
283
|
-
properties: {
|
|
284
|
-
tenantId: { type: 'string' },
|
|
285
|
-
tenantUserId: { type: 'string' }
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
|
-
async request => {
|
|
291
|
-
const { tenantId, tenantUserId } = request.body;
|
|
292
|
-
await fastify.account.services.tenant.deleteTenantUser({ tenantId, tenantUserId });
|
|
293
|
-
return {};
|
|
65
|
+
return await services.tenant.getTenant({ id });
|
|
294
66
|
}
|
|
295
67
|
);
|
|
296
68
|
|
|
297
69
|
fastify.post(
|
|
298
70
|
`${options.prefix}/admin/closeTenant`,
|
|
299
71
|
{
|
|
300
|
-
onRequest: [
|
|
72
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
301
73
|
schema: {
|
|
302
74
|
body: {
|
|
303
75
|
type: 'object',
|
|
@@ -310,7 +82,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
310
82
|
},
|
|
311
83
|
async request => {
|
|
312
84
|
const { tenantId } = request.body;
|
|
313
|
-
await
|
|
85
|
+
await services.tenant.closeTenant({ tenantId });
|
|
314
86
|
return {};
|
|
315
87
|
}
|
|
316
88
|
);
|
|
@@ -318,7 +90,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
318
90
|
fastify.post(
|
|
319
91
|
`${options.prefix}/admin/openTenant`,
|
|
320
92
|
{
|
|
321
|
-
onRequest: [
|
|
93
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
322
94
|
schema: {
|
|
323
95
|
body: {
|
|
324
96
|
type: 'object',
|
|
@@ -331,51 +103,66 @@ module.exports = fp(async (fastify, options) => {
|
|
|
331
103
|
},
|
|
332
104
|
async request => {
|
|
333
105
|
const { tenantId } = request.body;
|
|
334
|
-
await
|
|
106
|
+
await services.tenant.openTenant({ tenantId });
|
|
335
107
|
return {};
|
|
336
108
|
}
|
|
337
109
|
);
|
|
338
110
|
|
|
339
111
|
fastify.post(
|
|
340
|
-
`${options.prefix}/admin/
|
|
112
|
+
`${options.prefix}/admin/addTenant`,
|
|
341
113
|
{
|
|
342
|
-
onRequest: [
|
|
114
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
343
115
|
schema: {
|
|
344
116
|
body: {
|
|
345
117
|
type: 'object',
|
|
346
|
-
required: ['
|
|
118
|
+
required: ['name', 'accountNumber', 'serviceStartTime', 'serviceEndTime'],
|
|
347
119
|
properties: {
|
|
348
|
-
|
|
349
|
-
|
|
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'
|
|
129
|
+
}
|
|
350
130
|
}
|
|
351
131
|
}
|
|
352
132
|
}
|
|
353
133
|
},
|
|
354
134
|
async request => {
|
|
355
|
-
|
|
356
|
-
await fastify.account.services.tenant.closeTenantUser({ tenantId, tenantUserId });
|
|
135
|
+
await services.tenant.addTenant(request.body);
|
|
357
136
|
return {};
|
|
358
137
|
}
|
|
359
138
|
);
|
|
360
139
|
|
|
361
140
|
fastify.post(
|
|
362
|
-
`${options.prefix}/admin/
|
|
141
|
+
`${options.prefix}/admin/saveTenant`,
|
|
363
142
|
{
|
|
364
|
-
onRequest: [
|
|
143
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
365
144
|
schema: {
|
|
366
145
|
body: {
|
|
367
146
|
type: 'object',
|
|
368
|
-
required: ['
|
|
147
|
+
required: ['id', 'name', 'accountNumber', 'serviceStartTime', 'serviceEndTime'],
|
|
369
148
|
properties: {
|
|
370
|
-
|
|
371
|
-
|
|
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'
|
|
159
|
+
}
|
|
372
160
|
}
|
|
373
161
|
}
|
|
374
162
|
}
|
|
375
163
|
},
|
|
376
164
|
async request => {
|
|
377
|
-
|
|
378
|
-
await fastify.account.services.tenant.openTenantUser({ tenantId, tenantUserId });
|
|
165
|
+
await services.tenant.saveTenant(request.body);
|
|
379
166
|
return {};
|
|
380
167
|
}
|
|
381
168
|
);
|
|
@@ -383,7 +170,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
383
170
|
fastify.get(
|
|
384
171
|
`${options.prefix}/admin/getInviteList`,
|
|
385
172
|
{
|
|
386
|
-
onRequest: [
|
|
173
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
387
174
|
schema: {
|
|
388
175
|
query: {
|
|
389
176
|
type: 'object',
|
|
@@ -403,14 +190,14 @@ module.exports = fp(async (fastify, options) => {
|
|
|
403
190
|
request.query
|
|
404
191
|
);
|
|
405
192
|
|
|
406
|
-
return await
|
|
193
|
+
return await services.tenantInvite.getInviteList({ filter, perPage, currentPage, tenantId });
|
|
407
194
|
}
|
|
408
195
|
);
|
|
409
196
|
|
|
410
197
|
fastify.post(
|
|
411
198
|
`${options.prefix}/admin/addInviteToken`,
|
|
412
199
|
{
|
|
413
|
-
onRequest: [
|
|
200
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
414
201
|
schema: {
|
|
415
202
|
body: {
|
|
416
203
|
type: 'object',
|
|
@@ -434,7 +221,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
434
221
|
},
|
|
435
222
|
async request => {
|
|
436
223
|
const { tenantId, info } = request.body;
|
|
437
|
-
await
|
|
224
|
+
await services.tenantInvite.addInviteToken({ tenantId, info });
|
|
438
225
|
return {};
|
|
439
226
|
}
|
|
440
227
|
);
|
|
@@ -442,7 +229,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
442
229
|
fastify.post(
|
|
443
230
|
`${options.prefix}/admin/deleteInviteToken`,
|
|
444
231
|
{
|
|
445
|
-
onRequest: [
|
|
232
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
446
233
|
schema: {
|
|
447
234
|
body: {
|
|
448
235
|
type: 'object',
|
|
@@ -454,7 +241,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
454
241
|
}
|
|
455
242
|
},
|
|
456
243
|
async request => {
|
|
457
|
-
await
|
|
244
|
+
await services.tenantInvite.deleteInviteToken({ id: request.body.id });
|
|
458
245
|
return {};
|
|
459
246
|
}
|
|
460
247
|
);
|
|
@@ -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,71 @@
|
|
|
1
|
+
const fp = require('fastify-plugin');
|
|
2
|
+
|
|
3
|
+
module.exports = fp(async (fastify, options) => {
|
|
4
|
+
const { authenticate, services } = fastify.account;
|
|
5
|
+
fastify.post(
|
|
6
|
+
`${options.prefix}/admin/tenant/addOrg`,
|
|
7
|
+
{
|
|
8
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
9
|
+
required: ['name', 'tenantId', 'pid'],
|
|
10
|
+
properties: {
|
|
11
|
+
name: { type: 'string' },
|
|
12
|
+
tenantId: { type: 'string' },
|
|
13
|
+
pid: { type: 'number' }
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
async request => {
|
|
17
|
+
return await services.tenantOrg.addTenantOrg(request.body);
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
fastify.get(
|
|
22
|
+
`${options.prefix}/admin/tenant/orgList`,
|
|
23
|
+
{
|
|
24
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
25
|
+
schema: {
|
|
26
|
+
query: {
|
|
27
|
+
type: 'object',
|
|
28
|
+
properties: {
|
|
29
|
+
id: { type: 'string' }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
async request => {
|
|
35
|
+
const { tenantId } = request.query;
|
|
36
|
+
return await services.tenantOrg.getTenantOrgList({ tenantId });
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
fastify.post(
|
|
41
|
+
`${options.prefix}/admin/tenant/editOrg`,
|
|
42
|
+
{
|
|
43
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
44
|
+
required: ['name', 'tenantId', 'pid'],
|
|
45
|
+
properties: {
|
|
46
|
+
name: { type: 'string' },
|
|
47
|
+
tenantId: { type: 'string' },
|
|
48
|
+
pid: { type: 'number' }
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
async request => {
|
|
52
|
+
await services.tenantOrg.saveTenantOrg(request.body);
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
fastify.post(
|
|
58
|
+
`${options.prefix}/admin/tenant/removeOrg`,
|
|
59
|
+
{
|
|
60
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
61
|
+
required: ['id'],
|
|
62
|
+
properties: {
|
|
63
|
+
id: { type: 'number' }
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
async request => {
|
|
67
|
+
await services.tenantOrg.deleteTenantOrg(request.body);
|
|
68
|
+
return {};
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
});
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
const fp = require('fastify-plugin');
|
|
2
2
|
|
|
3
3
|
module.exports = fp(async (fastify, options) => {
|
|
4
|
+
const { authenticate, services } = fastify.account;
|
|
4
5
|
fastify.get(
|
|
5
6
|
`${options.prefix}/admin/getRoleList`,
|
|
6
7
|
{
|
|
7
|
-
onRequest: [
|
|
8
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
8
9
|
schema: {
|
|
9
10
|
query: {
|
|
10
11
|
type: 'object',
|
|
11
12
|
required: ['tenantId'],
|
|
12
13
|
properties: {
|
|
13
14
|
tenantId: { type: 'string' },
|
|
15
|
+
perPage: { type: 'number' },
|
|
16
|
+
currentPage: { type: 'number' },
|
|
14
17
|
filter: {
|
|
15
18
|
type: 'object',
|
|
16
19
|
properties: {
|
|
@@ -30,14 +33,14 @@ module.exports = fp(async (fastify, options) => {
|
|
|
30
33
|
},
|
|
31
34
|
request.query
|
|
32
35
|
);
|
|
33
|
-
return await
|
|
36
|
+
return await services.tenantRole.getTenantRoleList({ tenantId, perPage, currentPage, filter });
|
|
34
37
|
}
|
|
35
38
|
);
|
|
36
39
|
|
|
37
40
|
fastify.post(
|
|
38
41
|
`${options.prefix}/admin/addRole`,
|
|
39
42
|
{
|
|
40
|
-
onRequest: [
|
|
43
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
41
44
|
schema: {
|
|
42
45
|
body: {
|
|
43
46
|
type: 'object',
|
|
@@ -52,7 +55,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
52
55
|
},
|
|
53
56
|
async request => {
|
|
54
57
|
const { tenantId, name, description } = request.body;
|
|
55
|
-
await
|
|
58
|
+
await services.tenantRole.addTenantRole({ tenantId, name, description });
|
|
56
59
|
|
|
57
60
|
return {};
|
|
58
61
|
}
|
|
@@ -61,7 +64,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
61
64
|
fastify.post(
|
|
62
65
|
`${options.prefix}/admin/saveRole`,
|
|
63
66
|
{
|
|
64
|
-
onRequest: [
|
|
67
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
65
68
|
schema: {
|
|
66
69
|
body: {
|
|
67
70
|
type: 'object',
|
|
@@ -75,7 +78,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
75
78
|
}
|
|
76
79
|
},
|
|
77
80
|
async request => {
|
|
78
|
-
await
|
|
81
|
+
await services.tenantRole.saveTenantRole(request.body);
|
|
79
82
|
return {};
|
|
80
83
|
}
|
|
81
84
|
);
|
|
@@ -83,7 +86,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
83
86
|
fastify.post(
|
|
84
87
|
`${options.prefix}/admin/removeRole`,
|
|
85
88
|
{
|
|
86
|
-
onRequest: [
|
|
89
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
87
90
|
schema: {
|
|
88
91
|
body: {
|
|
89
92
|
type: 'object',
|
|
@@ -96,7 +99,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
96
99
|
},
|
|
97
100
|
async request => {
|
|
98
101
|
const { id } = request.body;
|
|
99
|
-
await
|
|
102
|
+
await services.tenantRole.removeTenantRole({ id });
|
|
100
103
|
return {};
|
|
101
104
|
}
|
|
102
105
|
);
|
|
@@ -104,7 +107,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
104
107
|
fastify.get(
|
|
105
108
|
`${options.prefix}/admin/getRolePermissionList`,
|
|
106
109
|
{
|
|
107
|
-
onRequest: [
|
|
110
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
108
111
|
schema: {
|
|
109
112
|
query: {
|
|
110
113
|
type: 'object',
|
|
@@ -117,14 +120,14 @@ module.exports = fp(async (fastify, options) => {
|
|
|
117
120
|
},
|
|
118
121
|
async request => {
|
|
119
122
|
const { id } = request.query;
|
|
120
|
-
return await
|
|
123
|
+
return await services.permission.getRolePermissionList({ roleId: id });
|
|
121
124
|
}
|
|
122
125
|
);
|
|
123
126
|
|
|
124
127
|
fastify.post(
|
|
125
128
|
`${options.prefix}/admin/saveRolePermissionList`,
|
|
126
129
|
{
|
|
127
|
-
onRequest: [
|
|
130
|
+
onRequest: [authenticate.user, authenticate.admin],
|
|
128
131
|
schema: {
|
|
129
132
|
roleId: { type: 'string' },
|
|
130
133
|
applications: {
|
|
@@ -138,7 +141,7 @@ module.exports = fp(async (fastify, options) => {
|
|
|
138
141
|
}
|
|
139
142
|
},
|
|
140
143
|
async request => {
|
|
141
|
-
await
|
|
144
|
+
await services.permission.saveRolePermissionList(request.body);
|
|
142
145
|
return {};
|
|
143
146
|
}
|
|
144
147
|
);
|