sunpengfei
2025-08-13 37fe2cc6c007dae986ece6346408d6541078baa9
feat:开发
1个文件已添加
3个文件已修改
35 ■■■■■ 已修改文件
FlexJobApi.Core/Models/UserServer/EnterpriseEmployees/Queries/GetEnterpriseEmployeesQuery.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
FlexJobApi.Core/Utils/JsonUtils/EmptyStringToNullConverter.cs 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
FlexJobApi.UserServer.Application/EnterpriseEmployees/Queries/EnterpriseEmployeeQueryHandler.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
FlexJobApi.Web.Entry/Startup.cs 1 ●●●● 补丁 | 查看 | 原始文档 | 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()