diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Startup.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Startup.cs index e7bab1a9..bde35395 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Startup.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Startup.cs @@ -6,6 +6,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Yi.Framework.Core; using Yi.Framework.Model.ModelFactory; +using Yi.Framework.WebCore.BuilderExtend; using Yi.Framework.WebCore.MiddlewareExtend; using Yi.Framework.WebCore.Utility; @@ -38,7 +39,7 @@ namespace Yi.Framework.ApiMicroservice #endregion services.AddControllers(optios=> { //optios.Filters.Add(typeof(CustomExceptionFilterAttribute)); - }); + }).AddJsonFileService(); #region //Swagger·þÎñÅäÖà diff --git a/Yi.Framework/Yi.Framework.WebCore/BuilderExtend/JsonExtension.cs b/Yi.Framework/Yi.Framework.WebCore/BuilderExtend/JsonExtension.cs new file mode 100644 index 00000000..ccf52354 --- /dev/null +++ b/Yi.Framework/Yi.Framework.WebCore/BuilderExtend/JsonExtension.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.WebCore.BuilderExtend +{ + public static class JsonExtension + { + public static void AddJsonFileService(this IMvcBuilder builder) + { + builder.AddNewtonsoftJson(options => + { + options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; + options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm"; + }); + + } + } +} diff --git a/Yi.Framework/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj b/Yi.Framework/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj index 396231b7..789419be 100644 --- a/Yi.Framework/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj +++ b/Yi.Framework/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj @@ -9,12 +9,17 @@ + + + + +