From bcb66a3463551f402721e40e801b88b7b836d66e Mon Sep 17 00:00:00 2001 From: jiahao Date: Mon, 4 Sep 2023 23:01:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E6=B8=AC=E8=A9=A6=20api=EF=BC=9AhelloDB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/LoginController.cs | 15 ++- z01_WinAPP/fmKeKe.Designer.cs | 103 ++++++++++++++++++ z01_WinAPP/fmKeKe.cs | 23 ++++ z01_WinAPP/fmKeKe.resx | 60 ++++++++++ 4 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 z01_WinAPP/fmKeKe.Designer.cs create mode 100644 z01_WinAPP/fmKeKe.cs create mode 100644 z01_WinAPP/fmKeKe.resx diff --git a/FrontendWebApi/ApiControllers/LoginController.cs b/FrontendWebApi/ApiControllers/LoginController.cs index b6e8347..8a17ab1 100644 --- a/FrontendWebApi/ApiControllers/LoginController.cs +++ b/FrontendWebApi/ApiControllers/LoginController.cs @@ -56,6 +56,16 @@ namespace FrontendWebApi.ApiControllers { return Ok(System.DateTime.Now.ToString() + " OK !"); + } + + [AllowAnonymous] + [HttpGet("~/hellodb")] + [Consumes("application/x-www-form-urlencoded")] + public async Task>> hellodb() + { + var User = await backendRepository.GetOneAsync("userinfo", @$" deleted = 0"); + return Ok(System.DateTime.Now.ToString() + @$"{User.full_name} OK !"); + } #endregion @@ -89,12 +99,15 @@ namespace FrontendWebApi.ApiControllers apiResult.Msg = "登入成功"; apiResult.Data = jwt.GenerateToken(jwtLoing); } - catch + catch( Exception ex) { + apiResult.Msg = ex.Message; apiResult.Code = "9999"; return BadRequest(apiResult); } return Ok(apiResult); + + } diff --git a/z01_WinAPP/fmKeKe.Designer.cs b/z01_WinAPP/fmKeKe.Designer.cs new file mode 100644 index 0000000..41f3559 --- /dev/null +++ b/z01_WinAPP/fmKeKe.Designer.cs @@ -0,0 +1,103 @@ +namespace z01_WinAPP +{ + partial class fmKeKe + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.button1 = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.button1); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.dataGridView1); + this.splitContainer1.Size = new System.Drawing.Size(1378, 890); + this.splitContainer1.SplitterDistance = 131; + this.splitContainer1.TabIndex = 0; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(78, 44); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(94, 29); + this.button1.TabIndex = 0; + this.button1.Text = "button1"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // dataGridView1 + // + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridView1.Location = new System.Drawing.Point(0, 0); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.RowHeadersWidth = 51; + this.dataGridView1.RowTemplate.Height = 29; + this.dataGridView1.Size = new System.Drawing.Size(1378, 755); + this.dataGridView1.TabIndex = 0; + // + // fmKeKe + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 19F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1378, 890); + this.Controls.Add(this.splitContainer1); + this.Name = "fmKeKe"; + this.Text = "fmKeKe"; + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.DataGridView dataGridView1; + } +} \ No newline at end of file diff --git a/z01_WinAPP/fmKeKe.cs b/z01_WinAPP/fmKeKe.cs new file mode 100644 index 0000000..1a6544e --- /dev/null +++ b/z01_WinAPP/fmKeKe.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace z01_WinAPP +{ + public partial class fmKeKe : Form + { + public fmKeKe() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + + } + } +} diff --git a/z01_WinAPP/fmKeKe.resx b/z01_WinAPP/fmKeKe.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/z01_WinAPP/fmKeKe.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file From 39ab492bdb1c077aa9de61a59cedcded9e997a72 Mon Sep 17 00:00:00 2001 From: jiahao Date: Tue, 5 Sep 2023 10:27:30 +0800 Subject: [PATCH 2/2] add feat(): hello DB API --- .../ApiControllers/LoginController.cs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/FrontendWebApi/ApiControllers/LoginController.cs b/FrontendWebApi/ApiControllers/LoginController.cs index 8a17ab1..f2d8757 100644 --- a/FrontendWebApi/ApiControllers/LoginController.cs +++ b/FrontendWebApi/ApiControllers/LoginController.cs @@ -12,7 +12,9 @@ using NPOI.SS.UserModel; using NPOI.XSSF.UserModel; using Repository.BackendRepository.Interface; using Repository.FrontendRepository.Interface; +using Serilog; using Serilog.Core; +using Serilog.Data; using System; using System.Collections.Generic; using System.IdentityModel.Tokens.Jwt; @@ -63,9 +65,20 @@ namespace FrontendWebApi.ApiControllers [Consumes("application/x-www-form-urlencoded")] public async Task>> hellodb() { - var User = await backendRepository.GetOneAsync("userinfo", @$" deleted = 0"); - return Ok(System.DateTime.Now.ToString() + @$"{User.full_name} OK !"); - + ApiResult apiResult = new ApiResult(null); + ErrorCode errorCode = new ErrorCode(); + try + { + var User = await backendRepository.GetOneAsync("userinfo", @$" deleted = 0"); + return Ok(System.DateTime.Now.ToString() + @$" get user test: {User.full_name} OK !"); + } + catch (Exception ex ) + { + logger.LogError(ex.Message); + apiResult.Msg = ex.Message; + apiResult.Code = "9999"; + return BadRequest(apiResult); + } } #endregion @@ -101,6 +114,7 @@ namespace FrontendWebApi.ApiControllers } catch( Exception ex) { + logger.LogError(ex.Message); apiResult.Msg = ex.Message; apiResult.Code = "9999"; return BadRequest(apiResult);