Przeglądaj źródła

Merge branch 'master' of http://git.shengws.com/csx/XT_New

XMLWAN 4 lat temu
rodzic
commit
48a17514e8

+ 55 - 57
controllers/base_api_controller.go Wyświetl plik

@@ -2,8 +2,6 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/enums"
5
-	"XT_New/models"
6
-	"XT_New/service"
7 5
 )
8 6
 
9 7
 type BaseAPIController struct {
@@ -62,36 +60,36 @@ type BaseAuthAPIController struct {
62 60
 func (this *BaseAuthAPIController) Prepare() {
63 61
 	this.BaseAPIController.Prepare()
64 62
 	if this.GetAdminUserInfo() == nil {
65
-		var userAdmin models.AdminUser
63
+		//var userAdmin models.AdminUser
66 64
 		//userAdmin.Id = 400
67 65
 		//userAdmin.Mobile = "13535547901"
68
-
69
-		userAdmin.Id = 597
70
-		userAdmin.Mobile = "19874122664"
71
-		userAdmin.IsSuperAdmin = false
72
-		userAdmin.Status = 1
73
-		userAdmin.CreateTime = 1530786071
74
-		userAdmin.ModifyTime = 1530786071
75
-		var subscibe models.ServeSubscibe
76
-		subscibe.ID = 1
77
-		subscibe.OrgId = 12
78
-		subscibe.PeriodStart = 1538035409
79
-		subscibe.PeriodEnd = 1569571409
80
-		subscibe.State = 1
81
-		subscibe.Status = 1
82
-		subscibe.CreatedTime = 1538035409
83
-		subscibe.UpdatedTime = 1538035409
84
-		subscibes := make(map[int64]*models.ServeSubscibe, 0)
85
-		subscibes[4] = &subscibe
86
-		var adminUserInfo service.AdminUserInfo
87
-		adminUserInfo.CurrentOrgId = 12
88
-		adminUserInfo.CurrentAppId = 18
89
-		adminUserInfo.AdminUser = &userAdmin
90
-		adminUserInfo.Subscibes = subscibes
91
-		this.SetSession("admin_user_info", &adminUserInfo)
92
-
93
-		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
94
-		//this.StopRun()
66
+		//
67
+		////userAdmin.Id = 597
68
+		////userAdmin.Mobile = "19874122664"
69
+		//userAdmin.IsSuperAdmin = false
70
+		//userAdmin.Status = 1
71
+		//userAdmin.CreateTime = 1530786071
72
+		//userAdmin.ModifyTime = 1530786071
73
+		//var subscibe models.ServeSubscibe
74
+		//subscibe.ID = 1
75
+		//subscibe.OrgId = 12
76
+		//subscibe.PeriodStart = 1538035409
77
+		//subscibe.PeriodEnd = 1569571409
78
+		//subscibe.State = 1
79
+		//subscibe.Status = 1
80
+		//subscibe.CreatedTime = 1538035409
81
+		//subscibe.UpdatedTime = 1538035409
82
+		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
83
+		//subscibes[4] = &subscibe
84
+		//var adminUserInfo service.AdminUserInfo
85
+		//adminUserInfo.CurrentOrgId = 12
86
+		//adminUserInfo.CurrentAppId = 18
87
+		//adminUserInfo.AdminUser = &userAdmin
88
+		//adminUserInfo.Subscibes = subscibes
89
+		//this.SetSession("admin_user_info", &adminUserInfo)
90
+
91
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
92
+		this.StopRun()
95 93
 	}
96 94
 
97 95
 	//if this.Ctx.Request.Method != "GET" {
@@ -177,35 +175,35 @@ type BaseServeAPIController struct {
177 175
 func (this *BaseServeAPIController) Prepare() {
178 176
 	this.BaseAPIController.Prepare()
179 177
 	if this.GetAdminUserInfo() == nil {
180
-		var userAdmin models.AdminUser
178
+		//var userAdmin models.AdminUser
181 179
 		//userAdmin.Id = 400
182 180
 		//userAdmin.Mobile = "13535547901"
183
-		userAdmin.Id = 597
184
-		userAdmin.Mobile = "19874122664"
185
-		userAdmin.IsSuperAdmin = false
186
-		userAdmin.Status = 1
187
-		userAdmin.CreateTime = 1530786071
188
-		userAdmin.ModifyTime = 1530786071
189
-		var subscibe models.ServeSubscibe
190
-		subscibe.ID = 1
191
-		subscibe.OrgId = 12
192
-		subscibe.PeriodStart = 1538035409
193
-		subscibe.PeriodEnd = 1569571409
194
-		subscibe.State = 1
195
-		subscibe.Status = 1
196
-		subscibe.CreatedTime = 1538035409
197
-		subscibe.UpdatedTime = 1538035409
198
-		subscibes := make(map[int64]*models.ServeSubscibe, 0)
199
-		subscibes[4] = &subscibe
200
-		var adminUserInfo service.AdminUserInfo
201
-		adminUserInfo.CurrentOrgId = 12
202
-		adminUserInfo.CurrentAppId = 18
203
-		adminUserInfo.AdminUser = &userAdmin
204
-		adminUserInfo.Subscibes = subscibes
205
-		this.SetSession("admin_user_info", &adminUserInfo)
206
-
207
-		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
208
-		//this.StopRun()
181
+		////userAdmin.Id = 597
182
+		////userAdmin.Mobile = "19874122664"
183
+		//userAdmin.IsSuperAdmin = false
184
+		//userAdmin.Status = 1
185
+		//userAdmin.CreateTime = 1530786071
186
+		//userAdmin.ModifyTime = 1530786071
187
+		//var subscibe models.ServeSubscibe
188
+		//subscibe.ID = 1
189
+		//subscibe.OrgId = 12
190
+		//subscibe.PeriodStart = 1538035409
191
+		//subscibe.PeriodEnd = 1569571409
192
+		//subscibe.State = 1
193
+		//subscibe.Status = 1
194
+		//subscibe.CreatedTime = 1538035409
195
+		//subscibe.UpdatedTime = 1538035409
196
+		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
197
+		//subscibes[4] = &subscibe
198
+		//var adminUserInfo service.AdminUserInfo
199
+		//adminUserInfo.CurrentOrgId = 12
200
+		//adminUserInfo.CurrentAppId = 18
201
+		//adminUserInfo.AdminUser = &userAdmin
202
+		//adminUserInfo.Subscibes = subscibes
203
+		//this.SetSession("admin_user_info", &adminUserInfo)
204
+
205
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
206
+		this.StopRun()
209 207
 	}
210 208
 }
211 209
 

+ 172 - 0
controllers/gobal_config_api_controller.go Wyświetl plik

@@ -17,6 +17,7 @@ import (
17 17
 	"regexp"
18 18
 	"runtime"
19 19
 	"strconv"
20
+	"strings"
20 21
 	"time"
21 22
 
22 23
 	"github.com/astaxie/beego"
@@ -52,6 +53,9 @@ func GobalConfigRegistRouters() {
52 53
 
53 54
 	beego.Router("/api/advicetemplate/getprintinfo", &GobalConfigApiController{}, "post:GetPrintInfo")
54 55
 
56
+	beego.Router("/api/public/orgs", &GobalConfigApiController{}, "get:GetOrgs")
57
+	beego.Router("/api/org/change", &GobalConfigApiController{}, "post:ChangeOrg")
58
+
55 59
 }
56 60
 
57 61
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -940,3 +944,171 @@ func (c *GobalConfigApiController) GetPrintInfo() {
940 944
 		"doctoradvice": getPrint,
941 945
 	})
942 946
 }
947
+
948
+func (c *GobalConfigApiController) GetOrgs() {
949
+	adminUserInfo := c.GetAdminUserInfo()
950
+	var orgs []*models.Org
951
+	adminUser, err := service.GetHomeData(adminUserInfo.AdminUser.Id)
952
+	if err != nil {
953
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
954
+		return
955
+	}
956
+	for _, item := range adminUser.Org {
957
+		orgs = append(orgs, item)
958
+	}
959
+	for _, item := range adminUser.VMApp_Role {
960
+		for _, subItem := range item.Org {
961
+			orgs = append(orgs, subItem)
962
+		}
963
+	}
964
+	orgs = RemoveRepeatedOrgElement(orgs)
965
+
966
+	c.ServeSuccessJSON(map[string]interface{}{
967
+		"orgs": orgs,
968
+	})
969
+
970
+}
971
+
972
+func (this *GobalConfigApiController) ChangeOrg() {
973
+	org_id, _ := this.GetInt64("org_id")
974
+	adminUserInfo := this.GetAdminUserInfo()
975
+	tempOrg, err := service.GetOrgById(org_id)
976
+	if err != nil {
977
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
978
+		return
979
+	}
980
+
981
+	if tempOrg == nil {
982
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoExist)
983
+		return
984
+	}
985
+
986
+	mobile := adminUserInfo.AdminUser.Mobile
987
+	// 只取最近被创建的 admin_role
988
+	adminUser, getAdminErr := service.GetValidAdminUserByMobileReturnErr(mobile) //账号信息唯一值
989
+	if getAdminErr != nil {
990
+		utils.ErrorLog("获取管理员失败:%v", getAdminErr)
991
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
992
+		this.ServeJSON()
993
+		return
994
+	} else if adminUser == nil {
995
+		utils.ErrorLog("查找不到 mobile = %v 的用户", mobile)
996
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
997
+		this.ServeJSON()
998
+		return
999
+	} else {
1000
+
1001
+		adminUserInfo.CurrentOrgId = tempOrg.Id
1002
+		orgApp, _ := service.GetOrgApp(tempOrg.Id, 3)
1003
+		subscibe, _ := service.GetOrgSubscibe(tempOrg.Id)
1004
+		adminUserInfo.CurrentAppId = orgApp.Id
1005
+		appRole, _ := service.GetAppRole(tempOrg.Id, orgApp.Id, adminUserInfo.AdminUser.Id)
1006
+		var FiledList []*models.FiledConfig
1007
+		FiledList, _ = service.FindFiledByOrgId(tempOrg.Id)
1008
+		if len(FiledList) == 0 {
1009
+			err := service.BatchInsertFiledConfig(tempOrg.Id)
1010
+			if err == nil {
1011
+				FiledList, _ = service.FindFiledByOrgId(tempOrg.Id)
1012
+
1013
+			} else {
1014
+				utils.ErrorLog("字段批量插入失败:%v", err)
1015
+			}
1016
+		}
1017
+
1018
+		var curAppUrlfors []string
1019
+
1020
+		if len(curAppUrlfors) == 0 {
1021
+			if adminUser.Id == tempOrg.Creator {
1022
+				urlfors_xt, _, _ := service.GetSuperAdminUsersPurviewTreeAndUrlfors(3)
1023
+				urlfors_cdm, _, _ := service.GetSuperAdminUsersPurviewTreeAndUrlfors(4)
1024
+				urlfors_scrm, _, _ := service.GetSuperAdminUsersPurviewTreeAndUrlfors(6)
1025
+				urlfors_mall, _, _ := service.GetSuperAdminUsersPurviewTreeAndUrlfors(7)
1026
+				curAppUrlfors = append(curAppUrlfors, urlfors_xt...)
1027
+				curAppUrlfors = append(curAppUrlfors, urlfors_scrm...)
1028
+				curAppUrlfors = append(curAppUrlfors, urlfors_cdm...)
1029
+				curAppUrlfors = append(curAppUrlfors, urlfors_mall...)
1030
+			} else {
1031
+				appRole, _ := service.FindAdminUserIDA(appRole.Id)
1032
+				role_arr := strings.Split(appRole.RoleIds, ",")
1033
+				var ids string
1034
+				for _, role_id := range role_arr {
1035
+					id, _ := strconv.ParseInt(role_id, 10, 64)
1036
+					purview_ids, _ := service.GetRolePurviewIds(id)
1037
+					if len(ids) == 0 {
1038
+						ids = purview_ids
1039
+					} else {
1040
+						ids = ids + "," + purview_ids
1041
+					}
1042
+				}
1043
+
1044
+				pruviews, _ := service.GetPurviewById(ids)
1045
+				for _, item := range pruviews {
1046
+					if item.Module == 3 && item.Parentid > 0 {
1047
+						fmt.Println(item.Urlfor)
1048
+						curAppUrlfors = append(curAppUrlfors, item.Urlfor)
1049
+					}
1050
+				}
1051
+			}
1052
+		}
1053
+
1054
+		userInfo := map[string]interface{}{
1055
+			"id":         adminUser.Id,
1056
+			"mobile":     adminUser.Mobile,
1057
+			"user_name":  appRole.UserName,
1058
+			"avatar":     appRole.Avatar,
1059
+			"intro":      appRole.Intro,
1060
+			"user_type":  appRole.UserType,
1061
+			"user_title": appRole.UserTitle,
1062
+		}
1063
+		org := map[string]interface{}{
1064
+			"id":             tempOrg.Id,
1065
+			"org_name":       tempOrg.OrgName,
1066
+			"org_short_name": tempOrg.OrgShortName,
1067
+			"org_intro":      tempOrg.OrgIntroduction,
1068
+			"org_logo":       tempOrg.OrgLogo,
1069
+			"province":       tempOrg.Province,
1070
+			"city":           tempOrg.City,
1071
+			"district":       tempOrg.District,
1072
+			"address":        tempOrg.Address,
1073
+		}
1074
+
1075
+		tempInfo, _ := service.GetOrgInfoTemplate(tempOrg.Id)
1076
+		template_info := map[string]interface{}{
1077
+			"id":          tempInfo.ID,
1078
+			"org_id":      tempInfo.OrgId,
1079
+			"template_id": tempInfo.TemplateId,
1080
+		}
1081
+
1082
+		this.SetSession("admin_user_info", adminUserInfo)
1083
+
1084
+		this.ServeSuccessJSON(map[string]interface{}{
1085
+			"user":           userInfo,
1086
+			"org":            org,
1087
+			"urlfors":        curAppUrlfors,
1088
+			"current_org_id": adminUserInfo.CurrentOrgId,
1089
+			"current_app_id": adminUserInfo.CurrentAppId,
1090
+			"subscibe":       subscibe,
1091
+			"template_info":  template_info,
1092
+			"fileds":         FiledList,
1093
+		})
1094
+
1095
+	}
1096
+
1097
+}
1098
+
1099
+func RemoveRepeatedOrgElement(orgs []*models.Org) (newOrgs []*models.Org) {
1100
+	newOrgs = make([]*models.Org, 0)
1101
+	for i := 0; i < len(orgs); i++ {
1102
+		repeat := false
1103
+		for j := i + 1; j < len(orgs); j++ {
1104
+			if orgs[i].Id == orgs[j].Id {
1105
+				repeat = true
1106
+				break
1107
+			}
1108
+		}
1109
+		if !repeat {
1110
+			newOrgs = append(newOrgs, orgs[i])
1111
+		}
1112
+	}
1113
+	return
1114
+}

+ 70 - 70
controllers/new_mobile_api_controllers/role.json Wyświetl plik

@@ -1,87 +1,87 @@
1 1
 {
2
-    "roles": [
3
-      {
4
-        "role_name": "子管理员",
5
-        "role_introduction": "子管理员角色具备平台全部功能的使用权限,请谨慎配置",
6
-        "is_super_admin": false,
7
-        "status": 1,
8
-        "is_system": 1,
9
-        "number": 9999,
10
-        "purview_ids": "71,72,70,74,75,73,127,128,48,52,110,94,111,112,113,114,115,116,117,118,119,129,84,93,121,122,124,125,120,77,78,79,80,76,156,157,158,159,155,82,83,108,149,154,190,81,101,100,102,161,160,162,163,165,170,169,171,172,173,174,177,175,178,180,179,181,186,185,187,188,189,192",
11
-        "func_ids": "1,2,3,4,5,6,7,8,9,10,11,12,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45"
12
-      },
13
-      {
14
-        "role_name": "医生",
15
-        "role_introduction": "医生角色能够进行建立患者档案,制定和调整患者透析治疗方案,定期评价病人的透析质量等",
16
-        "is_super_admin": false,
17
-        "status": 1,
18
-        "is_system": 2,
19
-        "number": 9998,
20
-        "purview_ids": "71,72,70,74,75,73,127,128,48,52,110,93,121,122,124,125,120,101,100,102,156,157,158,159,15571,72,70,74,75,73,127,128,48,52,110,93,121,122,124,125,120,101,100,102,156,157,158,159,155",
21
-        "func_ids": "1,2,3,4,5,6,7,8,9,10,11,12,24,25,26,27,28,29,30,31,32,33"
2
+  "roles": [
3
+    {
4
+      "role_name": "子管理员",
5
+      "role_introduction": "子管理员角色具备平台全部功能的使用权限,请谨慎配置",
6
+      "is_super_admin": false,
7
+      "status": 1,
8
+      "is_system": 1,
9
+      "number": 9999,
10
+      "purview_ids": "49,71,72,70,74,75,73,127,128,48,52,110,94,111,112,113,114,115,116,117,118,119,129,84,93,121,122,124,125,120,77,78,79,80,76,156,157,158,159,155,82,83,108,149,154,190,81,101,100,102,161,160,162,163,165,170,169,171,172,173,174,177,175,178,180,179,181,186,185,187,188,189,192,81,82,83,104,106,107,108,149,154,190,191",
11
+      "func_ids": "20001,20002,20003,20004,20005,20006,20007,20008,20009,20010,20011,20012,20024,20025,20026,20027,20028,20029,20030,20031,20032,20033,20034,20035,20036,20037,20038,20039,20040,20041,20042,20043,20044,20045"
12
+    },
13
+    {
14
+      "role_name": "医生",
15
+      "role_introduction": "医生角色能够进行建立患者档案,制定和调整患者透析治疗方案,定期评价病人的透析质量等",
16
+      "is_super_admin": false,
17
+      "status": 1,
18
+      "is_system": 2,
19
+      "number": 9998,
20
+      "purview_ids": "49,71,72,70,74,75,73,127,128,48,52,110,93,121,122,124,125,120,101,100,102,156,157,158,159,15571,72,70,74,75,73,127,128,48,52,110,93,121,122,124,125,120,101,100,102,156,157,158,159,155",
21
+      "func_ids": "20001,20002,20003,20004,20005,20006,20007,20008,20009,20010,20011,20012,20024,20025,20026,20027,20028,20029,20030,20031,20032,20033"
22 22
 
23 23
 
24
-      },
25
-      {
26
-        "role_name": "护士",
27
-        "role_introduction": "护士角色能够进行病人透析管理,以及医院的感染控制与消毒记录等",
28
-        "is_super_admin": false,
29
-        "status": 1,
30
-        "is_system": 3,
31
-        "number": 9997,
32
-        "purview_ids": "74,75,73,48,52,110,93,121,122,124,125,120",
33
-        "func_ids": "7,8,10,11,12,13,14,16,17,19,21,22,24,25,27,28"
24
+    },
25
+    {
26
+      "role_name": "护士",
27
+      "role_introduction": "护士角色能够进行病人透析管理,以及医院的感染控制与消毒记录等",
28
+      "is_super_admin": false,
29
+      "status": 1,
30
+      "is_system": 3,
31
+      "number": 9997,
32
+      "purview_ids": "49,74,75,73,48,52,110,93,121,122,124,125,120",
33
+      "func_ids": "20007,20008,20010,20011,20012,20013,20014,20016,20017,20019,20021,20022,20024,20025,20027,20028"
34 34
 
35 35
 
36 36
 
37
-      },
38
-      {
39
-        "role_name": "库存",
40
-        "role_introduction": "库存角色负责透析耗材的日常管理,对耗材的入库、出库、退库的登记操作",
41
-        "is_super_admin": false,
42
-        "status": 1,
43
-        "is_system": 0,
44
-        "number": 9996,
45
-        "purview_ids": "94,111,112,113,114,115,116,117,118,119,129,84",
46
-        "func_ids": ""
37
+    },
38
+    {
39
+      "role_name": "库存",
40
+      "role_introduction": "库存角色负责透析耗材的日常管理,对耗材的入库、出库、退库的登记操作",
41
+      "is_super_admin": false,
42
+      "status": 1,
43
+      "is_system": 0,
44
+      "number": 9996,
45
+      "purview_ids": "94,111,112,113,114,115,116,117,118,119,129,84",
46
+      "func_ids": ""
47 47
 
48 48
 
49 49
 
50
-      },{
51
-        "role_name": "运营",
52
-        "role_introduction": "运营角色能够在SCRM中管理微网站、使用营销工具、做会员管理和分销商品经营的操作",
53
-        "is_super_admin": false,
54
-        "status": 1,
55
-        "is_system": 0,
56
-        "number": 9995,
57
-        "purview_ids": "161,160,162,163,165,170,169,171,172,173,174,177,175,178,180,179,181,186,185,187,188,189,192",
58
-        "func_ids": ""
50
+    },{
51
+      "role_name": "运营",
52
+      "role_introduction": "运营角色能够在SCRM中管理微网站、使用营销工具、做会员管理和分销商品经营的操作",
53
+      "is_super_admin": false,
54
+      "status": 1,
55
+      "is_system": 0,
56
+      "number": 9995,
57
+      "purview_ids": "161,160,162,163,165,170,169,171,172,173,174,177,175,178,180,179,181,186,185,187,188,189,192",
58
+      "func_ids": ""
59 59
 
60 60
 
61 61
 
62
-      },{
63
-        "role_name": "技师",
64
-        "role_introduction": "技师角色能够进行设备的管理,日常维护维修记录等",
65
-        "is_super_admin": false,
66
-        "status": 1,
67
-        "is_system": 0,
68
-        "number": 9994,
69
-        "purview_ids": "77,78,79,80,76",
70
-        "func_ids": ""
62
+    },{
63
+      "role_name": "技师",
64
+      "role_introduction": "技师角色能够进行设备的管理,日常维护维修记录等",
65
+      "is_super_admin": false,
66
+      "status": 1,
67
+      "is_system": 0,
68
+      "number": 9994,
69
+      "purview_ids": "77,78,79,80,76,191",
70
+      "func_ids": ""
71 71
 
72 72
 
73
-      },
74
-      {
75
-        "role_name": "院长",
76
-        "role_introduction": "院长角色了解血透患者血液透析质量和相关的大数据,以及掌握透析中心整体运营情况",
77
-        "is_super_admin": false,
78
-        "status": 1,
79
-        "is_system": 0,
80
-        "number": 9993,
81
-        "purview_ids": "",
82
-        "func_ids": ""
73
+    },
74
+    {
75
+      "role_name": "院长",
76
+      "role_introduction": "院长角色了解血透患者血液透析质量和相关的大数据,以及掌握透析中心整体运营情况",
77
+      "is_super_admin": false,
78
+      "status": 1,
79
+      "is_system": 0,
80
+      "number": 9993,
81
+      "purview_ids": "",
82
+      "func_ids": ""
83 83
 
84 84
 
85
-      }
86
-    ]
85
+    }
86
+  ]
87 87
 }

+ 1 - 0
controllers/role_controller.go Wyświetl plik

@@ -588,6 +588,7 @@ func (this *RoleAPIController) EditAdminInitData() {
588 588
 		"roles":           roles,
589 589
 		"qntoken":         qntoken,
590 590
 		"isSubSuperAdmin": isSubSuperAdmin,
591
+		"org":             org,
591 592
 	})
592 593
 }
593 594
 

+ 1 - 1
routers/router.go Wyświetl plik

@@ -12,7 +12,7 @@ import (
12 12
 func init() {
13 13
 	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
14 14
 		// AllowAllOrigins:  true,
15
-		AllowOrigins: []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://localhost:9531", "http://xt.test.shengws.com", "http://new_mobile.test.sgjyun.com", "https://xt.test.shengws.com", "http://xt.test.sgjyun.com", "https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com", "https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com", "http://mobile.sgjyun.com", "http://mobile.kuyicloud.com"},
15
+		AllowOrigins: []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://localhost:9531", "http://xt.test.shengws.com", "http://new_mobile.test.sgjyun.com", "https://xt.test.shengws.com", "http://xt.test.sgjyun.com:9528", "https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com", "https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com", "http://mobile.sgjyun.com", "http://mobile.kuyicloud.com"},
16 16
 		//AllowOrigins:     []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://xt.test.shengws.com","https://xt.test.shengws.com", "http://xt.test.sgjyun.com","https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com","https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com","http://mobile.sgjyun.com","http://mobile.kuyicloud.com"},
17 17
 		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
18 18
 		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type", "X-XSRF-TOKEN", "Permission"},

+ 3 - 0
service/orginfo_service.go Wyświetl plik

@@ -3,6 +3,7 @@ package service
3 3
 import (
4 4
 	"XT_New/models"
5 5
 	"github.com/jinzhu/gorm"
6
+	"strconv"
6 7
 	"time"
7 8
 )
8 9
 
@@ -142,11 +143,13 @@ func createOrgApp(tx *gorm.DB, superAdminRole *models.Role, userName string, app
142 143
 		}
143 144
 	}
144 145
 
146
+	//string := strconv.FormatInt(int64,10        /)
145 147
 	app_role := models.App_Role{
146 148
 		AdminUserId: superAdminRole.Creator,
147 149
 		OrgId:       superAdminRole.OrgId,
148 150
 		AppId:       app_id,
149 151
 		RoleId:      superAdminRole.Id,
152
+		RoleIds:     strconv.FormatInt(superAdminRole.Id, 10),
150 153
 		Avatar:      "",
151 154
 		UserName:    userName,
152 155
 		Intro:       "",

+ 22 - 20
service/role_service.go Wyświetl plik

@@ -41,14 +41,14 @@ func GetAppRole(orgID int64, appID int64, adminUserID int64) (*models.App_Role,
41 41
 			return nil, err
42 42
 		}
43 43
 	}
44
-
45
-	role_ids := strings.Split(appRole.RoleIds, ",")
46
-
47
-	for _, item := range role_ids {
48
-		id, _ := strconv.ParseInt(item, 10, 64)
49
-		role, _ := GetRoleByRoleID(id)
50
-		if role.IsSystem == 1 && role.RoleName == "子管理员" {
51
-			appRole.IsSubSuperAdmin = true
44
+	if len(appRole.RoleIds) > 0 {
45
+		role_ids := strings.Split(appRole.RoleIds, ",")
46
+		for _, item := range role_ids {
47
+			id, _ := strconv.ParseInt(item, 10, 64)
48
+			role, _ := GetRoleByRoleID(id)
49
+			if role.IsSystem == 1 && role.RoleName == "子管理员" {
50
+				appRole.IsSubSuperAdmin = true
51
+			}
52 52
 		}
53 53
 	}
54 54
 
@@ -136,7 +136,7 @@ func GetAdminUsersAndLoginInfo(orgID int64, appID int64, page int, count int) ([
136 136
 		page = 1
137 137
 	}
138 138
 	var viewModels []*AdminUserManageViewModel = make([]*AdminUserManageViewModel, 0)
139
-	rows, err := readUserDb.Raw("SELECT u_a_r.admin_user_id, u_a_r.user_name, u_a_r.user_title, u_l.ip, u_l.ctime, u_a_r.status,u_a_r.avatar,u_a_r.role_ids FROM sgj_user_admin_role AS u_a_r  LEFT JOIN (SELECT * FROM (SELECT admin_user_id, org_id, app_id, ip, ctime FROM sgj_user_admin_login_log WHERE org_id = ? AND app_id = ?  ORDER BY ctime DESC) AS t GROUP BY admin_user_id) AS u_l ON u_a_r.org_id = u_l.org_id AND u_a_r.app_id = u_l.app_id AND u_a_r.admin_user_id = u_l.admin_user_id WHERE u_a_r.org_id = ? AND u_a_r.app_id = ? AND user_type != 1 GROUP BY u_a_r.admin_user_id LIMIT ? OFFSET ?;", orgID, appID, orgID, appID, count, (page-1)*count).Rows()
139
+	rows, err := readUserDb.Raw("SELECT u_a_r.admin_user_id, u_a_r.user_name, u_a_r.user_title, u_l.ip, u_l.ctime, u_a_r.status,u_a_r.avatar,u_a_r.role_ids FROM sgj_user_admin_role AS u_a_r  LEFT JOIN (SELECT * FROM (SELECT admin_user_id, org_id, app_id, ip, ctime FROM sgj_user_admin_login_log WHERE org_id = ? AND app_id = ?  ORDER BY ctime DESC) AS t GROUP BY admin_user_id) AS u_l ON u_a_r.org_id = u_l.org_id AND u_a_r.app_id = u_l.app_id AND u_a_r.admin_user_id = u_l.admin_user_id WHERE u_a_r.org_id = ? AND u_a_r.app_id = ? GROUP BY u_a_r.admin_user_id LIMIT ? OFFSET ?;", orgID, appID, orgID, appID, count, (page-1)*count).Rows()
140 140
 	defer rows.Close()
141 141
 	if err != nil {
142 142
 		if err == gorm.ErrRecordNotFound {
@@ -160,18 +160,20 @@ func GetAdminUsersAndLoginInfo(orgID int64, appID int64, page int, count int) ([
160 160
 	}
161 161
 
162 162
 	for _, item := range viewModels {
163
-		ids := strings.Split(item.RoleIds, ",")
164
-		for _, id := range ids {
165
-			id, _ := strconv.ParseInt(id, 10, 64)
166
-			role, _ := GetRoleByRoleID(id)
167
-			if role.IsSystem == 1 && role.RoleName == "子管理员" {
168
-				item.IsSubSuperAdmin = true
169
-			}
163
+		if len(item.RoleIds) > 0 {
164
+			ids := strings.Split(item.RoleIds, ",")
165
+			for _, id := range ids {
166
+				id, _ := strconv.ParseInt(id, 10, 64)
167
+				role, _ := GetRoleByRoleID(id)
168
+				if role.IsSystem == 1 && role.RoleName == "子管理员" {
169
+					item.IsSubSuperAdmin = true
170
+				}
170 171
 
171
-			if len(item.RoleName) == 0 {
172
-				item.RoleName = role.RoleName
173
-			} else {
174
-				item.RoleName = item.RoleName + "," + role.RoleName
172
+				if len(item.RoleName) == 0 {
173
+					item.RoleName = role.RoleName
174
+				} else {
175
+					item.RoleName = item.RoleName + "," + role.RoleName
176
+				}
175 177
 			}
176 178
 		}
177 179