From e6d1fc16dd4173d2dc2c9dd8aa6172be4494b871 Mon Sep 17 00:00:00 2001 From: cheche <717840555@qq.com> Date: Wed, 27 Mar 2024 14:15:21 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E8=B4=A6=E6=88=B7=E5=85=B3=E8=81=94?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Identity/Response/UserResponse.cs | 5 +++++ .../Services/Implements/UserService.cs | 19 +++++++++++++++++-- Src/Dlhis.Sys/SqlSugarPack.cs | 14 ++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/Src/Dlhis.Sys/Identity/Response/UserResponse.cs b/Src/Dlhis.Sys/Identity/Response/UserResponse.cs index 15c1fe33..f152ac30 100644 --- a/Src/Dlhis.Sys/Identity/Response/UserResponse.cs +++ b/Src/Dlhis.Sys/Identity/Response/UserResponse.cs @@ -9,6 +9,11 @@ public class UserResponse /// public string UserName { get; set; } + /// + /// 操作员名称 + /// + public string GainfoName { get; set; } + /// /// 规范化账号名称 /// diff --git a/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs b/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs index 0576c9fe..e4f3f747 100644 --- a/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs +++ b/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs @@ -1,4 +1,5 @@ using System.Security.Claims; +using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Sys.Entities; using Dlhis.Sys.Identity.Request; using Dlhis.Sys.Identity.Response; @@ -13,15 +14,17 @@ namespace Dlhis.Sys.Identity.Services.Implements; public class UserService : IUserService { private readonly IDbContext _dbContext; + private readonly IDbContext _dbContext1; - public UserService(IDbContext dbContext) + public UserService(IDbContext dbContext, IDbContext dbContext1) { _dbContext = dbContext.ChangeDb("identity"); + _dbContext1 = dbContext1; } public async Task> GetPageAsync(UserPageRequest request) { - return await _dbContext.Queryable() + var page = await _dbContext.Queryable() .LeftJoin((x, ur) => x.Id == ur.UserId) .LeftJoin((x, ur, r) => ur.RoleId == r.Id) .WhereIF(request.Search.IsPresent(), x => x.UserName.Contains(request.Search) @@ -36,6 +39,18 @@ public class UserService : IUserService Role = r.Name }, true) .ToPageListAsync(request); + + var gainfos = await _dbContext1.ChangeDb("default").Queryable() + .Where(x => x.IdentityUserId > 0) + .ToListAsync(); + + page.Data.ForEach(item => + { + item.GainfoName = gainfos.Where(x => x.IdentityUserId == item.Id) + .FirstOrDefault()?.Name; + }); + + return page; } public async Task ResetAccessFailedCountAsync(int id) diff --git a/Src/Dlhis.Sys/SqlSugarPack.cs b/Src/Dlhis.Sys/SqlSugarPack.cs index 98f4153a..b71cf8f5 100644 --- a/Src/Dlhis.Sys/SqlSugarPack.cs +++ b/Src/Dlhis.Sys/SqlSugarPack.cs @@ -25,6 +25,20 @@ public class SqlSugarPack : BaseAppPack InitKeyType = InitKeyType.Attribute, IsAutoCloseConnection = true, + MoreSettings = new ConnMoreSettings + { + DisableNvarchar = true, + } + }, + new() + { + ConfigId = "default", + + ConnectionString = configuration.GetSection("SqlSugarOptions:DefaultConnectionString").Value, + DbType = DbType.MySql, + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true, + MoreSettings = new ConnMoreSettings { DisableNvarchar = true,