diff --git a/business/jxstore/permission/permission.go b/business/jxstore/permission/permission.go index 8e9930afe..f59d5f042 100644 --- a/business/jxstore/permission/permission.go +++ b/business/jxstore/permission/permission.go @@ -2,6 +2,7 @@ package permission import ( "fmt" + "git.rosy.net.cn/jx-callback/business/jxutils/tasksch" "strings" "time" @@ -94,18 +95,23 @@ func GetRole(ctx *jxcontext.Context, name string) (roles []*model.Role, err erro db = dao.GetDB() ) roles, err = dao.GetRole(db, name, "") - for _, v := range roles { - if v.CityCodes != "" { - if cityInfos, err := dao.GetPlaces(db, jxutils.StrListToIntList(strings.Split(v.CityCodes, ","))); err == nil { - v.CityInfo = cityInfos + task := tasksch.NewParallelTask("GetRole", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, + func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { + v := batchItemList[0].(*model.Role) + if v.CityCodes != "" { + if cityInfos, err := dao.GetPlaces(db, jxutils.StrListToIntList(strings.Split(v.CityCodes, ","))); err == nil { + v.CityInfo = cityInfos + } } - } - if v.StoreIDs != "" { - if stores, err := dao.GetStoreList(db, jxutils.StrListToIntList(strings.Split(v.StoreIDs, ",")), nil, nil, nil, nil, ""); err == nil { - v.Stores = stores + if v.StoreIDs != "" { + if stores, err := dao.GetStoreList(db, jxutils.StrListToIntList(strings.Split(v.StoreIDs, ",")), nil, nil, nil, nil, ""); err == nil { + v.Stores = stores + } } - } - } + return retVal, err + }, roles) + tasksch.HandleTask(task, nil, false).Run() + task.GetResult(0) return roles, err }