diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.Models/LoginUser.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.Models/LoginUser.cs new file mode 100644 index 00000000..32db30c2 --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.DataAccess.Models/LoginUser.cs @@ -0,0 +1,63 @@ +using System.ComponentModel; + +namespace Bootstrap.DataAccess +{ + /// + /// 登录用户信息实体类 + /// + public class LoginLog + { + /// + /// 获得/设置 Id + /// + public string? Id { get; set; } + + /// + /// 获得/设置 用户名 + /// + [DisplayName("登录名称")] + public string UserName { get; set; } = ""; + + /// + /// 获得/设置 登录时间 + /// + [DisplayName("登录时间")] + public DateTime LoginTime { get; set; } + + /// + /// 获得/设置 登录IP地址 + /// + [DisplayName("主机")] + public string Ip { get; set; } = ""; + + /// + /// 获得/设置 登录浏览器 + /// + [DisplayName("浏览器")] + public string Browser { get; set; } = ""; + + /// + /// 获得/设置 登录操作系统 + /// + [DisplayName("操作系统")] + public string OS { get; set; } = ""; + + /// + /// 获得/设置 登录地点 + /// + [DisplayName("登录地点")] + public string City { get; set; } = ""; + + /// + /// 获得/设置 登录是否成功 + /// + [DisplayName("登录结果")] + public string Result { get; set; } = ""; + + /// + /// 获得/设置 用户 UserAgent + /// + [DisplayName("登录名称")] + public string UserAgent { get; set; } = ""; + } +} diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Extensions/ServicesExtensions.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Extensions/ServicesExtensions.cs index e6ba0df3..2d322d6b 100644 --- a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Extensions/ServicesExtensions.cs +++ b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Extensions/ServicesExtensions.cs @@ -33,9 +33,11 @@ namespace Microsoft.Extensions.DependencyInjection // 增加数据服务 services.AddSingleton(typeof(IDataService<>), typeof(DefaultDataService<>)); + // 增加业务服务 services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); return services; } } diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/LoginsService.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/LoginsService.cs new file mode 100644 index 00000000..a513efad --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/LoginsService.cs @@ -0,0 +1,24 @@ +using BootstrapAdmin.Web.Core; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BootstrapAdmin.DataAccess.PetaPoco.Services +{ + class LoginsService : ILogins + { + /// + /// + /// + /// + /// + /// + /// + public Task Log(string userName, bool result) + { + return Task.FromResult(true); + } + } +} diff --git a/src/blazor/admin/BootstrapAdmin.Web.Core/ILogin.cs b/src/blazor/admin/BootstrapAdmin.Web.Core/ILogin.cs new file mode 100644 index 00000000..cbe6257c --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.Web.Core/ILogin.cs @@ -0,0 +1,16 @@ +namespace BootstrapAdmin.Web.Core +{ + /// + /// + /// + public interface ILogins + { + /// + /// + /// + /// + /// + /// + Task Log(string userName, bool result); + } +} diff --git a/src/blazor/admin/BootstrapAdmin.Web/Controllers/AccountController.cs b/src/blazor/admin/BootstrapAdmin.Web/Controllers/AccountController.cs index c9274716..e76e3c17 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Controllers/AccountController.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Controllers/AccountController.cs @@ -60,11 +60,12 @@ namespace Bootstrap.Admin.Controllers /// /// The login. /// + /// /// User name. /// Password. /// Remember. [HttpPost] - public async Task Login([FromServices] IUsers userService, string userName, string password, string remember) + public async Task Login([FromServices] IUsers userService, [FromServices] ILogins loginService, string userName, string password, string remember) { if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password)) { @@ -72,7 +73,7 @@ namespace Bootstrap.Admin.Controllers } var auth = userService.Authenticate(userName, password); - //await HttpContext.Log(userName, auth); + await loginService.Log(userName, auth); return auth ? await SignInAsync(userName, remember == "true") : RedirectLogin(); }