+ 添加autils.NewStoreBossRole

This commit is contained in:
gazebo
2019-09-09 12:03:07 +08:00
parent 0abd1b0642
commit f4e97af0e1
5 changed files with 10 additions and 9 deletions

View File

@@ -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)

View File

@@ -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))
}
}
}

View File

@@ -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)

View File

@@ -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)
}
}

View File

@@ -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 {