Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

namespace LINGYUN.Abp.Demo.Authors;
public class EfCoreAuthorRepository
: EfCoreRepository<DemoDbContext, Author, Guid>,
: EfCoreRepository<IDemoDbContext, Author, Guid>,
IAuthorRepository
{
public EfCoreAuthorRepository(
IDbContextProvider<DemoDbContext> dbContextProvider)
IDbContextProvider<IDemoDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

namespace LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore;

public class EfCoreLanguageRepository : EfCoreRepository<LocalizationDbContext, Language, Guid>,
public class EfCoreLanguageRepository : EfCoreRepository<ILocalizationDbContext, Language, Guid>,
ILanguageRepository
{
public EfCoreLanguageRepository(
IDbContextProvider<LocalizationDbContext> dbContextProvider) : base(dbContextProvider)
IDbContextProvider<ILocalizationDbContext> dbContextProvider) : base(dbContextProvider)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

namespace LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore;

public class EfCoreResourceRepository : EfCoreRepository<LocalizationDbContext, Resource, Guid>,
public class EfCoreResourceRepository : EfCoreRepository<ILocalizationDbContext, Resource, Guid>,
IResourceRepository
{
public EfCoreResourceRepository(
IDbContextProvider<LocalizationDbContext> dbContextProvider) : base(dbContextProvider)
IDbContextProvider<ILocalizationDbContext> dbContextProvider) : base(dbContextProvider)
{
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -11,11 +10,11 @@

namespace LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore;

public class EfCoreTextRepository : EfCoreRepository<LocalizationDbContext, Text, int>,
public class EfCoreTextRepository : EfCoreRepository<ILocalizationDbContext, Text, int>,
ITextRepository
{
public EfCoreTextRepository(
IDbContextProvider<LocalizationDbContext> dbContextProvider) : base(dbContextProvider)
IDbContextProvider<ILocalizationDbContext> dbContextProvider) : base(dbContextProvider)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

namespace LINGYUN.Platform.Datas;

public class EfCoreDataRepository : EfCoreRepository<PlatformDbContext, Data, Guid>, IDataRepository
public class EfCoreDataRepository : EfCoreRepository<IPlatformDbContext, Data, Guid>, IDataRepository
{
public EfCoreDataRepository(
IDbContextProvider<PlatformDbContext> dbContextProvider) : base(dbContextProvider)
IDbContextProvider<IPlatformDbContext> dbContextProvider) : base(dbContextProvider)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace LINGYUN.Platform.Layouts;

public class EfCoreLayoutRepository : EfCoreRepository<PlatformDbContext, Layout, Guid>, ILayoutRepository
public class EfCoreLayoutRepository : EfCoreRepository<IPlatformDbContext, Layout, Guid>, ILayoutRepository
{
public EfCoreLayoutRepository(IDbContextProvider<PlatformDbContext> dbContextProvider)
public EfCoreLayoutRepository(IDbContextProvider<IPlatformDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

namespace LINGYUN.Platform.Menus;

public class EfCoreMenuRepository : EfCoreRepository<PlatformDbContext, Menu, Guid>, IMenuRepository
public class EfCoreMenuRepository : EfCoreRepository<IPlatformDbContext, Menu, Guid>, IMenuRepository
{
public EfCoreMenuRepository(
IDbContextProvider<PlatformDbContext> dbContextProvider)
IDbContextProvider<IPlatformDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
using LINGYUN.Platform.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;

namespace LINGYUN.Platform.Menus;

public class EfCoreRoleMenuRepository : EfCoreRepository<PlatformDbContext, RoleMenu, Guid>, IRoleMenuRepository
{
public EfCoreRoleMenuRepository(
IDbContextProvider<PlatformDbContext> dbContextProvider)
: base(dbContextProvider)
{
}

public async virtual Task<List<RoleMenu>> GetListByRoleNameAsync(
using LINGYUN.Platform.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Platform.Menus;
public class EfCoreRoleMenuRepository : EfCoreRepository<IPlatformDbContext, RoleMenu, Guid>, IRoleMenuRepository
{
public EfCoreRoleMenuRepository(
IDbContextProvider<IPlatformDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
public async virtual Task<List<RoleMenu>> GetListByRoleNameAsync(
string roleName,
string framework = null,
CancellationToken cancellationToken = default)
{
var dbContext = await GetDbContextAsync();

var menus = dbContext.Set<Menu>();
var roleMenus = dbContext.Set<RoleMenu>().Where(x => x.RoleName == roleName);

IQueryable<RoleMenu> queryable;
string framework = null,
CancellationToken cancellationToken = default)
{
var dbContext = await GetDbContextAsync();
var menus = dbContext.Set<Menu>();
var roleMenus = dbContext.Set<RoleMenu>().Where(x => x.RoleName == roleName);
IQueryable<RoleMenu> queryable;
if (!framework.IsNullOrWhiteSpace())
{
queryable = from menu in menus
join roleMenu in roleMenus
on menu.Id equals roleMenu.MenuId
where menu.Framework == framework
queryable = from menu in menus
join roleMenu in roleMenus
on menu.Id equals roleMenu.MenuId
where menu.Framework == framework
select roleMenu;
}
}
else
{
queryable = roleMenus;
}

return await queryable.ToListAsync(GetCancellationToken(cancellationToken));
}

public async virtual Task<bool> RoleHasInMenuAsync(
string roleName,
string menuName,
CancellationToken cancellationToken = default)
{
var menuQuery = (await GetDbContextAsync()).Set<Menu>().Where(x => x.Name == menuName);

return await
(from roleMenu in (await GetDbSetAsync())
join menu in menuQuery
on roleMenu.MenuId equals menu.Id
select roleMenu)
.AnyAsync(x => x.RoleName == roleName,
GetCancellationToken(cancellationToken));
}

public async virtual Task<Menu> FindStartupMenuAsync(
return await queryable.ToListAsync(GetCancellationToken(cancellationToken));
}
public async virtual Task<bool> RoleHasInMenuAsync(
string roleName,
string menuName,
CancellationToken cancellationToken = default)
{
var menuQuery = (await GetDbContextAsync()).Set<Menu>().Where(x => x.Name == menuName);
return await
(from roleMenu in (await GetDbSetAsync())
join menu in menuQuery
on roleMenu.MenuId equals menu.Id
select roleMenu)
.AnyAsync(x => x.RoleName == roleName,
GetCancellationToken(cancellationToken));
}
public async virtual Task<Menu> FindStartupMenuAsync(
IEnumerable<string> roleNames,
string framework = null,
string framework = null,
CancellationToken cancellationToken = default)
{
var dbContext = await GetDbContextAsync();
var roleMenuQuery = dbContext.Set<RoleMenu>()
.Where(x => roleNames.Contains(x.RoleName))
.Where(x => x.Startup);

return await
(from roleMenu in roleMenuQuery
join menu in dbContext.Set<Menu>()
on roleMenu.MenuId equals menu.Id
select menu)
.WhereIf(!framework.IsNullOrWhiteSpace(), x => x.Framework == framework)
.OrderByDescending(x => x.CreationTime)
return await
(from roleMenu in roleMenuQuery
join menu in dbContext.Set<Menu>()
on roleMenu.MenuId equals menu.Id
select menu)
.WhereIf(!framework.IsNullOrWhiteSpace(), x => x.Framework == framework)
.OrderByDescending(x => x.CreationTime)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

namespace LINGYUN.Platform.Menus;
public class EfCoreUserFavoriteMenuRepository :
EfCoreRepository<PlatformDbContext, UserFavoriteMenu, Guid>,
EfCoreRepository<IPlatformDbContext, UserFavoriteMenu, Guid>,
IUserFavoriteMenuRepository
{
public EfCoreUserFavoriteMenuRepository(
IDbContextProvider<PlatformDbContext> dbContextProvider)
IDbContextProvider<IPlatformDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

namespace LINGYUN.Platform.Menus;

public class EfCoreUserMenuRepository : EfCoreRepository<PlatformDbContext, UserMenu, Guid>, IUserMenuRepository
public class EfCoreUserMenuRepository : EfCoreRepository<IPlatformDbContext, UserMenu, Guid>, IUserMenuRepository
{
public EfCoreUserMenuRepository(
IDbContextProvider<PlatformDbContext> dbContextProvider)
IDbContextProvider<IPlatformDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

namespace LINGYUN.Platform.Packages;
public class EfCorePackageRepository :
EfCoreRepository<PlatformDbContext, Package, Guid>,
EfCoreRepository<IPlatformDbContext, Package, Guid>,
IPackageRepository
{
public EfCorePackageRepository(
IDbContextProvider<PlatformDbContext> dbContextProvider)
IDbContextProvider<IPlatformDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

namespace LINGYUN.Abp.TaskManagement.EntityFrameworkCore;
public class EfCoreBackgroundJobActionRepository :
EfCoreRepository<TaskManagementDbContext, BackgroundJobAction, Guid>,
EfCoreRepository<ITaskManagementDbContext, BackgroundJobAction, Guid>,
IBackgroundJobActionRepository
{
public EfCoreBackgroundJobActionRepository(
IDbContextProvider<TaskManagementDbContext> dbContextProvider)
IDbContextProvider<ITaskManagementDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
namespace LINGYUN.Abp.TaskManagement.EntityFrameworkCore;

public class EfCoreBackgroundJobInfoRepository :
EfCoreRepository<TaskManagementDbContext, BackgroundJobInfo, string>,
EfCoreRepository<ITaskManagementDbContext, BackgroundJobInfo, string>,
IBackgroundJobInfoRepository
{
protected IClock Clock { get; }

public EfCoreBackgroundJobInfoRepository(
IClock clock,
IDbContextProvider<TaskManagementDbContext> dbContextProvider)
IDbContextProvider<ITaskManagementDbContext> dbContextProvider)
: base(dbContextProvider)
{
Clock = clock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
namespace LINGYUN.Abp.TaskManagement.EntityFrameworkCore;

public class EfCoreBackgroundJobLogRepository :
EfCoreRepository<TaskManagementDbContext, BackgroundJobLog, long>,
EfCoreRepository<ITaskManagementDbContext, BackgroundJobLog, long>,
IBackgroundJobLogRepository
{
public EfCoreBackgroundJobLogRepository(
IDbContextProvider<TaskManagementDbContext> dbContextProvider)
IDbContextProvider<ITaskManagementDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

namespace PackageName.CompanyName.ProjectName.Users
{
public class UserRepository : EfCoreRepository<ProjectNameDbContext, User, Guid>, IUserRepository
public class UserRepository : EfCoreRepository<IProjectNameDbContext, User, Guid>, IUserRepository
{
public UserRepository(IDbContextProvider<ProjectNameDbContext> dbContextProvider) : base(dbContextProvider)
public UserRepository(IDbContextProvider<IProjectNameDbContext> dbContextProvider) : base(dbContextProvider)
{
}

Expand Down
Loading