获取用户

optimize
wet 2 years ago
parent 2b6f536d97
commit 0b55e216cf

@ -31,5 +31,5 @@ public interface ISysUserService
Task<List<long>> GetDataScopeIdUserList(long userId = 0);
void CheckDataScopeByUserId(long userId);
void CheckDataScope(long orgId);
Task<List<SysUser>> GetTenantUser(string name);
Task<List<SysUser>> GetTenantUser(string name,int type);
}

@ -385,11 +385,13 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient
//这里如果报错看下AdminType的值 不能是0必须是在枚举值内的
var users = await _sysUserRep.ToListAsync();
var uu= users.Adapt<List<_SysUser>>();
if (!users.Any()) {
var uu = users.Adapt<List<_SysUser>>();
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")
@ -542,11 +544,13 @@ public class SysUserService : ISysUserService, IDynamicApiController, ITransient
/// 获取租户下的用户
/// </summary>
/// <param name="name"></param>
/// <param name="type">默认0 获取当前用户,可不传 1 获取所有用户</param>
/// <returns></returns>
[HttpGet("/sysUser/GetTenantUser")]
public Task<List<SysUser>> GetTenantUser(string name)
public Task<List<SysUser>> 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();
}
}

Loading…
Cancel
Save