From 5aab0908c471706ff9a73878e61aa6d228e7aee7 Mon Sep 17 00:00:00 2001
From: zhangpeihang <948869991@qq.com>
Date: Fri, 14 Jan 2022 23:36:19 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?=
=?UTF-8?q?=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/LoginService.cs | 29 +++++++++++++++++--
.../admin/BootstrapAdmin.Web.Core/ILogin.cs | 10 +++++--
2 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/LoginService.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/LoginService.cs
index 4701653e..a971afd2 100644
--- a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/LoginService.cs
+++ b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/LoginService.cs
@@ -1,4 +1,6 @@
using BootstrapAdmin.Web.Core;
+using PetaPoco;
+using BootstrapAdmin.DataAccess.Models;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -9,15 +11,38 @@ namespace BootstrapAdmin.DataAccess.PetaPoco.Services;
class LoginService : ILogin
{
+ private IDatabase Database { get; }
+
+ public LoginService(IDatabase database) => Database = database;
+
///
///
///
///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
///
///
- ///
- public Task Log(string userName, bool result)
+ public Task Log(string userName, DateTime loginTime, string IP, string address, string? browser, string userAgent, string OS, bool result)
{
+ var loginUser = new LoginLog()
+ {
+ UserName = userName,
+ LoginTime = DateTime.Now,
+ Ip = IP,
+ City = address,
+ OS = OS,
+ Browser = browser,
+ UserAgent = userAgent,
+ Result = result ? "登录成功" : "登录失败"
+ };
+
+ Database.Insert(loginUser);
+
return Task.FromResult(true);
}
}
diff --git a/src/blazor/admin/BootstrapAdmin.Web.Core/ILogin.cs b/src/blazor/admin/BootstrapAdmin.Web.Core/ILogin.cs
index fbece575..6ed14ad5 100644
--- a/src/blazor/admin/BootstrapAdmin.Web.Core/ILogin.cs
+++ b/src/blazor/admin/BootstrapAdmin.Web.Core/ILogin.cs
@@ -6,10 +6,16 @@
public interface ILogin
{
///
- /// 记录登录日志
+ ///
///
///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
///
///
- Task Log(string userName, bool result);
+ Task Log(string userName, DateTime loginTime, string IP, string address, string? browser, string userAgent, string OS, bool result);
}