From 5c8abc1f191ef0cdf1cd0bf04d42a0e9cf798961 Mon Sep 17 00:00:00 2001 From: "jay.chang" Date: Tue, 23 Jan 2024 14:41:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=B0=B4=E9=9B=BB=E5=A0=B1?= =?UTF-8?q?=E8=A1=A8api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/TenantBillController.cs | 25 ++++-- FrontendWebApi/FrontendWebApi.csproj | 1 + FrontendWebApi/Models/Bill.cs | 3 + FrontendWebApi/appsettings.Development.json | 59 +++++++------- FrontendWebApi/appsettings.json | 80 +++++++++---------- 5 files changed, 86 insertions(+), 82 deletions(-) diff --git a/FrontendWebApi/ApiControllers/TenantBillController.cs b/FrontendWebApi/ApiControllers/TenantBillController.cs index d60593a..6e17d1a 100644 --- a/FrontendWebApi/ApiControllers/TenantBillController.cs +++ b/FrontendWebApi/ApiControllers/TenantBillController.cs @@ -9,6 +9,7 @@ using System.IO; using static FrontendWebApi.Models.Bill; using Microsoft.Extensions.Logging; using System.Text.Json; +using Newtonsoft.Json.Linq; // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 @@ -17,8 +18,8 @@ namespace FrontendWebApi.ApiControllers { //[Route("api/[controller]")] //[ApiController] - public class TenantBillController - //public class TenantBillController : MyBaseApiController + //public class TenantBillController + public class TenantBillController : MyBaseApiController { private readonly IBackendRepository backendRepository; @@ -60,7 +61,7 @@ namespace FrontendWebApi.ApiControllers } [HttpPost] - public async Task> AddOneTenantList(TenantList tl) + public async Task> AddOneTenantList([FromBody] TenantList tl) { ApiResult apiResult = new ApiResult(); @@ -91,7 +92,7 @@ namespace FrontendWebApi.ApiControllers } [HttpPost] - public async Task> UpdateOneTenantList(TenantList tl) + public async Task> UpdateOneTenantList([FromBody] TenantList tl) { ApiResult apiResult = new ApiResult(); @@ -122,7 +123,7 @@ namespace FrontendWebApi.ApiControllers } [HttpPost] - public async Task> DelOneTenantList(TenantList tl) + public async Task> DelOneTenantList([FromBody] TenantList tl) { ApiResult apiResult = new ApiResult(); @@ -144,13 +145,21 @@ namespace FrontendWebApi.ApiControllers return apiResult; } + public class MyJsonData + { + public string Name { get; set; } + public int Age { get; set; } + } + [HttpPost] - public async Task>> GetTenantBill(string tableType, string building_tag) + public async Task>> GetTenantBill([FromBody] TenantBill tb) { ApiResult> apiResult = new ApiResult>(); List tenantBill = new List(); try { + string tableType = tb.tableType; + string building_tag = tb.building_tag; string ElecOrWater = tableType == "elec" ? "E4" : "W1"; string sqlString = null; if (building_tag == "ALL") @@ -193,13 +202,13 @@ namespace FrontendWebApi.ApiControllers } [HttpPost] - public async Task> UpdateTenantBill(TenantBill tb, string tableType) + public async Task> UpdateTenantBill([FromBody] TenantBill tb) { ApiResult apiResult = new ApiResult(); try { - string bill_per = tableType == "elec" ? "bill_perKWH" : "bill_perRCV"; + string bill_per = tb.tableType == "elec" ? "bill_perKWH" : "bill_perRCV"; var updated_at = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); var start_timestamp = tb.start_timestamp.ToString("yyyy-MM-dd HH:mm:ss"); var end_timestamp = tb.end_timestamp.ToString("yyyy-MM-dd HH:mm:ss"); diff --git a/FrontendWebApi/FrontendWebApi.csproj b/FrontendWebApi/FrontendWebApi.csproj index fe797d3..8ca452a 100644 --- a/FrontendWebApi/FrontendWebApi.csproj +++ b/FrontendWebApi/FrontendWebApi.csproj @@ -11,6 +11,7 @@ + diff --git a/FrontendWebApi/Models/Bill.cs b/FrontendWebApi/Models/Bill.cs index f4f81fe..2b58ded 100644 --- a/FrontendWebApi/Models/Bill.cs +++ b/FrontendWebApi/Models/Bill.cs @@ -34,8 +34,11 @@ namespace FrontendWebApi.Models public string updated_by { get; set; } public DateTime? updated_at { get; set; } public string tenant_guid { get; set; } + public string tableType { get; set; } + public string building_tag { get; set; } } + public class OutputBill { public string tenant_name { get; set; } diff --git a/FrontendWebApi/appsettings.Development.json b/FrontendWebApi/appsettings.Development.json index 8798a2e..0e905a9 100644 --- a/FrontendWebApi/appsettings.Development.json +++ b/FrontendWebApi/appsettings.Development.json @@ -13,40 +13,39 @@ "JwtLifeSeconds": 3600 }, "DBConfig": { - "MySqlDBConfig": { - "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201 - "Port": "js2LutKe+rdjzdxMPQUrvQ==", - //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 + "MySqlDBConfig": { + "Server": "CYGthbCeGtAXT4s1NOSJHQ==", //0.132 + "Port": "mkF51jVbg40V5K5eTh2Ckw==", + //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp - //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome - "Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821 + "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel - //"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office - //"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //MCUT + //"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut + //"Database": "XZ2fOBnta9kdVGEb7y92cg==", //ibms_mcut "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Password": "FVAPxztxpY4gJJKQ/se4bQ==" } - //"MSSqlDBConfig": { - // "Server": "avZg8PA8C9GVgYZBgEKzCg==", - // "Port": "lJA0KPkG6RvFfTgWiXFyUw==", - // "Database": "VvfWH/59gQguY2eA2xBCug==", - // "Root": "sD8GZ9UPiIQGU6dU011/4A==", - // "Password": "2gi7rOmGha2VdXC5vtHxhg==" - //} + //"MSSqlDBConfig": { + // "Server": "avZg8PA8C9GVgYZBgEKzCg==", + // "Port": "lJA0KPkG6RvFfTgWiXFyUw==", + // "Database": "VvfWH/59gQguY2eA2xBCug==", + // "Root": "sD8GZ9UPiIQGU6dU011/4A==", + // "Password": "2gi7rOmGha2VdXC5vtHxhg==" + //} - //"MSSqlDBConfig": { //172.16.220.250 - // "Server": "zp3Nilx0PISEEC4caZWqCg==", - // "Port": "7puf4kd9qJ/q0fq2QASWeQ==", - // "Database": "VvfWH/59gQguY2eA2xBCug==", - // "Root": "sD8GZ9UPiIQGU6dU011/4A==", - // "Password": "Jue6jMFRi11meN6xbdKwDA==" - //} - //"MSSqlDBConfig": { - // "Server": "FPhyer7n0h/pw/yCMzKcPQ==", - // "Port": "7puf4kd9qJ/q0fq2QASWeQ==", - // "Database": "VvfWH/59gQguY2eA2xBCug==", - // "Root": "sD8GZ9UPiIQGU6dU011/4A==", - // "Password": "Jue6jMFRi11meN6xbdKwDA==" - //} + //"MSSqlDBConfig": { //172.16.220.250 + // "Server": "zp3Nilx0PISEEC4caZWqCg==", + // "Port": "7puf4kd9qJ/q0fq2QASWeQ==", + // "Database": "VvfWH/59gQguY2eA2xBCug==", + // "Root": "sD8GZ9UPiIQGU6dU011/4A==", + // "Password": "Jue6jMFRi11meN6xbdKwDA==" + //} + //"MSSqlDBConfig": { + // "Server": "FPhyer7n0h/pw/yCMzKcPQ==", + // "Port": "7puf4kd9qJ/q0fq2QASWeQ==", + // "Database": "VvfWH/59gQguY2eA2xBCug==", + // "Root": "sD8GZ9UPiIQGU6dU011/4A==", + // "Password": "Jue6jMFRi11meN6xbdKwDA==" + //} + } } -} diff --git a/FrontendWebApi/appsettings.json b/FrontendWebApi/appsettings.json index 56ec028..caa3d53 100644 --- a/FrontendWebApi/appsettings.json +++ b/FrontendWebApi/appsettings.json @@ -11,49 +11,41 @@ "SignKey": "TaipeiDome123456", //ñ��//�̤�16�r�� "JwtLifeSeconds": 86400 }, - "DBConfig": { - //"MySqlDBConfig": { - // "Server": "avZg8PA8C9GVgYZBgEKzCg==", - // "Port": "JKuuq+uwXTv3d/3a4itt6A==", - // "Database": "VvfWH/59gQguY2eA2xBCug==", - // "Root": "HHJtgEbqTcvCJtK4Lzg1Jg==", - // "Password": "2gi7rOmGha2VdXC5vtHxhg==" - //}, - "MySqlDBConfig": { - "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201 - "Port": "js2LutKe+rdjzdxMPQUrvQ==", - //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //三菱 - //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp - //"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //MCUT - //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome - //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel - //"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office - "Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821 - "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", - "Password": "FVAPxztxpY4gJJKQ/se4bQ==" - }, - "MSSqlDBConfig": { - "Server": "bJm+UAtbeaTjDmp/A5ep2w==", //0.130 - "Port": "S5cUXKnKOacFtFy9+0dtpw==", - "Database": "VvfWH/59gQguY2eA2xBCug==", //taipei_dome - "Root": "4GCCJGAXzLa8ecdmPAkYKg==", - "Password": "0O24es2ZRF5uoJ4aU+YCdg==" + "DBConfig": { + "MySqlDBConfig": { + "Server": "CYGthbCeGtAXT4s1NOSJHQ==", //0.132 + "Port": "mkF51jVbg40V5K5eTh2Ckw==", + //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 + //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp + "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome + //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel + //"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut + //"Database": "XZ2fOBnta9kdVGEb7y92cg==", //ibms_mcut + "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", + "Password": "FVAPxztxpY4gJJKQ/se4bQ==" + }, + "MSSqlDBConfig": { + "Server": "bJm+UAtbeaTjDmp/A5ep2w==", //0.130 + "Port": "S5cUXKnKOacFtFy9+0dtpw==", + "Database": "VvfWH/59gQguY2eA2xBCug==", //taipei_dome + "Root": "4GCCJGAXzLa8ecdmPAkYKg==", + "Password": "0O24es2ZRF5uoJ4aU+YCdg==" + } + //"MSSqlDBConfig": { + // "Server": "avZg8PA8C9GVgYZBgEKzCg==", + // "Port": "lJA0KPkG6RvFfTgWiXFyUw==", + // "Database": "VvfWH/59gQguY2eA2xBCug==", + // "Root": "sD8GZ9UPiIQGU6dU011/4A==", + // "Password": "2gi7rOmGha2VdXC5vtHxhg==" + //} + //"MSSqlDBConfig": { + // "Server": "ueFp+VFb200lhh1Uctc97WH0/tX6tfXYU2v1oxCWuuM=", + // "Port": "S5cUXKnKOacFtFy9+0dtpw==", + // "Database": "VvfWH/59gQguY2eA2xBCug==", + // "Root": "+plVKQ+enAqt7BYV2uMQng==", + // "Password": "0O24es2ZRF5uoJ4aU+YCdg==" + //} } - //"MSSqlDBConfig": { - // "Server": "avZg8PA8C9GVgYZBgEKzCg==", - // "Port": "lJA0KPkG6RvFfTgWiXFyUw==", - // "Database": "VvfWH/59gQguY2eA2xBCug==", - // "Root": "sD8GZ9UPiIQGU6dU011/4A==", - // "Password": "2gi7rOmGha2VdXC5vtHxhg==" - //} - //"MSSqlDBConfig": { - // "Server": "ueFp+VFb200lhh1Uctc97WH0/tX6tfXYU2v1oxCWuuM=", - // "Port": "S5cUXKnKOacFtFy9+0dtpw==", - // "Database": "VvfWH/59gQguY2eA2xBCug==", - // "Root": "+plVKQ+enAqt7BYV2uMQng==", - // "Password": "0O24es2ZRF5uoJ4aU+YCdg==" - //} + + } - - -}