/// <summary> /// 获取api资源 /// </summary> /// <returns></returns> public async Task <PaginationResult <ApiScopeDto> > GetApiScopesAsync(int?skip, int?take, string search) { var query = ApiScopes; if (!string.IsNullOrEmpty(search)) { search = search.Trim(); query = query.Where(e => e.Name.Contains(search) || e.DisplayName.Contains(search) || e.Description.Contains(search)); } int total = await query.CountAsync().ConfigureAwait(false); skip ??= 0; take ??= 10; List <ApiScope> resources = await query.Skip(skip.Value).Take(take.Value).ToListAsync().ConfigureAwait(false); var dtos = resources.Select(e => ApiScopeDto.FromDbEntity(mapper, e)); return(new PaginationResult <ApiScopeDto> { Succeeded = true, Total = total, Rows = dtos.ToList(), PageSize = take.Value }); }
/// <summary> /// 通过id获取api作用域 /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <ApiScopeDto> GetApiScopeByIdAsync(int id) { var apiScope = await ApiScopes .AsNoTracking() .FirstOrDefaultAsync(e => e.Id == id).ConfigureAwait(false); if (apiScope == null) { return(null); } var dto = ApiScopeDto.FromDbEntity(mapper, apiScope); return(dto); }