- 角色管理初版

This commit is contained in:
gazebo
2019-08-07 18:16:44 +08:00
parent 059be1befd
commit 3639a1c7cb
14 changed files with 500 additions and 72 deletions

View File

@@ -6,9 +6,12 @@ import (
"strings"
"time"
"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/jxutils/msg"
"git.rosy.net.cn/jx-callback/business/partner"
@@ -216,6 +219,7 @@ func checkConfig(configType, key, value string) (err error) {
err = fmt.Errorf("此银行代码:%s不支持请联系开发", value)
}
}
case model.ConfigTypeRole:
default:
err = fmt.Errorf("当前只支持配置:%s, 传入的配置类型:%s", utils.Format4Output(model.ConfigTypeName, true), configType)
}
@@ -245,21 +249,32 @@ func DeleteConfig(ctx *jxcontext.Context, key, configType string) (err error) {
switch configType {
case model.ConfigTypePricePack:
storeMapList, err := dao.GetStoresMapList(db, nil, nil, model.StoreStatusAll, model.StoreIsSyncYes, key)
if err != nil {
return err
}
if len(storeMapList) > 0 {
var storeInfo []string
for _, v := range storeMapList {
storeInfo = append(storeInfo, fmt.Sprintf("门店:%d, 平台:%s", v.StoreID, model.VendorChineseNames[v.VendorID]))
if err == nil {
if len(storeMapList) > 0 {
var storeInfo []string
for _, v := range storeMapList {
storeInfo = append(storeInfo, fmt.Sprintf("门店:%d, 平台:%s", v.StoreID, model.VendorChineseNames[v.VendorID]))
}
err = fmt.Errorf("还有门店在使用价格包:%s门店信息:%s", key, strings.Join(storeInfo, ","))
}
}
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")))
}
}
return fmt.Errorf("还有门店在使用价格包:%s门店信息:%s", key, strings.Join(storeInfo, ","))
}
}
_, err = dao.DeleteEntityLogically(db, &model.NewConfig{}, nil, ctx.GetUserName(), map[string]interface{}{
"Key": key,
"Type": configType,
})
if err == nil {
_, err = dao.DeleteEntityLogically(db, &model.NewConfig{}, nil, ctx.GetUserName(), map[string]interface{}{
"Key": key,
"Type": configType,
})
}
return err
}