李宏 2 years ago
parent
commit
5f2c92991c
  1. 4
      aspnet-core/LINGYUN.MicroService.All.sln
  2. 7
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application/LINGYUN/Abp/Identity/OrganizationUnitAppService.cs
  3. 23
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application/LINGYUN/Abp/Identity/OrganizationUnitGetListSpecification.cs
  4. 22
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/IOrganizationUnitRepository.cs
  5. 32
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/System/Linq/Expressions/ExpressionFuncExtensions.cs
  6. 1
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN/Abp/Identity/EntityFrameworkCore/AbpIdentityEntityFrameworkCoreModule.cs
  7. 46
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs

4
aspnet-core/LINGYUN.MicroService.All.sln

@ -645,9 +645,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cli", "cli", "{59627844-A66
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Cli", "modules\cli\LINGYUN.Abp.Cli\LINGYUN.Abp.Cli.csproj", "{2F49E870-DAE2-4D89-98CA-46BBD91C68E2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.OssManagement.FileSystem.Imaging", "modules\oss-management\LINGYUN.Abp.OssManagement.FileSystem.Imaging\LINGYUN.Abp.OssManagement.FileSystem.Imaging.csproj", "{6C8489F4-68B5-4CBC-8463-010C71C23245}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.FileSystem.Imaging", "modules\oss-management\LINGYUN.Abp.OssManagement.FileSystem.Imaging\LINGYUN.Abp.OssManagement.FileSystem.Imaging.csproj", "{6C8489F4-68B5-4CBC-8463-010C71C23245}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp", "modules\oss-management\LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp\LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp.csproj", "{5177C729-7666-4A6C-9D54-D7E5DEF0E857}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp", "modules\oss-management\LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp\LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp.csproj", "{5177C729-7666-4A6C-9D54-D7E5DEF0E857}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

7
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application/LINGYUN/Abp/Identity/OrganizationUnitAppService.cs

@ -102,9 +102,12 @@ namespace LINGYUN.Abp.Identity
public async virtual Task<PagedResultDto<OrganizationUnitDto>> GetListAsync(OrganizationUnitGetByPagedDto input)
{
var origanizationUnitCount = await OrganizationUnitRepository.GetCountAsync();
var specification = new OrganizationUnitGetListSpecification(input);
var origanizationUnitCount = await OrganizationUnitRepository.GetCountAsync(specification);
var origanizationUnits = await OrganizationUnitRepository
.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, false);
.GetListAsync(specification, input.Sorting, input.MaxResultCount, input.SkipCount, false);
return new PagedResultDto<OrganizationUnitDto>(origanizationUnitCount,
ObjectMapper.Map<List<OrganizationUnit>, List<OrganizationUnitDto>>(origanizationUnits));

23
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application/LINGYUN/Abp/Identity/OrganizationUnitGetListSpecification.cs

@ -0,0 +1,23 @@
using System;
using System.Linq.Expressions;
using Volo.Abp.Identity;
using Volo.Abp.Specifications;
namespace LINGYUN.Abp.Identity;
public class OrganizationUnitGetListSpecification : Specification<OrganizationUnit>
{
protected OrganizationUnitGetByPagedDto Input { get; }
public OrganizationUnitGetListSpecification(OrganizationUnitGetByPagedDto input)
{
Input = input;
}
public override Expression<Func<OrganizationUnit, bool>> ToExpression()
{
Expression<Func<OrganizationUnit, bool>> expression = _ => true;
return expression
.AndIf(!Input.Filter.IsNullOrWhiteSpace(), x =>
x.DisplayName.Contains(Input.Filter) || x.Code.Contains(Input.Filter));
}
}

22
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/IOrganizationUnitRepository.cs

@ -0,0 +1,22 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Identity;
using Volo.Abp.Specifications;
namespace LINGYUN.Abp.Identity;
public interface IOrganizationUnitRepository : Volo.Abp.Identity.IOrganizationUnitRepository
{
Task<int> GetCountAsync(
ISpecification<OrganizationUnit> specification,
CancellationToken cancellationToken = default);
Task<List<OrganizationUnit>> GetListAsync(
ISpecification<OrganizationUnit> specification,
string sorting = nameof(OrganizationUnit.Code),
int maxResultCount = 10,
int skipCount = 0,
bool includeDetails = false,
CancellationToken cancellationToken = default);
}

32
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/System/Linq/Expressions/ExpressionFuncExtensions.cs

@ -0,0 +1,32 @@
using Volo.Abp.Specifications;
namespace System.Linq.Expressions;
public static class ExpressionFuncExtensions
{
public static Expression<Func<T, bool>> AndIf<T>(
this Expression<Func<T, bool>> first,
bool condition,
Expression<Func<T, bool>> second)
{
if (condition)
{
return ExpressionFuncExtender.And(first, second);
}
return first;
}
public static Expression<Func<T, bool>> OrIf<T>(
this Expression<Func<T, bool>> first,
bool condition,
Expression<Func<T, bool>> second)
{
if (condition)
{
return ExpressionFuncExtender.Or(first, second);
}
return first;
}
}

1
aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN/Abp/Identity/EntityFrameworkCore/AbpIdentityEntityFrameworkCoreModule.cs

@ -17,6 +17,7 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore
{
options.AddRepository<IdentityRole, EfCoreIdentityRoleRepository>();
options.AddRepository<IdentityUser, EfCoreIdentityUserRepository>();
options.AddRepository<OrganizationUnit, EfCoreOrganizationUnitRepository>();
});
}

46
aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs

@ -0,0 +1,46 @@
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.Specifications;
namespace LINGYUN.Abp.Identity.EntityFrameworkCore;
public class EfCoreOrganizationUnitRepository : Volo.Abp.Identity.EntityFrameworkCore.EfCoreOrganizationUnitRepository, IOrganizationUnitRepository
{
public EfCoreOrganizationUnitRepository(
IDbContextProvider<IIdentityDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
public async virtual Task<int> GetCountAsync(
ISpecification<OrganizationUnit> specification,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.Where(specification.ToExpression())
.CountAsync(GetCancellationToken(cancellationToken));
}
public async virtual Task<List<OrganizationUnit>> GetListAsync(
ISpecification<OrganizationUnit> specification,
string sorting = nameof(OrganizationUnit.Code),
int maxResultCount = 10,
int skipCount = 0,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.IncludeDetails(includeDetails)
.Where(specification.ToExpression())
.OrderBy(sorting)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
}
Loading…
Cancel
Save