Browse Source
- 新增通讯录应用集成模块,通讯录相关接口事件移动到通讯录模块 - 新增办公应用集成模块,办公应用相关接口事件移动到办公模块 - 新增部分单元测试模块pull/1393/head
303 changed files with 9012 additions and 302 deletions
2
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work.ExternalContact/LINGYUN/Abp/WeChat/Work/ExternalContact/Models/ExternalAttributeDeserializeFactory.cs → aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work.Common/LINGYUN/Abp/WeChat/Work/Common/Members/Models/ExternalAttributeDeserializeFactory.cs
2
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work.ExternalContact/LINGYUN/Abp/WeChat/Work/ExternalContact/Models/ExternalAttributeDeserializeFactory.cs → aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work.Common/LINGYUN/Abp/WeChat/Work/Common/Members/Models/ExternalAttributeDeserializeFactory.cs
@ -1,6 +1,6 @@ |
|||
using System.ComponentModel; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.ExternalContact.Models; |
|||
namespace LINGYUN.Abp.WeChat.Work.Common.Members.Models; |
|||
/// <summary>
|
|||
/// 属性类型
|
|||
/// </summary>
|
|||
@ -0,0 +1,25 @@ |
|||
using System.ComponentModel; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Common.Members.Models; |
|||
/// <summary>
|
|||
/// 性别
|
|||
/// </summary>
|
|||
[Description("性别")] |
|||
public enum Gender |
|||
{ |
|||
/// <summary>
|
|||
/// 未知
|
|||
/// </summary>
|
|||
[Description("未知")] |
|||
None = 0, |
|||
/// <summary>
|
|||
/// 男性
|
|||
/// </summary>
|
|||
[Description("男性")] |
|||
Male = 1, |
|||
/// <summary>
|
|||
/// 女性
|
|||
/// </summary>
|
|||
[Description("女性")] |
|||
FeMale = 2, |
|||
} |
|||
@ -1,7 +1,7 @@ |
|||
using System.Collections.Generic; |
|||
using System.Xml.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Common.Messages.Models; |
|||
namespace LINGYUN.Abp.WeChat.Work.Common.Members.Models; |
|||
|
|||
[XmlRoot("Item")] |
|||
public class MemberExtendAttribute |
|||
@ -1,6 +1,6 @@ |
|||
using System.ComponentModel; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.ExternalContact.Models; |
|||
namespace LINGYUN.Abp.WeChat.Work.Common.Members.Models; |
|||
/// <summary>
|
|||
/// 视频号状态
|
|||
/// </summary>
|
|||
@ -0,0 +1,62 @@ |
|||
using System; |
|||
|
|||
namespace Newtonsoft.Json; |
|||
|
|||
#nullable enable |
|||
public class EnumToNumberStringConverter<T> : JsonConverter where T : struct, Enum |
|||
{ |
|||
public override bool CanConvert(Type objectType) |
|||
{ |
|||
return objectType == typeof(T?); |
|||
} |
|||
|
|||
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) |
|||
{ |
|||
if (reader.TokenType == JsonToken.Null) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
try |
|||
{ |
|||
if (reader.TokenType == JsonToken.String) |
|||
{ |
|||
var stringValue = reader.Value?.ToString(); |
|||
if (string.IsNullOrEmpty(stringValue)) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
if (int.TryParse(stringValue, out var intValue)) |
|||
{ |
|||
return (T?)Enum.ToObject(typeof(T), intValue); |
|||
} |
|||
} |
|||
else if (reader.TokenType == JsonToken.Integer) |
|||
{ |
|||
return (T?)Enum.ToObject(typeof(T), Convert.ToInt32(reader.Value)); |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw new JsonSerializationException($"Error converting value {reader.Value} to type '{objectType}'.", ex); |
|||
} |
|||
|
|||
throw new JsonSerializationException($"Unexpected token {reader.TokenType} when parsing enum."); |
|||
} |
|||
|
|||
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) |
|||
{ |
|||
if (value == null) |
|||
{ |
|||
writer.WriteNull(); |
|||
} |
|||
else |
|||
{ |
|||
var enumValue = (T)value; |
|||
writer.WriteValue(Convert.ToInt32(enumValue).ToString()); |
|||
} |
|||
} |
|||
} |
|||
#nullable disable |
|||
|
|||
@ -0,0 +1,31 @@ |
|||
using System; |
|||
|
|||
namespace Newtonsoft.Json; |
|||
|
|||
public class IntToBoolConverter : JsonConverter |
|||
{ |
|||
public override bool CanConvert(Type objectType) |
|||
{ |
|||
return objectType == typeof(bool); |
|||
} |
|||
|
|||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) |
|||
{ |
|||
switch (reader.TokenType) |
|||
{ |
|||
case JsonToken.Integer: |
|||
var value = (long)reader.Value; |
|||
return value == 1; |
|||
case JsonToken.Boolean: |
|||
return (bool)reader.Value; |
|||
default: |
|||
throw new JsonSerializationException($"Unexpected token {reader.TokenType} when parsing bool."); |
|||
} |
|||
} |
|||
|
|||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) |
|||
{ |
|||
var boolValue = (bool)value; |
|||
writer.WriteValue(boolValue ? 1 : 0); |
|||
} |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
namespace System.Text.Json.Serialization; |
|||
|
|||
#nullable enable |
|||
public class EnumToNumberStringConverter<T> : JsonConverter<T?> where T : struct, Enum |
|||
{ |
|||
public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) |
|||
{ |
|||
if (reader.TokenType == JsonTokenType.Null) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
if (reader.TokenType == JsonTokenType.String) |
|||
{ |
|||
var stringValue = reader.GetString(); |
|||
if (string.IsNullOrEmpty(stringValue)) |
|||
{ |
|||
return null; |
|||
} |
|||
if (int.TryParse(stringValue, out var intValue)) |
|||
{ |
|||
return (T)Enum.ToObject(typeof(T), intValue); |
|||
} |
|||
} |
|||
else if (reader.TokenType == JsonTokenType.Number) |
|||
{ |
|||
return (T)Enum.ToObject(typeof(T), reader.GetInt32()); |
|||
} |
|||
|
|||
throw new JsonException($"Unable to convert value to enum {typeof(T).Name}"); |
|||
} |
|||
|
|||
public override void Write(Utf8JsonWriter writer, T? value, JsonSerializerOptions options) |
|||
{ |
|||
if (value == null) |
|||
{ |
|||
writer.WriteNullValue(); |
|||
} |
|||
else |
|||
{ |
|||
writer.WriteStringValue(Convert.ToInt32(value).ToString()); |
|||
} |
|||
} |
|||
} |
|||
#nullable disable |
|||
@ -1,4 +1,4 @@ |
|||
using LINGYUN.Abp.WeChat.Work.ExternalContact.Models; |
|||
using LINGYUN.Abp.WeChat.Work.Common.Members.Models; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace System.Text.Json.Serialization; |
|||
@ -0,0 +1,26 @@ |
|||
namespace System.Text.Json.Serialization; |
|||
|
|||
public class IntToBoolJsonConverter : JsonConverter<bool> |
|||
{ |
|||
public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) |
|||
{ |
|||
switch (reader.TokenType) |
|||
{ |
|||
case JsonTokenType.Number: |
|||
var intValue = reader.GetInt64(); |
|||
return intValue == 1; |
|||
case JsonTokenType.True: |
|||
return true; |
|||
case JsonTokenType.False: |
|||
return false; |
|||
} |
|||
|
|||
throw new JsonException($"Cannot convert {reader.TokenType} to bool."); |
|||
} |
|||
|
|||
public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options) |
|||
{ |
|||
writer.WriteNumberValue(value ? 1 : 0); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,27 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0;net9.0</TargetFrameworks> |
|||
<AssemblyName>LINGYUN.Abp.WeChat.Work.Contacts</AssemblyName> |
|||
<PackageId>LINGYUN.Abp.WeChat.Work.Contacts</PackageId> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<GenerateDocumentationFile>True</GenerateDocumentationFile> |
|||
<Nullable>enable</Nullable> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Remove="LINGYUN\Abp\WeChat\Work\Contacts\Localization\Resources\*.json" /> |
|||
<EmbeddedResource Include="LINGYUN\Abp\WeChat\Work\Contacts\Localization\Resources\*.json" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.WeChat.Work\LINGYUN.Abp.WeChat.Work.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,45 @@ |
|||
using LINGYUN.Abp.WeChat.Common; |
|||
using LINGYUN.Abp.WeChat.Common.Messages; |
|||
using LINGYUN.Abp.WeChat.Work.Common.Messages; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Messages.Models; |
|||
using LINGYUN.Abp.WeChat.Work.Localization; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts; |
|||
/// <summary>
|
|||
/// 企业微信通讯录模块
|
|||
/// </summary>
|
|||
[DependsOn(typeof(AbpWeChatWorkModule))] |
|||
public class AbpWeChatWorkContactModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpWeChatWorkMessageResolveOptions>(options => |
|||
{ |
|||
options.MapEvent("change_contact", context => |
|||
{ |
|||
var changeType = context.GetMessageData("ChangeType"); |
|||
return changeType switch |
|||
{ |
|||
"create_user" => context.GetWeChatMessage<CreateUserEvent>(), |
|||
"update_user" => context.GetWeChatMessage<UpdateUserEvent>(), |
|||
"delete_user" => context.GetWeChatMessage<DeleteUserEvent>(), |
|||
"create_party" => context.GetWeChatMessage<CreateDepartmentEvent>(), |
|||
"update_party" => context.GetWeChatMessage<UpdateDepartmentEvent>(), |
|||
"delete_party" => context.GetWeChatMessage<DeleteDepartmentEvent>(), |
|||
"update_tag" => context.GetWeChatMessage<UserTagChangeEvent>(), |
|||
_ => throw new AbpWeChatException($"Contact change event {changeType} is not mounted!"), |
|||
}; |
|||
}); |
|||
options.MapEvent("batch_job_result", context => context.GetWeChatMessage<BatchJobResultEvent>()); |
|||
}); |
|||
|
|||
Configure<AbpLocalizationOptions>(options => |
|||
{ |
|||
options.Resources |
|||
.Get<WeChatWorkResource>() |
|||
.AddVirtualJson("/LINGYUN/Abp/WeChat/Work/Contacts/Localization/Resources"); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,87 @@ |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Departments.Request; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Departments.Response; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Departments; |
|||
/// <summary>
|
|||
/// 企业微信部门管理接口
|
|||
/// </summary>
|
|||
public interface IWeChatWorkDepartmentProvider |
|||
{ |
|||
/// <summary>
|
|||
/// 获取部门列表
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90208" />
|
|||
/// </remarks>
|
|||
/// <param name="request">请求参数</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkGetDepartmentListResponse> GetDepartmentListAsync( |
|||
WeChatWorkGetDepartmentListRequest request, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 获取子部门ID列表
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/95350" />
|
|||
/// </remarks>
|
|||
/// <param name="request">请求参数</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkGetSubDepartmentListResponse> GetSubDepartmentListAsync( |
|||
WeChatWorkGetSubDepartmentListRequest request, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 获取单个部门详情
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/95351" />
|
|||
/// </remarks>
|
|||
/// <param name="request">请求参数</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkGetDepartmentResponse> GetDepartmentAsync( |
|||
WeChatWorkGetDepartmentRequest request, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 创建部门
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 此接口使用通讯录应用Token<br />
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90205" />
|
|||
/// </remarks>
|
|||
/// <param name="request">请求参数</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkCreateDepartmentResponse> CreateDepartmentAsync( |
|||
WeChatWorkCreateDepartmentRequest request, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 更新部门
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 此接口使用通讯录应用Token<br />
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90206" />
|
|||
/// </remarks>
|
|||
/// <param name="request">请求参数</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkResponse> UpdateDepartmentAsync( |
|||
WeChatWorkUpdateDepartmentRequest request, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 删除部门
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 此接口使用通讯录应用Token<br />
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90207" />
|
|||
/// </remarks>
|
|||
/// <param name="request">请求参数</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkResponse> DeleteDepartmentAsync( |
|||
WeChatWorkDeleteDepartmentRequest request, |
|||
CancellationToken cancellationToken = default); |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Departments.Models; |
|||
/// <summary>
|
|||
/// 部门
|
|||
/// </summary>
|
|||
public class Department |
|||
{ |
|||
/// <summary>
|
|||
/// 部门名称
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("name")] |
|||
[JsonPropertyName("name")] |
|||
public string Name { get; set; } |
|||
/// <summary>
|
|||
/// 部门id
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("id")] |
|||
[JsonPropertyName("id")] |
|||
public string Id { get; set; } |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Departments.Models; |
|||
/// <summary>
|
|||
/// 部门详情
|
|||
/// </summary>
|
|||
public class DepartmentInfo : Department |
|||
{ |
|||
/// <summary>
|
|||
/// 部门英文名称
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("name_en")] |
|||
[JsonPropertyName("name_en")] |
|||
public string? NameEn { get; set; } |
|||
/// <summary>
|
|||
/// 部门负责人的UserID,返回在应用可见范围内的部门负责人列表
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("department_leader")] |
|||
[JsonPropertyName("department_leader")] |
|||
public string[] DepartmentLeader { get; set; } |
|||
/// <summary>
|
|||
/// 父部门id。根部门为1
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("parentid")] |
|||
[JsonPropertyName("parentid")] |
|||
public int ParentId { get; set; } |
|||
/// <summary>
|
|||
/// 在父部门中的次序值。order值大的排序靠前。值范围是[0, 2^32)
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("order")] |
|||
[JsonPropertyName("order")] |
|||
public int Order { get; set; } |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Departments.Models; |
|||
/// <summary>
|
|||
/// 子部门
|
|||
/// </summary>
|
|||
public class SubDepartment |
|||
{ |
|||
/// <summary>
|
|||
/// 部门id
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("id")] |
|||
[JsonPropertyName("id")] |
|||
public string Id { get; set; } |
|||
/// <summary>
|
|||
/// 父部门id。根部门为1。
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("parentid")] |
|||
[JsonPropertyName("parentid")] |
|||
public int ParentId { get; set; } |
|||
/// <summary>
|
|||
/// 在父部门中的次序值。order值大的排序靠前。值范围是[0, 2^32)。
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("order")] |
|||
[JsonPropertyName("order")] |
|||
public int Order { get; set; } |
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
using System.Xml.Linq; |
|||
using Volo.Abp; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Departments.Request; |
|||
/// <summary>
|
|||
/// 创建部门请求参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90205" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkCreateDepartmentRequest : WeChatWorkRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 部门名称。同一个层级的部门名称不能重复。长度限制为1~64个UTF-8字符
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("name")] |
|||
[JsonPropertyName("name")] |
|||
public string Name { get; } |
|||
/// <summary>
|
|||
/// 英文名称。同一个层级的部门名称不能重复。需要在管理后台开启多语言支持才能生效。长度限制为1~64个字符
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("name_en")] |
|||
[JsonPropertyName("name_en")] |
|||
public string? NameEn { get; set; } |
|||
/// <summary>
|
|||
/// 父部门id,32位整型
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("parentid")] |
|||
[JsonPropertyName("parentid")] |
|||
public int ParentId { get; } |
|||
/// <summary>
|
|||
/// 在父部门中的次序值。order值大的排序靠前。有效的值范围是[0, 2^32)
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("order")] |
|||
[JsonPropertyName("order")] |
|||
public int? Order { get; set; } |
|||
/// <summary>
|
|||
/// 部门id,32位整型,指定时必须大于1。若不填该参数,将自动生成id
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("id")] |
|||
[JsonPropertyName("id")] |
|||
public int? Id { get; set; } |
|||
public WeChatWorkCreateDepartmentRequest(string name, int parentId = 0, string? nameEn = null, int? order = null, int? id = null) |
|||
{ |
|||
Check.NotNullOrWhiteSpace(name, nameof(name), 64, 1); |
|||
Check.Length(nameEn, nameof(nameEn), 64, 1); |
|||
|
|||
Name = name; |
|||
NameEn = nameEn; |
|||
ParentId = parentId; |
|||
Order = order; |
|||
Id = id; |
|||
} |
|||
|
|||
protected override void Validate() |
|||
{ |
|||
Check.NotNullOrWhiteSpace(Name, nameof(Name), 64, 1); |
|||
Check.Length(NameEn, nameof(NameEn), 64, 1); |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Departments.Request; |
|||
/// <summary>
|
|||
/// 删除部门请求参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90207" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkDeleteDepartmentRequest : WeChatWorkRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 部门id
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("id")] |
|||
[JsonPropertyName("id")] |
|||
public int Id { get; } |
|||
public WeChatWorkDeleteDepartmentRequest(int id) |
|||
{ |
|||
Id = id; |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Departments.Request; |
|||
/// <summary>
|
|||
/// 获取部门列表请求参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90208" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkGetDepartmentListRequest : WeChatWorkRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 部门id。获取指定部门及其下的子部门(以及子部门的子部门等等,递归)。 如果不填,默认获取全量组织架构
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("id")] |
|||
[JsonPropertyName("id")] |
|||
public int? Id { get; } |
|||
public WeChatWorkGetDepartmentListRequest(int? id = null) |
|||
{ |
|||
Id = id; |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Departments.Request; |
|||
/// <summary>
|
|||
/// 获取单个部门详情请求参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90207" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkGetDepartmentRequest : WeChatWorkRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 部门id
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("id")] |
|||
[JsonPropertyName("id")] |
|||
public int Id { get; } |
|||
public WeChatWorkGetDepartmentRequest(int id) |
|||
{ |
|||
Id = id; |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Departments.Request; |
|||
/// <summary>
|
|||
/// 获取子部门ID列表请求参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/95350" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkGetSubDepartmentListRequest : WeChatWorkRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 部门id。获取指定部门及其下的子部门(以及子部门的子部门等等,递归)。 如果不填,默认获取全量组织架构
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("id")] |
|||
[JsonPropertyName("id")] |
|||
public int? Id { get; } |
|||
public WeChatWorkGetSubDepartmentListRequest(int? id = null) |
|||
{ |
|||
Id = id; |
|||
} |
|||
} |
|||
@ -0,0 +1,60 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
using Volo.Abp; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Departments.Request; |
|||
/// <summary>
|
|||
/// 更新部门请求参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90205" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkUpdateDepartmentRequest : WeChatWorkRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 部门id
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("id")] |
|||
[JsonPropertyName("id")] |
|||
public int Id { get; } |
|||
/// <summary>
|
|||
/// 部门名称。长度限制为1~64个UTF-8字符
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("name")] |
|||
[JsonPropertyName("name")] |
|||
public string? Name { get; set; } |
|||
/// <summary>
|
|||
/// 英文名称,需要在管理后台开启多语言支持才能生效。长度限制为1~64个字符
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("name_en")] |
|||
[JsonPropertyName("name_en")] |
|||
public string? NameEn { get; set; } |
|||
/// <summary>
|
|||
/// 父部门id
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("parentid")] |
|||
[JsonPropertyName("parentid")] |
|||
public int? ParentId { get; set; } |
|||
/// <summary>
|
|||
/// 在父部门中的次序值。order值大的排序靠前。有效的值范围是[0, 2^32)
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("order")] |
|||
[JsonPropertyName("order")] |
|||
public int? Order { get; set; } |
|||
public WeChatWorkUpdateDepartmentRequest(int id) |
|||
{ |
|||
Id = id; |
|||
} |
|||
|
|||
protected override void Validate() |
|||
{ |
|||
Check.NotNullOrWhiteSpace(Name, nameof(Name), 64, 1); |
|||
Check.Length(NameEn, nameof(NameEn), 64, 1); |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Departments.Response; |
|||
/// <summary>
|
|||
/// 创建部门响应参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90205" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkCreateDepartmentResponse : WeChatWorkResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 创建的部门id
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("id")] |
|||
[JsonPropertyName("id")] |
|||
public int Id { get; set; } |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using JetBrains.Annotations; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Departments.Models; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Departments.Response; |
|||
/// <summary>
|
|||
/// 获取部门列表响应参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90208" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkGetDepartmentListResponse : WeChatWorkResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 部门列表数据
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("department")] |
|||
[JsonPropertyName("department")] |
|||
public DepartmentInfo[] Department { get; set; } |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using JetBrains.Annotations; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Departments.Models; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Departments.Response; |
|||
/// <summary>
|
|||
/// 获取单个部门详情响应参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/95351" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkGetDepartmentResponse : WeChatWorkResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 部门详情
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("department")] |
|||
[JsonPropertyName("department")] |
|||
public DepartmentInfo Department { get; set; } |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using JetBrains.Annotations; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Departments.Models; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Departments.Response; |
|||
/// <summary>
|
|||
/// 获取子部门ID列表响应参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/95350" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkGetSubDepartmentListResponse : WeChatWorkResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 部门列表数据。
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("department_id")] |
|||
[JsonPropertyName("department_id")] |
|||
public SubDepartment[] Department { get; set; } |
|||
} |
|||
@ -0,0 +1,108 @@ |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Departments.Request; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Departments.Response; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Features; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Token; |
|||
using LINGYUN.Abp.WeChat.Work.Token; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using System.Net.Http; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Features; |
|||
using Volo.Abp.Json; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Departments; |
|||
|
|||
[RequiresFeature(WeChatWorkContactsFeatureNames.Enable)] |
|||
public class WeChatWorkDepartmentProvider : IWeChatWorkDepartmentProvider, ISingletonDependency |
|||
{ |
|||
protected IJsonSerializer JsonSerializer { get; } |
|||
protected IHttpClientFactory HttpClientFactory { get; } |
|||
protected IWeChatWorkTokenProvider WeChatWorkTokenProvider { get; } |
|||
protected IWeChatWorkContactTokenProvider WeChatWorkContactTokenProvider { get; } |
|||
|
|||
public WeChatWorkDepartmentProvider( |
|||
IJsonSerializer jsonSerializer, |
|||
IHttpClientFactory httpClientFactory, |
|||
IWeChatWorkTokenProvider weChatWorkTokenProvider, |
|||
IWeChatWorkContactTokenProvider weChatWorkContactTokenProvider) |
|||
{ |
|||
JsonSerializer = jsonSerializer; |
|||
HttpClientFactory = httpClientFactory; |
|||
WeChatWorkTokenProvider = weChatWorkTokenProvider; |
|||
WeChatWorkContactTokenProvider = weChatWorkContactTokenProvider; |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkGetDepartmentListResponse> GetDepartmentListAsync( |
|||
WeChatWorkGetDepartmentListRequest request, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotNull(request, nameof(request)); |
|||
|
|||
var token = await WeChatWorkTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.GetDepartmentListAsync(token.AccessToken, request, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkGetSubDepartmentListResponse> GetSubDepartmentListAsync( |
|||
WeChatWorkGetSubDepartmentListRequest request, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotNull(request, nameof(request)); |
|||
|
|||
var token = await WeChatWorkTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.GetSubDepartmentListAsync(token.AccessToken, request, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkGetDepartmentResponse> GetDepartmentAsync( |
|||
WeChatWorkGetDepartmentRequest request, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotNull(request, nameof(request)); |
|||
|
|||
var token = await WeChatWorkTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.GetDepartmentAsync(token.AccessToken, request, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkCreateDepartmentResponse> CreateDepartmentAsync( |
|||
WeChatWorkCreateDepartmentRequest request, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotNull(request, nameof(request)); |
|||
|
|||
var token = await WeChatWorkContactTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.CreateDepartmentAsync(token.AccessToken, request, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkResponse> UpdateDepartmentAsync( |
|||
WeChatWorkUpdateDepartmentRequest request, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotNull(request, nameof(request)); |
|||
|
|||
var token = await WeChatWorkContactTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.UpdateDepartmentAsync(token.AccessToken, request, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkResponse> DeleteDepartmentAsync( |
|||
WeChatWorkDeleteDepartmentRequest request, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotNull(request, nameof(request)); |
|||
|
|||
var token = await WeChatWorkContactTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.DeleteDepartmentAsync(token.AccessToken, request, cancellationToken); |
|||
} |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
using LINGYUN.Abp.WeChat.Work.Features; |
|||
using LINGYUN.Abp.WeChat.Work.Localization; |
|||
using Volo.Abp.Features; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Validation.StringValues; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Features; |
|||
public class WeChatWorkContactsFeatureDefinitionProvider : FeatureDefinitionProvider |
|||
{ |
|||
public override void Define(IFeatureDefinitionContext context) |
|||
{ |
|||
var weChatFeature = context.GetGroupOrNull(WeChatWorkFeatureNames.GroupName); |
|||
if (weChatFeature == null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var group = weChatFeature.AddFeature(WeChatWorkContactsFeatureNames.GroupName); |
|||
group.CreateChild( |
|||
WeChatWorkContactsFeatureNames.Enable, |
|||
defaultValue: "false", |
|||
displayName: L("Features:ContactsEnable"), |
|||
description: L("Features:ContactsEnableDesc"), |
|||
valueType: new ToggleStringValueType(new BooleanValueValidator())); |
|||
} |
|||
|
|||
private static LocalizableString L(string name) |
|||
{ |
|||
return LocalizableString.Create<WeChatWorkResource>(name); |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using LINGYUN.Abp.WeChat.Work.Features; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Features; |
|||
/// <summary>
|
|||
/// 企业微信通讯录模块功能
|
|||
/// </summary>
|
|||
public static class WeChatWorkContactsFeatureNames |
|||
{ |
|||
public const string GroupName = WeChatWorkFeatureNames.GroupName + ".Contacts"; |
|||
/// <summary>
|
|||
/// 启用企业微信通讯录
|
|||
/// </summary>
|
|||
public const string Enable = GroupName + ".Enable"; |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
{ |
|||
"culture": "en", |
|||
"texts": { |
|||
"Features:ContactsEnable": "Enable Contacts", |
|||
"Features:ContactsEnableDesc": "Enable the ability to provide the application with an Enterprise wechat contacts interface.", |
|||
"DisplayName:WeChatWorkContact.Secret": "Contact Secret", |
|||
"Description:WeChatWorkContact.Secret": "Secretfor the address contact application. Some contact interfaces require a contact synchronization secret." |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
{ |
|||
"culture": "zh-Hans", |
|||
"texts": { |
|||
"Features:ContactsEnable": "启用通讯录", |
|||
"Features:ContactsEnableDesc": "启用以使应用拥有企业微信通讯录接口的能力.", |
|||
"DisplayName:WeChatWorkContact.Secret": "通讯录访问密钥", |
|||
"Description:WeChatWorkContact.Secret": "通讯录应用访问密钥,部分通讯录接口需要通讯录同步secret." |
|||
} |
|||
} |
|||
@ -0,0 +1,199 @@ |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Members.Request; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Members.Response; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members; |
|||
/// <summary>
|
|||
/// 企业微信成员管理接口
|
|||
/// </summary>
|
|||
public interface IWeChatWorkMemberProvider |
|||
{ |
|||
/// <summary>
|
|||
/// 读取成员
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90196" />
|
|||
/// </remarks>
|
|||
/// <param name="userId">成员UserID。对应管理端的账号,企业内必须唯一。不区分大小写,长度为1~64个字节</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkGetMemberResponse> GetMemberAsync( |
|||
string userId, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 创建成员
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 此接口使用通讯录应用Token<br />
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90195" />
|
|||
/// </remarks>
|
|||
/// <param name="request">请求参数</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkCreateMemberResponse> CreateMemberAsync( |
|||
WeChatWorkCreateMemberRequest request, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 更新成员
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 此接口使用通讯录应用Token<br />
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90197" />
|
|||
/// </remarks>
|
|||
/// <param name="request">请求参数</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkResponse> UpdateMemberAsync( |
|||
WeChatWorkUpdateMemberRequest request, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 删除成员
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 此接口使用通讯录应用Token<br />
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90198" />
|
|||
/// </remarks>
|
|||
/// <param name="userId">成员UserID。对应管理端的账号</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkResponse> DeleteMemberAsync( |
|||
string userId, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 批量删除成员
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 此接口使用通讯录应用Token<br />
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90199" />
|
|||
/// </remarks>
|
|||
/// <param name="request">请求参数</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkResponse> BulkDeleteMemberAsync( |
|||
WeChatWorkBulkDeleteMemberRequest request, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 获取部门成员
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90200" />
|
|||
/// </remarks>
|
|||
/// <param name="departmentId">获取的部门id</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkGetSimpleMemberListResponse> GetSimpleMemberListAsync( |
|||
int departmentId, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 获取部门成员详情
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90201" />
|
|||
/// </remarks>
|
|||
/// <param name="departmentId">获取的部门id</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkGetMemberListResponse> GetMemberListAsync( |
|||
int departmentId, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// userid转openid
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90202" />
|
|||
/// </remarks>
|
|||
/// <param name="request">请求参数</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkConvertToOpenIdResponse> ConvertToOpenIdAsync( |
|||
WeChatWorkConvertToOpenIdRequest request, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// openid转userid
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90202" />
|
|||
/// </remarks>
|
|||
/// <param name="request">请求参数</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkConvertToUserIdResponse> ConvertToUserIdAsync( |
|||
WeChatWorkConvertToUserIdRequest request, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 登录二次验证
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90203" />
|
|||
/// </remarks>
|
|||
/// <param name="userId">成员UserID。对应管理端的账号</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkResponse> AuthSuccessAsync( |
|||
string userId, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 邀请成员
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90975" />
|
|||
/// </remarks>
|
|||
/// <param name="request">请求参数</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkBulkInviteMemberResponse> BulkInviteMemberAsync( |
|||
WeChatWorkBulkInviteMemberRequest request, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 获取加入企业二维码
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 此接口使用通讯录应用Token<br />
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/91714" />
|
|||
/// </remarks>
|
|||
/// <param name="sizeType">二维码尺寸类型</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkGetJoinQrCodeResponse> GetJoinQrCodeAsync( |
|||
QrCodeSizeType sizeType, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 手机号获取userid
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/95402" />
|
|||
/// </remarks>
|
|||
/// <param name="request">请求参数</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkGetUserIdResponse> GetUserIdByMobileAsync( |
|||
WeChatWorkGetUserIdByMobileRequest request, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 邮箱获取userid
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/95895" />
|
|||
/// </remarks>
|
|||
/// <param name="request">请求参数</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkGetUserIdResponse> GetUserIdByEmailAsync( |
|||
WeChatWorkGetUserIdByEmailRequest request, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 获取成员ID列表
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 此接口使用通讯录应用Token<br />
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/96067" />
|
|||
/// </remarks>
|
|||
/// <param name="request">请求参数</param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<WeChatWorkGetUserIdListResponse> GetUserIdListAsync( |
|||
WeChatWorkGetUserIdListRequest request, |
|||
CancellationToken cancellationToken = default); |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
using System.ComponentModel; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
/// <summary>
|
|||
/// 属性类型
|
|||
/// </summary>
|
|||
[Description("属性类型")] |
|||
public enum AttributeType |
|||
{ |
|||
/// <summary>
|
|||
/// 文本
|
|||
/// </summary>
|
|||
[Description("文本")] |
|||
Text = 0, |
|||
/// <summary>
|
|||
/// 网页
|
|||
/// </summary>
|
|||
[Description("网页")] |
|||
Web = 1 |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
/// <summary>
|
|||
/// 部门成员
|
|||
/// </summary>
|
|||
public class DepartmentMember |
|||
{ |
|||
/// <summary>
|
|||
/// 成员UserID。对应管理端的账号
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("userid")] |
|||
[JsonPropertyName("userid")] |
|||
public string UserId { get; set; } |
|||
/// <summary>
|
|||
/// 成员名称,代开发自建应用需要管理员授权才返回
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("name")] |
|||
[JsonPropertyName("name")] |
|||
public string Name { get; set; } |
|||
/// <summary>
|
|||
/// 成员所属部门列表。列表项为部门ID,32位整型
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("department")] |
|||
[JsonPropertyName("department")] |
|||
public int[]? Department { get; set; } |
|||
/// <summary>
|
|||
/// 全局唯一
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("open_userid")] |
|||
[JsonPropertyName("open_userid")] |
|||
public string OpenUserId { get; set; } |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
/// <summary>
|
|||
/// 用户-部门关系
|
|||
/// </summary>
|
|||
public class DepartmentUser |
|||
{ |
|||
/// <summary>
|
|||
/// 用户userid,当用户在多个部门下时会有多条记录
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("userid")] |
|||
[JsonPropertyName("userid")] |
|||
public string UserId { get; set; } |
|||
/// <summary>
|
|||
/// 用户所属部门
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("department")] |
|||
[JsonPropertyName("department")] |
|||
public int Department { get; set; } |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
using System.ComponentModel; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
/// <summary>
|
|||
/// 邮箱类型
|
|||
/// </summary>
|
|||
[Description("邮箱类型")] |
|||
public enum EmailType |
|||
{ |
|||
/// <summary>
|
|||
/// 企业邮箱
|
|||
/// </summary>
|
|||
[Description("企业邮箱")] |
|||
BizEmail = 1, |
|||
/// <summary>
|
|||
/// 个人邮箱
|
|||
/// </summary>
|
|||
[Description("个人邮箱")] |
|||
PersonEmail = 2, |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
/// <summary>
|
|||
/// 成员扩展属性
|
|||
/// </summary>
|
|||
public abstract class MemberAttribute |
|||
{ |
|||
/// <summary>
|
|||
/// 属性名称: 在新增或者更新操作时,需要先确保在管理端有创建该属性,否则会忽略
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("name")] |
|||
[JsonPropertyName("name")] |
|||
public string Name { get; set; } |
|||
/// <summary>
|
|||
/// 属性类型
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("type")] |
|||
[JsonPropertyName("type")] |
|||
public AttributeType Type { get; set; } |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
using Newtonsoft.Json.Linq; |
|||
using System; |
|||
using System.Text.Json; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
internal static class MemberAttributeDeserializeFactory |
|||
{ |
|||
/// <summary>
|
|||
/// 根据属性类型创建属性(System.Text.Json)
|
|||
/// </summary>
|
|||
public static MemberAttribute CreateExternalAttribute(AttributeType type, JsonElement configElement) |
|||
{ |
|||
return type switch |
|||
{ |
|||
AttributeType.Text => JsonSerializer.Deserialize<MemberTextAttribute>(configElement.GetRawText())!, |
|||
AttributeType.Web => JsonSerializer.Deserialize<MemberWebAttribute>(configElement.GetRawText())!, |
|||
_ => throw new NotSupportedException($"Attribute type {type} is not supported for the time being"), |
|||
}; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 根据属性类型创建属性(Newtonsoft.Json)
|
|||
/// </summary>
|
|||
public static MemberAttribute CreateExternalAttribute(AttributeType type, JToken configToken) |
|||
{ |
|||
return type switch |
|||
{ |
|||
AttributeType.Text => configToken.ToObject<MemberTextAttribute>()!, |
|||
AttributeType.Web => configToken.ToObject<MemberWebAttribute>()!, |
|||
_ => throw new NotSupportedException($"Attribute type {type} is not supported for the time being"), |
|||
}; |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
/// <summary>
|
|||
/// 成员扩展属性
|
|||
/// </summary>
|
|||
public class MemberExternalAttribute |
|||
{ |
|||
/// <summary>
|
|||
/// 扩展属性列表
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("attrs")] |
|||
[JsonPropertyName("attrs")] |
|||
public MemberAttribute[] Attributes { get; set; } |
|||
} |
|||
@ -0,0 +1,173 @@ |
|||
using JetBrains.Annotations; |
|||
using LINGYUN.Abp.WeChat.Work.Common.Members.Models; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
/// <summary>
|
|||
/// 成员详情
|
|||
/// </summary>
|
|||
public class MemberInfo |
|||
{ |
|||
/// <summary>
|
|||
/// 全局唯一
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("open_userid")] |
|||
[JsonPropertyName("open_userid")] |
|||
public string OpenUserId { get; set; } |
|||
/// <summary>
|
|||
/// 成员UserID
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("userid")] |
|||
[JsonPropertyName("userid")] |
|||
public string UserId { get; set; } |
|||
/// <summary>
|
|||
/// 成员名称
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("name")] |
|||
[JsonPropertyName("name")] |
|||
public string Name { get; set; } |
|||
/// <summary>
|
|||
/// 手机号码
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("mobile")] |
|||
[JsonPropertyName("mobile")] |
|||
public string? Mobile { get; set; } |
|||
/// <summary>
|
|||
/// 成员所属部门id列表
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("department")] |
|||
[JsonPropertyName("department")] |
|||
public int[] Department { get; set; } |
|||
/// <summary>
|
|||
/// 主部门
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("main_department")] |
|||
[JsonPropertyName("main_department")] |
|||
public int? MainDepartment { get; set; } |
|||
/// <summary>
|
|||
/// 部门内的排序值,默认为0。数量必须和department一致,数值越大排序越前面。值范围是[0, 2^32)
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("order")] |
|||
[JsonPropertyName("order")] |
|||
public int[]? Order { get; set; } |
|||
/// <summary>
|
|||
/// 员工个人二维码
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("qr_code")] |
|||
[JsonPropertyName("qr_code")] |
|||
public string? QrCode { get; set; } |
|||
/// <summary>
|
|||
/// 职务信息
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("position")] |
|||
[JsonPropertyName("position")] |
|||
public string? Position { get; set; } |
|||
/// <summary>
|
|||
/// 性别
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("gender")] |
|||
[JsonPropertyName("gender")] |
|||
public Gender? Gender { get; set; } |
|||
/// <summary>
|
|||
/// 邮箱
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("email")] |
|||
[JsonPropertyName("email")] |
|||
public string? Email { get; set; } |
|||
/// <summary>
|
|||
/// 企业邮箱
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("biz_mail")] |
|||
[JsonPropertyName("biz_mail")] |
|||
public string? BizEmail { get; set; } |
|||
/// <summary>
|
|||
/// 表示在所在的部门内是否为部门负责人,数量与department一致
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("is_leader_in_dept")] |
|||
[JsonPropertyName("is_leader_in_dept")] |
|||
public int[]? IsLeaderInDept { get; set; } |
|||
/// <summary>
|
|||
/// 直属上级UserID,返回在应用可见范围内的直属上级列表,最多有1个直属上级
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("direct_leader")] |
|||
[JsonPropertyName("direct_leader")] |
|||
public string[]? DirectLeader { get; set; } |
|||
/// <summary>
|
|||
/// 头像url
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("avatar")] |
|||
[JsonPropertyName("avatar")] |
|||
public string? Avatar { get; set; } |
|||
/// <summary>
|
|||
/// 头像缩略图url
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("thumb_avatar")] |
|||
[JsonPropertyName("thumb_avatar")] |
|||
public string? ThumbAvatar { get; set; } |
|||
/// <summary>
|
|||
/// 座机
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("telephone")] |
|||
[JsonPropertyName("telephone")] |
|||
public string? TelePhone { get; set; } |
|||
/// <summary>
|
|||
/// 别名
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("alias")] |
|||
[JsonPropertyName("alias")] |
|||
public string? Alias { get; set; } |
|||
/// <summary>
|
|||
/// 地址
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("address")] |
|||
[JsonPropertyName("address")] |
|||
public string? Address { get; set; } |
|||
/// <summary>
|
|||
/// 激活状态
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("status")] |
|||
[JsonPropertyName("status")] |
|||
public MemberStatus Status { get; set; } |
|||
/// <summary>
|
|||
/// 扩展属性
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("extattr")] |
|||
[JsonPropertyName("extattr")] |
|||
public MemberExternalAttribute? ExternalAttribute { get; set; } |
|||
/// <summary>
|
|||
/// 对外职务,如果设置了该值,则以此作为对外展示的职务,否则以position来展示。
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("external_position")] |
|||
[JsonPropertyName("external_position")] |
|||
public string? ExternalPosition { get; set; } |
|||
/// <summary>
|
|||
/// 外部联系人的自定义展示信息
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("external_profile")] |
|||
[JsonPropertyName("external_profile")] |
|||
public ExternalProfile? ExternalProfile { get; set; } |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
using System.ComponentModel; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
/// <summary>
|
|||
/// 激活状态
|
|||
/// </summary>
|
|||
[Description("激活状态")] |
|||
public enum MemberStatus |
|||
{ |
|||
/// <summary>
|
|||
/// 已激活
|
|||
/// </summary>
|
|||
[Description("已激活")] |
|||
Activated = 1, |
|||
/// <summary>
|
|||
/// 已禁用
|
|||
/// </summary>
|
|||
[Description("已禁用")] |
|||
Disabled = 2, |
|||
/// <summary>
|
|||
/// 未激活
|
|||
/// </summary>
|
|||
[Description("未激活")] |
|||
NotActivated = 4, |
|||
/// <summary>
|
|||
/// 退出企业
|
|||
/// </summary>
|
|||
[Description("退出企业")] |
|||
Exited = 5, |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
/// <summary>
|
|||
/// 文本类型的成员属性
|
|||
/// </summary>
|
|||
public class MemberTextAttribute : MemberAttribute |
|||
{ |
|||
/// <summary>
|
|||
/// 文本
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("text")] |
|||
[JsonPropertyName("text")] |
|||
public MemberTextModel Text { get; set; } |
|||
} |
|||
|
|||
public class MemberTextModel |
|||
{ |
|||
/// <summary>
|
|||
/// 文本
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("value")] |
|||
[JsonPropertyName("value")] |
|||
public string Value { get; set; } |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
/// <summary>
|
|||
/// 网页类型的成员属性
|
|||
/// </summary>
|
|||
public class MemberWebAttribute : MemberAttribute |
|||
{ |
|||
/// <summary>
|
|||
/// 网页
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("web")] |
|||
[JsonPropertyName("web")] |
|||
public MemberWebModel Web { get; set; } |
|||
} |
|||
|
|||
public class MemberWebModel |
|||
{ |
|||
/// <summary>
|
|||
/// 网页的url,必须包含http或者https头
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("url")] |
|||
[JsonPropertyName("url")] |
|||
public string Url { get; set; } |
|||
/// <summary>
|
|||
/// 网页的展示标题,长度限制12个UTF8字符
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("title")] |
|||
[JsonPropertyName("title")] |
|||
public string Title { get; set; } |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
using System.ComponentModel; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
/// <summary>
|
|||
/// 二维码尺寸类型
|
|||
/// </summary>
|
|||
[Description("二维码尺寸类型")] |
|||
public enum QrCodeSizeType |
|||
{ |
|||
/// <summary>
|
|||
/// 171 x 171
|
|||
/// </summary>
|
|||
[Description("171 x 171")] |
|||
Size171 = 1, |
|||
/// <summary>
|
|||
/// 399 x 399
|
|||
/// </summary>
|
|||
[Description("399 x 399")] |
|||
Size399 = 2, |
|||
/// <summary>
|
|||
/// 741 x 741
|
|||
/// </summary>
|
|||
[Description("741 x 741")] |
|||
Size741 = 3, |
|||
/// <summary>
|
|||
/// 2052 x 2052
|
|||
/// </summary>
|
|||
[Description("2052 x 2052")] |
|||
Size2052 = 4, |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Request; |
|||
/// <summary>
|
|||
/// 批量删除成员请求参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90199" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkBulkDeleteMemberRequest : WeChatWorkRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 成员UserID列表。对应管理端的账号。最多支持200个。若存在无效UserID,直接返回错误
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("useridlist")] |
|||
[JsonPropertyName("useridlist")] |
|||
public List<string> UserIdList { get; } |
|||
public WeChatWorkBulkDeleteMemberRequest() :this([]) |
|||
{ |
|||
} |
|||
|
|||
public WeChatWorkBulkDeleteMemberRequest(List<string> userIdList) |
|||
{ |
|||
UserIdList = userIdList; |
|||
} |
|||
|
|||
protected override void Validate() |
|||
{ |
|||
if (UserIdList.Count > 100) |
|||
{ |
|||
throw new ArgumentException("The maximum number of member ids that can be deleted simultaneously is only 200!"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Request; |
|||
/// <summary>
|
|||
/// 邀请成员请求参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90975" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkBulkInviteMemberRequest : WeChatWorkRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 成员ID列表, 最多支持1000个。
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("user")] |
|||
[JsonPropertyName("user")] |
|||
public List<string> User { get; } |
|||
/// <summary>
|
|||
/// 部门ID列表,最多支持100个。
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("party")] |
|||
[JsonPropertyName("party")] |
|||
public List<int> Party { get; } |
|||
/// <summary>
|
|||
/// 标签ID列表,最多支持100个。
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("tag")] |
|||
[JsonPropertyName("tag")] |
|||
public List<int> Tag { get; } |
|||
public WeChatWorkBulkInviteMemberRequest() |
|||
{ |
|||
User = new List<string>(); |
|||
Party = new List<int>(); |
|||
Tag = new List<int>(); |
|||
} |
|||
|
|||
protected override void Validate() |
|||
{ |
|||
if (User.IsNullOrEmpty() && Party.IsNullOrEmpty() && Tag.IsNullOrEmpty()) |
|||
{ |
|||
throw new ArgumentException("User, Party, and Tag cannot all be empty at the same time!"); |
|||
} |
|||
if (User.Count > 1000) |
|||
{ |
|||
throw new ArgumentException("User list, up to 1000 supported!"); |
|||
} |
|||
if (Party.Count > 100) |
|||
{ |
|||
throw new ArgumentException("Party list, up to 100 supported!"); |
|||
} |
|||
if (Tag.Count > 100) |
|||
{ |
|||
throw new ArgumentException("Tag list, up to 100 supported!"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
using Volo.Abp; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Request; |
|||
/// <summary>
|
|||
/// userid转openid请求参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90202" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkConvertToOpenIdRequest : WeChatWorkRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 企业内的成员id
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("userid")] |
|||
[JsonPropertyName("userid")] |
|||
public string UserId { get; } |
|||
public WeChatWorkConvertToOpenIdRequest(string userId) |
|||
{ |
|||
UserId = Check.NotNullOrWhiteSpace(userId, nameof(userId)); |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
using Volo.Abp; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Request; |
|||
/// <summary>
|
|||
/// openid转userid请求参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90202" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkConvertToUserIdRequest : WeChatWorkRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 在使用企业支付之后,返回结果的openid
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("openid")] |
|||
[JsonPropertyName("openid")] |
|||
public string OpenId { get; } |
|||
public WeChatWorkConvertToUserIdRequest(string openId) |
|||
{ |
|||
OpenId = Check.NotNullOrWhiteSpace(openId, nameof(openId)); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,230 @@ |
|||
using JetBrains.Annotations; |
|||
using LINGYUN.Abp.WeChat.Work.Common.Members.Models; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
using Newtonsoft.Json; |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Text.Json.Serialization; |
|||
using Volo.Abp; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Request; |
|||
/// <summary>
|
|||
/// 创建成员请求参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90195" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkCreateMemberRequest : WeChatWorkRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 成员UserID。对应管理端的账号,企业内必须唯一。长度为1~64个字节。只能由数字、字母和“_-@.”四种字符组成,且第一个字符必须是数字或字母。系统进行唯一性检查时会忽略大小写。
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("userid")] |
|||
[JsonPropertyName("userid")] |
|||
[StringLength(64, MinimumLength = 1)] |
|||
public string UserId { get; set; } |
|||
/// <summary>
|
|||
/// 成员名称。长度为1~64个utf8字符
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("name")] |
|||
[JsonPropertyName("name")] |
|||
[StringLength(64, MinimumLength = 1)] |
|||
public string Name { get; set; } |
|||
/// <summary>
|
|||
/// 成员别名。长度1~64个utf8字符
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("alias")] |
|||
[JsonPropertyName("alias")] |
|||
[StringLength(64, MinimumLength = 1)] |
|||
public string? Alias { get; set; } |
|||
/// <summary>
|
|||
/// 手机号码。企业内必须唯一,mobile/email二者不能同时为空 ,中国大陆手机号码可省略“+86”,其他国家或地区必须要带上国际码。
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("mobile")] |
|||
[JsonPropertyName("mobile")] |
|||
public string? Mobile { get; set; } |
|||
/// <summary>
|
|||
/// 成员所属部门id列表,不超过100个。当不填写department或id为0时,成员会放在其他(待设置部门)下,当填写的部门不存在时,会在在其他(待设置部门)下新建对应部门
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("department")] |
|||
[JsonPropertyName("department")] |
|||
public int[]? Department { get; set; } |
|||
/// <summary>
|
|||
/// 部门内的排序值,默认为0,成员次序以创建时间从小到大排列。个数必须和参数department的个数一致,数值越大排序越前面。有效的值范围是[0, 2^32)
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("order")] |
|||
[JsonPropertyName("order")] |
|||
public int[]? Order { get; set; } |
|||
/// <summary>
|
|||
/// 职务信息。长度为0~128个字符
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[StringLength(128)] |
|||
[JsonProperty("position")] |
|||
[JsonPropertyName("position")] |
|||
public string? Position { get; set; } |
|||
/// <summary>
|
|||
/// 性别
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("gender")] |
|||
[JsonPropertyName("gender")] |
|||
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.EnumToNumberStringConverter<Gender>))] |
|||
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.EnumToNumberStringConverter<Gender>))] |
|||
public Gender? Gender { get; set; } |
|||
/// <summary>
|
|||
/// 邮箱。可填写企业已有的邮箱账号,方便同事获取成员的邮箱账号以发邮件。长度6~64个字节,且为有效的email格式。企业内必须唯一,mobile/email二者不能同时为空。境外成员可用此邮箱登录企业微信。
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[StringLength(64)] |
|||
[JsonProperty("email")] |
|||
[JsonPropertyName("email")] |
|||
public string? Email { get; set; } |
|||
/// <summary>
|
|||
/// 如果企业已开通腾讯企业邮(企业微信邮箱),设置该值可创建企业邮箱账号。长度6~64个字节,且为有效的企业邮箱格式。企业内必须唯一。未填写则系统会为用户生成默认企业邮箱(由系统生成的邮箱可修改一次)
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[StringLength(64)] |
|||
[JsonProperty("biz_mail")] |
|||
[JsonPropertyName("biz_mail")] |
|||
public string? BizEmail { get; set; } |
|||
/// <summary>
|
|||
/// 座机。32字节以内,由纯数字、“-”、“+”或“,”组成。
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[StringLength(32)] |
|||
[JsonProperty("telephone")] |
|||
[JsonPropertyName("telephone")] |
|||
public string? TelePhone { get; set; } |
|||
/// <summary>
|
|||
/// 个数必须和参数department的个数一致,表示在所在的部门内是否为部门负责人。1表示为部门负责人,0表示非部门负责人。在审批(自建、第三方)等应用里可以用来标识上级审批人
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("is_leader_in_dept")] |
|||
[JsonPropertyName("is_leader_in_dept")] |
|||
public int[]? IsLeaderInDept { get; set; } |
|||
/// <summary>
|
|||
/// 直属上级UserID,设置范围为企业内成员,可以设置最多1个上级
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("direct_leader")] |
|||
[JsonPropertyName("direct_leader")] |
|||
public string[]? DirectLeader { get; set; } |
|||
/// <summary>
|
|||
/// 成员头像的mediaid,通过素材管理接口上传图片获得的mediaid
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("avatar_mediaid")] |
|||
[JsonPropertyName("avatar_mediaid")] |
|||
public string? AvatarMediaId { get; set; } |
|||
/// <summary>
|
|||
/// 启用/禁用成员。1表示启用成员,0表示禁用成员
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("enable")] |
|||
[JsonPropertyName("enable")] |
|||
public int? Enable { get; set; } |
|||
/// <summary>
|
|||
/// 扩展属性。扩展属性字段需要先在WEB管理端添加,见扩展属性添加方法,否则忽略未知属性的赋值。字段详情见成员扩展属性
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("extattr")] |
|||
[JsonPropertyName("extattr")] |
|||
public MemberExternalAttribute? ExternalAttribute { get; set; } |
|||
/// <summary>
|
|||
/// 是否邀请该成员使用企业微信(将通过微信服务通知或短信或邮件下发邀请,每天自动下发一次,最多持续3个工作日),默认值为true。
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("to_invite")] |
|||
[JsonPropertyName("to_invite")] |
|||
public bool? ToInvite { get; set; } |
|||
/// <summary>
|
|||
/// 成员对外属性,字段详情见对外属性
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("external_profile")] |
|||
[JsonPropertyName("external_profile")] |
|||
public ExternalProfile? ExternalProfile { get; set; } |
|||
/// <summary>
|
|||
/// 对外职务,如果设置了该值,则以此作为对外展示的职务,否则以position来展示。长度12个汉字内
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[StringLength(12)] |
|||
[JsonProperty("external_position")] |
|||
[JsonPropertyName("external_position")] |
|||
public string? ExternalPosition { get; set; } |
|||
/// <summary>
|
|||
/// 视频号名字(设置后,成员将对外展示该视频号)。须从企业绑定到企业微信的视频号中选择,可在“我的企业”页中查看绑定的视频号
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("nickname")] |
|||
[JsonPropertyName("nickname")] |
|||
public string? NickName { get; set; } |
|||
/// <summary>
|
|||
/// 地址。长度最大128个字符
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[StringLength(128)] |
|||
[JsonProperty("address")] |
|||
[JsonPropertyName("address")] |
|||
public string? Address { get; set; } |
|||
/// <summary>
|
|||
/// 主部门
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("main_department")] |
|||
[JsonPropertyName("main_department")] |
|||
public int? MainDepartment { get; set; } |
|||
protected override void Validate() |
|||
{ |
|||
Check.NotNullOrWhiteSpace(UserId, nameof(UserId), 64, 1); |
|||
Check.NotNullOrWhiteSpace(Name, nameof(Name), 64, 1); |
|||
Check.Length(Alias, nameof(Alias), 64, 1); |
|||
Check.Length(Position, nameof(Position), 128); |
|||
Check.Length(Email, nameof(Email), 64, 6); |
|||
Check.Length(BizEmail, nameof(BizEmail), 64, 6); |
|||
Check.Length(TelePhone, nameof(TelePhone), 32); |
|||
Check.Length(ExternalPosition, nameof(ExternalPosition), 12); |
|||
Check.Length(Address, nameof(Address), 128); |
|||
// mobile/email二者不能同时为空
|
|||
if (Mobile.IsNullOrWhiteSpace() && Email.IsNullOrWhiteSpace()) |
|||
{ |
|||
throw new ArgumentException("mobile and email cannot be empty at the same time!"); |
|||
} |
|||
// 成员所属部门id列表,不超过100个
|
|||
if (Department?.Length > 0) |
|||
{ |
|||
// 成员所属部门id列表,不超过100个
|
|||
if (Department?.Length > 100) |
|||
{ |
|||
throw new ArgumentException("The list of department ids to which members belong shall not exceed 100!"); |
|||
} |
|||
// 部门排序列表个数必须和参数department的个数一致
|
|||
if (Order?.Length != Department?.Length) |
|||
{ |
|||
throw new ArgumentException("The number of Order must be consistent with the number of the parameter \"department\"!"); |
|||
} |
|||
// 部门负责人列表个数必须和参数department的个数一致
|
|||
if (IsLeaderInDept?.Length != Department?.Length) |
|||
{ |
|||
throw new ArgumentException("The number of IsLeaderInDept must be consistent with the number of the parameter \"Department\"!"); |
|||
} |
|||
} |
|||
// 最多只可设置一个直属上级
|
|||
if (DirectLeader?.Length > 1) |
|||
{ |
|||
throw new ArgumentException("At most, only one direct superior can be set up!"); |
|||
} |
|||
// 只可存在两种值
|
|||
if (Enable.HasValue && Enable != 0) |
|||
{ |
|||
Enable = 1; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
using JetBrains.Annotations; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
using Volo.Abp; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Request; |
|||
/// <summary>
|
|||
/// 邮箱获取userid请求参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/95402" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkGetUserIdByEmailRequest : WeChatWorkRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 邮箱
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("email")] |
|||
[JsonPropertyName("email")] |
|||
public string Email { get; } |
|||
/// <summary>
|
|||
/// 邮箱类型
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("email_type")] |
|||
[JsonPropertyName("email_type")] |
|||
public EmailType? EmailType { get; } |
|||
public WeChatWorkGetUserIdByEmailRequest(string email, EmailType? emailType = null) |
|||
{ |
|||
Email = Check.NotNullOrWhiteSpace(email, nameof(email)); |
|||
EmailType = emailType; |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
using Volo.Abp; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Request; |
|||
/// <summary>
|
|||
/// 手机号获取userid请求参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/95402" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkGetUserIdByMobileRequest : WeChatWorkRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 用户在企业微信通讯录中的手机号码。长度为5~32个字节
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("mobile")] |
|||
[JsonPropertyName("mobile")] |
|||
public string Mobile { get; } |
|||
public WeChatWorkGetUserIdByMobileRequest(string mobile) |
|||
{ |
|||
Mobile = Check.NotNullOrWhiteSpace(mobile, nameof(mobile), 32, 5); |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
using Volo.Abp; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Request; |
|||
/// <summary>
|
|||
/// 获取成员ID列表请求参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/96067" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkGetUserIdListRequest : WeChatWorkRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用不填
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("cursor")] |
|||
[JsonPropertyName("cursor")] |
|||
public string? Cursor { get; set; } |
|||
/// <summary>
|
|||
/// 分页,预期请求的数据量,取值范围 1 ~ 10000
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("limit")] |
|||
[JsonPropertyName("limit")] |
|||
public int? Limit { get; set; } |
|||
public WeChatWorkGetUserIdListRequest(string? cursor = null, int? limit = 100) |
|||
{ |
|||
Cursor = cursor; |
|||
Limit = limit; |
|||
} |
|||
|
|||
protected override void Validate() |
|||
{ |
|||
if (Limit.HasValue) |
|||
{ |
|||
Check.Range(Limit.Value, nameof(Limit), 1, 10000); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,236 @@ |
|||
using JetBrains.Annotations; |
|||
using LINGYUN.Abp.WeChat.Work.Common.Members.Models; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
using Newtonsoft.Json; |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Text.Json.Serialization; |
|||
using Volo.Abp; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Request; |
|||
/// <summary>
|
|||
/// 更新成员请求参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90197" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkUpdateMemberRequest : WeChatWorkRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 成员UserID。对应管理端的账号,企业内必须唯一。不区分大小写,长度为1~64个字节
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("userid")] |
|||
[JsonPropertyName("userid")] |
|||
[StringLength(64, MinimumLength = 1)] |
|||
public string UserId { get; set; } |
|||
/// <summary>
|
|||
/// 如果userid由系统自动生成,则仅允许修改一次。新值可由new_userid字段指定。
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("new_userid")] |
|||
[JsonPropertyName("new_userid")] |
|||
[StringLength(64, MinimumLength = 1)] |
|||
public string? NewUserId { get; set; } |
|||
/// <summary>
|
|||
/// 成员名称。长度为1~64个utf8字符
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("name")] |
|||
[JsonPropertyName("name")] |
|||
[StringLength(64, MinimumLength = 1)] |
|||
public string Name { get; set; } |
|||
/// <summary>
|
|||
/// 成员别名。长度1~64个utf8字符
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("alias")] |
|||
[JsonPropertyName("alias")] |
|||
[StringLength(64, MinimumLength = 1)] |
|||
public string? Alias { get; set; } |
|||
/// <summary>
|
|||
/// 手机号码。企业内必须唯一。若成员已激活企业微信,则需成员自行修改(此情况下该参数被忽略,但不会报错) ,中国大陆手机号码可省略“+86”,其他国家或地区必须要带上国际码。
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("mobile")] |
|||
[JsonPropertyName("mobile")] |
|||
public string? Mobile { get; set; } |
|||
/// <summary>
|
|||
/// 成员所属部门id列表,不超过100个
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("department")] |
|||
[JsonPropertyName("department")] |
|||
public int[]? Department { get; set; } |
|||
/// <summary>
|
|||
/// 部门内的排序值,默认为0。当有传入department时有效。数量必须和department一致,数值越大排序越前面。有效的值范围是[0, 2^32)
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("order")] |
|||
[JsonPropertyName("order")] |
|||
public int[]? Order { get; set; } |
|||
/// <summary>
|
|||
/// 职务信息。长度为0~128个utf8字符
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[StringLength(128)] |
|||
[JsonProperty("position")] |
|||
[JsonPropertyName("position")] |
|||
public string? Position { get; set; } |
|||
/// <summary>
|
|||
/// 性别
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("gender")] |
|||
[JsonPropertyName("gender")] |
|||
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.EnumToNumberStringConverter<Gender>))] |
|||
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.EnumToNumberStringConverter<Gender>))] |
|||
public Gender? Gender { get; set; } |
|||
/// <summary>
|
|||
/// 邮箱。可填写企业已有的邮箱账号,方便同事获取成员的邮箱账号以发邮件。长度6~64个字节,且为有效的email格式。企业内必须唯一。境外成员可用此邮箱登录企业微信。
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[StringLength(64)] |
|||
[JsonProperty("email")] |
|||
[JsonPropertyName("email")] |
|||
public string? Email { get; set; } |
|||
/// <summary>
|
|||
/// 如果企业已开通腾讯企业邮(企业微信邮箱),设置该值可创建企业邮箱账号。长度6~63个字节,且为有效的企业邮箱格式。企业内必须唯一。未填写则系统会为用户生成默认企业邮箱(由系统生成的邮箱可修改一次)。
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[StringLength(64)] |
|||
[JsonProperty("biz_mail")] |
|||
[JsonPropertyName("biz_mail")] |
|||
public string? BizEmail { get; set; } |
|||
/// <summary>
|
|||
/// 企业邮箱别名。长度6~63个字节,且为有效的企业邮箱格式。企业内必须唯一,最多可设置5个别名。更新时为覆盖式更新。传空结构或传空数组会清空当前企业邮箱别名。
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[StringLength(63, MinimumLength = 6)] |
|||
[JsonProperty("biz_mail_alias")] |
|||
[JsonPropertyName("biz_mail_alias")] |
|||
public string? BizEmailAlias { get; set; } |
|||
/// <summary>
|
|||
/// 座机。32字节以内,由纯数字、“-”、“+”或“,”组成。
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[StringLength(32)] |
|||
[JsonProperty("telephone")] |
|||
[JsonPropertyName("telephone")] |
|||
public string? TelePhone { get; set; } |
|||
/// <summary>
|
|||
/// 部门负责人字段,个数必须和department一致,表示在所在的部门内是否为负责人。0-否,1-是
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("is_leader_in_dept")] |
|||
[JsonPropertyName("is_leader_in_dept")] |
|||
public int[]? IsLeaderInDept { get; set; } |
|||
/// <summary>
|
|||
/// 直属上级UserID,设置范围为企业内成员,可以设置最多1个上级
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("direct_leader")] |
|||
[JsonPropertyName("direct_leader")] |
|||
public string[]? DirectLeader { get; set; } |
|||
/// <summary>
|
|||
/// 成员头像的mediaid,通过素材管理接口上传图片获得的mediaid
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("avatar_mediaid")] |
|||
[JsonPropertyName("avatar_mediaid")] |
|||
public string? AvatarMediaId { get; set; } |
|||
/// <summary>
|
|||
/// 启用/禁用成员。1表示启用成员,0表示禁用成员
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("enable")] |
|||
[JsonPropertyName("enable")] |
|||
public int? Enable { get; set; } |
|||
/// <summary>
|
|||
/// 扩展属性。扩展属性字段需要先在WEB管理端添加,见扩展属性添加方法,否则忽略未知属性的赋值。字段详情见成员扩展属性
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("extattr")] |
|||
[JsonPropertyName("extattr")] |
|||
public MemberExternalAttribute? ExternalAttribute { get; set; } |
|||
/// <summary>
|
|||
/// 成员对外属性,字段详情见对外属性
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("external_profile")] |
|||
[JsonPropertyName("external_profile")] |
|||
public ExternalProfile? ExternalProfile { get; set; } |
|||
/// <summary>
|
|||
/// 对外职务,如果设置了该值,则以此作为对外展示的职务,否则以position来展示。不超过12个汉字
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[StringLength(12)] |
|||
[JsonProperty("external_position")] |
|||
[JsonPropertyName("external_position")] |
|||
public string? ExternalPosition { get; set; } |
|||
/// <summary>
|
|||
/// 视频号名字(设置后,成员将对外展示该视频号)。须从企业绑定到企业微信的视频号中选择,可在“我的企业”页中查看绑定的视频号
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("nickname")] |
|||
[JsonPropertyName("nickname")] |
|||
public string? NickName { get; set; } |
|||
/// <summary>
|
|||
/// 地址。长度最大128个字符
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[StringLength(128)] |
|||
[JsonProperty("address")] |
|||
[JsonPropertyName("address")] |
|||
public string? Address { get; set; } |
|||
/// <summary>
|
|||
/// 主部门
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("main_department")] |
|||
[JsonPropertyName("main_department")] |
|||
public int? MainDepartment { get; set; } |
|||
|
|||
protected override void Validate() |
|||
{ |
|||
Check.NotNullOrWhiteSpace(UserId, nameof(UserId), 64, 1); |
|||
Check.NotNullOrWhiteSpace(Name, nameof(Name), 64, 1); |
|||
Check.Length(Alias, nameof(Alias), 64, 1); |
|||
Check.Length(Position, nameof(Position), 128); |
|||
Check.Length(Email, nameof(Email), 64, 6); |
|||
Check.Length(BizEmail, nameof(BizEmail), 64, 6); |
|||
Check.Length(TelePhone, nameof(TelePhone), 32); |
|||
Check.Length(ExternalPosition, nameof(ExternalPosition), 12); |
|||
Check.Length(Address, nameof(Address), 128); |
|||
Check.Length(NewUserId, nameof(NewUserId), 64, 1); |
|||
// 成员所属部门id列表,不超过100个
|
|||
if (Department?.Length > 0) |
|||
{ |
|||
// 成员所属部门id列表,不超过100个
|
|||
if (Department?.Length > 100) |
|||
{ |
|||
throw new ArgumentException("The list of department ids to which members belong shall not exceed 100!"); |
|||
} |
|||
// 部门排序列表个数必须和参数department的个数一致
|
|||
if (Order?.Length != Department?.Length) |
|||
{ |
|||
throw new ArgumentException("The number of Order must be consistent with the number of the parameter \"department\"!"); |
|||
} |
|||
// 部门负责人列表个数必须和参数department的个数一致
|
|||
if (IsLeaderInDept?.Length != Department?.Length) |
|||
{ |
|||
throw new ArgumentException("The number of IsLeaderInDept must be consistent with the number of the parameter \"Department\"!"); |
|||
} |
|||
} |
|||
// 最多只可设置一个直属上级
|
|||
if (DirectLeader?.Length > 1) |
|||
{ |
|||
throw new ArgumentException("At most, only one direct superior can be set up!"); |
|||
} |
|||
// 只可存在两种值
|
|||
if (Enable.HasValue && Enable != 0) |
|||
{ |
|||
Enable = 1; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Response; |
|||
/// <summary>
|
|||
/// 邀请成员响应参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90975" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkBulkInviteMemberResponse : WeChatWorkResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 非法成员列表
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("invaliduser")] |
|||
[JsonPropertyName("invaliduser")] |
|||
public string[] InvalidUser { get; set; } |
|||
/// <summary>
|
|||
/// 非法部门列表
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("invalidparty")] |
|||
[JsonPropertyName("invalidparty")] |
|||
public int[] InvalidParty { get; set; } |
|||
/// <summary>
|
|||
/// 非法标签列表
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("invalidtag")] |
|||
[JsonPropertyName("invalidtag")] |
|||
public int[] InvalidTag { get; set; } |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Response; |
|||
/// <summary>
|
|||
/// userid转openid响应参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90202" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkConvertToOpenIdResponse : WeChatWorkResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 企业微信成员userid对应的openid
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("openid")] |
|||
[JsonPropertyName("openid")] |
|||
public string OpenId { get; set; } |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Response; |
|||
/// <summary>
|
|||
/// openid转userid响应参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90202" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkConvertToUserIdResponse : WeChatWorkResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 该openid在企业微信对应的成员userid
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("userid")] |
|||
[JsonPropertyName("userid")] |
|||
public string UserId { get; set; } |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using JetBrains.Annotations; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Departments.Models; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Response; |
|||
/// <summary>
|
|||
/// 创建成员响应参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90195" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkCreateMemberResponse : WeChatWorkResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 因填写不存在的部门,新增的部门列表
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("created_department_list")] |
|||
[JsonPropertyName("created_department_list")] |
|||
public Department[]? CreatedDepartmentList { get; set; } |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Response; |
|||
/// <summary>
|
|||
/// 获取加入企业二维码响应参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/91714" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkGetJoinQrCodeResponse : WeChatWorkResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 二维码链接,有效期7天
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("join_qrcode")] |
|||
[JsonPropertyName("join_qrcode")] |
|||
public string JoinQrcCode { get; set; } |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using JetBrains.Annotations; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Response; |
|||
/// <summary>
|
|||
/// 获取部门成员详情响应参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90201" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkGetMemberListResponse : WeChatWorkResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 成员列表
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("userlist")] |
|||
[JsonPropertyName("userlist")] |
|||
public MemberInfo[] UserList { get; set; } |
|||
} |
|||
@ -0,0 +1,170 @@ |
|||
using JetBrains.Annotations; |
|||
using LINGYUN.Abp.WeChat.Work.Common.Members.Models; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Response; |
|||
/// <summary>
|
|||
/// 读取成员响应参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90196" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkGetMemberResponse : WeChatWorkResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 全局唯一
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("open_userid")] |
|||
[JsonPropertyName("open_userid")] |
|||
public string OpenUserId { get; set; } |
|||
/// <summary>
|
|||
/// 成员UserID
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("userid")] |
|||
[JsonPropertyName("userid")] |
|||
public string UserId { get; set; } |
|||
/// <summary>
|
|||
/// 成员名称
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("name")] |
|||
[JsonPropertyName("name")] |
|||
public string Name { get; set; } |
|||
/// <summary>
|
|||
/// 手机号码
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("mobile")] |
|||
[JsonPropertyName("mobile")] |
|||
public string? Mobile { get; set; } |
|||
/// <summary>
|
|||
/// 成员所属部门id列表
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("department")] |
|||
[JsonPropertyName("department")] |
|||
public int[] Department { get; set; } |
|||
/// <summary>
|
|||
/// 主部门
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("main_department")] |
|||
[JsonPropertyName("main_department")] |
|||
public int? MainDepartment { get; set; } |
|||
/// <summary>
|
|||
/// 部门内的排序值,默认为0。数量必须和department一致,数值越大排序越前面。值范围是[0, 2^32)
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("order")] |
|||
[JsonPropertyName("order")] |
|||
public int[]? Order { get; set; } |
|||
/// <summary>
|
|||
/// 员工个人二维码
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("qr_code")] |
|||
[JsonPropertyName("qr_code")] |
|||
public string? QrCode { get; set; } |
|||
/// <summary>
|
|||
/// 职务信息
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("position")] |
|||
[JsonPropertyName("position")] |
|||
public string? Position { get; set; } |
|||
/// <summary>
|
|||
/// 性别
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("gender")] |
|||
[JsonPropertyName("gender")] |
|||
public Gender? Gender { get; set; } |
|||
/// <summary>
|
|||
/// 邮箱
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("email")] |
|||
[JsonPropertyName("email")] |
|||
public string? Email { get; set; } |
|||
/// <summary>
|
|||
/// 企业邮箱
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("biz_mail")] |
|||
[JsonPropertyName("biz_mail")] |
|||
public string? BizEmail { get; set; } |
|||
/// <summary>
|
|||
/// 表示在所在的部门内是否为部门负责人,数量与department一致
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("is_leader_in_dept")] |
|||
[JsonPropertyName("is_leader_in_dept")] |
|||
public int[]? IsLeaderInDept { get; set; } |
|||
/// <summary>
|
|||
/// 直属上级UserID,返回在应用可见范围内的直属上级列表,最多有1个直属上级
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("direct_leader")] |
|||
[JsonPropertyName("direct_leader")] |
|||
public string[]? DirectLeader { get; set; } |
|||
/// <summary>
|
|||
/// 头像url
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("avatar")] |
|||
[JsonPropertyName("avatar")] |
|||
public string? Avatar { get; set; } |
|||
/// <summary>
|
|||
/// 头像缩略图url
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("thumb_avatar")] |
|||
[JsonPropertyName("thumb_avatar")] |
|||
public string? ThumbAvatar { get; set; } |
|||
/// <summary>
|
|||
/// 座机
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("telephone")] |
|||
[JsonPropertyName("telephone")] |
|||
public string? TelePhone { get; set; } |
|||
/// <summary>
|
|||
/// 别名
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("alias")] |
|||
[JsonPropertyName("alias")] |
|||
public string? Alias { get; set; } |
|||
/// <summary>
|
|||
/// 地址
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("address")] |
|||
[JsonPropertyName("address")] |
|||
public string? Address { get; set; } |
|||
/// <summary>
|
|||
/// 激活状态
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("status")] |
|||
[JsonPropertyName("status")] |
|||
public MemberStatus Status { get; set; } |
|||
/// <summary>
|
|||
/// 扩展属性
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("extattr")] |
|||
[JsonPropertyName("extattr")] |
|||
public MemberExternalAttribute? ExternalAttribute { get; set; } |
|||
/// <summary>
|
|||
/// 对外职务,如果设置了该值,则以此作为对外展示的职务,否则以position来展示。
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("external_position")] |
|||
[JsonPropertyName("external_position")] |
|||
public string? ExternalPosition { get; set; } |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using JetBrains.Annotations; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Response; |
|||
/// <summary>
|
|||
/// 获取部门成员响应参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/90200" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkGetSimpleMemberListResponse : WeChatWorkResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 成员列表
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("userlist")] |
|||
[JsonPropertyName("userlist")] |
|||
public DepartmentMember[] UserList { get; set; } |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using JetBrains.Annotations; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Response; |
|||
/// <summary>
|
|||
/// 获取成员ID列表响应参数
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 详情见: <see href="https://developer.work.weixin.qq.com/document/path/96067" />
|
|||
/// </remarks>
|
|||
public class WeChatWorkGetUserIdListResponse : WeChatWorkResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 用户-部门关系列表
|
|||
/// </summary>
|
|||
[CanBeNull] |
|||
[JsonProperty("next_cursor")] |
|||
[JsonPropertyName("next_cursor")] |
|||
public string? NextCursor { get; set; } |
|||
/// <summary>
|
|||
/// 分页游标,下次请求时填写以获取之后分页的记录。如果该字段返回空则表示已没有更多数据
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("dept_user")] |
|||
[JsonPropertyName("dept_user")] |
|||
public DepartmentUser[] DepartmentUser { get; set; } |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using JetBrains.Annotations; |
|||
using Newtonsoft.Json; |
|||
using System.Text.Json.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members.Response; |
|||
/// <summary>
|
|||
/// 获取userid响应参数
|
|||
/// </summary>
|
|||
public class WeChatWorkGetUserIdResponse : WeChatWorkResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 成员UserID。对应管理端的账号,企业内必须唯一。不区分大小写,长度为1~64个字节。注意:第三方应用获取的值是密文的userid
|
|||
/// </summary>
|
|||
[NotNull] |
|||
[JsonProperty("userid")] |
|||
[JsonPropertyName("userid")] |
|||
public string UserId { get; set; } |
|||
} |
|||
@ -0,0 +1,209 @@ |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Features; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Members.Models; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Members.Request; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Members.Response; |
|||
using LINGYUN.Abp.WeChat.Work.Contacts.Token; |
|||
using LINGYUN.Abp.WeChat.Work.Token; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using System.Net.Http; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Features; |
|||
using Volo.Abp.Json; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Members; |
|||
|
|||
[RequiresFeature(WeChatWorkContactsFeatureNames.Enable)] |
|||
public class WeChatWorkMemberProvider : IWeChatWorkMemberProvider, ISingletonDependency |
|||
{ |
|||
protected IJsonSerializer JsonSerializer { get; } |
|||
protected IHttpClientFactory HttpClientFactory { get; } |
|||
protected IWeChatWorkTokenProvider WeChatWorkTokenProvider { get; } |
|||
protected IWeChatWorkContactTokenProvider WeChatWorkContactTokenProvider { get; } |
|||
|
|||
public WeChatWorkMemberProvider( |
|||
IJsonSerializer jsonSerializer, |
|||
IHttpClientFactory httpClientFactory, |
|||
IWeChatWorkTokenProvider weChatWorkTokenProvider, |
|||
IWeChatWorkContactTokenProvider weChatWorkContactTokenProvider) |
|||
{ |
|||
JsonSerializer = jsonSerializer; |
|||
HttpClientFactory = httpClientFactory; |
|||
WeChatWorkTokenProvider = weChatWorkTokenProvider; |
|||
WeChatWorkContactTokenProvider = weChatWorkContactTokenProvider; |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkGetMemberResponse> GetMemberAsync( |
|||
string userId, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotNullOrWhiteSpace(userId, nameof(userId), 64, 1); |
|||
|
|||
var token = await WeChatWorkTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.GetMemberAsync(token.AccessToken, userId, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkCreateMemberResponse> CreateMemberAsync( |
|||
WeChatWorkCreateMemberRequest request, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotNull(request, nameof(request)); |
|||
|
|||
var token = await WeChatWorkContactTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.CreateMemberAsync(token.AccessToken, request, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkResponse> UpdateMemberAsync( |
|||
WeChatWorkUpdateMemberRequest request, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotNull(request, nameof(request)); |
|||
|
|||
var token = await WeChatWorkContactTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.UpdateMemberAsync(token.AccessToken, request, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkResponse> DeleteMemberAsync( |
|||
string userId, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotNullOrWhiteSpace(userId, nameof(userId), 64, 1); |
|||
|
|||
var token = await WeChatWorkContactTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.DeleteMemberAsync(token.AccessToken, userId, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkResponse> BulkDeleteMemberAsync( |
|||
WeChatWorkBulkDeleteMemberRequest request, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotNull(request, nameof(request)); |
|||
|
|||
var token = await WeChatWorkContactTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.BulkDeleteMemberAsync(token.AccessToken, request, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkGetSimpleMemberListResponse> GetSimpleMemberListAsync( |
|||
int departmentId, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotDefaultOrNull<int>(departmentId, nameof(departmentId)); |
|||
|
|||
var token = await WeChatWorkTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.GetSimpleMemberListAsync(token.AccessToken, departmentId, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkGetMemberListResponse> GetMemberListAsync( |
|||
int departmentId, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotDefaultOrNull<int>(departmentId, nameof(departmentId)); |
|||
|
|||
var token = await WeChatWorkTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.GetMemberListAsync(token.AccessToken, departmentId, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkConvertToOpenIdResponse> ConvertToOpenIdAsync( |
|||
WeChatWorkConvertToOpenIdRequest request, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotNull(request, nameof(request)); |
|||
|
|||
var token = await WeChatWorkTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.ConvertToOpenIdAsync(token.AccessToken, request, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkConvertToUserIdResponse> ConvertToUserIdAsync( |
|||
WeChatWorkConvertToUserIdRequest request, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotNull(request, nameof(request)); |
|||
|
|||
var token = await WeChatWorkTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.ConvertToUserIdAsync(token.AccessToken, request, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkResponse> AuthSuccessAsync( |
|||
string userId, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotNull(userId, nameof(userId)); |
|||
|
|||
var token = await WeChatWorkTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.AuthSuccessAsync(token.AccessToken, userId, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkBulkInviteMemberResponse> BulkInviteMemberAsync( |
|||
WeChatWorkBulkInviteMemberRequest request, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
Check.NotNull(request, nameof(request)); |
|||
|
|||
var token = await WeChatWorkTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.BulkInviteMemberAsync(token.AccessToken, request, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkGetJoinQrCodeResponse> GetJoinQrCodeAsync( |
|||
QrCodeSizeType sizeType, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
var token = await WeChatWorkContactTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.GetJoinQrCodeAsync(token.AccessToken, sizeType, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkGetUserIdResponse> GetUserIdByMobileAsync( |
|||
WeChatWorkGetUserIdByMobileRequest request, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
var token = await WeChatWorkTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.GetUserIdByMobileAsync(token.AccessToken, request, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkGetUserIdResponse> GetUserIdByEmailAsync( |
|||
WeChatWorkGetUserIdByEmailRequest request, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
var token = await WeChatWorkTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.GetUserIdByEmailAsync(token.AccessToken, request, cancellationToken); |
|||
} |
|||
|
|||
public async virtual Task<WeChatWorkGetUserIdListResponse> GetUserIdListAsync( |
|||
WeChatWorkGetUserIdListRequest request, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
var token = await WeChatWorkContactTokenProvider.GetTokenAsync(cancellationToken); |
|||
var client = HttpClientFactory.CreateWeChatWorkApiClient(); |
|||
|
|||
return await client.GetUserIdListAsync(token.AccessToken, request, cancellationToken); |
|||
} |
|||
} |
|||
@ -1,8 +1,9 @@ |
|||
using LINGYUN.Abp.WeChat.Common.Messages; |
|||
using LINGYUN.Abp.WeChat.Work.Common.Messages; |
|||
using System.Xml.Serialization; |
|||
using Volo.Abp.EventBus; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Common.Messages.Models; |
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Messages.Models; |
|||
/// <summary>
|
|||
/// 新增部门事件
|
|||
/// </summary>
|
|||
@ -1,7 +1,8 @@ |
|||
using LINGYUN.Abp.WeChat.Common.Messages; |
|||
using LINGYUN.Abp.WeChat.Work.Common.Messages; |
|||
using Volo.Abp.EventBus; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Common.Messages.Models; |
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Messages.Models; |
|||
/// <summary>
|
|||
/// 新增成员事件
|
|||
/// </summary>
|
|||
@ -1,8 +1,9 @@ |
|||
using LINGYUN.Abp.WeChat.Common.Messages; |
|||
using LINGYUN.Abp.WeChat.Work.Common.Messages; |
|||
using System.Xml.Serialization; |
|||
using Volo.Abp.EventBus; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Common.Messages.Models; |
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Messages.Models; |
|||
/// <summary>
|
|||
/// 删除部门事件
|
|||
/// </summary>
|
|||
@ -1,8 +1,9 @@ |
|||
using LINGYUN.Abp.WeChat.Common.Messages; |
|||
using LINGYUN.Abp.WeChat.Work.Common.Messages; |
|||
using System.Xml.Serialization; |
|||
using Volo.Abp.EventBus; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Common.Messages.Models; |
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Messages.Models; |
|||
/// <summary>
|
|||
/// 删除成员事件
|
|||
/// </summary>
|
|||
@ -1,6 +1,7 @@ |
|||
using System.Xml.Serialization; |
|||
using LINGYUN.Abp.WeChat.Work.Common.Messages; |
|||
using System.Xml.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Common.Messages.Models; |
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Messages.Models; |
|||
/// <summary>
|
|||
/// 部门变更事件
|
|||
/// </summary>
|
|||
@ -1,7 +1,8 @@ |
|||
using LINGYUN.Abp.WeChat.Common.Messages; |
|||
using LINGYUN.Abp.WeChat.Work.Common.Messages; |
|||
using Volo.Abp.EventBus; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Common.Messages.Models; |
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Messages.Models; |
|||
/// <summary>
|
|||
/// 更新部门事件
|
|||
/// </summary>
|
|||
@ -1,8 +1,9 @@ |
|||
using LINGYUN.Abp.WeChat.Common.Messages; |
|||
using LINGYUN.Abp.WeChat.Work.Common.Messages; |
|||
using System.Xml.Serialization; |
|||
using Volo.Abp.EventBus; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Common.Messages.Models; |
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Messages.Models; |
|||
/// <summary>
|
|||
/// 更新成员事件
|
|||
/// </summary>
|
|||
@ -1,6 +1,8 @@ |
|||
using System.Xml.Serialization; |
|||
using LINGYUN.Abp.WeChat.Work.Common.Members.Models; |
|||
using LINGYUN.Abp.WeChat.Work.Common.Messages; |
|||
using System.Xml.Serialization; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Common.Messages.Models; |
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Messages.Models; |
|||
/// <summary>
|
|||
/// 成员变更事件
|
|||
/// </summary>
|
|||
@ -1,8 +1,9 @@ |
|||
using LINGYUN.Abp.WeChat.Common.Messages; |
|||
using LINGYUN.Abp.WeChat.Work.Common.Messages; |
|||
using System.Xml.Serialization; |
|||
using Volo.Abp.EventBus; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Common.Messages.Models; |
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Messages.Models; |
|||
/// <summary>
|
|||
/// 标签成员变更事件
|
|||
/// </summary>
|
|||
@ -0,0 +1,30 @@ |
|||
using LINGYUN.Abp.WeChat.Work.Localization; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Settings; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Settings; |
|||
|
|||
public class WeChatWorkContactSettingDefinitionProvider : SettingDefinitionProvider |
|||
{ |
|||
public override void Define(ISettingDefinitionContext context) |
|||
{ |
|||
context.Add( |
|||
new SettingDefinition( |
|||
WeChatWorkContactSettingNames.Secret, |
|||
displayName: L("DisplayName:WeChatWorkContact.Secret"), |
|||
description: L("Description:WeChatWorkContact.Secret"), |
|||
isVisibleToClients: false, |
|||
isEncrypted: true) |
|||
.WithProviders( |
|||
DefaultValueSettingValueProvider.ProviderName, |
|||
ConfigurationSettingValueProvider.ProviderName, |
|||
GlobalSettingValueProvider.ProviderName, |
|||
TenantSettingValueProvider.ProviderName) |
|||
); |
|||
} |
|||
|
|||
private static ILocalizableString L(string name) |
|||
{ |
|||
return LocalizableString.Create<WeChatWorkResource>(name); |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using LINGYUN.Abp.WeChat.Work.Settings; |
|||
|
|||
namespace LINGYUN.Abp.WeChat.Work.Contacts.Settings; |
|||
|
|||
public static class WeChatWorkContactSettingNames |
|||
{ |
|||
public const string Prefix = WeChatWorkSettingNames.Prefix + ".Contacts"; |
|||
/// <summary>
|
|||
/// 通讯录应用Srcret
|
|||
/// </summary>
|
|||
public const string Secret = Prefix + ".Secret"; |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue