From 618ae4c2511d857085487b0a85b92a1e517b4114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 22 Jan 2021 10:31:41 +0800 Subject: [PATCH] aa --- business/jxstore/cms/permission.go | 11 +++++++++++ business/jxstore/cms/store.go | 20 ++++++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/business/jxstore/cms/permission.go b/business/jxstore/cms/permission.go index fd825c452..a71c9b24e 100644 --- a/business/jxstore/cms/permission.go +++ b/business/jxstore/cms/permission.go @@ -359,3 +359,14 @@ func GetUserStoresResultMap(userID string) (resultMap map[int]int, err error) { } return resultMap, err } + +func IsRoled(ctx *jxcontext.Context) bool { + if ctx.GetUserName() != "jxadmin" { + if user, err := dao.GetUserByID(dao.GetDB(), "user_id", ctx.GetUserID()); err == nil { + if user.Type&model.UserTypeRole != 0 { + return true + } + } + } + return false +} diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 1255c18ba..e60b4b050 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -517,20 +517,16 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa retVal.Stores = storeList } //权限 - if ctx.GetUserName() != "jxadmin" { - if user, err := dao.GetUserByID(db, "user_id", ctx.GetUserID()); err == nil { - if user.Type&model.UserTypeRole != 0 { - if storeIDsMap, err := GetUserStoresResultMap(user.UserID); err == nil { - var storeList2 []*StoreExt - for _, v := range retVal.Stores { - if storeIDsMap[v.ID] != 0 { - storeList2 = append(storeList2, v) - } - } - retVal.Stores = nil - retVal.Stores = storeList2 + if IsRoled(ctx) { + if storeIDsMap, err := GetUserStoresResultMap(ctx.GetUserID()); err == nil { + var storeList2 []*StoreExt + for _, v := range retVal.Stores { + if storeIDsMap[v.ID] != 0 { + storeList2 = append(storeList2, v) } } + retVal.Stores = nil + retVal.Stores = storeList2 } } // 订单情况过滤