From ff3504743189322887d0d83fdf771c5aff5380f1 Mon Sep 17 00:00:00 2001 From: lihanbo Date: Sat, 2 Nov 2024 10:38:32 +0800 Subject: [PATCH] 105040 Clean code --- LFlow.Base/Utils/CodeFirst.cs | 5 +---- LFlow.Base/Utils/ObjectToWhereExp.cs | 2 +- LFlow.Middleware/Middlewares/LoggingMiddleware.cs | 5 ++--- LFlow.Middleware/Register/MiddlewareRegister.cs | 1 - LFlow.UserManagement/Controller/UserManagementController.cs | 2 +- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/LFlow.Base/Utils/CodeFirst.cs b/LFlow.Base/Utils/CodeFirst.cs index 4754a72..25cb83d 100644 --- a/LFlow.Base/Utils/CodeFirst.cs +++ b/LFlow.Base/Utils/CodeFirst.cs @@ -1,8 +1,5 @@ -using System; -using System.Collections.Concurrent; -using System.Net; -using Serilog; using SqlSugar; +using System.Collections.Concurrent; namespace LFlow.Base.Utils; diff --git a/LFlow.Base/Utils/ObjectToWhereExp.cs b/LFlow.Base/Utils/ObjectToWhereExp.cs index f6a1f85..f4ef5c7 100644 --- a/LFlow.Base/Utils/ObjectToWhereExp.cs +++ b/LFlow.Base/Utils/ObjectToWhereExp.cs @@ -24,7 +24,7 @@ public static class ObjectToWhereExp } else if (property.PropertyType == typeof(DateTime) && value is DateTime dateTime) { - if (dateTime != default(DateTime)) + if (dateTime != default) { whereExp += $" and {property.Name} like '%{value}%'"; } diff --git a/LFlow.Middleware/Middlewares/LoggingMiddleware.cs b/LFlow.Middleware/Middlewares/LoggingMiddleware.cs index 43b6d83..71dda0c 100644 --- a/LFlow.Middleware/Middlewares/LoggingMiddleware.cs +++ b/LFlow.Middleware/Middlewares/LoggingMiddleware.cs @@ -18,11 +18,10 @@ using (_logger?.BeginScope("LoggingMiddleware")) { - //_logger?.LogInformation($"Controller: {controllerName} / Action : {actionName}"); - //_logger?.LogInformation("Router Data {@routerData}", context.GetRouteData()); + _logger?.LogInformation($"Controller: {controllerName} / Action : {actionName}"); + _logger?.LogInformation("Router Data {@routerData}", context.GetRouteData()); await next(); } - } } } diff --git a/LFlow.Middleware/Register/MiddlewareRegister.cs b/LFlow.Middleware/Register/MiddlewareRegister.cs index 85747d9..eac944e 100644 --- a/LFlow.Middleware/Register/MiddlewareRegister.cs +++ b/LFlow.Middleware/Register/MiddlewareRegister.cs @@ -59,7 +59,6 @@ namespace LFlow.Middleware.Register //logger?.LogInformation("Middleware {MiddlewareName} is registered.", middleware.GetType().Name); Console.WriteLine($"[{DateTime.Now:hh:mm:ss} INF] Middleware {middleware.GetType().Name} is registered."); } - } } } diff --git a/LFlow.UserManagement/Controller/UserManagementController.cs b/LFlow.UserManagement/Controller/UserManagementController.cs index 153d170..50ed9a3 100644 --- a/LFlow.UserManagement/Controller/UserManagementController.cs +++ b/LFlow.UserManagement/Controller/UserManagementController.cs @@ -15,7 +15,7 @@ namespace LFlow.UserManagement.Controller var loginedUser = service.Login(user); if (loginedUser == null) { - logger.Error("登录失败,用户名或密码错误"); + //logger.Error("登录失败,用户名或密码错误"); return Fail(loginedUser, "登录失败,用户名或密码错误", 10001); } return Success(loginedUser);