package rolesync import ( "context" "git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/dao" "git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/model" "git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/model/entity" "git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/service" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" ) func EnqueueRole(ctx context.Context, roleID, actorID int64) error { if gdb.TXFromCtx(ctx, g.DB().GetGroup()) != nil { return nil } var role *entity.SysRole if err := dao.SysRole.Ctx(ctx).Where("role_id", roleID).Scan(&role); err != nil { return err } if role == nil || role.IsPass != 1 { return nil } err := service.AgentRole().SyncInheritedRole(ctx, &model.AgentRoleSyncMessage{TenantId: role.TenantId, SourceRoleId: role.RoleId, SourceDeptId: role.DeptId, ActorId: actorID}) if err != nil { return gerror.Wrap(err, "模板已保存,但部分企业同步失败,请修复关联后重新保存") } return nil }