From 39ab492bdb1c077aa9de61a59cedcded9e997a72 Mon Sep 17 00:00:00 2001 From: jiahao Date: Tue, 5 Sep 2023 10:27:30 +0800 Subject: [PATCH] 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);