From f4e97af0e18bdb2f59121b883b6783f20126d561 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 9 Sep 2019 12:03:07 +0800 Subject: [PATCH] =?UTF-8?q?+=20=E6=B7=BB=E5=8A=A0autils.NewStoreBossRole?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/authz/autils/authz_utils.go | 4 ++++ business/jxstore/cms/authz.go | 5 ++--- business/jxstore/cms/authz_test.go | 3 +-- business/jxstore/cms/user2.go | 4 ++-- business/jxutils/weixinmsg/weixinmsg.go | 3 +-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/business/authz/autils/authz_utils.go b/business/authz/autils/authz_utils.go index fdd1da447..cb75f0149 100644 --- a/business/authz/autils/authz_utils.go +++ b/business/authz/autils/authz_utils.go @@ -37,6 +37,10 @@ func NewRole(name string, storeID int) (r *authz.RoleInfo) { return r } +func NewStoreBossRole(storeID int) (r *authz.RoleInfo) { + return NewRole(authz.StoreRoleBoss, storeID) +} + func NewRoleByModel(conf *model.NewConfig) (r *authz.RoleInfo) { if conf.Type != model.ConfigTypeRole { r = NewRole(conf.Key, 0) diff --git a/business/jxstore/cms/authz.go b/business/jxstore/cms/authz.go index e8cd10646..6e938398f 100644 --- a/business/jxstore/cms/authz.go +++ b/business/jxstore/cms/authz.go @@ -3,7 +3,6 @@ package cms import ( "git.rosy.net.cn/jx-callback/business/auth2" "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin" - "git.rosy.net.cn/jx-callback/business/authz" "git.rosy.net.cn/jx-callback/business/authz/autils" "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/model/dao" @@ -111,7 +110,7 @@ func TransferLegacyWeixins(mobile string) (err error) { } if v.JxStoreID > 0 { // 运营就不加到门店老板组里了 if user.Type&model.UserTypeOperator == 0 { - api2.RoleMan.AddRole4User(user.GetID(), autils.NewRole(authz.StoreRoleBoss, v.JxStoreID)) + api2.RoleMan.AddRole4User(user.GetID(), autils.NewStoreBossRole(v.JxStoreID)) } } else { if mobile != "" { @@ -119,7 +118,7 @@ func TransferLegacyWeixins(mobile string) (err error) { if err = err2; err == nil { for _, role := range rList { if role.StoreID > 0 { - api2.RoleMan.DeleteRole4User(user.GetID(), autils.NewRole(authz.StoreRoleBoss, role.StoreID)) + api2.RoleMan.DeleteRole4User(user.GetID(), autils.NewStoreBossRole(role.StoreID)) } } } diff --git a/business/jxstore/cms/authz_test.go b/business/jxstore/cms/authz_test.go index 31d78f708..34868dd56 100644 --- a/business/jxstore/cms/authz_test.go +++ b/business/jxstore/cms/authz_test.go @@ -6,7 +6,6 @@ import ( "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/globals/api2" - "git.rosy.net.cn/jx-callback/business/authz" "git.rosy.net.cn/jx-callback/business/authz/autils" _ "git.rosy.net.cn/jx-callback/business/partner/purchase/ebai" _ "git.rosy.net.cn/jx-callback/business/partner/purchase/elm" @@ -23,7 +22,7 @@ func TestTransferLegacyWeixins(t *testing.T) { } func TestCasbin(t *testing.T) { - userList, err := api2.RoleMan.GetRoleUserList(autils.NewRole(authz.StoreRoleBoss, 100324)) + userList, err := api2.RoleMan.GetRoleUserList(autils.NewStoreBossRole(100324)) t.Log(utils.Format4Output(userList, false)) if err != nil { t.Fatal(err) diff --git a/business/jxstore/cms/user2.go b/business/jxstore/cms/user2.go index f38b4a2e4..23ea882df 100644 --- a/business/jxstore/cms/user2.go +++ b/business/jxstore/cms/user2.go @@ -132,7 +132,7 @@ func TryAddStoreBossRole4User(ctx *jxcontext.Context, user *model.User) (err err if storeList, err := dao.GetStoreList(dao.GetDB(), nil, []string{userMobile}, ""); err == nil && len(storeList) > 0 { roleList := make([]*authz.RoleInfo, len(storeList)) for k, v := range storeList { - roleList[k] = autils.NewRole(authz.StoreRoleBoss, v.ID) + roleList[k] = autils.NewStoreBossRole(v.ID) } err = AddRoles4User(ctx, user.GetID(), roleList) } @@ -152,7 +152,7 @@ func TryAddStoreBossRole4StoreByMobile(ctx *jxcontext.Context, storeID int, mobi } } if len(userIDs) > 0 { - role := autils.NewRole(authz.StoreRoleBoss, storeID) + role := autils.NewStoreBossRole(storeID) err = AddUsers4Role(ctx, role, userIDs) } } diff --git a/business/jxutils/weixinmsg/weixinmsg.go b/business/jxutils/weixinmsg/weixinmsg.go index cb4062c32..db21bc1db 100644 --- a/business/jxutils/weixinmsg/weixinmsg.go +++ b/business/jxutils/weixinmsg/weixinmsg.go @@ -6,7 +6,6 @@ import ( "time" "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin" - "git.rosy.net.cn/jx-callback/business/authz" "git.rosy.net.cn/jx-callback/business/authz/autils" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" "git.rosy.net.cn/jx-callback/business/jxutils/netprinter" @@ -116,7 +115,7 @@ func GetWeixinOpenIDsFromStoreID(storeID int) (retVal []string) { } } if globals.EnableWXAuth2 { - if userIDList, err2 := api2.RoleMan.GetRoleUserList(autils.NewRole(authz.StoreRoleBoss, storeID)); err2 == nil { + if userIDList, err2 := api2.RoleMan.GetRoleUserList(autils.NewStoreBossRole(storeID)); err2 == nil { for _, v := range userIDList { if authList, err2 := dao.GetUserBindAuthInfo(db, v, model.AuthBindTypeAuth, []string{weixin.AuthTypeMP}, "", ""); err2 == nil { for _, v := range authList {