Galosys.Foundation.Integration.Im.Abstractions 26.7.31.1

dotnet add package Galosys.Foundation.Integration.Im.Abstractions --version 26.7.31.1
                    
NuGet\Install-Package Galosys.Foundation.Integration.Im.Abstractions -Version 26.7.31.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Galosys.Foundation.Integration.Im.Abstractions" Version="26.7.31.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Galosys.Foundation.Integration.Im.Abstractions" Version="26.7.31.1" />
                    
Directory.Packages.props
<PackageReference Include="Galosys.Foundation.Integration.Im.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Galosys.Foundation.Integration.Im.Abstractions --version 26.7.31.1
                    
#r "nuget: Galosys.Foundation.Integration.Im.Abstractions, 26.7.31.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Galosys.Foundation.Integration.Im.Abstractions@26.7.31.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Galosys.Foundation.Integration.Im.Abstractions&version=26.7.31.1
                    
Install as a Cake Addin
#tool nuget:?package=Galosys.Foundation.Integration.Im.Abstractions&version=26.7.31.1
                    
Install as a Cake Tool

Galosys.Foundation.Integration.Im.Abstractions

IM 集成抽象层 — 为钉钉、飞书、企微等 IM 平台提供统一接口抽象。平台无关的业务代码只依赖此模块。

DI 注册

通过 AddIntegrationIm<T>() 注册具体平台实现到 DI 容器:

// 注册钉钉适配器
services.AddIntegrationIm<DingTalkPlatform>();

// 或注册飞书适配器
services.AddIntegrationIm<FeishuPlatform>();

具体平台的注册扩展方法在对应适配器模块中:

// DingTalk
services.AddAlibabaCloudDingTalk();

// Feishu
services.AddMudFeishu();

接口概览

// 门面接口 — 聚合四个子服务
public interface IImPlatform
{
    IMessageSender Notification { get; }
    IApprovalHandler Approval { get; }
    IWebhookHandler Webhook { get; }
    IUserMappingStore UserMapping { get; }
    string Platform { get; }
}

// 消息通知
public interface IMessageSender
{
    Task<string> SendAsync(ImMessage message, CancellationToken ct = default);
    Task<string> SendCardAsync(string targetId, ApprovalCardData data, CancellationToken ct = default);
    Task<bool> RevokeAsync(string messageId, CancellationToken ct = default);
}

// 审批管理
public interface IApprovalHandler
{
    Task<string> StartAsync(ApprovalRequest request, CancellationToken ct = default);
    Task<ApprovalStatus> QueryStatusAsync(string instanceId, CancellationToken ct = default);
    Task HandleCallbackAsync(ApprovalCallback callback, CancellationToken ct = default);
}

// Webhook 回调处理
public interface IWebhookHandler
{
    Task<TResult> HandleAsync<TResult>(string platform, string rawBody,
        IReadOnlyDictionary<string, string> headers, CancellationToken ct = default);
}

// 用户 ID 映射
public interface IUserMappingStore
{
    Task<string> ToPlatformIdAsync(string erpUserId, string platform, CancellationToken ct = default);
    Task<string> ToErpIdAsync(string platformUserId, string platform, CancellationToken ct = default);
    Task SyncAsync(CancellationToken ct = default);
}

DTO 模型

// 消息
public record ImMessage(
    ImTargetType TargetType,    // User / Group
    string TargetId,
    ImMessageType Type,         // Text / Markdown / Card
    string Title,
    string Content,
    IReadOnlyList<ImAction>? Actions
);

// 审批请求
public record ApprovalRequest(
    string BizKey,              // ERP 业务单据号
    string Title,
    string Description,
    decimal? Amount,
    string InitiatorId,
    IReadOnlyList<string> ApproverIds,
    IReadOnlyList<ApprovalFormField>? FormFields
);

// 审批回调
public abstract record ApprovalCallback(
    string Platform,
    string InstanceId,
    string BizKey,
    ApprovalStatus Status,      // Pending / Approved / Rejected / Canceled
    string? Comment,
    string OperatorId
);

配置

[Options("Integration:Im")]
public class ImPlatformOptions
{
    public string AppId { get; set; }
    public string AppSecret { get; set; }
    public string? WebhookUrl { get; set; }
}

文档

  • 架构设计: docs/im-abstraction-layer-design.md
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Galosys.Foundation.Integration.Im.Abstractions:

Package Downloads
Galosys.Foundation.Mud.Feishu

Galosys.Foundation快速开发库

Galosys.Foundation.AlibabaCloud.Sdk.DingTalk

Galosys.Foundation快速开发库

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
26.7.31.1 0 7/31/2026
26.7.30.1 39 7/30/2026
26.7.29.1 53 7/29/2026
26.7.28.1 87 7/28/2026
26.7.26.2 104 7/26/2026
26.7.26.1 98 7/25/2026
26.7.25.1 106 7/25/2026
26.7.24.2 112 7/24/2026
26.7.24.1 121 7/24/2026
26.7.22.1 118 7/23/2026
26.7.21.1 107 7/21/2026
26.7.20.2 112 7/20/2026
26.7.20.1 111 7/20/2026
26.7.19.3 106 7/19/2026