aa
This commit is contained in:
@@ -43,7 +43,7 @@ func AddMenu(ctx *jxcontext.Context, menu *model.Menu) (err error) {
|
||||
if len(menus) > 0 {
|
||||
return fmt.Errorf("添加失败!已存在相同名称的 menu name : %v", menu.Name)
|
||||
}
|
||||
txDB , _ := dao.Begin(db)
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
@@ -66,7 +66,7 @@ func UpdateMenu(ctx *jxcontext.Context, menuID int, payload map[string]interface
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
txDB , _ := dao.Begin(db)
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
@@ -120,7 +120,7 @@ func AddRole(ctx *jxcontext.Context, name string) (err error) {
|
||||
role := &model.Role{
|
||||
Name: name,
|
||||
}
|
||||
txDB , _ := dao.Begin(db)
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
@@ -154,7 +154,7 @@ func UpdateRole(ctx *jxcontext.Context, roleID int, name string, isDelete bool,
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
txDB , _ := dao.Begin(db)
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
@@ -216,7 +216,7 @@ func UpdateUserRole(ctx *jxcontext.Context, userIDs []string, roleIDs []int) (er
|
||||
}
|
||||
}
|
||||
}
|
||||
txDB , _ := dao.Begin(db)
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
@@ -296,7 +296,7 @@ func UpdateRoleMenu(ctx *jxcontext.Context, roleIDs, menuIDs []int) (err error)
|
||||
}
|
||||
}
|
||||
}
|
||||
txDB , _ := dao.Begin(db)
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
@@ -339,65 +339,70 @@ func GetUserStoresResultMap(userID string) (resultMap map[int]int, err error) {
|
||||
// storeIDMap = make(map[int]int)
|
||||
)
|
||||
resultMap = make(map[int]int)
|
||||
userRoles, err := dao.GetUserRole2(db, []string{userID}, nil)
|
||||
for _, v := range userRoles {
|
||||
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
|
||||
}
|
||||
if v.BrandID != 0 {
|
||||
brandIDs = append(brandIDs, v.BrandID)
|
||||
}
|
||||
if v.CityCodes != "0" && v.CityCodes != "" {
|
||||
cityCodes = append(cityCodes, jxutils.StrListToIntList(strings.Split(v.CityCodes, ","))...)
|
||||
}
|
||||
if v.StoreIDs != "" {
|
||||
storeIDs = append(storeIDs, jxutils.StrListToIntList(strings.Split(v.StoreIDs, ","))...)
|
||||
}
|
||||
if stores, err := dao.GetStoreList(db, storeIDs, cityCodes, nil, brandIDs, nil, ""); len(stores) > 0 && err == nil {
|
||||
for _, v := range stores {
|
||||
resultMap[v.ID] = v.ID
|
||||
user, _ := dao.GetUserByID(db, "user_id", userID)
|
||||
if user.BindStoreID != 0 {
|
||||
resultMap[user.BindStoreID] = user.BindStoreID
|
||||
} else {
|
||||
userRoles, err2 := dao.GetUserRole2(db, []string{userID}, nil)
|
||||
err = err2
|
||||
for _, v := range userRoles {
|
||||
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
|
||||
}
|
||||
if v.BrandID != 0 {
|
||||
brandIDs = append(brandIDs, v.BrandID)
|
||||
}
|
||||
if v.CityCodes != "0" && v.CityCodes != "" {
|
||||
cityCodes = append(cityCodes, jxutils.StrListToIntList(strings.Split(v.CityCodes, ","))...)
|
||||
}
|
||||
if v.StoreIDs != "" {
|
||||
storeIDs = append(storeIDs, jxutils.StrListToIntList(strings.Split(v.StoreIDs, ","))...)
|
||||
}
|
||||
if stores, err := dao.GetStoreList(db, storeIDs, cityCodes, nil, brandIDs, nil, ""); len(stores) > 0 && err == nil {
|
||||
for _, v := range stores {
|
||||
resultMap[v.ID] = v.ID
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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...)
|
||||
// }
|
||||
}
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user