This commit is contained in:
Fu Diwei
2022-02-16 11:33:32 +08:00
102 changed files with 631 additions and 455 deletions

View File

@@ -1,14 +1,9 @@
# *********************************** WARNING **************************************
# We have not automatically identified the languages in your repository.
# Please edit the `language:` list below to add the appropriate supported languages.
# **********************************************************************************
name: "CodeQL"
on:
push:
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
workflow_dispatch:
@@ -16,50 +11,25 @@ jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: [csharp]
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
steps:
- name: Checkout repository
- name: Checkout Repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# Initializes the CodeQL tools for scanning.
fetch-depth: 1
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
queries: security-and-quality
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

24
.github/workflows/super-linter.yml vendored Normal file
View File

@@ -0,0 +1,24 @@
# For more information, see:
# https://github.com/github/super-linter
name: CodeLint
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
run-lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Lint Code Base
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -436,6 +436,10 @@
<summary>[展开查看]</summary>
- Release 2.6.1
- **修复**:修复部门 ID 可能溢出的问题。([Gitee PR #5](https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat/pulls/5)
- Release 2.5.0
- **变更**:升级公共组件。

View File

@@ -88,7 +88,7 @@ else
- [如何解密经过加密处理的开放数据?](./Advanced_OpenDataDecryption.md)
- [如何生成 JS-SDK 初始化时所需的参数及签名?](./Advanced_JSSDK.md)
- [如何生成 JS-SDK 初始化时所需的参数及签名?](./Advanced_Parameters.md)
- [如何扩展额外的 API](./Advanced_Extensions.md)

View File

@@ -50,6 +50,6 @@ var paramMap = client.GenerateParametersForJsapiGetBrandPayRequest(request.AppId
- 生成客户端小程序唤起开通车主服务页面所需的参数字典:`GenerateParametersForMiniProgramVehiclePAPPayPartnerAuth`
- 生成客户端小程序唤起免密支付升级无感支付页面所需的参数字典:`GenerateParametersForAppVehiclePAPPayPartnerNoSensePayment`
- 生成客户端 App 唤起免密支付升级无感支付页面所需的参数字典:`GenerateParametersForAppVehiclePAPPayPartnerNoSensePayment`
- 生成客户端 App 唤起免密支付升级无感支付页面所需的参数字典:`GenerateParametersForMiniProgramVehiclePAPPayPartnerNoSensePayment`
- 生成客户端小程序唤起免密支付升级无感支付页面所需的参数字典:`GenerateParametersForMiniProgramVehiclePAPPayPartnerNoSensePayment`

View File

@@ -98,4 +98,4 @@ else
- [如何验证回调通知事件签名?](./Advanced_EventSignatureVerification.md)
- [如何生成客户端调起支付时所需的参数及签名?](./Advanced_Payment.md)
- [如何生成客户端调起支付时所需的参数及签名?](./Advanced_Parameters.md)

View File

@@ -112,7 +112,7 @@ else
- [如何验证回调通知事件签名?](./Advanced_EventSignatureVerification.md)
- [如何生成客户端调起支付时所需的参数及签名?](./Advanced_Payment.md)
- [如何生成客户端调起支付时所需的参数及签名?](./Advanced_Parameters.md)
- [如何扩展额外的 API](./Advanced_Extensions.md)

View File

@@ -84,6 +84,6 @@ else
- [如何解析回调通知事件?](./Advanced_EventDataDeserialization.md)
- [如何生成 JS-SDK 初始化时所需的参数及签名?](./Advanced_JSSDK.md)
- [如何生成 JS-SDK 初始化时所需的参数及签名?](./Advanced_Parameters.md)
- [如何扩展额外的 API](./Advanced_Extensions.md)

View File

@@ -40,7 +40,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="JWT" Version="8.8.1" />
<PackageReference Include="JWT" Version="8.9.0" />
<PackageReference Include="SKIT.FlurlHttpClient.Common" Version="2.2.0" />
</ItemGroup>

View File

@@ -6,7 +6,7 @@ using Newtonsoft.Json;
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities
{
internal static class JWTUtility
internal static class JwtUtility
{
private static readonly Lazy<IJwtEncoder> _encoder = new Lazy<IJwtEncoder>(() =>
{

View File

@@ -0,0 +1,25 @@
using System;
using JWT;
using JWT.Algorithms;
using JWT.Serializers;
using Newtonsoft.Json;
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities
{
internal static class JwtUtility
{
private static readonly Lazy<IJwtEncoder> _encoder = new Lazy<IJwtEncoder>(() =>
{
IJwtAlgorithm algorithm = new HMACSHA256Algorithm();
IJsonSerializer serializer = new JsonNetSerializer(new JsonSerializer() { NullValueHandling = NullValueHandling.Ignore });
IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
IJwtEncoder encoder = new JwtEncoder(algorithm, serializer, urlEncoder);
return encoder;
}, isThreadSafe: true);
public static string EncodeWithHS256(object payload, string secret)
{
return _encoder.Value.Encode(payload, secret);
}
}
}

View File

@@ -139,7 +139,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
{
if (data is WechatOpenAIPlatformRequest.Serialization.IEncryptedUrlEncoded)
{
string jwt = Utilities.JWTUtility.EncodeWithHS256(payload: data, secret: Credentials.EncodingAESKey!);
string jwt = Utilities.JwtUtility.EncodeWithHS256(payload: data, secret: Credentials.EncodingAESKey!);
data = new { query = jwt };
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
@@ -8,16 +9,18 @@ using Newtonsoft.Json.Serialization;
namespace Newtonsoft.Json.Converters
{
using SKIT.FlurlHttpClient.Wechat.TenpayV2.Utilities;
internal static class FlattenNArrayObjectConverterBase
{
public const string PROPERTY_WILDCARD_NARRAY_ELEMENT = "$n";
public const string PROPERTY_NAME_NARRAY = "#n";
}
internal abstract partial class FlattenNArrayObjectConverterBase<T> : JsonConverter<T?>
internal abstract partial class FlattenNArrayObjectConverterBase<T> : JsonConverter
where T : class, new()
{
private sealed class InnerTypedJsonProperty
private sealed class InnerTypedJsonPropertyInfo
{
public string PropertyName { get; }
@@ -27,14 +30,17 @@ namespace Newtonsoft.Json.Converters
public bool PropertyIsNArray { get; }
public JsonConverter? JsonConverter { get; }
public JsonConverter? JsonConverterOnRead { get; }
public InnerTypedJsonProperty(string propertyName, PropertyInfo propertyInfo, bool propertyIsNArray, JsonConverter? jsonConverter)
public JsonConverter? JsonConverterOnWrite { get; }
public InnerTypedJsonPropertyInfo(string propertyName, PropertyInfo propertyInfo, bool propertyIsNArray, JsonConverter? jsonReadConverter, JsonConverter? jsonWriteConverter)
{
PropertyName = propertyName;
PropertyInfo = propertyInfo;
PropertyIsNArray = propertyIsNArray;
JsonConverter = jsonConverter;
JsonConverterOnRead = jsonReadConverter;
JsonConverterOnWrite = jsonWriteConverter;
}
}
@@ -53,7 +59,12 @@ namespace Newtonsoft.Json.Converters
get { return true; }
}
public override T? ReadJson(JsonReader reader, Type objectType, T? existingValue, bool hasExistingValue, JsonSerializer serializer)
public override bool CanConvert(Type objectType)
{
return objectType.IsClass && !objectType.IsAbstract && !objectType.IsInterface;
}
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null)
{
@@ -61,44 +72,47 @@ namespace Newtonsoft.Json.Converters
}
else if (reader.TokenType == JsonToken.StartObject)
{
InnerTypedJsonProperty[] typedJsonProperties = GetTypedJsonProperties(objectType);
InnerTypedJsonPropertyInfo[] typedJsonProperties = GetTypedJsonProperties(objectType);
if (typedJsonProperties.Count(p => p.PropertyIsNArray) != 1)
throw new JsonSerializationException("The number of `$n` properties must be only one.");
JObject jObject = JObject.Load(reader);
T tObject = new T();
foreach (JProperty jKey in jObject.Properties())
foreach (JProperty jProperty in jObject.Properties())
{
InnerTypedJsonProperty? typedJsonProperty = typedJsonProperties.SingleOrDefault(e => e.PropertyName == jKey.Name);
if (typedJsonProperty != null)
InnerTypedJsonPropertyInfo? typedJsonPropertyInfo = typedJsonProperties.SingleOrDefault(e => e.PropertyName == jProperty.Name);
if (typedJsonPropertyInfo != null)
{
// 处理普通属性
JsonSerializer tmpSerializer = serializer;
if (typedJsonProperty.JsonConverter != null)
{
tmpSerializer = JsonSerializer.CreateDefault(serializer.ExtractSerializerSettings());
tmpSerializer.Converters.Add(typedJsonProperty.JsonConverter);
}
object? value = jObject[typedJsonProperty.PropertyName]?.ToObject(typedJsonProperty.PropertyType, tmpSerializer);
typedJsonProperty.PropertyInfo.SetValue(tObject, value);
JsonSerializer tmpSerializer = GetClonedJsonSerializer(serializer, typedJsonPropertyInfo.JsonConverterOnRead);
object? propertyValue = jProperty.Value?.ToObject(typedJsonPropertyInfo.PropertyType, tmpSerializer);
typedJsonPropertyInfo.PropertyInfo.SetValue(tObject, propertyValue);
}
else if (TryMatchNArrayIndex(jKey.Name, out int index))
else if (TryMatchNArrayIndex(jProperty.Name, out int index))
{
// 处理 $n 属性
InnerTypedJsonProperty narrayJsonProperty = typedJsonProperties.Single(e => e.PropertyIsNArray);
object? value = narrayJsonProperty.PropertyInfo.GetValue(tObject);
typedJsonPropertyInfo = typedJsonProperties.Single(e => e.PropertyIsNArray);
JsonSerializer tmpSerializer = serializer;
Array? propertyValue = typedJsonPropertyInfo.PropertyInfo.GetValue(tObject) as Array;
ReflectionUtility.CreateOrExpandArray(ref propertyValue, typedJsonPropertyInfo.PropertyType.GetElementType()!, index + 1);
ReflectionUtility.CreateOrExpandArrayElement(propertyValue!, index, (object element) =>
{
InnerTypedJsonPropertyInfo? insider = GetTypedJsonProperties(element.GetType())
.SingleOrDefault(p => string.Equals(p.PropertyName.Replace(PROPERTY_WILDCARD_NARRAY_ELEMENT, index.ToString()), jProperty.Name));
if (insider != null)
{
JsonSerializer tmpSerializer = GetClonedJsonSerializer(serializer, insider.JsonConverterOnRead);
object? elementPropertyValue = jProperty.Value?.ToObject(insider.PropertyType, tmpSerializer);
insider.PropertyInfo.SetValue(element, elementPropertyValue);
}
Array array = CreateOrExpandNArray(value, narrayJsonProperty.PropertyType.GetElementType()!, index + 1);
object? element = CreateOrUpdateNArrayElement(array, index, jKey.Name, jKey.Value, tmpSerializer);
narrayJsonProperty.PropertyInfo.SetValue(tObject, array);
return element;
});
typedJsonPropertyInfo.PropertyInfo.SetValue(tObject, propertyValue);
}
else if (serializer.MissingMemberHandling == MissingMemberHandling.Error)
{
throw new JsonSerializationException($"Could not find member `{jKey.Name}` on object of type `{objectType.Name}`.");
throw new JsonSerializationException($"Could not find member `{jProperty.Name}` on object of type `{objectType.Name}`.");
}
}
@@ -108,7 +122,7 @@ namespace Newtonsoft.Json.Converters
throw new JsonSerializationException();
}
public override void WriteJson(JsonWriter writer, T? value, JsonSerializer serializer)
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
if (value is null)
{
@@ -119,29 +133,28 @@ namespace Newtonsoft.Json.Converters
writer.WriteStartObject();
JsonObjectContract jsonContract = (JsonObjectContract)serializer.ContractResolver.ResolveContract(value.GetType());
foreach (JsonProperty jsonProperty in jsonContract.Properties)
foreach (JsonProperty jsonContractProperty in jsonContract.Properties)
{
if (jsonProperty.Ignored)
if (jsonContractProperty.Ignored)
continue;
if (!(jsonProperty.ShouldSerialize == null || jsonProperty.ShouldSerialize(value)))
if (!(jsonContractProperty.ShouldSerialize == null || jsonContractProperty.ShouldSerialize(value)))
continue;
string propertyKey = jsonProperty.PropertyName;
object? propertyValue = jsonProperty.ValueProvider.GetValue(value);
string propertyName = jsonContractProperty.PropertyName;
object? propertyValue = jsonContractProperty.ValueProvider?.GetValue(value);
if (propertyValue is null)
{
if (serializer.NullValueHandling == NullValueHandling.Ignore)
continue;
}
if (!PROPERTY_NAME_NARRAY.Equals(propertyKey))
if (!PROPERTY_NAME_NARRAY.Equals(propertyName))
{
// 处理普通属性
writer.WritePropertyName(propertyKey);
writer.WritePropertyName(propertyName);
if (jsonProperty.Converter != null && jsonProperty.Converter.CanWrite)
if (jsonContractProperty.Converter != null && jsonContractProperty.Converter.CanWrite)
{
jsonProperty.Converter.WriteJson(writer, propertyValue, serializer);
jsonContractProperty.Converter.WriteJson(writer, propertyValue, serializer);
}
else
{
@@ -150,7 +163,6 @@ namespace Newtonsoft.Json.Converters
}
else
{
// 处理 $n 属性
if (propertyValue is null)
continue;
@@ -161,10 +173,10 @@ namespace Newtonsoft.Json.Converters
if (jSubToken == null)
continue;
foreach (JProperty jSubKey in jSubToken)
foreach (JProperty jSubProperty in jSubToken)
{
writer.WritePropertyName(jSubKey.Name.Replace(PROPERTY_WILDCARD_NARRAY_ELEMENT, i.ToString()));
serializer.Serialize(writer, jSubKey.Value);
writer.WritePropertyName(jSubProperty.Name.Replace(PROPERTY_WILDCARD_NARRAY_ELEMENT, i.ToString()));
serializer.Serialize(writer, jSubProperty.Value);
}
}
}
@@ -173,16 +185,16 @@ namespace Newtonsoft.Json.Converters
writer.WriteEndObject();
}
private static InnerTypedJsonProperty[] GetTypedJsonProperties(Type type)
private static InnerTypedJsonPropertyInfo[] GetTypedJsonProperties(Type type)
{
if (type == null) throw new ArgumentNullException(nameof(type));
string mappedTypeKey = type.AssemblyQualifiedName ?? type.GetHashCode().ToString();
InnerTypedJsonProperty[]? typedJsonProperties = (InnerTypedJsonProperty[]?)_mappedTypeJsonProperties[mappedTypeKey];
string mappedKey = type.AssemblyQualifiedName ?? type.GetHashCode().ToString();
InnerTypedJsonPropertyInfo[]? mappedValue = (InnerTypedJsonPropertyInfo[]?)_mappedTypeJsonProperties[mappedKey];
if (typedJsonProperties == null)
if (mappedValue == null)
{
typedJsonProperties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public)
mappedValue = type.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.Where(p =>
{
if (p.CanWrite || p.GetCustomAttributes<JsonPropertyAttribute>(inherit: true).Any())
@@ -195,24 +207,39 @@ namespace Newtonsoft.Json.Converters
.Select(p =>
{
string name = p.GetCustomAttribute<JsonPropertyAttribute>(inherit: true)?.PropertyName ?? p.Name;
JsonConverter? converter = p.GetCustomAttributes<JsonConverterAttribute>(inherit: true)
IEnumerable<JsonConverter> converters = p.GetCustomAttributes<JsonConverterAttribute>(inherit: true)
.OrderByDescending(attr => attr.IsDefaultAttribute())
.Select(attr => (JsonConverter)Activator.CreateInstance(attr.ConverterType, attr.ConverterParameters)!)
.FirstOrDefault();
return new InnerTypedJsonProperty
.Select(attr => (JsonConverter)Activator.CreateInstance(attr.ConverterType, attr.ConverterParameters)!);
JsonConverter? readConverter = converters.FirstOrDefault(c => c.CanRead);
JsonConverter? writeConverter = converters.FirstOrDefault(c => c.CanWrite);
return new InnerTypedJsonPropertyInfo
(
propertyName: name,
propertyInfo: p,
propertyIsNArray: PROPERTY_NAME_NARRAY.Equals(name) && p.PropertyType.IsArray && p.PropertyType.GetElementType()!.IsClass,
jsonConverter: converter
jsonReadConverter: readConverter,
jsonWriteConverter: writeConverter
);
})
.OrderBy(e => e.PropertyInfo.GetCustomAttribute<JsonPropertyAttribute>(inherit: true)?.Order)
.ToArray();
_mappedTypeJsonProperties[mappedTypeKey] = typedJsonProperties;
_mappedTypeJsonProperties[mappedKey] = mappedValue;
}
return typedJsonProperties;
return mappedValue;
}
private static JsonSerializer GetClonedJsonSerializer(JsonSerializer serializer, JsonConverter? converter)
{
JsonSerializer serializerCopy = serializer;
if (converter != null)
{
serializerCopy = JsonSerializer.CreateDefault(serializer.ExtractSerializerSettings());
serializerCopy.Converters.Add(converter);
}
return serializerCopy;
}
private static bool TryMatchNArrayIndex(string key, out int index)
@@ -228,70 +255,5 @@ namespace Newtonsoft.Json.Converters
index = -1;
return false;
}
private static Array CreateOrExpandNArray(object? array, Type elementType, int capacity)
{
if (elementType == null) throw new ArgumentNullException(nameof(elementType));
if (capacity <= 0) throw new ArgumentOutOfRangeException(nameof(capacity));
if (array == null)
{
return Array.CreateInstance(elementType, capacity);
}
Array src = (Array)array;
if (src.Length < capacity)
{
Array dst = Array.CreateInstance(elementType, capacity);
Array.Copy(src, dst, src.Length);
return dst;
}
return src;
}
private static object CreateOrUpdateNArrayElement(Array array, int index, string jKey, JToken? jValue, JsonSerializer serializer)
{
if (array == null) throw new ArgumentNullException(nameof(array));
if (index < 0) throw new ArgumentOutOfRangeException(nameof(index));
object? element = array.GetValue(index);
Type elementType = array.GetType().GetElementType()!;
if (element == null)
{
if (elementType.IsAbstract || elementType.IsInterface)
{
throw new NotSupportedException();
}
else if (elementType.IsArray)
{
element = Array.CreateInstance(elementType, 0);
}
else
{
element = Activator.CreateInstance(elementType);
}
array.SetValue(element, index);
}
InnerTypedJsonProperty? typedJsonProperty = GetTypedJsonProperties(elementType)
.SingleOrDefault(p => string.Equals(p.PropertyName.Replace(PROPERTY_WILDCARD_NARRAY_ELEMENT, index.ToString()), jKey));
if (typedJsonProperty != null)
{
if (typedJsonProperty.JsonConverter != null)
{
serializer = JsonSerializer.CreateDefault(serializer.ExtractSerializerSettings());
serializer.Converters.Add(typedJsonProperty.JsonConverter);
}
object? obj = jValue?.ToObject(typedJsonProperty.PropertyType, serializer);
typedJsonProperty.PropertyInfo.SetValue(element, obj);
}
return element!;
}
}
}

View File

@@ -8,6 +8,8 @@ using System.Text.RegularExpressions;
namespace System.Text.Json.Converters
{
using SKIT.FlurlHttpClient.Wechat.TenpayV2.Utilities;
internal static class FlattenNArrayObjectConverterBase
{
public const string PROPERTY_WILDCARD_NARRAY_ELEMENT = Newtonsoft.Json.Converters.FlattenNArrayObjectConverterBase.PROPERTY_WILDCARD_NARRAY_ELEMENT;
@@ -17,7 +19,7 @@ namespace System.Text.Json.Converters
internal class FlattenNArrayObjectConverterBase<T> : JsonConverter<T?>
where T : class, new()
{
private sealed class InnerTypedJsonProperty
private sealed class InnerTypedJsonPropertyInfo
{
public string PropertyName { get; }
@@ -29,7 +31,7 @@ namespace System.Text.Json.Converters
public JsonConverter? JsonConverter { get; }
public InnerTypedJsonProperty(string propertyName, PropertyInfo propertyInfo, bool propertyIsNArray, JsonConverter? jsonConverter)
public InnerTypedJsonPropertyInfo(string propertyName, PropertyInfo propertyInfo, bool propertyIsNArray, JsonConverter? jsonConverter)
{
PropertyName = propertyName;
PropertyInfo = propertyInfo;
@@ -43,6 +45,11 @@ namespace System.Text.Json.Converters
private static readonly Hashtable _mappedTypeJsonProperties = new Hashtable();
public override bool CanConvert(Type typeToConvert)
{
return typeToConvert.IsClass && !typeToConvert.IsAbstract && !typeToConvert.IsInterface;
}
public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.Null)
@@ -51,40 +58,43 @@ namespace System.Text.Json.Converters
}
else if (reader.TokenType == JsonTokenType.StartObject)
{
InnerTypedJsonProperty[] typedJsonProperties = GetTypedJsonProperties(typeToConvert);
InnerTypedJsonPropertyInfo[] typedJsonProperties = GetTypedJsonProperties(typeToConvert);
if (typedJsonProperties.Count(p => p.PropertyIsNArray) != 1)
throw new JsonException("The number of `$n` properties must be only one.");
JsonElement jElement = JsonDocument.ParseValue(ref reader).RootElement.Clone();
T tObject = new T();
foreach (JsonProperty jKey in jElement.EnumerateObject())
foreach (JsonProperty jProperty in jElement.EnumerateObject())
{
InnerTypedJsonProperty? typedJsonProperty = typedJsonProperties.SingleOrDefault(e => e.PropertyName == jKey.Name);
if (typedJsonProperty != null)
InnerTypedJsonPropertyInfo? typedJsonPropertyInfo = typedJsonProperties.SingleOrDefault(e => e.PropertyName == jProperty.Name);
if (typedJsonPropertyInfo != null)
{
// 处理普通属性
JsonSerializerOptions tmpOptions = options;
if (typedJsonProperty.JsonConverter != null)
{
tmpOptions = new JsonSerializerOptions(options);
tmpOptions.Converters.Add(typedJsonProperty.JsonConverter);
}
object? value = JsonSerializer.Deserialize(jKey.Value, typedJsonProperty.PropertyType, tmpOptions);
typedJsonProperty.PropertyInfo.SetValue(tObject, value);
JsonSerializerOptions tmpOptions = GetClonedJsonSerializerOptions(options, typedJsonPropertyInfo.JsonConverter);
object? propertyValue = jProperty.Value.Deserialize(typedJsonPropertyInfo.PropertyType, tmpOptions);
typedJsonPropertyInfo.PropertyInfo.SetValue(tObject, propertyValue);
}
else if (TryMatchNArrayIndex(jKey.Name, out int index))
else if (TryMatchNArrayIndex(jProperty.Name, out int index))
{
// 处理 $n 属性
InnerTypedJsonProperty narrayJsonProperty = typedJsonProperties.Single(e => e.PropertyIsNArray);
object? value = narrayJsonProperty.PropertyInfo.GetValue(tObject);
typedJsonPropertyInfo = typedJsonProperties.Single(e => e.PropertyIsNArray);
JsonSerializerOptions tmpOptions = options;
Array? propertyValue = typedJsonPropertyInfo.PropertyInfo.GetValue(tObject) as Array;
ReflectionUtility.CreateOrExpandArray(ref propertyValue, typedJsonPropertyInfo.PropertyType.GetElementType()!, index + 1);
ReflectionUtility.CreateOrExpandArrayElement(propertyValue!, index, (object element) =>
{
InnerTypedJsonPropertyInfo? insider = GetTypedJsonProperties(element.GetType())
.SingleOrDefault(p => string.Equals(p.PropertyName.Replace(PROPERTY_WILDCARD_NARRAY_ELEMENT, index.ToString()), jProperty.Name));
if (insider != null)
{
JsonSerializerOptions tmpOptions = GetClonedJsonSerializerOptions(options, insider.JsonConverter);
object? elementPropertyValue = JsonSerializer.Deserialize(jProperty.Value, insider.PropertyType, tmpOptions)!;
insider.PropertyInfo.SetValue(element, elementPropertyValue);
}
Array array = CreateOrExpandNArray(value, narrayJsonProperty.PropertyType.GetElementType()!, index + 1);
object? element = CreateOrUpdateNArrayElement(array, index, jKey.Name, jKey.Value, tmpOptions);
narrayJsonProperty.PropertyInfo.SetValue(tObject, array);
return element;
});
typedJsonPropertyInfo.PropertyInfo.SetValue(tObject, propertyValue);
}
}
return tObject;
@@ -103,48 +113,39 @@ namespace System.Text.Json.Converters
writer.WriteStartObject();
foreach (InnerTypedJsonProperty typedJsonProperty in GetTypedJsonProperties(value.GetType()))
foreach (InnerTypedJsonPropertyInfo typedJsonProperty in GetTypedJsonProperties(value.GetType()))
{
if (!typedJsonProperty.PropertyIsNArray)
{
// 处理普通属性
string propertyKey = typedJsonProperty.PropertyName;
string propertyName = typedJsonProperty.PropertyName;
object? propertyValue = typedJsonProperty.PropertyInfo.GetValue(value);
if (propertyValue is null)
{
if (options.DefaultIgnoreCondition == JsonIgnoreCondition.Always || options.DefaultIgnoreCondition == JsonIgnoreCondition.WhenWritingNull)
continue;
}
else if (propertyValue == (propertyValue.GetType().IsValueType ? Activator.CreateInstance(propertyValue.GetType()) : null))
if (propertyValue == (typedJsonProperty.PropertyType.IsValueType ? Activator.CreateInstance(typedJsonProperty.PropertyType) : null))
{
if (options.DefaultIgnoreCondition == JsonIgnoreCondition.Always || options.DefaultIgnoreCondition == JsonIgnoreCondition.WhenWritingDefault)
continue;
}
JsonSerializerOptions tmpOptions = options;
JsonConverter? tmpConverter = typedJsonProperty.JsonConverter;
if (tmpConverter != null)
{
tmpOptions = new JsonSerializerOptions(options);
tmpOptions.Converters.Add(tmpConverter);
}
if (tmpConverter != null && CheckTypeIsSubclassOf(tmpConverter.GetType(), typeof(TextualObjectInJsonFormatConverterBase<>)))
JsonSerializerOptions tmpOptions = GetClonedJsonSerializerOptions(options, typedJsonProperty.JsonConverter);
if (typedJsonProperty.JsonConverter != null && ReflectionUtility.CheckTypeIsSubclassOf(typedJsonProperty.JsonConverter.GetType(), typeof(TextualObjectInJsonFormatConverterBase<>)))
{
// TODO: 优化
tmpOptions.Converters.Remove(tmpConverter);
writer.WritePropertyName(propertyKey);
tmpOptions.Converters.Remove(typedJsonProperty.JsonConverter);
writer.WritePropertyName(tmpOptions.PropertyNamingPolicy?.ConvertName(propertyName) ?? propertyName);
writer.WriteStringValue(JsonSerializer.Serialize(propertyValue, tmpOptions));
}
else
{
writer.WritePropertyName(propertyKey);
writer.WritePropertyName(tmpOptions.PropertyNamingPolicy?.ConvertName(propertyName) ?? propertyName);
writer.WriteRawValue(JsonSerializer.Serialize(propertyValue, tmpOptions), skipInputValidation: true);
}
}
else
{
// 处理 $n 属性
Array? array = (Array?)typedJsonProperty.PropertyInfo.GetValue(value);
if (array is null)
continue;
@@ -155,27 +156,59 @@ namespace System.Text.Json.Converters
if (element is null)
continue;
JsonSerializerOptions tmpOptions = options;
JsonConverter? tmpConverter = GetTypedJsonConverter(element.GetType());
if (tmpConverter != null)
{
tmpOptions = new JsonSerializerOptions(options);
tmpOptions.Converters.Add(tmpConverter);
}
JsonSerializerOptions tmpOptions = GetClonedJsonSerializerOptions(options, GetTypedJsonConverter(element.GetType()));
JsonObject jSubObject = JsonSerializer.SerializeToNode(element, tmpOptions)!.AsObject();
foreach (KeyValuePair<string, JsonNode?> jSubKey in jSubObject)
foreach (KeyValuePair<string, JsonNode?> jSubProperty in jSubObject)
{
writer.WritePropertyName(jSubKey.Key.Replace(PROPERTY_WILDCARD_NARRAY_ELEMENT, i.ToString()));
writer.WriteRawValue(jSubKey.Value?.ToJsonString(tmpOptions)!, skipInputValidation: true);
string subPropertyName = jSubProperty.Key.Replace(PROPERTY_WILDCARD_NARRAY_ELEMENT, i.ToString());
JsonNode? subPropertyValue = jSubProperty.Value;
writer.WritePropertyName(tmpOptions.PropertyNamingPolicy?.ConvertName(subPropertyName) ?? subPropertyName);
writer.WriteRawValue(subPropertyValue?.ToJsonString(tmpOptions)!, skipInputValidation: true);
}
}
}
}
writer.WriteEndObject();
}
private static InnerTypedJsonPropertyInfo[] GetTypedJsonProperties(Type type)
{
if (type == null) throw new ArgumentNullException(nameof(type));
string mappedKey = type.AssemblyQualifiedName ?? type.GetHashCode().ToString();
InnerTypedJsonPropertyInfo[]? mappedValue = (InnerTypedJsonPropertyInfo[]?)_mappedTypeJsonProperties[mappedKey];
if (mappedValue == null)
{
mappedValue = type.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.Where(p =>
{
if (p.CanWrite || p.GetCustomAttributes<JsonIncludeAttribute>(inherit: true).Any())
{
return !p.GetCustomAttributes<JsonIgnoreAttribute>(inherit: false).Any();
}
return false;
})
.Select(p =>
{
string name = p.GetCustomAttribute<JsonPropertyNameAttribute>(inherit: true)?.Name ?? p.Name;
return new InnerTypedJsonPropertyInfo
(
propertyName: name,
propertyInfo: p,
propertyIsNArray: PROPERTY_NAME_NARRAY.Equals(name) && p.PropertyType.IsArray && p.PropertyType.GetElementType()!.IsClass,
jsonConverter: GetTypedJsonConverter(p)
);
})
.OrderBy(e => e.PropertyInfo.GetCustomAttribute<JsonPropertyOrderAttribute>(inherit: true)?.Order)
.ToArray();
_mappedTypeJsonProperties[mappedKey] = mappedValue;
}
return mappedValue;
}
private static JsonConverter? GetTypedJsonConverter(MemberInfo? memberInfo)
{
if (memberInfo == null)
@@ -206,67 +239,17 @@ namespace System.Text.Json.Converters
.FirstOrDefault(converter => converter != null);
}
private static InnerTypedJsonProperty[] GetTypedJsonProperties(Type type)
private static JsonSerializerOptions GetClonedJsonSerializerOptions(JsonSerializerOptions options, JsonConverter? converter)
{
if (type == null) throw new ArgumentNullException(nameof(type));
JsonSerializerOptions optionsCopy = options;
string mappedTypeKey = type.AssemblyQualifiedName ?? type.GetHashCode().ToString();
InnerTypedJsonProperty[]? typedJsonProperties = (InnerTypedJsonProperty[]?)_mappedTypeJsonProperties[mappedTypeKey];
if (typedJsonProperties == null)
if (converter != null)
{
typedJsonProperties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.Where(p =>
{
if (p.CanWrite || p.GetCustomAttributes<JsonIncludeAttribute>(inherit: true).Any())
{
return !p.GetCustomAttributes<JsonIgnoreAttribute>(inherit: false).Any();
}
return false;
})
.Select(p =>
{
string name = p.GetCustomAttribute<JsonPropertyNameAttribute>(inherit: true)?.Name ?? p.Name;
if (name.Equals("modify_time_$n"))
{
var cs = p.GetCustomAttributes<JsonConverterAttribute>(inherit: true);
}
return new InnerTypedJsonProperty
(
propertyName: name,
propertyInfo: p,
propertyIsNArray: PROPERTY_NAME_NARRAY.Equals(name) && p.PropertyType.IsArray && p.PropertyType.GetElementType()!.IsClass,
jsonConverter: GetTypedJsonConverter(p)
);
})
.OrderBy(e => e.PropertyInfo.GetCustomAttribute<JsonPropertyOrderAttribute>(inherit: true)?.Order)
.ToArray();
_mappedTypeJsonProperties[mappedTypeKey] = typedJsonProperties;
optionsCopy = new JsonSerializerOptions(options);
optionsCopy.Converters.Add(converter);
}
return typedJsonProperties;
}
private static bool CheckTypeIsSubclassOf(Type type, Type generic)
{
bool IsTheRawGenericType(Type test)
=> generic == (test.IsGenericType ? test.GetGenericTypeDefinition() : test);
bool isTheRawGenericType = type.GetInterfaces().Any(IsTheRawGenericType);
if (isTheRawGenericType)
return true;
Type? tmp = type;
while (tmp != null && tmp != typeof(object))
{
isTheRawGenericType = IsTheRawGenericType(tmp);
if (isTheRawGenericType) return true;
tmp = tmp.BaseType;
}
return false;
return optionsCopy;
}
private static bool TryMatchNArrayIndex(string key, out int index)
@@ -282,70 +265,5 @@ namespace System.Text.Json.Converters
index = -1;
return false;
}
private static Array CreateOrExpandNArray(object? array, Type elementType, int capacity)
{
if (elementType == null) throw new ArgumentNullException(nameof(elementType));
if (capacity <= 0) throw new ArgumentOutOfRangeException(nameof(capacity));
if (array == null)
{
return Array.CreateInstance(elementType, capacity);
}
Array src = (Array)array;
if (src.Length < capacity)
{
Array dst = Array.CreateInstance(elementType, capacity);
Array.Copy(src, dst, src.Length);
return dst;
}
return src;
}
private static object CreateOrUpdateNArrayElement(Array array, int index, string jKey, JsonElement jValue, JsonSerializerOptions serializerOptions)
{
if (array == null) throw new ArgumentNullException(nameof(array));
if (index < 0) throw new ArgumentOutOfRangeException(nameof(index));
object? element = array.GetValue(index);
Type elementType = array.GetType().GetElementType()!;
if (element == null)
{
if (elementType.IsAbstract || elementType.IsInterface)
{
throw new NotSupportedException();
}
else if (elementType.IsArray)
{
element = Array.CreateInstance(elementType, 0);
}
else
{
element = Activator.CreateInstance(elementType);
}
array.SetValue(element, index);
}
InnerTypedJsonProperty? typedJsonProperty = GetTypedJsonProperties(elementType)
.SingleOrDefault(p => string.Equals(p.PropertyName.Replace(PROPERTY_WILDCARD_NARRAY_ELEMENT, index.ToString()), jKey));
if (typedJsonProperty != null)
{
if (typedJsonProperty.JsonConverter != null)
{
serializerOptions = new JsonSerializerOptions(serializerOptions);
serializerOptions.Converters.Add(typedJsonProperty.JsonConverter);
}
object? obj = JsonSerializer.Deserialize(jValue, typedJsonProperty.PropertyType, serializerOptions)!;
typedJsonProperty.PropertyInfo.SetValue(element, obj);
}
return element!;
}
}
}

View File

@@ -1,7 +1,7 @@
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Text.Json.Nodes;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Utilities
{
@@ -13,22 +13,15 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Utilities
return string.Empty;
StringBuilder stringBuilder = new StringBuilder();
JObject jObject = JsonConvert.DeserializeObject<JObject>(json);
JProperty[] jProps = jObject.Properties().OrderBy(p => p.Name).ToArray();
foreach (JProperty jProp in jProps)
JsonObject jObject = JsonNode.Parse(json)!.AsObject();
foreach (KeyValuePair<string, JsonNode?> jProp in jObject.OrderBy(p => p.Key))
{
if (jProp.Value.Type == JTokenType.Null)
{
string key = jProp.Key;
string? value = jProp.Value?.ToString();
if (string.IsNullOrEmpty(value))
continue;
}
else if (jProp.Value.Type == JTokenType.String)
{
if (string.IsNullOrEmpty((string)jProp.Value))
continue;
}
stringBuilder.Append($"{jProp.Name}={jProp.Value}&");
stringBuilder.Append($"{key}={value}&");
}
return stringBuilder.ToString().TrimEnd('&');

View File

@@ -0,0 +1,74 @@
using System;
using System.Linq;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.Utilities
{
internal static class ReflectionUtility
{
public static void CreateOrExpandArray(ref Array? array, Type elementType, int capacity)
{
if (elementType == null) throw new ArgumentNullException(nameof(elementType));
if (capacity <= 0) throw new ArgumentOutOfRangeException(nameof(capacity));
if (array == null)
{
array = Array.CreateInstance(elementType, capacity);
}
else if (array.Length < capacity)
{
Array tmpArray = Array.CreateInstance(elementType, capacity);
Array.Copy(array, tmpArray, array.Length);
array = tmpArray;
}
}
public static void CreateOrExpandArrayElement(Array array, int index, Func<object, object>? updateFactory)
{
if (array == null) throw new ArgumentNullException(nameof(array));
if (index < 0 || index >= array.Length) throw new ArgumentOutOfRangeException(nameof(index));
if (updateFactory == null) throw new ArgumentNullException(nameof(updateFactory));
object? element = array.GetValue(index);
if (element is null)
{
Type elementType = array.GetType().GetElementType()!;
if (elementType.IsAbstract || elementType.IsInterface)
{
throw new NotSupportedException();
}
else if (elementType.IsArray)
{
element = Array.CreateInstance(elementType, 0);
}
else
{
element = Activator.CreateInstance(elementType);
}
}
element = updateFactory(element);
array.SetValue(element, index);
}
public static bool CheckTypeIsSubclassOf(Type childType, Type baseType)
{
bool IsTheRawGenericType(Type type)
=> baseType == (type.IsGenericType ? type.GetGenericTypeDefinition() : type);
bool isTheRawGenericType = childType.GetInterfaces().Any(IsTheRawGenericType);
if (isTheRawGenericType)
return true;
Type? t = childType;
while (t != null && t != typeof(object))
{
isTheRawGenericType = IsTheRawGenericType(t);
if (isTheRawGenericType) return true;
t = t.BaseType;
}
return false;
}
}
}

View File

@@ -0,0 +1,54 @@
using System;
namespace Newtonsoft.Json.Converters
{
internal class TextualLongArrayWithPipeSplitConverter : JsonConverter<long[]?>
{
public override bool CanRead
{
get { return true; }
}
public override bool CanWrite
{
get { return true; }
}
public override long[]? ReadJson(JsonReader reader, Type objectType, long[]? existingValue, bool hasExistingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null)
{
return null;
}
else if (reader.TokenType == JsonToken.String)
{
string? value = serializer.Deserialize<string>(reader);
if (value == null)
return null;
if (string.IsNullOrEmpty(value))
return Array.Empty<long>();
string[] strArr = value.Split('|');
long[] intArr = new long[strArr.Length];
for (int i = 0; i < strArr.Length; i++)
{
if (!long.TryParse(strArr[i], out long j))
throw new JsonSerializationException("Unexpected token when parsing string to long.");
intArr[i] = j;
}
return intArr;
}
throw new JsonSerializationException();
}
public override void WriteJson(JsonWriter writer, long[]? value, JsonSerializer serializer)
{
if (value != null)
writer.WriteValue(string.Join("|", value));
else
writer.WriteNull();
}
}
}

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Newtonsoft.Json.Converters
{
internal class TextualLongListWithPipeSplitConverter : JsonConverter
{
private readonly JsonConverter<long[]?> _converter = new TextualLongArrayWithPipeSplitConverter();
public override bool CanConvert(Type objectType)
{
return objectType.IsGenericType &&
typeof(IList<>).IsAssignableFrom(objectType.GetGenericTypeDefinition()) &&
typeof(long) == objectType.GetGenericArguments()[0];
}
public override bool CanRead
{
get { return true; }
}
public override bool CanWrite
{
get { return true; }
}
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{
long[]? array = _converter.ReadJson(reader, objectType, null, false, serializer);
return array?.ToList();
}
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
_converter.WriteJson(writer, ((IList<long>?)value)?.ToArray(), serializer);
}
}
}

View File

@@ -0,0 +1,44 @@
using System.Text.Json.Serialization;
namespace System.Text.Json.Converters
{
internal class TextualLongArrayWithPipeSplitConverter : JsonConverter<long[]?>
{
public override long[]? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.Null)
{
return null;
}
else if (reader.TokenType == JsonTokenType.String)
{
string? value = reader.GetString();
if (value == null)
return null;
if (string.IsNullOrEmpty(value))
return Array.Empty<long>();
string[] strArr = value.Split('|');
long[] intArr = new long[strArr.Length];
for (int i = 0; i < strArr.Length; i++)
{
if (!long.TryParse(strArr[i], out long j))
throw new JsonException("Unexpected token when parsing string to long.");
intArr[i] = j;
}
return intArr;
}
throw new JsonException();
}
public override void Write(Utf8JsonWriter writer, long[]? value, JsonSerializerOptions options)
{
if (value != null)
writer.WriteStringValue(string.Join("|", value));
else
writer.WriteNullValue();
}
}
}

View File

@@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
namespace System.Text.Json.Converters
{
internal class TextualLongListWithPipeSplitConverter : JsonConverterFactory
{
private sealed class InnerTextualIntegerListWithVBarSplitConverter : JsonConverter<IList<long>?>
{
private readonly JsonConverter<long[]?> _converter = new TextualLongArrayWithPipeSplitConverter();
public override IList<long>? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
long[]? array = _converter.Read(ref reader, typeToConvert, options);
IList<long>? list = array?.ToList();
return list;
}
public override void Write(Utf8JsonWriter writer, IList<long>? value, JsonSerializerOptions options)
{
_converter.Write(writer, value?.ToArray(), options);
}
}
public override bool CanConvert(Type typeToConvert)
{
return typeToConvert.IsGenericType &&
typeof(IList<>).IsAssignableFrom(typeToConvert.GetGenericTypeDefinition()) &&
typeof(long) == typeToConvert.GetGenericArguments()[0];
}
public override JsonConverter? CreateConverter(Type typeToConvert, JsonSerializerOptions options)
{
return new InnerTextualIntegerListWithVBarSplitConverter();
}
}
}

View File

@@ -25,7 +25,7 @@
/// 获取或设置提单部门 ID。
/// </summary>
[System.Xml.Serialization.XmlElement("Party")]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
}
public class Notifier

View File

@@ -210,7 +210,7 @@
/// 获取或设置部门 ID。
/// </summary>
[System.Xml.Serialization.XmlElement("Id", IsNullable = true)]
public int? DepartmentId { get; set; }
public long? DepartmentId { get; set; }
/// <summary>
/// 获取或设置上级部门 ID。

View File

@@ -37,7 +37,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("partyid")]
[System.Text.Json.Serialization.JsonPropertyName("partyid")]
public int[] DepartmentIdList { get; set; } = default!;
public long[] DepartmentIdList { get; set; } = default!;
}
public class AllowedTag

View File

@@ -33,7 +33,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("allow_party")]
[System.Text.Json.Serialization.JsonPropertyName("allow_party")]
public IList<int>? AllowedDepartmentIdList { get; set; }
public IList<long>? AllowedDepartmentIdList { get; set; }
/// <summary>
/// 获取或设置可见标签 ID 列表。

View File

@@ -17,7 +17,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("invalidparty")]
[System.Text.Json.Serialization.JsonPropertyName("invalidparty")]
public int[]? InvalidDepartmentIdList { get; set; }
public long[]? InvalidDepartmentIdList { get; set; }
/// <summary>
/// 获取或设置无效的标签 ID 列表。

View File

@@ -42,7 +42,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("partyid")]
[System.Text.Json.Serialization.JsonPropertyName("partyid")]
public int? DepartmentId { get; set; }
public long? DepartmentId { get; set; }
}
}

View File

@@ -19,7 +19,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("party")]
[System.Text.Json.Serialization.JsonPropertyName("party")]
public IList<int>? DepartmentIdList { get; set; }
public IList<long>? DepartmentIdList { get; set; }
/// <summary>
/// 获取或设置标签 ID 列表。

View File

@@ -17,7 +17,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("invalidparty")]
[System.Text.Json.Serialization.JsonPropertyName("invalidparty")]
public int[]? InvalidDepartmentIdList { get; set; }
public long[]? InvalidDepartmentIdList { get; set; }
/// <summary>
/// 获取或设置无效的标签 ID 列表。

View File

@@ -25,7 +25,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("partyid")]
[System.Text.Json.Serialization.JsonPropertyName("partyid")]
public int[]? DepartmentIdList { get; set; }
public long[]? DepartmentIdList { get; set; }
/// <summary>
/// 获取或设置标签 ID 列表。

View File

@@ -10,7 +10,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("id")]
[System.Text.Json.Serialization.JsonPropertyName("id")]
public int? DepartmentId { get; set; }
public long? DepartmentId { get; set; }
/// <summary>
/// 获取或设置部门名称。
@@ -31,7 +31,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("parentid")]
[System.Text.Json.Serialization.JsonPropertyName("parentid")]
public int? ParentDepartmentId { get; set; }
public long? ParentDepartmentId { get; set; }
/// <summary>
/// 获取或设置在上级部门中的次序值。

View File

@@ -10,6 +10,6 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("id")]
[System.Text.Json.Serialization.JsonPropertyName("id")]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
}
}

View File

@@ -10,6 +10,6 @@
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
}
}

View File

@@ -10,6 +10,6 @@
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
}
}

View File

@@ -10,6 +10,6 @@
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public int? ParentDepartmentId { get; set; }
public long? ParentDepartmentId { get; set; }
}
}

View File

@@ -14,7 +14,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("id")]
[System.Text.Json.Serialization.JsonPropertyName("id")]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
/// <summary>
/// 获取或设置部门名称。
@@ -35,7 +35,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("parentid")]
[System.Text.Json.Serialization.JsonPropertyName("parentid")]
public int ParentDepartmentId { get; set; }
public long ParentDepartmentId { get; set; }
/// <summary>
/// 获取或设置在上级部门中的次序值。

View File

@@ -10,6 +10,6 @@
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public int? ParentDepartmentId { get; set; }
public long? ParentDepartmentId { get; set; }
}
}

View File

@@ -14,14 +14,14 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("id")]
[System.Text.Json.Serialization.JsonPropertyName("id")]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
/// <summary>
/// 获取或设置上级部门 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("parentid")]
[System.Text.Json.Serialization.JsonPropertyName("parentid")]
public int ParentDepartmentId { get; set; }
public long ParentDepartmentId { get; set; }
/// <summary>
/// 获取或设置在上级部门中的次序值。

View File

@@ -10,7 +10,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("id")]
[System.Text.Json.Serialization.JsonPropertyName("id")]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
/// <summary>
/// 获取或设置部门名称。
@@ -31,7 +31,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("parentid")]
[System.Text.Json.Serialization.JsonPropertyName("parentid")]
public int? ParentDepartmentId { get; set; }
public long? ParentDepartmentId { get; set; }
/// <summary>
/// 获取或设置在上级部门中的次序值。

View File

@@ -33,6 +33,6 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("partyid")]
[System.Text.Json.Serialization.JsonPropertyName("partyid")]
public IList<int>? DepartmentIdList { get; set; }
public IList<long>? DepartmentIdList { get; set; }
}
}

View File

@@ -180,7 +180,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("party")]
[System.Text.Json.Serialization.JsonPropertyName("party")]
public IList<int>? DepartmentIdList { get; set; }
public IList<long>? DepartmentIdList { get; set; }
/// <summary>
/// 获取或设置是否临时会话模式。

View File

@@ -196,7 +196,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("party")]
[System.Text.Json.Serialization.JsonPropertyName("party")]
public int[]? DepartmentIdList { get; set; }
public long[]? DepartmentIdList { get; set; }
/// <summary>
/// 获取或设置是否临时会话模式。

View File

@@ -61,7 +61,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("party")]
[System.Text.Json.Serialization.JsonPropertyName("party")]
public IList<int>? DepartmentIdList { get; set; }
public IList<long>? DepartmentIdList { get; set; }
/// <summary>
/// 获取或设置是否临时会话模式。

View File

@@ -173,7 +173,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("partyid")]
[System.Text.Json.Serialization.JsonPropertyName("partyid")]
public int? DepartmentId { get; set; }
public long? DepartmentId { get; set; }
}
}

View File

@@ -28,7 +28,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("partyid")]
[System.Text.Json.Serialization.JsonPropertyName("partyid")]
public int? DepartmentId { get; set; }
public long? DepartmentId { get; set; }
}
}

View File

@@ -23,7 +23,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("department_list")]
[System.Text.Json.Serialization.JsonPropertyName("department_list")]
public IList<int>? DepartmentIdList { get; set; }
public IList<long>? DepartmentIdList { get; set; }
}
}

View File

@@ -35,7 +35,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("department_list")]
[System.Text.Json.Serialization.JsonPropertyName("department_list")]
public int[]? DepartmentIdList { get; set; }
public long[]? DepartmentIdList { get; set; }
}
}

View File

@@ -99,7 +99,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("to_party")]
[System.Text.Json.Serialization.JsonPropertyName("to_party")]
public IList<int>? ToDepartmentIdList { get; set; }
public IList<long>? ToDepartmentIdList { get; set; }
/// <summary>
/// 获取或设置是否发送给学校的所有家长。

View File

@@ -31,6 +31,6 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("invalid_party")]
[System.Text.Json.Serialization.JsonPropertyName("invalid_party")]
public int[]? InvalidDepartmentIdIdList { get; set; }
public long[]? InvalidDepartmentIdIdList { get; set; }
}
}

View File

@@ -115,7 +115,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("department_list")]
[System.Text.Json.Serialization.JsonPropertyName("department_list")]
public IList<int>? DepartmentIdList { get; set; }
public IList<long>? DepartmentIdList { get; set; }
}
public class ExternalContact

View File

@@ -25,7 +25,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("department_list")]
[System.Text.Json.Serialization.JsonPropertyName("department_list")]
public int[]? DepartmentIdList { get; set; }
public long[]? DepartmentIdList { get; set; }
}
public class ExternalContact

View File

@@ -47,7 +47,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("partyid")]
[System.Text.Json.Serialization.JsonPropertyName("partyid")]
public int? DepartmentId { get; set; }
public long? DepartmentId { get; set; }
}
}

View File

@@ -28,7 +28,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("partyid")]
[System.Text.Json.Serialization.JsonPropertyName("partyid")]
public int? DepartmentId { get; set; }
public long? DepartmentId { get; set; }
}
}

View File

@@ -21,7 +21,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("partyid")]
[System.Text.Json.Serialization.JsonPropertyName("partyid")]
public int[]? DepartmentIdList { get; set; }
public long[]? DepartmentIdList { get; set; }
/// <summary>
/// 获取或设置标签 ID 列表。

View File

@@ -23,7 +23,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("partyid")]
[System.Text.Json.Serialization.JsonPropertyName("partyid")]
public IList<int>? DepartmentIdList { get; set; }
public IList<long>? DepartmentIdList { get; set; }
/// <summary>
/// 获取或设置标签 ID 列表。

View File

@@ -25,7 +25,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("partyids")]
[System.Text.Json.Serialization.JsonPropertyName("partyids")]
public int[]? DepartmentIdList { get; set; }
public long[]? DepartmentIdList { get; set; }
}
public class ReportTo

View File

@@ -21,7 +21,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("department_id_list")]
[System.Text.Json.Serialization.JsonPropertyName("department_id_list")]
public int[]? DepartmentIdList { get; set; }
public long[]? DepartmentIdList { get; set; }
}
public class GroupChatRange

View File

@@ -14,7 +14,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("department_id")]
[System.Text.Json.Serialization.JsonPropertyName("department_id")]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
/// <summary>
/// 获取或设置部门名称。
@@ -28,7 +28,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("parentid")]
[System.Text.Json.Serialization.JsonPropertyName("parentid")]
public int ParentDepartmentId { get; set; }
public long ParentDepartmentId { get; set; }
/// <summary>
/// 获取或设置在上级部门中的次序值。

View File

@@ -28,7 +28,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("main_department")]
[System.Text.Json.Serialization.JsonPropertyName("main_department")]
public int? AnchorMainDepartmentId { get; set; }
public long? AnchorMainDepartmentId { get; set; }
/// <summary>
/// 获取或设置直播标题。

View File

@@ -105,7 +105,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("main_department")]
[System.Text.Json.Serialization.JsonPropertyName("main_department")]
public int? CreatorMainDepartmentId { get; set; }
public long? CreatorMainDepartmentId { get; set; }
/// <summary>
/// 获取或设置会议标题。

View File

@@ -973,10 +973,10 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// 获取或设置接收消息的部门 ID 列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("toparty")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.TextualIntegerListWithPipeSplitConverter))]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.TextualLongListWithPipeSplitConverter))]
[System.Text.Json.Serialization.JsonPropertyName("toparty")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.TextualIntegerListWithPipeSplitConverter))]
public IList<int>? ToDepartmentIdList { get; set; }
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.TextualLongListWithPipeSplitConverter))]
public IList<long>? ToDepartmentIdList { get; set; }
/// <summary>
/// 获取或设置接收消息的标签 ID 列表。

View File

@@ -18,10 +18,10 @@
/// 获取或设置无效的部门 ID 列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("invalidparty")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.TextualIntegerArrayWithPipeSplitConverter))]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.TextualLongArrayWithPipeSplitConverter))]
[System.Text.Json.Serialization.JsonPropertyName("invalidparty")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.TextualIntegerArrayWithPipeSplitConverter))]
public int[]? InvalidDepartmentIdList { get; set; }
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.TextualLongArrayWithPipeSplitConverter))]
public long[]? InvalidDepartmentIdList { get; set; }
/// <summary>
/// 获取或设置无效的标签 ID 列表。

View File

@@ -56,7 +56,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("partyids")]
[System.Text.Json.Serialization.JsonPropertyName("partyids")]
public IList<int>? DepartmentIdList { get; set; }
public IList<long>? DepartmentIdList { get; set; }
/// <summary>
/// 获取或设置标签 ID 列表。

View File

@@ -237,7 +237,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("openapi_id")]
[System.Text.Json.Serialization.JsonPropertyName("openapi_id")]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
/// <summary>
/// 获取或设置成员名称。
@@ -476,7 +476,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("choose_department")]
[System.Text.Json.Serialization.JsonPropertyName("choose_department")]
public int? ApplicantDepartmentId { get; set; }
public long? ApplicantDepartmentId { get; set; }
/// <summary>
/// 获取或设置审批模板 ID。

View File

@@ -26,7 +26,7 @@
[Newtonsoft.Json.JsonProperty("partyid")]
[System.Text.Json.Serialization.JsonPropertyName("partyid")]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
}
public class Notifier
@@ -323,7 +323,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("openapi_id")]
[System.Text.Json.Serialization.JsonPropertyName("openapi_id")]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
/// <summary>
/// 获取或设置成员名称。

View File

@@ -29,7 +29,7 @@
[Newtonsoft.Json.JsonProperty("open_partyid")]
[System.Text.Json.Serialization.JsonPropertyName("open_partyid")]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
}
public class Tag

View File

@@ -34,7 +34,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("departments")]
[System.Text.Json.Serialization.JsonPropertyName("departments")]
public int[] DepartmentIdList { get; set; } = default!;
public long[] DepartmentIdList { get; set; } = default!;
}
}

View File

@@ -39,7 +39,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("id")]
[System.Text.Json.Serialization.JsonPropertyName("id")]
public int? DepartmentId { get; set; }
public long? DepartmentId { get; set; }
/// <summary>
/// 获取或设置部门名称。
@@ -60,7 +60,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("parentid")]
[System.Text.Json.Serialization.JsonPropertyName("parentid")]
public int ParentDepartmentId { get; set; }
public long ParentDepartmentId { get; set; }
/// <summary>
/// 获取或设置标准年级。

View File

@@ -10,6 +10,6 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("id")]
[System.Text.Json.Serialization.JsonPropertyName("id")]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
}
}

View File

@@ -10,6 +10,6 @@
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
}
}

View File

@@ -10,6 +10,6 @@
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public int? ParentDepartmentId { get; set; }
public long? ParentDepartmentId { get; set; }
}
}

View File

@@ -41,7 +41,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("id")]
[System.Text.Json.Serialization.JsonPropertyName("id")]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
/// <summary>
/// 获取或设置部门名称。
@@ -62,7 +62,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("parentid")]
[System.Text.Json.Serialization.JsonPropertyName("parentid")]
public int ParentDepartmentId { get; set; }
public long ParentDepartmentId { get; set; }
/// <summary>
/// 获取或设置标准年级。

View File

@@ -46,14 +46,14 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("id")]
[System.Text.Json.Serialization.JsonPropertyName("id")]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
/// <summary>
/// 获取或设置新的部门 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("new_id")]
[System.Text.Json.Serialization.JsonPropertyName("new_id")]
public int? NewDepartmentId { get; set; }
public long? NewDepartmentId { get; set; }
/// <summary>
/// 获取或设置部门名称。
@@ -67,7 +67,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("parentid")]
[System.Text.Json.Serialization.JsonPropertyName("parentid")]
public int? ParentDepartmentId { get; set; }
public long? ParentDepartmentId { get; set; }
/// <summary>
/// 获取或设置标准年级。

View File

@@ -18,7 +18,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("partyids")]
[System.Text.Json.Serialization.JsonPropertyName("partyids")]
public int[]? DepartmentIdList { get; set; }
public long[]? DepartmentIdList { get; set; }
/// <summary>
/// 获取或设置客户群(即班级群)名称列表。

View File

@@ -32,7 +32,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("partyids")]
[System.Text.Json.Serialization.JsonPropertyName("partyids")]
public int[] DepartmentIdList { get; set; } = default!;
public long[] DepartmentIdList { get; set; } = default!;
}
}

View File

@@ -32,7 +32,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("partyids")]
[System.Text.Json.Serialization.JsonPropertyName("partyids")]
public int[] DepartmentIdList { get; set; } = default!;
public long[] DepartmentIdList { get; set; } = default!;
/// <summary>
/// 获取或设置观看时长(单位:秒)。

View File

@@ -71,7 +71,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("department")]
[System.Text.Json.Serialization.JsonPropertyName("department")]
public int[] DepartmentIdList { get; set; } = default!;
public long[] DepartmentIdList { get; set; } = default!;
/// <summary>
/// 获取或设置学生的家长列表。

View File

@@ -30,7 +30,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("department")]
[System.Text.Json.Serialization.JsonPropertyName("department")]
public IList<int> DepartmentIdList { get; set; } = new List<int>();
public IList<long> DepartmentIdList { get; set; } = new List<long>();
}
}

View File

@@ -37,7 +37,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("department")]
[System.Text.Json.Serialization.JsonPropertyName("department")]
public IList<int>? DepartmentIdList { get; set; }
public IList<long>? DepartmentIdList { get; set; }
}
}

View File

@@ -26,6 +26,6 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("department")]
[System.Text.Json.Serialization.JsonPropertyName("department")]
public IList<int> DepartmentIdList { get; set; } = new List<int>();
public IList<long> DepartmentIdList { get; set; } = new List<long>();
}
}

View File

@@ -33,6 +33,6 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("department")]
[System.Text.Json.Serialization.JsonPropertyName("department")]
public IList<int>? DepartmentIdList { get; set; }
public IList<long>? DepartmentIdList { get; set; }
}
}

View File

@@ -140,7 +140,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("allow_party")]
[System.Text.Json.Serialization.JsonPropertyName("allow_party")]
public int[]? AllowedDepartmentIdList { get; set; }
public long[]? AllowedDepartmentIdList { get; set; }
/// <summary>
/// 获取或设置可见标签 ID 列表。
@@ -161,7 +161,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("extra_party")]
[System.Text.Json.Serialization.JsonPropertyName("extra_party")]
public int[]? ExtraDepartmentIdList { get; set; }
public long[]? ExtraDepartmentIdList { get; set; }
/// <summary>
/// 获取或设置额外标签 ID 列表。

View File

@@ -76,7 +76,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("id")]
[System.Text.Json.Serialization.JsonPropertyName("id")]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
/// <summary>
/// 获取或设置是否有可写权限。

View File

@@ -44,6 +44,6 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("partylist")]
[System.Text.Json.Serialization.JsonPropertyName("partylist")]
public int[] DepartmentIdList { get; set; } = default!;
public long[] DepartmentIdList { get; set; } = default!;
}
}

View File

@@ -26,6 +26,6 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("partylist")]
[System.Text.Json.Serialization.JsonPropertyName("partylist")]
public IList<int>? DepartmentIdList { get; set; }
public IList<long>? DepartmentIdList { get; set; }
}
}

View File

@@ -19,6 +19,6 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("invalidparty")]
[System.Text.Json.Serialization.JsonPropertyName("invalidparty")]
public int[]? InvalidDepartmentIdList { get; set; }
public long[]? InvalidDepartmentIdList { get; set; }
}
}

View File

@@ -263,7 +263,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("department")]
[System.Text.Json.Serialization.JsonPropertyName("department")]
public IList<int> DepartmentIdList { get; set; } = new List<int>();
public IList<long> DepartmentIdList { get; set; } = new List<long>();
/// <summary>
/// 获取或设置部门次序列表。
@@ -284,7 +284,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("main_department")]
[System.Text.Json.Serialization.JsonPropertyName("main_department")]
public int? MainDepartmentId { get; set; }
public long? MainDepartmentId { get; set; }
/// <summary>
/// 获取或设置直属上级成员账号列表。

View File

@@ -282,7 +282,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("department")]
[System.Text.Json.Serialization.JsonPropertyName("department")]
public int[] DepartmentIdList { get; set; } = default!;
public long[] DepartmentIdList { get; set; } = default!;
/// <summary>
/// 获取或设置部门次序列表。
@@ -303,7 +303,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("main_department")]
[System.Text.Json.Serialization.JsonPropertyName("main_department")]
public int? MainDepartmentId { get; set; }
public long? MainDepartmentId { get; set; }
/// <summary>
/// 获取或设置直属上级成员账号列表。
@@ -361,4 +361,4 @@
[System.Text.Json.Serialization.JsonPropertyName("external_profile")]
public Types.ExternalProfile? ExternalProfile { get; set; }
}
}
}

View File

@@ -109,7 +109,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("department")]
[System.Text.Json.Serialization.JsonPropertyName("department")]
public int[] DepartmentIdList { get; set; } = default!;
public long[] DepartmentIdList { get; set; } = default!;
/// <summary>
/// 获取或设置部门次序列表。
@@ -130,7 +130,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("main_department")]
[System.Text.Json.Serialization.JsonPropertyName("main_department")]
public int? MainDepartmentId { get; set; }
public long? MainDepartmentId { get; set; }
/// <summary>
/// 获取或设置直属上级成员账号列表。

View File

@@ -10,7 +10,7 @@
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public int DepartmentId { get; set; }
public long DepartmentId { get; set; }
/// <summary>
/// 获取或设置是否递归获取子部门成员。

View File

@@ -35,7 +35,7 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("department")]
[System.Text.Json.Serialization.JsonPropertyName("department")]
public int[] DepartmentIdList { get; set; } = default!;
public long[] DepartmentIdList { get; set; } = default!;
}
}

View File

@@ -93,7 +93,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("department")]
[System.Text.Json.Serialization.JsonPropertyName("department")]
public IList<int>? DepartmentIdList { get; set; }
public IList<long>? DepartmentIdList { get; set; }
/// <summary>
/// 获取或设置部门次序列表。
@@ -114,7 +114,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("main_department")]
[System.Text.Json.Serialization.JsonPropertyName("main_department")]
public int? MainDepartmentId { get; set; }
public long? MainDepartmentId { get; set; }
/// <summary>
/// 获取或设置直属上级成员账号列表。

View File

@@ -30,7 +30,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("departmentid")]
[System.Text.Json.Serialization.JsonPropertyName("departmentid")]
public int? DepartmentId { get; set; }
public long? DepartmentId { get; set; }
/// <summary>
/// 获取或设置权限。

View File

@@ -30,7 +30,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("departmentid")]
[System.Text.Json.Serialization.JsonPropertyName("departmentid")]
public int? DepartmentId { get; set; }
public long? DepartmentId { get; set; }
}
}

View File

@@ -14,7 +14,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat</PackageProjectUrl>
<PackageTags>Flurl.Http Wechat Weixin MicroMessage WechatWork WeixinWork Wxwork 微信 企业微信 企业号 微信企业号</PackageTags>
<Version>2.5.0</Version>
<Version>2.5.1</Version>
<Description>基于 Flurl.Http 的企业微信 API 客户端支持企业内部开发、第三方应用开发、智慧硬件开发模式支持基础服务、通讯录管理、客户联系、身份验证、应用管理、素材管理、设备管理、消息推送、OA、效率工具、企业互联、电子发票、家校沟通、家校应用、政民沟通等功能。</Description>
<Authors>Fu Diwei</Authors>
<RepositoryType>git</RepositoryType>

View File

@@ -2,7 +2,7 @@
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.UnitTests
{
public class TestCase_JWTUtilityTests
public class TestCase_JwtUtilityTests
{
[Fact(DisplayName = "测试用例JWT HS256 编码")]
public void TestJWTEncodeWithHS256()
@@ -17,7 +17,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.UnitTests
};
string secret = "jWmYm7qr5nMoAUwZRjGtBxmz3KA1tkAj3ykkR6q2B2C";
string actualJwt = Utilities.JWTUtility.EncodeWithHS256(payload: payload, secret: secret);
string actualJwt = Utilities.JwtUtility.EncodeWithHS256(payload: payload, secret: secret);
string expectedJwt = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOiJ4amxzajMzbGFzZmFmIiwiZGF0YSI6eyJxIjoi5Zyo5b6u5L-h5pm66KiA5LiO5b6u5L-h5pm66IGG5Lik5aSn5oqA5pyv55qE5pSv5oyB5LiL77yM5b6u5L-hQUnlm6LpmJ_mjqjlh7rkuobigJzlvq7kv6Hlr7nor53lvIDmlL7lubPlj7DigJ3lkozigJzohb7orq_lsI_lvq7igJ3mmbrog73noazku7bkuKTlpKfmoLjlv4Pkuqflk4HjgILlvq7kv6HmlK_ku5jlm6LpmJ_mnIDmlrDlj5HluIPnmoTigJzlvq7kv6HpnZLom5lQcm_igJ3lnKjnjrDlnLrorr7nva7kuobkvZPpqozljLrvvIzorqnlpKflrrbmhJ_lj5dBSeiupOiEuOeahOacrOS6i-OAgiJ9fQ.8FeSvxKlIrbI6MCAaWGekB4sHGA8DeUxgVXiHa8ulJk";
Assert.Equal(expectedJwt, actualJwt, ignoreCase: true);

View File

@@ -0,0 +1,26 @@
using Xunit;
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.UnitTests
{
public class TestCase_JwtUtilityTests
{
[Fact(DisplayName = "测试用例JWT HS256 编码")]
public void TestJWTEncodeWithHS256()
{
object payload = new
{
uid = "xjlsj33lasfaf",
data = new
{
q = "在微信智言与微信智聆两大技术的支持下微信AI团队推出了“微信对话开放平台”和“腾讯小微”智能硬件两大核心产品。微信支付团队最新发布的“微信青蛙Pro”在现场设置了体验区让大家感受AI认脸的本事。"
}
};
string secret = "jWmYm7qr5nMoAUwZRjGtBxmz3KA1tkAj3ykkR6q2B2C";
string actualJwt = Utilities.JwtUtility.EncodeWithHS256(payload: payload, secret: secret);
string expectedJwt = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOiJ4amxzajMzbGFzZmFmIiwiZGF0YSI6eyJxIjoi5Zyo5b6u5L-h5pm66KiA5LiO5b6u5L-h5pm66IGG5Lik5aSn5oqA5pyv55qE5pSv5oyB5LiL77yM5b6u5L-hQUnlm6LpmJ_mjqjlh7rkuobigJzlvq7kv6Hlr7nor53lvIDmlL7lubPlj7DigJ3lkozigJzohb7orq_lsI_lvq7igJ3mmbrog73noazku7bkuKTlpKfmoLjlv4Pkuqflk4HjgILlvq7kv6HmlK_ku5jlm6LpmJ_mnIDmlrDlj5HluIPnmoTigJzlvq7kv6HpnZLom5lQcm_igJ3lnKjnjrDlnLrorr7nva7kuobkvZPpqozljLrvvIzorqnlpKflrrbmhJ_lj5dBSeiupOiEuOeahOacrOS6i-OAgiJ9fQ.8FeSvxKlIrbI6MCAaWGekB4sHGA8DeUxgVXiHa8ulJk";
Assert.Equal(expectedJwt, actualJwt, ignoreCase: true);
}
}
}

View File

@@ -10,6 +10,8 @@
<ItemGroup>
<None Remove=".gitignore" />
<None Remove="appsettings - 复制.json" />
<None Remove="appsettings.local.json" />
<Content Include="appsettings.json">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>

Some files were not shown because too many files have changed in this diff Show More