提交 9176faa9 编写于 作者: 麦壳饼's avatar 麦壳饼

第三方的 健康检查 没有设置 StringEnumConverter

上级 38991961
...@@ -10,9 +10,14 @@ using System.Collections.Generic; ...@@ -10,9 +10,14 @@ using System.Collections.Generic;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System.Linq; using System.Linq;
using IoTSharp.Contracts; using IoTSharp.Contracts;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Microsoft.AspNetCore.Mvc.Filters;
namespace IoTSharp.Controllers namespace IoTSharp.Controllers
{ {
[Route("api/[controller]")] [Route("api/[controller]")]
[ApiController] [ApiController]
public class HealthChecksController : ControllerBase public class HealthChecksController : ControllerBase
...@@ -30,9 +35,14 @@ namespace IoTSharp.Controllers ...@@ -30,9 +35,14 @@ namespace IoTSharp.Controllers
/// <returns></returns> /// <returns></returns>
[HttpGet()] [HttpGet()]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ApiResult<List<HealthCheckExecution>>> Get() public async Task<ActionResult> Get()
{ {
var _jsonSerializationSettings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
Converters = new[] { new StringEnumConverter() },
DateTimeZoneHandling = DateTimeZoneHandling.Local
};
using (var scope = __serviceScopeFactory.CreateScope()) using (var scope = __serviceScopeFactory.CreateScope())
using (var db = scope.ServiceProvider.GetRequiredService<HealthChecksDb>()) using (var db = scope.ServiceProvider.GetRequiredService<HealthChecksDb>())
{ {
...@@ -58,7 +68,8 @@ namespace IoTSharp.Controllers ...@@ -58,7 +68,8 @@ namespace IoTSharp.Controllers
healthChecksExecutions.Add(execution); healthChecksExecutions.Add(execution);
} }
} }
return new ApiResult<List<HealthCheckExecution>>(ApiCode.Success, "OK", healthChecksExecutions); var responseContent = JsonConvert.SerializeObject(healthChecksExecutions, _jsonSerializationSettings);
return new JsonResult( healthChecksExecutions,_jsonSerializationSettings);
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册