|
@@ -31,6 +31,13 @@ func RoleAPIControllerRegistRouters() {
|
31
|
31
|
|
32
|
32
|
beego.Router("/api/admin/specialpermission/initdata", &RoleAPIController{}, "get:SpecialPermissionInitData")
|
33
|
33
|
beego.Router("/api/admin/specialpermission/dialysisrecord/submit", &RoleAPIController{}, "post:SubmitDialysisRecordPermission")
|
|
34
|
+
|
|
35
|
+ beego.Router("/api/roles/list", &RoleAPIController{}, "get:GetAllOrgRole")
|
|
36
|
+ beego.Router("/api/staff", &RoleAPIController{}, "get:GetAllOrgUser")
|
|
37
|
+ beego.Router("/api/role/addStaff", &RoleAPIController{}, "post:AddRoleStaff")
|
|
38
|
+
|
|
39
|
+ beego.Router("/api/role/staff", &RoleAPIController{}, "get:GetRoleStaff")
|
|
40
|
+
|
34
|
41
|
}
|
35
|
42
|
|
36
|
43
|
type RoleAPIController struct {
|
|
@@ -43,15 +50,14 @@ func (this *RoleAPIController) GetRoles() {
|
43
|
50
|
page, _ := this.GetInt("page")
|
44
|
51
|
adminUserInfo := this.GetAdminUserInfo()
|
45
|
52
|
|
46
|
|
- if adminUserInfo.AdminUser.IsSuperAdmin == false {
|
47
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
|
48
|
|
- return
|
49
|
|
- }
|
50
|
|
-
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
51
|
57
|
if page <= 0 {
|
52
|
58
|
page = 1
|
53
|
59
|
}
|
54
|
|
- roles, total, getRoleErr := service.GetRoles(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, page, 10)
|
|
60
|
+ roles, total, getRoleErr := service.GetRoles(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, page, 100)
|
55
|
61
|
if getRoleErr != nil {
|
56
|
62
|
|
57
|
63
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
@@ -74,11 +80,16 @@ func (this *RoleAPIController) CreateRole() {
|
74
|
80
|
return
|
75
|
81
|
}
|
76
|
82
|
adminUserInfo := this.GetAdminUserInfo()
|
77
|
|
- if adminUserInfo.AdminUser.IsSuperAdmin == false {
|
78
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+ total := service.FindRoleRecordByRoleName(name, adminUserInfo.CurrentOrgId)
|
|
89
|
+ if total > 0 {
|
|
90
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRoleNameIsExist)
|
79
|
91
|
return
|
80
|
92
|
}
|
81
|
|
-
|
82
|
93
|
role, createErr := service.CreateRole(adminUserInfo.AdminUser.Id, adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, name, intro)
|
83
|
94
|
if createErr != nil {
|
84
|
95
|
|
|
@@ -105,11 +116,11 @@ func (this *RoleAPIController) ModifyRole() {
|
105
|
116
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
106
|
117
|
return
|
107
|
118
|
}
|
108
|
|
- adminUserInfo := this.GetAdminUserInfo()
|
109
|
|
- if adminUserInfo.AdminUser.IsSuperAdmin == false {
|
110
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
|
111
|
|
- return
|
112
|
|
- }
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
113
|
124
|
|
114
|
125
|
role, getRoleErr := service.GetRoleByRoleID(roleID)
|
115
|
126
|
if getRoleErr != nil {
|
|
@@ -145,10 +156,10 @@ func (this *RoleAPIController) ModifyRoleStatus() {
|
145
|
156
|
}
|
146
|
157
|
|
147
|
158
|
adminUserInfo := this.GetAdminUserInfo()
|
148
|
|
- if adminUserInfo.AdminUser.IsSuperAdmin == false {
|
149
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
|
150
|
|
- return
|
151
|
|
- }
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
152
|
163
|
|
153
|
164
|
role, getRoleErr := service.GetRoleByRoleID(roleID)
|
154
|
165
|
if getRoleErr != nil {
|
|
@@ -185,11 +196,11 @@ func (this *RoleAPIController) ModifyRoleStatus() {
|
185
|
196
|
|
186
|
197
|
|
187
|
198
|
func (this *RoleAPIController) EditPurviewInitData() {
|
188
|
|
- adminUserInfo := this.GetAdminUserInfo()
|
189
|
|
- if adminUserInfo.AdminUser.IsSuperAdmin == false {
|
190
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
|
191
|
|
- return
|
192
|
|
- }
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
193
|
204
|
|
194
|
205
|
roleId, _ := this.GetInt64("role_id")
|
195
|
206
|
if roleId <= 0 {
|
|
@@ -220,10 +231,10 @@ func (this *RoleAPIController) EditPurviewInitData() {
|
220
|
231
|
|
221
|
232
|
func (this *RoleAPIController) EditPurview() {
|
222
|
233
|
adminUserInfo := this.GetAdminUserInfo()
|
223
|
|
- if adminUserInfo.AdminUser.IsSuperAdmin == false {
|
224
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
|
225
|
|
- return
|
226
|
|
- }
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
227
|
238
|
roleId, _ := this.GetInt64("role_id")
|
228
|
239
|
purviewIds := this.GetString("purview_ids")
|
229
|
240
|
if roleId <= 0 {
|
|
@@ -275,24 +286,38 @@ func (this *RoleAPIController) EditPurview() {
|
275
|
286
|
|
276
|
287
|
func (this *RoleAPIController) AdminMainView() {
|
277
|
288
|
adminUserInfo := this.GetAdminUserInfo()
|
278
|
|
- if adminUserInfo.AdminUser.IsSuperAdmin == false {
|
279
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
|
280
|
|
- return
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+ var isSubSuperAdmin bool = false
|
|
293
|
+ adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+ role_ids := strings.Split(adminUserRole.RoleIds, ",")
|
|
297
|
+
|
|
298
|
+ org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
|
|
299
|
+
|
|
300
|
+ if adminUserInfo.AdminUser.Id != org.Creator {
|
|
301
|
+ for _, item := range role_ids {
|
|
302
|
+ id, _ := strconv.ParseInt(item, 10, 64)
|
|
303
|
+ role, _ := service.GetRoleByRoleID(id)
|
|
304
|
+ if role.IsSystem == 1 && role.RoleName == "子管理员" {
|
|
305
|
+ isSubSuperAdmin = true
|
|
306
|
+ }
|
|
307
|
+ }
|
281
|
308
|
}
|
282
|
309
|
|
283
|
|
- viewModels, total, getAdminsErr := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 10)
|
|
310
|
+ viewModels, _, getAdminsErr := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 100)
|
284
|
311
|
if getAdminsErr != nil {
|
285
|
312
|
|
286
|
313
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
287
|
314
|
return
|
288
|
315
|
}
|
289
|
316
|
|
290
|
|
- existRoleCount, _ := service.GetValidRoleCount(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
|
291
|
|
-
|
292
|
317
|
this.ServeSuccessJSON(map[string]interface{}{
|
293
|
|
- "admins": viewModels,
|
294
|
|
- "total_count": total,
|
295
|
|
- "is_exist_role": existRoleCount > 0,
|
|
318
|
+ "admins": viewModels,
|
|
319
|
+ "org": org,
|
|
320
|
+ "isSubSuperAdmin": isSubSuperAdmin,
|
296
|
321
|
})
|
297
|
322
|
}
|
298
|
323
|
|
|
@@ -300,13 +325,13 @@ func (this *RoleAPIController) AdminMainView() {
|
300
|
325
|
|
301
|
326
|
func (this *RoleAPIController) Admins() {
|
302
|
327
|
adminUserInfo := this.GetAdminUserInfo()
|
303
|
|
- if adminUserInfo.AdminUser.IsSuperAdmin == false {
|
304
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
|
305
|
|
- return
|
306
|
|
- }
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
307
|
332
|
|
308
|
333
|
page, _ := this.GetInt("page")
|
309
|
|
- viewModels, total, getAdminsErr := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, page, 10)
|
|
334
|
+ viewModels, total, getAdminsErr := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, page, 100)
|
310
|
335
|
if getAdminsErr != nil {
|
311
|
336
|
|
312
|
337
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
@@ -321,9 +346,27 @@ func (this *RoleAPIController) Admins() {
|
321
|
346
|
|
322
|
347
|
func (this *RoleAPIController) AddAdminInitData() {
|
323
|
348
|
adminUserInfo := this.GetAdminUserInfo()
|
324
|
|
- if adminUserInfo.AdminUser.IsSuperAdmin == false {
|
325
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
|
326
|
|
- return
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+ var isSubSuperAdmin bool = false
|
|
355
|
+ adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+ role_ids := strings.Split(adminUserRole.RoleIds, ",")
|
|
359
|
+
|
|
360
|
+ org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
|
|
361
|
+
|
|
362
|
+ if adminUserInfo.AdminUser.Id != org.Creator {
|
|
363
|
+ for _, item := range role_ids {
|
|
364
|
+ id, _ := strconv.ParseInt(item, 10, 64)
|
|
365
|
+ role, _ := service.GetRoleByRoleID(id)
|
|
366
|
+ if role.IsSystem == 1 && role.RoleName == "子管理员" {
|
|
367
|
+ isSubSuperAdmin = true
|
|
368
|
+ }
|
|
369
|
+ }
|
327
|
370
|
}
|
328
|
371
|
|
329
|
372
|
roles, getRoleErr := service.GetAllValidRoles(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
|
|
@@ -338,8 +381,10 @@ func (this *RoleAPIController) AddAdminInitData() {
|
338
|
381
|
qntoken, _ := redisClient.Get("qn_token").Result()
|
339
|
382
|
|
340
|
383
|
this.ServeSuccessJSON(map[string]interface{}{
|
341
|
|
- "roles": roles,
|
342
|
|
- "qntoken": qntoken,
|
|
384
|
+ "roles": roles,
|
|
385
|
+ "qntoken": qntoken,
|
|
386
|
+ "isSubSuperAdmin": isSubSuperAdmin,
|
|
387
|
+ "org": org,
|
343
|
388
|
})
|
344
|
389
|
}
|
345
|
390
|
|
|
@@ -352,85 +397,85 @@ func (this *RoleAPIController) AddAdminInitData() {
|
352
|
397
|
|
353
|
398
|
func (this *RoleAPIController) AddAdmin() {
|
354
|
399
|
adminUserInfo := this.GetAdminUserInfo()
|
355
|
|
- if adminUserInfo.AdminUser.IsSuperAdmin == false {
|
356
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
|
357
|
|
- return
|
358
|
|
- }
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
|
359
|
404
|
|
360
|
405
|
mobile := this.GetString("mobile")
|
361
|
406
|
name := this.GetString("name")
|
362
|
407
|
userType, _ := this.GetInt("type")
|
363
|
408
|
userTitle, _ := this.GetInt("title")
|
364
|
|
- roleId, _ := this.GetInt64("role")
|
365
|
|
-
|
|
409
|
+ roleIds := this.GetString("role")
|
|
410
|
+ user_title_name := this.GetString("user_title_name")
|
366
|
411
|
|
367
|
|
- _, titleExist := models.UserTitle[userTitle]
|
368
|
|
- if len(mobile) == 0 || len(name) == 0 || (userType != 2 && userType != 3 && userType != 4) || !titleExist || roleId <= 0 {
|
|
412
|
+ if len(mobile) == 0 || len(name) == 0 || (userType != 2 && userType != 3 && userType != 4) || len(roleIds) <= 0 {
|
369
|
413
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
370
|
414
|
return
|
371
|
415
|
}
|
372
|
416
|
|
373
|
|
- isRoleExist, getRoleErr := service.IsRoleExist(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, roleId)
|
374
|
|
- if getRoleErr != nil {
|
375
|
|
-
|
376
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
377
|
|
- return
|
378
|
|
- }
|
379
|
|
- if !isRoleExist {
|
380
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRoleNotExist)
|
381
|
|
- return
|
382
|
|
- }
|
383
|
|
-
|
384
|
|
-
|
385
|
|
- if isMobileDidUsed, err := service.IsMobileDidUsedAtApp(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, mobile); err != nil {
|
|
417
|
+
|
|
418
|
+ if adminUser, err := service.GetValidAdminUserByMobileReturnErr(mobile); err != nil {
|
386
|
419
|
|
387
|
420
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
388
|
421
|
return
|
389
|
422
|
} else {
|
390
|
|
- if isMobileDidUsed {
|
391
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMobileDidUsedInApp)
|
392
|
|
- return
|
393
|
|
- }
|
394
|
|
- }
|
|
423
|
+ if adminUser == nil {
|
|
424
|
+ _, password, createErr := service.CreateGeneralAdminUser(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, mobile, name, user_title_name, roleIds, userType, userTitle)
|
|
425
|
+ if createErr != nil {
|
|
426
|
+
|
|
427
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
|
|
428
|
+ return
|
|
429
|
+
|
|
430
|
+ } else {
|
|
431
|
+ sendSMSErr := service.SMSSendInviteMobileToJoinOrgAdmin(name, mobile, password)
|
|
432
|
+ if sendSMSErr != nil {
|
|
433
|
+ }
|
|
434
|
+
|
|
435
|
+ this.ServeSuccessJSON(nil)
|
|
436
|
+ return
|
|
437
|
+ }
|
|
438
|
+ } else {
|
|
439
|
+
|
|
440
|
+ total, _ := service.FindAdminUserByID(adminUser.Id, adminUserInfo.CurrentOrgId)
|
|
441
|
+
|
|
442
|
+ if total <= 0 {
|
|
443
|
+
|
|
444
|
+ app_role := &models.App_Role{
|
|
445
|
+ AdminUserId: adminUser.Id,
|
|
446
|
+ OrgId: adminUserInfo.CurrentOrgId,
|
|
447
|
+ AppId: adminUserInfo.CurrentAppId,
|
|
448
|
+ Avatar: "",
|
|
449
|
+ UserName: name,
|
|
450
|
+ UserTitleName: user_title_name,
|
|
451
|
+ Status: 1,
|
|
452
|
+ UserType: int8(userType),
|
|
453
|
+ UserTitle: int8(userTitle),
|
|
454
|
+ CreateTime: time.Now().Unix(),
|
|
455
|
+ ModifyTime: time.Now().Unix(),
|
|
456
|
+ RoleIds: roleIds,
|
|
457
|
+ }
|
|
458
|
+ err := service.CreateUserRole(app_role)
|
|
459
|
+ if err != nil {
|
|
460
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
|
|
461
|
+ return
|
|
462
|
+ }
|
|
463
|
+ this.ServeSuccessJSON(nil)
|
|
464
|
+ } else {
|
|
465
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRepeatCreateStaffException)
|
|
466
|
+ return
|
|
467
|
+ }
|
395
|
468
|
|
396
|
|
- if isSuperAdmin, err := service.IsUserSuperAdminWithMobile(mobile); err != nil {
|
397
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMobileNotExit)
|
398
|
|
- return
|
399
|
|
- } else {
|
400
|
|
- if isSuperAdmin {
|
401
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRoleMobileIsSuperAdmin)
|
402
|
469
|
return
|
403
|
470
|
}
|
404
|
471
|
}
|
405
|
472
|
|
406
|
|
-
|
407
|
|
-
|
408
|
|
-
|
409
|
|
-
|
410
|
|
-
|
411
|
|
-
|
412
|
|
-
|
413
|
|
-
|
414
|
|
-
|
415
|
|
-
|
416
|
|
-
|
417
|
|
-
|
418
|
|
-
|
419
|
|
-
|
420
|
|
-
|
421
|
|
-
|
422
|
|
-
|
423
|
|
-
|
424
|
473
|
}
|
425
|
474
|
|
426
|
475
|
|
427
|
476
|
|
428
|
477
|
func (this *RoleAPIController) EditAdminInitData() {
|
429
|
478
|
adminUserInfo := this.GetAdminUserInfo()
|
430
|
|
- if adminUserInfo.AdminUser.IsSuperAdmin == false {
|
431
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
|
432
|
|
- return
|
433
|
|
- }
|
434
|
479
|
|
435
|
480
|
admin_user_id, _ := this.GetInt64("uid")
|
436
|
481
|
if admin_user_id <= 0 {
|
|
@@ -438,13 +483,13 @@ func (this *RoleAPIController) EditAdminInitData() {
|
438
|
483
|
return
|
439
|
484
|
}
|
440
|
485
|
|
441
|
|
- adminUserViewModel, getInfoErr := service.GetGeneralAdminUser(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, admin_user_id)
|
442
|
|
- if getInfoErr != nil {
|
443
|
|
-
|
|
486
|
+ appRole, getAppRoleErr := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, admin_user_id)
|
|
487
|
+ if getAppRoleErr != nil {
|
|
488
|
+
|
444
|
489
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
445
|
490
|
return
|
446
|
491
|
}
|
447
|
|
- if adminUserViewModel == nil {
|
|
492
|
+ if appRole == nil {
|
448
|
493
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserNotExist)
|
449
|
494
|
return
|
450
|
495
|
}
|
|
@@ -456,14 +501,33 @@ func (this *RoleAPIController) EditAdminInitData() {
|
456
|
501
|
return
|
457
|
502
|
}
|
458
|
503
|
|
|
504
|
+ var isSubSuperAdmin bool = false
|
|
505
|
+ adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+ role_ids := strings.Split(adminUserRole.RoleIds, ",")
|
|
509
|
+
|
|
510
|
+ org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
|
|
511
|
+
|
|
512
|
+ if adminUserInfo.AdminUser.Id != org.Creator {
|
|
513
|
+ for _, item := range role_ids {
|
|
514
|
+ id, _ := strconv.ParseInt(item, 10, 64)
|
|
515
|
+ role, _ := service.GetRoleByRoleID(id)
|
|
516
|
+ if role.IsSystem == 1 && role.RoleName == "子管理员" {
|
|
517
|
+ isSubSuperAdmin = true
|
|
518
|
+ }
|
|
519
|
+ }
|
|
520
|
+ }
|
|
521
|
+
|
459
|
522
|
redisClient := service.RedisClient()
|
460
|
523
|
defer redisClient.Close()
|
461
|
524
|
qntoken, _ := redisClient.Get("qn_token").Result()
|
462
|
525
|
|
463
|
526
|
this.ServeSuccessJSON(map[string]interface{}{
|
464
|
|
- "admin": adminUserViewModel,
|
465
|
|
- "roles": roles,
|
466
|
|
- "qntoken": qntoken,
|
|
527
|
+ "admin": appRole,
|
|
528
|
+ "roles": roles,
|
|
529
|
+ "qntoken": qntoken,
|
|
530
|
+ "isSubSuperAdmin": isSubSuperAdmin,
|
467
|
531
|
})
|
468
|
532
|
}
|
469
|
533
|
|
|
@@ -476,20 +540,21 @@ func (this *RoleAPIController) EditAdminInitData() {
|
476
|
540
|
|
477
|
541
|
func (this *RoleAPIController) EditAdmin() {
|
478
|
542
|
adminUserInfo := this.GetAdminUserInfo()
|
479
|
|
- if adminUserInfo.AdminUser.IsSuperAdmin == false {
|
480
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
|
481
|
|
- return
|
482
|
|
- }
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
483
|
547
|
|
484
|
548
|
adminUserId, _ := this.GetInt64("uid")
|
485
|
549
|
name := this.GetString("name")
|
486
|
550
|
userType, _ := this.GetInt("type")
|
487
|
551
|
userTitle, _ := this.GetInt("title")
|
488
|
|
- roleId, _ := this.GetInt64("role")
|
|
552
|
+ roleIds := this.GetString("role")
|
489
|
553
|
intro := this.GetString("intro")
|
|
554
|
+ user_title_name := this.GetString("user_title_name")
|
490
|
555
|
|
491
|
556
|
_, titleExist := models.UserTitle[userTitle]
|
492
|
|
- if adminUserId <= 0 || len(name) == 0 || (userType != 2 && userType != 3 && userType != 4) || !titleExist || roleId <= 0 {
|
|
557
|
+ if adminUserId <= 0 || len(name) == 0 || (userType != 2 && userType != 3 && userType != 4) || !titleExist || len(roleIds) <= 0 {
|
493
|
558
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
494
|
559
|
return
|
495
|
560
|
}
|
|
@@ -505,22 +570,12 @@ func (this *RoleAPIController) EditAdmin() {
|
505
|
570
|
return
|
506
|
571
|
}
|
507
|
572
|
|
508
|
|
- isRoleExist, getRoleErr := service.IsRoleExist(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, roleId)
|
509
|
|
- if getRoleErr != nil {
|
510
|
|
-
|
511
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
512
|
|
- return
|
513
|
|
- }
|
514
|
|
- if !isRoleExist {
|
515
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRoleNotExist)
|
516
|
|
- return
|
517
|
|
- }
|
518
|
|
-
|
519
|
573
|
appRole.UserName = name
|
520
|
574
|
appRole.UserType = int8(userType)
|
521
|
575
|
appRole.UserTitle = int8(userTitle)
|
522
|
|
- appRole.RoleId = roleId
|
|
576
|
+ appRole.RoleIds = roleIds
|
523
|
577
|
appRole.Intro = intro
|
|
578
|
+ appRole.UserTitleName = user_title_name
|
524
|
579
|
appRole.ModifyTime = time.Now().Unix()
|
525
|
580
|
saveErr := service.SaveAppRole(appRole)
|
526
|
581
|
if saveErr != nil {
|
|
@@ -537,10 +592,10 @@ func (this *RoleAPIController) EditAdmin() {
|
537
|
592
|
|
538
|
593
|
func (this *RoleAPIController) AdminSetStatus() {
|
539
|
594
|
adminUserInfo := this.GetAdminUserInfo()
|
540
|
|
- if adminUserInfo.AdminUser.IsSuperAdmin == false {
|
541
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
|
542
|
|
- return
|
543
|
|
- }
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
|
544
|
599
|
|
545
|
600
|
userID, _ := this.GetInt64("uid")
|
546
|
601
|
if userID <= 0 {
|
|
@@ -558,12 +613,6 @@ func (this *RoleAPIController) AdminSetStatus() {
|
558
|
613
|
}
|
559
|
614
|
|
560
|
615
|
enable, _ := this.GetBool("enable")
|
561
|
|
- if enable == true {
|
562
|
|
- if roleEnable, _ := service.IsRoleExist(appRole.OrgId, appRole.AppId, appRole.RoleId); roleEnable == false {
|
563
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRoleNotExist)
|
564
|
|
- return
|
565
|
|
- }
|
566
|
|
- }
|
567
|
616
|
|
568
|
617
|
if enable {
|
569
|
618
|
appRole.Status = 1
|
|
@@ -584,10 +633,10 @@ func (this *RoleAPIController) AdminSetStatus() {
|
584
|
633
|
|
585
|
634
|
func (this *RoleAPIController) SpecialPermissionInitData() {
|
586
|
635
|
adminUserInfo := this.GetAdminUserInfo()
|
587
|
|
- if adminUserInfo.AdminUser.IsSuperAdmin == false {
|
588
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
|
589
|
|
- return
|
590
|
|
- }
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
|
591
|
640
|
|
592
|
641
|
adminUsers, getAdminUsersErr := service.GetAllGeneralAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
|
593
|
642
|
if getAdminUsersErr != nil {
|
|
@@ -613,10 +662,10 @@ func (this *RoleAPIController) SpecialPermissionInitData() {
|
613
|
662
|
|
614
|
663
|
func (this *RoleAPIController) SubmitDialysisRecordPermission() {
|
615
|
664
|
adminUserInfo := this.GetAdminUserInfo()
|
616
|
|
- if adminUserInfo.AdminUser.IsSuperAdmin == false {
|
617
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
|
618
|
|
- return
|
619
|
|
- }
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
|
620
|
669
|
|
621
|
670
|
idsString := this.GetString("ids")
|
622
|
671
|
if len(idsString) == 0 {
|
|
@@ -712,3 +761,81 @@ func (this *RoleAPIController) SubmitDialysisRecordPermission() {
|
712
|
761
|
}
|
713
|
762
|
|
714
|
763
|
}
|
|
764
|
+
|
|
765
|
+func (this *RoleAPIController) GetAllOrgRole() {
|
|
766
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
767
|
+
|
|
768
|
+ var isSubSuperAdmin bool = false
|
|
769
|
+ adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+ role_ids := strings.Split(adminUserRole.RoleIds, ",")
|
|
773
|
+
|
|
774
|
+ org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
|
|
775
|
+
|
|
776
|
+ if adminUserInfo.AdminUser.Id != org.Creator {
|
|
777
|
+ for _, item := range role_ids {
|
|
778
|
+ id, _ := strconv.ParseInt(item, 10, 64)
|
|
779
|
+ role, _ := service.GetRoleByRoleID(id)
|
|
780
|
+ if role.IsSystem == 1 && role.RoleName == "子管理员" {
|
|
781
|
+ isSubSuperAdmin = true
|
|
782
|
+ }
|
|
783
|
+ }
|
|
784
|
+ }
|
|
785
|
+
|
|
786
|
+ roles, err := service.GetAllOrgValidRoles(adminUserInfo.CurrentOrgId, isSubSuperAdmin)
|
|
787
|
+ if err != nil {
|
|
788
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
789
|
+ return
|
|
790
|
+ } else {
|
|
791
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
792
|
+ "roles": roles,
|
|
793
|
+ })
|
|
794
|
+ }
|
|
795
|
+
|
|
796
|
+}
|
|
797
|
+
|
|
798
|
+func (this *RoleAPIController) GetAllOrgUser() {
|
|
799
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
800
|
+ org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
|
|
801
|
+ viewModels, _, _ := service.GetAllAdminUsersAndRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 100)
|
|
802
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
803
|
+ "admins": viewModels,
|
|
804
|
+ "org": org,
|
|
805
|
+ })
|
|
806
|
+}
|
|
807
|
+
|
|
808
|
+func (this *RoleAPIController) AddRoleStaff() {
|
|
809
|
+
|
|
810
|
+ role_id, _ := this.GetInt64("id", 0)
|
|
811
|
+ staff_ids := this.GetString("ids")
|
|
812
|
+ ids := strings.Split(staff_ids, ",")
|
|
813
|
+ for _, item := range ids {
|
|
814
|
+ id, _ := strconv.ParseInt(item, 10, 64)
|
|
815
|
+ role, _ := service.FindAdminUserID(id)
|
|
816
|
+ role.RoleIds = role.RoleIds + "," + strconv.FormatInt(role_id, 10)
|
|
817
|
+ service.SaveAdminUser(&role)
|
|
818
|
+ }
|
|
819
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
820
|
+ "msg": "添加成功",
|
|
821
|
+ })
|
|
822
|
+
|
|
823
|
+}
|
|
824
|
+
|
|
825
|
+func (this *RoleAPIController) GetRoleStaff() {
|
|
826
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
827
|
+
|
|
828
|
+ viewModels, _, getAdminsErr := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 100)
|
|
829
|
+ if getAdminsErr != nil {
|
|
830
|
+
|
|
831
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
832
|
+ return
|
|
833
|
+ }
|
|
834
|
+ org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
|
|
835
|
+
|
|
836
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
837
|
+ "admins": viewModels,
|
|
838
|
+ "org": org,
|
|
839
|
+ })
|
|
840
|
+
|
|
841
|
+}
|