From 7e318ca948d803eac3762adc4393afb74200bb84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 12 Apr 2022 14:07:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=87=AA=E5=B7=B1=E9=97=A8=E5=BA=97=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/user2.go | 25 +++++++++++---- business/jxstore/permission/permission.go | 39 +---------------------- 2 files changed, 19 insertions(+), 45 deletions(-) diff --git a/business/jxstore/cms/user2.go b/business/jxstore/cms/user2.go index c66c708b4..d6344c663 100644 --- a/business/jxstore/cms/user2.go +++ b/business/jxstore/cms/user2.go @@ -1243,15 +1243,26 @@ func UpdateUserLastInfo(ctx *jxcontext.Context, storeID, brandID int) (err error } func GetUserStoreAuth(ctx *jxcontext.Context, storeID int) (outStoreID int, err error) { - //if permission.IsRoled(ctx) { - storeMap, _ := permission.GetUserStoresResultMap(ctx.GetUserID()) - if storeMap[storeID] != 0 { - return storeID, err - } else { + if permission.IsRoled(ctx) { + configs, _ := dao.QueryConfigs(dao.GetDB(), "checkversion", model.ConfigTypeSys, "") + storeMaps, _, err := GetMyStoreListNew(ctx, configs[0].Value) + if err != nil { return 0, err } - //} - //return storeID, err + for _, v := range storeMaps.([]map[string]interface{}) { + if v["id"].(int) != storeID { + continue + } + return storeID, nil + } + //storeMap, _ := permission.GetUserStoresResultMap(ctx.GetUserID()) + //if storeMap[storeID] != 0 { + // return storeID, err + //} else { + // return 0, err + //} + } + return storeID, err } func SendQywxPeopleCount(ctx *jxcontext.Context) (err error) { diff --git a/business/jxstore/permission/permission.go b/business/jxstore/permission/permission.go index f59d5f042..04bea7b00 100644 --- a/business/jxstore/permission/permission.go +++ b/business/jxstore/permission/permission.go @@ -340,9 +340,6 @@ func UpdateRoleMenu(ctx *jxcontext.Context, roleIDs, menuIDs []int) (err error) func GetUserStoresResultMap(userID string) (resultMap map[int]int, err error) { var ( db = dao.GetDB() - // brandIDMap = make(map[int]int) - // cityCodeMap = make(map[int]int) - // storeIDMap = make(map[int]int) ) resultMap = make(map[int]int) user, _ := dao.GetUserByID(db, "user_id", userID) @@ -360,23 +357,6 @@ func GetUserStoresResultMap(userID string) (resultMap map[int]int, err error) { var ( brandIDs, cityCodes, storeIDs []int ) - // if _, ok := brandIDMap[v.BrandID]; !ok { - // brandIDMap[v.BrandID] = 1 - // } - // if v.CityCodes != "" { - // for _, cityCode := range jxutils.StrListToIntList(strings.Split(v.CityCodes, ",")) { - // if _, ok := cityCodeMap[cityCode]; !ok { - // cityCodeMap[cityCode] = 1 - // } - // } - // } - // if v.StoreIDs != "" { - // for _, storeID := range jxutils.StrListToIntList(strings.Split(v.StoreIDs, ",")) { - // if _, ok := storeIDMap[storeID]; !ok { - // storeIDMap[storeID] = 1 - // } - // } - // } if v.CityCodes == "" && v.StoreIDs == "" { continue } @@ -395,24 +375,7 @@ func GetUserStoresResultMap(userID string) (resultMap map[int]int, err error) { } } } - // for k, _ := range brandIDMap { - // brandIDs = append(brandIDs, k) - // } - // for k, _ := range cityCodeMap { - // cityCodes = append(cityCodes, k) - // } - // for k, _ := range storeIDMap { - // storeIDs = append(storeIDs, k) - // } - // if stores1, err := dao.GetStoreList(db, nil, nil, brandIDs, nil, nil, ""); len(stores1) > 0 && err == nil { - // stores = append(stores, stores1...) - // } - // if stores2, err := dao.GetStoreList(db, nil, cityCodes, nil, nil, nil, ""); len(stores2) > 0 && err == nil { - // stores = append(stores, stores2...) - // } - // if stores3, err := dao.GetStoreList(db, storeIDs, nil, nil, nil, nil, ""); len(stores3) > 0 && err == nil { - // stores = append(stores, stores3...) - // } + return resultMap, err }