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