diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Events/Contact/ChangeContactEvent.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Events/Contact/ChangeContactEvent.cs
index 535a4adc..d7df9e73 100644
--- a/src/SKIT.FlurlHttpClient.Wechat.Work/Events/Contact/ChangeContactEvent.cs
+++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Events/Contact/ChangeContactEvent.cs
@@ -149,7 +149,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Events
///
[Obsolete("相关接口或字段于 2022-08-15 下线。")]
[System.Xml.Serialization.XmlElement("MainDepartment", IsNullable = true)]
- public int? UserMainDepartmentId { get; set; }
+ public long? UserMainDepartmentId { get; set; }
///
/// 获取或设置用户邮箱。
diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinServiceExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinServiceExtensions.cs
index c729f01a..0d6bf119 100644
--- a/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinServiceExtensions.cs
+++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinServiceExtensions.cs
@@ -425,6 +425,46 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken);
}
+
+ ///
+ /// 异步调用 [POST] /cgi-bin/service/contact/search 接口。
+ /// REF: https://developer.work.weixin.qq.com/document/path/91844
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static async Task ExecuteCgibinServiceContactSearchAsync(this WechatWorkClient client, Models.CgibinServiceContactSearchRequest request, CancellationToken cancellationToken = default)
+ {
+ if (client is null) throw new ArgumentNullException(nameof(client));
+ if (request is null) throw new ArgumentNullException(nameof(request));
+
+ IFlurlRequest flurlReq = client
+ .CreateRequest(request, HttpMethod.Post, "cgi-bin", "service", "contact", "search")
+ .SetQueryParam("provider_access_token", request.ProviderAccessToken);
+
+ return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 异步调用 [POST] /cgi-bin/service/contact/batchsearch 接口。
+ /// REF: https://developer.work.weixin.qq.com/document/path/91844
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static async Task ExecuteCgibinServiceContactBatchSearchAsync(this WechatWorkClient client, Models.CgibinServiceContactBatchSearchRequest request, CancellationToken cancellationToken = default)
+ {
+ if (client is null) throw new ArgumentNullException(nameof(client));
+ if (request is null) throw new ArgumentNullException(nameof(request));
+
+ IFlurlRequest flurlReq = client
+ .CreateRequest(request, HttpMethod.Post, "cgi-bin", "service", "contact", "batchsearch")
+ .SetQueryParam("provider_access_token", request.ProviderAccessToken);
+
+ return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken);
+ }
#endregion
#region Batch
diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExternalContact/CgibinExternalContactGetUnassignedListResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExternalContact/CgibinExternalContactGetUnassignedListResponse.cs
index 2962997c..c52091ec 100644
--- a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExternalContact/CgibinExternalContactGetUnassignedListResponse.cs
+++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExternalContact/CgibinExternalContactGetUnassignedListResponse.cs
@@ -44,7 +44,7 @@
///
[Newtonsoft.Json.JsonProperty("is_last")]
[System.Text.Json.Serialization.JsonPropertyName("is_last")]
- public bool IsEnding { get; set; }
+ public bool IsLast { get; set; }
///
/// 获取或设置翻页标记。
diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/Contact/CgibinServiceContactBatchSearchRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/Contact/CgibinServiceContactBatchSearchRequest.cs
new file mode 100644
index 00000000..35e629c1
--- /dev/null
+++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/Contact/CgibinServiceContactBatchSearchRequest.cs
@@ -0,0 +1,86 @@
+using System.Collections.Generic;
+
+namespace SKIT.FlurlHttpClient.Wechat.Work.Models
+{
+ ///
+ /// 表示 [POST] /cgi-bin/service/contact/batchsearch 接口的请求。
+ ///
+ public class CgibinServiceContactBatchSearchRequest : WechatWorkRequest
+ {
+ public static class Types
+ {
+ public class QueryRequest
+ {
+ ///
+ /// 获取或设置搜索关键词。
+ ///
+ [Newtonsoft.Json.JsonProperty("query_word")]
+ [System.Text.Json.Serialization.JsonPropertyName("query_word")]
+ public string QueryWord { get; set; } = string.Empty;
+
+ ///
+ /// 获取或设置查询类型。
+ ///
+ [Newtonsoft.Json.JsonProperty("query_type")]
+ [System.Text.Json.Serialization.JsonPropertyName("query_type")]
+ public int? QueryType { get; set; }
+
+ ///
+ /// 获取或设置查询范围。
+ ///
+ [Newtonsoft.Json.JsonProperty("query_range")]
+ [System.Text.Json.Serialization.JsonPropertyName("query_range")]
+ public int? QueryRange { get; set; }
+
+ ///
+ /// 获取或设置精确匹配字段类型。
+ ///
+ [Newtonsoft.Json.JsonProperty("full_match_field")]
+ [System.Text.Json.Serialization.JsonPropertyName("full_match_field")]
+ public int? FullMatchField { get; set; }
+
+ ///
+ /// 获取或设置翻页标记。
+ ///
+ [Newtonsoft.Json.JsonProperty("cursor")]
+ [System.Text.Json.Serialization.JsonPropertyName("cursor")]
+ public string? Cursor { get; set; }
+
+ ///
+ /// 获取或设置分页每页数量。
+ ///
+ [Newtonsoft.Json.JsonProperty("limit")]
+ [System.Text.Json.Serialization.JsonPropertyName("limit")]
+ public int? Limit { get; set; }
+ }
+ }
+
+ ///
+ /// 获取或设置服务商 AccessToken。
+ ///
+ [Newtonsoft.Json.JsonIgnore]
+ [System.Text.Json.Serialization.JsonIgnore]
+ public string ProviderAccessToken { get; set; } = string.Empty;
+
+ ///
+ /// 获取或设置授权方 CorpId。
+ ///
+ [Newtonsoft.Json.JsonProperty("auth_corpid")]
+ [System.Text.Json.Serialization.JsonPropertyName("auth_corpid")]
+ public string AuthorizerCorpId { get; set; } = string.Empty;
+
+ ///
+ /// 获取或设置应用 ID。
+ ///
+ [Newtonsoft.Json.JsonProperty("agentid")]
+ [System.Text.Json.Serialization.JsonPropertyName("agentid")]
+ public int? AgentId { get; set; }
+
+ ///
+ /// 获取或设置搜索请求列表。
+ ///
+ [Newtonsoft.Json.JsonProperty("query_request_list")]
+ [System.Text.Json.Serialization.JsonPropertyName("query_request_list")]
+ public IList? QueryRequestList { get; set; }
+ }
+}
diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/Contact/CgibinServiceContactBatchSearchResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/Contact/CgibinServiceContactBatchSearchResponse.cs
new file mode 100644
index 00000000..44bf91ce
--- /dev/null
+++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/Contact/CgibinServiceContactBatchSearchResponse.cs
@@ -0,0 +1,101 @@
+namespace SKIT.FlurlHttpClient.Wechat.Work.Models
+{
+ ///
+ /// 表示 [POST] /cgi-bin/service/contact/batchsearch 接口的响应。
+ ///
+ public class CgibinServiceContactBatchSearchResponse : WechatWorkResponse
+ {
+ public static class Types
+ {
+ public class Query
+ {
+ public static class Types
+ {
+ public class QueryRequest
+ {
+ ///
+ /// 获取或设置搜索关键词。
+ ///
+ [Newtonsoft.Json.JsonProperty("query_word")]
+ [System.Text.Json.Serialization.JsonPropertyName("query_word")]
+ public string QueryWord { get; set; } = default!;
+
+ ///
+ /// 获取或设置查询类型。
+ ///
+ [Newtonsoft.Json.JsonProperty("query_type")]
+ [System.Text.Json.Serialization.JsonPropertyName("query_type")]
+ public int? QueryType { get; set; }
+
+ ///
+ /// 获取或设置查询范围。
+ ///
+ [Newtonsoft.Json.JsonProperty("query_range")]
+ [System.Text.Json.Serialization.JsonPropertyName("query_range")]
+ public int? QueryRange { get; set; }
+
+ ///
+ /// 获取或设置精确匹配字段类型。
+ ///
+ [Newtonsoft.Json.JsonProperty("full_match_field")]
+ [System.Text.Json.Serialization.JsonPropertyName("full_match_field")]
+ public int? FullMatchField { get; set; }
+
+ ///
+ /// 获取或设置翻页标记。
+ ///
+ [Newtonsoft.Json.JsonProperty("cursor")]
+ [System.Text.Json.Serialization.JsonPropertyName("cursor")]
+ public string? Cursor { get; set; }
+
+ ///
+ /// 获取或设置分页每页数量。
+ ///
+ [Newtonsoft.Json.JsonProperty("limit")]
+ [System.Text.Json.Serialization.JsonPropertyName("limit")]
+ public int? Limit { get; set; }
+ }
+
+ public class QueryResult : CgibinServiceContactSearchResponse.Types.QueryResult
+ {
+ }
+ }
+
+ ///
+ /// 获取或设置搜索请求信息。
+ ///
+ [Newtonsoft.Json.JsonProperty("query_request")]
+ [System.Text.Json.Serialization.JsonPropertyName("query_request")]
+ public Types.QueryRequest QueryRequest { get; set; } = default!;
+
+ ///
+ /// 获取或设置搜索结果信息。
+ ///
+ [Newtonsoft.Json.JsonProperty("query_result")]
+ [System.Text.Json.Serialization.JsonPropertyName("query_result")]
+ public Types.QueryResult QueryResult { get; set; } = default!;
+
+ ///
+ /// 获取或设置翻页是否结束。
+ ///
+ [Newtonsoft.Json.JsonProperty("is_last")]
+ [System.Text.Json.Serialization.JsonPropertyName("is_last")]
+ public bool IsLast { get; set; }
+
+ ///
+ /// 获取或设置翻页标记。
+ ///
+ [Newtonsoft.Json.JsonProperty("next_cursor")]
+ [System.Text.Json.Serialization.JsonPropertyName("next_cursor")]
+ public string? NextCursor { get; set; }
+ }
+ }
+
+ ///
+ /// 获取或设置搜索列表。
+ ///
+ [Newtonsoft.Json.JsonProperty("query_result_list")]
+ [System.Text.Json.Serialization.JsonPropertyName("query_result_list")]
+ public Types.Query[] QueryList { get; set; } = default!;
+ }
+}
diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/Contact/CgibinServiceContactSearchRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/Contact/CgibinServiceContactSearchRequest.cs
new file mode 100644
index 00000000..208d5000
--- /dev/null
+++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/Contact/CgibinServiceContactSearchRequest.cs
@@ -0,0 +1,71 @@
+namespace SKIT.FlurlHttpClient.Wechat.Work.Models
+{
+ ///
+ /// 表示 [POST] /cgi-bin/service/contact/search 接口的请求。
+ ///
+ public class CgibinServiceContactSearchRequest : WechatWorkRequest
+ {
+ ///
+ /// 获取或设置服务商 AccessToken。
+ ///
+ [Newtonsoft.Json.JsonIgnore]
+ [System.Text.Json.Serialization.JsonIgnore]
+ public string ProviderAccessToken { get; set; } = string.Empty;
+
+ ///
+ /// 获取或设置授权方 CorpId。
+ ///
+ [Newtonsoft.Json.JsonProperty("auth_corpid")]
+ [System.Text.Json.Serialization.JsonPropertyName("auth_corpid")]
+ public string AuthorizerCorpId { get; set; } = string.Empty;
+
+ ///
+ /// 获取或设置应用 ID。
+ ///
+ [Newtonsoft.Json.JsonProperty("agentid")]
+ [System.Text.Json.Serialization.JsonPropertyName("agentid")]
+ public int? AgentId { get; set; }
+
+ ///
+ /// 获取或设置搜索关键词。
+ ///
+ [Newtonsoft.Json.JsonProperty("query_word")]
+ [System.Text.Json.Serialization.JsonPropertyName("query_word")]
+ public string QueryWord { get; set; } = string.Empty;
+
+ ///
+ /// 获取或设置查询类型。
+ ///
+ [Newtonsoft.Json.JsonProperty("query_type")]
+ [System.Text.Json.Serialization.JsonPropertyName("query_type")]
+ public int? QueryType { get; set; }
+
+ ///
+ /// 获取或设置查询范围。
+ ///
+ [Newtonsoft.Json.JsonProperty("query_range")]
+ [System.Text.Json.Serialization.JsonPropertyName("query_range")]
+ public int? QueryRange { get; set; }
+
+ ///
+ /// 获取或设置精确匹配字段类型。
+ ///
+ [Newtonsoft.Json.JsonProperty("full_match_field")]
+ [System.Text.Json.Serialization.JsonPropertyName("full_match_field")]
+ public int? FullMatchField { get; set; }
+
+ ///
+ /// 获取或设置翻页标记。
+ ///
+ [Newtonsoft.Json.JsonProperty("cursor")]
+ [System.Text.Json.Serialization.JsonPropertyName("cursor")]
+ public string? Cursor { get; set; }
+
+ ///
+ /// 获取或设置分页每页数量。
+ ///
+ [Newtonsoft.Json.JsonProperty("limit")]
+ [System.Text.Json.Serialization.JsonPropertyName("limit")]
+ public int? Limit { get; set; }
+ }
+}
diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/Contact/CgibinServiceContactSearchResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/Contact/CgibinServiceContactSearchResponse.cs
new file mode 100644
index 00000000..5a4c4d83
--- /dev/null
+++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/Contact/CgibinServiceContactSearchResponse.cs
@@ -0,0 +1,86 @@
+namespace SKIT.FlurlHttpClient.Wechat.Work.Models
+{
+ ///
+ /// 表示 [POST] /cgi-bin/service/contact/search 接口的响应。
+ ///
+ public class CgibinServiceContactSearchResponse : WechatWorkResponse
+ {
+ public static class Types
+ {
+ public class QueryResult
+ {
+ public static class Types
+ {
+ public class User
+ {
+ ///
+ /// 获取或设置查询到的用户 UserId 列表。
+ ///
+ [Newtonsoft.Json.JsonProperty("userid")]
+ [System.Text.Json.Serialization.JsonPropertyName("userid")]
+ public string[]? UserIdList { get; set; } = default!;
+
+ ///
+ /// 获取或设置查询到的用户 OpenUserId 列表。
+ ///
+ [Newtonsoft.Json.JsonProperty("open_userid")]
+ [System.Text.Json.Serialization.JsonPropertyName("open_userid")]
+ public string[]? OpenUserIdList { get; set; } = default!;
+ }
+
+ public class Department
+ {
+ ///
+ /// 获取或设置查询到的部门 ID 列表。
+ ///
+ [Newtonsoft.Json.JsonProperty("department_id")]
+ [System.Text.Json.Serialization.JsonPropertyName("department_id")]
+ public long[]? DepartmentIdList { get; set; } = default!;
+ }
+ }
+
+ ///
+ /// 获取或设置查询到的用户信息。
+ ///
+ [Newtonsoft.Json.JsonProperty("user")]
+ [System.Text.Json.Serialization.JsonPropertyName("user")]
+ public Types.User? User { get; set; }
+
+ ///
+ /// 获取或设置查询到的部门信息。
+ ///
+ [Newtonsoft.Json.JsonProperty("party")]
+ [System.Text.Json.Serialization.JsonPropertyName("party")]
+ public Types.Department? Department { get; set; }
+
+ ///
+ /// 获取或设置查询到的已离职用户信息。
+ ///
+ [Newtonsoft.Json.JsonProperty("dismiss_user")]
+ [System.Text.Json.Serialization.JsonPropertyName("dismiss_user")]
+ public Types.User? DismissUser { get; set; }
+ }
+ }
+
+ ///
+ /// 获取或设置搜索结果信息。
+ ///
+ [Newtonsoft.Json.JsonProperty("query_result")]
+ [System.Text.Json.Serialization.JsonPropertyName("query_result")]
+ public Types.QueryResult QueryResult { get; set; } = default!;
+
+ ///
+ /// 获取或设置翻页是否结束。
+ ///
+ [Newtonsoft.Json.JsonProperty("is_last")]
+ [System.Text.Json.Serialization.JsonPropertyName("is_last")]
+ public bool IsLast { get; set; }
+
+ ///
+ /// 获取或设置翻页标记。
+ ///
+ [Newtonsoft.Json.JsonProperty("next_cursor")]
+ [System.Text.Json.Serialization.JsonPropertyName("next_cursor")]
+ public string? NextCursor { get; set; }
+ }
+}
diff --git a/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/Contact/CgibinServiceContactBatchSearchRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/Contact/CgibinServiceContactBatchSearchRequest.json
new file mode 100644
index 00000000..77537e92
--- /dev/null
+++ b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/Contact/CgibinServiceContactBatchSearchRequest.json
@@ -0,0 +1,14 @@
+{
+ "auth_corpid": "wwxxxxxx",
+ "agentid": 1000046,
+ "query_request_list": [
+ {
+ "query_word": "zhangsan",
+ "query_type": 1,
+ "query_range": 1,
+ "limit": 50,
+ "full_match_field": 1,
+ "cursor": "CURSOR"
+ }
+ ]
+}
diff --git a/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/Contact/CgibinServiceContactBatchSearchResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/Contact/CgibinServiceContactBatchSearchResponse.json
new file mode 100644
index 00000000..0cf303bc
--- /dev/null
+++ b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/Contact/CgibinServiceContactBatchSearchResponse.json
@@ -0,0 +1,29 @@
+{
+ "errcode": 0,
+ "errmsg": "ok",
+ "query_result_list": [
+ {
+ "query_request": {
+ "query_word": "zhangsan",
+ "query_type": 1,
+ "limit": 50,
+ "cursor": "CURSOR"
+ },
+ "query_result": {
+ "user": {
+ "userid": ["zhangshan", "lisi"],
+ "open_userid": ["wwxxxx", "wwxxxa"]
+ },
+ "party": {
+ "department_id": [1, 2, 3]
+ },
+ "dismiss_user": {
+ "userid": ["zhangshan", "lisi"],
+ "open_userid": ["wwxxxx", "wwxxxa"]
+ }
+ },
+ "is_last": false,
+ "next_cursor": "NEXT_CURSOR"
+ }
+ ]
+}
diff --git a/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/Contact/CgibinServiceContactSearchRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/Contact/CgibinServiceContactSearchRequest.json
new file mode 100644
index 00000000..e599feee
--- /dev/null
+++ b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/Contact/CgibinServiceContactSearchRequest.json
@@ -0,0 +1,10 @@
+{
+ "auth_corpid": "wwxxxxxx",
+ "query_word": "zhangsan",
+ "query_type": 1,
+ "query_range": 1,
+ "agentid": 1000046,
+ "limit": 50,
+ "full_match_field": 1,
+ "cursor": "CURSOR"
+}
diff --git a/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/Contact/CgibinServiceContactSearchResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/Contact/CgibinServiceContactSearchResponse.json
new file mode 100644
index 00000000..abe8a07e
--- /dev/null
+++ b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/Contact/CgibinServiceContactSearchResponse.json
@@ -0,0 +1,19 @@
+{
+ "errcode": 0,
+ "errmsg": "ok",
+ "query_result": {
+ "user": {
+ "userid": ["zhangshan", "lisi"],
+ "open_userid": ["wwxxxx", "wwxxxa"]
+ },
+ "party": {
+ "department_id": [1, 2, 3]
+ },
+ "dismiss_user": {
+ "userid": ["zhangshan", "lisi"],
+ "open_userid": ["wwxxxx", "wwxxxa"]
+ }
+ },
+ "is_last": false,
+ "next_cursor": "NEXT_CURSOR"
+}