From 0b55e216cf2cd044fd93d1fe0f1293636402e874 Mon Sep 17 00:00:00 2001 From: wet <1034391973@qq.com> Date: Fri, 13 Jan 2023 15:54:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/User/ISysUserService.cs | 2 +- .../Service/User/SysUserService.cs | 20 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Myshipping.Core/Service/User/ISysUserService.cs b/Myshipping.Core/Service/User/ISysUserService.cs index 3aed40d3..7764bccb 100644 --- a/Myshipping.Core/Service/User/ISysUserService.cs +++ b/Myshipping.Core/Service/User/ISysUserService.cs @@ -31,5 +31,5 @@ public interface ISysUserService Task> GetDataScopeIdUserList(long userId = 0); void CheckDataScopeByUserId(long userId); void CheckDataScope(long orgId); - Task> GetTenantUser(string name); + Task> GetTenantUser(string name,int type); } diff --git a/Myshipping.Core/Service/User/SysUserService.cs b/Myshipping.Core/Service/User/SysUserService.cs index d59ecf89..8c105ecb 100644 --- a/Myshipping.Core/Service/User/SysUserService.cs +++ b/Myshipping.Core/Service/User/SysUserService.cs @@ -385,11 +385,13 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient //这里如果报错看下AdminType的值 不能是0,必须是在枚举值内的 var users = await _sysUserRep.ToListAsync(); - var uu= users.Adapt>(); - if (!users.Any()) { + var uu = users.Adapt>(); + if (!users.Any()) + { throw Oops.Oh("没有数据"); } - using (MemoryStream ms = new MemoryStream()) { + using (MemoryStream ms = new MemoryStream()) + { ms.SaveAs(uu); ms.Seek(0, SeekOrigin.Begin); return await Task.FromResult(new FileStreamResult(ms, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") @@ -399,7 +401,7 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient } } - + /// 用户导入 /// /// @@ -539,14 +541,16 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient } } /// - /// 获取租户下的用户 + /// 获取租户下的用户 /// /// + /// 默认0 获取当前用户,可不传 1 获取所有用户 /// [HttpGet("/sysUser/GetTenantUser")] - public Task> GetTenantUser(string name) + public Task> GetTenantUser(string name, int type = 0) { - return _sysUserRep.AsQueryable().Where(x => x.TenantId == Convert.ToInt64(UserManager.TENANT_ID)).WhereIF(!string.IsNullOrWhiteSpace(name), x => x.Name.Contains(name)).ToListAsync(); + return _sysUserRep.AsQueryable().Filter(null, true).WhereIF(type == 0, x => x.TenantId == Convert.ToInt64(UserManager.TENANT_ID)) + .WhereIF(!string.IsNullOrWhiteSpace(name), x => x.Name.Contains(name)).ToListAsync(); } - + }