From 5af11cc200dd5ebe474b9c0475883b0e6d1e3759 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期三, 11 三月 2026 10:00:49 +0800
Subject: [PATCH] 重构整个项目:改进代码质量和架构
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseController/ApiBaseController.cs | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseController/ApiBaseController.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseController/ApiBaseController.cs
index 426a86e..ad0803b 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseController/ApiBaseController.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseController/ApiBaseController.cs
@@ -16,11 +16,11 @@
[Authorize, ApiController]
public class ApiBaseController<IService, TEntity> : Controller
{
- protected IService Service;
+ protected readonly IService Service;
public ApiBaseController(IService service)
{
- Service = service;
+ Service = service ?? throw new ArgumentNullException(nameof(service));
}
/// <summary>
@@ -108,12 +108,12 @@
[HttpPost, Route("Export")]
public virtual ActionResult Export([FromBody] PageDataOptions loadData)
{
- WebResponseContent result = InvokeService("Export", new object[] { loadData }) as WebResponseContent;
- if (result.Status)
+ WebResponseContent? result = InvokeService("Export", new object[] { loadData }) as WebResponseContent;
+ if (result != null && result.Status && result.Data != null)
return File(
- System.IO.File.ReadAllBytes(result.Data.ToString()),
+ System.IO.File.ReadAllBytes(result.Data.ToString() ?? string.Empty),
System.Net.Mime.MediaTypeNames.Application.Octet,
- Path.GetFileName(result.Data.ToString())
+ Path.GetFileName(result.Data.ToString() ?? string.Empty) ?? string.Empty
);
return Json(result);
}
@@ -125,12 +125,12 @@
[HttpPost, HttpGet, Route("DownLoadTemplate")]
public virtual ActionResult DownLoadTemplate()
{
- WebResponseContent result = InvokeService("DownLoadTemplate", new object[] { }) as WebResponseContent;
- if (result.Status)
+ WebResponseContent? result = InvokeService("DownLoadTemplate", new object[] { }) as WebResponseContent;
+ if (result != null && result.Status && result.Data != null)
return File(
- System.IO.File.ReadAllBytes(result.Data.ToString()),
+ System.IO.File.ReadAllBytes(result.Data.ToString() ?? string.Empty),
System.Net.Mime.MediaTypeNames.Application.Octet,
- Path.GetFileName(result.Data.ToString())
+ Path.GetFileName(result.Data.ToString() ?? string.Empty) ?? string.Empty
);
return Json(result);
}
--
Gitblit v1.9.3