aa
This commit is contained in:
@@ -333,58 +333,70 @@ func UpdateRoleMenu(ctx *jxcontext.Context, roleIDs, menuIDs []int) (err error)
|
|||||||
|
|
||||||
func GetUserStoresResultMap(userID string) (resultMap map[int]int, err error) {
|
func GetUserStoresResultMap(userID string) (resultMap map[int]int, err error) {
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
brandIDMap = make(map[int]int)
|
// brandIDMap = make(map[int]int)
|
||||||
cityCodeMap = make(map[int]int)
|
// cityCodeMap = make(map[int]int)
|
||||||
storeIDMap = make(map[int]int)
|
// storeIDMap = make(map[int]int)
|
||||||
brandIDs, cityCodes, storeIDs []int
|
|
||||||
stores []*model.Store
|
|
||||||
)
|
)
|
||||||
resultMap = make(map[int]int)
|
resultMap = make(map[int]int)
|
||||||
userRoles, err := dao.GetUserRole2(db, []string{userID}, nil)
|
userRoles, err := dao.GetUserRole2(db, []string{userID}, nil)
|
||||||
for _, v := range userRoles {
|
for _, v := range userRoles {
|
||||||
if _, ok := brandIDMap[v.BrandID]; !ok {
|
var (
|
||||||
brandIDMap[v.BrandID] = 1
|
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.BrandID != 0 {
|
||||||
|
brandIDs = append(brandIDs, v.BrandID)
|
||||||
}
|
}
|
||||||
if v.CityCodes != "" {
|
if v.CityCodes != "0" {
|
||||||
for _, cityCode := range jxutils.StrListToIntList(strings.Split(v.CityCodes, ",")) {
|
cityCodes = append(cityCodes, jxutils.StrListToIntList(strings.Split(v.CityCodes, ","))...)
|
||||||
if _, ok := cityCodeMap[cityCode]; !ok {
|
|
||||||
cityCodeMap[cityCode] = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if v.StoreIDs != "" {
|
if v.StoreIDs != "" {
|
||||||
for _, storeID := range jxutils.StrListToIntList(strings.Split(v.StoreIDs, ",")) {
|
storeIDs = append(storeIDs, jxutils.StrListToIntList(strings.Split(v.StoreIDs, ","))...)
|
||||||
if _, ok := storeIDMap[storeID]; !ok {
|
}
|
||||||
storeIDMap[storeID] = 1
|
if stores, err := dao.GetStoreList(db, storeIDs, cityCodes, brandIDs, nil, nil, ""); len(stores) > 0 && err == nil {
|
||||||
|
for _, v := range stores {
|
||||||
|
if _, ok := resultMap[v.ID]; !ok {
|
||||||
|
resultMap[v.ID] = v.ID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for k, _ := range brandIDMap {
|
// for k, _ := range brandIDMap {
|
||||||
brandIDs = append(brandIDs, k)
|
// brandIDs = append(brandIDs, k)
|
||||||
}
|
// }
|
||||||
for k, _ := range cityCodeMap {
|
// for k, _ := range cityCodeMap {
|
||||||
cityCodes = append(cityCodes, k)
|
// cityCodes = append(cityCodes, k)
|
||||||
}
|
// }
|
||||||
for k, _ := range storeIDMap {
|
// for k, _ := range storeIDMap {
|
||||||
storeIDs = append(storeIDs, k)
|
// storeIDs = append(storeIDs, k)
|
||||||
}
|
// }
|
||||||
if stores1, err := dao.GetStoreList(db, nil, nil, brandIDs, nil, nil, ""); len(stores1) > 0 && err == nil {
|
// if stores1, err := dao.GetStoreList(db, nil, nil, brandIDs, nil, nil, ""); len(stores1) > 0 && err == nil {
|
||||||
stores = append(stores, stores1...)
|
// stores = append(stores, stores1...)
|
||||||
}
|
// }
|
||||||
if stores2, err := dao.GetStoreList(db, nil, cityCodes, nil, nil, nil, ""); len(stores2) > 0 && err == nil {
|
// if stores2, err := dao.GetStoreList(db, nil, cityCodes, nil, nil, nil, ""); len(stores2) > 0 && err == nil {
|
||||||
stores = append(stores, stores2...)
|
// stores = append(stores, stores2...)
|
||||||
}
|
// }
|
||||||
if stores3, err := dao.GetStoreList(db, storeIDs, nil, nil, nil, nil, ""); len(stores3) > 0 && err == nil {
|
// if stores3, err := dao.GetStoreList(db, storeIDs, nil, nil, nil, nil, ""); len(stores3) > 0 && err == nil {
|
||||||
stores = append(stores, stores3...)
|
// stores = append(stores, stores3...)
|
||||||
}
|
// }
|
||||||
|
|
||||||
for _, v := range stores {
|
|
||||||
if _, ok := resultMap[v.ID]; !ok {
|
|
||||||
resultMap[v.ID] = v.ID
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resultMap, err
|
return resultMap, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user