28 changed files with 736 additions and 11 deletions
@ -0,0 +1,16 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Identity.Application" Version="3.0.0" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\identity\LINGYUN.Abp.Identity.Application.Contracts\LINGYUN.Abp.Identity.Application.Contracts.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,22 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.AutoMapper; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
[DependsOn( |
|||
typeof(Volo.Abp.Identity.AbpIdentityApplicationModule), |
|||
typeof(AbpIdentityApplicationContractsModule))] |
|||
public class AbpIdentityApplicationModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddAutoMapperObjectMapper<AbpIdentityApplicationModule>(); |
|||
|
|||
Configure<AbpAutoMapperOptions>(options => |
|||
{ |
|||
options.AddProfile<AbpIdentityApplicationModuleAutoMapperProfile>(validate: true); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
using AutoMapper; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class AbpIdentityApplicationModuleAutoMapperProfile : Profile |
|||
{ |
|||
public AbpIdentityApplicationModuleAutoMapperProfile() |
|||
{ |
|||
CreateMap<IdentityUser, IdentityUserDto>() |
|||
.MapExtraProperties(); |
|||
|
|||
CreateMap<IdentityRole, IdentityRoleDto>() |
|||
.MapExtraProperties(); |
|||
|
|||
CreateMap<OrganizationUnit, OrganizationUnitDto>() |
|||
.MapExtraProperties(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,183 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
[Authorize(IdentityPermissions.OrganizationUnits.Default)] |
|||
public class OrganizationUnitAppService : IdentityAppServiceBase, IOrganizationUnitAppService |
|||
{ |
|||
protected OrganizationUnitManager OrganizationUnitManager { get; } |
|||
protected IOrganizationUnitRepository OrganizationUnitRepository { get; } |
|||
|
|||
protected IdentityUserManager UserManager { get; } |
|||
protected IIdentityUserRepository UserRepository { get; } |
|||
|
|||
public OrganizationUnitAppService( |
|||
IdentityUserManager userManager, |
|||
IIdentityUserRepository userRepository, |
|||
OrganizationUnitManager organizationUnitManager, |
|||
IOrganizationUnitRepository organizationUnitRepository) |
|||
{ |
|||
UserManager = userManager; |
|||
UserRepository = userRepository; |
|||
OrganizationUnitManager = organizationUnitManager; |
|||
OrganizationUnitRepository = organizationUnitRepository; |
|||
|
|||
ObjectMapperContext = typeof(AbpIdentityApplicationModule); |
|||
} |
|||
|
|||
[Authorize(IdentityPermissions.OrganizationUnits.Create)] |
|||
public virtual async Task<OrganizationUnitDto> CreateAsync(OrganizationUnitCreateDto input) |
|||
{ |
|||
var origanizationUnit = new OrganizationUnit( |
|||
GuidGenerator.Create(), input.DisplayName, input.ParentId, CurrentTenant.Id) |
|||
{ |
|||
CreationTime = Clock.Now |
|||
}; |
|||
input.MapExtraPropertiesTo(origanizationUnit); |
|||
|
|||
await OrganizationUnitManager.CreateAsync(origanizationUnit); |
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
|
|||
return ObjectMapper.Map<OrganizationUnit, OrganizationUnitDto>(origanizationUnit); |
|||
} |
|||
|
|||
[Authorize(IdentityPermissions.OrganizationUnits.Delete)] |
|||
public virtual async Task DeleteAsync(Guid id) |
|||
{ |
|||
var origanizationUnit = await OrganizationUnitRepository.FindAsync(id); |
|||
if (origanizationUnit == null) |
|||
{ |
|||
return; |
|||
} |
|||
await OrganizationUnitManager.DeleteAsync(id); |
|||
} |
|||
|
|||
public virtual async Task<ListResultDto<OrganizationUnitDto>> FindChildrenAsync(OrganizationUnitGetChildrenDto input) |
|||
{ |
|||
var origanizationUnitChildren = await OrganizationUnitManager.FindChildrenAsync(input.Id, input.Recursive); |
|||
|
|||
return new ListResultDto<OrganizationUnitDto>( |
|||
ObjectMapper.Map<List<OrganizationUnit>, List<OrganizationUnitDto>>(origanizationUnitChildren)); |
|||
} |
|||
|
|||
public virtual async Task<OrganizationUnitDto> GetAsync(Guid id) |
|||
{ |
|||
var origanizationUnit = await OrganizationUnitRepository.FindAsync(id); |
|||
|
|||
return ObjectMapper.Map<OrganizationUnit, OrganizationUnitDto>(origanizationUnit); |
|||
} |
|||
|
|||
public virtual async Task<OrganizationUnitDto> GetLastChildOrNullAsync(Guid parentId) |
|||
{ |
|||
var origanizationUnitLastChildren = await OrganizationUnitManager.GetLastChildOrNullAsync(parentId); |
|||
|
|||
return ObjectMapper.Map<OrganizationUnit, OrganizationUnitDto>(origanizationUnitLastChildren); |
|||
} |
|||
|
|||
public virtual async Task<PagedResultDto<OrganizationUnitDto>> GetListAsync(OrganizationUnitGetByPagedDto input) |
|||
{ |
|||
var origanizationUnitCount = await OrganizationUnitRepository.GetCountAsync(); |
|||
var origanizationUnits = await OrganizationUnitRepository |
|||
.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, false); |
|||
|
|||
return new PagedResultDto<OrganizationUnitDto>(origanizationUnitCount, |
|||
ObjectMapper.Map<List<OrganizationUnit>, List<OrganizationUnitDto>>(origanizationUnits)); |
|||
} |
|||
|
|||
[Authorize(IdentityPermissions.OrganizationUnits.ManageRoles)] |
|||
public virtual async Task<PagedResultDto<IdentityRoleDto>> GetRolesAsync(OrganizationUnitGetRoleByPagedDto input) |
|||
{ |
|||
var origanizationUnit = await OrganizationUnitRepository.GetAsync(input.Id); |
|||
var origanizationUnitRoleCount = await OrganizationUnitRepository.GetRolesCountAsync(origanizationUnit); |
|||
var origanizationUnitRoles = await OrganizationUnitRepository.GetRolesAsync(origanizationUnit, |
|||
input.Sorting, input.MaxResultCount, input.SkipCount, false); |
|||
|
|||
return new PagedResultDto<IdentityRoleDto>(origanizationUnitRoleCount, |
|||
ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(origanizationUnitRoles)); |
|||
} |
|||
|
|||
[Authorize(IdentityPermissions.OrganizationUnits.ManageUsers)] |
|||
public virtual async Task<ListResultDto<IdentityUserDto>> GetUsersAsync(OrganizationUnitGetUserDto input) |
|||
{ |
|||
var origanizationUnit = await OrganizationUnitRepository.GetAsync(input.Id); |
|||
// TODO: 官方库没有定义分页查询API,有可能是企业付费版本,需要自行实现
|
|||
var origanizationUnitUsers = await UserRepository.GetUsersInOrganizationUnitAsync(origanizationUnit.Id); |
|||
|
|||
return new ListResultDto<IdentityUserDto>( |
|||
ObjectMapper.Map<List<IdentityUser>, List<IdentityUserDto>>(origanizationUnitUsers)); |
|||
} |
|||
|
|||
[Authorize(IdentityPermissions.OrganizationUnits.Update)] |
|||
public virtual async Task MoveAsync(OrganizationUnitMoveDto input) |
|||
{ |
|||
await OrganizationUnitManager.MoveAsync(input.Id, input.ParentId); |
|||
} |
|||
|
|||
[Authorize(IdentityPermissions.OrganizationUnits.Update)] |
|||
public virtual async Task<OrganizationUnitDto> UpdateAsync(Guid id, OrganizationUnitUpdateDto input) |
|||
{ |
|||
var origanizationUnit = await OrganizationUnitRepository.GetAsync(id); |
|||
origanizationUnit.DisplayName = input.DisplayName; |
|||
input.MapExtraPropertiesTo(origanizationUnit); |
|||
|
|||
await OrganizationUnitManager.UpdateAsync(origanizationUnit); |
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
|
|||
return ObjectMapper.Map<OrganizationUnit, OrganizationUnitDto>(origanizationUnit); |
|||
} |
|||
|
|||
[Authorize(IdentityPermissions.OrganizationUnits.ManageRoles)] |
|||
public virtual async Task AddRoleAsync(OrganizationUnitDtoAddOrRemoveRoleDto input) |
|||
{ |
|||
var origanizationUnit = await OrganizationUnitRepository.GetAsync(input.Id); |
|||
if (!origanizationUnit.IsInRole(input.RoleId)) |
|||
{ |
|||
origanizationUnit.AddRole(input.RoleId); |
|||
await OrganizationUnitManager.UpdateAsync(origanizationUnit); |
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
} |
|||
} |
|||
|
|||
[Authorize(IdentityPermissions.OrganizationUnits.ManageRoles)] |
|||
public virtual async Task RemoveRoleAsync(OrganizationUnitDtoAddOrRemoveRoleDto input) |
|||
{ |
|||
var origanizationUnit = await OrganizationUnitRepository.GetAsync(input.Id); |
|||
if (origanizationUnit.IsInRole(input.RoleId)) |
|||
{ |
|||
origanizationUnit.RemoveRole(input.RoleId); |
|||
await OrganizationUnitManager.UpdateAsync(origanizationUnit); |
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
} |
|||
} |
|||
|
|||
[Authorize(IdentityPermissions.OrganizationUnits.ManageUsers)] |
|||
public virtual async Task AddUserAsync(OrganizationUnitDtoAddOrRemoveUserDto input) |
|||
{ |
|||
var identityUser = await UserRepository.GetAsync(input.UserId); |
|||
var origanizationUnit = await OrganizationUnitRepository.GetAsync(input.Id); |
|||
if (!identityUser.IsInOrganizationUnit(input.Id)) |
|||
{ |
|||
await UserManager.AddToOrganizationUnitAsync(identityUser, origanizationUnit); |
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
} |
|||
} |
|||
|
|||
[Authorize(IdentityPermissions.OrganizationUnits.ManageUsers)] |
|||
public virtual async Task RemoveUserAsync(OrganizationUnitDtoAddOrRemoveUserDto input) |
|||
{ |
|||
var identityUser = await UserRepository.GetAsync(input.UserId); |
|||
var origanizationUnit = await OrganizationUnitRepository.GetAsync(input.Id); |
|||
if (identityUser.IsInOrganizationUnit(input.Id)) |
|||
{ |
|||
await UserManager.RemoveFromOrganizationUnitAsync(identityUser, origanizationUnit); |
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Identity.HttpApi.Client" Version="3.0.0" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\identity\LINGYUN.Abp.Identity.Application.Contracts\LINGYUN.Abp.Identity.Application.Contracts.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,20 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.Identity.HttpApi.Client |
|||
{ |
|||
[DependsOn( |
|||
typeof(Volo.Abp.Identity.AbpIdentityHttpApiClientModule), |
|||
typeof(AbpIdentityApplicationContractsModule))] |
|||
public class AbpIdentityHttpApiClientModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddHttpClientProxies( |
|||
typeof(AbpIdentityApplicationContractsModule).Assembly, |
|||
IdentityRemoteServiceConsts.RemoteServiceName |
|||
); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netcoreapp3.1</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Identity.HttpApi" Version="3.0.0" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\identity\LINGYUN.Abp.Identity.Application.Contracts\LINGYUN.Abp.Identity.Application.Contracts.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,19 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
[DependsOn( |
|||
typeof(Volo.Abp.Identity.AbpIdentityHttpApiModule), |
|||
typeof(AbpIdentityApplicationContractsModule))] |
|||
public class AbpIdentityHttpApiModule : AbpModule |
|||
{ |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
PreConfigure<IMvcBuilder>(mvcBuilder => |
|||
{ |
|||
mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpIdentityHttpApiModule).Assembly); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,124 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
[RemoteService(Name = IdentityRemoteServiceConsts.RemoteServiceName)] |
|||
[Area("organization-unit")] |
|||
[ControllerName("organization-unit")] |
|||
[Route("api/identity/organization-unit")] |
|||
public class IOrganizationUnitController : AbpController, IOrganizationUnitAppService |
|||
{ |
|||
protected IOrganizationUnitAppService OrganizationUnitAppService { get; } |
|||
|
|||
public IOrganizationUnitController( |
|||
IOrganizationUnitAppService organizationUnitAppService) |
|||
{ |
|||
OrganizationUnitAppService = organizationUnitAppService; |
|||
} |
|||
|
|||
[HttpPost] |
|||
[Route("management-roles")] |
|||
public virtual async Task AddRoleAsync(OrganizationUnitDtoAddOrRemoveRoleDto input) |
|||
{ |
|||
await OrganizationUnitAppService.AddRoleAsync(input); |
|||
} |
|||
|
|||
[HttpPost] |
|||
[Route("management-users")] |
|||
public virtual async Task AddUserAsync(OrganizationUnitDtoAddOrRemoveUserDto input) |
|||
{ |
|||
await OrganizationUnitAppService.AddUserAsync(input); |
|||
} |
|||
|
|||
[HttpPost] |
|||
public virtual async Task<OrganizationUnitDto> CreateAsync(OrganizationUnitCreateDto input) |
|||
{ |
|||
return await OrganizationUnitAppService.CreateAsync(input); |
|||
} |
|||
|
|||
[HttpDelete] |
|||
[Route("{id}")] |
|||
public virtual async Task DeleteAsync(Guid id) |
|||
{ |
|||
await OrganizationUnitAppService.DeleteAsync(id); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("find-children")] |
|||
public virtual async Task<ListResultDto<OrganizationUnitDto>> FindChildrenAsync(OrganizationUnitGetChildrenDto input) |
|||
{ |
|||
return await OrganizationUnitAppService.FindChildrenAsync(input); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("{id}")] |
|||
public virtual async Task<OrganizationUnitDto> GetAsync(Guid id) |
|||
{ |
|||
return await OrganizationUnitAppService.GetAsync(id); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("last-children")] |
|||
public virtual async Task<OrganizationUnitDto> GetLastChildOrNullAsync([Required] Guid parentId) |
|||
{ |
|||
return await OrganizationUnitAppService.GetLastChildOrNullAsync(parentId); |
|||
} |
|||
|
|||
[HttpGet] |
|||
public virtual async Task<PagedResultDto<OrganizationUnitDto>> GetListAsync(OrganizationUnitGetByPagedDto input) |
|||
{ |
|||
return await OrganizationUnitAppService.GetListAsync(input); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("management-roles")] |
|||
public virtual async Task<PagedResultDto<IdentityRoleDto>> GetRolesAsync(OrganizationUnitGetRoleByPagedDto input) |
|||
{ |
|||
return await OrganizationUnitAppService.GetRolesAsync(input); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("management-users")] |
|||
public virtual async Task<ListResultDto<IdentityUserDto>> GetUsersAsync(OrganizationUnitGetUserDto input) |
|||
{ |
|||
return await OrganizationUnitAppService.GetUsersAsync(input); |
|||
} |
|||
|
|||
[HttpPut] |
|||
[Route("{id}/move")] |
|||
public virtual async Task MoveAsync(OrganizationUnitMoveDto input) |
|||
{ |
|||
await OrganizationUnitAppService.MoveAsync(input); |
|||
} |
|||
|
|||
[HttpDelete] |
|||
[Route("management-roles")] |
|||
public virtual async Task RemoveRoleAsync(OrganizationUnitDtoAddOrRemoveRoleDto input) |
|||
{ |
|||
await OrganizationUnitAppService.RemoveRoleAsync(input); |
|||
} |
|||
|
|||
[HttpDelete] |
|||
[Route("management-users")] |
|||
public virtual async Task RemoveUserAsync(OrganizationUnitDtoAddOrRemoveUserDto input) |
|||
{ |
|||
await OrganizationUnitAppService.RemoveUserAsync(input); |
|||
} |
|||
|
|||
[HttpPut] |
|||
[Route("{id}")] |
|||
public virtual async Task<OrganizationUnitDto> UpdateAsync(Guid id, OrganizationUnitUpdateDto input) |
|||
{ |
|||
return await OrganizationUnitAppService.UpdateAsync(id, input); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Remove="LINGYUN\Abp\Identity\Localization\en.json" /> |
|||
<None Remove="LINGYUN\Abp\Identity\Localization\zh-Hans.json" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<EmbeddedResource Include="LINGYUN\Abp\Identity\Localization\en.json" /> |
|||
<EmbeddedResource Include="LINGYUN\Abp\Identity\Localization\zh-Hans.json" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Identity.Application.Contracts" Version="3.0.0" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,32 @@ |
|||
using Volo.Abp.Application; |
|||
using Volo.Abp.Authorization; |
|||
using Volo.Abp.Identity.Localization; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
[DependsOn( |
|||
typeof(Volo.Abp.Identity.AbpIdentityApplicationContractsModule), |
|||
typeof(AbpAuthorizationModule), |
|||
typeof(AbpDddApplicationModule) |
|||
)] |
|||
public class AbpIdentityApplicationContractsModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpVirtualFileSystemOptions>(options => |
|||
{ |
|||
options.FileSets.AddEmbedded<AbpIdentityApplicationContractsModule>(); |
|||
}); |
|||
|
|||
Configure<AbpLocalizationOptions>(options => |
|||
{ |
|||
options.Resources |
|||
.Get<IdentityResource>() |
|||
.AddVirtualJson("/LINGYUN/Abp/Identity/Localization"); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.ObjectExtending; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class OrganizationUnitCreateDto : ExtensibleObject |
|||
{ |
|||
[Required] |
|||
[DynamicStringLength(typeof(OrganizationUnitConsts), nameof(OrganizationUnitConsts.MaxDisplayNameLength))] |
|||
public string DisplayName { get; set; } |
|||
|
|||
public Guid? ParentId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class OrganizationUnitDto : ExtensibleAuditedEntityDto<Guid> |
|||
{ |
|||
public Guid? ParentId { get; set; } |
|||
public string Code { get; set; } |
|||
public string DisplayName { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class OrganizationUnitDtoAddOrRemoveRoleDto : IEntityDto<Guid> |
|||
{ |
|||
[Required] |
|||
public Guid Id { get; set; } |
|||
|
|||
[Required] |
|||
public Guid RoleId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class OrganizationUnitDtoAddOrRemoveUserDto : IEntityDto<Guid> |
|||
{ |
|||
[Required] |
|||
public Guid Id { get; set; } |
|||
|
|||
[Required] |
|||
public Guid UserId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class OrganizationUnitGetByPagedDto : PagedAndSortedResultRequestDto |
|||
{ |
|||
public string Filter { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class OrganizationUnitGetChildrenDto : IEntityDto<Guid> |
|||
{ |
|||
[Required] |
|||
public Guid Id { get; set; } |
|||
public bool Recursive { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class OrganizationUnitGetRoleByPagedDto : PagedAndSortedResultRequestDto, IEntityDto<Guid> |
|||
{ |
|||
[Required] |
|||
public Guid Id { get; set; } |
|||
|
|||
public string Filter { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class OrganizationUnitGetUserDto : IEntityDto<Guid> |
|||
{ |
|||
[Required] |
|||
public Guid Id { get; set; } |
|||
|
|||
public string Filter { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class OrganizationUnitMoveDto : IEntityDto<Guid> |
|||
{ |
|||
[Required] |
|||
public Guid Id { get; set; } |
|||
public Guid? ParentId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class OrganizationUnitUpdateDto : ExtensibleObject |
|||
{ |
|||
public string DisplayName { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public interface IOrganizationUnitAppService : |
|||
ICrudAppService<OrganizationUnitDto, |
|||
Guid, |
|||
OrganizationUnitGetByPagedDto, |
|||
OrganizationUnitCreateDto, |
|||
OrganizationUnitUpdateDto> |
|||
{ |
|||
Task<OrganizationUnitDto> GetLastChildOrNullAsync([Required] Guid parentId); |
|||
|
|||
Task MoveAsync(OrganizationUnitMoveDto input); |
|||
|
|||
Task<ListResultDto<OrganizationUnitDto>> FindChildrenAsync(OrganizationUnitGetChildrenDto input); |
|||
|
|||
Task<PagedResultDto<IdentityRoleDto>> GetRolesAsync(OrganizationUnitGetRoleByPagedDto input); |
|||
|
|||
Task<ListResultDto<IdentityUserDto>> GetUsersAsync(OrganizationUnitGetUserDto input); |
|||
|
|||
Task AddRoleAsync(OrganizationUnitDtoAddOrRemoveRoleDto input); |
|||
|
|||
Task RemoveRoleAsync(OrganizationUnitDtoAddOrRemoveRoleDto input); |
|||
|
|||
Task AddUserAsync(OrganizationUnitDtoAddOrRemoveUserDto input); |
|||
|
|||
Task RemoveUserAsync(OrganizationUnitDtoAddOrRemoveUserDto input); |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Identity.Localization; |
|||
using Volo.Abp.Localization; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class IdentityPermissionDefinitionProvider : PermissionDefinitionProvider |
|||
{ |
|||
public override void Define(IPermissionDefinitionContext context) |
|||
{ |
|||
var identityGroup = context.GetGroupOrNull(Volo.Abp.Identity.IdentityPermissions.GroupName); |
|||
|
|||
var origanizationUnitPermission = identityGroup.AddPermission(IdentityPermissions.OrganizationUnits.Default, L("Permission:OrganizationUnitManagement")); |
|||
origanizationUnitPermission.AddChild(IdentityPermissions.OrganizationUnits.Create, L("Permission:Create")); |
|||
origanizationUnitPermission.AddChild(IdentityPermissions.OrganizationUnits.Update, L("Permission:Edit")); |
|||
origanizationUnitPermission.AddChild(IdentityPermissions.OrganizationUnits.Delete, L("Permission:Delete")); |
|||
origanizationUnitPermission.AddChild(IdentityPermissions.OrganizationUnits.ManageRoles, L("Permission:ChangeRoles")); |
|||
origanizationUnitPermission.AddChild(IdentityPermissions.OrganizationUnits.ManageUsers, L("Permission:ChangeUsers")); |
|||
} |
|||
|
|||
private static LocalizableString L(string name) |
|||
{ |
|||
return LocalizableString.Create<IdentityResource>(name); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using Volo.Abp.Reflection; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class IdentityPermissions |
|||
{ |
|||
public static class OrganizationUnits |
|||
{ |
|||
public const string Default = Volo.Abp.Identity.IdentityPermissions.GroupName + ".OrganizationUnits"; |
|||
public const string Create = Default + ".Create"; |
|||
public const string Update = Default + ".Update"; |
|||
public const string Delete = Default + ".Delete"; |
|||
public const string ManageUsers = Default + ".ManageUsers"; |
|||
public const string ManageRoles = Default + ".ManageRoles"; |
|||
} |
|||
|
|||
public static string[] GetAll() |
|||
{ |
|||
return ReflectionHelper.GetPublicConstantsRecursively(typeof(IdentityPermissions)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
{ |
|||
"culture": "en", |
|||
"texts": { |
|||
"Permission:OrganizationUnitManagement": "Organization unit management", |
|||
"Permission:ChangeRoles": "Change roles", |
|||
"Permission:ChangeUsers": "Change users" |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
{ |
|||
"culture": "zh-Hans", |
|||
"texts": { |
|||
"Permission:OrganizationUnitManagement": "组织机构管理", |
|||
"Permission:ChangeRoles": "更改角色", |
|||
"Permission:ChangeUsers": "更改用户" |
|||
} |
|||
} |
|||
Loading…
Reference in new issue