From 41385bbf1ff353c4bfd2a93724d29eb89afe8a73 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 20 Jan 2023 00:58:27 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=20=E6=B6=88=E9=99=A4=E8=AD=A6?= =?UTF-8?q?=E5=91=8A=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/BaiduOcr.cs | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Extensions/Components/BootstrapBlazor.BaiduOcr/Services/BaiduOcr.cs b/src/Extensions/Components/BootstrapBlazor.BaiduOcr/Services/BaiduOcr.cs index 6643ac950f9..5929dd9b078 100644 --- a/src/Extensions/Components/BootstrapBlazor.BaiduOcr/Services/BaiduOcr.cs +++ b/src/Extensions/Components/BootstrapBlazor.BaiduOcr/Services/BaiduOcr.cs @@ -5,6 +5,7 @@ using Baidu.Aip.Ocr; using Microsoft.Extensions.Options; using Newtonsoft.Json.Linq; +using System.Collections.Generic; namespace BootstrapBlazor.Components; @@ -71,11 +72,11 @@ public Task> CheckVatInvoiceAsync(byte[] image, Ca protected async Task GetAccessToken() { var client = HttpClientFactory.CreateClient(); - var para = new Dictionary() + var para = new List>() { - { "grant_type", "client_credentials" }, - { "client_id", Options.CurrentValue.ApiKey }, - { "client_secret", Options.CurrentValue.Secret } + new("grant_type", "client_credentials"), + new("client_id", Options.CurrentValue.ApiKey), + new("client_secret", Options.CurrentValue.Secret) }; var resp = await client.PostAsync("https://aip.baidubce.com/oauth/2.0/token", new FormUrlEncodedContent(para)); @@ -102,21 +103,21 @@ public Task> VerifyInvoiceAsync(string invoi var client = HttpClientFactory.CreateClient(); // 拼装参数 - var para = new Dictionary() + var para = new List>() { - { "invoice_code", invoiceCode }, - { "invoice_num", invoiceNum }, - { "invoice_date", invoiceDate }, - { "invoice_type", invoiceType }, + new("invoice_code", invoiceCode), + new("invoice_num", invoiceNum), + new("invoice_date", invoiceDate), + new("invoice_type", invoiceType), }; if (!string.IsNullOrEmpty(checkCode)) { - para["check_code"] = checkCode; + para.Add(new("check_code", checkCode)); } if (!string.IsNullOrEmpty(totalAmount)) { - para["total_amount"] = totalAmount; + para.Add(new("total_amount", totalAmount)); } // 提交数据 From c81212006a20da4ad909646df97cd725df50aaf2 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 20 Jan 2023 01:48:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?doc:=20=E5=A2=9E=E5=8A=A0=E5=A2=9E=E5=80=BC?= =?UTF-8?q?=E7=A8=8E=E9=AA=8C=E7=9C=9F=E6=8E=A5=E5=8F=A3=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BaiduOcr/BaiduOcrVerifyVatInvoice.razor | 87 +++++++++++++++++++ .../Samples/BaiduOcr.razor | 2 + 2 files changed, 89 insertions(+) create mode 100644 src/BootstrapBlazor.Shared/Demos/BaiduOcr/BaiduOcrVerifyVatInvoice.razor diff --git a/src/BootstrapBlazor.Shared/Demos/BaiduOcr/BaiduOcrVerifyVatInvoice.razor b/src/BootstrapBlazor.Shared/Demos/BaiduOcr/BaiduOcrVerifyVatInvoice.razor new file mode 100644 index 00000000000..514072660ef --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/BaiduOcr/BaiduOcrVerifyVatInvoice.razor @@ -0,0 +1,87 @@ +@inject IBaiduOcr OcrService +@inject ToastService ToastService +@implements IDisposable + + + + + + + + + + + +