|
@@ -4,7 +4,6 @@ import (
|
4
|
4
|
"gdyb/enums"
|
5
|
5
|
"gdyb/models"
|
6
|
6
|
"github.com/astaxie/beego"
|
7
|
|
-
|
8
|
7
|
//"XT_New/models"
|
9
|
8
|
|
10
|
9
|
//"XT_New/models"
|
|
@@ -96,83 +95,65 @@ func (this *BaseAuthAPIController) Prepare() {
|
96
|
95
|
adminUserInfo.CurrentAppId = 8642
|
97
|
96
|
adminUserInfo.AdminUser = &userAdmin
|
98
|
97
|
this.SetSession("admin_user_info", &adminUserInfo)
|
99
|
|
-
|
100
|
98
|
}
|
101
|
99
|
|
102
|
|
- //if this.Ctx.Request.Method != "GET" {
|
103
|
|
- // adminUserInfo := this.GetAdminUserInfo()
|
104
|
|
- //
|
105
|
|
- // err := service.GetOrgSubscibeState(adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId])
|
106
|
|
- // if err != nil || adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId].State == 3 {
|
107
|
|
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotSubscibe)
|
108
|
|
- // this.StopRun()
|
109
|
|
- // }
|
110
|
|
- //}
|
111
|
|
-
|
112
|
|
- //if this.Ctx.Request.Header.Get("Permission") == "1" {
|
113
|
|
- // isPermission := false
|
114
|
|
- //
|
115
|
|
- // //adminUserInfo := this.GetAdminUserInfo()
|
116
|
|
- //
|
117
|
|
- // //service.GetUserAllRole(adminUserInfo.CurrentOrgId)
|
118
|
|
- //
|
119
|
|
- //
|
120
|
|
- //
|
|
100
|
+ //if this.Ctx.Request.Header.Get("Permission") == "5" { //医保相关权限
|
|
101
|
+ // org_id, _ := beego.AppConfig.Int64("org_id")
|
|
102
|
+ // org, _ := service.GetOrgById(org_id)
|
|
103
|
+ // admin_user_id, _ := this.GetInt64("admin_user_id")
|
|
104
|
+ // if admin_user_id != org.Creator { //超级管理员不受此限制
|
|
105
|
+ // isPermission := false
|
|
106
|
+ // //该机构下该用户有多少个
|
|
107
|
+ // role, _ := service.GetUserAllRole(org_id, admin_user_id)
|
|
108
|
+ // var roles []string
|
|
109
|
+ // if len(role.RoleIds) <= 0 { //该用户没有设置角色
|
121
|
110
|
//
|
122
|
|
- // roles := []int64{1,2} //模拟该用户有多少角色
|
123
|
|
- // var targetRole models.RolePurview
|
124
|
|
- // var userRolePurview []string
|
125
|
|
- //
|
126
|
|
- // //用户角色1对应的权限
|
127
|
|
- // role1 := models.RolePurview{PurviewIds:"11,12,13"}
|
128
|
|
- //
|
129
|
|
- // //用户角色2对应的权限
|
130
|
|
- // role2 := models.RolePurview{PurviewIds:"11,15,16"}
|
131
|
|
- //
|
132
|
|
- //
|
133
|
|
- // //模拟角色2
|
134
|
|
- // //判断该用户有多少个角色,合并最大角色权限
|
135
|
|
- // if len(roles) == 1{ //单个
|
136
|
|
- // targetRole = role1
|
137
|
|
- // userRolePurview = strings.Split(targetRole.PurviewIds, ",")
|
138
|
|
- //
|
139
|
|
- // }else{ //多个
|
140
|
|
- // targetRole = role1
|
141
|
|
- // targetRole.PurviewIds = targetRole.PurviewIds + "," + role2.PurviewIds
|
142
|
|
- // userRolePurview = strings.Split(targetRole.PurviewIds, ",")
|
143
|
|
- // }
|
144
|
|
- //
|
145
|
|
- // userRolePurview = RemoveRepeatedElement2(userRolePurview)
|
|
111
|
+ // } else {
|
|
112
|
+ // roles = strings.Split(role.RoleIds, ",")
|
|
113
|
+ // }
|
|
114
|
+ // fmt.Println(roles)
|
146
|
115
|
//
|
147
|
|
- // fmt.Println(userRolePurview)
|
148
|
|
- // //所有权限列表
|
149
|
|
- // allPermission := []models.Purview{{Id:10,Urlfor:"/m/api/dialysis/dialysisPrescription-/api/dialysis/prescription"},
|
150
|
|
- // {Id:11,Urlfor:"/m/api/dialysis/dialysisPrescription1-/api/dialysis/prescription1"},
|
151
|
|
- // {Id:12,Urlfor:"/m/api/dialysis/dialysisPrescription2-/api/dialysis/prescription2"},
|
152
|
|
- // {Id:13,Urlfor:"/m/api/dialysis/dialysisPrescription3-/api/dialysis/prescription3"},
|
153
|
|
- // {Id:14,Urlfor:"/m/api/dialysis/dialysisPrescription4-/api/dialysis/prescription4"},
|
154
|
|
- // {Id:15,Urlfor:"/m/api/dialysis/dialysisPrescription5-/api/dialysis/prescription5"},
|
155
|
|
- // {Id:16,Urlfor:"/m/api/dialysis/dialysisPrescription6-/api/dialysis/prescription6"}}
|
156
|
|
- // for _, item := range allPermission {
|
157
|
|
- // //判断当前路由是否在权限路由列表里面
|
158
|
|
- // if strings.Split(item.Urlfor, "-")[1] == strings.Split(this.Ctx.Request.RequestURI , "?")[0]{
|
159
|
|
- // fmt.Println(strings.Split(this.Ctx.Request.RequestURI , "?")[0])
|
|
116
|
+ // //获取该用户下所有角色的权限总集
|
|
117
|
+ // var userRolePurviews string
|
|
118
|
+ // var userRolePurviewsArr []string
|
|
119
|
+ // for _, item := range roles {
|
|
120
|
+ // role_id, _ := strconv.ParseInt(item, 10, 64)
|
|
121
|
+ // purviews, _ := service.GetRoleFuncPurviewIds(role_id)
|
|
122
|
+ // if len(userRolePurviews) == 0 {
|
|
123
|
+ // userRolePurviews = purviews
|
|
124
|
+ // } else {
|
|
125
|
+ // userRolePurviews = userRolePurviews + "," + purviews
|
|
126
|
+ // }
|
|
127
|
+ // }
|
|
128
|
+ // //该用户所拥有角色的权限的总集
|
|
129
|
+ // userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
|
|
130
|
+ // fmt.Println(userRolePurviewsArr)
|
|
131
|
+ // //系统所记录的权限列表
|
|
132
|
+ // allPermission, _ := service.GetAllFunctionPurview()
|
160
|
133
|
//
|
|
134
|
+ // for _, item := range allPermission {
|
161
|
135
|
// //获取该角色的所有权限
|
162
|
|
- // for _, items := range userRolePurview{
|
|
136
|
+ // for _, items := range userRolePurviewsArr {
|
163
|
137
|
// id, _ := strconv.ParseInt(items, 10, 64)
|
164
|
|
- // if id == item.Id{
|
|
138
|
+ // if id == item.ID {
|
165
|
139
|
// isPermission = true
|
166
|
140
|
// }
|
167
|
141
|
// }
|
168
|
|
- // if !isPermission{
|
169
|
|
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreExist)
|
|
142
|
+ // if !isPermission {
|
|
143
|
+ // msg, _ := service.FindErrorMsgByStr(item.ID)
|
|
144
|
+ // json := make(map[string]interface{})
|
|
145
|
+ // json["msg"] = msg
|
|
146
|
+ // json["code"] = 0
|
|
147
|
+ // json["state"] = 0
|
|
148
|
+ // this.Data["json"] = json
|
|
149
|
+ // this.ServeJSON()
|
170
|
150
|
// this.StopRun()
|
171
|
151
|
// }
|
172
|
|
- // }
|
173
|
152
|
//
|
|
153
|
+ // }
|
174
|
154
|
// }
|
175
|
155
|
//}
|
|
156
|
+
|
176
|
157
|
}
|
177
|
158
|
|
178
|
159
|
type BaseServeAPIController struct {
|
|
@@ -182,16 +163,10 @@ type BaseServeAPIController struct {
|
182
|
163
|
func (this *BaseServeAPIController) Prepare() {
|
183
|
164
|
this.BaseAPIController.Prepare()
|
184
|
165
|
if this.GetAdminUserInfo() == nil {
|
185
|
|
- //org_id, _ := beego.AppConfig.Int64("org_id")
|
186
|
166
|
org_id, _ := beego.AppConfig.Int64("org_id")
|
187
|
|
-
|
188
|
|
- //org_id, _ := this.GetInt64("org_id")
|
189
|
167
|
var userAdmin models.AdminUser
|
190
|
168
|
userAdmin.Id = 1448
|
191
|
169
|
userAdmin.Mobile = "13318599895"
|
192
|
|
-
|
193
|
|
- //userAdmin.Id = 597
|
194
|
|
- //userAdmin.Mobile = "19874122664"
|
195
|
170
|
userAdmin.IsSuperAdmin = false
|
196
|
171
|
userAdmin.Status = 1
|
197
|
172
|
userAdmin.CreateTime = 1530786071
|
|
@@ -213,21 +188,62 @@ func (this *BaseServeAPIController) Prepare() {
|
213
|
188
|
this.SetSession("admin_user_info", &adminUserInfo)
|
214
|
189
|
}
|
215
|
190
|
|
216
|
|
- //if adminUserInfo.AppRole != nil {
|
217
|
|
- // if adminUserInfo.AppRole.Id > 0 {
|
218
|
|
- // app_role, _ := service.FindAppRoleById(adminUserInfo.AppRole.Id)
|
219
|
|
- // if app_role != nil {
|
220
|
|
- // if app_role.Status != 1 {
|
221
|
|
- // this.DelSession("mobile_admin_user_info")
|
222
|
|
- // this.Ctx.SetCookie("token_cookie", "")
|
223
|
|
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeForbidden)
|
|
191
|
+ //if this.Ctx.Request.Header.Get("Permission") == "5" { //医保相关权限
|
|
192
|
+ // org_id, _ := beego.AppConfig.Int64("org_id")
|
|
193
|
+ // org, _ := service.GetOrgById(org_id)
|
|
194
|
+ // admin_user_id, _ := this.GetInt64("admin_user_id")
|
|
195
|
+ // if admin_user_id != org.Creator { //超级管理员不受此限制
|
|
196
|
+ // isPermission := false
|
|
197
|
+ // //该机构下该用户有多少个
|
|
198
|
+ // role, _ := service.GetUserAllRole(org_id, admin_user_id)
|
|
199
|
+ // var roles []string
|
|
200
|
+ // if len(role.RoleIds) <= 0 { //该用户没有设置角色
|
|
201
|
+ //
|
|
202
|
+ // } else {
|
|
203
|
+ // roles = strings.Split(role.RoleIds, ",")
|
|
204
|
+ // }
|
|
205
|
+ // fmt.Println(roles)
|
|
206
|
+ //
|
|
207
|
+ // //获取该用户下所有角色的权限总集
|
|
208
|
+ // var userRolePurviews string
|
|
209
|
+ // var userRolePurviewsArr []string
|
|
210
|
+ // for _, item := range roles {
|
|
211
|
+ // role_id, _ := strconv.ParseInt(item, 10, 64)
|
|
212
|
+ // purviews, _ := service.GetRoleFuncPurviewIds(role_id)
|
|
213
|
+ // if len(userRolePurviews) == 0 {
|
|
214
|
+ // userRolePurviews = purviews
|
|
215
|
+ // } else {
|
|
216
|
+ // userRolePurviews = userRolePurviews + "," + purviews
|
|
217
|
+ // }
|
|
218
|
+ // }
|
|
219
|
+ // //该用户所拥有角色的权限的总集
|
|
220
|
+ // userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
|
|
221
|
+ // fmt.Println(userRolePurviewsArr)
|
|
222
|
+ // //系统所记录的权限列表
|
|
223
|
+ // allPermission, _ := service.GetAllFunctionPurview()
|
|
224
|
+ //
|
|
225
|
+ // for _, item := range allPermission {
|
|
226
|
+ // //获取该角色的所有权限
|
|
227
|
+ // for _, items := range userRolePurviewsArr {
|
|
228
|
+ // id, _ := strconv.ParseInt(items, 10, 64)
|
|
229
|
+ // if id == item.ID {
|
|
230
|
+ // isPermission = true
|
|
231
|
+ // }
|
|
232
|
+ // }
|
|
233
|
+ // if !isPermission {
|
|
234
|
+ // msg, _ := service.FindErrorMsgByStr(item.ID)
|
|
235
|
+ // json := make(map[string]interface{})
|
|
236
|
+ // json["msg"] = msg
|
|
237
|
+ // json["code"] = 0
|
|
238
|
+ // json["state"] = 0
|
|
239
|
+ // this.Data["json"] = json
|
|
240
|
+ // this.ServeJSON()
|
224
|
241
|
// this.StopRun()
|
225
|
242
|
// }
|
|
243
|
+ //
|
226
|
244
|
// }
|
227
|
245
|
// }
|
228
|
|
- //
|
229
|
246
|
//}
|
230
|
|
- //fmt.Println("222222222")
|
231
|
247
|
|
232
|
248
|
}
|
233
|
249
|
|