48 changed files with 1936 additions and 121 deletions
File diff suppressed because one or more lines are too long
@ -0,0 +1,12 @@ |
|||
using System; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class IdentityClaimDto : EntityDto<Guid> |
|||
{ |
|||
public string ClaimType { get; set; } |
|||
|
|||
public string ClaimValue { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class IdentityClaimTypeCreateDto : IdentityClaimTypeCreateOrUpdateBaseDto |
|||
{ |
|||
[Required] |
|||
[DynamicStringLength(typeof(IdentityClaimTypeConsts), nameof(IdentityClaimTypeConsts.MaxNameLength))] |
|||
public string Name { get; set; } |
|||
|
|||
public bool IsStatic { get; set; } |
|||
|
|||
public IdentityClaimValueType ValueType { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.ObjectExtending; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class IdentityClaimTypeCreateOrUpdateBaseDto : ExtensibleObject |
|||
{ |
|||
public bool Required { get; set; } |
|||
|
|||
[DynamicStringLength(typeof(IdentityClaimTypeConsts), nameof(IdentityClaimTypeConsts.MaxRegexLength))] |
|||
public string Regex { get; set; } |
|||
|
|||
[DynamicStringLength(typeof(IdentityClaimTypeConsts), nameof(IdentityClaimTypeConsts.MaxRegexDescriptionLength))] |
|||
public string RegexDescription { get; set; } |
|||
|
|||
[DynamicStringLength(typeof(IdentityClaimTypeConsts), nameof(IdentityClaimTypeConsts.MaxDescriptionLength))] |
|||
public string Description { get; set; } |
|||
|
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
using System; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class IdentityClaimTypeDto : ExtensibleEntityDto<Guid> |
|||
{ |
|||
public string Name { get; set; } |
|||
|
|||
public bool Required { get; set; } |
|||
|
|||
public bool IsStatic { get; set; } |
|||
|
|||
public string Regex { get; set; } |
|||
|
|||
public string RegexDescription { get; set; } |
|||
|
|||
public string Description { get; set; } |
|||
|
|||
public IdentityClaimValueType ValueType { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class IdentityClaimTypeGetByPagedDto : PagedAndSortedResultRequestDto |
|||
{ |
|||
public string Filter { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class IdentityClaimTypeUpdateDto : IdentityClaimTypeCreateOrUpdateBaseDto |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class IdentityRoleClaimCreateDto |
|||
{ |
|||
[Required] |
|||
[DynamicMaxLength(typeof(IdentityRoleClaimConsts), nameof(IdentityRoleClaimConsts.MaxClaimTypeLength))] |
|||
public string ClaimType { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicMaxLength(typeof(IdentityRoleClaimConsts), nameof(IdentityRoleClaimConsts.MaxClaimValueLength))] |
|||
public string ClaimValue { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class IdentityRoleClaimDeleteDto : IdentityRoleClaimCreateDto |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class IdentityRoleClaimUpdateDto : IdentityRoleClaimCreateDto |
|||
{ |
|||
[Required] |
|||
[DynamicMaxLength(typeof(IdentityRoleClaimConsts), nameof(IdentityRoleClaimConsts.MaxClaimValueLength))] |
|||
public string NewClaimValue { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class IdentityUserClaimCreateDto |
|||
{ |
|||
[Required] |
|||
[DynamicMaxLength(typeof(IdentityUserClaimConsts), nameof(IdentityUserClaimConsts.MaxClaimTypeLength))] |
|||
public string ClaimType { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicMaxLength(typeof(IdentityUserClaimConsts), nameof(IdentityUserClaimConsts.MaxClaimValueLength))] |
|||
public string ClaimValue { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class IdentityUserClaimDeleteDto : IdentityUserClaimCreateDto |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class IdentityUserClaimUpdateDto : IdentityUserClaimCreateDto |
|||
{ |
|||
[Required] |
|||
[DynamicMaxLength(typeof(IdentityUserClaimConsts), nameof(IdentityUserClaimConsts.MaxClaimValueLength))] |
|||
public string NewClaimValue { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public interface IIdentityClaimTypeAppService : |
|||
ICrudAppService< |
|||
IdentityClaimTypeDto, |
|||
Guid, |
|||
IdentityClaimTypeGetByPagedDto, |
|||
IdentityClaimTypeCreateDto, |
|||
IdentityClaimTypeUpdateDto> |
|||
{ |
|||
Task<ListResultDto<IdentityClaimTypeDto>> GetAllListAsync(); |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class IdentityErrorCodes |
|||
{ |
|||
public const string StaticClaimTypeChange = "Volo.Abp.Identity:020005"; |
|||
public const string StaticClaimTypeDeletion = "Volo.Abp.Identity:020006"; |
|||
} |
|||
} |
|||
@ -0,0 +1,129 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
[Authorize(IdentityPermissions.IdentityClaimType.Default)] |
|||
public class IdentityClaimTypeAppService : IdentityAppServiceBase, IIdentityClaimTypeAppService |
|||
{ |
|||
protected IdenityClaimTypeManager IdenityClaimTypeManager { get; } |
|||
|
|||
protected IIdentityClaimTypeRepository IdentityClaimTypeRepository { get; } |
|||
|
|||
public IdentityClaimTypeAppService( |
|||
IdenityClaimTypeManager idenityClaimTypeManager, |
|||
IIdentityClaimTypeRepository identityClaimTypeRepository) |
|||
{ |
|||
IdenityClaimTypeManager = idenityClaimTypeManager; |
|||
IdentityClaimTypeRepository = identityClaimTypeRepository; |
|||
} |
|||
|
|||
[Authorize(IdentityPermissions.IdentityClaimType.Create)] |
|||
public virtual async Task<IdentityClaimTypeDto> CreateAsync(IdentityClaimTypeCreateDto input) |
|||
{ |
|||
if (await IdentityClaimTypeRepository.AnyAsync(input.Name)) |
|||
{ |
|||
throw new UserFriendlyException(L["IdentityClaimTypeAlreadyExists", input.Name]); |
|||
} |
|||
var identityClaimType = new IdentityClaimType( |
|||
GuidGenerator.Create(), |
|||
input.Name, |
|||
input.Required, |
|||
input.IsStatic, |
|||
input.Regex, |
|||
input.RegexDescription, |
|||
input.Description, |
|||
input.ValueType |
|||
); |
|||
identityClaimType = await IdenityClaimTypeManager.CreateAsync(identityClaimType); |
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
|
|||
return ObjectMapper.Map<IdentityClaimType, IdentityClaimTypeDto>(identityClaimType); |
|||
} |
|||
|
|||
[Authorize(IdentityPermissions.IdentityClaimType.Delete)] |
|||
public virtual async Task DeleteAsync(Guid id) |
|||
{ |
|||
var identityClaimType = await IdentityClaimTypeRepository.FindAsync(id); |
|||
if (identityClaimType == null) |
|||
{ |
|||
return; |
|||
} |
|||
CheckDeletionClaimType(identityClaimType); |
|||
await IdentityClaimTypeRepository.DeleteAsync(identityClaimType); |
|||
} |
|||
|
|||
public virtual async Task<IdentityClaimTypeDto> GetAsync(Guid id) |
|||
{ |
|||
var identityClaimType = await IdentityClaimTypeRepository.FindAsync(id); |
|||
|
|||
return ObjectMapper.Map<IdentityClaimType, IdentityClaimTypeDto>(identityClaimType); |
|||
} |
|||
|
|||
public virtual async Task<ListResultDto<IdentityClaimTypeDto>> GetAllListAsync() |
|||
{ |
|||
var identityClaimTypes = await IdentityClaimTypeRepository |
|||
.GetListAsync(); |
|||
|
|||
return new ListResultDto<IdentityClaimTypeDto>( |
|||
ObjectMapper.Map<List<IdentityClaimType>, List<IdentityClaimTypeDto>>(identityClaimTypes)); |
|||
} |
|||
|
|||
public virtual async Task<PagedResultDto<IdentityClaimTypeDto>> GetListAsync(IdentityClaimTypeGetByPagedDto input) |
|||
{ |
|||
var identityClaimTypeCount = await IdentityClaimTypeRepository.GetCountAsync(input.Filter); |
|||
|
|||
var identityClaimTypes = await IdentityClaimTypeRepository |
|||
.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter); |
|||
|
|||
return new PagedResultDto<IdentityClaimTypeDto>(identityClaimTypeCount, |
|||
ObjectMapper.Map<List<IdentityClaimType>, List<IdentityClaimTypeDto>>(identityClaimTypes)); |
|||
} |
|||
|
|||
[Authorize(IdentityPermissions.IdentityClaimType.Update)] |
|||
public virtual async Task<IdentityClaimTypeDto> UpdateAsync(Guid id, IdentityClaimTypeUpdateDto input) |
|||
{ |
|||
var identityClaimType = await IdentityClaimTypeRepository.GetAsync(id); |
|||
CheckChangingClaimType(identityClaimType); |
|||
identityClaimType.Required = input.Required; |
|||
if (!string.Equals(identityClaimType.Regex, input.Regex, StringComparison.InvariantCultureIgnoreCase)) |
|||
{ |
|||
identityClaimType.Regex = input.Regex; |
|||
} |
|||
if (!string.Equals(identityClaimType.RegexDescription, input.RegexDescription, StringComparison.InvariantCultureIgnoreCase)) |
|||
{ |
|||
identityClaimType.RegexDescription = input.RegexDescription; |
|||
} |
|||
if (!string.Equals(identityClaimType.Description, input.Description, StringComparison.InvariantCultureIgnoreCase)) |
|||
{ |
|||
identityClaimType.Description = input.Description; |
|||
} |
|||
|
|||
identityClaimType = await IdenityClaimTypeManager.UpdateAsync(identityClaimType); |
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
|
|||
return ObjectMapper.Map<IdentityClaimType, IdentityClaimTypeDto>(identityClaimType); |
|||
} |
|||
|
|||
protected virtual void CheckChangingClaimType(IdentityClaimType claimType) |
|||
{ |
|||
if (claimType.IsStatic) |
|||
{ |
|||
throw new BusinessException(IdentityErrorCodes.StaticClaimTypeChange); |
|||
} |
|||
} |
|||
|
|||
protected virtual void CheckDeletionClaimType(IdentityClaimType claimType) |
|||
{ |
|||
if (claimType.IsStatic) |
|||
{ |
|||
throw new BusinessException(IdentityErrorCodes.StaticClaimTypeDeletion); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,38 +0,0 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
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(true, Name = IdentityRemoteServiceConsts.RemoteServiceName)] |
|||
[Area("identity")] |
|||
[ControllerName("Role")] |
|||
[Route("api/identity/roles")] |
|||
public class IIdentityRoleController : AbpController, IIdentityRoleAppService |
|||
{ |
|||
protected IIdentityRoleAppService RoleAppService { get; } |
|||
public IIdentityRoleController( |
|||
IIdentityRoleAppService roleAppService) |
|||
{ |
|||
RoleAppService = roleAppService; |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("organization-units/{id}")] |
|||
public virtual async Task<ListResultDto<OrganizationUnitDto>> GetOrganizationUnitsAsync(Guid id) |
|||
{ |
|||
return await RoleAppService.GetOrganizationUnitsAsync(id); |
|||
} |
|||
|
|||
[HttpPut] |
|||
[Route("organization-units/{id}")] |
|||
public virtual async Task SetOrganizationUnitsAsync(Guid id, IdentityRoleAddOrRemoveOrganizationUnitDto input) |
|||
{ |
|||
await RoleAppService.SetOrganizationUnitsAsync(id, input); |
|||
} |
|||
} |
|||
} |
|||
@ -1,38 +0,0 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
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(true, Name = IdentityRemoteServiceConsts.RemoteServiceName)] |
|||
[Area("identity")] |
|||
[ControllerName("User")] |
|||
[Route("api/identity/users")] |
|||
public class IIdentityUserController : AbpController, IIdentityUserAppService |
|||
{ |
|||
protected IIdentityUserAppService UserAppService { get; } |
|||
public IIdentityUserController( |
|||
IIdentityUserAppService userAppService) |
|||
{ |
|||
UserAppService = userAppService; |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("organization-units/{id}")] |
|||
public virtual async Task<ListResultDto<OrganizationUnitDto>> GetOrganizationUnitsAsync(Guid id) |
|||
{ |
|||
return await UserAppService.GetOrganizationUnitsAsync(id); |
|||
} |
|||
|
|||
[HttpPut] |
|||
[Route("organization-units/{id}")] |
|||
public virtual async Task UpdateOrganizationUnitsAsync(Guid id, IdentityUserOrganizationUnitUpdateDto input) |
|||
{ |
|||
await UserAppService.UpdateOrganizationUnitsAsync(id, input); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
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(true, Name = IdentityRemoteServiceConsts.RemoteServiceName)] |
|||
[Area("identity")] |
|||
[ControllerName("ClaimType")] |
|||
[Route("api/identity/claim-types")] |
|||
public class IdentityClaimTypeController : AbpController, IIdentityClaimTypeAppService |
|||
{ |
|||
protected IIdentityClaimTypeAppService IdentityClaimTypeAppService { get; } |
|||
public IdentityClaimTypeController(IIdentityClaimTypeAppService identityClaimTypeAppService) |
|||
{ |
|||
IdentityClaimTypeAppService = identityClaimTypeAppService; |
|||
} |
|||
|
|||
[HttpPost] |
|||
public virtual async Task<IdentityClaimTypeDto> CreateAsync(IdentityClaimTypeCreateDto input) |
|||
{ |
|||
return await IdentityClaimTypeAppService.CreateAsync(input); |
|||
} |
|||
|
|||
[HttpDelete] |
|||
[Route("{id}")] |
|||
public virtual async Task DeleteAsync(Guid id) |
|||
{ |
|||
await IdentityClaimTypeAppService.DeleteAsync(id); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("actived-list")] |
|||
public virtual async Task<ListResultDto<IdentityClaimTypeDto>> GetAllListAsync() |
|||
{ |
|||
return await IdentityClaimTypeAppService.GetAllListAsync(); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("{id}")] |
|||
public virtual async Task<IdentityClaimTypeDto> GetAsync(Guid id) |
|||
{ |
|||
return await IdentityClaimTypeAppService.GetAsync(id); |
|||
} |
|||
|
|||
[HttpGet] |
|||
public virtual async Task<PagedResultDto<IdentityClaimTypeDto>> GetListAsync(IdentityClaimTypeGetByPagedDto input) |
|||
{ |
|||
return await IdentityClaimTypeAppService.GetListAsync(input); |
|||
} |
|||
|
|||
[HttpPut] |
|||
[Route("{id}")] |
|||
public virtual async Task<IdentityClaimTypeDto> UpdateAsync(Guid id, IdentityClaimTypeUpdateDto input) |
|||
{ |
|||
return await IdentityClaimTypeAppService.UpdateAsync(id, input); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,74 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
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(true, Name = IdentityRemoteServiceConsts.RemoteServiceName)] |
|||
[Area("identity")] |
|||
[ControllerName("Role")] |
|||
[Route("api/identity/roles")] |
|||
public class IdentityRoleController : AbpController, IIdentityRoleAppService |
|||
{ |
|||
protected IIdentityRoleAppService RoleAppService { get; } |
|||
public IdentityRoleController( |
|||
IIdentityRoleAppService roleAppService) |
|||
{ |
|||
RoleAppService = roleAppService; |
|||
} |
|||
|
|||
#region OrganizationUnit
|
|||
|
|||
[HttpGet] |
|||
[Route("organization-units/{id}")] |
|||
public virtual async Task<ListResultDto<OrganizationUnitDto>> GetOrganizationUnitsAsync(Guid id) |
|||
{ |
|||
return await RoleAppService.GetOrganizationUnitsAsync(id); |
|||
} |
|||
|
|||
[HttpPut] |
|||
[Route("organization-units/{id}")] |
|||
public virtual async Task SetOrganizationUnitsAsync(Guid id, IdentityRoleAddOrRemoveOrganizationUnitDto input) |
|||
{ |
|||
await RoleAppService.SetOrganizationUnitsAsync(id, input); |
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
#region Claim
|
|||
|
|||
[HttpGet] |
|||
[Route("claims/{id}")] |
|||
public virtual async Task<ListResultDto<IdentityClaimDto>> GetClaimsAsync(Guid id) |
|||
{ |
|||
return await RoleAppService.GetClaimsAsync(id); |
|||
} |
|||
|
|||
[HttpPost] |
|||
[Route("claims/{id}")] |
|||
public virtual async Task AddClaimAsync(Guid id, IdentityRoleClaimCreateDto input) |
|||
{ |
|||
await RoleAppService.AddClaimAsync(id, input); |
|||
} |
|||
|
|||
[HttpPut] |
|||
[Route("claims/{id}")] |
|||
public virtual async Task UpdateClaimAsync(Guid id, IdentityRoleClaimUpdateDto input) |
|||
{ |
|||
await RoleAppService.UpdateClaimAsync(id, input); |
|||
} |
|||
|
|||
[HttpDelete] |
|||
[Route("claims/{id}")] |
|||
public virtual async Task DeleteClaimAsync(Guid id, IdentityRoleClaimDeleteDto input) |
|||
{ |
|||
await RoleAppService.DeleteClaimAsync(id, input); |
|||
} |
|||
|
|||
#endregion
|
|||
} |
|||
} |
|||
@ -0,0 +1,74 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
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(true, Name = IdentityRemoteServiceConsts.RemoteServiceName)] |
|||
[Area("identity")] |
|||
[ControllerName("User")] |
|||
[Route("api/identity/users")] |
|||
public class IdentityUserController : AbpController, IIdentityUserAppService |
|||
{ |
|||
protected IIdentityUserAppService UserAppService { get; } |
|||
public IdentityUserController( |
|||
IIdentityUserAppService userAppService) |
|||
{ |
|||
UserAppService = userAppService; |
|||
} |
|||
|
|||
#region OrganizationUnit
|
|||
|
|||
[HttpGet] |
|||
[Route("organization-units/{id}")] |
|||
public virtual async Task<ListResultDto<OrganizationUnitDto>> GetOrganizationUnitsAsync(Guid id) |
|||
{ |
|||
return await UserAppService.GetOrganizationUnitsAsync(id); |
|||
} |
|||
|
|||
[HttpPut] |
|||
[Route("organization-units/{id}")] |
|||
public virtual async Task UpdateOrganizationUnitsAsync(Guid id, IdentityUserOrganizationUnitUpdateDto input) |
|||
{ |
|||
await UserAppService.UpdateOrganizationUnitsAsync(id, input); |
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
#region Claim
|
|||
|
|||
[HttpGet] |
|||
[Route("claims/{id}")] |
|||
public virtual async Task<ListResultDto<IdentityClaimDto>> GetClaimsAsync(Guid id) |
|||
{ |
|||
return await UserAppService.GetClaimsAsync(id); |
|||
} |
|||
|
|||
[HttpPost] |
|||
[Route("claims/{id}")] |
|||
public virtual async Task AddClaimAsync(Guid id, IdentityUserClaimCreateDto input) |
|||
{ |
|||
await UserAppService.AddClaimAsync(id, input); |
|||
} |
|||
|
|||
[HttpPut] |
|||
[Route("claims/{id}")] |
|||
public virtual async Task UpdateClaimAsync(Guid id, IdentityUserClaimUpdateDto input) |
|||
{ |
|||
await UserAppService.UpdateClaimAsync(id, input); |
|||
} |
|||
|
|||
[HttpDelete] |
|||
[Route("claims/{id}")] |
|||
public virtual async Task DeleteClaimAsync(Guid id, IdentityUserClaimDeleteDto input) |
|||
{ |
|||
await UserAppService.DeleteClaimAsync(id, input); |
|||
} |
|||
|
|||
#endregion
|
|||
} |
|||
} |
|||
Binary file not shown.
@ -0,0 +1,93 @@ |
|||
import ApiService from './serviceBase' |
|||
import { ExtensibleEntity, ExtensibleObject, ListResultDto, PagedAndSortedResultRequestDto, PagedResultDto } from './types' |
|||
|
|||
const IdentityServiceUrl = process.env.VUE_APP_BASE_API |
|||
|
|||
export default class ClaimTypeApiService { |
|||
public static createClaimType(payload: IdentityClaimTypeCreate) { |
|||
const _url = '/api/identity/claim-types' |
|||
return ApiService.Post<IdentityClaimType>(_url, payload, IdentityServiceUrl) |
|||
} |
|||
|
|||
public static getActivedClaimTypes() { |
|||
const _url = '/api/identity/claim-types/actived-list' |
|||
return ApiService.Get<ListResultDto<IdentityClaimType>>(_url, IdentityServiceUrl) |
|||
} |
|||
|
|||
public static getClaimTypes(payload: IdentityClaimTypeGetByPaged) { |
|||
let _url = '/api/identity/claim-types?' |
|||
_url += 'filter=' + payload.filter |
|||
_url += '&sorting=' + payload.sorting |
|||
_url += '&skipCount=' + payload.skipCount |
|||
_url += '&maxResultCount=' + payload.maxResultCount |
|||
return ApiService.Get<PagedResultDto<IdentityClaimType>>(_url, IdentityServiceUrl) |
|||
} |
|||
|
|||
public static getClaimType(id: string) { |
|||
const _url = '/api/identity/claim-types/' + id |
|||
return ApiService.Get<IdentityClaimType>(_url, IdentityServiceUrl) |
|||
} |
|||
|
|||
public static updateClaimType(id: string, payload: IdentityClaimTypeUpdate) { |
|||
const _url = '/api/identity/claim-types/' + id |
|||
return ApiService.Put<IdentityClaimType>(_url, payload, IdentityServiceUrl) |
|||
} |
|||
|
|||
public static deleteClaimType(id: string) { |
|||
const _url = '/api/identity/claim-types/' + id |
|||
return ApiService.Delete(_url, IdentityServiceUrl) |
|||
} |
|||
} |
|||
|
|||
export enum IdentityClaimValueType { |
|||
String = 0, |
|||
Int = 1, |
|||
Boolean = 2, |
|||
DateTime = 3 |
|||
} |
|||
|
|||
export class IdentityClaimType extends ExtensibleEntity<string> { |
|||
name!: string |
|||
required!: boolean |
|||
isStatic!: boolean |
|||
regex?: string |
|||
regexDescription?: string |
|||
description?: string |
|||
valueType!: IdentityClaimValueType |
|||
} |
|||
|
|||
export class IdentityClaimTypeCreateOrUpdateBase extends ExtensibleObject { |
|||
required = false |
|||
regex?: string = '' |
|||
regexDescription?: string = '' |
|||
description?: string = '' |
|||
} |
|||
|
|||
export class IdentityClaimTypeCreate extends IdentityClaimTypeCreateOrUpdateBase { |
|||
name!: string |
|||
isStatic!: boolean |
|||
valueType!: IdentityClaimValueType |
|||
|
|||
constructor( |
|||
name: string, |
|||
isStatic = false, |
|||
valueType = IdentityClaimValueType.String |
|||
) { |
|||
super() |
|||
this.name = name |
|||
this.isStatic = isStatic |
|||
this.valueType = valueType |
|||
} |
|||
} |
|||
|
|||
export class IdentityClaimTypeUpdate extends IdentityClaimTypeCreateOrUpdateBase { |
|||
} |
|||
|
|||
export class IdentityClaimTypeGetByPaged extends PagedAndSortedResultRequestDto { |
|||
filter = '' |
|||
|
|||
constructor() { |
|||
super() |
|||
this.sorting = 'name' |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
/* eslint-disable */ |
|||
/* tslint:disable */ |
|||
// @ts-ignore
|
|||
import icon from 'vue-svgicon' |
|||
icon.register({ |
|||
'claim-type': { |
|||
width: 128, |
|||
height: 128, |
|||
viewBox: '0 0 1024 1024', |
|||
data: '<path pid="0" _fill="#333" d="M384 268.8c0-17.067 0-25.6 4.267-29.867 4.266-8.533 8.533-12.8 17.066-17.066 8.534-8.534 12.8-8.534 34.134-8.534 17.066-25.6 42.666-42.666 72.533-42.666s59.733 17.066 72.533 42.666c17.067 0 25.6 0 34.134 4.267 8.533 4.267 12.8 8.533 17.066 17.067C640 243.2 640 247.467 640 268.8l-8.533-12.8h51.2C729.6 256 768 294.4 768 341.333v256c0 12.8-8.533 21.334-21.333 21.334s-21.334-8.534-21.334-21.334v-256c0-25.6-17.066-42.666-42.666-42.666h-59.734l17.067-12.8c0 17.066 0 25.6-4.267 29.866-4.266 8.534-8.533 12.8-17.066 17.067-8.534 8.533-12.8 8.533-34.134 8.533H435.2c-17.067 0-21.333 0-29.867-4.266-8.533-4.267-12.8-8.534-17.066-17.067C384 311.467 384 307.2 384 285.867l17.067 12.8h-59.734c-25.6 0-42.666 17.066-42.666 42.666V768c0 25.6 17.066 42.667 42.666 42.667h341.334c25.6 0 42.666-17.067 42.666-42.667v-42.667c0-12.8 8.534-21.333 21.334-21.333S768 712.533 768 725.333V768c0 46.933-38.4 85.333-85.333 85.333H341.333C294.4 853.333 256 814.933 256 768V341.333C256 294.4 294.4 256 341.333 256h51.2L384 268.8zm42.667 0v8.533c0 12.8 8.533 21.334 21.333 21.334h128c12.8 0 21.333-8.534 21.333-21.334V256H588.8c-17.067 0-29.867-8.533-38.4-21.333-8.533-12.8-21.333-21.334-38.4-21.334s-29.867 8.534-38.4 21.334c-4.267 12.8-21.333 21.333-34.133 21.333h-12.8v12.8zm192 200.533H405.333C392.533 469.333 384 460.8 384 448s8.533-21.333 21.333-21.333h213.334c12.8 0 21.333 8.533 21.333 21.333s-8.533 21.333-21.333 21.333zm0 128H405.333C392.533 597.333 384 588.8 384 576s8.533-21.333 21.333-21.333h213.334c12.8 0 21.333 8.533 21.333 21.333s-8.533 21.333-21.333 21.333zm0 128H405.333C392.533 725.333 384 716.8 384 704s8.533-21.333 21.333-21.333h213.334c12.8 0 21.333 8.533 21.333 21.333s-8.533 21.333-21.333 21.333z"/>' |
|||
} |
|||
}) |
|||
|
After Width: | Height: | Size: 2.6 KiB |
@ -0,0 +1,230 @@ |
|||
<template> |
|||
<el-dialog |
|||
v-el-draggable-dialog |
|||
width="800px" |
|||
:visible="showDialog" |
|||
:title="title" |
|||
custom-class="modal-form" |
|||
:show-close="false" |
|||
:close-on-click-modal="false" |
|||
:close-on-press-escape="false" |
|||
@close="onFormClosed(false)" |
|||
> |
|||
<el-form |
|||
ref="claimTypeForm" |
|||
:model="claimType" |
|||
label-width="120px" |
|||
:rules="claimTypeRules" |
|||
> |
|||
<el-form-item |
|||
prop="name" |
|||
:label="$t('AbpIdentity.IdentityClaim:Name')" |
|||
> |
|||
<el-input |
|||
v-model="claimType.name" |
|||
:disabled="isEditClaimType" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item |
|||
prop="description" |
|||
:label="$t('AbpIdentity.IdentityClaim:Description')" |
|||
> |
|||
<el-input |
|||
v-model="claimType.description" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item |
|||
prop="regex" |
|||
:label="$t('AbpIdentity.IdentityClaim:Regex')" |
|||
> |
|||
<el-input |
|||
v-model="claimType.regex" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item |
|||
prop="regexDescription" |
|||
:label="$t('AbpIdentity.IdentityClaim:RegexDescription')" |
|||
> |
|||
<el-input |
|||
v-model="claimType.regexDescription" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item |
|||
prop="valueType" |
|||
:label="$t('AbpIdentity.IdentityClaim:ValueType')" |
|||
> |
|||
<el-select |
|||
v-model="claimType.valueType" |
|||
style="width: 100%" |
|||
:disabled="isEditClaimType" |
|||
> |
|||
<el-option |
|||
v-for="valueType in claimValueTypes" |
|||
:key="valueType.name" |
|||
:label="valueType.name" |
|||
:value="valueType.value" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item |
|||
prop="required" |
|||
:label="$t('AbpIdentity.IdentityClaim:Required')" |
|||
> |
|||
<el-switch |
|||
v-model="claimType.required" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item |
|||
prop="isStatic" |
|||
:label="$t('AbpIdentity.IdentityClaim:IsStatic')" |
|||
> |
|||
<el-switch |
|||
v-model="claimType.isStatic" |
|||
:disabled="isEditClaimType" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button |
|||
class="cancel" |
|||
style="width:100px" |
|||
@click="onFormClosed(false)" |
|||
> |
|||
{{ $t('global.cancel') }} |
|||
</el-button> |
|||
<el-button |
|||
class="confirm" |
|||
type="primary" |
|||
style="width:100px" |
|||
@click="onSave" |
|||
> |
|||
{{ $t('global.confirm') }} |
|||
</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import { Form } from 'element-ui' |
|||
import ClaimTypeApiService, { |
|||
IdentityClaimType, |
|||
IdentityClaimValueType, |
|||
IdentityClaimTypeCreate, |
|||
IdentityClaimTypeUpdate, |
|||
IdentityClaimTypeCreateOrUpdateBase |
|||
} from '@/api/cliam-type' |
|||
import { Component, Vue, Prop, Watch } from 'vue-property-decorator' |
|||
|
|||
@Component({ |
|||
name: 'CreateOrUpdateCliamTypeForm' |
|||
}) |
|||
export default class CreateOrUpdateCliamTypeForm extends Vue { |
|||
@Prop({ default: '' }) |
|||
private claimTypeId!: string |
|||
|
|||
@Prop({ default: '' }) |
|||
private title!: string |
|||
|
|||
@Prop({ default: false }) |
|||
private showDialog!: boolean |
|||
|
|||
private hasChanged = false |
|||
private claimType = new IdentityClaimType() |
|||
private claimValueTypes = [ |
|||
{ name: 'Boolean', value: IdentityClaimValueType.Boolean }, |
|||
{ name: 'DateTime', value: IdentityClaimValueType.DateTime }, |
|||
{ name: 'Int', value: IdentityClaimValueType.Int }, |
|||
{ name: 'String', value: IdentityClaimValueType.String } |
|||
] |
|||
|
|||
private claimTypeRules = { |
|||
name: [ |
|||
{ required: true, message: this.l('pleaseInputBy', { key: this.l('AbpIdentity.IdentityClaim:Name') }), trigger: 'blur' } |
|||
], |
|||
valueType: [ |
|||
{ required: true, message: this.l('pleaseSelectBy', { key: this.l('AbpIdentity.IdentityClaim:ValueType') }), trigger: 'blur' } |
|||
] |
|||
} |
|||
|
|||
get isEditClaimType() { |
|||
if (this.claimTypeId) { |
|||
return true |
|||
} |
|||
return false |
|||
} |
|||
|
|||
@Watch('claimTypeId') |
|||
private onClaimTypeIdChanged() { |
|||
this.handleGetClaimType() |
|||
} |
|||
|
|||
@Watch('showDialog', { immediate: true }) |
|||
private onShowDialogChanged() { |
|||
this.handleGetClaimType() |
|||
} |
|||
|
|||
private handleGetClaimType() { |
|||
this.hasChanged = false |
|||
if (this.showDialog && this.claimTypeId) { |
|||
ClaimTypeApiService.getClaimType(this.claimTypeId).then(res => { |
|||
this.claimType = res |
|||
}) |
|||
} |
|||
} |
|||
|
|||
private onSave() { |
|||
const claimTypeForm = this.$refs.claimTypeForm as Form |
|||
claimTypeForm.validate(valid => { |
|||
if (valid) { |
|||
if (this.isEditClaimType) { |
|||
const updatePayload = new IdentityClaimTypeUpdate() |
|||
this.updateClaimTypeByInput(updatePayload) |
|||
ClaimTypeApiService.updateClaimType(this.claimTypeId, updatePayload).then(res => { |
|||
this.claimType = res |
|||
this.hasChanged = true |
|||
this.$message.success(this.l('global.successful')) |
|||
}) |
|||
} else { |
|||
const createPayload = new IdentityClaimTypeCreate(this.claimType.name, this.claimType.isStatic, this.claimType.valueType) |
|||
this.updateClaimTypeByInput(createPayload) |
|||
ClaimTypeApiService.createClaimType(createPayload).then(() => { |
|||
claimTypeForm.resetFields() |
|||
this.hasChanged = true |
|||
this.$message.success(this.l('global.successful')) |
|||
this.onFormClosed(true) |
|||
}) |
|||
} |
|||
} |
|||
}) |
|||
} |
|||
|
|||
private onFormClosed(changed: boolean) { |
|||
const claimTypeForm = this.$refs.claimTypeForm as Form |
|||
claimTypeForm.resetFields() |
|||
this.hasChanged = this.hasChanged ? this.hasChanged : changed |
|||
this.$emit('closed', this.hasChanged) |
|||
} |
|||
|
|||
private updateClaimTypeByInput(claimType: IdentityClaimTypeCreateOrUpdateBase) { |
|||
claimType.regex = this.claimType.regex |
|||
claimType.regexDescription = this.claimType.regexDescription |
|||
claimType.required = this.claimType.required |
|||
claimType.description = this.claimType.description |
|||
} |
|||
|
|||
private l(name: string, values?: any[] | { [key: string]: any }) { |
|||
return this.$t(name, values).toString() |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
.confirm { |
|||
position: absolute; |
|||
right: 10px; |
|||
} |
|||
.cancel { |
|||
position: absolute; |
|||
right: 120px; |
|||
} |
|||
</style> |
|||
@ -0,0 +1,252 @@ |
|||
<template> |
|||
<div class="app-container"> |
|||
<div class="filter-container"> |
|||
<label |
|||
class="radio-label" |
|||
style="padding-left:0;" |
|||
>{{ $t('global.queryFilter') }}</label> |
|||
<el-input |
|||
v-model="dataFilter.filter" |
|||
:placeholder="$t('global.filterString')" |
|||
style="width: 250px;margin-left: 10px;" |
|||
class="filter-item" |
|||
/> |
|||
<el-button |
|||
class="filter-item" |
|||
style="margin-left: 10px; text-alignt" |
|||
type="primary" |
|||
@click="refreshPagedData" |
|||
> |
|||
{{ $t('global.searchList') }} |
|||
</el-button> |
|||
<el-button |
|||
class="filter-item" |
|||
type="primary" |
|||
:disabled="!checkPermission(['AbpIdentity.IdentityClaimTypes.Create'])" |
|||
@click="handleCreateClaimType" |
|||
> |
|||
{{ $t('AbpIdentity.AddClaim') }} |
|||
</el-button> |
|||
</div> |
|||
|
|||
<el-table |
|||
v-loading="dataLoading" |
|||
row-key="id" |
|||
:data="dataList" |
|||
stripe |
|||
border |
|||
fit |
|||
highlight-current-row |
|||
@sort-change="handleSortChange" |
|||
> |
|||
<el-table-column |
|||
:label="$t('AbpIdentity.IdentityClaim:Name')" |
|||
prop="name" |
|||
sortable |
|||
width="300px" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<span>{{ row.name }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('AbpIdentity.IdentityClaim:ValueType')" |
|||
prop="valueType" |
|||
sortable |
|||
width="150px" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<span>{{ row.valueType | claimValueTypeFilter }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('AbpIdentity.IdentityClaim:Description')" |
|||
prop="description" |
|||
sortable |
|||
min-width="100%" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<span>{{ row.description }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('AbpIdentity.IdentityClaim:Regex')" |
|||
prop="regex" |
|||
sortable |
|||
width="200px" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<span>{{ row.regex }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('AbpIdentity.IdentityClaim:Required')" |
|||
prop="required" |
|||
sortable |
|||
width="150px" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<el-switch |
|||
v-model="row.required" |
|||
disabled |
|||
/> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('AbpIdentity.IdentityClaim:IsStatic')" |
|||
prop="isStatic" |
|||
sortable |
|||
width="150px" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<el-switch |
|||
v-model="row.isStatic" |
|||
disabled |
|||
/> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('operaActions')" |
|||
align="center" |
|||
width="260px" |
|||
fixed="right" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<el-button |
|||
:disabled="!allowedEditClaim(row)" |
|||
size="mini" |
|||
type="primary" |
|||
@click="handleUpdateClaimType(row)" |
|||
> |
|||
{{ $t('AbpIdentity.UpdateClaim') }} |
|||
</el-button> |
|||
<el-button |
|||
:disabled="!allowedDeleteClaim(row)" |
|||
size="mini" |
|||
type="danger" |
|||
@click="handleDeleteClaimType(row)" |
|||
> |
|||
{{ $t('AbpIdentity.DeleteClaim') }} |
|||
</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
|
|||
<pagination |
|||
v-show="dataTotal>0" |
|||
:total="dataTotal" |
|||
:page.sync="currentPage" |
|||
:limit.sync="pageSize" |
|||
@pagination="refreshPagedData" |
|||
/> |
|||
|
|||
<create-or-update-cliam-type-form |
|||
:title="editClaimTypeTitle" |
|||
:claim-type-id="editClaimTypeId" |
|||
:show-dialog="showClaimTypeDialog" |
|||
@closed="onClaimTypeDialogClosed" |
|||
/> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import { checkPermission } from '@/utils/permission' |
|||
import { abpPagerFormat } from '@/utils' |
|||
import Pagination from '@/components/Pagination/index.vue' |
|||
import DataListMiXin from '@/mixins/DataListMiXin' |
|||
import Component, { mixins } from 'vue-class-component' |
|||
import CreateOrUpdateCliamTypeForm from './components/CreateOrUpdateCliamTypeForm.vue' |
|||
import ClaimTypeApiService, { IdentityClaimType, IdentityClaimTypeGetByPaged, IdentityClaimValueType } from '@/api/cliam-type' |
|||
|
|||
const valueTypeMap: { [key: number]: string } = { |
|||
[IdentityClaimValueType.String]: 'String', |
|||
[IdentityClaimValueType.Boolean]: 'Boolean', |
|||
[IdentityClaimValueType.DateTime]: 'DateTime', |
|||
[IdentityClaimValueType.Int]: 'Int' |
|||
} |
|||
|
|||
@Component({ |
|||
name: 'ClaimType', |
|||
components: { |
|||
Pagination, |
|||
CreateOrUpdateCliamTypeForm |
|||
}, |
|||
filters: { |
|||
claimValueTypeFilter(valueType: IdentityClaimValueType) { |
|||
return valueTypeMap[valueType] |
|||
} |
|||
}, |
|||
methods: { |
|||
checkPermission |
|||
} |
|||
}) |
|||
export default class ClaimType extends mixins(DataListMiXin) { |
|||
private editClaimTypeId = '' |
|||
private editClaimTypeTitle = '' |
|||
private showClaimTypeDialog = false |
|||
public dataFilter = new IdentityClaimTypeGetByPaged() |
|||
|
|||
mounted() { |
|||
this.refreshPagedData() |
|||
} |
|||
|
|||
get allowedEditClaim() { |
|||
return (claimType: IdentityClaimType) => { |
|||
return !claimType.isStatic && checkPermission(['AbpIdentity.IdentityClaimTypes.Update']) |
|||
} |
|||
} |
|||
|
|||
get allowedDeleteClaim() { |
|||
return (claimType: IdentityClaimType) => { |
|||
return !claimType.isStatic && checkPermission(['AbpIdentity.IdentityClaimTypes.Delete']) |
|||
} |
|||
} |
|||
|
|||
protected processDataFilter() { |
|||
this.dataFilter.skipCount = abpPagerFormat(this.currentPage, this.pageSize) |
|||
} |
|||
|
|||
protected getPagedList() { |
|||
return ClaimTypeApiService.getClaimTypes(this.dataFilter) |
|||
} |
|||
|
|||
private handleCreateClaimType() { |
|||
this.editClaimTypeId = '' |
|||
this.editClaimTypeTitle = this.l('AbpIdentity.IdentityClaim:New') |
|||
this.showClaimTypeDialog = true |
|||
} |
|||
|
|||
private handleUpdateClaimType(claimType: IdentityClaimType) { |
|||
this.editClaimTypeId = claimType.id |
|||
this.editClaimTypeTitle = this.l('AbpIdentity.ClaimSubject', { 0: claimType.name }) |
|||
this.showClaimTypeDialog = true |
|||
} |
|||
|
|||
private handleDeleteClaimType(claimType: IdentityClaimType) { |
|||
this.$confirm(this.l('AbpIdentity.WillDeleteClaim', { 0: claimType.name }), |
|||
this.l('AbpUi.AreYouSure'), { |
|||
callback: (action) => { |
|||
if (action === 'confirm') { |
|||
ClaimTypeApiService.deleteClaimType(claimType.id).then(() => { |
|||
this.$message.success(this.l('global.successful')) |
|||
this.refreshPagedData() |
|||
}) |
|||
} |
|||
} |
|||
}) |
|||
} |
|||
|
|||
private onClaimTypeDialogClosed(changed: boolean) { |
|||
this.showClaimTypeDialog = false |
|||
if (changed) { |
|||
this.refreshPagedData() |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
@ -0,0 +1,297 @@ |
|||
<template> |
|||
<el-dialog |
|||
v-el-draggable-dialog |
|||
width="800px" |
|||
:visible="showDialog" |
|||
:title="title" |
|||
custom-class="modal-form" |
|||
:show-close="false" |
|||
:close-on-click-modal="true" |
|||
:close-on-press-escape="true" |
|||
@close="onFormClosed(false)" |
|||
> |
|||
<el-form |
|||
ref="userClaimForm" |
|||
:model="editUserClaim" |
|||
label-width="120px" |
|||
:rules="userClaimRules" |
|||
> |
|||
<el-form-item |
|||
prop="claimType" |
|||
:label="$t('AbpIdentity.DisplayName:ClaimType')" |
|||
> |
|||
<el-select |
|||
v-model="editUserClaim.claimType" |
|||
style="width: 100%" |
|||
@change="onClaimTypeChanged" |
|||
> |
|||
<el-option |
|||
v-for="claim in claimTypes" |
|||
:key="claim.id" |
|||
:label="claim.name" |
|||
:value="claim.name" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item |
|||
prop="claimValue" |
|||
:label="$t('AbpIdentity.DisplayName:ClaimValue')" |
|||
> |
|||
<el-input |
|||
v-if="hasStringValueType(editUserClaim.claimType)" |
|||
v-model="editUserClaim.claimValue" |
|||
type="text" |
|||
/> |
|||
<el-input |
|||
v-else-if="hasIntegerValueType(editUserClaim.claimType)" |
|||
v-model="editUserClaim.claimValue" |
|||
type="number" |
|||
/> |
|||
<el-switch |
|||
v-else-if="hasBooleanValueType(editUserClaim.claimType)" |
|||
v-model="editUserClaim.claimValue" |
|||
/> |
|||
<el-date-picker |
|||
v-else-if="hasDateTimeValueType(editUserClaim.claimType)" |
|||
v-model="editUserClaim.claimValue" |
|||
type="datetime" |
|||
style="width: 100%" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item |
|||
style="text-align: center;" |
|||
label-width="0px" |
|||
> |
|||
<el-button |
|||
type="primary" |
|||
style="width:180px" |
|||
@click="onSave" |
|||
> |
|||
{{ $t('AbpIdentity.AddClaim') }} |
|||
</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
<el-table |
|||
row-key="id" |
|||
:data="userClaims" |
|||
border |
|||
fit |
|||
highlight-current-row |
|||
style="width: 100%;" |
|||
> |
|||
<el-table-column |
|||
:label="$t('AbpIdentity.DisplayName:ClaimType')" |
|||
prop="claimType" |
|||
sortable |
|||
width="150px" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<span>{{ row.claimType }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('AbpIdentity.DisplayName:ClaimValue')" |
|||
prop="claimValue" |
|||
sortable |
|||
min-width="100%" |
|||
align="center" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<span>{{ claimValue(row.claimType, row.claimValue) }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
:label="$t('operaActions')" |
|||
align="center" |
|||
width="150px" |
|||
> |
|||
<template slot-scope="{row}"> |
|||
<el-button |
|||
:disabled="!checkPermission(['AbpIdentity.Users.ManageClaims'])" |
|||
size="mini" |
|||
type="danger" |
|||
@click="handleDeleteUserClaim(row)" |
|||
> |
|||
{{ $t('AbpIdentity.DeleteClaim') }} |
|||
</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import { dateFormat } from '@/utils/index' |
|||
import { checkPermission } from '@/utils/permission' |
|||
import { Component, Vue, Prop, Watch } from 'vue-property-decorator' |
|||
import UserService, { UserClaim, UserClaimCreateOrUpdate, UserClaimDelete } from '@/api/users' |
|||
import ClaimTypeApiService, { IdentityClaimType, IdentityClaimValueType } from '@/api/cliam-type' |
|||
import { Form } from 'element-ui' |
|||
|
|||
@Component({ |
|||
name: 'UserClaimCreateOrUpdateForm', |
|||
methods: { |
|||
checkPermission |
|||
} |
|||
}) |
|||
export default class UserClaimCreateOrUpdateForm extends Vue { |
|||
@Prop({ default: '' }) |
|||
private userId!: string |
|||
|
|||
@Prop({ default: '' }) |
|||
private title!: string |
|||
|
|||
@Prop({ default: false }) |
|||
private showDialog!: boolean |
|||
|
|||
private editUserClaim = new UserClaimCreateOrUpdate() |
|||
private userClaims = new Array<UserClaim>() |
|||
private claimTypes = new Array<IdentityClaimType>() |
|||
|
|||
private userClaimRules = {} |
|||
|
|||
get cliamType() { |
|||
return (claimName: string) => { |
|||
const claimIndex = this.claimTypes.findIndex(cliam => cliam.name === claimName) |
|||
if (claimIndex >= 0) { |
|||
return this.claimTypes[claimIndex].valueType |
|||
} |
|||
return IdentityClaimValueType.String |
|||
} |
|||
} |
|||
|
|||
get claimValue() { |
|||
return (type: string, value: string) => { |
|||
const valueType = this.cliamType(type) |
|||
switch (valueType) { |
|||
case IdentityClaimValueType.Int : |
|||
case IdentityClaimValueType.String : |
|||
return value |
|||
case IdentityClaimValueType.Boolean : |
|||
return value.toLowerCase() === 'true' |
|||
case IdentityClaimValueType.DateTime : |
|||
return dateFormat(new Date(value), 'YYYY-mm-dd HH:MM:SS') |
|||
} |
|||
} |
|||
} |
|||
|
|||
get hasStringValueType() { |
|||
return (claimName: string) => { |
|||
return this.cliamType(claimName) === IdentityClaimValueType.String |
|||
} |
|||
} |
|||
|
|||
get hasBooleanValueType() { |
|||
return (claimName: string) => { |
|||
return this.cliamType(claimName) === IdentityClaimValueType.Boolean |
|||
} |
|||
} |
|||
|
|||
get hasDateTimeValueType() { |
|||
return (claimName: string) => { |
|||
return this.cliamType(claimName) === IdentityClaimValueType.DateTime |
|||
} |
|||
} |
|||
|
|||
get hasIntegerValueType() { |
|||
return (claimName: string) => { |
|||
return this.cliamType(claimName) === IdentityClaimValueType.Int |
|||
} |
|||
} |
|||
|
|||
@Watch('userId') |
|||
private onUserIdChanged() { |
|||
if (this.userId && this.showDialog) { |
|||
this.handleGetUserClaims() |
|||
} |
|||
} |
|||
|
|||
mounted() { |
|||
this.handleGetClaimTypes() |
|||
this.handleGetUserClaims() |
|||
this.userClaimRules = { |
|||
claimType: [ |
|||
{ required: true, message: this.l('pleaseSelectBy', { key: this.l('AbpIdentity.DisplayName:ClaimType') }), trigger: 'blur' } |
|||
], |
|||
claimValue: [ |
|||
{ required: true, message: this.l('pleaseInputBy', { key: this.l('AbpIdentity.DisplayName:ClaimValue') }), trigger: 'blur' } |
|||
] |
|||
} |
|||
} |
|||
|
|||
private handleGetClaimTypes() { |
|||
ClaimTypeApiService.getActivedClaimTypes().then(res => { |
|||
this.claimTypes = res.items |
|||
}) |
|||
} |
|||
|
|||
private handleGetUserClaims() { |
|||
if (this.userId) { |
|||
UserService.getUserClaims(this.userId).then(res => { |
|||
this.userClaims = res.items |
|||
}) |
|||
} |
|||
} |
|||
|
|||
private handleDeleteUserClaim(claim: UserClaim) { |
|||
this.$confirm(this.l('AbpIdentity.DeleteClaim'), |
|||
this.l('AbpUi.AreYouSure'), { |
|||
callback: (action) => { |
|||
if (action === 'confirm') { |
|||
const deleteClaim = new UserClaimDelete() |
|||
deleteClaim.claimType = claim.claimType |
|||
deleteClaim.claimValue = claim.claimValue |
|||
UserService.deleteUserClaim(this.userId, deleteClaim).then(() => { |
|||
this.$message.success(this.l('global.successful')) |
|||
const claimIndex = this.userClaims.findIndex(uc => uc.id === claim.id) |
|||
this.userClaims.splice(claimIndex, 1) |
|||
}) |
|||
} |
|||
} |
|||
}) |
|||
} |
|||
|
|||
// TODO: 可以简化为一个组件,通过组件来实现用户/客户端等的声明类型 |
|||
private onClaimTypeChanged() { |
|||
const valueType = this.cliamType(this.editUserClaim.claimType) |
|||
switch (valueType) { |
|||
case IdentityClaimValueType.Int : |
|||
this.editUserClaim.claimValue = '0' |
|||
break |
|||
case IdentityClaimValueType.String : |
|||
this.editUserClaim.claimValue = '' |
|||
break |
|||
case IdentityClaimValueType.Boolean : |
|||
this.editUserClaim.claimValue = 'false' |
|||
break |
|||
case IdentityClaimValueType.DateTime : |
|||
this.editUserClaim.claimValue = '' |
|||
break |
|||
} |
|||
} |
|||
|
|||
private onSave() { |
|||
const userClaimForm = this.$refs.userClaimForm as Form |
|||
userClaimForm.validate(valid => { |
|||
if (valid) { |
|||
UserService.addUserClaim(this.userId, this.editUserClaim).then(() => { |
|||
this.$message.success(this.$t('global.successful').toString()) |
|||
userClaimForm.resetFields() |
|||
this.handleGetUserClaims() |
|||
}) |
|||
} |
|||
}) |
|||
} |
|||
|
|||
private onFormClosed(changed: boolean) { |
|||
const userClaimForm = this.$refs.userClaimForm as Form |
|||
userClaimForm.resetFields() |
|||
this.$emit('closed', changed) |
|||
} |
|||
|
|||
private l(name: string, values?: any[] | { [key: string]: any }) { |
|||
return this.$t(name, values).toString() |
|||
} |
|||
} |
|||
</script> |
|||
Loading…
Reference in new issue