FlexJobApi.Core/Models/UserServer/EnterpriseEmployees/Queries/GetEnterpriseEmployeesQuery.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
FlexJobApi.Core/Utils/JsonUtils/EmptyStringToNullConverter.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
FlexJobApi.UserServer.Application/EnterpriseEmployees/Queries/EnterpriseEmployeeQueryHandler.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
FlexJobApi.Web.Entry/Startup.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
FlexJobApi.Core/Models/UserServer/EnterpriseEmployees/Queries/GetEnterpriseEmployeesQuery.cs
@@ -79,6 +79,11 @@ public Guid Id { get; set; } /// <summary> /// 头像 /// </summary> public string Avatar { get; set; } /// <summary> /// 姓名 /// </summary> public string Name { get; set; } FlexJobApi.Core/Utils/JsonUtils/EmptyStringToNullConverter.cs
New file @@ -0,0 +1,28 @@ using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FlexJobApi.Core { public class EmptyStringToNullConverter : JsonConverter { public override bool CanConvert(Type objectType) { return objectType == typeof(string); } public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var value = (string)reader.Value; return string.IsNullOrEmpty(value) ? null : value; } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { writer.WriteValue(value); } } } FlexJobApi.UserServer.Application/EnterpriseEmployees/Queries/EnterpriseEmployeeQueryHandler.cs
@@ -74,6 +74,7 @@ var s = q.Select(it => new GetEnterpriseEmployeesQueryResultItem { Id = it.Id, Avatar = it.User.Avatar, Name = it.Name, Identity = it.Identity, Gender = it.Gender, FlexJobApi.Web.Entry/Startup.cs
@@ -68,6 +68,7 @@ services.AddControllers() .AddNewtonsoftJson(options => { options.SerializerSettings.Converters.Add(new EmptyStringToNullConverter()); //options.SerializerSettings.Converters.Add(new StringEnumConverter()); }) .AddFriendlyException()