From 5835b6c6d5333c17e6cfd68cebb7d87987c32b50 Mon Sep 17 00:00:00 2001 From: panguodong <704303609@qq.com> Date: Thu, 24 Nov 2022 09:34:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9C=E7=A8=8B=E8=AF=B7=E6=B1=82QueryString?= =?UTF-8?q?=E7=89=B9=E6=80=A7=E5=A2=9E=E5=8A=A0format=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Attributes/Parameters/QueryStringAttribute.cs | 9 ++++++++- .../RemoteRequest/Proxies/HttpDispatchProxy.cs | 7 ++++++- .../Attributes/Parameters/QueryStringAttribute.cs | 9 ++++++++- .../Furion/RemoteRequest/Proxies/HttpDispatchProxy.cs | 7 ++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/framework/Furion.Pure/RemoteRequest/Attributes/Parameters/QueryStringAttribute.cs b/framework/Furion.Pure/RemoteRequest/Attributes/Parameters/QueryStringAttribute.cs index 46318ab30e..2b0955cfbc 100644 --- a/framework/Furion.Pure/RemoteRequest/Attributes/Parameters/QueryStringAttribute.cs +++ b/framework/Furion.Pure/RemoteRequest/Attributes/Parameters/QueryStringAttribute.cs @@ -39,13 +39,20 @@ public class QueryStringAttribute : ParameterBaseAttribute /// 构造函数 /// /// - public QueryStringAttribute(string alias) + /// + public QueryStringAttribute(string alias, string format = null) { Alias = alias; + Format = format; } /// /// 参数别名 /// public string Alias { get; set; } + + /// + /// 格式化 + /// + public string Format { get; set; } } \ No newline at end of file diff --git a/framework/Furion.Pure/RemoteRequest/Proxies/HttpDispatchProxy.cs b/framework/Furion.Pure/RemoteRequest/Proxies/HttpDispatchProxy.cs index 1feb4fe149..eb1d00a419 100644 --- a/framework/Furion.Pure/RemoteRequest/Proxies/HttpDispatchProxy.cs +++ b/framework/Furion.Pure/RemoteRequest/Proxies/HttpDispatchProxy.cs @@ -168,10 +168,15 @@ public class HttpDispatchProxy : AspectDispatchProxy, IDispatchProxy // 处理基元类型 if (valueType.IsRichPrimitive() - && (!valueType.IsArray || valueType == typeof(string))) + && ((!valueType.IsArray && valueType != typeof(DateTime)) || valueType == typeof(string))) { parameterQueries.Add(queryStringAttribute.Alias ?? item.Name, item.Value); } + // 处理时间类型 + else if (valueType == typeof(DateTime)) + { + parameterQueries.Add(queryStringAttribute.Alias ?? item.Name, ((DateTime)item.Value).ToString(queryStringAttribute.Format)); + } // 处理集合类型 else if (valueType.IsArray || (typeof(IEnumerable).IsAssignableFrom(valueType) diff --git a/framework/Furion/RemoteRequest/Attributes/Parameters/QueryStringAttribute.cs b/framework/Furion/RemoteRequest/Attributes/Parameters/QueryStringAttribute.cs index 46318ab30e..2b0955cfbc 100644 --- a/framework/Furion/RemoteRequest/Attributes/Parameters/QueryStringAttribute.cs +++ b/framework/Furion/RemoteRequest/Attributes/Parameters/QueryStringAttribute.cs @@ -39,13 +39,20 @@ public class QueryStringAttribute : ParameterBaseAttribute /// 构造函数 /// /// - public QueryStringAttribute(string alias) + /// + public QueryStringAttribute(string alias, string format = null) { Alias = alias; + Format = format; } /// /// 参数别名 /// public string Alias { get; set; } + + /// + /// 格式化 + /// + public string Format { get; set; } } \ No newline at end of file diff --git a/framework/Furion/RemoteRequest/Proxies/HttpDispatchProxy.cs b/framework/Furion/RemoteRequest/Proxies/HttpDispatchProxy.cs index 1feb4fe149..eb1d00a419 100644 --- a/framework/Furion/RemoteRequest/Proxies/HttpDispatchProxy.cs +++ b/framework/Furion/RemoteRequest/Proxies/HttpDispatchProxy.cs @@ -168,10 +168,15 @@ public class HttpDispatchProxy : AspectDispatchProxy, IDispatchProxy // 处理基元类型 if (valueType.IsRichPrimitive() - && (!valueType.IsArray || valueType == typeof(string))) + && ((!valueType.IsArray && valueType != typeof(DateTime)) || valueType == typeof(string))) { parameterQueries.Add(queryStringAttribute.Alias ?? item.Name, item.Value); } + // 处理时间类型 + else if (valueType == typeof(DateTime)) + { + parameterQueries.Add(queryStringAttribute.Alias ?? item.Name, ((DateTime)item.Value).ToString(queryStringAttribute.Format)); + } // 处理集合类型 else if (valueType.IsArray || (typeof(IEnumerable).IsAssignableFrom(valueType) -- Gitee