From f0fcf84ddb0151e8a24c5b0a89126eedb94a8e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 29 Mar 2021 10:19:53 +0800 Subject: [PATCH] aa --- business/jxstore/cms/store.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 7539c72b0..0640d343c 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -4097,12 +4097,25 @@ func RefreshStoreBind(ctx *jxcontext.Context) (err error) { task := tasksch.NewParallelTask("RefreshStoreBind", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { store := batchItemList[0].(*model.Store) - var userIDs []string + var ( + userIDmap1 = make(map[string]string) + userIDmap2 = make(map[string]string) + userIDs []string + ) userList := getAllUsers4Store(ctx, db, store) for _, v := range userList { - userIDs = append(userIDs, v.UserID) + userIDmap1[v.UserID] = v.UserID } - err = AddUsers4Role(ctx, autils.NewRole(authz.StoreRoleBoss, store.ID), userIDs) + nowUserIDs, _ := GetRoleUserList(ctx, autils.NewRole(authz.StoreRoleBoss, store.ID)) + for _, v := range nowUserIDs { + userIDmap2[v] = v + } + for _, v := range userIDmap1 { + if userIDmap2[v] == "" { + userIDs = append(userIDs, v) + } + } + AddUsers4Role(ctx, autils.NewRole(authz.StoreRoleBoss, store.ID), userIDs) return retVal, err }, stores) tasksch.HandleTask(task, nil, true).Run()