|
|
|
@ -1,5 +1,7 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq.Dynamic.Core; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
@ -9,7 +11,7 @@ using Volo.Abp.IdentityServer.EntityFrameworkCore; |
|
|
|
|
|
|
|
namespace Volo.Abp.IdentityServer.ApiScopes |
|
|
|
{ |
|
|
|
public class ApiScopeRepository : EfCoreRepository<IIdentityServerDbContext, ApiScope>, IApiScopeRepository |
|
|
|
public class ApiScopeRepository : EfCoreRepository<IIdentityServerDbContext, ApiScope, Guid>, IApiScopeRepository |
|
|
|
{ |
|
|
|
public ApiScopeRepository(IDbContextProvider<IIdentityServerDbContext> dbContextProvider) : base( |
|
|
|
dbContextProvider) |
|
|
|
@ -30,5 +32,44 @@ namespace Volo.Abp.IdentityServer.ApiScopes |
|
|
|
|
|
|
|
return await query.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<List<ApiScope>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null, bool includeDetails = false, CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
return await DbSet |
|
|
|
.IncludeDetails(includeDetails) |
|
|
|
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Name.Contains(filter) || |
|
|
|
x.Description.Contains(filter) || |
|
|
|
x.DisplayName.Contains(filter)) |
|
|
|
.OrderBy(sorting ?? "name desc") |
|
|
|
.PageBy(skipCount, maxResultCount) |
|
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
return await DbSet.AnyAsync(x => x.Id != expectedId && x.Name == name, GetCancellationToken(cancellationToken)); |
|
|
|
} |
|
|
|
|
|
|
|
public override async Task DeleteAsync(Guid id, bool autoSave = false, CancellationToken cancellationToken = new CancellationToken()) |
|
|
|
{ |
|
|
|
var scopeClaims = DbContext.Set<ApiScopeClaim>().Where(sc => sc.ApiScopeId == id); |
|
|
|
foreach (var claim in scopeClaims) |
|
|
|
{ |
|
|
|
DbContext.Set<ApiScopeClaim>().Remove(claim); |
|
|
|
} |
|
|
|
|
|
|
|
var scopeProperties = DbContext.Set<ApiScopeProperty>().Where(s => s.ApiScopeId == id); |
|
|
|
foreach (var property in scopeProperties) |
|
|
|
{ |
|
|
|
DbContext.Set<ApiScopeProperty>().Remove(property); |
|
|
|
} |
|
|
|
|
|
|
|
await base.DeleteAsync(id, autoSave, cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
public override IQueryable<ApiScope> WithDetails() |
|
|
|
{ |
|
|
|
return GetQueryable().IncludeDetails(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|