fix 修复response写入问题,禁用设备导入

This commit is contained in:
2024-04-13 09:31:22 +08:00
parent 4445988bf4
commit c8253bb083
2 changed files with 8 additions and 1 deletions

View File

@@ -139,6 +139,8 @@ public class DeviceService : IDeviceService
/// <returns></returns>
public async Task<List<string>> BulkUploadsAsync(ImportListRequest request)
{
true.ThrowIfTrue("设备导入功能暂时停用.");
var errs = new List<string>();
var lst = request.Imports;
var places = await _dbContext.Queryable<BusinessPlaceEntity>().ToListAsync();

View File

@@ -7,6 +7,9 @@ using Newtonsoft.Json;
namespace Dlhis.Basic.Organization.Filters;
/// <summary>
/// 忽略响应<see cref="IApiResult"/>.Data的自动camelCase
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class IgnoreDataCaseAttribute : Attribute, IAsyncResultFilter
{
@@ -29,6 +32,7 @@ public class IgnoreDataCaseAttribute : Attribute, IAsyncResultFilter
var json = JsonConvert.SerializeObject(body);
var bytes = Encoding.UTF8.GetBytes(json);
context.HttpContext.Response.StatusCode = 200;
context.HttpContext.Response.ContentType = "application/json";
context.HttpContext.Response.ContentLength = bytes.Length;
await context.HttpContext.Response.BodyWriter.WriteAsync(bytes);
@@ -36,6 +40,7 @@ public class IgnoreDataCaseAttribute : Attribute, IAsyncResultFilter
}
}
await next();
//eg:过滤器直接响应结果,此处进行短路
//await next();
}
}