From 151e54356419b0eb47776c093039cc6ad2791206 Mon Sep 17 00:00:00 2001 From: "jay.chang" Date: Thu, 1 Feb 2024 17:40:49 +0800 Subject: [PATCH] =?UTF-8?q?[WebAPI]=E6=B0=B4=E9=9B=BB=E5=A0=B1=E8=A1=A8API?= =?UTF-8?q?=E5=9B=9E=E5=82=B3=E5=80=BC=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FrontendWebApi/ApiControllers/TenantBillController.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/FrontendWebApi/ApiControllers/TenantBillController.cs b/FrontendWebApi/ApiControllers/TenantBillController.cs index b78f3a8..d2a85d8 100644 --- a/FrontendWebApi/ApiControllers/TenantBillController.cs +++ b/FrontendWebApi/ApiControllers/TenantBillController.cs @@ -109,6 +109,7 @@ namespace FrontendWebApi.ApiControllers apiResult.Msg = "新增用戶失敗。"; if (exception.Message.Contains($" for key 'PRIMARY'")) { + apiResult.Code = "0001"; apiResult.Msg = "已有相同使用者。"; } Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); @@ -143,6 +144,7 @@ namespace FrontendWebApi.ApiControllers apiResult.Msg = "修改失敗。"; if (exception.Message.Contains($"a foreign key constraint")) { + apiResult.Code = "0001"; apiResult.Msg = "水電報表仍有該用戶,無法修改名稱。"; } Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); @@ -170,6 +172,7 @@ namespace FrontendWebApi.ApiControllers apiResult.Msg = "刪除用戶失敗。"; if (exception.Message.Contains($"a foreign key constraint")) { + apiResult.Code = "0001"; apiResult.Msg = "水電報表仍有該用戶,無法刪除。"; } Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); @@ -250,13 +253,13 @@ namespace FrontendWebApi.ApiControllers } if (start_timestamp == "") { - apiResult.Code = "9999"; + apiResult.Code = "0001"; apiResult.Msg = "請選擇起始日期。"; return apiResult; } if (end_timestamp == "") { - apiResult.Code = "9999"; + apiResult.Code = "0001"; apiResult.Msg = "請選擇結束日期。"; return apiResult; } @@ -300,7 +303,7 @@ namespace FrontendWebApi.ApiControllers // $"updated_at = '{updated_at}', " + // $"tenant_guid = '{tb.tenant_guid}' " + // $"WHERE device_number = '{tb.device_number}'"; - apiResult.Code = "9999"; + apiResult.Code = "0001"; apiResult.Msg = "請選擇同一個月份"; return apiResult; }