|
|
|
@ -1,6 +1,7 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using MongoDB.Driver; |
|
|
|
using MongoDB.Driver.Linq; |
|
|
|
@ -9,33 +10,46 @@ using Volo.Abp.MongoDB; |
|
|
|
|
|
|
|
namespace Volo.Abp.SettingManagement.MongoDB |
|
|
|
{ |
|
|
|
public class MongoSettingRepository : MongoDbRepository<ISettingManagementMongoDbContext, Setting, Guid>, ISettingRepository |
|
|
|
public class MongoSettingRepository : MongoDbRepository<ISettingManagementMongoDbContext, Setting, Guid>, |
|
|
|
ISettingRepository |
|
|
|
{ |
|
|
|
public MongoSettingRepository(IMongoDbContextProvider<ISettingManagementMongoDbContext> dbContextProvider) |
|
|
|
: base(dbContextProvider) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<Setting> FindAsync(string name, string providerName, string providerKey) |
|
|
|
public virtual async Task<Setting> FindAsync( |
|
|
|
string name, |
|
|
|
string providerName, |
|
|
|
string providerKey, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
return await (await GetMongoQueryableAsync()) |
|
|
|
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))) |
|
|
|
.OrderBy(x => x.Id) |
|
|
|
.FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey); |
|
|
|
.FirstOrDefaultAsync( |
|
|
|
s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey, |
|
|
|
GetCancellationToken(cancellationToken)); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<List<Setting>> GetListAsync(string providerName, string providerKey) |
|
|
|
public virtual async Task<List<Setting>> GetListAsync( |
|
|
|
string providerName, |
|
|
|
string providerKey, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
return await (await GetMongoQueryableAsync()) |
|
|
|
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))) |
|
|
|
.Where(s => s.ProviderName == providerName && s.ProviderKey == providerKey) |
|
|
|
.ToListAsync(); |
|
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<List<Setting>> GetListAsync(string[] names, string providerName, string providerKey) |
|
|
|
public virtual async Task<List<Setting>> GetListAsync( |
|
|
|
string[] names, |
|
|
|
string providerName, |
|
|
|
string providerKey, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
return await (await GetMongoQueryableAsync()) |
|
|
|
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))) |
|
|
|
.Where(s => names.Contains(s.Name) && s.ProviderName == providerName && s.ProviderKey == providerKey) |
|
|
|
.ToListAsync(); |
|
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|