Browse Source

修复登录 app 优先级选择的 bug

庄逸洲 5 years ago
parent
commit
ae4c2522d8
3 changed files with 13 additions and 12 deletions
  1. 8 8
      controllers/verify_token_controller.go
  2. 1 1
      service/login_service.go
  3. 4 3
      service/org_service.go

+ 8 - 8
controllers/verify_token_controller.go View File

416
 
416
 
417
 	// 自动创建所有应用
417
 	// 自动创建所有应用
418
 	didCreateNew := false
418
 	didCreateNew := false
419
-	if did_patient_manage_create == false {
420
-		err := service.CreateOrgApp(adminUserID, orgID, 1, false)
421
-		if err != nil {
422
-			utils.ErrorLog("自动创建酷医聚客应用失败:%v", err)
423
-			return false, &enums.SGJError{Code: enums.ErrorCodeDataException}
424
-		}
425
-		didCreateNew = true
426
-	}
427
 	if did_dialysis_manage_create == false {
419
 	if did_dialysis_manage_create == false {
428
 		err := service.CreateOrgApp(adminUserID, orgID, 3, false)
420
 		err := service.CreateOrgApp(adminUserID, orgID, 3, false)
429
 		if err != nil {
421
 		if err != nil {
440
 		}
432
 		}
441
 		didCreateNew = true
433
 		didCreateNew = true
442
 	}
434
 	}
435
+	if did_patient_manage_create == false {
436
+		err := service.CreateOrgApp(adminUserID, orgID, 1, false)
437
+		if err != nil {
438
+			utils.ErrorLog("自动创建酷医聚客应用失败:%v", err)
439
+			return false, &enums.SGJError{Code: enums.ErrorCodeDataException}
440
+		}
441
+		didCreateNew = true
442
+	}
443
 	if did_mall_manage_create == false {
443
 	if did_mall_manage_create == false {
444
 		err := service.CreateOrgApp(adminUserID, orgID, 5, false)
444
 		err := service.CreateOrgApp(adminUserID, orgID, 5, false)
445
 		if err != nil {
445
 		if err != nil {

+ 1 - 1
service/login_service.go View File

73
 }
73
 }
74
 
74
 
75
 func GetAdminUserPrioritizedAppType(adminUserID int) (int8, error) {
75
 func GetAdminUserPrioritizedAppType(adminUserID int) (int8, error) {
76
-	rows, err := readUserDb.Raw("SELECT app.app_type FROM sgj_user_org_app AS app, sgj_user_admin_role AS r WHERE r.admin_user_id = ? AND r.app_id = app.id AND app.status = 1 AND r.status = 1 ORDER BY app.org_id ASC, app.app_type ASC LIMIT 1;", adminUserID).Rows()
76
+	rows, err := readUserDb.Raw("SELECT app.app_type FROM sgj_user_org_app AS app, sgj_user_admin_role AS r WHERE r.admin_user_id = ? AND r.app_id = app.id AND app.status = 1 AND app.open_status = 1 AND r.status = 1 ORDER BY app.org_id ASC, app.app_type ASC LIMIT 1;", adminUserID).Rows()
77
 	defer rows.Close()
77
 	defer rows.Close()
78
 	if err != nil {
78
 	if err != nil {
79
 		return 0, err
79
 		return 0, err

+ 4 - 3
service/org_service.go View File

30
 		return err
30
 		return err
31
 	}
31
 	}
32
 
32
 
33
-	if err := createOrgApp(tx_admin, &role, mobile, 1, openSCRM); err != nil {
33
+	// app 的创建顺序也决定了登录后前往 app 的优先级
34
+	if err := createOrgApp(tx_admin, &role, mobile, 3, openXT); err != nil {
34
 		tx_admin.Rollback()
35
 		tx_admin.Rollback()
35
 		return err
36
 		return err
36
 	}
37
 	}
37
-	if err := createOrgApp(tx_admin, &role, mobile, 3, openXT); err != nil {
38
+	if err := createOrgApp(tx_admin, &role, mobile, 4, openCDM); err != nil {
38
 		tx_admin.Rollback()
39
 		tx_admin.Rollback()
39
 		return err
40
 		return err
40
 	}
41
 	}
41
-	if err := createOrgApp(tx_admin, &role, mobile, 4, openCDM); err != nil {
42
+	if err := createOrgApp(tx_admin, &role, mobile, 1, openSCRM); err != nil {
42
 		tx_admin.Rollback()
43
 		tx_admin.Rollback()
43
 		return err
44
 		return err
44
 	}
45
 	}