[WebAPI]水電報表API回傳值修改

This commit is contained in:
張家睿 2024-02-01 17:40:49 +08:00
parent c35aeb2f2e
commit 151e543564

View File

@ -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;
}