- 重构authz结构

- 角色管理初版完成
This commit is contained in:
gazebo
2019-08-08 17:06:58 +08:00
parent 60f3ec9c3b
commit b51614946f
18 changed files with 161 additions and 98 deletions

View File

@@ -6,12 +6,14 @@ import (
"strings"
"time"
"git.rosy.net.cn/baseapi/utils/errlist"
"git.rosy.net.cn/jx-callback/globals/api2"
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/mobile"
"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/msg"
"git.rosy.net.cn/jx-callback/business/partner"
@@ -259,15 +261,25 @@ func DeleteConfig(ctx *jxcontext.Context, key, configType string) (err error) {
}
}
case model.ConfigTypeRole:
userIDs, err2 := api2.RoleMan.GetRoleUserList(authz.NewRole(key, 0))
if err = err2; err == nil {
if len(userIDs) > 0 {
userList, err2 := GetUsers(ctx, 0, "", userIDs, "", "")
if err = err2; err == nil {
err = fmt.Errorf("还有人员在使用角色:%s人员信息:%s", key, utils.MustMarshal(utils.Struct2Map(userList, "compact")))
}
errList := errlist.New()
userIDs, err2 := api2.RoleMan.GetRoleUserList(autils.NewRole(key, 0))
if err = err2; err == nil && len(userIDs) > 0 {
userList, err2 := GetUsers(ctx, 0, "", userIDs, "", "")
if err = err2; err == nil {
err = fmt.Errorf("还有人员在使用角色:%s人员信息:%s", key, utils.MustMarshal(utils.Struct2Map(userList, "compact")))
}
}
errList.AddErr(err)
storeList, err2 := dao.GetStoreList4Role(db, key)
if err = err2; err == nil && len(storeList) > 0 {
storeIDs := make([]int, len(storeList))
for k, v := range storeList {
storeIDs[k] = v.ID
}
err = fmt.Errorf("还有门店在使用角色:%s门店信息:%s", key, utils.MustMarshal(storeIDs))
}
errList.AddErr(err)
err = errList.GetErrListAsOne()
}
if err == nil {
_, err = dao.DeleteEntityLogically(db, &model.NewConfig{}, nil, ctx.GetUserName(), map[string]interface{}{