更新水電報表api

This commit is contained in:
張家睿 2024-01-23 14:41:38 +08:00
parent 718f2768f7
commit 5c8abc1f19
5 changed files with 86 additions and 82 deletions

View File

@ -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<TenantBillController>
//public class TenantBillController
public class TenantBillController : MyBaseApiController<TenantBillController>
{
private readonly IBackendRepository backendRepository;
@ -60,7 +61,7 @@ namespace FrontendWebApi.ApiControllers
}
[HttpPost]
public async Task<ApiResult<string>> AddOneTenantList(TenantList tl)
public async Task<ApiResult<string>> AddOneTenantList([FromBody] TenantList tl)
{
ApiResult<string> apiResult = new ApiResult<string>();
@ -91,7 +92,7 @@ namespace FrontendWebApi.ApiControllers
}
[HttpPost]
public async Task<ApiResult<string>> UpdateOneTenantList(TenantList tl)
public async Task<ApiResult<string>> UpdateOneTenantList([FromBody] TenantList tl)
{
ApiResult<string> apiResult = new ApiResult<string>();
@ -122,7 +123,7 @@ namespace FrontendWebApi.ApiControllers
}
[HttpPost]
public async Task<ApiResult<string>> DelOneTenantList(TenantList tl)
public async Task<ApiResult<string>> DelOneTenantList([FromBody] TenantList tl)
{
ApiResult<string> apiResult = new ApiResult<string>();
@ -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<ApiResult<List<TenantBill>>> GetTenantBill(string tableType, string building_tag)
public async Task<ApiResult<List<TenantBill>>> GetTenantBill([FromBody] TenantBill tb)
{
ApiResult<List<TenantBill>> apiResult = new ApiResult<List<TenantBill>>();
List<TenantBill> tenantBill = new List<TenantBill>();
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<ApiResult<string>> UpdateTenantBill(TenantBill tb, string tableType)
public async Task<ApiResult<string>> UpdateTenantBill([FromBody] TenantBill tb)
{
ApiResult<string> apiResult = new ApiResult<string>();
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");

View File

@ -11,6 +11,7 @@
<ItemGroup>
<PackageReference Include="Autodesk.Forge" Version="1.9.7" />
<PackageReference Include="Haukcode.WkHtmlToPdfDotNet" Version="1.5.86" />
<PackageReference Include="iTextSharp" Version="5.5.13.2" />
<PackageReference Include="Microsoft.AspNet.WebApi.Cors" Version="5.2.7" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.21" />

View File

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

View File

@ -14,15 +14,14 @@
},
"DBConfig": {
"MySqlDBConfig": {
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
"Port": "js2LutKe+rdjzdxMPQUrvQ==",
"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=="
}
@ -49,4 +48,4 @@
// "Password": "Jue6jMFRi11meN6xbdKwDA=="
//}
}
}
}

View File

@ -12,23 +12,15 @@
"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==", //
"Server": "CYGthbCeGtAXT4s1NOSJHQ==", //0.132
"Port": "mkF51jVbg40V5K5eTh2Ckw==",
//"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
//"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //MCUT
//"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
"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
//"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut
//"Database": "XZ2fOBnta9kdVGEb7y92cg==", //ibms_mcut
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
},
@ -56,4 +48,4 @@
}
}
}