mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-07-15 23:13:32 +08:00
feat(work): 新增获取单个部门和子部门 ID 列表的相关接口
This commit is contained in:
parent
5b314d0683
commit
ef508c1f92
@ -102,5 +102,51 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinDepartmentListResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [GET] /cgi-bin/department/simplelist 接口。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95350 </para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95406 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinDepartmentSimpleListResponse> ExecuteCgibinDepartmentSimpleListAsync(this WechatWorkClient client, Models.CgibinDepartmentSimpleListRequest 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.Get, "cgi-bin", "department", "simplelist")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
if (request.ParentDepartmentId != null)
|
||||
flurlReq.SetQueryParam("id", request.ParentDepartmentId.Value);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinDepartmentSimpleListResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [GET] /cgi-bin/department/get 接口。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95351 </para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95407 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinDepartmentGetResponse> ExecuteCgibinDepartmentGetAsync(this WechatWorkClient client, Models.CgibinDepartmentGetRequest 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.Get, "cgi-bin", "department", "get")
|
||||
.SetQueryParam("access_token", request.AccessToken)
|
||||
.SetQueryParam("id", request.DepartmentId);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinDepartmentGetResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /cgi-bin/department/get 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinDepartmentGetRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置部门 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public int DepartmentId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /cgi-bin/department/get 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinDepartmentGetResponse : WechatWorkResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Department : CgibinDepartmentListResponse.Types.Department
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置部门信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("department")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("department")]
|
||||
public Types.Department Department { get; set; } = default!;
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /cgi-bin/department/simplelist 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinDepartmentSimpleListRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置指定上级部门 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public int? ParentDepartmentId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /cgi-bin/department/simplelist 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinDepartmentSimpleListResponse : WechatWorkResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Department
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置部门 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("id")]
|
||||
public int DepartmentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置上级部门 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("parentid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("parentid")]
|
||||
public int ParentDepartmentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置在上级部门中的次序值。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("order")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("order")]
|
||||
public long DepartmentOrder { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置部门列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("department_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("department_id")]
|
||||
public Types.Department[] DepartmentList { get; set; } = default!;
|
||||
}
|
||||
}
|
@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>企业微信 API 接口域名。</para>
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
{
|
||||
/// <summary>
|
||||
/// 表示企业微信 API 请求的基类。
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
{
|
||||
|
@ -1 +0,0 @@
|
||||
{}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"department": {
|
||||
"id": 2,
|
||||
"name": "广州研发中心",
|
||||
"name_en": "RDGZ",
|
||||
"department_leader": [ "zhangsan", "lisi" ],
|
||||
"parentid": 1,
|
||||
"order": 10
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
{}
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"department_id": [
|
||||
{
|
||||
"id": 2,
|
||||
"parentid": 1,
|
||||
"order": 10
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"parentid": 2,
|
||||
"order": 40
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user