Browse Source

Use a data dictionary instead of a **PlatformType**

pull/281/head
cKey 5 years ago
parent
commit
4b1e250f64
  1. 3531
      aspnet-core/database/ApiGateway-Init.sql
  2. 50
      aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Datas/IDataAppService.cs
  3. 29
      aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Layouts/Dto/GetLayoutListInput.cs
  4. 25
      aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Layouts/Dto/LayoutCreateDto.cs
  5. 56
      aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Layouts/Dto/LayoutCreateOrUpdateDto.cs
  6. 34
      aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Layouts/Dto/LayoutDto.cs
  7. 18
      aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/GetMenuInput.cs
  8. 4
      aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/MenuDto.cs
  9. 43
      aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/MenuGetAllInput.cs
  10. 29
      aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/MenuGetByRoleInput.cs
  11. 33
      aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/MenuGetByUserInput.cs
  12. 39
      aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/MenuGetListInput.cs
  13. 389
      aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Datas/DataAppService.cs
  14. 245
      aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Layouts/LayoutAppService.cs
  15. 479
      aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/MenuAppService.cs
  16. 113
      aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/en.json
  17. 113
      aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/zh-Hans.json
  18. 7
      aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/LayoutConsts.cs
  19. 248
      aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/Data.cs
  20. 118
      aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/DataDictionaryDataSeeder.cs
  21. 187
      aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/DataItem.cs
  22. 37
      aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/IDataDictionaryDataSeeder.cs
  23. 76
      aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Layouts/ILayoutRepository.cs
  24. 78
      aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Layouts/Layout.cs
  25. 226
      aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IMenuRepository.cs
  26. 134
      aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/Menu.cs
  27. 482
      aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/MenuManager.cs
  28. 100
      aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/IRouteDataSeeder.cs
  29. 300
      aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/RouteDataSeeder.cs
  30. 507
      aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs
  31. 160
      aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Layouts/EfCoreLayoutRepository.cs
  32. 504
      aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreMenuRepository.cs
  33. 175
      aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Datas/DataController.cs
  34. 256
      aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Menus/MenuController.cs
  35. 1887
      aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/DataSeeder/ElementAdminDataSeedContributor.cs
  36. 291
      aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/DataSeeder/VbenAdminDataSeedContributor.cs
  37. 556
      aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantSynchronizer.cs
  38. 148
      aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj
  39. 665
      aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20210621020117_Rename-Route-Field-PlantType-To-Framework.Designer.cs
  40. 81
      aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20210621020117_Rename-Route-Field-PlantType-To-Framework.cs
  41. 1302
      aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs
  42. 237
      vueJs/src/api/data-dictionary.ts
  43. 186
      vueJs/src/api/layout.ts
  44. 245
      vueJs/src/api/menu.ts
  45. 283
      vueJs/src/store/modules/permission.ts
  46. 408
      vueJs/src/views/admin/data-dictionary/components/DataDictionaryTree.vue
  47. 358
      vueJs/src/views/admin/roles/components/ManageRoleMenuDialog.vue
  48. 716
      vueJs/src/views/admin/roles/index.vue
  49. 358
      vueJs/src/views/admin/users/components/ManageUserMenuDialog.vue
  50. 746
      vueJs/src/views/admin/users/index.vue
  51. 555
      vueJs/src/views/container/layouts/components/CreateOrUpdateLayoutDialog.vue
  52. 486
      vueJs/src/views/container/layouts/index.vue
  53. 583
      vueJs/src/views/container/menus/index.vue
  54. 240
      vueJs/vue.config.js

3531
aspnet-core/database/ApiGateway-Init.sql

File diff suppressed because it is too large

50
aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Datas/IDataAppService.cs

@ -1,24 +1,26 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
namespace LINGYUN.Platform.Datas namespace LINGYUN.Platform.Datas
{ {
public interface IDataAppService : public interface IDataAppService :
ICrudAppService< ICrudAppService<
DataDto, DataDto,
Guid, Guid,
GetDataListInput, GetDataListInput,
DataCreateDto, DataCreateDto,
DataUpdateDto> DataUpdateDto>
{ {
Task<ListResultDto<DataDto>> GetAllAsync(); Task<DataDto> GetAsync(string name);
Task CreateItemAsync(Guid id, DataItemCreateDto input); Task<ListResultDto<DataDto>> GetAllAsync();
Task UpdateItemAsync(Guid id, string name, DataItemUpdateDto input); Task CreateItemAsync(Guid id, DataItemCreateDto input);
Task DeleteItemAsync(Guid id, string name); Task UpdateItemAsync(Guid id, string name, DataItemUpdateDto input);
}
} Task DeleteItemAsync(Guid id, string name);
}
}

29
aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Layouts/Dto/GetLayoutListInput.cs

@ -1,13 +1,16 @@
using Volo.Abp.Application.Dtos; using LINGYUN.Platform.Routes;
using Volo.Abp.Application.Dtos;
namespace LINGYUN.Platform.Layouts using Volo.Abp.Validation;
{
public class GetLayoutListInput : PagedAndSortedResultRequestDto namespace LINGYUN.Platform.Layouts
{ {
public string Filter { get; set; } public class GetLayoutListInput : PagedAndSortedResultRequestDto
{
public bool Reverse { get; set; } public string Filter { get; set; }
public PlatformType? PlatformType { get; set; } public bool Reverse { get; set; }
}
} [DynamicStringLength(typeof(LayoutConsts), nameof(LayoutConsts.MaxFrameworkLength))]
public string Framework { get; set; }
}
}

25
aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Layouts/Dto/LayoutCreateDto.cs

@ -1,9 +1,16 @@
using System; using LINGYUN.Platform.Routes;
using System;
namespace LINGYUN.Platform.Layouts using System.ComponentModel.DataAnnotations;
{ using Volo.Abp.Validation;
public class LayoutCreateDto : LayoutCreateOrUpdateDto
{ namespace LINGYUN.Platform.Layouts
public Guid DataId { get; set; } {
} public class LayoutCreateDto : LayoutCreateOrUpdateDto
} {
public Guid DataId { get; set; }
[Required]
[DynamicStringLength(typeof(LayoutConsts), nameof(LayoutConsts.MaxFrameworkLength))]
public string Framework { get; set; }
}
}

56
aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Layouts/Dto/LayoutCreateOrUpdateDto.cs

@ -1,29 +1,27 @@
using LINGYUN.Platform.Routes; using LINGYUN.Platform.Routes;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation; using Volo.Abp.Validation;
namespace LINGYUN.Platform.Layouts namespace LINGYUN.Platform.Layouts
{ {
public class LayoutCreateOrUpdateDto public class LayoutCreateOrUpdateDto
{ {
[Required] [Required]
[DynamicStringLength(typeof(RouteConsts), nameof(RouteConsts.MaxNameLength))] [DynamicStringLength(typeof(RouteConsts), nameof(RouteConsts.MaxNameLength))]
public string Name { get; set; } public string Name { get; set; }
[Required] [Required]
[DynamicStringLength(typeof(RouteConsts), nameof(RouteConsts.MaxDisplayNameLength))] [DynamicStringLength(typeof(RouteConsts), nameof(RouteConsts.MaxDisplayNameLength))]
public string DisplayName { get; set; } public string DisplayName { get; set; }
[DynamicStringLength(typeof(RouteConsts), nameof(RouteConsts.MaxDescriptionLength))] [DynamicStringLength(typeof(RouteConsts), nameof(RouteConsts.MaxDescriptionLength))]
public string Description { get; set; } public string Description { get; set; }
[Required] [Required]
[DynamicStringLength(typeof(RouteConsts), nameof(RouteConsts.MaxPathLength))] [DynamicStringLength(typeof(RouteConsts), nameof(RouteConsts.MaxPathLength))]
public string Path { get; set; } public string Path { get; set; }
[DynamicStringLength(typeof(RouteConsts), nameof(RouteConsts.MaxRedirectLength))] [DynamicStringLength(typeof(RouteConsts), nameof(RouteConsts.MaxRedirectLength))]
public string Redirect { get; set; } public string Redirect { get; set; }
}
public PlatformType PlatformType { get; set; } }
}
}

34
aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Layouts/Dto/LayoutDto.cs

@ -1,17 +1,17 @@
using LINGYUN.Platform.Routes; using LINGYUN.Platform.Routes;
using System; using System;
namespace LINGYUN.Platform.Layouts namespace LINGYUN.Platform.Layouts
{ {
public class LayoutDto : RouteDto public class LayoutDto : RouteDto
{ {
/// <summary> /// <summary>
/// 所属平台 /// 框架
/// </summary> /// </summary>
public PlatformType PlatformType { get; set; } public string Framework { get; set; }
/// <summary> /// <summary>
/// 约定的Meta采用哪种数据字典,主要是约束路由必须字段的一致性 /// 约定的Meta采用哪种数据字典,主要是约束路由必须字段的一致性
/// </summary> /// </summary>
public Guid DataId { get; set; } public Guid DataId { get; set; }
} }
} }

18
aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/GetMenuInput.cs

@ -1,7 +1,11 @@
namespace LINGYUN.Platform.Menus using LINGYUN.Platform.Routes;
{ using Volo.Abp.Validation;
public class GetMenuInput
{ namespace LINGYUN.Platform.Menus
public PlatformType PlatformType { get; set; } {
} public class GetMenuInput
} {
[DynamicStringLength(typeof(LayoutConsts), nameof(LayoutConsts.MaxFrameworkLength))]
public string Framework { get; set; }
}
}

4
aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/MenuDto.cs

@ -15,9 +15,9 @@ namespace LINGYUN.Platform.Menus
/// </summary> /// </summary>
public string Component { get; set; } public string Component { get; set; }
/// <summary> /// <summary>
/// 所属平台 /// 框架
/// </summary> /// </summary>
public PlatformType PlatformType { get; set; } public string Framework { get; set; }
/// <summary> /// <summary>
/// 父节点 /// 父节点
/// </summary> /// </summary>

43
aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/MenuGetAllInput.cs

@ -1,20 +1,23 @@
using System; using LINGYUN.Platform.Routes;
using Volo.Abp.Application.Dtos; using System;
using Volo.Abp.Application.Dtos;
namespace LINGYUN.Platform.Menus using Volo.Abp.Validation;
{
public class MenuGetAllInput : ISortedResultRequest namespace LINGYUN.Platform.Menus
{ {
public PlatformType? PlatformType { get; set; } public class MenuGetAllInput : ISortedResultRequest
{
public string Filter { get; set; } [DynamicStringLength(typeof(LayoutConsts), nameof(LayoutConsts.MaxFrameworkLength))]
public string Framework { get; set; }
public bool Reverse { get; set; }
public string Filter { get; set; }
public Guid? ParentId { get; set; }
public bool Reverse { get; set; }
public string Sorting { get; set; }
public Guid? ParentId { get; set; }
public Guid? LayoutId { get; set; }
} public string Sorting { get; set; }
}
public Guid? LayoutId { get; set; }
}
}

29
aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/MenuGetByRoleInput.cs

@ -1,13 +1,16 @@
using System.ComponentModel.DataAnnotations; using LINGYUN.Platform.Routes;
using System.ComponentModel.DataAnnotations;
namespace LINGYUN.Platform.Menus using Volo.Abp.Validation;
{
public class MenuGetByRoleInput namespace LINGYUN.Platform.Menus
{ {
[Required] public class MenuGetByRoleInput
[StringLength(80)] {
public string Role { get; set; } [Required]
[StringLength(80)]
public PlatformType PlatformType { get; set; } public string Role { get; set; }
}
} [DynamicStringLength(typeof(LayoutConsts), nameof(LayoutConsts.MaxFrameworkLength))]
public string Framework { get; set; }
}
}

33
aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/MenuGetByUserInput.cs

@ -1,15 +1,18 @@
using System; using LINGYUN.Platform.Routes;
using System.ComponentModel.DataAnnotations; using System;
using System.ComponentModel.DataAnnotations;
namespace LINGYUN.Platform.Menus using Volo.Abp.Validation;
{
public class MenuGetByUserInput namespace LINGYUN.Platform.Menus
{ {
[Required] public class MenuGetByUserInput
public Guid UserId { get; set; } {
[Required]
public string[] Roles { get; set; } = new string[0]; public Guid UserId { get; set; }
public PlatformType PlatformType { get; set; } public string[] Roles { get; set; } = new string[0];
}
} [DynamicStringLength(typeof(LayoutConsts), nameof(LayoutConsts.MaxFrameworkLength))]
public string Framework { get; set; }
}
}

39
aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/MenuGetListInput.cs

@ -1,18 +1,21 @@
using System; using LINGYUN.Platform.Routes;
using Volo.Abp.Application.Dtos; using System;
using Volo.Abp.Application.Dtos;
namespace LINGYUN.Platform.Menus using Volo.Abp.Validation;
{
public class MenuGetListInput : PagedAndSortedResultRequestDto namespace LINGYUN.Platform.Menus
{ {
public PlatformType? PlatformType { get; set; } public class MenuGetListInput : PagedAndSortedResultRequestDto
{
public string Filter { get; set; } [DynamicStringLength(typeof(LayoutConsts), nameof(LayoutConsts.MaxFrameworkLength))]
public string Framework { get; set; }
public bool Reverse { get; set; }
public string Filter { get; set; }
public Guid? ParentId { get; set; }
public bool Reverse { get; set; }
public Guid? LayoutId { get; set; }
} public Guid? ParentId { get; set; }
}
public Guid? LayoutId { get; set; }
}
}

389
aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Datas/DataAppService.cs

@ -1,191 +1,198 @@
using LINGYUN.Platform.Permissions; using LINGYUN.Platform.Permissions;
using LINGYUN.Platform.Utils; using LINGYUN.Platform.Utils;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
namespace LINGYUN.Platform.Datas namespace LINGYUN.Platform.Datas
{ {
[Authorize(PlatformPermissions.DataDictionary.Default)] [Authorize(PlatformPermissions.DataDictionary.Default)]
public class DataAppService : PlatformApplicationServiceBase, IDataAppService public class DataAppService : PlatformApplicationServiceBase, IDataAppService
{ {
protected IDataRepository DataRepository { get; } protected IDataRepository DataRepository { get; }
public DataAppService( public DataAppService(
IDataRepository dataRepository) IDataRepository dataRepository)
{ {
DataRepository = dataRepository; DataRepository = dataRepository;
} }
[Authorize(PlatformPermissions.DataDictionary.Create)] [Authorize(PlatformPermissions.DataDictionary.Create)]
public virtual async Task<DataDto> CreateAsync(DataCreateDto input) public virtual async Task<DataDto> CreateAsync(DataCreateDto input)
{ {
var data = await DataRepository.FindByNameAsync(input.Name); var data = await DataRepository.FindByNameAsync(input.Name);
if (data != null) if (data != null)
{ {
throw new UserFriendlyException("指定名称的数据字典已经存在!"); throw new UserFriendlyException(L["DuplicateData", input.Name]);
} }
string code = string.Empty; string code = string.Empty;
var children = await DataRepository.GetChildrenAsync(input.ParentId); var children = await DataRepository.GetChildrenAsync(input.ParentId);
if (children.Any()) if (children.Any())
{ {
var lastChildren = children.OrderBy(x => x.Code).FirstOrDefault(); var lastChildren = children.OrderBy(x => x.Code).FirstOrDefault();
code = CodeNumberGenerator.CalculateNextCode(lastChildren.Code); code = CodeNumberGenerator.CalculateNextCode(lastChildren.Code);
} }
else else
{ {
var parentData = input.ParentId != null var parentData = input.ParentId != null
? await DataRepository.GetAsync(input.ParentId.Value) ? await DataRepository.GetAsync(input.ParentId.Value)
: null; : null;
code = CodeNumberGenerator.AppendCode(parentData?.Code, CodeNumberGenerator.CreateCode(1)); code = CodeNumberGenerator.AppendCode(parentData?.Code, CodeNumberGenerator.CreateCode(1));
} }
data = new Data( data = new Data(
GuidGenerator.Create(), GuidGenerator.Create(),
input.Name, input.Name,
code, code,
input.DisplayName, input.DisplayName,
input.Description, input.Description,
input.ParentId, input.ParentId,
CurrentTenant.Id CurrentTenant.Id
); );
data = await DataRepository.InsertAsync(data); data = await DataRepository.InsertAsync(data);
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map<Data, DataDto>(data); return ObjectMapper.Map<Data, DataDto>(data);
} }
[Authorize(PlatformPermissions.DataDictionary.Delete)] [Authorize(PlatformPermissions.DataDictionary.Delete)]
public virtual async Task DeleteAsync(Guid id) public virtual async Task DeleteAsync(Guid id)
{ {
var data = await DataRepository.GetAsync(id); var data = await DataRepository.GetAsync(id);
var children = await DataRepository.GetChildrenAsync(data.Id); var children = await DataRepository.GetChildrenAsync(data.Id);
if (children.Any()) if (children.Any())
{ {
throw new UserFriendlyException("当前数据字典存在子节点,无法删除!"); throw new UserFriendlyException(L["UnableRemoveHasChildNode"]);
} }
await DataRepository.DeleteAsync(data); await DataRepository.DeleteAsync(data);
} }
public virtual async Task<DataDto> GetAsync(Guid id) public virtual async Task<DataDto> GetAsync(string name)
{ {
var data = await DataRepository.GetAsync(id); var data = await DataRepository.FindByNameAsync(name);
return ObjectMapper.Map<Data, DataDto>(data); return ObjectMapper.Map<Data, DataDto>(data);
} }
public virtual async Task<ListResultDto<DataDto>> GetAllAsync() public virtual async Task<DataDto> GetAsync(Guid id)
{ {
var datas = await DataRepository.GetListAsync(includeDetails: false); var data = await DataRepository.GetAsync(id);
return new ListResultDto<DataDto>( return ObjectMapper.Map<Data, DataDto>(data);
ObjectMapper.Map<List<Data>, List<DataDto>>(datas)); }
}
public virtual async Task<ListResultDto<DataDto>> GetAllAsync()
public virtual async Task<PagedResultDto<DataDto>> GetListAsync(GetDataListInput input) {
{ var datas = await DataRepository.GetListAsync(includeDetails: false);
var count = await DataRepository.GetCountAsync(input.Filter);
return new ListResultDto<DataDto>(
var datas = await DataRepository.GetPagedListAsync( ObjectMapper.Map<List<Data>, List<DataDto>>(datas));
input.Filter, input.Sorting, }
false, input.SkipCount, input.MaxResultCount);
public virtual async Task<PagedResultDto<DataDto>> GetListAsync(GetDataListInput input)
return new PagedResultDto<DataDto>(count, {
ObjectMapper.Map<List<Data>, List<DataDto>>(datas)); var count = await DataRepository.GetCountAsync(input.Filter);
}
var datas = await DataRepository.GetPagedListAsync(
[Authorize(PlatformPermissions.DataDictionary.Update)] input.Filter, input.Sorting,
public virtual async Task<DataDto> UpdateAsync(Guid id, DataUpdateDto input) false, input.SkipCount, input.MaxResultCount);
{
var data = await DataRepository.GetAsync(id); return new PagedResultDto<DataDto>(count,
ObjectMapper.Map<List<Data>, List<DataDto>>(datas));
if (!string.Equals(data.Name, input.Name, StringComparison.InvariantCultureIgnoreCase)) }
{
data.Name = input.Name; [Authorize(PlatformPermissions.DataDictionary.Update)]
} public virtual async Task<DataDto> UpdateAsync(Guid id, DataUpdateDto input)
if (!string.Equals(data.DisplayName, input.DisplayName, StringComparison.InvariantCultureIgnoreCase)) {
{ var data = await DataRepository.GetAsync(id);
data.DisplayName = input.DisplayName;
} if (!string.Equals(data.Name, input.Name, StringComparison.InvariantCultureIgnoreCase))
if (!string.Equals(data.Description, input.Description, StringComparison.InvariantCultureIgnoreCase)) {
{ data.Name = input.Name;
data.Description = input.Description; }
} if (!string.Equals(data.DisplayName, input.DisplayName, StringComparison.InvariantCultureIgnoreCase))
{
data = await DataRepository.UpdateAsync(data); data.DisplayName = input.DisplayName;
await CurrentUnitOfWork.SaveChangesAsync(); }
if (!string.Equals(data.Description, input.Description, StringComparison.InvariantCultureIgnoreCase))
return ObjectMapper.Map<Data, DataDto>(data); {
} data.Description = input.Description;
}
[Authorize(PlatformPermissions.DataDictionary.ManageItems)]
public virtual async Task UpdateItemAsync(Guid id, string name, DataItemUpdateDto input) data = await DataRepository.UpdateAsync(data);
{ await CurrentUnitOfWork.SaveChangesAsync();
var data = await DataRepository.GetAsync(id);
var dataItem = data.FindItem(name); return ObjectMapper.Map<Data, DataDto>(data);
if (dataItem == null) }
{
throw new UserFriendlyException($"不存在名为 {name} 的数据字典项!"); [Authorize(PlatformPermissions.DataDictionary.ManageItems)]
} public virtual async Task UpdateItemAsync(Guid id, string name, DataItemUpdateDto input)
{
if (!string.Equals(dataItem.DefaultValue, input.DefaultValue, StringComparison.InvariantCultureIgnoreCase)) var data = await DataRepository.GetAsync(id);
{ var dataItem = data.FindItem(name);
dataItem.DefaultValue = input.DefaultValue; if (dataItem == null)
} {
if (!string.Equals(dataItem.DisplayName, input.DisplayName, StringComparison.InvariantCultureIgnoreCase)) throw new UserFriendlyException(L["DataItemNotFound", name]);
{ }
dataItem.DisplayName = input.DisplayName;
} if (!string.Equals(dataItem.DefaultValue, input.DefaultValue, StringComparison.InvariantCultureIgnoreCase))
if (!string.Equals(dataItem.Description, input.Description, StringComparison.InvariantCultureIgnoreCase)) {
{ dataItem.DefaultValue = input.DefaultValue;
dataItem.Description = input.Description; }
} if (!string.Equals(dataItem.DisplayName, input.DisplayName, StringComparison.InvariantCultureIgnoreCase))
dataItem.AllowBeNull = input.AllowBeNull; {
dataItem.DisplayName = input.DisplayName;
data = await DataRepository.UpdateAsync(data); }
await CurrentUnitOfWork.SaveChangesAsync(); if (!string.Equals(dataItem.Description, input.Description, StringComparison.InvariantCultureIgnoreCase))
} {
dataItem.Description = input.Description;
[Authorize(PlatformPermissions.DataDictionary.ManageItems)] }
public virtual async Task CreateItemAsync(Guid id, DataItemCreateDto input) dataItem.AllowBeNull = input.AllowBeNull;
{
var data = await DataRepository.GetAsync(id); await DataRepository.UpdateAsync(data);
var dataItem = data.FindItem(input.Name); await CurrentUnitOfWork.SaveChangesAsync();
if (dataItem != null) }
{
throw new UserFriendlyException($"已经存在名为 {input.Name} 的数据字典项!"); [Authorize(PlatformPermissions.DataDictionary.ManageItems)]
} public virtual async Task CreateItemAsync(Guid id, DataItemCreateDto input)
{
data.AddItem( var data = await DataRepository.GetAsync(id);
GuidGenerator, var dataItem = data.FindItem(input.Name);
input.Name, if (dataItem != null)
input.DisplayName, {
input.DefaultValue, throw new UserFriendlyException(L["DuplicateDataItem", input.Name]);
input.ValueType, }
input.Description,
input.AllowBeNull); data.AddItem(
GuidGenerator,
await DataRepository.UpdateAsync(data); input.Name,
await CurrentUnitOfWork.SaveChangesAsync(); input.DisplayName,
} input.DefaultValue,
input.ValueType,
[Authorize(PlatformPermissions.DataDictionary.ManageItems)] input.Description,
public virtual async Task DeleteItemAsync(Guid id, string name) input.AllowBeNull);
{
var data = await DataRepository.GetAsync(id); await DataRepository.UpdateAsync(data);
data.RemoveItem(name); await CurrentUnitOfWork.SaveChangesAsync();
}
await DataRepository.UpdateAsync(data);
await CurrentUnitOfWork.SaveChangesAsync(); [Authorize(PlatformPermissions.DataDictionary.ManageItems)]
} public virtual async Task DeleteItemAsync(Guid id, string name)
} {
} var data = await DataRepository.GetAsync(id);
data.RemoveItem(name);
await DataRepository.UpdateAsync(data);
await CurrentUnitOfWork.SaveChangesAsync();
}
}
}

245
aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Layouts/LayoutAppService.cs

@ -1,124 +1,121 @@
using LINGYUN.Platform.Datas; using LINGYUN.Platform.Permissions;
using LINGYUN.Platform.Permissions; using Microsoft.AspNetCore.Authorization;
using LINGYUN.Platform.Routes; using System;
using LINGYUN.Platform.Utils; using System.Collections.Generic;
using Microsoft.AspNetCore.Authorization; using System.Threading.Tasks;
using System; using Volo.Abp;
using System.Collections.Generic; using Volo.Abp.Application.Dtos;
using System.Threading.Tasks;
using Volo.Abp; namespace LINGYUN.Platform.Layouts
using Volo.Abp.Application.Dtos; {
[Authorize(PlatformPermissions.Layout.Default)]
namespace LINGYUN.Platform.Layouts public class LayoutAppService : PlatformApplicationServiceBase, ILayoutAppService
{ {
[Authorize(PlatformPermissions.Layout.Default)] protected ILayoutRepository LayoutRepository { get; }
public class LayoutAppService : PlatformApplicationServiceBase, ILayoutAppService
{ public LayoutAppService(
protected ILayoutRepository LayoutRepository { get; } ILayoutRepository layoutRepository)
{
public LayoutAppService( LayoutRepository = layoutRepository;
ILayoutRepository layoutRepository) }
{
LayoutRepository = layoutRepository; [Authorize(PlatformPermissions.Layout.Create)]
} public virtual async Task<LayoutDto> CreateAsync(LayoutCreateDto input)
{
[Authorize(PlatformPermissions.Layout.Create)] var layout = await LayoutRepository.FindByNameAsync(input.Name);
public virtual async Task<LayoutDto> CreateAsync(LayoutCreateDto input) if (layout != null)
{ {
var layout = await LayoutRepository.FindByNameAsync(input.Name); throw new UserFriendlyException(L["DuplicateLayout", input.Name]);
if (layout != null) }
{
throw new UserFriendlyException($"已经存在名为 {input.Name} 的布局!"); layout = new Layout(
} GuidGenerator.Create(),
input.Path,
layout = new Layout( input.Name,
GuidGenerator.Create(), input.DisplayName,
input.Path, input.DataId,
input.Name, input.Framework,
input.DisplayName, input.Redirect,
input.DataId, input.Description,
input.PlatformType, CurrentTenant.Id);
input.Redirect,
input.Description, layout = await LayoutRepository.InsertAsync(layout);
CurrentTenant.Id); await CurrentUnitOfWork.SaveChangesAsync();
layout = await LayoutRepository.InsertAsync(layout); return ObjectMapper.Map<Layout, LayoutDto>(layout);
await CurrentUnitOfWork.SaveChangesAsync(); }
return ObjectMapper.Map<Layout, LayoutDto>(layout); [Authorize(PlatformPermissions.Layout.Delete)]
} public virtual async Task DeleteAsync(Guid id)
{
[Authorize(PlatformPermissions.Layout.Delete)] var layout = await LayoutRepository.GetAsync(id);
public virtual async Task DeleteAsync(Guid id)
{ //if (await LayoutRepository.AnyMenuAsync(layout.Id))
var layout = await LayoutRepository.GetAsync(id); //{
// throw new UserFriendlyException($"不能删除存在菜单的布局!");
//if (await LayoutRepository.AnyMenuAsync(layout.Id)) //}
//{
// throw new UserFriendlyException($"不能删除存在菜单的布局!"); await LayoutRepository.DeleteAsync(layout);
//} await CurrentUnitOfWork.SaveChangesAsync();
}
await LayoutRepository.DeleteAsync(layout);
await CurrentUnitOfWork.SaveChangesAsync(); public virtual async Task<LayoutDto> GetAsync(Guid id)
} {
var layout = await LayoutRepository.GetAsync(id);
public virtual async Task<LayoutDto> GetAsync(Guid id)
{ return ObjectMapper.Map<Layout, LayoutDto>(layout);
var layout = await LayoutRepository.GetAsync(id); }
return ObjectMapper.Map<Layout, LayoutDto>(layout); public virtual async Task<ListResultDto<LayoutDto>> GetAllListAsync()
} {
var layouts = await LayoutRepository.GetListAsync();
public virtual async Task<ListResultDto<LayoutDto>> GetAllListAsync()
{ return new ListResultDto<LayoutDto>(
var layouts = await LayoutRepository.GetListAsync(); ObjectMapper.Map<List<Layout>, List<LayoutDto>>(layouts));
}
return new ListResultDto<LayoutDto>(
ObjectMapper.Map<List<Layout>, List<LayoutDto>>(layouts)); public virtual async Task<PagedResultDto<LayoutDto>> GetListAsync(GetLayoutListInput input)
} {
var count = await LayoutRepository.GetCountAsync(input.Framework, input.Filter);
public virtual async Task<PagedResultDto<LayoutDto>> GetListAsync(GetLayoutListInput input)
{ var layouts = await LayoutRepository.GetPagedListAsync(
var count = await LayoutRepository.GetCountAsync(input.PlatformType, input.Filter); input.Framework, input.Filter,
input.Sorting, input.Reverse, false,
var layouts = await LayoutRepository.GetPagedListAsync( input.SkipCount, input.MaxResultCount);
input.PlatformType, input.Filter,
input.Sorting, input.Reverse, false, return new PagedResultDto<LayoutDto>(count,
input.SkipCount, input.MaxResultCount); ObjectMapper.Map<List<Layout>, List<LayoutDto>>(layouts));
}
return new PagedResultDto<LayoutDto>(count,
ObjectMapper.Map<List<Layout>, List<LayoutDto>>(layouts)); [Authorize(PlatformPermissions.Layout.Update)]
} public virtual async Task<LayoutDto> UpdateAsync(Guid id, LayoutUpdateDto input)
{
[Authorize(PlatformPermissions.Layout.Update)] var layout = await LayoutRepository.GetAsync(id);
public virtual async Task<LayoutDto> UpdateAsync(Guid id, LayoutUpdateDto input)
{ if (!string.Equals(layout.Name, input.Name, StringComparison.InvariantCultureIgnoreCase))
var layout = await LayoutRepository.GetAsync(id); {
layout.Name = input.Name;
if (!string.Equals(layout.Name, input.Name, StringComparison.InvariantCultureIgnoreCase)) }
{ if (!string.Equals(layout.DisplayName, input.DisplayName, StringComparison.InvariantCultureIgnoreCase))
layout.Name = input.Name; {
} layout.DisplayName = input.DisplayName;
if (!string.Equals(layout.DisplayName, input.DisplayName, StringComparison.InvariantCultureIgnoreCase)) }
{ if (!string.Equals(layout.Description, input.Description, StringComparison.InvariantCultureIgnoreCase))
layout.DisplayName = input.DisplayName; {
} layout.Description = input.Description;
if (!string.Equals(layout.Description, input.Description, StringComparison.InvariantCultureIgnoreCase)) }
{ if (!string.Equals(layout.Path, input.Path, StringComparison.InvariantCultureIgnoreCase))
layout.Description = input.Description; {
} layout.Path = input.Path;
if (!string.Equals(layout.Path, input.Path, StringComparison.InvariantCultureIgnoreCase)) }
{ if (!string.Equals(layout.Redirect, input.Redirect, StringComparison.InvariantCultureIgnoreCase))
layout.Path = input.Path; {
} layout.Redirect = input.Redirect;
if (!string.Equals(layout.Redirect, input.Redirect, StringComparison.InvariantCultureIgnoreCase)) }
{ layout = await LayoutRepository.UpdateAsync(layout);
layout.Redirect = input.Redirect; await CurrentUnitOfWork.SaveChangesAsync();
}
layout = await LayoutRepository.UpdateAsync(layout); return ObjectMapper.Map<Layout, LayoutDto>(layout);
await CurrentUnitOfWork.SaveChangesAsync(); }
}
return ObjectMapper.Map<Layout, LayoutDto>(layout); }
}
}
}

479
aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/MenuAppService.cs

@ -1,240 +1,239 @@
using LINGYUN.Platform.Datas; using LINGYUN.Platform.Datas;
using LINGYUN.Platform.Layouts; using LINGYUN.Platform.Layouts;
using LINGYUN.Platform.Permissions; using LINGYUN.Platform.Permissions;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.Users; using Volo.Abp.Users;
namespace LINGYUN.Platform.Menus namespace LINGYUN.Platform.Menus
{ {
[Authorize] [Authorize]
public class MenuAppService : PlatformApplicationServiceBase, IMenuAppService public class MenuAppService : PlatformApplicationServiceBase, IMenuAppService
{ {
protected DataItemMappingOptions DataItemMapping { get; } protected DataItemMappingOptions DataItemMapping { get; }
protected MenuManager MenuManager { get; } protected MenuManager MenuManager { get; }
protected IMenuRepository MenuRepository { get; } protected IMenuRepository MenuRepository { get; }
protected IDataRepository DataRepository { get; } protected IDataRepository DataRepository { get; }
protected ILayoutRepository LayoutRepository { get; } protected ILayoutRepository LayoutRepository { get; }
public MenuAppService( public MenuAppService(
MenuManager menuManager, MenuManager menuManager,
IMenuRepository menuRepository, IMenuRepository menuRepository,
IDataRepository dataRepository, IDataRepository dataRepository,
ILayoutRepository layoutRepository, ILayoutRepository layoutRepository,
IOptions<DataItemMappingOptions> options) IOptions<DataItemMappingOptions> options)
{ {
MenuManager = menuManager; MenuManager = menuManager;
MenuRepository = menuRepository; MenuRepository = menuRepository;
DataRepository = dataRepository; DataRepository = dataRepository;
LayoutRepository = layoutRepository; LayoutRepository = layoutRepository;
DataItemMapping = options.Value; DataItemMapping = options.Value;
} }
public virtual async Task<ListResultDto<MenuDto>> GetCurrentUserMenuListAsync(GetMenuInput input) public virtual async Task<ListResultDto<MenuDto>> GetCurrentUserMenuListAsync(GetMenuInput input)
{ {
var myMenus = await MenuRepository.GetUserMenusAsync( var myMenus = await MenuRepository.GetUserMenusAsync(
CurrentUser.GetId(), CurrentUser.GetId(),
CurrentUser.Roles, CurrentUser.Roles,
input.PlatformType); input.Framework);
return new ListResultDto<MenuDto>( return new ListResultDto<MenuDto>(
ObjectMapper.Map<List<Menu>, List<MenuDto>>(myMenus)); ObjectMapper.Map<List<Menu>, List<MenuDto>>(myMenus));
} }
[Authorize(PlatformPermissions.Menu.Default)] [Authorize(PlatformPermissions.Menu.Default)]
public virtual async Task<MenuDto> GetAsync(Guid id) public virtual async Task<MenuDto> GetAsync(Guid id)
{ {
var menu = await MenuRepository.GetAsync(id); var menu = await MenuRepository.GetAsync(id);
return ObjectMapper.Map<Menu, MenuDto>(menu); return ObjectMapper.Map<Menu, MenuDto>(menu);
} }
[Authorize(PlatformPermissions.Menu.Default)] [Authorize(PlatformPermissions.Menu.Default)]
public virtual async Task<ListResultDto<MenuDto>> GetAllAsync(MenuGetAllInput input) public virtual async Task<ListResultDto<MenuDto>> GetAllAsync(MenuGetAllInput input)
{ {
var menus = await MenuRepository.GetAllAsync( var menus = await MenuRepository.GetAllAsync(
input.Filter, input.Sorting, input.Reverse, input.Filter, input.Sorting, input.Reverse,
input.PlatformType, input.ParentId, input.LayoutId); input.Framework, input.ParentId, input.LayoutId);
return new ListResultDto<MenuDto>( return new ListResultDto<MenuDto>(
ObjectMapper.Map<List<Menu>, List<MenuDto>>(menus)); ObjectMapper.Map<List<Menu>, List<MenuDto>>(menus));
} }
[Authorize(PlatformPermissions.Menu.Default)] [Authorize(PlatformPermissions.Menu.Default)]
public virtual async Task<PagedResultDto<MenuDto>> GetListAsync(MenuGetListInput input) public virtual async Task<PagedResultDto<MenuDto>> GetListAsync(MenuGetListInput input)
{ {
var count = await MenuRepository.GetCountAsync(input.Filter, input.PlatformType, input.ParentId, input.LayoutId); var count = await MenuRepository.GetCountAsync(input.Filter, input.Framework, input.ParentId, input.LayoutId);
var menus = await MenuRepository.GetListAsync( var menus = await MenuRepository.GetListAsync(
input.Filter, input.Sorting, input.Reverse, input.Filter, input.Sorting, input.Reverse,
input.PlatformType, input.ParentId, input.LayoutId, input.Framework, input.ParentId, input.LayoutId,
input.SkipCount, input.MaxResultCount); input.SkipCount, input.MaxResultCount);
return new PagedResultDto<MenuDto>(count, return new PagedResultDto<MenuDto>(count,
ObjectMapper.Map<List<Menu>, List<MenuDto>>(menus)); ObjectMapper.Map<List<Menu>, List<MenuDto>>(menus));
} }
[Authorize(PlatformPermissions.Menu.Create)] [Authorize(PlatformPermissions.Menu.Create)]
public virtual async Task<MenuDto> CreateAsync(MenuCreateDto input) public virtual async Task<MenuDto> CreateAsync(MenuCreateDto input)
{ {
var layout = await LayoutRepository.GetAsync(input.LayoutId); var layout = await LayoutRepository.GetAsync(input.LayoutId);
var data = await DataRepository.GetAsync(layout.DataId); var data = await DataRepository.GetAsync(layout.DataId);
var menu = await MenuManager.CreateAsync( var menu = await MenuManager.CreateAsync(
GuidGenerator.Create(), layout,
layout.Id, GuidGenerator.Create(),
input.Path, input.Path,
input.Name, input.Name,
input.Component, input.Component,
input.DisplayName, input.DisplayName,
input.Redirect, input.Redirect,
input.Description, input.Description,
layout.PlatformType, input.ParentId,
input.ParentId, CurrentTenant.Id,
CurrentTenant.Id, input.IsPublic);
input.IsPublic);
// 利用布局约定的数据字典来校验必须的路由元数据,元数据的加入是为了适配多端路由
// 利用布局约定的数据字典来校验必须的路由元数据,元数据的加入是为了适配多端路由 foreach (var dataItem in data.Items)
foreach (var dataItem in data.Items) {
{ if (!input.Meta.TryGetValue(dataItem.Name, out object meta))
if (!input.Meta.TryGetValue(dataItem.Name, out object meta)) {
{ if (!dataItem.AllowBeNull)
if (!dataItem.AllowBeNull) {
{ throw new BusinessException(PlatformErrorCodes.MenuMissingMetadata)
throw new BusinessException(PlatformErrorCodes.MenuMissingMetadata) .WithData("Name", dataItem.DisplayName)
.WithData("Name", dataItem.DisplayName) .WithData("DataName", data.DisplayName);
.WithData("DataName", data.DisplayName); }
} // 是否需要设定默认值
// 是否需要设定默认值 menu.SetProperty(dataItem.Name, dataItem.DefaultValue);
menu.SetProperty(dataItem.Name, dataItem.DefaultValue); }
} else
else {
{ // 需要检查参数是否有效
// 需要检查参数是否有效 menu.SetProperty(dataItem.Name, DataItemMapping.MapToString(dataItem.ValueType, meta));
menu.SetProperty(dataItem.Name, DataItemMapping.MapToString(dataItem.ValueType, meta)); }
} }
}
await CurrentUnitOfWork.SaveChangesAsync();
await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map<Menu, MenuDto>(menu);
return ObjectMapper.Map<Menu, MenuDto>(menu); }
}
[Authorize(PlatformPermissions.Menu.Update)]
[Authorize(PlatformPermissions.Menu.Update)] public virtual async Task<MenuDto> UpdateAsync(Guid id, MenuUpdateDto input)
public virtual async Task<MenuDto> UpdateAsync(Guid id, MenuUpdateDto input) {
{ var menu = await MenuRepository.GetAsync(id);
var menu = await MenuRepository.GetAsync(id);
// 利用布局约定的数据字典来校验必须的路由元数据,元数据的加入是为了适配多端路由
// 利用布局约定的数据字典来校验必须的路由元数据,元数据的加入是为了适配多端路由 var layout = await LayoutRepository.GetAsync(menu.LayoutId);
var layout = await LayoutRepository.GetAsync(menu.LayoutId); var data = await DataRepository.GetAsync(layout.DataId);
var data = await DataRepository.GetAsync(layout.DataId); foreach (var dataItem in data.Items)
foreach (var dataItem in data.Items) {
{ if (!input.Meta.TryGetValue(dataItem.Name, out object meta))
if (!input.Meta.TryGetValue(dataItem.Name, out object meta)) {
{ if (!dataItem.AllowBeNull)
if (!dataItem.AllowBeNull) {
{ throw new BusinessException(PlatformErrorCodes.MenuMissingMetadata)
throw new BusinessException(PlatformErrorCodes.MenuMissingMetadata) .WithData("Name", dataItem.DisplayName)
.WithData("Name", dataItem.DisplayName) .WithData("DataName", data.DisplayName);
.WithData("DataName", data.DisplayName); }
} // 是否需要设定默认值?
// 是否需要设定默认值? menu.SetProperty(dataItem.Name, dataItem.DefaultValue);
menu.SetProperty(dataItem.Name, dataItem.DefaultValue); }
} else
else {
{ // 与现有的数据做对比
// 与现有的数据做对比 var menuMeta = menu.GetProperty(dataItem.Name);
var menuMeta = menu.GetProperty(dataItem.Name); if (menuMeta != null && menuMeta.Equals(meta))
if (menuMeta != null && menuMeta.Equals(meta)) {
{ continue;
continue; }
} // 需要检查参数是否有效
// 需要检查参数是否有效 menu.SetProperty(dataItem.Name, DataItemMapping.MapToString(dataItem.ValueType, meta));
menu.SetProperty(dataItem.Name, DataItemMapping.MapToString(dataItem.ValueType, meta)); }
} }
}
if (!string.Equals(menu.Name, input.Name, StringComparison.InvariantCultureIgnoreCase))
if (!string.Equals(menu.Name, input.Name, StringComparison.InvariantCultureIgnoreCase)) {
{ menu.Name = input.Name;
menu.Name = input.Name; }
} if (!string.Equals(menu.DisplayName, input.DisplayName, StringComparison.InvariantCultureIgnoreCase))
if (!string.Equals(menu.DisplayName, input.DisplayName, StringComparison.InvariantCultureIgnoreCase)) {
{ menu.DisplayName = input.DisplayName;
menu.DisplayName = input.DisplayName; }
} if (!string.Equals(menu.Description, input.Description, StringComparison.InvariantCultureIgnoreCase))
if (!string.Equals(menu.Description, input.Description, StringComparison.InvariantCultureIgnoreCase)) {
{ menu.Description = input.Description;
menu.Description = input.Description; }
} if (!string.Equals(menu.Path, input.Path, StringComparison.InvariantCultureIgnoreCase))
if (!string.Equals(menu.Path, input.Path, StringComparison.InvariantCultureIgnoreCase)) {
{ menu.Path = input.Path;
menu.Path = input.Path; }
} if (!string.Equals(menu.Redirect, input.Redirect, StringComparison.InvariantCultureIgnoreCase))
if (!string.Equals(menu.Redirect, input.Redirect, StringComparison.InvariantCultureIgnoreCase)) {
{ menu.Redirect = input.Redirect;
menu.Redirect = input.Redirect; }
} if (!string.Equals(menu.Component, input.Component, StringComparison.InvariantCultureIgnoreCase))
if (!string.Equals(menu.Component, input.Component, StringComparison.InvariantCultureIgnoreCase)) {
{ menu.Component = input.Component;
menu.Component = input.Component; }
}
menu.IsPublic = input.IsPublic;
menu.IsPublic = input.IsPublic;
await MenuManager.UpdateAsync(menu);
await MenuManager.UpdateAsync(menu); await CurrentUnitOfWork.SaveChangesAsync();
await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map<Menu, MenuDto>(menu);
return ObjectMapper.Map<Menu, MenuDto>(menu); }
}
[Authorize(PlatformPermissions.Menu.Delete)]
[Authorize(PlatformPermissions.Menu.Delete)] public virtual async Task DeleteAsync(Guid id)
public virtual async Task DeleteAsync(Guid id) {
{ var childrens = await MenuRepository.GetChildrenAsync(id);
var childrens = await MenuRepository.GetChildrenAsync(id); if (childrens.Any())
if (childrens.Any()) {
{ throw new BusinessException(PlatformErrorCodes.DeleteMenuHaveChildren);
throw new BusinessException(PlatformErrorCodes.DeleteMenuHaveChildren); }
}
var menu = await MenuRepository.GetAsync(id);
var menu = await MenuRepository.GetAsync(id); await MenuRepository.DeleteAsync(menu);
await MenuRepository.DeleteAsync(menu); }
}
[Authorize(PlatformPermissions.Menu.ManageUsers)]
[Authorize(PlatformPermissions.Menu.ManageUsers)] public virtual async Task<ListResultDto<MenuDto>> GetUserMenuListAsync(MenuGetByUserInput input)
public virtual async Task<ListResultDto<MenuDto>> GetUserMenuListAsync(MenuGetByUserInput input) {
{ var menus = await MenuRepository.GetUserMenusAsync(input.UserId, input.Roles, input.Framework);
var menus = await MenuRepository.GetUserMenusAsync(input.UserId, input.Roles, input.PlatformType);
return new ListResultDto<MenuDto>(
return new ListResultDto<MenuDto>( ObjectMapper.Map<List<Menu>, List<MenuDto>>(menus));
ObjectMapper.Map<List<Menu>, List<MenuDto>>(menus)); }
}
[Authorize(PlatformPermissions.Menu.ManageUsers)]
[Authorize(PlatformPermissions.Menu.ManageUsers)] public virtual async Task SetUserMenusAsync(UserMenuInput input)
public virtual async Task SetUserMenusAsync(UserMenuInput input) {
{ await MenuManager.SetUserMenusAsync(input.UserId, input.MenuIds);
await MenuManager.SetUserMenusAsync(input.UserId, input.MenuIds); }
}
[Authorize(PlatformPermissions.Menu.ManageRoles)]
[Authorize(PlatformPermissions.Menu.ManageRoles)] public virtual async Task SetRoleMenusAsync(RoleMenuInput input)
public virtual async Task SetRoleMenusAsync(RoleMenuInput input) {
{ await MenuManager.SetRoleMenusAsync(input.RoleName, input.MenuIds);
await MenuManager.SetRoleMenusAsync(input.RoleName, input.MenuIds); }
}
[Authorize(PlatformPermissions.Menu.ManageRoles)]
[Authorize(PlatformPermissions.Menu.ManageRoles)] public virtual async Task<ListResultDto<MenuDto>> GetRoleMenuListAsync(MenuGetByRoleInput input)
public virtual async Task<ListResultDto<MenuDto>> GetRoleMenuListAsync(MenuGetByRoleInput input) {
{ var menus = await MenuRepository.GetRoleMenusAsync(new string[] { input.Role }, input.Framework);
var menus = await MenuRepository.GetRoleMenusAsync(new string[] { input.Role }, input.PlatformType);
return new ListResultDto<MenuDto>(
return new ListResultDto<MenuDto>( ObjectMapper.Map<List<Menu>, List<MenuDto>>(menus));
ObjectMapper.Map<List<Menu>, List<MenuDto>>(menus)); }
} }
} }
}

113
aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/en.json

@ -1,55 +1,60 @@
{ {
"culture": "en", "culture": "en",
"texts": { "texts": {
"Platform:01404": "File not found, name: {FileName}, version:{FileVersion}!", "Platform:01404": "File not found, name: {FileName}, version:{FileVersion}!",
"Platform:02001": "The same menu exists in the sibling directory: {Name}!", "Platform:02001": "The same menu exists in the sibling directory: {Name}!",
"Platform:02002": "You are not allowed to delete menu nodes when there are other submenus!", "Platform:02002": "You are not allowed to delete menu nodes when there are other submenus!",
"Platform:02003": "The menu level has reached the specified maximum: {Depth}!", "Platform:02003": "The menu level has reached the specified maximum: {Depth}!",
"Platform:02101": "The menu metadata is missing the necessary element :{Name}, which is defined in the data dictionary :{DataName}!", "Platform:02101": "The menu metadata is missing the necessary element :{Name}, which is defined in the data dictionary :{DataName}!",
"Platform:03001": "The metadata format does not match!", "Platform:03001": "The metadata format does not match!",
"UploadFileSizeBeyondLimit": "Upload file size cannot exceed {0} MB!", "UploadFileSizeBeyondLimit": "Upload file size cannot exceed {0} MB!",
"NotAllowedFileExtensionName": "Not allowed file extension: {0}!", "NotAllowedFileExtensionName": "Not allowed file extension: {0}!",
"DisplayName:VersionFileLimitLength": "File limit size", "DisplayName:VersionFileLimitLength": "File limit size",
"Description:VersionFileLimitLength": "Limit size of uploaded file in MB", "Description:VersionFileLimitLength": "Limit size of uploaded file in MB",
"DisplayName:AllowVersionFileExtensions": "File extension", "DisplayName:AllowVersionFileExtensions": "File extension",
"Description:AllowVersionFileExtensions": "List of allowed extensions to upload files, with multiple extensions separated by, don't need a notation", "Description:AllowVersionFileExtensions": "List of allowed extensions to upload files, with multiple extensions separated by, don't need a notation",
"DisplayName:Menus": "Menus", "DisplayName:Menus": "Menus",
"DisplayName:Name": "Name", "DisplayName:Name": "Name",
"DisplayName:Code": "Code", "DisplayName:Code": "Code",
"DisplayName:IsPublic": "Is Public", "DisplayName:IsPublic": "Is Public",
"DisplayName:DisplayName": "Display Name", "DisplayName:DisplayName": "Display Name",
"DisplayName:Description": "Description", "DisplayName:Description": "Description",
"DisplayName:AllowBeNull": "Allow Be Null", "DisplayName:AllowBeNull": "Allow Be Null",
"DisplayName:DefaultValue": "Default Value", "DisplayName:DefaultValue": "Default Value",
"DisplayName:ValueType": "Value Type", "DisplayName:ValueType": "Value Type",
"DisplayName:Path": "Path", "DisplayName:Path": "Path",
"DisplayName:Redirect": "Redirect", "DisplayName:Redirect": "Redirect",
"DisplayName:Meta": "Meta", "DisplayName:Meta": "Meta",
"DisplayName:Component": "Component", "DisplayName:Component": "Component",
"DisplayName:Filter": "Filter", "DisplayName:Filter": "Filter",
"DisplayName:PlatformType": "Platform Type", "DisplayName:PlatformType": "Platform Type",
"DisplayName:SecrchMenu": "Secrch Menu", "DisplayName:SecrchMenu": "Secrch Menu",
"DisplayName:SecrchLayout": "Secrch Layout", "DisplayName:SecrchLayout": "Secrch Layout",
"DisplayName:Layout": "Layout", "DisplayName:Layout": "Layout",
"DisplayName:Basic": "Basic", "DisplayName:Basic": "Basic",
"DisplayName:DataDictionary": "Data Dictionary", "DisplayName:DataDictionary": "Data Dictionary",
"Layout:AddNew": "Add New", "Layout:AddNew": "Add New",
"Layout:Edit": "Edit", "Layout:Edit": "Edit",
"Layout:EditByName": "Edit Layout - {0}", "Layout:EditByName": "Edit Layout - {0}",
"Layout:Delete": "Delete Layout", "Layout:Delete": "Delete Layout",
"Menu:AddNew": "Add New", "Menu:AddNew": "Add New",
"Menu:AddChildren": "Add Children", "Menu:AddChildren": "Add Children",
"Menu:Edit": "Edit", "Menu:Edit": "Edit",
"Menu:EditByName": "Edit Menu - {0}", "Menu:EditByName": "Edit Menu - {0}",
"Menu:Delete": "Delete Menu", "Menu:Delete": "Delete Menu",
"Menu:Manage": "Manage Menus", "Menu:Manage": "Manage Menus",
"Data:AddNew": "Add New", "Data:AddNew": "Add New",
"Data:AddChildren": "Add Children", "Data:AddChildren": "Add Children",
"Data:Edit": "Edit", "Data:Edit": "Edit",
"Data:Delete": "Delete Data", "Data:Delete": "Delete Data",
"Data:AppendItem": "Append Item", "Data:AppendItem": "Append Item",
"Data:EditItem": "Edit Item", "Data:EditItem": "Edit Item",
"Data:RemoveItem": "Remove Item", "Data:RemoveItem": "Remove Item",
"Data:Items": "Data Items" "Data:Items": "Data Items",
} "DuplicateData": "A data dictionary named {0} already exists!",
"DuplicateDataItem": "A data dictionary entry named {0} already exists!",
"DataItemNotFound": "There is no data dictionary entry named {0}!",
"UnableRemoveHasChildNode": "Current data dictionary exists child node, cannot delete!",
"DuplicateLayout": "A layout named {0} already exists!"
}
} }

113
aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/zh-Hans.json

@ -1,55 +1,60 @@
{ {
"culture": "zh-Hans", "culture": "zh-Hans",
"texts": { "texts": {
"Platform:01404": "文件: {FileName}, 版本号: {FileVersion} 不存在!", "Platform:01404": "文件: {FileName}, 版本号: {FileVersion} 不存在!",
"Platform:02001": "同级目录下存在相同的菜单: {Name}!", "Platform:02001": "同级目录下存在相同的菜单: {Name}!",
"Platform:02002": "在有其他子菜单的情况下,不允许删除菜单节点!", "Platform:02002": "在有其他子菜单的情况下,不允许删除菜单节点!",
"Platform:02003": "菜单层级已达到规定最大值: {Depth}!", "Platform:02003": "菜单层级已达到规定最大值: {Depth}!",
"Platform:02101": "菜单元数据缺少必要的元素: {Name},此选项在数据字典:{DataName} 中定义!", "Platform:02101": "菜单元数据缺少必要的元素: {Name},此选项在数据字典:{DataName} 中定义!",
"Platform:03001": "元数据格式不匹配!", "Platform:03001": "元数据格式不匹配!",
"UploadFileSizeBeyondLimit": "上传文件大小不能超过 {0} MB!", "UploadFileSizeBeyondLimit": "上传文件大小不能超过 {0} MB!",
"NotAllowedFileExtensionName": "不被允许的文件扩展名: {0}!", "NotAllowedFileExtensionName": "不被允许的文件扩展名: {0}!",
"DisplayName:VersionFileLimitLength": "文件限制大小", "DisplayName:VersionFileLimitLength": "文件限制大小",
"Description:VersionFileLimitLength": "上传文件的限制大小,单位(MB)", "Description:VersionFileLimitLength": "上传文件的限制大小,单位(MB)",
"DisplayName:AllowVersionFileExtensions": "文件扩展名", "DisplayName:AllowVersionFileExtensions": "文件扩展名",
"Description:AllowVersionFileExtensions": "允许的上传文件扩展名列表,多个扩展名以,分隔,无需输入.符号", "Description:AllowVersionFileExtensions": "允许的上传文件扩展名列表,多个扩展名以,分隔,无需输入.符号",
"DisplayName:Menus": "菜单列表", "DisplayName:Menus": "菜单列表",
"DisplayName:Name": "名称", "DisplayName:Name": "名称",
"DisplayName:Code": "编号", "DisplayName:Code": "编号",
"DisplayName:IsPublic": "是否公用的", "DisplayName:IsPublic": "是否公用的",
"DisplayName:DisplayName": "显示名称", "DisplayName:DisplayName": "显示名称",
"DisplayName:Description": "说明", "DisplayName:Description": "说明",
"DisplayName:AllowBeNull": "允许空值", "DisplayName:AllowBeNull": "允许空值",
"DisplayName:DefaultValue": "默认值", "DisplayName:DefaultValue": "默认值",
"DisplayName:ValueType": "值类型", "DisplayName:ValueType": "值类型",
"DisplayName:Path": "路径", "DisplayName:Path": "路径",
"DisplayName:Redirect": "重定向路径", "DisplayName:Redirect": "重定向路径",
"DisplayName:Meta": "元数据", "DisplayName:Meta": "元数据",
"DisplayName:Component": "组件", "DisplayName:Component": "组件",
"DisplayName:Filter": "筛选", "DisplayName:Filter": "筛选",
"DisplayName:PlatformType": "平台类型", "DisplayName:PlatformType": "平台类型",
"DisplayName:SecrchMenu": "查询菜单", "DisplayName:SecrchMenu": "查询菜单",
"DisplayName:SecrchLayout": "查询布局", "DisplayName:SecrchLayout": "查询布局",
"DisplayName:Layout": "布局", "DisplayName:Layout": "布局",
"DisplayName:Basic": "基础信息", "DisplayName:Basic": "基础信息",
"DisplayName:DataDictionary": "数据字典", "DisplayName:DataDictionary": "数据字典",
"Layout:AddNew": "添加新布局", "Layout:AddNew": "添加新布局",
"Layout:Edit": "编辑布局", "Layout:Edit": "编辑布局",
"Layout:EditByName": "编辑布局 - {0}", "Layout:EditByName": "编辑布局 - {0}",
"Layout:Delete": "删除布局", "Layout:Delete": "删除布局",
"Menu:AddNew": "添加新菜单", "Menu:AddNew": "添加新菜单",
"Menu:AddChildren": "添加子菜单", "Menu:AddChildren": "添加子菜单",
"Menu:Edit": "编辑菜单", "Menu:Edit": "编辑菜单",
"Menu:EditByName": "编辑菜单 - {0}", "Menu:EditByName": "编辑菜单 - {0}",
"Menu:Delete": "删除菜单", "Menu:Delete": "删除菜单",
"Menu:Manage": "管理菜单", "Menu:Manage": "管理菜单",
"Data:AddNew": "添加新字典", "Data:AddNew": "添加新字典",
"Data:AddChildren": "添加下级字典", "Data:AddChildren": "添加下级字典",
"Data:Edit": "编辑字典", "Data:Edit": "编辑字典",
"Data:Delete": "删除字典", "Data:Delete": "删除字典",
"Data:AppendItem": "添加项目", "Data:AppendItem": "添加项目",
"Data:EditItem": "编辑项目", "Data:EditItem": "编辑项目",
"Data:RemoveItem": "删除项目", "Data:RemoveItem": "删除项目",
"Data:Items": "字典项目" "Data:Items": "字典项目",
} "DuplicateData": "已经存在名为 {0} 的数据字典!",
"DuplicateDataItem": "已经存在名为 {0} 的数据字典项!",
"DataItemNotFound": "不存在名为 {0} 的数据字典项!",
"UnableRemoveHasChildNode": "当前数据字典存在子节点,无法删除!",
"DuplicateLayout": "已经存在名为 {0} 的布局!"
}
} }

7
aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/LayoutConsts.cs

@ -0,0 +1,7 @@
namespace LINGYUN.Platform.Routes
{
public static class LayoutConsts
{
public static int MaxFrameworkLength { get; set; } = 64;
}
}

248
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/Data.cs

@ -1,121 +1,127 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Guids; using Volo.Abp.Guids;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
namespace LINGYUN.Platform.Datas namespace LINGYUN.Platform.Datas
{ {
/// <summary> /// <summary>
/// 数据字典 /// 数据字典
/// </summary> /// </summary>
public class Data : FullAuditedAggregateRoot<Guid>, IMultiTenant public class Data : FullAuditedAggregateRoot<Guid>, IMultiTenant
{ {
public virtual Guid? TenantId { get; protected set; } public virtual Guid? TenantId { get; protected set; }
public virtual string Name { get; set; } public virtual string Name { get; set; }
public virtual string Code { get; set; } public virtual string Code { get; set; }
public virtual string DisplayName { get; set; } public virtual string DisplayName { get; set; }
public virtual string Description { get; set; } public virtual string Description { get; set; }
public virtual Guid? ParentId { get; set; } public virtual Guid? ParentId { get; set; }
public virtual ICollection<DataItem> Items { get; protected set; } public virtual bool IsStatic { get; set; }
protected Data() public virtual ICollection<DataItem> Items { get; protected set; }
{
Items = new Collection<DataItem>(); protected Data()
} {
Items = new Collection<DataItem>();
public Data( }
[NotNull] Guid id,
[NotNull] string name, public Data(
[NotNull] string code, [NotNull] Guid id,
[NotNull] string displayName, [NotNull] string name,
string description = "", [NotNull] string code,
Guid? parentId = null, [NotNull] string displayName,
Guid? tenantId = null) string description = "",
{ Guid? parentId = null,
Check.NotNull(id, nameof(id)); Guid? tenantId = null)
Check.NotNullOrWhiteSpace(name, nameof(name)); {
Check.NotNullOrWhiteSpace(code, nameof(code)); Check.NotNull(id, nameof(id));
Check.NotNullOrWhiteSpace(displayName, nameof(displayName)); Check.NotNullOrWhiteSpace(name, nameof(name));
Check.NotNullOrWhiteSpace(code, nameof(code));
Id = id; Check.NotNullOrWhiteSpace(displayName, nameof(displayName));
Name = name;
Code = code; Id = id;
DisplayName = displayName; Name = name;
Description = description; Code = code;
ParentId = parentId; DisplayName = displayName;
TenantId = tenantId; Description = description;
ParentId = parentId;
CreationTime = DateTime.Now; TenantId = tenantId;
Items = new Collection<DataItem>(); CreationTime = DateTime.Now;
}
Items = new Collection<DataItem>();
public Data AddItem( }
[NotNull] IGuidGenerator guidGenerator,
[NotNull] string name, public Data AddItem(
[NotNull] string displayName, [NotNull] IGuidGenerator guidGenerator,
[CanBeNull] string defaultValue, [NotNull] string name,
ValueType valueType = ValueType.String, [NotNull] string displayName,
string description = "", [CanBeNull] string defaultValue,
bool allowBeNull = true) ValueType valueType = ValueType.String,
{ string description = "",
Check.NotNull(guidGenerator, nameof(guidGenerator)); bool allowBeNull = true,
Check.NotNull(name, nameof(name)); bool isStatic = false)
Check.NotNull(displayName, nameof(displayName)); {
Check.NotNull(guidGenerator, nameof(guidGenerator));
if (!IsInItem(name)) Check.NotNull(name, nameof(name));
{ Check.NotNull(displayName, nameof(displayName));
var dataItem = new DataItem(
guidGenerator.Create(), if (!IsInItem(name))
Id, {
name, var dataItem = new DataItem(
displayName, guidGenerator.Create(),
defaultValue, Id,
valueType, name,
description, displayName,
allowBeNull, defaultValue,
TenantId valueType,
); description,
Items.Add(dataItem); allowBeNull,
} TenantId
)
return this; {
} IsStatic = isStatic
};
public DataItem FindItem(string name) Items.Add(dataItem);
{ }
return Items.FirstOrDefault(item => item.Name == name);
} return this;
}
public DataItem FindItem(Guid id)
{ public DataItem FindItem(string name)
return Items.FirstOrDefault(item => item.Id == id); {
} return Items.FirstOrDefault(item => item.Name == name);
}
public bool RemoveItem(string name)
{ public DataItem FindItem(Guid id)
if (IsInItem(name)) {
{ return Items.FirstOrDefault(item => item.Id == id);
Items.RemoveAll(item => item.Name == name); }
return true;
} public bool RemoveItem(string name)
return false; {
} if (IsInItem(name))
{
public bool IsInItem(string name) Items.RemoveAll(item => item.Name == name);
{ return true;
return Items.Any(item => item.Name == name); }
} return false;
} }
}
public bool IsInItem(string name)
{
return Items.Any(item => item.Name == name);
}
}
}

118
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/DataDictionaryDataSeeder.cs

@ -1,57 +1,61 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids; using Volo.Abp.Guids;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
namespace LINGYUN.Platform.Datas namespace LINGYUN.Platform.Datas
{ {
public class DataDictionaryDataSeeder : IDataDictionaryDataSeeder, ITransientDependency public class DataDictionaryDataSeeder : IDataDictionaryDataSeeder, ITransientDependency
{ {
protected ICurrentTenant CurrentTenant { get; } protected ICurrentTenant CurrentTenant { get; }
protected IGuidGenerator GuidGenerator { get; } protected IGuidGenerator GuidGenerator { get; }
protected IDataRepository DataRepository { get; } protected IDataRepository DataRepository { get; }
public DataDictionaryDataSeeder( public DataDictionaryDataSeeder(
ICurrentTenant currentTenant, ICurrentTenant currentTenant,
IGuidGenerator guidGenerator, IGuidGenerator guidGenerator,
IDataRepository dataRepository) IDataRepository dataRepository)
{ {
CurrentTenant = currentTenant; CurrentTenant = currentTenant;
GuidGenerator = guidGenerator; GuidGenerator = guidGenerator;
DataRepository = dataRepository; DataRepository = dataRepository;
} }
public virtual async Task<Data> SeedAsync( public virtual async Task<Data> SeedAsync(
string name, string name,
string code, string code,
string displayName, string displayName,
string description = "", string description = "",
Guid? parentId = null, Guid? parentId = null,
Guid? tenantId = null, Guid? tenantId = null,
CancellationToken cancellationToken = default) bool isStatic = false,
{ CancellationToken cancellationToken = default)
using (CurrentTenant.Change(tenantId)) {
{ using (CurrentTenant.Change(tenantId))
var data = await DataRepository.FindByNameAsync(name, cancellationToken: cancellationToken); {
var data = await DataRepository.FindByNameAsync(name, cancellationToken: cancellationToken);
if (data == null)
{ if (data == null)
data = new Data( {
GuidGenerator.Create(), data = new Data(
name, GuidGenerator.Create(),
code, name,
displayName, code,
description, displayName,
parentId, description,
tenantId); parentId,
tenantId)
data = await DataRepository.InsertAsync(data); {
} IsStatic = isStatic
};
return data;
} data = await DataRepository.InsertAsync(data, true);
} }
}
} return data;
}
}
}
}

187
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/DataItem.cs

@ -1,93 +1,94 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using System; using System;
using System.Collections.Generic; using Volo.Abp;
using Volo.Abp; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.MultiTenancy;
using Volo.Abp.MultiTenancy;
namespace LINGYUN.Platform.Datas
namespace LINGYUN.Platform.Datas {
{ public class DataItem : FullAuditedAggregateRoot<Guid>, IMultiTenant
public class DataItem : FullAuditedAggregateRoot<Guid>, IMultiTenant {
{ public virtual Guid? TenantId { get; protected set; }
public virtual Guid? TenantId { get; protected set; }
public virtual string Name { get; protected set; }
public virtual string Name { get; protected set; }
public virtual string DisplayName { get; set; }
public virtual string DisplayName { get; set; }
public virtual string DefaultValue { get; set; }
public virtual string DefaultValue { get; set; }
public virtual string Description { get; set; }
public virtual string Description { get; set; }
public virtual bool AllowBeNull { get; set; }
public virtual bool AllowBeNull { get; set; }
public virtual bool IsStatic { get; set; }
public virtual ValueType ValueType { get; protected set; }
public virtual ValueType ValueType { get; protected set; }
public virtual Guid DataId { get; protected set; }
public virtual Guid DataId { get; protected set; }
protected DataItem() { }
protected DataItem() { }
public DataItem(
[NotNull] Guid id, internal DataItem(
[NotNull] Guid dataId, [NotNull] Guid id,
[NotNull] string name, [NotNull] Guid dataId,
[NotNull] string displayName, [NotNull] string name,
[CanBeNull] string defaultValue = null, [NotNull] string displayName,
ValueType valueType = ValueType.String, [CanBeNull] string defaultValue = null,
string description = "", ValueType valueType = ValueType.String,
bool allowBeNull = true, string description = "",
Guid? tenantId = null) bool allowBeNull = true,
{ Guid? tenantId = null)
Check.NotNull(id, nameof(id)); {
Check.NotNull(dataId, nameof(dataId)); Check.NotNull(id, nameof(id));
Check.NotNullOrWhiteSpace(name, nameof(name)); Check.NotNull(dataId, nameof(dataId));
Check.NotNullOrWhiteSpace(displayName, nameof(displayName)); Check.NotNullOrWhiteSpace(name, nameof(name));
Check.NotNullOrWhiteSpace(displayName, nameof(displayName));
Id = id;
Name = name; Id = id;
DefaultValue = defaultValue ?? SetDefaultValue(); Name = name;
ValueType = valueType; DefaultValue = defaultValue ?? SetDefaultValue();
DisplayName = displayName; ValueType = valueType;
AllowBeNull = allowBeNull; DisplayName = displayName;
AllowBeNull = allowBeNull;
DataId = dataId;
TenantId = tenantId; DataId = dataId;
Description = description; TenantId = tenantId;
} Description = description;
}
public string SetDefaultValue()
{ public string SetDefaultValue()
switch (ValueType) {
{ switch (ValueType)
case ValueType.Array: {
DefaultValue = "";// 当数据类型为数组对象时,需要前端来做转换了,约定的分隔符为英文逗号 case ValueType.Array:
break; DefaultValue = "";// 当数据类型为数组对象时,需要前端来做转换了,约定的分隔符为英文逗号
case ValueType.Boolean: break;
DefaultValue = "false"; case ValueType.Boolean:
break; DefaultValue = "false";
case ValueType.Date: break;
DefaultValue = !AllowBeNull ? DateTime.Now.ToString("yyyy-MM-dd") : ""; case ValueType.Date:
break; DefaultValue = !AllowBeNull ? DateTime.Now.ToString("yyyy-MM-dd") : "";
case ValueType.DateTime: break;
if (!AllowBeNull) case ValueType.DateTime:
{ if (!AllowBeNull)
DefaultValue = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // TODO: 以当前时间作为默认值? {
} DefaultValue = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // TODO: 以当前时间作为默认值?
DefaultValue = !AllowBeNull ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : ""; }
break; DefaultValue = !AllowBeNull ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : "";
case ValueType.Numeic: break;
DefaultValue = "0"; case ValueType.Numeic:
break; DefaultValue = "0";
case ValueType.Object: break;
DefaultValue = "{}"; case ValueType.Object:
break; DefaultValue = "{}";
default: break;
case ValueType.String: default:
DefaultValue = ""; case ValueType.String:
break; DefaultValue = "";
} break;
}
return DefaultValue;
} return DefaultValue;
} }
} }
}

37
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/IDataDictionaryDataSeeder.cs

@ -1,18 +1,19 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace LINGYUN.Platform.Datas namespace LINGYUN.Platform.Datas
{ {
public interface IDataDictionaryDataSeeder public interface IDataDictionaryDataSeeder
{ {
Task<Data> SeedAsync( Task<Data> SeedAsync(
string name, string name,
string code, string code,
string displayName, string displayName,
string description = "", string description = "",
Guid? parentId = null, Guid? parentId = null,
Guid? tenantId = null, Guid? tenantId = null,
CancellationToken cancellationToken = default); bool isStatic = false,
} CancellationToken cancellationToken = default);
} }
}

76
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Layouts/ILayoutRepository.cs

@ -1,38 +1,38 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
namespace LINGYUN.Platform.Layouts namespace LINGYUN.Platform.Layouts
{ {
public interface ILayoutRepository : IBasicRepository<Layout, Guid> public interface ILayoutRepository : IBasicRepository<Layout, Guid>
{ {
/// <summary> /// <summary>
/// 根据名称查询布局 /// 根据名称查询布局
/// </summary> /// </summary>
/// <param name="name"></param> /// <param name="name"></param>
/// <param name="includeDetails"></param> /// <param name="includeDetails"></param>
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
Task<Layout> FindByNameAsync( Task<Layout> FindByNameAsync(
string name, string name,
bool includeDetails = true, bool includeDetails = true,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<int> GetCountAsync( Task<int> GetCountAsync(
PlatformType? platformType = null, string framework = "",
string filter = "", string filter = "",
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<List<Layout>> GetPagedListAsync( Task<List<Layout>> GetPagedListAsync(
PlatformType? platformType = null, string framework = "",
string filter = "", string filter = "",
string sorting = nameof(Layout.Name), string sorting = nameof(Layout.Name),
bool reverse = false, bool reverse = false,
bool includeDetails = false, bool includeDetails = false,
int skipCount = 0, int skipCount = 0,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
} }
} }

78
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Layouts/Layout.cs

@ -1,39 +1,39 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using LINGYUN.Platform.Routes; using LINGYUN.Platform.Routes;
using System; using System;
namespace LINGYUN.Platform.Layouts namespace LINGYUN.Platform.Layouts
{ {
/// <summary> /// <summary>
/// 布局视图实体 /// 布局视图实体
/// </summary> /// </summary>
public class Layout : Route public class Layout : Route
{ {
/// <summary> /// <summary>
/// 所属平台 /// 框架
/// </summary> /// </summary>
public virtual PlatformType PlatformType { get; protected set; } public virtual string Framework { get; protected set; }
/// <summary> /// <summary>
/// 约定的Meta采用哪种数据字典,主要是约束路由必须字段的一致性 /// 约定的Meta采用哪种数据字典,主要是约束路由必须字段的一致性
/// </summary> /// </summary>
public virtual Guid DataId { get; protected set; } public virtual Guid DataId { get; protected set; }
protected Layout() { } protected Layout() { }
public Layout( public Layout(
[NotNull] Guid id, [NotNull] Guid id,
[NotNull] string path, [NotNull] string path,
[NotNull] string name, [NotNull] string name,
[NotNull] string displayName, [NotNull] string displayName,
[NotNull] Guid dataId, [NotNull] Guid dataId,
[NotNull] PlatformType platformType = PlatformType.None, [NotNull] string framework,
[CanBeNull] string redirect = "", [CanBeNull] string redirect = "",
[CanBeNull] string description = "", [CanBeNull] string description = "",
[CanBeNull] Guid? tenantId = null) [CanBeNull] Guid? tenantId = null)
: base(id, path, name, displayName, redirect, description, tenantId) : base(id, path, name, displayName, redirect, description, tenantId)
{ {
DataId = dataId; DataId = dataId;
PlatformType = platformType; Framework = framework;
} }
} }
} }

226
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IMenuRepository.cs

@ -1,113 +1,113 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
namespace LINGYUN.Platform.Menus namespace LINGYUN.Platform.Menus
{ {
public interface IMenuRepository : IBasicRepository<Menu, Guid> public interface IMenuRepository : IBasicRepository<Menu, Guid>
{ {
/// <summary> /// <summary>
/// 根据名称查询菜单 /// 根据名称查询菜单
/// </summary> /// </summary>
/// <param name="menuName"></param> /// <param name="menuName"></param>
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
Task<Menu> FindByNameAsync( Task<Menu> FindByNameAsync(
string menuName, string menuName,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// 查询主菜单,每一个布局页创建的时候都要创建路径为 / 的主菜单 /// 查询主菜单,每一个布局页创建的时候都要创建路径为 / 的主菜单
/// </summary> /// </summary>
/// <param name="platformType"></param> /// <param name="platformType"></param>
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
Task<Menu> FindMainAsync( Task<Menu> FindMainAsync(
PlatformType platformType = PlatformType.None, string framework = "",
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// 获取子节点 /// 获取子节点
/// </summary> /// </summary>
/// <param name="parentId"></param> /// <param name="parentId"></param>
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
Task<List<Menu>> GetChildrenAsync( Task<List<Menu>> GetChildrenAsync(
Guid? parentId, Guid? parentId,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
); );
/// <summary> /// <summary>
/// 通过父菜单编码查询子菜单 /// 通过父菜单编码查询子菜单
/// </summary> /// </summary>
/// <param name="code"></param> /// <param name="code"></param>
/// <param name="parentId"></param> /// <param name="parentId"></param>
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
Task<List<Menu>> GetAllChildrenWithParentCodeAsync( Task<List<Menu>> GetAllChildrenWithParentCodeAsync(
string code, string code,
Guid? parentId, Guid? parentId,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
); );
/// <summary> /// <summary>
/// 查找用户可访问菜单 /// 查找用户可访问菜单
/// </summary> /// </summary>
/// <param name="userId">用户标识</param> /// <param name="userId">用户标识</param>
/// <param name="roles">角色列表</param> /// <param name="roles">角色列表</param>
/// <param name="platformType">平台类型</param> /// <param name="platformType">平台类型</param>
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
Task<List<Menu>> GetUserMenusAsync( Task<List<Menu>> GetUserMenusAsync(
Guid userId, Guid userId,
string[] roles, string[] roles,
PlatformType platformType = PlatformType.None, string framework = "",
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// 查找角色可访问菜单 /// 查找角色可访问菜单
/// </summary> /// </summary>
/// <param name="roles">角色列表</param> /// <param name="roles">角色列表</param>
/// <param name="platformType">平台类型</param> /// <param name="platformType">平台类型</param>
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
Task<List<Menu>> GetRoleMenusAsync( Task<List<Menu>> GetRoleMenusAsync(
string[] roles, string[] roles,
PlatformType platformType = PlatformType.None, string framework = "",
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<int> GetCountAsync( Task<int> GetCountAsync(
string filter = "", string filter = "",
PlatformType? platformType = null, string framework = "",
Guid? parentId = null, Guid? parentId = null,
Guid? layoutId = null, Guid? layoutId = null,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<List<Menu>> GetListAsync( Task<List<Menu>> GetListAsync(
string filter = "", string filter = "",
string sorting = nameof(Menu.Code), string sorting = nameof(Menu.Code),
bool reverse = false, bool reverse = false,
PlatformType? platformType = null, string framework = "",
Guid? parentId = null, Guid? parentId = null,
Guid? layoutId = null, Guid? layoutId = null,
int skipCount = 0, int skipCount = 0,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<List<Menu>> GetAllAsync( Task<List<Menu>> GetAllAsync(
string filter = "", string filter = "",
string sorting = nameof(Menu.Code), string sorting = nameof(Menu.Code),
bool reverse = false, bool reverse = false,
PlatformType? platformType = null, string framework = "",
Guid? parentId = null, Guid? parentId = null,
Guid? layoutId = null, Guid? layoutId = null,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task RemoveAllRolesAsync( Task RemoveAllRolesAsync(
Menu menu, Menu menu,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
); );
Task RemoveAllMembersAsync( Task RemoveAllMembersAsync(
Menu menu, Menu menu,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
); );
} }
} }

134
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/Menu.cs

@ -1,67 +1,67 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using LINGYUN.Platform.Routes; using LINGYUN.Platform.Routes;
using System; using System;
using Volo.Abp; using Volo.Abp;
namespace LINGYUN.Platform.Menus namespace LINGYUN.Platform.Menus
{ {
/// <summary> /// <summary>
/// 菜单 /// 菜单
/// </summary> /// </summary>
public class Menu : Route public class Menu : Route
{ {
/// <summary> /// <summary>
/// 所属平台 /// 框架
/// </summary> /// </summary>
public virtual PlatformType PlatformType { get; set; } public virtual string Framework { get; set; }
/// <summary> /// <summary>
/// 菜单编号 /// 菜单编号
/// </summary> /// </summary>
public virtual string Code { get; set; } public virtual string Code { get; set; }
/// <summary> /// <summary>
/// 菜单布局页,Layout的路径 /// 菜单布局页,Layout的路径
/// </summary> /// </summary>
public virtual string Component { get; set; } public virtual string Component { get; set; }
/// <summary> /// <summary>
/// 所属的父菜单 /// 所属的父菜单
/// </summary> /// </summary>
public virtual Guid? ParentId { get; set; } public virtual Guid? ParentId { get; set; }
/// <summary> /// <summary>
/// 所属布局标识 /// 所属布局标识
/// </summary> /// </summary>
public virtual Guid LayoutId { get; set; } public virtual Guid LayoutId { get; set; }
/// <summary> /// <summary>
/// 公共菜单 /// 公共菜单
/// </summary> /// </summary>
public virtual bool IsPublic { get; set; } public virtual bool IsPublic { get; set; }
protected Menu() protected Menu()
{ {
} }
public Menu( public Menu(
[NotNull] Guid id, [NotNull] Guid id,
[NotNull] Guid layoutId, [NotNull] Guid layoutId,
[NotNull] string path, [NotNull] string path,
[NotNull] string name, [NotNull] string name,
[NotNull] string code, [NotNull] string code,
[NotNull] string component, [NotNull] string component,
[NotNull] string displayName, [NotNull] string displayName,
string redirect = "", [NotNull] string framework,
string description = "", string redirect = "",
PlatformType platformType = PlatformType.None, string description = "",
Guid? parentId = null, Guid? parentId = null,
Guid? tenantId = null) Guid? tenantId = null)
: base(id, path, name, displayName, redirect, description, tenantId) : base(id, path, name, displayName, redirect, description, tenantId)
{ {
Check.NotNullOrWhiteSpace(code, nameof(code)); Check.NotNullOrWhiteSpace(code, nameof(code));
LayoutId = layoutId; LayoutId = layoutId;
Code = code; Code = code;
Component = component;// 下属的一级菜单的Component应该是布局页, 例如vue-admin中的 component: Layout, 其他前端框架雷同, 此处应传递布局页的路径让前端import Component = component;// 下属的一级菜单的Component应该是布局页, 例如vue-admin中的 component: Layout, 其他前端框架雷同, 此处应传递布局页的路径让前端import
PlatformType = platformType; Framework = framework;
ParentId = parentId; ParentId = parentId;
IsPublic = false; IsPublic = false;
} }
} }
} }

482
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/MenuManager.cs

@ -1,241 +1,241 @@
using LINGYUN.Platform.Utils; using LINGYUN.Platform.Layouts;
using System; using LINGYUN.Platform.Utils;
using System.Collections.Generic; using System;
using System.Linq; using System.Collections.Generic;
using System.Threading.Tasks; using System.Linq;
using Volo.Abp; using System.Threading.Tasks;
using Volo.Abp.Domain.Services; using Volo.Abp;
using Volo.Abp.Uow; using Volo.Abp.Domain.Services;
using Volo.Abp.Uow;
namespace LINGYUN.Platform.Menus
{ namespace LINGYUN.Platform.Menus
public class MenuManager : DomainService {
{ public class MenuManager : DomainService
protected IUnitOfWorkManager UnitOfWorkManager => LazyServiceProvider.LazyGetRequiredService<IUnitOfWorkManager>(); {
protected IUnitOfWorkManager UnitOfWorkManager => LazyServiceProvider.LazyGetRequiredService<IUnitOfWorkManager>();
protected IMenuRepository MenuRepository { get; }
protected IUserMenuRepository UserMenuRepository { get; } protected IMenuRepository MenuRepository { get; }
protected IRoleMenuRepository RoleMenuRepository { get; } protected IUserMenuRepository UserMenuRepository { get; }
protected IRoleMenuRepository RoleMenuRepository { get; }
public MenuManager(
IMenuRepository menuRepository, public MenuManager(
IUserMenuRepository userMenuRepository, IMenuRepository menuRepository,
IRoleMenuRepository roleMenuRepository) IUserMenuRepository userMenuRepository,
{ IRoleMenuRepository roleMenuRepository)
MenuRepository = menuRepository; {
UserMenuRepository = userMenuRepository; MenuRepository = menuRepository;
RoleMenuRepository = roleMenuRepository; UserMenuRepository = userMenuRepository;
} RoleMenuRepository = roleMenuRepository;
}
[UnitOfWork]
public virtual async Task<Menu> CreateAsync( [UnitOfWork]
Guid id, public virtual async Task<Menu> CreateAsync(
Guid layoutId, Layout layout,
string path, Guid id,
string name, string path,
string component, string name,
string displayName, string component,
string redirect = "", string displayName,
string description = "", string redirect = "",
PlatformType platformType = PlatformType.None, string description = "",
Guid? parentId = null, Guid? parentId = null,
Guid? tenantId = null, Guid? tenantId = null,
bool isPublic = false) bool isPublic = false)
{ {
var code = await GetNextChildCodeAsync(parentId); var code = await GetNextChildCodeAsync(parentId);
if (code.Length > MenuConsts.MaxCodeLength) if (code.Length > MenuConsts.MaxCodeLength)
{ {
throw new BusinessException(PlatformErrorCodes.MenuAchieveMaxDepth) throw new BusinessException(PlatformErrorCodes.MenuAchieveMaxDepth)
.WithData("Depth", MenuConsts.MaxDepth); .WithData("Depth", MenuConsts.MaxDepth);
} }
var menu = new Menu( var menu = new Menu(
id, id,
layoutId, layout.Id,
path, path,
name, name,
code, code,
component, component,
displayName, displayName,
redirect, layout.Framework,
description, redirect,
platformType, description,
parentId, parentId,
tenantId) tenantId)
{ {
IsPublic = isPublic IsPublic = isPublic
}; };
await ValidateMenuAsync(menu); await ValidateMenuAsync(menu);
await MenuRepository.InsertAsync(menu); await MenuRepository.InsertAsync(menu);
return menu; return menu;
} }
[UnitOfWork] [UnitOfWork]
public virtual async Task UpdateAsync(Menu menu) public virtual async Task UpdateAsync(Menu menu)
{ {
await ValidateMenuAsync(menu); await ValidateMenuAsync(menu);
await MenuRepository.UpdateAsync(menu); await MenuRepository.UpdateAsync(menu);
} }
[UnitOfWork] [UnitOfWork]
public virtual async Task DeleteAsync(Guid id) public virtual async Task DeleteAsync(Guid id)
{ {
var children = await FindChildrenAsync(id, true); var children = await FindChildrenAsync(id, true);
foreach (var child in children) foreach (var child in children)
{ {
await MenuRepository.RemoveAllMembersAsync(child); await MenuRepository.RemoveAllMembersAsync(child);
await MenuRepository.RemoveAllRolesAsync(child); await MenuRepository.RemoveAllRolesAsync(child);
await MenuRepository.DeleteAsync(child); await MenuRepository.DeleteAsync(child);
} }
var menu = await MenuRepository.GetAsync(id); var menu = await MenuRepository.GetAsync(id);
await MenuRepository.RemoveAllMembersAsync(menu); await MenuRepository.RemoveAllMembersAsync(menu);
await MenuRepository.RemoveAllRolesAsync(menu); await MenuRepository.RemoveAllRolesAsync(menu);
await MenuRepository.DeleteAsync(id); await MenuRepository.DeleteAsync(id);
} }
[UnitOfWork] [UnitOfWork]
public virtual async Task MoveAsync(Guid id, Guid? parentId) public virtual async Task MoveAsync(Guid id, Guid? parentId)
{ {
var menu = await MenuRepository.GetAsync(id); var menu = await MenuRepository.GetAsync(id);
if (menu.ParentId == parentId) if (menu.ParentId == parentId)
{ {
return; return;
} }
var children = await FindChildrenAsync(id, true); var children = await FindChildrenAsync(id, true);
var oldCode = menu.Code; var oldCode = menu.Code;
menu.Code = await GetNextChildCodeAsync(parentId); menu.Code = await GetNextChildCodeAsync(parentId);
menu.ParentId = parentId; menu.ParentId = parentId;
await ValidateMenuAsync(menu); await ValidateMenuAsync(menu);
foreach (var child in children) foreach (var child in children)
{ {
child.Code = CodeNumberGenerator.AppendCode(menu.Code, CodeNumberGenerator.GetRelativeCode(child.Code, oldCode)); child.Code = CodeNumberGenerator.AppendCode(menu.Code, CodeNumberGenerator.GetRelativeCode(child.Code, oldCode));
} }
} }
public virtual async Task<bool> UserHasInMenuAsync(Guid userId, string menuName) public virtual async Task<bool> UserHasInMenuAsync(Guid userId, string menuName)
{ {
var menu = await MenuRepository.FindByNameAsync(menuName); var menu = await MenuRepository.FindByNameAsync(menuName);
return false; return false;
} }
public virtual async Task SetUserMenusAsync(Guid userId, IEnumerable<Guid> menuIds) public virtual async Task SetUserMenusAsync(Guid userId, IEnumerable<Guid> menuIds)
{ {
using (var unitOfWork = UnitOfWorkManager.Begin()) using (var unitOfWork = UnitOfWorkManager.Begin())
{ {
var userMenus = await UserMenuRepository.GetListByUserIdAsync(userId); var userMenus = await UserMenuRepository.GetListByUserIdAsync(userId);
// 移除不存在的菜单 // 移除不存在的菜单
// TODO: 升级框架版本解决未能删除不需要菜单的问题 // TODO: 升级框架版本解决未能删除不需要菜单的问题
// userMenus.RemoveAll(x => !menuIds.Contains(x.MenuId)); // userMenus.RemoveAll(x => !menuIds.Contains(x.MenuId));
var dels = userMenus.Where(x => !menuIds.Contains(x.MenuId)); var dels = userMenus.Where(x => !menuIds.Contains(x.MenuId));
if (dels.Any()) if (dels.Any())
{ {
await UserMenuRepository.DeleteManyAsync(dels); await UserMenuRepository.DeleteManyAsync(dels);
} }
var adds = menuIds.Where(menuId => !userMenus.Any(x => x.MenuId == menuId)); var adds = menuIds.Where(menuId => !userMenus.Any(x => x.MenuId == menuId));
if (adds.Any()) if (adds.Any())
{ {
var addInMenus = adds.Select(menuId => new UserMenu(GuidGenerator.Create(), menuId, userId, CurrentTenant.Id)); var addInMenus = adds.Select(menuId => new UserMenu(GuidGenerator.Create(), menuId, userId, CurrentTenant.Id));
await UserMenuRepository.InsertAsync(addInMenus); await UserMenuRepository.InsertAsync(addInMenus);
} }
await unitOfWork.SaveChangesAsync(); await unitOfWork.SaveChangesAsync();
} }
} }
public virtual async Task SetRoleMenusAsync(string roleName, IEnumerable<Guid> menuIds) public virtual async Task SetRoleMenusAsync(string roleName, IEnumerable<Guid> menuIds)
{ {
using (var unitOfWork = UnitOfWorkManager.Begin()) using (var unitOfWork = UnitOfWorkManager.Begin())
{ {
var roleMenus = await RoleMenuRepository.GetListByRoleNameAsync(roleName); var roleMenus = await RoleMenuRepository.GetListByRoleNameAsync(roleName);
// 移除不存在的菜单 // 移除不存在的菜单
// TODO: 升级框架版本解决未能删除不需要菜单的问题 // TODO: 升级框架版本解决未能删除不需要菜单的问题
// roleMenus.RemoveAll(x => !menuIds.Contains(x.MenuId)); // roleMenus.RemoveAll(x => !menuIds.Contains(x.MenuId));
var dels = roleMenus.Where(x => !menuIds.Contains(x.MenuId)); var dels = roleMenus.Where(x => !menuIds.Contains(x.MenuId));
if (dels.Any()) if (dels.Any())
{ {
await RoleMenuRepository.DeleteManyAsync(dels); await RoleMenuRepository.DeleteManyAsync(dels);
} }
var adds = menuIds.Where(menuId => !roleMenus.Any(x => x.MenuId == menuId)); var adds = menuIds.Where(menuId => !roleMenus.Any(x => x.MenuId == menuId));
if (adds.Any()) if (adds.Any())
{ {
var addInMenus = adds.Select(menuId => new RoleMenu(GuidGenerator.Create(), menuId, roleName, CurrentTenant.Id)); var addInMenus = adds.Select(menuId => new RoleMenu(GuidGenerator.Create(), menuId, roleName, CurrentTenant.Id));
await RoleMenuRepository.InsertAsync(addInMenus); await RoleMenuRepository.InsertAsync(addInMenus);
} }
await unitOfWork.SaveChangesAsync(); await unitOfWork.SaveChangesAsync();
} }
} }
public virtual async Task<string> GetNextChildCodeAsync(Guid? parentId) public virtual async Task<string> GetNextChildCodeAsync(Guid? parentId)
{ {
var lastChild = await GetLastChildOrNullAsync(parentId); var lastChild = await GetLastChildOrNullAsync(parentId);
if (lastChild != null) if (lastChild != null)
{ {
return CodeNumberGenerator.CalculateNextCode(lastChild.Code); return CodeNumberGenerator.CalculateNextCode(lastChild.Code);
} }
var parentCode = parentId != null var parentCode = parentId != null
? await GetCodeOrDefaultAsync(parentId.Value) ? await GetCodeOrDefaultAsync(parentId.Value)
: null; : null;
return CodeNumberGenerator.AppendCode( return CodeNumberGenerator.AppendCode(
parentCode, parentCode,
CodeNumberGenerator.CreateCode(1) CodeNumberGenerator.CreateCode(1)
); );
} }
public virtual async Task<Menu> GetLastChildOrNullAsync(Guid? parentId) public virtual async Task<Menu> GetLastChildOrNullAsync(Guid? parentId)
{ {
var children = await MenuRepository.GetChildrenAsync(parentId); var children = await MenuRepository.GetChildrenAsync(parentId);
return children.OrderBy(c => c.Code).LastOrDefault(); return children.OrderBy(c => c.Code).LastOrDefault();
} }
public async Task<List<Menu>> FindChildrenAsync(Guid? parentId, bool recursive = false) public async Task<List<Menu>> FindChildrenAsync(Guid? parentId, bool recursive = false)
{ {
if (!recursive) if (!recursive)
{ {
return await MenuRepository.GetChildrenAsync(parentId); return await MenuRepository.GetChildrenAsync(parentId);
} }
if (!parentId.HasValue) if (!parentId.HasValue)
{ {
return await MenuRepository.GetListAsync(includeDetails: true); return await MenuRepository.GetListAsync(includeDetails: true);
} }
var code = await GetCodeOrDefaultAsync(parentId.Value); var code = await GetCodeOrDefaultAsync(parentId.Value);
return await MenuRepository.GetAllChildrenWithParentCodeAsync(code, parentId); return await MenuRepository.GetAllChildrenWithParentCodeAsync(code, parentId);
} }
public virtual async Task<string> GetCodeOrDefaultAsync(Guid id) public virtual async Task<string> GetCodeOrDefaultAsync(Guid id)
{ {
var menu = await MenuRepository.GetAsync(id); var menu = await MenuRepository.GetAsync(id);
return menu?.Code; return menu?.Code;
} }
protected virtual async Task ValidateMenuAsync(Menu menu) protected virtual async Task ValidateMenuAsync(Menu menu)
{ {
var siblings = (await FindChildrenAsync(menu.ParentId)) var siblings = (await FindChildrenAsync(menu.ParentId))
.Where(x => x.Id != menu.Id) .Where(x => x.Id != menu.Id)
.ToList(); .ToList();
if (siblings.Any(x => x.Name == menu.Name)) if (siblings.Any(x => x.Name == menu.Name))
{ {
throw new BusinessException(PlatformErrorCodes.DuplicateMenu) throw new BusinessException(PlatformErrorCodes.DuplicateMenu)
.WithData("Name", menu.Name); .WithData("Name", menu.Name);
} }
} }
} }
} }

100
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/IRouteDataSeeder.cs

@ -1,50 +1,50 @@
using LINGYUN.Platform.Layouts; using LINGYUN.Platform.Layouts;
using LINGYUN.Platform.Menus; using LINGYUN.Platform.Menus;
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace LINGYUN.Platform.Routes namespace LINGYUN.Platform.Routes
{ {
public interface IRouteDataSeeder public interface IRouteDataSeeder
{ {
Task<Layout> SeedLayoutAsync( Task<Layout> SeedLayoutAsync(
string name, string name,
string path, string path,
string displayName, string displayName,
Guid dataId, Guid dataId,
PlatformType platformType = PlatformType.None, string framework,
string redirect = "", string redirect = "",
string description = "", string description = "",
Guid? tenantId = null, Guid? tenantId = null,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<Menu> SeedMenuAsync( Task<Menu> SeedMenuAsync(
Layout layout, Layout layout,
string name, string name,
string path, string path,
string code, string code,
string component, string component,
string displayName, string displayName,
string redirect = "", string redirect = "",
string description = "", string description = "",
Guid? parentId = null, Guid? parentId = null,
Guid? tenantId = null, Guid? tenantId = null,
bool isPublic = false, bool isPublic = false,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task SeedUserMenuAsync( Task SeedUserMenuAsync(
Guid userId, Guid userId,
Menu menu, Menu menu,
Guid? tenantId = null, Guid? tenantId = null,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
); );
Task SeedRoleMenuAsync( Task SeedRoleMenuAsync(
string roleName, string roleName,
Menu menu, Menu menu,
Guid? tenantId = null, Guid? tenantId = null,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
); );
} }
} }

300
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/RouteDataSeeder.cs

@ -1,150 +1,150 @@
using LINGYUN.Platform.Layouts; using LINGYUN.Platform.Layouts;
using LINGYUN.Platform.Menus; using LINGYUN.Platform.Menus;
using System; using System;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids; using Volo.Abp.Guids;
namespace LINGYUN.Platform.Routes namespace LINGYUN.Platform.Routes
{ {
public class RouteDataSeeder : IRouteDataSeeder, ITransientDependency public class RouteDataSeeder : IRouteDataSeeder, ITransientDependency
{ {
protected IGuidGenerator GuidGenerator { get; } protected IGuidGenerator GuidGenerator { get; }
protected ILayoutRepository LayoutRepository { get; } protected ILayoutRepository LayoutRepository { get; }
protected IMenuRepository MenuRepository { get; } protected IMenuRepository MenuRepository { get; }
protected IUserMenuRepository UserMenuRepository { get; } protected IUserMenuRepository UserMenuRepository { get; }
protected IRoleMenuRepository RoleMenuRepository { get; } protected IRoleMenuRepository RoleMenuRepository { get; }
public RouteDataSeeder( public RouteDataSeeder(
IGuidGenerator guidGenerator, IGuidGenerator guidGenerator,
IMenuRepository menuRepository, IMenuRepository menuRepository,
ILayoutRepository layoutRepository, ILayoutRepository layoutRepository,
IUserMenuRepository userMenuRepository, IUserMenuRepository userMenuRepository,
IRoleMenuRepository roleMenuRepository) IRoleMenuRepository roleMenuRepository)
{ {
GuidGenerator = guidGenerator; GuidGenerator = guidGenerator;
MenuRepository = menuRepository; MenuRepository = menuRepository;
LayoutRepository = layoutRepository; LayoutRepository = layoutRepository;
UserMenuRepository = userMenuRepository; UserMenuRepository = userMenuRepository;
RoleMenuRepository = roleMenuRepository; RoleMenuRepository = roleMenuRepository;
} }
public virtual async Task<Layout> SeedLayoutAsync( public virtual async Task<Layout> SeedLayoutAsync(
string name, string name,
string path, string path,
string displayName, string displayName,
Guid dataId, Guid dataId,
PlatformType platformType = PlatformType.None, string framework,
string redirect = "", string redirect = "",
string description = "", string description = "",
Guid? tenantId = null, Guid? tenantId = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var layout = await LayoutRepository.FindByNameAsync(name, cancellationToken: cancellationToken); var layout = await LayoutRepository.FindByNameAsync(name, cancellationToken: cancellationToken);
if (layout == null) if (layout == null)
{ {
layout = new Layout( layout = new Layout(
GuidGenerator.Create(), GuidGenerator.Create(),
path, path,
name, name,
displayName, displayName,
dataId, dataId,
platformType, framework,
redirect, redirect,
description, description,
tenantId); tenantId);
layout = await LayoutRepository.InsertAsync(layout, cancellationToken: cancellationToken); layout = await LayoutRepository.InsertAsync(layout, cancellationToken: cancellationToken);
} }
return layout; return layout;
} }
public virtual async Task<Menu> SeedMenuAsync( public virtual async Task<Menu> SeedMenuAsync(
Layout layout, Layout layout,
string name, string name,
string path, string path,
string code, string code,
string component, string component,
string displayName, string displayName,
string redirect = "", string redirect = "",
string description = "", string description = "",
Guid? parentId = null, Guid? parentId = null,
Guid? tenantId = null, Guid? tenantId = null,
bool isPublic = false, bool isPublic = false,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
if (parentId.HasValue) if (parentId.HasValue)
{ {
var children = await MenuRepository.GetChildrenAsync(parentId); var children = await MenuRepository.GetChildrenAsync(parentId);
var childMenu = children.FirstOrDefault(x => x.Name == name); var childMenu = children.FirstOrDefault(x => x.Name == name);
if (childMenu != null) if (childMenu != null)
{ {
return childMenu; return childMenu;
} }
} }
var menu = await MenuRepository.FindByNameAsync(name, cancellationToken: cancellationToken); var menu = await MenuRepository.FindByNameAsync(name, cancellationToken: cancellationToken);
if (menu == null) if (menu == null)
{ {
menu = new Menu( menu = new Menu(
GuidGenerator.Create(), GuidGenerator.Create(),
layout.Id, layout.Id,
path, path,
name, name,
code, code,
component, component,
displayName, displayName,
redirect, layout.Framework,
description, redirect,
layout.PlatformType, description,
parentId, parentId,
tenantId) tenantId)
{ {
IsPublic = isPublic IsPublic = isPublic
}; };
menu = await MenuRepository.InsertAsync(menu, cancellationToken: cancellationToken); menu = await MenuRepository.InsertAsync(menu, cancellationToken: cancellationToken);
} }
return menu; return menu;
} }
public virtual async Task SeedRoleMenuAsync( public virtual async Task SeedRoleMenuAsync(
string roleName, string roleName,
Menu menu, Menu menu,
Guid? tenantId = null, Guid? tenantId = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
if (! await RoleMenuRepository.RoleHasInMenuAsync(roleName, menu.Name, cancellationToken)) if (! await RoleMenuRepository.RoleHasInMenuAsync(roleName, menu.Name, cancellationToken))
{ {
var roleMenu = new RoleMenu(GuidGenerator.Create(), menu.Id, roleName, tenantId); var roleMenu = new RoleMenu(GuidGenerator.Create(), menu.Id, roleName, tenantId);
await RoleMenuRepository.InsertAsync(roleMenu); await RoleMenuRepository.InsertAsync(roleMenu);
var childrens = await MenuRepository.GetChildrenAsync(menu.Id); var childrens = await MenuRepository.GetChildrenAsync(menu.Id);
foreach (var children in childrens) foreach (var children in childrens)
{ {
await SeedRoleMenuAsync(roleName, children, tenantId, cancellationToken); await SeedRoleMenuAsync(roleName, children, tenantId, cancellationToken);
} }
} }
} }
public virtual async Task SeedUserMenuAsync( public virtual async Task SeedUserMenuAsync(
Guid userId, Guid userId,
Menu menu, Menu menu,
Guid? tenantId = null, Guid? tenantId = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
if (!await UserMenuRepository.UserHasInMenuAsync(userId, menu.Name, cancellationToken)) if (!await UserMenuRepository.UserHasInMenuAsync(userId, menu.Name, cancellationToken))
{ {
var userMenu = new UserMenu(GuidGenerator.Create(), menu.Id, userId, tenantId); var userMenu = new UserMenu(GuidGenerator.Create(), menu.Id, userId, tenantId);
await UserMenuRepository.InsertAsync(userMenu); await UserMenuRepository.InsertAsync(userMenu);
var childrens = await MenuRepository.GetChildrenAsync(menu.Id); var childrens = await MenuRepository.GetChildrenAsync(menu.Id);
foreach (var children in childrens) foreach (var children in childrens)
{ {
await SeedUserMenuAsync(userId, children, tenantId, cancellationToken); await SeedUserMenuAsync(userId, children, tenantId, cancellationToken);
} }
} }
} }
} }
} }

507
aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs

@ -1,249 +1,258 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using LINGYUN.Platform.Datas; using LINGYUN.Platform.Datas;
using LINGYUN.Platform.Layouts; using LINGYUN.Platform.Layouts;
using LINGYUN.Platform.Menus; using LINGYUN.Platform.Menus;
using LINGYUN.Platform.Routes; using LINGYUN.Platform.Routes;
using LINGYUN.Platform.Versions; using LINGYUN.Platform.Versions;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System; using System;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling; using Volo.Abp.EntityFrameworkCore.Modeling;
namespace LINGYUN.Platform.EntityFrameworkCore namespace LINGYUN.Platform.EntityFrameworkCore
{ {
public static class PlatformDbContextModelBuilderExtensions public static class PlatformDbContextModelBuilderExtensions
{ {
public static void ConfigurePlatform( public static void ConfigurePlatform(
this ModelBuilder builder, this ModelBuilder builder,
Action<PlatformModelBuilderConfigurationOptions> optionsAction = null) Action<PlatformModelBuilderConfigurationOptions> optionsAction = null)
{ {
Check.NotNull(builder, nameof(builder)); Check.NotNull(builder, nameof(builder));
var options = new PlatformModelBuilderConfigurationOptions( var options = new PlatformModelBuilderConfigurationOptions(
PlatformDbProperties.DbTablePrefix, PlatformDbProperties.DbTablePrefix,
PlatformDbProperties.DbSchema PlatformDbProperties.DbSchema
); );
optionsAction?.Invoke(options); optionsAction?.Invoke(options);
builder.Entity<Layout>(b => builder.Entity<Layout>(b =>
{ {
b.ToTable(options.TablePrefix + "Layouts", options.Schema); b.ToTable(options.TablePrefix + "Layouts", options.Schema);
b.ConfigureRoute(); b.Property(p => p.Framework)
}); .HasMaxLength(LayoutConsts.MaxFrameworkLength)
.HasColumnName(nameof(Layout.Framework))
builder.Entity<Menu>(b => .IsRequired();
{
b.ToTable(options.TablePrefix + "Menus", options.Schema); b.ConfigureRoute();
});
b.ConfigureRoute();
builder.Entity<Menu>(b =>
b.Property(p => p.Component) {
.HasMaxLength(MenuConsts.MaxComponentLength) b.ToTable(options.TablePrefix + "Menus", options.Schema);
.HasColumnName(nameof(Menu.Component))
.IsRequired(); b.ConfigureRoute();
b.Property(p => p.Code)
.HasMaxLength(MenuConsts.MaxCodeLength) b.Property(p => p.Framework)
.HasColumnName(nameof(Menu.Code)) .HasMaxLength(LayoutConsts.MaxFrameworkLength)
.IsRequired(); .HasColumnName(nameof(Menu.Framework))
}); .IsRequired();
b.Property(p => p.Component)
builder.Entity<RoleMenu>(x => .HasMaxLength(MenuConsts.MaxComponentLength)
{ .HasColumnName(nameof(Menu.Component))
x.ToTable(options.TablePrefix + "RoleMenus"); .IsRequired();
b.Property(p => p.Code)
x.Property(p => p.RoleName) .HasMaxLength(MenuConsts.MaxCodeLength)
.IsRequired() .HasColumnName(nameof(Menu.Code))
.HasMaxLength(RoleRouteConsts.MaxRoleNameLength) .IsRequired();
.HasColumnName(nameof(RoleMenu.RoleName)); });
x.ConfigureByConvention(); builder.Entity<RoleMenu>(x =>
{
x.HasIndex(i => new { i.RoleName, i.MenuId }); x.ToTable(options.TablePrefix + "RoleMenus");
});
x.Property(p => p.RoleName)
builder.Entity<UserMenu>(x => .IsRequired()
{ .HasMaxLength(RoleRouteConsts.MaxRoleNameLength)
x.ToTable(options.TablePrefix + "UserMenus"); .HasColumnName(nameof(RoleMenu.RoleName));
x.ConfigureByConvention(); x.ConfigureByConvention();
x.HasIndex(i => new { i.UserId, i.MenuId }); x.HasIndex(i => new { i.RoleName, i.MenuId });
}); });
builder.Entity<Data>(x => builder.Entity<UserMenu>(x =>
{ {
x.ToTable(options.TablePrefix + "Datas"); x.ToTable(options.TablePrefix + "UserMenus");
x.Property(p => p.Code) x.ConfigureByConvention();
.HasMaxLength(DataConsts.MaxCodeLength)
.HasColumnName(nameof(Data.Code)) x.HasIndex(i => new { i.UserId, i.MenuId });
.IsRequired(); });
x.Property(p => p.Name)
.HasMaxLength(DataConsts.MaxNameLength) builder.Entity<Data>(x =>
.HasColumnName(nameof(Data.Name)) {
.IsRequired(); x.ToTable(options.TablePrefix + "Datas");
x.Property(p => p.DisplayName)
.HasMaxLength(DataConsts.MaxDisplayNameLength) x.Property(p => p.Code)
.HasColumnName(nameof(Data.DisplayName)) .HasMaxLength(DataConsts.MaxCodeLength)
.IsRequired(); .HasColumnName(nameof(Data.Code))
x.Property(p => p.Description) .IsRequired();
.HasMaxLength(DataConsts.MaxDescriptionLength) x.Property(p => p.Name)
.HasColumnName(nameof(Data.Description)); .HasMaxLength(DataConsts.MaxNameLength)
.HasColumnName(nameof(Data.Name))
x.ConfigureByConvention(); .IsRequired();
x.Property(p => p.DisplayName)
x.HasMany(p => p.Items) .HasMaxLength(DataConsts.MaxDisplayNameLength)
.WithOne() .HasColumnName(nameof(Data.DisplayName))
.HasForeignKey(fk => fk.DataId) .IsRequired();
.IsRequired(); x.Property(p => p.Description)
.HasMaxLength(DataConsts.MaxDescriptionLength)
x.HasIndex(i => new { i.Name }); .HasColumnName(nameof(Data.Description));
});
x.ConfigureByConvention();
builder.Entity<DataItem>(x =>
{ x.HasMany(p => p.Items)
x.ToTable(options.TablePrefix + "DataItems"); .WithOne()
.HasForeignKey(fk => fk.DataId)
x.Property(p => p.DefaultValue) .IsRequired();
.HasMaxLength(DataItemConsts.MaxValueLength)
.HasColumnName(nameof(DataItem.DefaultValue)); x.HasIndex(i => new { i.Name });
x.Property(p => p.Name) });
.HasMaxLength(DataItemConsts.MaxNameLength)
.HasColumnName(nameof(DataItem.Name)) builder.Entity<DataItem>(x =>
.IsRequired(); {
x.Property(p => p.DisplayName) x.ToTable(options.TablePrefix + "DataItems");
.HasMaxLength(DataItemConsts.MaxDisplayNameLength)
.HasColumnName(nameof(DataItem.DisplayName)) x.Property(p => p.DefaultValue)
.IsRequired(); .HasMaxLength(DataItemConsts.MaxValueLength)
x.Property(p => p.Description) .HasColumnName(nameof(DataItem.DefaultValue));
.HasMaxLength(DataItemConsts.MaxDescriptionLength) x.Property(p => p.Name)
.HasColumnName(nameof(DataItem.Description)); .HasMaxLength(DataItemConsts.MaxNameLength)
.HasColumnName(nameof(DataItem.Name))
x.Property(p => p.AllowBeNull).HasDefaultValue(true); .IsRequired();
x.Property(p => p.DisplayName)
x.ConfigureByConvention(); .HasMaxLength(DataItemConsts.MaxDisplayNameLength)
.HasColumnName(nameof(DataItem.DisplayName))
x.HasIndex(i => new { i.Name }); .IsRequired();
}); x.Property(p => p.Description)
.HasMaxLength(DataItemConsts.MaxDescriptionLength)
.HasColumnName(nameof(DataItem.Description));
builder.Entity<AppVersion>(x =>
{ x.Property(p => p.AllowBeNull).HasDefaultValue(true);
x.ToTable(options.TablePrefix + "Version", options.Schema);
x.ConfigureByConvention();
x.Property(p => p.Title)
.IsRequired() x.HasIndex(i => new { i.Name });
.HasColumnName(nameof(AppVersion.Title)) });
.HasMaxLength(AppVersionConsts.MaxTitleLength);
x.Property(p => p.Version)
.IsRequired() builder.Entity<AppVersion>(x =>
.HasColumnName(nameof(AppVersion.Version)) {
.HasMaxLength(AppVersionConsts.MaxVersionLength); x.ToTable(options.TablePrefix + "Version", options.Schema);
x.Property(p => p.Description) x.Property(p => p.Title)
.HasColumnName(nameof(AppVersion.Description)) .IsRequired()
.HasMaxLength(AppVersionConsts.MaxDescriptionLength); .HasColumnName(nameof(AppVersion.Title))
.HasMaxLength(AppVersionConsts.MaxTitleLength);
x.ConfigureByConvention(); x.Property(p => p.Version)
.IsRequired()
x.HasIndex(i => i.Version); .HasColumnName(nameof(AppVersion.Version))
.HasMaxLength(AppVersionConsts.MaxVersionLength);
x.HasMany(p => p.Files)
.WithOne(q => q.AppVersion) x.Property(p => p.Description)
.HasPrincipalKey(pk => pk.Id) .HasColumnName(nameof(AppVersion.Description))
.HasForeignKey(fk => fk.AppVersionId) .HasMaxLength(AppVersionConsts.MaxDescriptionLength);
.OnDelete(DeleteBehavior.Cascade);
}); x.ConfigureByConvention();
builder.Entity<VersionFile>(x => x.HasIndex(i => i.Version);
{
x.ToTable(options.TablePrefix + "VersionFile", options.Schema); x.HasMany(p => p.Files)
.WithOne(q => q.AppVersion)
x.Property(p => p.Name) .HasPrincipalKey(pk => pk.Id)
.IsRequired() .HasForeignKey(fk => fk.AppVersionId)
.HasColumnName(nameof(VersionFile.Name)) .OnDelete(DeleteBehavior.Cascade);
.HasMaxLength(VersionFileConsts.MaxNameLength); });
x.Property(p => p.SHA256)
.IsRequired() builder.Entity<VersionFile>(x =>
.HasColumnName(nameof(VersionFile.SHA256)) {
.HasMaxLength(VersionFileConsts.MaxSHA256Length); x.ToTable(options.TablePrefix + "VersionFile", options.Schema);
x.Property(p => p.Version)
.IsRequired() x.Property(p => p.Name)
.HasColumnName(nameof(VersionFile.Version)) .IsRequired()
.HasMaxLength(VersionFileConsts.MaxVersionLength); .HasColumnName(nameof(VersionFile.Name))
.HasMaxLength(VersionFileConsts.MaxNameLength);
x.Property(p => p.Path) x.Property(p => p.SHA256)
.HasColumnName(nameof(VersionFile.Path)) .IsRequired()
.HasMaxLength(VersionFileConsts.MaxPathLength); .HasColumnName(nameof(VersionFile.SHA256))
.HasMaxLength(VersionFileConsts.MaxSHA256Length);
x.ConfigureAudited(); x.Property(p => p.Version)
x.ConfigureMultiTenant(); .IsRequired()
.HasColumnName(nameof(VersionFile.Version))
x.HasIndex(i => new { i.Path, i.Name, i.Version }).IsUnique(); .HasMaxLength(VersionFileConsts.MaxVersionLength);
}); x.Property(p => p.Path)
} .HasColumnName(nameof(VersionFile.Path))
.HasMaxLength(VersionFileConsts.MaxPathLength);
public static EntityTypeBuilder<TRoute> ConfigureRoute<TRoute>(
this EntityTypeBuilder<TRoute> builder) x.ConfigureAudited();
where TRoute : Route x.ConfigureMultiTenant();
{
builder x.HasIndex(i => new { i.Path, i.Name, i.Version }).IsUnique();
.Property(p => p.DisplayName)
.HasMaxLength(RouteConsts.MaxDisplayNameLength) });
.HasColumnName(nameof(Route.DisplayName)) }
.IsRequired();
builder public static EntityTypeBuilder<TRoute> ConfigureRoute<TRoute>(
.Property(p => p.Name) this EntityTypeBuilder<TRoute> builder)
.HasMaxLength(RouteConsts.MaxNameLength) where TRoute : Route
.HasColumnName(nameof(Route.Name)) {
.IsRequired(); builder
builder .Property(p => p.DisplayName)
.Property(p => p.Path) .HasMaxLength(RouteConsts.MaxDisplayNameLength)
.HasMaxLength(RouteConsts.MaxPathLength) .HasColumnName(nameof(Route.DisplayName))
.HasColumnName(nameof(Route.Path)); .IsRequired();
builder builder
.Property(p => p.Redirect) .Property(p => p.Name)
.HasMaxLength(RouteConsts.MaxRedirectLength) .HasMaxLength(RouteConsts.MaxNameLength)
.HasColumnName(nameof(Route.Redirect)); .HasColumnName(nameof(Route.Name))
.IsRequired();
builder.ConfigureByConvention(); builder
.Property(p => p.Path)
return builder; .HasMaxLength(RouteConsts.MaxPathLength)
} .HasColumnName(nameof(Route.Path));
builder
public static OwnedNavigationBuilder<TEntity, TRoute> ConfigureRoute<TEntity, TRoute>( .Property(p => p.Redirect)
[NotNull] this OwnedNavigationBuilder<TEntity, TRoute> builder, .HasMaxLength(RouteConsts.MaxRedirectLength)
[CanBeNull] string tablePrefix = "", .HasColumnName(nameof(Route.Redirect));
[CanBeNull] string schema = null)
where TEntity : class builder.ConfigureByConvention();
where TRoute : Route
{ return builder;
builder.ToTable(tablePrefix + "Routes", schema); }
builder public static OwnedNavigationBuilder<TEntity, TRoute> ConfigureRoute<TEntity, TRoute>(
.Property(p => p.DisplayName) [NotNull] this OwnedNavigationBuilder<TEntity, TRoute> builder,
.HasMaxLength(RouteConsts.MaxDisplayNameLength) [CanBeNull] string tablePrefix = "",
.HasColumnName(nameof(Route.DisplayName)) [CanBeNull] string schema = null)
.IsRequired(); where TEntity : class
builder where TRoute : Route
.Property(p => p.Name) {
.HasMaxLength(RouteConsts.MaxNameLength) builder.ToTable(tablePrefix + "Routes", schema);
.HasColumnName(nameof(Route.Name))
.IsRequired(); builder
builder .Property(p => p.DisplayName)
.Property(p => p.Path) .HasMaxLength(RouteConsts.MaxDisplayNameLength)
.HasMaxLength(RouteConsts.MaxPathLength) .HasColumnName(nameof(Route.DisplayName))
.HasColumnName(nameof(Route.Path)); .IsRequired();
builder builder
.Property(p => p.Redirect) .Property(p => p.Name)
.HasMaxLength(RouteConsts.MaxRedirectLength) .HasMaxLength(RouteConsts.MaxNameLength)
.HasColumnName(nameof(Route.Redirect)); .HasColumnName(nameof(Route.Name))
.IsRequired();
return builder; builder
} .Property(p => p.Path)
} .HasMaxLength(RouteConsts.MaxPathLength)
} .HasColumnName(nameof(Route.Path));
builder
.Property(p => p.Redirect)
.HasMaxLength(RouteConsts.MaxRedirectLength)
.HasColumnName(nameof(Route.Redirect));
return builder;
}
}
}

160
aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Layouts/EfCoreLayoutRepository.cs

@ -1,80 +1,80 @@
using LINGYUN.Platform.EntityFrameworkCore; using LINGYUN.Platform.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Dynamic.Core; using System.Linq.Dynamic.Core;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Platform.Layouts namespace LINGYUN.Platform.Layouts
{ {
public class EfCoreLayoutRepository : EfCoreRepository<PlatformDbContext, Layout, Guid>, ILayoutRepository public class EfCoreLayoutRepository : EfCoreRepository<PlatformDbContext, Layout, Guid>, ILayoutRepository
{ {
public EfCoreLayoutRepository(IDbContextProvider<PlatformDbContext> dbContextProvider) public EfCoreLayoutRepository(IDbContextProvider<PlatformDbContext> dbContextProvider)
: base(dbContextProvider) : base(dbContextProvider)
{ {
} }
public virtual async Task<Layout> FindByNameAsync( public virtual async Task<Layout> FindByNameAsync(
string name, string name,
bool includeDetails = false, bool includeDetails = false,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.IncludeDetails(includeDetails) .IncludeDetails(includeDetails)
.Where(x => x.Name == name) .Where(x => x.Name == name)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<int> GetCountAsync( public virtual async Task<int> GetCountAsync(
PlatformType? platformType = null, string framework = "",
string filter = "", string filter = "",
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.WhereIf(platformType.HasValue, x => x.PlatformType == platformType.Value) .WhereIf(!framework.IsNullOrWhiteSpace(), x => x.Framework.Equals(framework))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => .WhereIf(!filter.IsNullOrWhiteSpace(), x =>
x.Name.Contains(filter) || x.DisplayName.Contains(filter) || x.Name.Contains(filter) || x.DisplayName.Contains(filter) ||
x.Description.Contains(filter) || x.Redirect.Contains(filter)) x.Description.Contains(filter) || x.Redirect.Contains(filter))
.CountAsync(GetCancellationToken(cancellationToken)); .CountAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<Layout>> GetPagedListAsync( public virtual async Task<List<Layout>> GetPagedListAsync(
PlatformType? platformType = null, string framework = "",
string filter = "", string filter = "",
string sorting = nameof(Layout.Name), string sorting = nameof(Layout.Name),
bool reverse = false, bool reverse = false,
bool includeDetails = false, bool includeDetails = false,
int skipCount = 0, int skipCount = 0,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
sorting ??= nameof(Layout.Name); sorting ??= nameof(Layout.Name);
sorting = reverse ? sorting + " DESC" : sorting; sorting = reverse ? sorting + " DESC" : sorting;
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.IncludeDetails(includeDetails) .IncludeDetails(includeDetails)
.WhereIf(platformType.HasValue, x => x.PlatformType == platformType.Value) .WhereIf(!framework.IsNullOrWhiteSpace(), x => x.Framework.Equals(framework))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => .WhereIf(!filter.IsNullOrWhiteSpace(), x =>
x.Name.Contains(filter) || x.DisplayName.Contains(filter) || x.Name.Contains(filter) || x.DisplayName.Contains(filter) ||
x.Description.Contains(filter) || x.Redirect.Contains(filter)) x.Description.Contains(filter) || x.Redirect.Contains(filter))
.OrderBy(sorting) .OrderBy(sorting)
.PageBy(skipCount, maxResultCount) .PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public override async Task<IQueryable<Layout>> WithDetailsAsync() public override async Task<IQueryable<Layout>> WithDetailsAsync()
{ {
return (await GetQueryableAsync()).IncludeDetails(); return (await GetQueryableAsync()).IncludeDetails();
} }
[System.Obsolete("将在abp框架移除之后删除")] [System.Obsolete("将在abp框架移除之后删除")]
public override IQueryable<Layout> WithDetails() public override IQueryable<Layout> WithDetails()
{ {
return GetQueryable().IncludeDetails(); return GetQueryable().IncludeDetails();
} }
} }
} }

504
aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreMenuRepository.cs

@ -1,252 +1,252 @@
using LINGYUN.Platform.EntityFrameworkCore; using LINGYUN.Platform.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Dynamic.Core; using System.Linq.Dynamic.Core;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Platform.Menus namespace LINGYUN.Platform.Menus
{ {
public class EfCoreMenuRepository : EfCoreRepository<PlatformDbContext, Menu, Guid>, IMenuRepository public class EfCoreMenuRepository : EfCoreRepository<PlatformDbContext, Menu, Guid>, IMenuRepository
{ {
public EfCoreMenuRepository( public EfCoreMenuRepository(
IDbContextProvider<PlatformDbContext> dbContextProvider) IDbContextProvider<PlatformDbContext> dbContextProvider)
: base(dbContextProvider) : base(dbContextProvider)
{ {
} }
public virtual async Task<bool> UserHasInMenuAsync( public virtual async Task<bool> UserHasInMenuAsync(
Guid userId, Guid userId,
string menuName, string menuName,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var menuQuery = (await GetDbSetAsync()).Where(x => x.Name == menuName); var menuQuery = (await GetDbSetAsync()).Where(x => x.Name == menuName);
return await (from menu in menuQuery return await (from menu in menuQuery
join userMenu in (await GetDbContextAsync()).Set<UserMenu>() join userMenu in (await GetDbContextAsync()).Set<UserMenu>()
on menu.Id equals userMenu.MenuId on menu.Id equals userMenu.MenuId
select userMenu) select userMenu)
.AnyAsync(x => x.UserId == userId, GetCancellationToken(cancellationToken)); .AnyAsync(x => x.UserId == userId, GetCancellationToken(cancellationToken));
} }
public virtual async Task<bool> RoleHasInMenuAsync( public virtual async Task<bool> RoleHasInMenuAsync(
string roleName, string roleName,
string menuName, string menuName,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var menuQuery = (await GetDbSetAsync()).Where(x => x.Name == menuName); var menuQuery = (await GetDbSetAsync()).Where(x => x.Name == menuName);
return await (from menu in menuQuery return await (from menu in menuQuery
join roleMenu in (await GetDbContextAsync()).Set<RoleMenu>() join roleMenu in (await GetDbContextAsync()).Set<RoleMenu>()
on menu.Id equals roleMenu.MenuId on menu.Id equals roleMenu.MenuId
select roleMenu) select roleMenu)
.AnyAsync(x => x.RoleName == roleName, GetCancellationToken(cancellationToken)); .AnyAsync(x => x.RoleName == roleName, GetCancellationToken(cancellationToken));
} }
public virtual async Task<Menu> FindByNameAsync( public virtual async Task<Menu> FindByNameAsync(
string menuName, string menuName,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.Where(x => x.Name == menuName) .Where(x => x.Name == menuName)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<Menu> FindMainAsync( public virtual async Task<Menu> FindMainAsync(
PlatformType platformType = PlatformType.None, string framework = "",
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.Where(menu => menu.PlatformType.HasFlag(platformType) && menu.Path == "/") .Where(menu => menu.Framework.Equals(framework) && menu.Path == "/")
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<Menu>> GetRoleMenusAsync( public virtual async Task<List<Menu>> GetRoleMenusAsync(
string[] roles, string[] roles,
PlatformType platformType = PlatformType.None, string framework = "",
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var menuQuery = (await GetDbSetAsync()) var menuQuery = (await GetDbSetAsync())
.Where(menu => menu.PlatformType.HasFlag(platformType)); .Where(menu => menu.Framework.Equals(framework));
var roleMenuQuery = (await GetDbContextAsync()).Set<RoleMenu>() var roleMenuQuery = (await GetDbContextAsync()).Set<RoleMenu>()
.Where(menu => roles.Contains(menu.RoleName)); .Where(menu => roles.Contains(menu.RoleName));
return await (from menu in menuQuery return await (from menu in menuQuery
join roleMenu in roleMenuQuery join roleMenu in roleMenuQuery
on menu.Id equals roleMenu.MenuId on menu.Id equals roleMenu.MenuId
select menu) select menu)
.Union(menuQuery.Where(x => x.IsPublic)) .Union(menuQuery.Where(x => x.IsPublic))
.Distinct() .Distinct()
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<Menu>> GetUserMenusAsync( public virtual async Task<List<Menu>> GetUserMenusAsync(
Guid userId, Guid userId,
string[] roles, string[] roles,
PlatformType platformType = PlatformType.None, string framework = "",
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var menuQuery = (await GetDbSetAsync()) var menuQuery = (await GetDbSetAsync())
.Where(menu => menu.PlatformType.HasFlag(platformType)); .Where(menu => menu.Framework.Equals(framework));
var dbContext = await GetDbContextAsync(); var dbContext = await GetDbContextAsync();
var userMenuQuery = from userMenu in dbContext.Set<UserMenu>() var userMenuQuery = from userMenu in dbContext.Set<UserMenu>()
join menu in menuQuery join menu in menuQuery
on userMenu.MenuId equals menu.Id on userMenu.MenuId equals menu.Id
where userMenu.UserId == userId where userMenu.UserId == userId
select menu; select menu;
if (roles != null && roles.Length > 0) if (roles != null && roles.Length > 0)
{ {
var roleMenuQuery = from roleMenu in dbContext.Set<RoleMenu>() var roleMenuQuery = from roleMenu in dbContext.Set<RoleMenu>()
join menu in menuQuery join menu in menuQuery
on roleMenu.MenuId equals menu.Id on roleMenu.MenuId equals menu.Id
where roles.Contains(roleMenu.RoleName) where roles.Contains(roleMenu.RoleName)
select menu; ; select menu; ;
return await userMenuQuery return await userMenuQuery
.Union(roleMenuQuery) .Union(roleMenuQuery)
.Union(menuQuery.Where(x => x.IsPublic)) .Union(menuQuery.Where(x => x.IsPublic))
.Distinct() .Distinct()
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
return await userMenuQuery return await userMenuQuery
.Union(menuQuery.Where(x => x.IsPublic)) .Union(menuQuery.Where(x => x.IsPublic))
.Distinct() .Distinct()
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<Menu>> GetChildrenAsync( public virtual async Task<List<Menu>> GetChildrenAsync(
Guid? parentId, Guid? parentId,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
) )
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.Where(x => x.ParentId == parentId) .Where(x => x.ParentId == parentId)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<Menu>> GetAllChildrenWithParentCodeAsync( public virtual async Task<List<Menu>> GetAllChildrenWithParentCodeAsync(
string code, string code,
Guid? parentId, Guid? parentId,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
) )
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.Where(x => x.Code.StartsWith(code) && x.Id != parentId.Value) .Where(x => x.Code.StartsWith(code) && x.Id != parentId.Value)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<Menu>> GetAllAsync( public virtual async Task<List<Menu>> GetAllAsync(
string filter = "", string filter = "",
string sorting = nameof(Menu.Code), string sorting = nameof(Menu.Code),
bool reverse = false, bool reverse = false,
PlatformType? platformType = null, string framework = "",
Guid? parentId = null, Guid? parentId = null,
Guid? layoutId = null, Guid? layoutId = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
sorting ??= nameof(Menu.Code); sorting ??= nameof(Menu.Code);
sorting = reverse ? sorting + " DESC" : sorting; sorting = reverse ? sorting + " DESC" : sorting;
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.WhereIf(parentId.HasValue, x => x.ParentId == parentId) .WhereIf(parentId.HasValue, x => x.ParentId == parentId)
.WhereIf(layoutId.HasValue, x => x.LayoutId == layoutId) .WhereIf(layoutId.HasValue, x => x.LayoutId == layoutId)
.WhereIf(platformType.HasValue, menu => menu.PlatformType.HasFlag(platformType.Value)) .WhereIf(!framework.IsNullOrWhiteSpace(), menu => menu.Framework.Equals(framework))
.WhereIf(!filter.IsNullOrWhiteSpace(), menu => .WhereIf(!filter.IsNullOrWhiteSpace(), menu =>
menu.Path.Contains(filter) || menu.Name.Contains(filter) || menu.Path.Contains(filter) || menu.Name.Contains(filter) ||
menu.DisplayName.Contains(filter) || menu.Description.Contains(filter) || menu.DisplayName.Contains(filter) || menu.Description.Contains(filter) ||
menu.Redirect.Contains(filter)) menu.Redirect.Contains(filter))
.OrderBy(sorting) .OrderBy(sorting)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<int> GetCountAsync( public virtual async Task<int> GetCountAsync(
string filter = "", string filter = "",
PlatformType? platformType = null, string framework = "",
Guid? parentId = null, Guid? parentId = null,
Guid? layoutId = null, Guid? layoutId = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.WhereIf(parentId.HasValue, x => x.ParentId == parentId) .WhereIf(parentId.HasValue, x => x.ParentId == parentId)
.WhereIf(layoutId.HasValue, x => x.LayoutId == layoutId) .WhereIf(layoutId.HasValue, x => x.LayoutId == layoutId)
.WhereIf(platformType.HasValue, menu => menu.PlatformType.HasFlag(platformType.Value)) .WhereIf(!framework.IsNullOrWhiteSpace(), menu => menu.Framework.Equals(framework))
.WhereIf(!filter.IsNullOrWhiteSpace(), menu => .WhereIf(!filter.IsNullOrWhiteSpace(), menu =>
menu.Path.Contains(filter) || menu.Name.Contains(filter) || menu.Path.Contains(filter) || menu.Name.Contains(filter) ||
menu.DisplayName.Contains(filter) || menu.Description.Contains(filter) || menu.DisplayName.Contains(filter) || menu.Description.Contains(filter) ||
menu.Redirect.Contains(filter)) menu.Redirect.Contains(filter))
.CountAsync(GetCancellationToken(cancellationToken)); .CountAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<Menu>> GetListAsync( public virtual async Task<List<Menu>> GetListAsync(
string filter = "", string filter = "",
string sorting = nameof(Menu.Code), string sorting = nameof(Menu.Code),
bool reverse = false, bool reverse = false,
PlatformType? platformType = null, string framework = "",
Guid? parentId = null, Guid? parentId = null,
Guid? layoutId = null, Guid? layoutId = null,
int skipCount = 0, int skipCount = 0,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
sorting ??= nameof(Menu.Code); sorting ??= nameof(Menu.Code);
sorting = reverse ? sorting + " DESC" : sorting; sorting = reverse ? sorting + " DESC" : sorting;
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.WhereIf(parentId.HasValue, x => x.ParentId == parentId) .WhereIf(parentId.HasValue, x => x.ParentId == parentId)
.WhereIf(layoutId.HasValue, x => x.LayoutId == layoutId) .WhereIf(layoutId.HasValue, x => x.LayoutId == layoutId)
.WhereIf(platformType.HasValue, menu => menu.PlatformType.HasFlag(platformType.Value)) .WhereIf(!framework.IsNullOrWhiteSpace(), menu => menu.Framework.Equals(framework))
.WhereIf(!filter.IsNullOrWhiteSpace(), menu => .WhereIf(!filter.IsNullOrWhiteSpace(), menu =>
menu.Path.Contains(filter) || menu.Name.Contains(filter) || menu.Path.Contains(filter) || menu.Name.Contains(filter) ||
menu.DisplayName.Contains(filter) || menu.Description.Contains(filter) || menu.DisplayName.Contains(filter) || menu.Description.Contains(filter) ||
menu.Redirect.Contains(filter)) menu.Redirect.Contains(filter))
.OrderBy(sorting) .OrderBy(sorting)
.PageBy(skipCount, maxResultCount) .PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task RemoveAllRolesAsync( public virtual async Task RemoveAllRolesAsync(
Menu menu, Menu menu,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
) )
{ {
var dbContext = await GetDbContextAsync(); var dbContext = await GetDbContextAsync();
var rolesQuery = await dbContext.Set<RoleMenu>() var rolesQuery = await dbContext.Set<RoleMenu>()
.Where(q => q.MenuId == menu.Id) .Where(q => q.MenuId == menu.Id)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
dbContext.Set<RoleMenu>().RemoveRange(rolesQuery); dbContext.Set<RoleMenu>().RemoveRange(rolesQuery);
} }
public virtual async Task RemoveAllMembersAsync( public virtual async Task RemoveAllMembersAsync(
Menu menu, Menu menu,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
) )
{ {
var dbContext = await GetDbContextAsync(); var dbContext = await GetDbContextAsync();
var membersQuery = await dbContext.Set<UserMenu>() var membersQuery = await dbContext.Set<UserMenu>()
.Where(q => q.MenuId == menu.Id) .Where(q => q.MenuId == menu.Id)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
dbContext.Set<UserMenu>().RemoveRange(membersQuery); dbContext.Set<UserMenu>().RemoveRange(membersQuery);
} }
public override async Task<IQueryable<Menu>> WithDetailsAsync() public override async Task<IQueryable<Menu>> WithDetailsAsync()
{ {
return (await GetQueryableAsync()).IncludeDetails(); return (await GetQueryableAsync()).IncludeDetails();
} }
[System.Obsolete("将在abp框架移除之后删除")] [System.Obsolete("将在abp框架移除之后删除")]
public override IQueryable<Menu> WithDetails() public override IQueryable<Menu> WithDetails()
{ {
return GetQueryable().IncludeDetails(); return GetQueryable().IncludeDetails();
} }
} }
} }

175
aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Datas/DataController.cs

@ -1,84 +1,91 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
namespace LINGYUN.Platform.Datas namespace LINGYUN.Platform.Datas
{ {
[RemoteService(Name = PlatformRemoteServiceConsts.RemoteServiceName)] [RemoteService(Name = PlatformRemoteServiceConsts.RemoteServiceName)]
[Area("platform")] [Area("platform")]
[Route("api/platform/datas")] [Route("api/platform/datas")]
public class DataController : AbpController, IDataAppService public class DataController : AbpController, IDataAppService
{ {
protected IDataAppService DataAppService { get; } protected IDataAppService DataAppService { get; }
public DataController( public DataController(
IDataAppService dataAppService) IDataAppService dataAppService)
{ {
DataAppService = dataAppService; DataAppService = dataAppService;
} }
[HttpPost] [HttpPost]
public virtual async Task<DataDto> CreateAsync(DataCreateDto input) public virtual async Task<DataDto> CreateAsync(DataCreateDto input)
{ {
return await DataAppService.CreateAsync(input); return await DataAppService.CreateAsync(input);
} }
[HttpPost] [HttpPost]
[Route("{id}/items")] [Route("{id}/items")]
public virtual async Task CreateItemAsync(Guid id, DataItemCreateDto input) public virtual async Task CreateItemAsync(Guid id, DataItemCreateDto input)
{ {
await DataAppService.CreateItemAsync(id, input); await DataAppService.CreateItemAsync(id, input);
} }
[HttpDelete] [HttpDelete]
[Route("{id}")] [Route("{id}")]
public virtual async Task DeleteAsync(Guid id) public virtual async Task DeleteAsync(Guid id)
{ {
await DataAppService.DeleteAsync(id); await DataAppService.DeleteAsync(id);
} }
[HttpDelete] [HttpDelete]
[Route("{id}/items/{name}")] [Route("{id}/items/{name}")]
public virtual async Task DeleteItemAsync(Guid id, string name) public virtual async Task DeleteItemAsync(Guid id, string name)
{ {
await DataAppService.DeleteItemAsync(id, name); await DataAppService.DeleteItemAsync(id, name);
} }
[HttpGet] [HttpGet]
[Route("{id}")] [Route("by-name/{name}")]
public virtual async Task<DataDto> GetAsync(Guid id) public virtual async Task<DataDto> GetAsync(string name)
{ {
return await DataAppService.GetAsync(id); return await DataAppService.GetAsync(name);
} }
[HttpGet] [HttpGet]
[Route("all")] [Route("{id}")]
public virtual async Task<ListResultDto<DataDto>> GetAllAsync() public virtual async Task<DataDto> GetAsync(Guid id)
{ {
return await DataAppService.GetAllAsync(); return await DataAppService.GetAsync(id);
} }
[HttpGet] [HttpGet]
public virtual async Task<PagedResultDto<DataDto>> GetListAsync(GetDataListInput input) [Route("all")]
{ public virtual async Task<ListResultDto<DataDto>> GetAllAsync()
return await DataAppService.GetListAsync(input); {
} return await DataAppService.GetAllAsync();
}
[HttpPut]
[Route("{id}")] [HttpGet]
public virtual async Task<DataDto> UpdateAsync(Guid id, DataUpdateDto input) public virtual async Task<PagedResultDto<DataDto>> GetListAsync(GetDataListInput input)
{ {
return await DataAppService.UpdateAsync(id, input); return await DataAppService.GetListAsync(input);
} }
[HttpPut] [HttpPut]
[Route("{id}/items/{name}")] [Route("{id}")]
public virtual async Task UpdateItemAsync(Guid id, string name, DataItemUpdateDto input) public virtual async Task<DataDto> UpdateAsync(Guid id, DataUpdateDto input)
{ {
await DataAppService.UpdateItemAsync(id, name, input); return await DataAppService.UpdateAsync(id, input);
} }
}
} [HttpPut]
[Route("{id}/items/{name}")]
public virtual async Task UpdateItemAsync(Guid id, string name, DataItemUpdateDto input)
{
await DataAppService.UpdateItemAsync(id, name, input);
}
}
}

256
aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Menus/MenuController.cs

@ -1,128 +1,128 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Identity; using Volo.Abp.Identity;
namespace LINGYUN.Platform.Menus namespace LINGYUN.Platform.Menus
{ {
[RemoteService(Name = PlatformRemoteServiceConsts.RemoteServiceName)] [RemoteService(Name = PlatformRemoteServiceConsts.RemoteServiceName)]
[Area("platform")] [Area("platform")]
[Route("api/platform/menus")] [Route("api/platform/menus")]
public class MenuController : AbpController, IMenuAppService public class MenuController : AbpController, IMenuAppService
{ {
protected IMenuAppService MenuAppService { get; } protected IMenuAppService MenuAppService { get; }
protected IUserRoleFinder UserRoleFinder { get; } protected IUserRoleFinder UserRoleFinder { get; }
public MenuController( public MenuController(
IMenuAppService menuAppService, IMenuAppService menuAppService,
IUserRoleFinder userRoleFinder) IUserRoleFinder userRoleFinder)
{ {
MenuAppService = menuAppService; MenuAppService = menuAppService;
UserRoleFinder = userRoleFinder; UserRoleFinder = userRoleFinder;
} }
[HttpGet] [HttpGet]
[Route("by-current-user")] [Route("by-current-user")]
public virtual async Task<ListResultDto<MenuDto>> GetCurrentUserMenuListAsync(GetMenuInput input) public virtual async Task<ListResultDto<MenuDto>> GetCurrentUserMenuListAsync(GetMenuInput input)
{ {
return await MenuAppService.GetCurrentUserMenuListAsync(input); return await MenuAppService.GetCurrentUserMenuListAsync(input);
} }
[HttpGet] [HttpGet]
[Route("{id}")] [Route("{id}")]
public virtual async Task<MenuDto> GetAsync(Guid id) public virtual async Task<MenuDto> GetAsync(Guid id)
{ {
return await MenuAppService.GetAsync(id); return await MenuAppService.GetAsync(id);
} }
[HttpGet] [HttpGet]
[Route("all")] [Route("all")]
public virtual async Task<ListResultDto<MenuDto>> GetAllAsync(MenuGetAllInput input) public virtual async Task<ListResultDto<MenuDto>> GetAllAsync(MenuGetAllInput input)
{ {
return await MenuAppService.GetAllAsync(input); return await MenuAppService.GetAllAsync(input);
} }
[HttpGet] [HttpGet]
public virtual async Task<PagedResultDto<MenuDto>> GetListAsync(MenuGetListInput input) public virtual async Task<PagedResultDto<MenuDto>> GetListAsync(MenuGetListInput input)
{ {
return await MenuAppService.GetListAsync(input); return await MenuAppService.GetListAsync(input);
} }
[HttpPost] [HttpPost]
public virtual async Task<MenuDto> CreateAsync(MenuCreateDto input) public virtual async Task<MenuDto> CreateAsync(MenuCreateDto input)
{ {
return await MenuAppService.CreateAsync(input); return await MenuAppService.CreateAsync(input);
} }
[HttpPut] [HttpPut]
[Route("{id}")] [Route("{id}")]
public virtual async Task<MenuDto> UpdateAsync(Guid id, MenuUpdateDto input) public virtual async Task<MenuDto> UpdateAsync(Guid id, MenuUpdateDto input)
{ {
return await MenuAppService.UpdateAsync(id, input); return await MenuAppService.UpdateAsync(id, input);
} }
[HttpDelete] [HttpDelete]
[Route("{id}")] [Route("{id}")]
public virtual async Task DeleteAsync(Guid id) public virtual async Task DeleteAsync(Guid id)
{ {
await MenuAppService.DeleteAsync(id); await MenuAppService.DeleteAsync(id);
} }
[HttpPut] [HttpPut]
[Route("by-user")] [Route("by-user")]
public virtual async Task SetUserMenusAsync(UserMenuInput input) public virtual async Task SetUserMenusAsync(UserMenuInput input)
{ {
await MenuAppService.SetUserMenusAsync(input); await MenuAppService.SetUserMenusAsync(input);
} }
[HttpGet] [HttpGet]
[Route("by-user")] [Route("by-user")]
public virtual async Task<ListResultDto<MenuDto>> GetUserMenuListAsync(MenuGetByUserInput input) public virtual async Task<ListResultDto<MenuDto>> GetUserMenuListAsync(MenuGetByUserInput input)
{ {
return await MenuAppService.GetUserMenuListAsync(input); return await MenuAppService.GetUserMenuListAsync(input);
} }
[HttpGet] [HttpGet]
[Route("by-user/{userId}/{platformType}")] [Route("by-user/{userId}/{framework}")]
public virtual async Task<ListResultDto<MenuDto>> GetUserMenuListAsync(Guid userId, PlatformType platformType) public virtual async Task<ListResultDto<MenuDto>> GetUserMenuListAsync(Guid userId, string framework)
{ {
var userRoles = await UserRoleFinder.GetRolesAsync(userId); var userRoles = await UserRoleFinder.GetRolesAsync(userId);
var getMenuByUser = new MenuGetByUserInput var getMenuByUser = new MenuGetByUserInput
{ {
UserId = userId, UserId = userId,
Roles = userRoles, Roles = userRoles,
PlatformType = platformType Framework = framework
}; };
return await MenuAppService.GetUserMenuListAsync(getMenuByUser); return await MenuAppService.GetUserMenuListAsync(getMenuByUser);
} }
[HttpPut] [HttpPut]
[Route("by-role")] [Route("by-role")]
public virtual async Task SetRoleMenusAsync(RoleMenuInput input) public virtual async Task SetRoleMenusAsync(RoleMenuInput input)
{ {
await MenuAppService.SetRoleMenusAsync(input); await MenuAppService.SetRoleMenusAsync(input);
} }
[HttpGet] [HttpGet]
[Route("by-role")] [Route("by-role")]
public virtual async Task<ListResultDto<MenuDto>> GetRoleMenuListAsync(MenuGetByRoleInput input) public virtual async Task<ListResultDto<MenuDto>> GetRoleMenuListAsync(MenuGetByRoleInput input)
{ {
return await MenuAppService.GetRoleMenuListAsync(input); return await MenuAppService.GetRoleMenuListAsync(input);
} }
[HttpGet] [HttpGet]
[Route("by-role/{role}/{platformType}")] [Route("by-role/{role}/{framework}")]
public virtual async Task<ListResultDto<MenuDto>> GetRoleMenuListAsync(string role, PlatformType platformType) public virtual async Task<ListResultDto<MenuDto>> GetRoleMenuListAsync(string role, string framework)
{ {
return await MenuAppService.GetRoleMenuListAsync(new MenuGetByRoleInput return await MenuAppService.GetRoleMenuListAsync(new MenuGetByRoleInput
{ {
Role = role, Role = role,
PlatformType = platformType Framework = framework
}); });
} }
} }
} }

1887
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDataSeedContributor.cs → aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/DataSeeder/ElementAdminDataSeedContributor.cs

File diff suppressed because it is too large

291
aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/DataSeeder/VbenAdminDataSeedContributor.cs

@ -0,0 +1,291 @@
using LINGYUN.Platform.Datas;
using LINGYUN.Platform.Layouts;
using LINGYUN.Platform.Menus;
using LINGYUN.Platform.Routes;
using LINGYUN.Platform.Utils;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.MultiTenancy;
namespace LINGYUN.Platform.DataSeeder
{
public class VbenAdminDataSeedContributor : IDataSeedContributor, ITransientDependency
{
protected ICurrentTenant CurrentTenant { get; }
protected IGuidGenerator GuidGenerator { get; }
protected IRouteDataSeeder RouteDataSeeder { get; }
protected IDataDictionaryDataSeeder DataDictionaryDataSeeder { get; }
protected IMenuRepository MenuRepository { get; }
protected ILayoutRepository LayoutRepository { get; }
public VbenAdminDataSeedContributor(
ICurrentTenant currentTenant,
IRouteDataSeeder routeDataSeeder,
IMenuRepository menuRepository,
ILayoutRepository layoutRepository,
IGuidGenerator guidGenerator,
IDataDictionaryDataSeeder dataDictionaryDataSeeder)
{
CurrentTenant = currentTenant;
GuidGenerator = guidGenerator;
RouteDataSeeder = routeDataSeeder;
MenuRepository = menuRepository;
LayoutRepository = layoutRepository;
DataDictionaryDataSeeder = dataDictionaryDataSeeder;
}
public virtual async Task SeedAsync(DataSeedContext context)
{
using (CurrentTenant.Change(context.TenantId))
{
var uiDataItem = await SeedUIFrameworkDataAsync(context.TenantId);
var layoutData = await SeedLayoutDataAsync(context.TenantId);
var layout = await SeedDefaultLayoutAsync(layoutData, uiDataItem);
}
}
private async Task<DataItem> SeedUIFrameworkDataAsync(Guid? tenantId)
{
var data = await DataDictionaryDataSeeder
.SeedAsync(
"UI Framewark",
CodeNumberGenerator.CreateCode(2),
"UI框架",
"UI Framewark",
null,
tenantId,
true);
data.AddItem(
GuidGenerator,
"Vue Vben Admin",
"Vue Vben Admin",
"Vue Vben Admin",
Datas.ValueType.String,
"Vue Vben Admin",
isStatic: true);
return data.FindItem("Vue Vben Admin");
}
private async Task<Layout> SeedDefaultLayoutAsync(Data data, DataItem uiDataItem)
{
var layout = await RouteDataSeeder.SeedLayoutAsync(
"Vben Admin Layout",
"LAYOUT", // 路由层面已经处理好了,只需要传递LAYOUT可自动引用布局
"Vben Admin Layout",
data.Id,
uiDataItem.Name,
"",
"Vben Admin Layout",
data.TenantId
);
return layout;
}
private async Task<Data> SeedLayoutDataAsync(Guid? tenantId)
{
var data = await DataDictionaryDataSeeder
.SeedAsync(
"Vben Admin Layout",
CodeNumberGenerator.CreateCode(3),
"Vben Admin布局约束",
"Vben Admin Layout Meta Dictionary",
null,
tenantId,
true);
data.AddItem(
GuidGenerator,
"hideMenu",
"不在菜单显示",
"false",
Datas.ValueType.Boolean,
"当前路由不在菜单显示",
isStatic: true);
data.AddItem(
GuidGenerator,
"icon",
"图标",
"",
Datas.ValueType.String,
"图标,也是菜单图标",
isStatic: true);
data.AddItem(
GuidGenerator,
"currentActiveMenu",
"当前激活的菜单",
"",
Datas.ValueType.String,
"用于配置详情页时左侧激活的菜单路径",
isStatic: true);
data.AddItem(
GuidGenerator,
"ignoreKeepAlive",
"KeepAlive缓存",
"false",
Datas.ValueType.Boolean,
"是否忽略KeepAlive缓存",
isStatic: true);
data.AddItem(
GuidGenerator,
"frameSrc",
"IFrame地址",
"",
Datas.ValueType.String,
"内嵌iframe的地址",
isStatic: true);
data.AddItem(
GuidGenerator,
"transitionName",
"路由切换动画",
"",
Datas.ValueType.String,
"指定该路由切换的动画名",
isStatic: true);
data.AddItem(
GuidGenerator,
"roles",
"可以访问的角色",
"",
Datas.ValueType.Array,
"可以访问的角色,只在权限模式为Role的时候有效",
isStatic: true);
data.AddItem(
GuidGenerator,
"title",
"路由标题",
"",
Datas.ValueType.String,
"路由title 一般必填",
false,
isStatic: true);
data.AddItem(
GuidGenerator,
"carryParam",
"在tab页显示",
"false",
Datas.ValueType.Boolean,
"如果该路由会携带参数,且需要在tab页上面显示。则需要设置为true",
isStatic: true);
data.AddItem(
GuidGenerator,
"hideBreadcrumb",
"隐藏面包屑",
"false",
Datas.ValueType.Boolean,
"隐藏该路由在面包屑上面的显示",
isStatic: true);
data.AddItem(
GuidGenerator,
"ignoreAuth",
"忽略权限",
"false",
Datas.ValueType.Boolean,
"是否忽略权限,只在权限模式为Role的时候有效",
isStatic: true);
data.AddItem(
GuidGenerator,
"hideChildrenInMenu",
"隐藏所有子菜单",
"false",
Datas.ValueType.Boolean,
"隐藏所有子菜单",
isStatic: true);
data.AddItem(
GuidGenerator,
"hideTab",
"不在标签页显示",
"false",
Datas.ValueType.Boolean,
"当前路由不在标签页显示",
isStatic: true);
data.AddItem(
GuidGenerator,
"affix",
"固定标签页",
"false",
Datas.ValueType.Boolean,
"是否固定标签页",
isStatic: true);
data.AddItem(
GuidGenerator,
"frameFormat",
"格式化IFrame",
"false",
Datas.ValueType.Boolean,
"扩展的格式化frame,{token}: 在打开的iframe页面传递token请求头");
return data;
}
private async Task<Menu> SeedMenuAsync(
Layout layout,
Data data,
string name,
string path,
string code,
string component,
string displayName,
string redirect = "",
string description = "",
Guid? parentId = null,
Guid? tenantId = null,
Dictionary<string, object> meta = null,
string[] roles = null,
Guid[] users = null,
bool isPublic = false
)
{
var menu = await RouteDataSeeder.SeedMenuAsync(
layout,
name,
path,
code,
component,
displayName,
redirect,
description,
parentId,
tenantId,
isPublic
);
foreach (var item in data.Items)
{
menu.SetProperty(item.Name, item.DefaultValue);
}
if (meta != null)
{
foreach (var item in meta)
{
menu.SetProperty(item.Key, item.Value);
}
}
if (roles != null)
{
foreach (var role in roles)
{
await RouteDataSeeder.SeedRoleMenuAsync(role, menu, tenantId);
}
}
if (users != null)
{
foreach (var user in users)
{
await RouteDataSeeder.SeedUserMenuAsync(user, menu, tenantId);
}
}
return menu;
}
}
}

556
aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantSynchronizer.cs

@ -1,525 +1,31 @@
using LINGYUN.Abp.MultiTenancy; using LINGYUN.Abp.MultiTenancy;
using LINGYUN.Platform.Datas; using System.Threading.Tasks;
using LINGYUN.Platform.Layouts; using Volo.Abp.Data;
using LINGYUN.Platform.Menus; using Volo.Abp.DependencyInjection;
using LINGYUN.Platform.Routes; using Volo.Abp.EventBus.Distributed;
using LINGYUN.Platform.Utils;
using System; namespace LINGYUN.Platform.EventBus.Handlers
using System.Collections.Generic; {
using System.Threading.Tasks; public class TenantSynchronizer :
using Volo.Abp.Data; IDistributedEventHandler<CreateEventData>,
using Volo.Abp.DependencyInjection; ITransientDependency
using Volo.Abp.EventBus.Distributed; {
using Volo.Abp.Guids; protected IDataSeeder DataSeeder { get; }
using Volo.Abp.MultiTenancy;
public TenantSynchronizer(IDataSeeder dataSeeder)
namespace LINGYUN.Platform.EventBus.Handlers {
{ DataSeeder = dataSeeder;
public class TenantSynchronizer : }
IDistributedEventHandler<CreateEventData>,
ITransientDependency /// <summary>
{ /// 租户创建之后需要预置种子数据
protected ICurrentTenant CurrentTenant { get; } /// </summary>
protected IGuidGenerator GuidGenerator { get; } /// <param name="eventData"></param>
protected IRouteDataSeeder RouteDataSeeder { get; } /// <returns></returns>
protected IDataDictionaryDataSeeder DataDictionaryDataSeeder { get; } public virtual async Task HandleEventAsync(CreateEventData eventData)
protected IMenuRepository MenuRepository { get; } {
protected ILayoutRepository LayoutRepository { get; } await DataSeeder.SeedAsync(
new DataSeedContext(eventData.Id));
public TenantSynchronizer( }
ICurrentTenant currentTenant, }
IRouteDataSeeder routeDataSeeder, }
IMenuRepository menuRepository,
ILayoutRepository layoutRepository,
IGuidGenerator guidGenerator,
IDataDictionaryDataSeeder dataDictionaryDataSeeder)
{
CurrentTenant = currentTenant;
GuidGenerator = guidGenerator;
RouteDataSeeder = routeDataSeeder;
MenuRepository = menuRepository;
LayoutRepository = layoutRepository;
DataDictionaryDataSeeder = dataDictionaryDataSeeder;
}
/// <summary>
/// 租户创建之后需要预置租户平台数据
/// </summary>
/// <param name="eventData"></param>
/// <returns></returns>
public virtual async Task HandleEventAsync(CreateEventData eventData)
{
using (CurrentTenant.Change(eventData.Id))
{
var data = await SeedDefaultDataDictionaryAsync(eventData.Id);
// 预置
var layout = await SeedDefaultLayoutAsync(data);
// 首页
await SeedHomeMenuAsync(layout, data);
// 管理菜单预置菜单数据
await SeedAdminMenuAsync(layout, data);
// 审计日志菜单数据
await SeedAuditingMenuAsync(layout, data);
// 布局容器预置菜单数据
await SeedContainerMenuAsync(layout, data);
}
}
/// <summary>
/// 租户删除之后删除租户平台数据
/// TODO: 不应删除用户数据
/// </summary>
/// <param name="eventData"></param>
/// <returns></returns>
//public virtual async Task HandleEventAsync(DeleteEventData eventData)
//{
// //await MenuRepository.GetAllAsync();
//}
private async Task<Data> SeedDefaultDataDictionaryAsync(Guid? tenantId)
{
var data = await DataDictionaryDataSeeder
.SeedAsync(
"Layout",
CodeNumberGenerator.CreateCode(1),
"Vue Admin Layout Meta Dictionary",
"Vue Admin Layout Meta Dictionary",
null,
tenantId);
data.AddItem(
GuidGenerator,
"roles", // TODO: 是否需要把这一项写入到预置数据?
"roles",
"",
Datas.ValueType.Array,
"will control the page roles (allow setting multiple roles)");
data.AddItem(
GuidGenerator,
"title",
"title",
"component",
Datas.ValueType.String,
"the name showed in subMenu and breadcrumb (recommend set)");
data.AddItem(
GuidGenerator,
"icon",
"icon",
"icon",
Datas.ValueType.String,
"the icon showed in the sidebar");
data.AddItem(
GuidGenerator,
"hidden",
"hidden",
"false",
Datas.ValueType.Boolean,
"if true, this route will not show in the sidebar (default is false)");
data.AddItem(
GuidGenerator,
"alwaysShow",
"alwaysShow",
"false",
Datas.ValueType.Boolean,
"if true, will always show the root menu (default is false)");
data.AddItem(
GuidGenerator,
"breadcrumb",
"breadcrumb",
"true",
Datas.ValueType.Boolean,
"if false, the item will be hidden in breadcrumb (default is true)");
data.AddItem(
GuidGenerator,
"noCache",
"noCache",
"false",
Datas.ValueType.Boolean,
"if true, the page will not be cached (default is false)");
data.AddItem(
GuidGenerator,
"affix",
"affix",
"false",
Datas.ValueType.Boolean,
"if true, the tag will affix in the tags-view");
data.AddItem(
GuidGenerator,
"activeMenu",
"activeMenu",
"",
Datas.ValueType.String,
"if set path, the sidebar will highlight the path you set");
return data;
}
private async Task<Layout> SeedDefaultLayoutAsync(Data data)
{
var layout = await RouteDataSeeder.SeedLayoutAsync(
"Layout",
"layout/index.vue",
"Vue Admin Layout",
data.Id,
PlatformType.WebMvvm, // 针对当前的vue管理页
"",
"Vue Admin Layout",
data.TenantId
);
return layout;
}
private async Task SeedHomeMenuAsync(Layout layout, Data data)
{
var adminMenu = await SeedMenuAsync(
layout,
data,
"home",
"/",
CodeNumberGenerator.CreateCode(1),
layout.Path,
"Home",
"/dashboard",
"Home",
null,
layout.TenantId,
new Dictionary<string, object>()
{
{ "title", "home" },
{ "icon", "home" },
{ "alwaysShow", true }
},
// isPublic: true,
isPublic: false); // 首页应该是共有的页面
await SeedMenuAsync(
layout,
data,
"dashboard",
"dashboard",
CodeNumberGenerator.AppendCode(adminMenu.Code, CodeNumberGenerator.CreateCode(1)),
"views/dashboard/index.vue",
"Dashboard",
"",
"Dashboard",
adminMenu.Id,
layout.TenantId,
new Dictionary<string, object>()
{
{ "title", "dashboard" },
{ "icon", "dashboard" }
},
isPublic: false);
}
private async Task SeedAdminMenuAsync(Layout layout, Data data)
{
var adminMenu = await SeedMenuAsync(
layout,
data,
"admin",
"/admin",
CodeNumberGenerator.CreateCode(2),
layout.Path,
"Admin",
"",
"Admin",
null,
layout.TenantId,
new Dictionary<string, object>()
{
{ "title", "admin" },
{ "icon", "admin" },
{ "alwaysShow", true }
},
new string[] { "admin" });
await SeedMenuAsync(
layout,
data,
"roles",
"roles",
CodeNumberGenerator.AppendCode(adminMenu.Code, CodeNumberGenerator.CreateCode(1)),
"views/admin/roles/index.vue",
"Manage Roles",
"",
"Manage Roles",
adminMenu.Id,
layout.TenantId,
new Dictionary<string, object>()
{
{ "title", "roles" },
{ "icon", "role" },
{ "roles", new string[] { "AbpIdentity.Roles" } }
},
new string[] { "admin" });
await SeedMenuAsync(
layout,
data,
"users",
"users",
CodeNumberGenerator.AppendCode(adminMenu.Code, CodeNumberGenerator.CreateCode(2)),
"views/admin/users/index.vue",
"Manage Users",
"",
"Manage Users",
adminMenu.Id,
layout.TenantId,
new Dictionary<string, object>()
{
{ "title", "users" },
{ "icon", "users" },
{ "roles", new string[] { "AbpIdentity.Users" } }
},
new string[] { "admin" });
await SeedMenuAsync(
layout,
data,
"organization-unit",
"organization-unit",
CodeNumberGenerator.AppendCode(adminMenu.Code, CodeNumberGenerator.CreateCode(3)),
"views/admin/organization-unit/index.vue",
"Manage Organization Units",
"",
"Manage Organization Units",
adminMenu.Id,
layout.TenantId,
new Dictionary<string, object>()
{
{ "title", "organization-unit" },
{ "icon", "organization-unit" },
{ "roles", new string[] { "AbpIdentity.OrganizationUnits" } }
},
new string[] { "admin" });
await SeedMenuAsync(
layout,
data,
"data-dictionary",
"data-dictionary",
CodeNumberGenerator.AppendCode(adminMenu.Code, CodeNumberGenerator.CreateCode(5)),
"views/admin/data-dictionary/index.vue",
"Manage Data Dictionarys",
"",
"Manage Data Dictionarys",
adminMenu.Id,
layout.TenantId,
new Dictionary<string, object>()
{
{ "title", "data-dictionary" },
{ "icon", "data-dictionary" },
{ "roles", new string[] { "Platform.DataDictionary" } }
},
new string[] { "admin" });
await SeedMenuAsync(
layout,
data,
"settings",
"settings",
CodeNumberGenerator.AppendCode(adminMenu.Code, CodeNumberGenerator.CreateCode(6)),
"views/admin/settings/index.vue",
"Manage Settings",
"",
"Manage Settings",
adminMenu.Id,
layout.TenantId,
new Dictionary<string, object>()
{
{ "title", "settings" },
{ "icon", "settings" },
{ "roles", new string[] { "AbpSettingManagement.Settings" } }
},
new string[] { "admin" });
}
private async Task SeedAuditingMenuAsync(Layout layout, Data data)
{
var auditingMenu = await SeedMenuAsync(
layout,
data,
"auditing",
"/auditing",
CodeNumberGenerator.CreateCode(5),
layout.Path,
"Auditing",
"",
"Auditing",
null,
layout.TenantId,
new Dictionary<string, object>()
{
{ "title", "auditing" },
{ "icon", "auditing" },
{ "alwaysShow", true },
{ "roles", new string[]{ "AbpAuditing.AuditLog", "AbpAuditing.SecurityLog" } }
},
new string[] { "admin" });
await SeedMenuAsync(
layout,
data,
"audit-log",
"audit-log",
CodeNumberGenerator.AppendCode(auditingMenu.Code, CodeNumberGenerator.CreateCode(1)),
"views/admin/auditing/audit-log/index.vue",
"Manage AuditLog",
"",
"Manage AuditLog",
auditingMenu.Id,
layout.TenantId,
new Dictionary<string, object>()
{
{ "title", "audit-log" },
{ "icon", "audit-log" },
{ "roles", new string[]{ "AbpAuditing.AuditLog" } }
},
new string[] { "admin" });
await SeedMenuAsync(
layout,
data,
"security-log",
"security-log",
CodeNumberGenerator.AppendCode(auditingMenu.Code, CodeNumberGenerator.CreateCode(2)),
"views/admin/auditing/security-log/index.vue",
"Manage SecurityLog",
"",
"Manage SecurityLog",
auditingMenu.Id,
layout.TenantId,
new Dictionary<string, object>()
{
{ "title", "security-log" },
{ "icon", "security-log" },
{ "roles", new string[]{ "AbpAuditing.SecurityLog" } }
},
new string[] { "admin" });
}
private async Task SeedContainerMenuAsync(Layout layout, Data data)
{
var containerRoot = await SeedMenuAsync(
layout,
data,
"container",
"/container",
CodeNumberGenerator.CreateCode(6),
layout.Path,
"Container",
"",
"Manage Container",
null,
layout.TenantId,
new Dictionary<string, object>()
{
{ "title", "container" },
{ "icon", "container" },
{ "alwaysShow", true }
},
new string[] { "admin" });
await SeedMenuAsync(
layout,
data,
"layouts",
"layouts",
CodeNumberGenerator.AppendCode(containerRoot.Code, CodeNumberGenerator.CreateCode(1)),
"views/container/layouts/index.vue",
"Manage Layouts",
"",
"Manage Layouts",
containerRoot.Id,
containerRoot.TenantId,
new Dictionary<string, object>()
{
{ "title", "layouts" },
{ "icon", "layout" }
},
new string[] { "admin" });
await SeedMenuAsync(
layout,
data,
"menus",
"menus",
CodeNumberGenerator.AppendCode(containerRoot.Code, CodeNumberGenerator.CreateCode(2)),
"views/container/menus/index.vue",
"Manage Menus",
"",
"Manage Menus",
containerRoot.Id,
containerRoot.TenantId,
new Dictionary<string, object>()
{
{ "title", "menus" },
{ "icon", "menu" }
},
new string[] { "admin" });
}
private async Task<Menu> SeedMenuAsync(
Layout layout,
Data data,
string name,
string path,
string code,
string component,
string displayName,
string redirect = "",
string description = "",
Guid? parentId = null,
Guid? tenantId = null,
Dictionary<string, object> meta = null,
string[] roles = null,
Guid[] users = null,
bool isPublic = false
)
{
var menu = await RouteDataSeeder.SeedMenuAsync(
layout,
name,
path,
code,
component,
displayName,
redirect,
description,
parentId,
tenantId,
isPublic
);
foreach (var item in data.Items)
{
menu.SetProperty(item.Name, item.DefaultValue);
}
if (meta != null)
{
foreach (var item in meta)
{
menu.SetProperty(item.Key, item.Value);
}
}
if (roles != null)
{
foreach (var role in roles)
{
await RouteDataSeeder.SeedRoleMenuAsync(role, menu, tenantId);
}
}
if (users != null)
{
foreach (var user in users)
{
await RouteDataSeeder.SeedUserMenuAsync(user, menu, tenantId);
}
}
return menu;
}
}
}

148
aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj

@ -1,74 +1,74 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
<RootNamespace>LINGYUN.Platform</RootNamespace> <RootNamespace>LINGYUN.Platform</RootNamespace>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="%2a%2a\**" /> <Compile Remove="%2a%2a\**" />
<Content Remove="%2a%2a\**" /> <Content Remove="%2a%2a\**" />
<EmbeddedResource Remove="%2a%2a\**" /> <EmbeddedResource Remove="%2a%2a\**" />
<None Remove="%2a%2a\**" /> <None Remove="%2a%2a\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="Migrations\20200723131720_Add-Platform-Module.cs" /> <Compile Remove="Migrations\20200723131720_Add-Platform-Module.cs" />
<Compile Remove="Migrations\20200723131720_Add-Platform-Module.Designer.cs" /> <Compile Remove="Migrations\20200723131720_Add-Platform-Module.Designer.cs" />
<Compile Remove="Migrations\20200908021207_Upgrade-abp-3.1.0.cs" /> <Compile Remove="Migrations\20200908021207_Upgrade-abp-3.1.0.cs" />
<Compile Remove="Migrations\20200908021207_Upgrade-abp-3.1.0.Designer.cs" /> <Compile Remove="Migrations\20200908021207_Upgrade-abp-3.1.0.Designer.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DotNetCore.CAP.Dashboard" Version="5.1.0" /> <PackageReference Include="DotNetCore.CAP.Dashboard" Version="5.1.0" />
<PackageReference Include="DotNetCore.CAP.MySql" Version="5.1.0" /> <PackageReference Include="DotNetCore.CAP.MySql" Version="5.1.0" />
<PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="5.1.0" /> <PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="5.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.*"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.*">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="5.0.*" /> <PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="5.0.*" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" /> <PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="Serilog.Enrichers.Assembly" Version="2.0.0" /> <PackageReference Include="Serilog.Enrichers.Assembly" Version="2.0.0" />
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.1" /> <PackageReference Include="Serilog.Enrichers.Process" Version="2.0.1" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" /> <PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" /> <PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" /> <PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="4.3.0" /> <PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="4.3.0" />
<PackageReference Include="Volo.Abp.AspNetCore.MultiTenancy" Version="4.3.0" /> <PackageReference Include="Volo.Abp.AspNetCore.MultiTenancy" Version="4.3.0" />
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="4.3.0" /> <PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="4.3.0" />
<PackageReference Include="Volo.Abp.Autofac" Version="4.3.0" /> <PackageReference Include="Volo.Abp.Autofac" Version="4.3.0" />
<PackageReference Include="Volo.Abp.BlobStoring.FileSystem" Version="4.3.0" /> <PackageReference Include="Volo.Abp.BlobStoring.FileSystem" Version="4.3.0" />
<PackageReference Include="Volo.Abp.Identity.HttpApi.Client" Version="4.3.0" /> <PackageReference Include="Volo.Abp.Identity.HttpApi.Client" Version="4.3.0" />
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel.Web" Version="4.3.0" /> <PackageReference Include="Volo.Abp.Http.Client.IdentityModel.Web" Version="4.3.0" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySQL" Version="4.3.0" /> <PackageReference Include="Volo.Abp.EntityFrameworkCore.MySQL" Version="4.3.0" />
<PackageReference Include="Volo.Abp.AuditLogging.EntityFrameworkCore" Version="4.3.0" /> <PackageReference Include="Volo.Abp.AuditLogging.EntityFrameworkCore" Version="4.3.0" />
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" Version="4.3.0" /> <PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" Version="4.3.0" />
<PackageReference Include="Volo.Abp.TenantManagement.EntityFrameworkCore" Version="4.3.0" /> <PackageReference Include="Volo.Abp.TenantManagement.EntityFrameworkCore" Version="4.3.0" />
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="4.3.0" /> <PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="4.3.0" />
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="4.3.0" /> <PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="4.3.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.AspNetCore.HttpOverrides\LINGYUN.Abp.AspNetCore.HttpOverrides.csproj" /> <ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.AspNetCore.HttpOverrides\LINGYUN.Abp.AspNetCore.HttpOverrides.csproj" />
<ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.csproj" /> <ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.csproj" />
<ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.ExceptionHandling.Emailing\LINGYUN.Abp.ExceptionHandling.Emailing.csproj" /> <ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.ExceptionHandling.Emailing\LINGYUN.Abp.ExceptionHandling.Emailing.csproj" />
<ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.Features.LimitValidation.Redis.Client\LINGYUN.Abp.Features.LimitValidation.Redis.Client.csproj" /> <ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.Features.LimitValidation.Redis.Client\LINGYUN.Abp.Features.LimitValidation.Redis.Client.csproj" />
<ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.Notifications\LINGYUN.Abp.Notifications.csproj" /> <ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.Notifications\LINGYUN.Abp.Notifications.csproj" />
<ProjectReference Include="..\..\..\modules\features\LINGYUN.Abp.Features.Client\LINGYUN.Abp.Features.Client.csproj" /> <ProjectReference Include="..\..\..\modules\features\LINGYUN.Abp.Features.Client\LINGYUN.Abp.Features.Client.csproj" />
<ProjectReference Include="..\..\..\modules\lt\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\..\modules\lt\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\modules\oss-management\LINGYUN.Abp.OssManagement.Aliyun\LINGYUN.Abp.OssManagement.Aliyun.csproj" /> <ProjectReference Include="..\..\..\modules\oss-management\LINGYUN.Abp.OssManagement.Aliyun\LINGYUN.Abp.OssManagement.Aliyun.csproj" />
<ProjectReference Include="..\..\..\modules\oss-management\LINGYUN.Abp.OssManagement.Application\LINGYUN.Abp.OssManagement.Application.csproj" /> <ProjectReference Include="..\..\..\modules\oss-management\LINGYUN.Abp.OssManagement.Application\LINGYUN.Abp.OssManagement.Application.csproj" />
<ProjectReference Include="..\..\..\modules\oss-management\LINGYUN.Abp.OssManagement.FileSystem.ImageSharp\LINGYUN.Abp.OssManagement.FileSystem.ImageSharp.csproj" /> <ProjectReference Include="..\..\..\modules\oss-management\LINGYUN.Abp.OssManagement.FileSystem.ImageSharp\LINGYUN.Abp.OssManagement.FileSystem.ImageSharp.csproj" />
<ProjectReference Include="..\..\..\modules\oss-management\LINGYUN.Abp.OssManagement.FileSystem\LINGYUN.Abp.OssManagement.FileSystem.csproj" /> <ProjectReference Include="..\..\..\modules\oss-management\LINGYUN.Abp.OssManagement.FileSystem\LINGYUN.Abp.OssManagement.FileSystem.csproj" />
<ProjectReference Include="..\..\..\modules\oss-management\LINGYUN.Abp.OssManagement.HttpApi\LINGYUN.Abp.OssManagement.HttpApi.csproj" /> <ProjectReference Include="..\..\..\modules\oss-management\LINGYUN.Abp.OssManagement.HttpApi\LINGYUN.Abp.OssManagement.HttpApi.csproj" />
<ProjectReference Include="..\..\..\modules\oss-management\LINGYUN.Abp.OssManagement.SettingManagement\LINGYUN.Abp.OssManagement.SettingManagement.csproj" /> <ProjectReference Include="..\..\..\modules\oss-management\LINGYUN.Abp.OssManagement.SettingManagement\LINGYUN.Abp.OssManagement.SettingManagement.csproj" />
<ProjectReference Include="..\..\..\modules\platform\LINGYUN.Platform.Application\LINGYUN.Platform.Application.csproj" /> <ProjectReference Include="..\..\..\modules\platform\LINGYUN.Platform.Application\LINGYUN.Platform.Application.csproj" />
<ProjectReference Include="..\..\..\modules\platform\LINGYUN.Platform.EntityFrameworkCore\LINGYUN.Platform.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\..\modules\platform\LINGYUN.Platform.EntityFrameworkCore\LINGYUN.Platform.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\modules\platform\LINGYUN.Platform.HttpApi\LINGYUN.Platform.HttpApi.csproj" /> <ProjectReference Include="..\..\..\modules\platform\LINGYUN.Platform.HttpApi\LINGYUN.Platform.HttpApi.csproj" />
<ProjectReference Include="..\..\..\modules\tenants\LINGYUN.Abp.MultiTenancy.DbFinder\LINGYUN.Abp.MultiTenancy.DbFinder.csproj" /> <ProjectReference Include="..\..\..\modules\tenants\LINGYUN.Abp.MultiTenancy.DbFinder\LINGYUN.Abp.MultiTenancy.DbFinder.csproj" />
<ProjectReference Include="..\..\..\modules\tenants\LINGYUN.Abp.MultiTenancy\LINGYUN.Abp.MultiTenancy.csproj" /> <ProjectReference Include="..\..\..\modules\tenants\LINGYUN.Abp.MultiTenancy\LINGYUN.Abp.MultiTenancy.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

665
aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20210621020117_Rename-Route-Field-PlantType-To-Framework.Designer.cs

@ -0,0 +1,665 @@
// <auto-generated />
using System;
using LINGYUN.Platform.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Platform.Migrations
{
[DbContext(typeof(PlatformHttpApiHostMigrationsDbContext))]
[Migration("20210621020117_Rename-Route-Field-PlantType-To-Framework")]
partial class RenameRouteFieldPlantTypeToFramework
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql)
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.7");
modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<string>("Code")
.IsRequired()
.HasMaxLength(1024)
.HasColumnType("varchar(1024) CHARACTER SET utf8mb4")
.HasColumnName("Code");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40) CHARACTER SET utf8mb4")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<Guid?>("DeleterId")
.HasColumnType("char(36)")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime(6)")
.HasColumnName("DeletionTime");
b.Property<string>("Description")
.HasMaxLength(1024)
.HasColumnType("varchar(1024) CHARACTER SET utf8mb4")
.HasColumnName("Description");
b.Property<string>("DisplayName")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("varchar(128) CHARACTER SET utf8mb4")
.HasColumnName("DisplayName");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext CHARACTER SET utf8mb4")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<bool>("IsStatic")
.HasColumnType("tinyint(1)");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("varchar(30) CHARACTER SET utf8mb4")
.HasColumnName("Name");
b.Property<Guid?>("ParentId")
.HasColumnType("char(36)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.HasIndex("Name");
b.ToTable("AppPlatformDatas");
});
modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<bool>("AllowBeNull")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(true);
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40) CHARACTER SET utf8mb4")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<Guid>("DataId")
.HasColumnType("char(36)");
b.Property<string>("DefaultValue")
.HasMaxLength(128)
.HasColumnType("varchar(128) CHARACTER SET utf8mb4")
.HasColumnName("DefaultValue");
b.Property<Guid?>("DeleterId")
.HasColumnType("char(36)")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime(6)")
.HasColumnName("DeletionTime");
b.Property<string>("Description")
.HasMaxLength(1024)
.HasColumnType("varchar(1024) CHARACTER SET utf8mb4")
.HasColumnName("Description");
b.Property<string>("DisplayName")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("varchar(128) CHARACTER SET utf8mb4")
.HasColumnName("DisplayName");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext CHARACTER SET utf8mb4")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<bool>("IsStatic")
.HasColumnType("tinyint(1)");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("varchar(30) CHARACTER SET utf8mb4")
.HasColumnName("Name");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("ValueType")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("DataId");
b.HasIndex("Name");
b.ToTable("AppPlatformDataItems");
});
modelBuilder.Entity("LINGYUN.Platform.Layouts.Layout", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40) CHARACTER SET utf8mb4")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<Guid>("DataId")
.HasColumnType("char(36)");
b.Property<Guid?>("DeleterId")
.HasColumnType("char(36)")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime(6)")
.HasColumnName("DeletionTime");
b.Property<string>("Description")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("DisplayName")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("varchar(128) CHARACTER SET utf8mb4")
.HasColumnName("DisplayName");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext CHARACTER SET utf8mb4")
.HasColumnName("ExtraProperties");
b.Property<string>("Framework")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64) CHARACTER SET utf8mb4")
.HasColumnName("Framework");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64) CHARACTER SET utf8mb4")
.HasColumnName("Name");
b.Property<string>("Path")
.HasMaxLength(255)
.HasColumnType("varchar(255) CHARACTER SET utf8mb4")
.HasColumnName("Path");
b.Property<string>("Redirect")
.HasMaxLength(255)
.HasColumnType("varchar(255) CHARACTER SET utf8mb4")
.HasColumnName("Redirect");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.ToTable("AppPlatformLayouts");
});
modelBuilder.Entity("LINGYUN.Platform.Menus.Menu", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<string>("Code")
.IsRequired()
.HasMaxLength(23)
.HasColumnType("varchar(23) CHARACTER SET utf8mb4")
.HasColumnName("Code");
b.Property<string>("Component")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("varchar(255) CHARACTER SET utf8mb4")
.HasColumnName("Component");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40) CHARACTER SET utf8mb4")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<Guid?>("DeleterId")
.HasColumnType("char(36)")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime(6)")
.HasColumnName("DeletionTime");
b.Property<string>("Description")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("DisplayName")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("varchar(128) CHARACTER SET utf8mb4")
.HasColumnName("DisplayName");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext CHARACTER SET utf8mb4")
.HasColumnName("ExtraProperties");
b.Property<string>("Framework")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64) CHARACTER SET utf8mb4")
.HasColumnName("Framework");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<bool>("IsPublic")
.HasColumnType("tinyint(1)");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<Guid>("LayoutId")
.HasColumnType("char(36)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64) CHARACTER SET utf8mb4")
.HasColumnName("Name");
b.Property<Guid?>("ParentId")
.HasColumnType("char(36)");
b.Property<string>("Path")
.HasMaxLength(255)
.HasColumnType("varchar(255) CHARACTER SET utf8mb4")
.HasColumnName("Path");
b.Property<string>("Redirect")
.HasMaxLength(255)
.HasColumnType("varchar(255) CHARACTER SET utf8mb4")
.HasColumnName("Redirect");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.ToTable("AppPlatformMenus");
});
modelBuilder.Entity("LINGYUN.Platform.Menus.RoleMenu", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<Guid>("MenuId")
.HasColumnType("char(36)");
b.Property<string>("RoleName")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("varchar(256) CHARACTER SET utf8mb4")
.HasColumnName("RoleName");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.HasIndex("RoleName", "MenuId");
b.ToTable("AppPlatformRoleMenus");
});
modelBuilder.Entity("LINGYUN.Platform.Menus.UserMenu", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<Guid>("MenuId")
.HasColumnType("char(36)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("UserId", "MenuId");
b.ToTable("AppPlatformUserMenus");
});
modelBuilder.Entity("LINGYUN.Platform.Versions.AppVersion", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40) CHARACTER SET utf8mb4")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<Guid?>("DeleterId")
.HasColumnType("char(36)")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime(6)")
.HasColumnName("DeletionTime");
b.Property<string>("Description")
.HasMaxLength(2048)
.HasColumnType("longtext CHARACTER SET utf8mb4")
.HasColumnName("Description");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext CHARACTER SET utf8mb4")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<int>("Level")
.HasColumnType("int");
b.Property<int>("PlatformType")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50) CHARACTER SET utf8mb4")
.HasColumnName("Title");
b.Property<string>("Version")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("varchar(20) CHARACTER SET utf8mb4")
.HasColumnName("Version");
b.HasKey("Id");
b.HasIndex("Version");
b.ToTable("AppPlatformVersion");
});
modelBuilder.Entity("LINGYUN.Platform.Versions.VersionFile", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<Guid>("AppVersionId")
.HasColumnType("char(36)");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<int>("DownloadCount")
.HasColumnType("int");
b.Property<int>("FileType")
.HasColumnType("int");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("varchar(255) CHARACTER SET utf8mb4")
.HasColumnName("Name");
b.Property<string>("Path")
.HasMaxLength(255)
.HasColumnType("varchar(255) CHARACTER SET utf8mb4")
.HasColumnName("Path");
b.Property<string>("SHA256")
.IsRequired()
.HasMaxLength(65)
.HasColumnType("varchar(65) CHARACTER SET utf8mb4")
.HasColumnName("SHA256");
b.Property<long>("Size")
.HasColumnType("bigint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<string>("Version")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("varchar(20) CHARACTER SET utf8mb4")
.HasColumnName("Version");
b.HasKey("Id");
b.HasIndex("AppVersionId");
b.HasIndex("Path", "Name", "Version")
.IsUnique();
b.ToTable("AppPlatformVersionFile");
});
modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b =>
{
b.HasOne("LINGYUN.Platform.Datas.Data", null)
.WithMany("Items")
.HasForeignKey("DataId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("LINGYUN.Platform.Versions.VersionFile", b =>
{
b.HasOne("LINGYUN.Platform.Versions.AppVersion", "AppVersion")
.WithMany("Files")
.HasForeignKey("AppVersionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("AppVersion");
});
modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b =>
{
b.Navigation("Items");
});
modelBuilder.Entity("LINGYUN.Platform.Versions.AppVersion", b =>
{
b.Navigation("Files");
});
#pragma warning restore 612, 618
}
}
}

81
aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20210621020117_Rename-Route-Field-PlantType-To-Framework.cs

@ -0,0 +1,81 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace LINGYUN.Platform.Migrations
{
public partial class RenameRouteFieldPlantTypeToFramework : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "PlatformType",
table: "AppPlatformMenus");
migrationBuilder.DropColumn(
name: "PlatformType",
table: "AppPlatformLayouts");
migrationBuilder.AddColumn<string>(
name: "Framework",
table: "AppPlatformMenus",
type: "varchar(64) CHARACTER SET utf8mb4",
maxLength: 64,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "Framework",
table: "AppPlatformLayouts",
type: "varchar(64) CHARACTER SET utf8mb4",
maxLength: 64,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<bool>(
name: "IsStatic",
table: "AppPlatformDatas",
type: "tinyint(1)",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "IsStatic",
table: "AppPlatformDataItems",
type: "tinyint(1)",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Framework",
table: "AppPlatformMenus");
migrationBuilder.DropColumn(
name: "Framework",
table: "AppPlatformLayouts");
migrationBuilder.DropColumn(
name: "IsStatic",
table: "AppPlatformDatas");
migrationBuilder.DropColumn(
name: "IsStatic",
table: "AppPlatformDataItems");
migrationBuilder.AddColumn<int>(
name: "PlatformType",
table: "AppPlatformMenus",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "PlatformType",
table: "AppPlatformLayouts",
type: "int",
nullable: false,
defaultValue: 0);
}
}
}

1302
aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs

File diff suppressed because it is too large

237
vueJs/src/api/data-dictionary.ts

@ -1,116 +1,121 @@
import ApiService from './serviceBase' import ApiService from './serviceBase'
import { urlStringify } from '@/utils/index' import { urlStringify } from '@/utils/index'
import { ListResultDto, PagedResultDto, PagedAndSortedResultRequestDto } from './types' import { ListResultDto, PagedResultDto, PagedAndSortedResultRequestDto } from './types'
const sourceUrl = '/api/platform/datas' const sourceUrl = '/api/platform/datas'
/** 远程服务地址 */ /** 远程服务地址 */
const serviceUrl = process.env.VUE_APP_BASE_API const serviceUrl = process.env.VUE_APP_BASE_API
/** 数据字典api接口 */ /** 数据字典api接口 */
export default class DataDictionaryService { export default class DataDictionaryService {
public static get(id: string) { public static get(id: string) {
const _url = sourceUrl + '/' + id const _url = sourceUrl + '/' + id
return ApiService.Get<Data>(_url, serviceUrl) return ApiService.Get<Data>(_url, serviceUrl)
} }
public static getList(payload: GetDataByPaged) { public static getByName(name: string) {
const _url = sourceUrl + '?' + urlStringify(payload) const _url = sourceUrl + '/by-name/' + name
return ApiService.Get<PagedResultDto<Data >>(_url, serviceUrl) return ApiService.Get<Data>(_url, serviceUrl)
} }
public static getAll() { public static getList(payload: GetDataByPaged) {
const _url = sourceUrl + '/all' const _url = sourceUrl + '?' + urlStringify(payload)
return ApiService.Get<ListResultDto<Data >>(_url, serviceUrl) return ApiService.Get<PagedResultDto<Data >>(_url, serviceUrl)
} }
public static create(payload: DataCreate) { public static getAll() {
return ApiService.Post<Data>(sourceUrl, payload, serviceUrl) const _url = sourceUrl + '/all'
} return ApiService.Get<ListResultDto<Data >>(_url, serviceUrl)
}
public static update(id: string, payload: DataUpdate) {
const _url = sourceUrl + '/' + id public static create(payload: DataCreate) {
return ApiService.Put<Data>(_url, payload, serviceUrl) return ApiService.Post<Data>(sourceUrl, payload, serviceUrl)
} }
public static delete(id: string) { public static update(id: string, payload: DataUpdate) {
const _url = sourceUrl + '/' + id const _url = sourceUrl + '/' + id
return ApiService.Delete(_url, serviceUrl) return ApiService.Put<Data>(_url, payload, serviceUrl)
} }
public static appendItem(id: string, payload: DataItemCreate) { public static delete(id: string) {
const _url = sourceUrl + '/' + id + '/items' const _url = sourceUrl + '/' + id
return ApiService.Post<Data>(_url, payload, serviceUrl) return ApiService.Delete(_url, serviceUrl)
} }
public static updateItem(id: string, name: string, payload: DataItemUpdate) { public static appendItem(id: string, payload: DataItemCreate) {
const _url = sourceUrl + '/' + id + '/items/' + name const _url = sourceUrl + '/' + id + '/items'
return ApiService.Put<Data>(_url, payload, serviceUrl) return ApiService.Post<Data>(_url, payload, serviceUrl)
} }
public static removeItem(id: string, name: string) { public static updateItem(id: string, name: string, payload: DataItemUpdate) {
const _url = sourceUrl + '/' + id + '/items/' + name const _url = sourceUrl + '/' + id + '/items/' + name
return ApiService.Delete(_url, serviceUrl) return ApiService.Put<Data>(_url, payload, serviceUrl)
} }
}
public static removeItem(id: string, name: string) {
export enum ValueType { const _url = sourceUrl + '/' + id + '/items/' + name
String = 0, return ApiService.Delete(_url, serviceUrl)
Numeic = 1, }
Boolean = 2, }
Date = 3,
DateTime = 4, export enum ValueType {
Array = 5, String = 0,
Object = 6 Numeic = 1,
} Boolean = 2,
Date = 3,
export class DataItem { DateTime = 4,
id!: string Array = 5,
name!: string Object = 6
defaultValue!: string }
displayName!: string
description?: string export class DataItem {
allowBeNull!: boolean id!: string
valueType!: ValueType name!: string
} defaultValue!: string
displayName!: string
export class Data { description?: string
id!: string allowBeNull!: boolean
name!: string valueType!: ValueType
code!: string }
displayName!: string
description?: string export class Data {
parentId?: string id!: string
items = new Array<DataItem>() name!: string
} code!: string
displayName!: string
export class GetDataByPaged extends PagedAndSortedResultRequestDto { description?: string
filter = '' parentId?: string
} items = new Array<DataItem>()
}
export class DataCreateOrUpdate {
name = '' export class GetDataByPaged extends PagedAndSortedResultRequestDto {
displayName = '' filter = ''
description? = '' }
}
export class DataCreateOrUpdate {
export class DataCreate extends DataCreateOrUpdate { name = ''
parentId?: string displayName = ''
} description? = ''
}
export class DataUpdate extends DataCreateOrUpdate {
} export class DataCreate extends DataCreateOrUpdate {
parentId?: string
export class DataItemCreateOrUpdate { }
defaultValue = ''
displayName = '' export class DataUpdate extends DataCreateOrUpdate {
description? = '' }
allowBeNull = true
valueType = ValueType.String export class DataItemCreateOrUpdate {
} defaultValue = ''
displayName = ''
export class DataItemUpdate extends DataItemCreateOrUpdate { description? = ''
} allowBeNull = true
valueType = ValueType.String
export class DataItemCreate extends DataItemCreateOrUpdate { }
name = ''
} export class DataItemUpdate extends DataItemCreateOrUpdate {
}
export class DataItemCreate extends DataItemCreateOrUpdate {
name = ''
}

186
vueJs/src/api/layout.ts

@ -1,109 +1,77 @@
import ApiService from './serviceBase' import ApiService from './serviceBase'
import { urlStringify } from '@/utils/index' import { urlStringify } from '@/utils/index'
import { ListResultDto, PagedResultDto, PagedAndSortedResultRequestDto } from './types' import { ListResultDto, PagedResultDto, PagedAndSortedResultRequestDto } from './types'
const sourceUrl = '/api/platform/layouts' const sourceUrl = '/api/platform/layouts'
/** 远程服务地址 */ /** 远程服务地址 */
const serviceUrl = process.env.VUE_APP_BASE_API const serviceUrl = process.env.VUE_APP_BASE_API
/** 路由相关pi接口 */ /** 路由相关pi接口 */
export default class LayoutService { export default class LayoutService {
public static get(id: string) { public static get(id: string) {
const _url = sourceUrl + '/' + id const _url = sourceUrl + '/' + id
return ApiService.Get<Layout>(_url, serviceUrl) return ApiService.Get<Layout>(_url, serviceUrl)
} }
public static getAllList() { public static getAllList() {
const _url = sourceUrl + '/all' const _url = sourceUrl + '/all'
return ApiService.Get<ListResultDto<Layout >>(_url, serviceUrl) return ApiService.Get<ListResultDto<Layout >>(_url, serviceUrl)
} }
public static getList(payload: GetLayoutByPaged) { public static getList(payload: GetLayoutByPaged) {
const _url = sourceUrl + '?' + urlStringify(payload) const _url = sourceUrl + '?' + urlStringify(payload)
return ApiService.Get<PagedResultDto<Layout >>(_url, serviceUrl) return ApiService.Get<PagedResultDto<Layout >>(_url, serviceUrl)
} }
public static create(payload: LayoutCreate) { public static create(payload: LayoutCreate) {
return ApiService.Post<Layout>(sourceUrl, payload, serviceUrl) return ApiService.Post<Layout>(sourceUrl, payload, serviceUrl)
} }
public static update(id: string, payload: LayoutUpdate) { public static update(id: string, payload: LayoutUpdate) {
const _url = sourceUrl + '/' + id const _url = sourceUrl + '/' + id
return ApiService.Put<Layout>(_url, payload, serviceUrl) return ApiService.Put<Layout>(_url, payload, serviceUrl)
} }
public static delete(id: string) { public static delete(id: string) {
const _url = sourceUrl + '/' + id const _url = sourceUrl + '/' + id
return ApiService.Delete(_url, serviceUrl) return ApiService.Delete(_url, serviceUrl)
} }
} }
export enum PlatformType { export class Route {
None = 0, id!: string
WinCe = 2, name!: string
WinForm = 4, path!: string
Desktop = WinCe | WinForm, displayName!: string
WebForm = 8, description?: string
WebMvc = 16, redirect?: string
WebMvvm = 32, meta: {[key: string]: any} = {}
Web = WebForm | WebMvc | WebMvvm, }
Android = 64,
iOS = 128, export class Layout extends Route {
Mobile = Android | iOS, framework!: string
MiniProgram = 256, dataId!: string
All = Desktop | Web | Mobile | MiniProgram }
}
export class LayoutCreateOrUpdate {
export const PlatformTypes = [ name!: string
{ key: 'None', value: PlatformType.None }, path!: string
{ key: 'WinCe', value: PlatformType.WinCe }, displayName!: string
{ key: 'WinForm', value: PlatformType.WinForm }, description?: string
{ key: 'Desktop', value: PlatformType.Desktop }, redirect?: string
{ key: 'WebForm', value: PlatformType.WebForm }, }
{ key: 'WebMvc', value: PlatformType.WebMvc },
{ key: 'WebMvvm', value: PlatformType.WebMvvm }, export class LayoutCreate extends LayoutCreateOrUpdate {
{ key: 'Web', value: PlatformType.Web }, dataId!: string
{ key: 'Android', value: PlatformType.Android }, framework!: string
{ key: 'iOS', value: PlatformType.iOS }, }
{ key: 'Mobile', value: PlatformType.Mobile },
{ key: 'MiniProgram', value: PlatformType.MiniProgram }, export class LayoutUpdate extends LayoutCreateOrUpdate {
{ key: 'All', value: PlatformType.All }
] }
export class Route { export class GetLayoutByPaged extends PagedAndSortedResultRequestDto {
id!: string filter = ''
name!: string reverse = false
path!: string framework = ''
displayName!: string }
description?: string
redirect?: string
meta: {[key: string]: any} = {}
}
export class Layout extends Route {
platformType!: PlatformType
dataId!: string
}
export class LayoutCreateOrUpdate {
name!: string
path!: string
displayName!: string
description?: string
redirect?: string
platformType!: PlatformType
}
export class LayoutCreate extends LayoutCreateOrUpdate {
dataId!: string
}
export class LayoutUpdate extends LayoutCreateOrUpdate {
}
export class GetLayoutByPaged extends PagedAndSortedResultRequestDto {
filter = ''
reverse = false
platformType?: PlatformType | null
}

245
vueJs/src/api/menu.ts

@ -1,123 +1,122 @@
import ApiService from './serviceBase' import ApiService from './serviceBase'
import { Route, PlatformType } from './layout' import { Route } from './layout'
import { urlStringify } from '@/utils/index' import { urlStringify } from '@/utils/index'
import { ISortedResultRequest, PagedResultDto, PagedAndSortedResultRequestDto, ListResultDto } from './types' import { ISortedResultRequest, PagedResultDto, PagedAndSortedResultRequestDto, ListResultDto } from './types'
const sourceUrl = '/api/platform/menus' const sourceUrl = '/api/platform/menus'
/** 远程服务地址 */ /** 远程服务地址 */
const serviceUrl = process.env.VUE_APP_BASE_API const serviceUrl = process.env.VUE_APP_BASE_API
/** 路由相关pi接口 */ /** 路由相关pi接口 */
export default class MenuService { export default class MenuService {
public static get(id: string) { public static get(id: string) {
const _url = sourceUrl + '/' + id const _url = sourceUrl + '/' + id
return ApiService.Get<Menu>(_url, serviceUrl) return ApiService.Get<Menu>(_url, serviceUrl)
} }
public static getAll(payload: GetAllMenu) { public static getAll(payload: GetAllMenu) {
const _url = sourceUrl + '/all?' + urlStringify(payload) const _url = sourceUrl + '/all?' + urlStringify(payload)
return ApiService.Get<ListResultDto<Menu>>(_url, serviceUrl) return ApiService.Get<ListResultDto<Menu>>(_url, serviceUrl)
} }
public static getList(payload: GetMenuByPaged) { public static getList(payload: GetMenuByPaged) {
const _url = sourceUrl + '?' + urlStringify(payload) const _url = sourceUrl + '?' + urlStringify(payload)
return ApiService.Get<PagedResultDto<Menu>>(_url, serviceUrl) return ApiService.Get<PagedResultDto<Menu>>(_url, serviceUrl)
} }
public static getMyMenuList(platformType: PlatformType) { public static getMyMenuList(framework: string) {
const _url = sourceUrl + '/by-current-user?platformType=' + platformType const _url = sourceUrl + '/by-current-user?framework=' + framework
return ApiService.Get<ListResultDto<Menu>>(_url, serviceUrl) return ApiService.Get<ListResultDto<Menu>>(_url, serviceUrl)
} }
public static getRoleMenuList(role: string, platformType: PlatformType) { public static getRoleMenuList(role: string, framework: string) {
const _url = sourceUrl + `/by-role/${role}/${platformType}` const _url = sourceUrl + `/by-role/${role}/${framework}`
return ApiService.Get<ListResultDto<Menu>>(_url, serviceUrl) return ApiService.Get<ListResultDto<Menu>>(_url, serviceUrl)
} }
public static getUserMenuList(userId: string, platformType: PlatformType) { public static getUserMenuList(userId: string, framework: string) {
const _url = sourceUrl + `/by-user/${userId}/${platformType}` const _url = sourceUrl + `/by-user/${userId}/${framework}`
return ApiService.Get<ListResultDto<Menu>>(_url, serviceUrl) return ApiService.Get<ListResultDto<Menu>>(_url, serviceUrl)
} }
public static create(payload: MenuCreate) { public static create(payload: MenuCreate) {
return ApiService.Post<Menu>(sourceUrl, payload, serviceUrl) return ApiService.Post<Menu>(sourceUrl, payload, serviceUrl)
} }
public static update(id: string, payload: MenuUpdate) { public static update(id: string, payload: MenuUpdate) {
const _url = sourceUrl + '/' + id const _url = sourceUrl + '/' + id
return ApiService.Put<Menu>(_url, payload, serviceUrl) return ApiService.Put<Menu>(_url, payload, serviceUrl)
} }
public static delete(id: string) { public static delete(id: string) {
const _url = sourceUrl + '/' + id const _url = sourceUrl + '/' + id
return ApiService.Delete(_url, serviceUrl) return ApiService.Delete(_url, serviceUrl)
} }
public static setRoleMenu(payload: RoleMenu) { public static setRoleMenu(payload: RoleMenu) {
const _url = sourceUrl + '/by-role' const _url = sourceUrl + '/by-role'
return ApiService.Put<void>(_url, payload, serviceUrl) return ApiService.Put<void>(_url, payload, serviceUrl)
} }
public static setUserMenu(payload: UserMenu) { public static setUserMenu(payload: UserMenu) {
const _url = sourceUrl + '/by-user' const _url = sourceUrl + '/by-user'
return ApiService.Put<void>(_url, payload, serviceUrl) return ApiService.Put<void>(_url, payload, serviceUrl)
} }
} }
export class MenuCreateOrUpdate { export class MenuCreateOrUpdate {
name!: string name!: string
path!: string path!: string
component!: string component!: string
displayName!: string displayName!: string
description?: string description?: string
redirect?: string redirect?: string
isPublic!: boolean isPublic!: boolean
platformType!: PlatformType meta: {[key: string]: any} = {}
meta: {[key: string]: any} = {} }
}
export class MenuCreate extends MenuCreateOrUpdate {
export class MenuCreate extends MenuCreateOrUpdate { layoutId!: string
layoutId!: string parentId?: string
parentId?: string }
}
export class MenuUpdate extends MenuCreateOrUpdate {
export class MenuUpdate extends MenuCreateOrUpdate {
}
}
export class GetAllMenu implements ISortedResultRequest {
export class GetAllMenu implements ISortedResultRequest { filter = ''
filter = '' sorting = ''
sorting = '' reverse = false
reverse = false parentId?: string
parentId?: string layoutId?: string
layoutId?: string framework = ''
platformType?: PlatformType }
}
export class GetMenuByPaged extends PagedAndSortedResultRequestDto {
export class GetMenuByPaged extends PagedAndSortedResultRequestDto { filter = ''
filter = '' reverse = false
reverse = false layoutId?: string
layoutId?: string parentId?: string
parentId?: string framework = ''
platformType?: PlatformType }
}
export class Menu extends Route {
export class Menu extends Route { code!: string
code!: string layoutId!: string
layoutId!: string component!: string
component!: string framework = ''
platformType!: PlatformType parentId?: string
parentId?: string isPublic!: boolean
isPublic!: boolean children = new Array<Menu>()
children = new Array<Menu>() }
}
export class RoleMenu {
export class RoleMenu { roleName!: string
roleName!: string menuIds = new Array<string>()
menuIds = new Array<string>() }
}
export class UserMenu {
export class UserMenu { userId!: string
userId!: string menuIds = new Array<string>()
menuIds = new Array<string>() }
}

283
vueJs/src/store/modules/permission.ts

@ -1,142 +1,141 @@
import { VuexModule, Module, Mutation, Action, getModule } from 'vuex-module-decorators' import { VuexModule, Module, Mutation, Action, getModule } from 'vuex-module-decorators'
import { RouteConfig } from 'vue-router' import { RouteConfig } from 'vue-router'
// eslint-disable-next-line // eslint-disable-next-line
import { asyncRoutes, constantRoutes } from '@/router' import { asyncRoutes, constantRoutes } from '@/router'
import store from '@/store' import store from '@/store'
import { AbpModule } from '@/store/modules/abp' import { AbpModule } from '@/store/modules/abp'
import MenuService, { Menu } from '@/api/menu' import MenuService, { Menu } from '@/api/menu'
import { PlatformType } from '@/api/layout' import { generateTree } from '@/utils'
import { generateTree } from '@/utils'
const mapMetaBoolean = (key: string, meta: any) => {
const mapMetaBoolean = (key: string, meta: any) => { return typeof meta[key] === 'boolean' ? meta[key] : meta[key] === 'true'
return typeof meta[key] === 'boolean' ? meta[key] : meta[key] === 'true' }
}
const mapMetaArray = (key: string, meta: any) => {
const mapMetaArray = (key: string, meta: any) => { return Array.isArray(meta[key]) ? meta[key] : String(meta[key]).split(',')
return Array.isArray(meta[key]) ? meta[key] : String(meta[key]).split(',') }
}
const hasPermission = (roles: string[], route: RouteConfig) => {
const hasPermission = (roles: string[], route: RouteConfig) => { if (route.meta && route.meta.roles) {
if (route.meta && route.meta.roles) { return roles.some(role => route.meta.roles.includes(role))
return roles.some(role => route.meta.roles.includes(role)) } else {
} else { return true
return true }
} }
}
export const filterAsyncRoutes = (routes: RouteConfig[], roles: string[]) => {
export const filterAsyncRoutes = (routes: RouteConfig[], roles: string[]) => { const res: RouteConfig[] = []
const res: RouteConfig[] = [] routes.forEach(route => {
routes.forEach(route => { const r = { ...route }
const r = { ...route } if (hasPermission(roles, r)) {
if (hasPermission(roles, r)) { if (r.children) {
if (r.children) { r.children = filterAsyncRoutes(r.children, roles)
r.children = filterAsyncRoutes(r.children, roles) }
} res.push(r)
res.push(r) }
} })
}) return res
return res }
}
const filterDynamicRoutes = (menus: Menu[]) => {
const filterDynamicRoutes = (menus: Menu[]) => { const res: RouteConfig[] = []
const res: RouteConfig[] = []
menus.forEach(menu => {
menus.forEach(menu => { const r: RouteConfig = {
const r: RouteConfig = { path: menu.path,
path: menu.path, name: menu.name,
name: menu.name, redirect: menu.redirect,
redirect: menu.redirect, // meta自行转换
// meta自行转换 meta: {
meta: { activeMenu: menu.meta.activeMenu,
activeMenu: menu.meta.activeMenu, affix: mapMetaBoolean('affix', menu.meta), // 需要转换为正确的bool类型
affix: mapMetaBoolean('affix', menu.meta), // 需要转换为正确的bool类型 noCache: mapMetaBoolean('noCache', menu.meta),
noCache: mapMetaBoolean('noCache', menu.meta), breadcrumb: mapMetaBoolean('breadcrumb', menu.meta),
breadcrumb: mapMetaBoolean('breadcrumb', menu.meta), alwaysShow: mapMetaBoolean('alwaysShow', menu.meta),
alwaysShow: mapMetaBoolean('alwaysShow', menu.meta), hidden: mapMetaBoolean('hidden', menu.meta),
hidden: mapMetaBoolean('hidden', menu.meta), icon: menu.meta.icon,
icon: menu.meta.icon, title: menu.meta.title,
title: menu.meta.title, displayName: menu.displayName,
displayName: menu.displayName, roles: mapMetaArray('roles', menu.meta) // 需要转换为正确的array类型
roles: mapMetaArray('roles', menu.meta) // 需要转换为正确的array类型 },
}, component: resolve => require([`@/${menu.component}`], resolve) // 需要这种格式才可以正确加载动态路由
component: resolve => require([`@/${menu.component}`], resolve) // 需要这种格式才可以正确加载动态路由 }
} if (menu.children && menu.children.length > 0) {
if (menu.children && menu.children.length > 0) { r.children = filterDynamicRoutes(menu.children)
r.children = filterDynamicRoutes(menu.children) }
} res.push(r)
res.push(r) })
}) return res
return res }
}
export interface IPermissionState {
export interface IPermissionState { routes: RouteConfig[]
routes: RouteConfig[] dynamicRoutes: RouteConfig[]
dynamicRoutes: RouteConfig[] }
}
@Module({ dynamic: true, store, name: 'permission' })
@Module({ dynamic: true, store, name: 'permission' }) class Permission extends VuexModule implements IPermissionState {
class Permission extends VuexModule implements IPermissionState { public routes: RouteConfig[] = []
public routes: RouteConfig[] = [] public dynamicRoutes: RouteConfig[] = []
public dynamicRoutes: RouteConfig[] = [] public authorizedPermissions: string[] = []
public authorizedPermissions: string[] = []
@Mutation
@Mutation private SET_ROUTES(routes: RouteConfig[]) {
private SET_ROUTES(routes: RouteConfig[]) { this.routes = constantRoutes.concat(routes)
this.routes = constantRoutes.concat(routes) this.dynamicRoutes = routes
this.dynamicRoutes = routes }
}
@Mutation
@Mutation private SET_AUTHPERMISSIONS(permissions: Array<string>) {
private SET_AUTHPERMISSIONS(permissions: Array<string>) { this.authorizedPermissions = permissions
this.authorizedPermissions = permissions }
}
@Action
@Action public async RefreshPermissions() {
public async RefreshPermissions() { const authPermissions = new Array<string>()
const authPermissions = new Array<string>() const grantedPolicies = AbpModule.configuration.auth.grantedPolicies
const grantedPolicies = AbpModule.configuration.auth.grantedPolicies if (grantedPolicies) {
if (grantedPolicies) { Object.keys(grantedPolicies).forEach(key => {
Object.keys(grantedPolicies).forEach(key => { if (grantedPolicies[key]) {
if (grantedPolicies[key]) { authPermissions.push(key)
authPermissions.push(key) }
} })
}) }
} if (authPermissions.length === 0) {
if (authPermissions.length === 0) { // 防止没有任何权限无限刷新页面
// 防止没有任何权限无限刷新页面 this.SET_AUTHPERMISSIONS(['guest'])
this.SET_AUTHPERMISSIONS(['guest']) } else {
} else { this.SET_AUTHPERMISSIONS(authPermissions)
this.SET_AUTHPERMISSIONS(authPermissions) }
} }
}
@Action
@Action public async GenerateRoutes() {
public async GenerateRoutes() { await this.RefreshPermissions() // 保留授权
await this.RefreshPermissions() // 保留授权 // 没必要再针对admin角色授权,改成全部后台授权
// 没必要再针对admin角色授权,改成全部后台授权 // if (this.authorizedPermissions.includes('admin')) {
// if (this.authorizedPermissions.includes('admin')) { // accessedRoutes = asyncRoutes
// accessedRoutes = asyncRoutes // } else {
// } else { // accessedRoutes = filterAsyncRoutes(asyncRoutes, this.authorizedPermissions)
// accessedRoutes = filterAsyncRoutes(asyncRoutes, this.authorizedPermissions) // }
// }
// 取消注释用来启用后端动态路由配置
// 取消注释用来启用后端动态路由配置 const { items } = await MenuService.getMyMenuList('Vue Element Admin')
const { items } = await MenuService.getMyMenuList(PlatformType.WebMvvm) const dynamicRoutes = filterDynamicRoutes(generateTree(items))
const dynamicRoutes = filterDynamicRoutes(generateTree(items)) this.SET_ROUTES(dynamicRoutes)
this.SET_ROUTES(dynamicRoutes)
// 取消注释用来启用前端动态路由配置
// 取消注释用来启用前端动态路由配置 // const accessedRoutes = filterAsyncRoutes(asyncRoutes, this.authorizedPermissions)
// const accessedRoutes = filterAsyncRoutes(asyncRoutes, this.authorizedPermissions) // this.SET_ROUTES(accessedRoutes)
// this.SET_ROUTES(accessedRoutes) }
}
@Action ResetPermissions() {
@Action ResetPermissions() { this.SET_AUTHPERMISSIONS([])
this.SET_AUTHPERMISSIONS([]) }
}
@Action ResetRoutes() {
@Action ResetRoutes() { this.SET_ROUTES([])
this.SET_ROUTES([]) }
} }
}
export const PermissionModule = getModule(Permission)
export const PermissionModule = getModule(Permission)

408
vueJs/src/views/admin/data-dictionary/components/DataDictionaryTree.vue

@ -1,205 +1,203 @@
<template> <template>
<div> <div>
<el-card class="box-card"> <el-card class="box-card">
<div <div
slot="header" slot="header"
class="clearfix" class="clearfix"
> >
<span>{{ $t('AppPlatform.DisplayName:DataDictionary') }}</span> <span>{{ $t('AppPlatform.DisplayName:DataDictionary') }}</span>
<el-button <el-button
style="float: right;" style="float: right;"
type="primary" type="primary"
icon="ivu-icon ivu-icon-md-add" icon="ivu-icon ivu-icon-md-add"
@click="handleEditData('')" @click="handleEditData(null)"
> >
{{ $t('AppPlatform.Data:AddNew') }} {{ $t('AppPlatform.Data:AddNew') }}
</el-button> </el-button>
</div> </div>
<div> <div>
<el-tree <el-tree
ref="dataTree" ref="dataTree"
node-key="id" node-key="id"
:props="dataProps" :props="dataProps"
:data="datas" :data="datas"
draggable draggable
highlight-current highlight-current
default-expand-all default-expand-all
:expand-on-click-node="false" :expand-on-click-node="false"
icon-class="el-icon-arrow-right" icon-class="el-icon-arrow-right"
:allow-drag="handleAllowDrag" :allow-drag="handleAllowDrag"
:allow-drop="handleAllowDrop" :allow-drop="handleAllowDrop"
@node-drop="handleNodeDroped" @node-drop="handleNodeDroped"
@node-click="handleNodeClick" @node-click="handleNodeClick"
@node-contextmenu="onContextMenu" @node-contextmenu="onContextMenu"
/> />
</div> </div>
</el-card> </el-card>
<create-or-update-data-dialog <create-or-update-data-dialog
:is-edit="isEditData" :is-edit="isEditData"
:title="editDataTitle" :title="editDataTitle"
:show-dialog="showDataDialog" :show-dialog="showDataDialog"
:data-id="editDataId" :data-id="editDataId"
@closed="onDataDialogClosed" @closed="onDataDialogClosed"
/> />
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { checkPermission } from '@/utils/permission' import { checkPermission } from '@/utils/permission'
import { generateTree } from '@/utils/index' import { generateTree } from '@/utils/index'
import { Component, Mixins, Vue } from 'vue-property-decorator' import { Component, Mixins, Vue } from 'vue-property-decorator'
import LocalizationMiXin from '@/mixins/LocalizationMiXin' import LocalizationMiXin from '@/mixins/LocalizationMiXin'
import DataDictionaryService, { Data } from '@/api/data-dictionary' import DataDictionaryService, { Data } from '@/api/data-dictionary'
import CreateOrUpdateDataDialog from './CreateOrUpdateDataDialog.vue' import CreateOrUpdateDataDialog from './CreateOrUpdateDataDialog.vue'
const $contextmenu = Vue.prototype.$contextmenu const $contextmenu = Vue.prototype.$contextmenu
@Component({ @Component({
name: 'DataDictionaryTree', name: 'DataDictionaryTree',
components: { components: {
CreateOrUpdateDataDialog CreateOrUpdateDataDialog
}, },
data() { data() {
return { return {
dataProps: { dataProps: {
label: 'displayName', label: 'displayName',
children: 'children' children: 'children'
} }
} }
} }
}) })
export default class DataDictionaryTree extends Mixins(LocalizationMiXin) { export default class DataDictionaryTree extends Mixins(LocalizationMiXin) {
private showDataDialog = false private showDataDialog = false
private isEditData = false private isEditData = false
private editDataId = '' private editDataId: string | null = ''
private editDataTitle = '' private editDataTitle = ''
private datas = [] private datas = []
private currentEditNode = {} private currentEditNode = {}
mounted() { mounted() {
this.handleGetDatas() this.handleGetDatas()
} }
private handleGetDatas() { private handleGetDatas() {
DataDictionaryService DataDictionaryService
.getAll() .getAll()
.then(res => { .then(res => {
this.datas = generateTree(res.items) this.datas = generateTree(res.items)
}) })
} }
private onContextMenu(event: any, data: Data) { private onContextMenu(event: any, data: Data) {
$contextmenu({ $contextmenu({
items: [ items: [
{ {
label: this.l('AppPlatform.Data:Edit'), label: this.l('AppPlatform.Data:Edit'),
icon: 'el-icon-edit', icon: 'el-icon-edit',
disabled: !checkPermission(['Platform.DataDictionary.Update']), disabled: !checkPermission(['Platform.DataDictionary.Update']),
onClick: () => { onClick: () => {
this.handleEditData(data.id) this.handleEditData(data.id)
} }
}, },
{ {
label: this.l('AppPlatform.Data:AddNew'), label: this.l('AppPlatform.Data:AddNew'),
icon: 'ivu-icon ivu-icon-md-add', icon: 'ivu-icon ivu-icon-md-add',
disabled: !checkPermission(['Platform.DataDictionary.Create']), disabled: !checkPermission(['Platform.DataDictionary.Create']),
onClick: () => { onClick: () => {
this.handleEditData('') this.handleEditData(null)
} }
}, },
{ {
label: this.l('AppPlatform.Data:AppendItem'), label: this.l('AppPlatform.Data:AppendItem'),
disabled: !checkPermission(['Platform.DataDictionary.ManageItems']), disabled: !checkPermission(['Platform.DataDictionary.ManageItems']),
onClick: () => { onClick: () => {
this.$emit('onDataChecked', data.id) this.$emit('onDataChecked', data.id)
this.$events.emit('onCreateNewDataItem') this.$events.emit('onCreateNewDataItem')
} }
}, },
{ {
label: this.l('AppPlatform.Data:Delete'), label: this.l('AppPlatform.Data:Delete'),
icon: 'el-icon-delete', icon: 'el-icon-delete',
disabled: !checkPermission(['Platform.DataDictionary.Delete']), disabled: !checkPermission(['Platform.DataDictionary.Delete']),
onClick: () => { onClick: () => {
this.$confirm(this.l('AppPlatform.Data:WillDelete', { 0: data.displayName }), this.$confirm(this.l('AppPlatform.Data:WillDelete', { 0: data.displayName }),
this.l('AppPlatform.AreYouSure'), { this.l('AppPlatform.AreYouSure'), {
callback: (action) => { callback: (action) => {
if (action === 'confirm') { if (action === 'confirm') {
DataDictionaryService DataDictionaryService
.delete(data.id) .delete(data.id)
.then(() => { .then(() => {
this.handleGetDatas() this.handleGetDatas()
}) })
} }
} }
}) })
} }
} }
], ],
event, event,
customClass: 'context-menu', customClass: 'context-menu',
zIndex: 2, zIndex: 2,
minWidth: 150 minWidth: 150
}) })
} }
private onDataDialogClosed(changed: boolean) { private onDataDialogClosed(changed: boolean) {
this.showDataDialog = false this.showDataDialog = false
if (changed) { if (changed) {
this.handleGetDatas() this.handleGetDatas()
} }
} }
private handleEditData(dataId: string) { private handleEditData(dataId: string | null) {
this.editDataTitle = this.l('AppPlatform.Data:AddNew') this.editDataTitle = this.l('AppPlatform.Data:AddNew')
this.isEditData = false this.isEditData = false
if (dataId) { this.editDataId = dataId
this.editDataId = dataId if (dataId) {
this.isEditData = true this.isEditData = true
this.editDataTitle = this.l('AppPlatform.Data:Edit') this.editDataTitle = this.l('AppPlatform.Data:Edit')
} else { }
this.editDataId = '' this.showDataDialog = true
} }
this.showDataDialog = true
} private handleAllowDrag(draggingNode: any) {
return draggingNode.data.parentId !== undefined && draggingNode.data.parentId !== null
private handleAllowDrag(draggingNode: any) { }
return draggingNode.data.parentId !== undefined && draggingNode.data.parentId !== null
} private handleAllowDrop(draggingNode: any, dropNode: any) {
console.log(dropNode)
private handleAllowDrop(draggingNode: any, dropNode: any) { }
console.log(dropNode)
} private handleNodeDroped(draggingNode: any, dropNode: any) {
console.log(dropNode)
private handleNodeDroped(draggingNode: any, dropNode: any) { }
console.log(dropNode)
} private handleNodeClick(data: any) {
if (data.id !== undefined) {
private handleNodeClick(data: any) { this.$emit('onDataChecked', data.id)
if (data.id !== undefined) { }
this.$emit('onDataChecked', data.id) }
} }
} </script>
}
</script> <style lang="scss" scoped>
.custom-tree-node {
<style lang="scss" scoped> flex: 1;
.custom-tree-node { display: flex;
flex: 1; align-items: center;
display: flex; justify-content: space-between;
align-items: center; font-size: 14px;
justify-content: space-between; padding-right: 8px;
font-size: 14px; }
padding-right: 8px; .el-dropdown-link {
} cursor: pointer;
.el-dropdown-link { color: #409EFF;
cursor: pointer; }
color: #409EFF; .el-icon-arrow-down {
} font-size: 12px;
.el-icon-arrow-down { }
font-size: 12px; </style>
}
</style>

358
vueJs/src/views/admin/roles/components/ManageRoleMenuDialog.vue

@ -1,173 +1,185 @@
<template> <template>
<el-dialog <el-dialog
v-el-draggable-dialog v-el-draggable-dialog
width="800px" width="800px"
:title="$t('AppPlatform.Menu:Manage')" :title="$t('AppPlatform.Menu:Manage')"
:visible="showDialog" :visible="showDialog"
custom-class="modal-form" custom-class="modal-form"
:close-on-click-modal="false" :close-on-click-modal="false"
:close-on-press-escape="false" :close-on-press-escape="false"
:show-close="false" :show-close="false"
@close="onFormClosed" @close="onFormClosed"
> >
<el-form> <el-form>
<el-card> <el-card>
<el-form-item <el-form-item
label-width="120px" label-width="120px"
:label="$t('AppPlatform.DisplayName:PlatformType')" :label="$t('AppPlatform.DisplayName:UIFramework')"
> >
<el-select <el-select
v-model="getMenuQuery.platformType" v-model="getMenuQuery.framework"
style="width: 100%;" style="width: 100%;"
class="filter-item" class="filter-item"
clearable clearable
:placeholder="$t('pleaseSelectBy', {name: $t('AppPlatform.DisplayName:PlatformType')})" :placeholder="$t('pleaseSelectBy', {name: $t('AppPlatform.DisplayName:UIFramework')})"
@change="onPlatformTypeChanged" @change="onFrameworksChanged"
> >
<el-option <el-option
v-for="item in platformTypes" v-for="framework in uiFrameworks"
:key="item.key" :key="framework"
:label="item.key" :label="framework"
:value="item.value" :value="framework"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
label-width="120px" label-width="120px"
:label="$t('AppPlatform.DisplayName:Menus')" :label="$t('AppPlatform.DisplayName:Menus')"
> >
<el-tree <el-tree
ref="roleMenuTree" ref="roleMenuTree"
show-checkbox show-checkbox
:check-strictly="true" :check-strictly="true"
node-key="id" node-key="id"
:data="menus" :data="menus"
:props="menuProps" :props="menuProps"
:default-checked-keys="roleMenuIds" :default-checked-keys="roleMenuIds"
/> />
</el-form-item> </el-form-item>
</el-card> </el-card>
<el-form-item> <el-form-item>
<el-button <el-button
class="cancel" class="cancel"
type="info" type="info"
style="width:100px" style="width:100px"
@click="onFormClosed" @click="onFormClosed"
> >
{{ $t('AbpUi.Cancel') }} {{ $t('AbpUi.Cancel') }}
</el-button> </el-button>
<el-button <el-button
class="confirm" class="confirm"
type="primary" type="primary"
style="width:100px" style="width:100px"
icon="el-icon-check" icon="el-icon-check"
:loading="confirmButtonBusy" :loading="confirmButtonBusy"
@click="onSave" @click="onSave"
> >
{{ confirmButtonTitle }} {{ confirmButtonTitle }}
</el-button> </el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-dialog> </el-dialog>
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Mixins, Prop, Watch } from 'vue-property-decorator' import { Component, Mixins, Prop, Watch } from 'vue-property-decorator'
import LocalizationMiXin from '@/mixins/LocalizationMiXin' import LocalizationMiXin from '@/mixins/LocalizationMiXin'
import MenuService, { Menu, GetAllMenu, RoleMenu } from '@/api/menu' import DataService from '@/api/data-dictionary'
import { generateTree } from '@/utils' import MenuService, { Menu, GetAllMenu, RoleMenu } from '@/api/menu'
import { PlatformType, PlatformTypes } from '@/api/layout' import { generateTree } from '@/utils'
import { Tree } from 'element-ui' import { Tree } from 'element-ui'
@Component({ @Component({
name: 'ManageRoleMenuDialog' name: 'ManageRoleMenuDialog'
}) })
export default class ManageRoleMenuDialog extends Mixins(LocalizationMiXin) { export default class ManageRoleMenuDialog extends Mixins(LocalizationMiXin) {
@Prop({ default: false }) @Prop({ default: false })
private showDialog!: boolean private showDialog!: boolean
@Prop({ default: '' }) @Prop({ default: '' })
private roleName!: string private roleName!: string
private menus = new Array<Menu>() private menus = new Array<Menu>()
private roleMenuIds = new Array<string>() private roleMenuIds = new Array<string>()
private getMenuQuery = new GetAllMenu() private getMenuQuery = new GetAllMenu()
private platformTypes = PlatformTypes private uiFrameworks: string[] = []
private confirmButtonBusy = false private confirmButtonBusy = false
private menuProps = { private menuProps = {
children: 'children', children: 'children',
label: 'displayName' label: 'displayName'
} }
get confirmButtonTitle() { get confirmButtonTitle() {
if (this.confirmButtonBusy) { if (this.confirmButtonBusy) {
return this.$t('AbpUi.SavingWithThreeDot') return this.$t('AbpUi.SavingWithThreeDot')
} }
return this.$t('AbpUi.Save') return this.$t('AbpUi.Save')
} }
@Watch('showDialog', { immediate: true }) @Watch('showDialog', { immediate: true })
private onShowDialogChanged() { private onShowDialogChanged() {
this.handleGetRoleMenus() this.handleGetRoleMenus()
} }
private onPlatformTypeChanged() { monted() {
this.handleGetMenus() this.getUIFrameworks()
this.handleGetRoleMenus() }
}
private onFrameworksChanged() {
private handleGetMenus() { this.handleGetMenus()
MenuService this.handleGetRoleMenus()
.getAll(this.getMenuQuery) }
.then(res => {
this.menus = generateTree(res.items) private getUIFrameworks() {
}) DataService
} .getByName('UI Framewark')
.then(res => {
private handleGetRoleMenus() { this.uiFrameworks = res.items.map(item => item.name)
if (this.showDialog && this.roleName) { })
MenuService }
.getRoleMenuList(this.roleName, this.getMenuQuery.platformType || PlatformType.None)
.then(res => { private handleGetMenus() {
this.roleMenuIds = res.items.map(item => item.id) MenuService
}) .getAll(this.getMenuQuery)
} else { .then(res => {
this.roleMenuIds.length = 0 this.menus = generateTree(res.items)
} })
} }
private onSave() { private handleGetRoleMenus() {
const roleMenuTree = this.$refs.roleMenuTree as Tree if (this.showDialog && this.roleName) {
const roleMenu = new RoleMenu() MenuService
roleMenu.roleName = this.roleName .getRoleMenuList(this.roleName, this.getMenuQuery.framework)
roleMenu.menuIds = roleMenuTree.getCheckedKeys() .then(res => {
MenuService this.roleMenuIds = res.items.map(item => item.id)
.setRoleMenu(roleMenu) })
.then(() => { } else {
this.$message.success(this.l('successful')) this.roleMenuIds.length = 0
this.onFormClosed() }
}) }
}
private onSave() {
private onFormClosed() { const roleMenuTree = this.$refs.roleMenuTree as Tree
this.$nextTick(() => { const roleMenu = new RoleMenu()
const tree = this.$refs.roleMenuTree as Tree roleMenu.roleName = this.roleName
tree.setCheckedKeys([]) roleMenu.menuIds = roleMenuTree.getCheckedKeys()
}) MenuService
this.$emit('closed') .setRoleMenu(roleMenu)
} .then(() => {
} this.$message.success(this.l('successful'))
</script> this.onFormClosed()
})
<style lang="scss" scoped> }
.confirm {
position: absolute; private onFormClosed() {
margin-top: 10px; this.$nextTick(() => {
right: 0px; const tree = this.$refs.roleMenuTree as Tree
} tree.setCheckedKeys([])
.cancel { })
position: absolute; this.$emit('closed')
margin-top: 10px; }
right: 120px; }
} </script>
</style>
<style lang="scss" scoped>
.confirm {
position: absolute;
margin-top: 10px;
right: 0px;
}
.cancel {
position: absolute;
margin-top: 10px;
right: 120px;
}
</style>

716
vueJs/src/views/admin/roles/index.vue

@ -1,358 +1,358 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<div class="filter-container"> <div class="filter-container">
<el-button <el-button
class="filter-item" class="filter-item"
style="margin-left: 10px; text-alignt" style="margin-left: 10px;"
type="primary" type="primary"
@click="refreshPagedData" @click="refreshPagedData"
> >
{{ $t('roles.refreshList') }} {{ $t('roles.refreshList') }}
</el-button> </el-button>
<el-button <el-button
class="filter-item" class="filter-item"
type="primary" type="primary"
:disabled="!checkPermission(['AbpIdentity.Roles.Create'])" :disabled="!checkPermission(['AbpIdentity.Roles.Create'])"
@click="handleCreateRole" @click="handleCreateRole"
> >
{{ $t('roles.createRole') }} {{ $t('roles.createRole') }}
</el-button> </el-button>
</div> </div>
<el-table <el-table
v-loading="dataLoading" v-loading="dataLoading"
row-key="id" row-key="id"
:data="dataList" :data="dataList"
border border
fit fit
highlight-current-row highlight-current-row
style="width: 100%;" style="width: 100%;"
size="small" size="small"
> >
<el-table-column <el-table-column
:label="$t('roles.id')" :label="$t('roles.id')"
prop="id" prop="id"
sortable sortable
width="300px" width="300px"
align="center" align="center"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.id }}</span> <span>{{ row.id }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('roles.name')" :label="$t('roles.name')"
prop="name" prop="name"
sortable sortable
width="350px" width="350px"
min-width="350px" min-width="350px"
align="center" align="center"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.name }}</span> <span>{{ row.name }}</span>
<el-tag <el-tag
v-if="row.isDefault" v-if="row.isDefault"
type="success" type="success"
> >
{{ $t('roles.isDefault') }} {{ $t('roles.isDefault') }}
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('roles.isPublic')" :label="$t('roles.isPublic')"
prop="isPublic" prop="isPublic"
width="200px" width="200px"
align="center" align="center"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<el-tag <el-tag
:type="row.isPublic ? 'success' : 'warning'" :type="row.isPublic ? 'success' : 'warning'"
> >
{{ row.isPublic ? $t('roles.isPublic') : $t('roles.isPrivate') }} {{ row.isPublic ? $t('roles.isPublic') : $t('roles.isPrivate') }}
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('roles.type')" :label="$t('roles.type')"
prop="isStatic" prop="isStatic"
width="200px" width="200px"
align="center" align="center"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<el-tag <el-tag
:type="row.isStatic ? 'info' : 'success'" :type="row.isStatic ? 'info' : 'success'"
> >
{{ row.isStatic ? $t('roles.system') : $t('roles.custom') }} {{ row.isStatic ? $t('roles.system') : $t('roles.custom') }}
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('roles.operaActions')" :label="$t('roles.operaActions')"
align="center" align="center"
width="250px" width="250px"
min-width="250px" min-width="250px"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<el-button <el-button
:disabled="!checkPermission(['AbpIdentity.Roles.Update'])" :disabled="!checkPermission(['AbpIdentity.Roles.Update'])"
size="mini" size="mini"
type="primary" type="primary"
@click="handleEditRole(row)" @click="handleEditRole(row)"
> >
{{ $t('roles.updateRole') }} {{ $t('roles.updateRole') }}
</el-button> </el-button>
<el-dropdown <el-dropdown
class="options" class="options"
@command="handleCommand" @command="handleCommand"
> >
<el-button <el-button
v-permission="['AbpIdentity.Roles']" v-permission="['AbpIdentity.Roles']"
size="mini" size="mini"
type="info" type="info"
> >
{{ $t('roles.otherOpera') }}<i class="el-icon-arrow-down el-icon--right" /> {{ $t('roles.otherOpera') }}<i class="el-icon-arrow-down el-icon--right" />
</el-button> </el-button>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item <el-dropdown-item
:command="{key: 'claim', row}" :command="{key: 'claim', row}"
:disabled="!checkPermission(['AbpIdentity.Roles.ManageClaims'])" :disabled="!checkPermission(['AbpIdentity.Roles.ManageClaims'])"
> >
{{ $t('AbpIdentity.ManageClaim') }} {{ $t('AbpIdentity.ManageClaim') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
:command="{key: 'menu', row}" :command="{key: 'menu', row}"
:disabled="!checkPermission(['Platform.Menu.ManageRoles'])" :disabled="!checkPermission(['Platform.Menu.ManageRoles'])"
> >
{{ $t('AppPlatform.Menu:Manage') }} {{ $t('AppPlatform.Menu:Manage') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
:command="{key: 'permission', row}" :command="{key: 'permission', row}"
:disabled="!checkPermission(['AbpIdentity.Roles.ManagePermissions'])" :disabled="!checkPermission(['AbpIdentity.Roles.ManagePermissions'])"
> >
{{ $t('AbpIdentity.Permissions') }} {{ $t('AbpIdentity.Permissions') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
:command="row.isDefault ? {key: 'unDefault', row} : {key: 'default', row}" :command="row.isDefault ? {key: 'unDefault', row} : {key: 'default', row}"
:disabled="row.isStatic || !checkPermission(['AbpIdentity.Roles.Update'])" :disabled="row.isStatic || !checkPermission(['AbpIdentity.Roles.Update'])"
> >
{{ row.isDefault ? $t('roles.unSetDefault') : $t('roles.setDefault') }} {{ row.isDefault ? $t('roles.unSetDefault') : $t('roles.setDefault') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
divided divided
:command="{key: 'delete', row}" :command="{key: 'delete', row}"
:disabled="row.isStatic || !checkPermission(['AbpIdentity.Roles.Delete'])" :disabled="row.isStatic || !checkPermission(['AbpIdentity.Roles.Delete'])"
> >
{{ $t('roles.deleteRole') }} {{ $t('roles.deleteRole') }}
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination <pagination
v-show="dataTotal>0" v-show="dataTotal>0"
:total="dataTotal" :total="dataTotal"
:page.sync="currentPage" :page.sync="currentPage"
:limit.sync="pageSize" :limit.sync="pageSize"
@pagination="refreshPagedData" @pagination="refreshPagedData"
/> />
<role-edit-form <role-edit-form
:show-dialog="showEditDialog" :show-dialog="showEditDialog"
:role-id="editRoleId" :role-id="editRoleId"
@closed="onEditRoleFormClosed" @closed="onEditRoleFormClosed"
/> />
<role-create-form <role-create-form
:show-dialog="showCreateDialog" :show-dialog="showCreateDialog"
@closed="onCreateDialogClosed" @closed="onCreateDialogClosed"
/> />
<role-claim-create-or-update-form <role-claim-create-or-update-form
:show-dialog="showClaimDialog" :show-dialog="showClaimDialog"
:role-id="editRoleId" :role-id="editRoleId"
@closed="onClaimDialogClosed" @closed="onClaimDialogClosed"
/> />
<manage-role-menu-dialog <manage-role-menu-dialog
:show-dialog="showManageRoleMenuDialog" :show-dialog="showManageRoleMenuDialog"
:role-name="editRoleName" :role-name="editRoleName"
@closed="showManageRoleMenuDialog=false" @closed="showManageRoleMenuDialog=false"
/> />
<permission-form <permission-form
provider-name="R" provider-name="R"
:provider-key="editRoleName" :provider-key="editRoleName"
:readonly="!checkPermission(['AbpIdentity.Roles.ManagePermissions'])" :readonly="!checkPermission(['AbpIdentity.Roles.ManagePermissions'])"
:show-dialog="showPermissionDialog" :show-dialog="showPermissionDialog"
@closed="onPermissionDialogClosed" @closed="onPermissionDialogClosed"
/> />
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { abpPagerFormat } from '@/utils' import { abpPagerFormat } from '@/utils'
import DataListMiXin from '@/mixins/DataListMiXin' import DataListMiXin from '@/mixins/DataListMiXin'
import Component, { mixins } from 'vue-class-component' import Component, { mixins } from 'vue-class-component'
import RoleService, { RoleDto, UpdateRoleDto, RoleGetPagedDto } from '@/api/roles' import RoleService, { RoleDto, UpdateRoleDto, RoleGetPagedDto } from '@/api/roles'
import { checkPermission } from '@/utils/permission' import { checkPermission } from '@/utils/permission'
import Pagination from '@/components/Pagination/index.vue' import Pagination from '@/components/Pagination/index.vue'
import PermissionForm from '@/components/PermissionForm/index.vue' import PermissionForm from '@/components/PermissionForm/index.vue'
import RoleEditForm from './components/RoleEditForm.vue' import RoleEditForm from './components/RoleEditForm.vue'
import RoleCreateForm from './components/RoleCreateForm.vue' import RoleCreateForm from './components/RoleCreateForm.vue'
import ManageRoleMenuDialog from './components/ManageRoleMenuDialog.vue' import ManageRoleMenuDialog from './components/ManageRoleMenuDialog.vue'
import RoleClaimCreateOrUpdateForm from './components/RoleClaimCreateOrUpdateForm.vue' import RoleClaimCreateOrUpdateForm from './components/RoleClaimCreateOrUpdateForm.vue'
@Component({ @Component({
name: 'RoleList', name: 'RoleList',
components: { components: {
PermissionForm, PermissionForm,
Pagination, Pagination,
RoleEditForm, RoleEditForm,
RoleCreateForm, RoleCreateForm,
ManageRoleMenuDialog, ManageRoleMenuDialog,
RoleClaimCreateOrUpdateForm RoleClaimCreateOrUpdateForm
}, },
methods: { methods: {
checkPermission checkPermission
} }
}) })
export default class extends mixins(DataListMiXin) { export default class extends mixins(DataListMiXin) {
private showEditDialog = false private showEditDialog = false
private showManageRoleMenuDialog = false private showManageRoleMenuDialog = false
private editRoleId = '' private editRoleId = ''
private showClaimDialog = false private showClaimDialog = false
private showCreateDialog = false private showCreateDialog = false
private editRoleName = '' private editRoleName = ''
private showPermissionDialog = false private showPermissionDialog = false
public dataFilter = new RoleGetPagedDto() public dataFilter = new RoleGetPagedDto()
mounted() { mounted() {
this.refreshPagedData() this.refreshPagedData()
} }
protected processDataFilter() { protected processDataFilter() {
this.dataFilter.skipCount = abpPagerFormat(this.currentPage, this.pageSize) this.dataFilter.skipCount = abpPagerFormat(this.currentPage, this.pageSize)
} }
/** 获取角色权限列表 */ /** 获取角色权限列表 */
protected getPagedList(filter: any) { protected getPagedList(filter: any) {
return RoleService.getRoles(filter) return RoleService.getRoles(filter)
} }
/** 响应角色行操作事件 */ /** 响应角色行操作事件 */
private handleCommand(command: {key: string, row: RoleDto}) { private handleCommand(command: {key: string, row: RoleDto}) {
switch (command.key) { switch (command.key) {
case 'claim' : case 'claim' :
this.handleShowCliamDialog(command.row) this.handleShowCliamDialog(command.row)
break break
case 'permission' : case 'permission' :
this.handleShowPermissionDialog(command.row) this.handleShowPermissionDialog(command.row)
break break
case 'default' : case 'default' :
this.handleSetDefaultRole(command.row, true) this.handleSetDefaultRole(command.row, true)
break break
case 'unDefault' : case 'unDefault' :
this.handleSetDefaultRole(command.row, false) this.handleSetDefaultRole(command.row, false)
break break
case 'delete' : case 'delete' :
this.handleDeleteRole(command.row) this.handleDeleteRole(command.row)
break break
case 'menu' : case 'menu' :
this.editRoleName = command.row.name this.editRoleName = command.row.name
this.showManageRoleMenuDialog = true this.showManageRoleMenuDialog = true
break break
default: break default: break
} }
} }
/** 新建角色 */ /** 新建角色 */
private handleCreateRole() { private handleCreateRole() {
this.showCreateDialog = true this.showCreateDialog = true
} }
private handleEditRole(role: RoleDto) { private handleEditRole(role: RoleDto) {
this.editRoleId = role.id this.editRoleId = role.id
this.showEditDialog = true this.showEditDialog = true
} }
private handleShowCliamDialog(row: RoleDto) { private handleShowCliamDialog(row: RoleDto) {
this.editRoleId = row.id this.editRoleId = row.id
this.showClaimDialog = true this.showClaimDialog = true
} }
private handleShowPermissionDialog(row: RoleDto) { private handleShowPermissionDialog(row: RoleDto) {
this.editRoleName = row.name this.editRoleName = row.name
this.showPermissionDialog = true this.showPermissionDialog = true
} }
private onPermissionDialogClosed() { private onPermissionDialogClosed() {
this.showPermissionDialog = false this.showPermissionDialog = false
} }
private onClaimDialogClosed() { private onClaimDialogClosed() {
this.showClaimDialog = false this.showClaimDialog = false
} }
private onCreateDialogClosed(changed: boolean) { private onCreateDialogClosed(changed: boolean) {
this.showCreateDialog = false this.showCreateDialog = false
if (changed) { if (changed) {
this.refreshPagedData() this.refreshPagedData()
} }
} }
/** 设置默认角色 */ /** 设置默认角色 */
private handleSetDefaultRole(role: RoleDto, setDefault: boolean) { private handleSetDefaultRole(role: RoleDto, setDefault: boolean) {
// console.log('handleSetDefaultRole:' + role.id) // console.log('handleSetDefaultRole:' + role.id)
const setDefaultRoleDto = new UpdateRoleDto() const setDefaultRoleDto = new UpdateRoleDto()
setDefaultRoleDto.name = role.name setDefaultRoleDto.name = role.name
setDefaultRoleDto.isDefault = setDefault setDefaultRoleDto.isDefault = setDefault
setDefaultRoleDto.concurrencyStamp = role.concurrencyStamp setDefaultRoleDto.concurrencyStamp = role.concurrencyStamp
RoleService.updateRole(role.id, setDefaultRoleDto).then(role => { RoleService.updateRole(role.id, setDefaultRoleDto).then(role => {
this.$message.success(this.l('roles.roleHasBeenSetDefault', { name: role.name })) this.$message.success(this.l('roles.roleHasBeenSetDefault', { name: role.name }))
this.refreshPagedData() this.refreshPagedData()
}) })
} }
/** 删除角色 */ /** 删除角色 */
private handleDeleteRole(role: RoleDto) { private handleDeleteRole(role: RoleDto) {
this.$confirm(this.l('roles.delNotRecoverData'), this.$confirm(this.l('roles.delNotRecoverData'),
this.l('roles.whetherDeleteRole', { name: role.name }), { this.l('roles.whetherDeleteRole', { name: role.name }), {
callback: (action) => { callback: (action) => {
if (action === 'confirm') { if (action === 'confirm') {
RoleService.deleteRole(role.id).then(() => { RoleService.deleteRole(role.id).then(() => {
this.$message.success(this.l('roles.roleHasBeenDeleted', { name: role.name })) this.$message.success(this.l('roles.roleHasBeenDeleted', { name: role.name }))
this.refreshPagedData() this.refreshPagedData()
}) })
} }
} }
}) })
} }
private onEditRoleFormClosed(changed: boolean) { private onEditRoleFormClosed(changed: boolean) {
this.showEditDialog = false this.showEditDialog = false
if (changed) { if (changed) {
this.refreshPagedData() this.refreshPagedData()
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.roleItem { .roleItem {
width: 40px; width: 40px;
} }
.options { .options {
vertical-align: top; vertical-align: top;
margin-left: 20px; margin-left: 20px;
} }
.el-dropdown + .el-dropdown { .el-dropdown + .el-dropdown {
margin-left: 15px; margin-left: 15px;
} }
.el-icon-arrow-down { .el-icon-arrow-down {
font-size: 12px; font-size: 12px;
} }
</style> </style>

358
vueJs/src/views/admin/users/components/ManageUserMenuDialog.vue

@ -1,173 +1,185 @@
<template> <template>
<el-dialog <el-dialog
v-el-draggable-dialog v-el-draggable-dialog
width="800px" width="800px"
:title="$t('AppPlatform.Menu:Manage')" :title="$t('AppPlatform.Menu:Manage')"
:visible="showDialog" :visible="showDialog"
custom-class="modal-form" custom-class="modal-form"
:close-on-click-modal="false" :close-on-click-modal="false"
:close-on-press-escape="false" :close-on-press-escape="false"
:show-close="false" :show-close="false"
@close="onFormClosed" @close="onFormClosed"
> >
<el-form> <el-form>
<el-card> <el-card>
<el-form-item <el-form-item
label-width="120px" label-width="120px"
:label="$t('AppPlatform.DisplayName:PlatformType')" :label="$t('AppPlatform.DisplayName:UIFramework')"
> >
<el-select <el-select
v-model="getMenuQuery.platformType" v-model="getMenuQuery.framework"
style="width: 100%;" style="width: 100%;"
class="filter-item" class="filter-item"
clearable clearable
:placeholder="$t('pleaseSelectBy', {name: $t('AppPlatform.DisplayName:PlatformType')})" :placeholder="$t('pleaseSelectBy', {name: $t('AppPlatform.DisplayName:UIFramework')})"
@change="onPlatformTypeChanged" @change="onFrameworkChanged"
> >
<el-option <el-option
v-for="item in platformTypes" v-for="framework in uiFrameworks"
:key="item.key" :key="framework"
:label="item.key" :label="framework"
:value="item.value" :value="framework"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
label-width="120px" label-width="120px"
:label="$t('AppPlatform.DisplayName:Menus')" :label="$t('AppPlatform.DisplayName:Menus')"
> >
<el-tree <el-tree
ref="userMenuTree" ref="userMenuTree"
show-checkbox show-checkbox
:check-strictly="true" :check-strictly="true"
node-key="id" node-key="id"
:data="menus" :data="menus"
:props="menuProps" :props="menuProps"
:default-checked-keys="userMenuIds" :default-checked-keys="userMenuIds"
/> />
</el-form-item> </el-form-item>
</el-card> </el-card>
<el-form-item> <el-form-item>
<el-button <el-button
class="cancel" class="cancel"
type="info" type="info"
style="width:100px" style="width:100px"
@click="onFormClosed" @click="onFormClosed"
> >
{{ $t('AbpUi.Cancel') }} {{ $t('AbpUi.Cancel') }}
</el-button> </el-button>
<el-button <el-button
class="confirm" class="confirm"
type="primary" type="primary"
style="width:100px" style="width:100px"
icon="el-icon-check" icon="el-icon-check"
:loading="confirmButtonBusy" :loading="confirmButtonBusy"
@click="onSave" @click="onSave"
> >
{{ confirmButtonTitle }} {{ confirmButtonTitle }}
</el-button> </el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-dialog> </el-dialog>
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Mixins, Prop, Watch } from 'vue-property-decorator' import { Component, Mixins, Prop, Watch } from 'vue-property-decorator'
import LocalizationMiXin from '@/mixins/LocalizationMiXin' import LocalizationMiXin from '@/mixins/LocalizationMiXin'
import MenuService, { Menu, GetAllMenu, UserMenu } from '@/api/menu' import DataService from '@/api/data-dictionary'
import { generateTree } from '@/utils' import MenuService, { Menu, GetAllMenu, UserMenu } from '@/api/menu'
import { PlatformType, PlatformTypes } from '@/api/layout' import { generateTree } from '@/utils'
import { Tree } from 'element-ui' import { Tree } from 'element-ui'
@Component({ @Component({
name: 'ManageUserMenuDialog' name: 'ManageUserMenuDialog'
}) })
export default class ManageUserMenuDialog extends Mixins(LocalizationMiXin) { export default class ManageUserMenuDialog extends Mixins(LocalizationMiXin) {
@Prop({ default: false }) @Prop({ default: false })
private showDialog!: boolean private showDialog!: boolean
@Prop({ default: '' }) @Prop({ default: '' })
private userId!: string private userId!: string
private menus = new Array<Menu>() private menus = new Array<Menu>()
private userMenuIds = new Array<string>() private uiFrameworks: string[] = []
private getMenuQuery = new GetAllMenu() private userMenuIds = new Array<string>()
private platformTypes = PlatformTypes private getMenuQuery = new GetAllMenu()
private confirmButtonBusy = false private confirmButtonBusy = false
private menuProps = { private menuProps = {
children: 'children', children: 'children',
label: 'displayName' label: 'displayName'
} }
get confirmButtonTitle() { get confirmButtonTitle() {
if (this.confirmButtonBusy) { if (this.confirmButtonBusy) {
return this.l('AbpUi.SavingWithThreeDot') return this.l('AbpUi.SavingWithThreeDot')
} }
return this.l('AbpUi.Save') return this.l('AbpUi.Save')
} }
@Watch('showDialog', { immediate: true }) @Watch('showDialog', { immediate: true })
private onShowDialogChanged() { private onShowDialogChanged() {
this.handleGetUserMenus() this.handleGetUserMenus()
} }
private onPlatformTypeChanged() { monted() {
this.handleGetMenus() this.getUIFrameworks()
this.handleGetUserMenus() }
}
private onFrameworkChanged() {
private handleGetMenus() { this.handleGetMenus()
MenuService this.handleGetUserMenus()
.getAll(this.getMenuQuery) }
.then(res => {
this.menus = generateTree(res.items) private getUIFrameworks() {
}) DataService
} .getByName('UI Framewark')
.then(res => {
private handleGetUserMenus() { this.uiFrameworks = res.items.map(item => item.name)
if (this.showDialog && this.userId) { })
MenuService }
.getUserMenuList(this.userId, this.getMenuQuery.platformType || PlatformType.None)
.then(res => { private handleGetMenus() {
this.userMenuIds = res.items.map(item => item.id) MenuService
}) .getAll(this.getMenuQuery)
} else { .then(res => {
this.userMenuIds.length = 0 this.menus = generateTree(res.items)
} })
} }
private onSave() { private handleGetUserMenus() {
const userMenuTree = this.$refs.userMenuTree as Tree if (this.showDialog && this.userId) {
const userMenu = new UserMenu() MenuService
userMenu.userId = this.userId .getUserMenuList(this.userId, this.getMenuQuery.framework)
userMenu.menuIds = userMenuTree.getCheckedKeys() .then(res => {
MenuService this.userMenuIds = res.items.map(item => item.id)
.setUserMenu(userMenu) })
.then(() => { } else {
this.$message.success(this.l('successful')) this.userMenuIds.length = 0
this.onFormClosed() }
}) }
}
private onSave() {
private onFormClosed() { const userMenuTree = this.$refs.userMenuTree as Tree
this.$nextTick(() => { const userMenu = new UserMenu()
const tree = this.$refs.userMenuTree as Tree userMenu.userId = this.userId
tree.setCheckedKeys([]) userMenu.menuIds = userMenuTree.getCheckedKeys()
}) MenuService
this.$emit('closed') .setUserMenu(userMenu)
} .then(() => {
} this.$message.success(this.l('successful'))
</script> this.onFormClosed()
})
<style lang="scss" scoped> }
.confirm {
position: absolute; private onFormClosed() {
margin-top: 10px; this.$nextTick(() => {
right: 0px; const tree = this.$refs.userMenuTree as Tree
} tree.setCheckedKeys([])
.cancel { })
position: absolute; this.$emit('closed')
margin-top: 10px; }
right: 120px; }
} </script>
</style>
<style lang="scss" scoped>
.confirm {
position: absolute;
margin-top: 10px;
right: 0px;
}
.cancel {
position: absolute;
margin-top: 10px;
right: 120px;
}
</style>

746
vueJs/src/views/admin/users/index.vue

@ -1,373 +1,373 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<div class="filter-container"> <div class="filter-container">
<label <label
class="radio-label" class="radio-label"
style="padding-left:0;" style="padding-left:0;"
>{{ $t('users.queryFilter') }}</label> >{{ $t('users.queryFilter') }}</label>
<el-input <el-input
v-model="dataFilter.filter" v-model="dataFilter.filter"
:placeholder="$t('users.filterString')" :placeholder="$t('users.filterString')"
style="width: 250px;margin-left: 10px;" style="width: 250px;margin-left: 10px;"
class="filter-item" class="filter-item"
/> />
<el-button <el-button
class="filter-item" class="filter-item"
style="margin-left: 10px; text-alignt" style="margin-left: 10px;"
type="primary" type="primary"
@click="refreshPagedData" @click="refreshPagedData"
> >
{{ $t('AbpIdentity.Search') }} {{ $t('AbpIdentity.Search') }}
</el-button> </el-button>
<el-button <el-button
class="filter-item" class="filter-item"
type="primary" type="primary"
:disabled="!checkPermission(['AbpIdentity.Users.Create'])" :disabled="!checkPermission(['AbpIdentity.Users.Create'])"
@click="handleShowUserDialog('')" @click="handleShowUserDialog('')"
> >
{{ $t('AbpIdentity.NewUser') }} {{ $t('AbpIdentity.NewUser') }}
</el-button> </el-button>
</div> </div>
<el-table <el-table
v-loading="dataLoading" v-loading="dataLoading"
row-key="id" row-key="id"
:data="dataList" :data="dataList"
border border
fit fit
highlight-current-row highlight-current-row
style="width: 100%;" style="width: 100%;"
@sort-change="handleSortChange" @sort-change="handleSortChange"
> >
<el-table-column <el-table-column
:label="$t('AbpIdentity.DisplayName:UserName')" :label="$t('AbpIdentity.DisplayName:UserName')"
prop="userName" prop="userName"
sortable sortable
width="110px" width="110px"
align="center" align="center"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.userName }}</span> <span>{{ row.userName }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('AbpIdentity.DisplayName:Surname')" :label="$t('AbpIdentity.DisplayName:Surname')"
prop="surname" prop="surname"
width="110px" width="110px"
align="center" align="center"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.surname }}</span> <span>{{ row.surname }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('AbpIdentity.DisplayName:Name')" :label="$t('AbpIdentity.DisplayName:Name')"
prop="name" prop="name"
width="110px" width="110px"
align="center" align="center"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.name }}</span> <span>{{ row.name }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('AbpIdentity.DisplayName:Email')" :label="$t('AbpIdentity.DisplayName:Email')"
prop="email" prop="email"
sortable sortable
min-width="180" min-width="180"
align="center" align="center"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.email }}</span> <span>{{ row.email }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('AbpIdentity.DisplayName:PhoneNumber')" :label="$t('AbpIdentity.DisplayName:PhoneNumber')"
prop="phoneNumber" prop="phoneNumber"
width="140px" width="140px"
align="center" align="center"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.phoneNumber }}</span> <span>{{ row.phoneNumber }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('AbpIdentity.LockoutEnd')" :label="$t('AbpIdentity.LockoutEnd')"
prop="lockoutEnd" prop="lockoutEnd"
sortable sortable
width="140px" width="140px"
align="center" align="center"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.lockoutEnd | dateTimeFilter }}</span> <span>{{ row.lockoutEnd | dateTimeFilter }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('AbpIdentity.CreationTime')" :label="$t('AbpIdentity.CreationTime')"
prop="creationTime" prop="creationTime"
sortable sortable
width="140px" width="140px"
align="center" align="center"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.creationTime | dateTimeFilter }}</span> <span>{{ row.creationTime | dateTimeFilter }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('AbpIdentity.Actions')" :label="$t('AbpIdentity.Actions')"
align="center" align="center"
width="250px" width="250px"
min-width="250px" min-width="250px"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<el-button <el-button
:disabled="!checkPermission(['AbpIdentity.Users.Update'])" :disabled="!checkPermission(['AbpIdentity.Users.Update'])"
size="mini" size="mini"
type="primary" type="primary"
icon="el-icon-edit" icon="el-icon-edit"
@click="handleShowUserDialog(row.id)" @click="handleShowUserDialog(row.id)"
> >
{{ $t('AbpIdentity.Edit') }} {{ $t('AbpIdentity.Edit') }}
</el-button> </el-button>
<el-dropdown <el-dropdown
class="options" class="options"
@command="handleCommand" @command="handleCommand"
> >
<el-button <el-button
v-permission="['AbpIdentity.Users']" v-permission="['AbpIdentity.Users']"
size="mini" size="mini"
type="info" type="info"
> >
{{ $t('AbpIdentity.Actions') }}<i class="el-icon-arrow-down el-icon--right" /> {{ $t('AbpIdentity.Actions') }}<i class="el-icon-arrow-down el-icon--right" />
</el-button> </el-button>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item <el-dropdown-item
:command="{key: 'permission', row}" :command="{key: 'permission', row}"
:disabled="!checkPermission(['AbpIdentity.Users.ManagePermissions'])" :disabled="!checkPermission(['AbpIdentity.Users.ManagePermissions'])"
> >
{{ $t('AbpIdentity.Permissions') }} {{ $t('AbpIdentity.Permissions') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
:command="{key: 'lock', row}" :command="{key: 'lock', row}"
:disabled="!checkPermission(['AbpIdentity.Users.Update'])" :disabled="!checkPermission(['AbpIdentity.Users.Update'])"
> >
{{ $t('AbpIdentity.Lock') }} {{ $t('AbpIdentity.Lock') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
:command="{key: 'claim', row}" :command="{key: 'claim', row}"
:disabled="!checkPermission(['AbpIdentity.Users.ManageClaims'])" :disabled="!checkPermission(['AbpIdentity.Users.ManageClaims'])"
> >
{{ $t('AbpIdentity.ManageClaim') }} {{ $t('AbpIdentity.ManageClaim') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
:command="{key: 'menu', row}" :command="{key: 'menu', row}"
:disabled="!checkPermission(['Platform.Menu.ManageUsers'])" :disabled="!checkPermission(['Platform.Menu.ManageUsers'])"
> >
{{ $t('AppPlatform.Menu:Manage') }} {{ $t('AppPlatform.Menu:Manage') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
divided divided
:command="{key: 'delete', row}" :command="{key: 'delete', row}"
:disabled="!checkPermission(['AbpIdentity.Users.Delete'])" :disabled="!checkPermission(['AbpIdentity.Users.Delete'])"
> >
{{ $t('AbpIdentity.Delete') }} {{ $t('AbpIdentity.Delete') }}
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination <pagination
v-show="dataTotal>0" v-show="dataTotal>0"
:total="dataTotal" :total="dataTotal"
:page.sync="currentPage" :page.sync="currentPage"
:limit.sync="pageSize" :limit.sync="pageSize"
@pagination="refreshPagedData" @pagination="refreshPagedData"
/> />
<user-create-or-update-form <user-create-or-update-form
:show-dialog="showUserDialog" :show-dialog="showUserDialog"
:edit-user-id="editUserId" :edit-user-id="editUserId"
@closed="onUserDialogClosed" @closed="onUserDialogClosed"
/> />
<user-claim-create-or-update-form <user-claim-create-or-update-form
:show-dialog="showClaimDialog" :show-dialog="showClaimDialog"
:user-id="editUserId" :user-id="editUserId"
@closed="onClaimDialogClosed" @closed="onClaimDialogClosed"
/> />
<manage-user-menu-dialog <manage-user-menu-dialog
:show-dialog="showManageUserMenuDialog" :show-dialog="showManageUserMenuDialog"
:user-id="editUserId" :user-id="editUserId"
@closed="showManageUserMenuDialog=false" @closed="showManageUserMenuDialog=false"
/> />
<permission-form <permission-form
provider-name="U" provider-name="U"
:provider-key="editUserId" :provider-key="editUserId"
:readonly="!allowedEditPermission" :readonly="!allowedEditPermission"
:show-dialog="showPermissionDialog" :show-dialog="showPermissionDialog"
@closed="onPermissionDialogClosed" @closed="onPermissionDialogClosed"
/> />
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { UserModule } from '@/store/modules/user' import { UserModule } from '@/store/modules/user'
import DataListMiXin from '@/mixins/DataListMiXin' import DataListMiXin from '@/mixins/DataListMiXin'
import EventBusMiXin from '@/mixins/EventBusMiXin' import EventBusMiXin from '@/mixins/EventBusMiXin'
import Component, { mixins } from 'vue-class-component' import Component, { mixins } from 'vue-class-component'
import UserApiService, { User, UsersGetPagedDto } from '@/api/users' import UserApiService, { User, UsersGetPagedDto } from '@/api/users'
import Pagination from '@/components/Pagination/index.vue' import Pagination from '@/components/Pagination/index.vue'
import PermissionForm from '@/components/PermissionForm/index.vue' import PermissionForm from '@/components/PermissionForm/index.vue'
import ManageUserMenuDialog from './components/ManageUserMenuDialog.vue' import ManageUserMenuDialog from './components/ManageUserMenuDialog.vue'
import UserCreateOrUpdateForm from './components/UserCreateOrUpdateForm.vue' import UserCreateOrUpdateForm from './components/UserCreateOrUpdateForm.vue'
import UserClaimCreateOrUpdateForm from './components/UserClaimCreateOrUpdateForm.vue' import UserClaimCreateOrUpdateForm from './components/UserClaimCreateOrUpdateForm.vue'
import { dateFormat, abpPagerFormat } from '@/utils' import { dateFormat, abpPagerFormat } from '@/utils'
import { checkPermission } from '@/utils/permission' import { checkPermission } from '@/utils/permission'
@Component({ @Component({
name: 'UserList', name: 'UserList',
components: { components: {
Pagination, Pagination,
PermissionForm, PermissionForm,
ManageUserMenuDialog, ManageUserMenuDialog,
UserCreateOrUpdateForm, UserCreateOrUpdateForm,
UserClaimCreateOrUpdateForm UserClaimCreateOrUpdateForm
}, },
filters: { filters: {
dateTimeFilter(datetime: string) { dateTimeFilter(datetime: string) {
const date = new Date(datetime) const date = new Date(datetime)
return dateFormat(date, 'YYYY-mm-dd HH:MM') return dateFormat(date, 'YYYY-mm-dd HH:MM')
} }
}, },
methods: { methods: {
checkPermission checkPermission
} }
}) })
export default class extends mixins(DataListMiXin, EventBusMiXin) { export default class extends mixins(DataListMiXin, EventBusMiXin) {
private editUserId = '' private editUserId = ''
public dataFilter = new UsersGetPagedDto() public dataFilter = new UsersGetPagedDto()
private showUserDialog = false private showUserDialog = false
private showClaimDialog = false private showClaimDialog = false
private showPermissionDialog = false private showPermissionDialog = false
private showManageUserMenuDialog = false private showManageUserMenuDialog = false
get allowedEditPermission() { get allowedEditPermission() {
return this.editUserId !== UserModule.id && checkPermission(['AbpIdentity.Users.ManagePermissions']) return this.editUserId !== UserModule.id && checkPermission(['AbpIdentity.Users.ManagePermissions'])
} }
mounted() { mounted() {
this.refreshPagedData() this.refreshPagedData()
this.subscribe('userChanged', () => this.refreshPagedData()) this.subscribe('userChanged', () => this.refreshPagedData())
} }
destroyed() { destroyed() {
this.unSubscribe('userChanged') this.unSubscribe('userChanged')
} }
protected processDataFilter() { protected processDataFilter() {
this.dataFilter.skipCount = abpPagerFormat(this.currentPage, this.pageSize) this.dataFilter.skipCount = abpPagerFormat(this.currentPage, this.pageSize)
} }
/** 查询用户列表 */ /** 查询用户列表 */
protected getPagedList(filter: any) { protected getPagedList(filter: any) {
return UserApiService.getUsers(filter) return UserApiService.getUsers(filter)
} }
/** /**
* @param row 操作行数据,可以转换为 UserDataDto 对象 * @param row 操作行数据,可以转换为 UserDataDto 对象
*/ */
private handleLockUser(row: any) { private handleLockUser(row: any) {
console.log('handleLockUser' + row.id) console.log('handleLockUser' + row.id)
} }
private handleUserProfileChanged() { private handleUserProfileChanged() {
this.refreshPagedData() this.refreshPagedData()
} }
private handleShowCliamDialog(row: User) { private handleShowCliamDialog(row: User) {
this.editUserId = row.id this.editUserId = row.id
this.showClaimDialog = true this.showClaimDialog = true
} }
private onClaimDialogClosed() { private onClaimDialogClosed() {
this.showClaimDialog = false this.showClaimDialog = false
} }
private handleShowPermissionDialog(id: string) { private handleShowPermissionDialog(id: string) {
this.editUserId = id this.editUserId = id
this.showPermissionDialog = true this.showPermissionDialog = true
} }
private onPermissionDialogClosed() { private onPermissionDialogClosed() {
this.showPermissionDialog = false this.showPermissionDialog = false
} }
private handleShowUserDialog(id: string) { private handleShowUserDialog(id: string) {
this.editUserId = id this.editUserId = id
this.showUserDialog = true this.showUserDialog = true
} }
private onUserDialogClosed() { private onUserDialogClosed() {
this.showUserDialog = false this.showUserDialog = false
} }
/** 响应更多操作命令 */ /** 响应更多操作命令 */
private handleCommand(command: any) { private handleCommand(command: any) {
switch (command.key) { switch (command.key) {
case 'claim' : case 'claim' :
this.handleShowCliamDialog(command.row) this.handleShowCliamDialog(command.row)
break break
case 'menu' : case 'menu' :
this.editUserId = command.row.id this.editUserId = command.row.id
this.showManageUserMenuDialog = true this.showManageUserMenuDialog = true
break break
case 'permission' : case 'permission' :
this.handleShowPermissionDialog(command.row.id) this.handleShowPermissionDialog(command.row.id)
break break
case 'lock' : case 'lock' :
this.handleLockUser(command.row) this.handleLockUser(command.row)
break break
case 'delete' : case 'delete' :
this.handleDeleteUser(command.row) this.handleDeleteUser(command.row)
break break
default: break default: break
} }
} }
/** 响应删除用户事件 */ /** 响应删除用户事件 */
private handleDeleteUser(row: any) { private handleDeleteUser(row: any) {
this.$confirm(this.l('AbpIdentity.UserDeletionConfirmationMessage', { 0: row.userName }), this.$confirm(this.l('AbpIdentity.UserDeletionConfirmationMessage', { 0: row.userName }),
this.l('AbpIdentity.AreYouSure'), { this.l('AbpIdentity.AreYouSure'), {
callback: (action) => { callback: (action) => {
if (action === 'confirm') { if (action === 'confirm') {
UserApiService.deleteUser(row.id).then(() => { UserApiService.deleteUser(row.id).then(() => {
this.$message.success(this.l('global.successful')) this.$message.success(this.l('global.successful'))
this.refreshPagedData() this.refreshPagedData()
}) })
} }
} }
}) })
} }
} }
</script> </script>
<style lang="scss"> <style lang="scss">
.profile { .profile {
.el-dialog__header { .el-dialog__header {
background-color: dodgerblue; background-color: dodgerblue;
} }
} }
.options { .options {
vertical-align: top; vertical-align: top;
margin-left: 20px; margin-left: 20px;
} }
.el-icon-arrow-down { .el-icon-arrow-down {
font-size: 12px; font-size: 12px;
} }
</style> </style>

555
vueJs/src/views/container/layouts/components/CreateOrUpdateLayoutDialog.vue

@ -1,276 +1,279 @@
<template> <template>
<el-dialog <el-dialog
v-el-draggable-dialog v-el-draggable-dialog
width="800px" width="800px"
:visible="showDialog" :visible="showDialog"
:title="title" :title="title"
custom-class="modal-form" custom-class="modal-form"
:show-close="false" :show-close="false"
:close-on-click-modal="false" :close-on-click-modal="false"
:close-on-press-escape="false" :close-on-press-escape="false"
@close="onFormClosed(false)" @close="onFormClosed(false)"
> >
<el-form <el-form
ref="formLayout" ref="formLayout"
:model="layout" :model="layout"
label-width="120px" label-width="120px"
> >
<el-form-item <el-form-item
:label="$t('AppPlatform.DisplayName:PlatformType')" v-if="!isEdit"
:rules="{ prop="framework"
required: true, :label="$t('AppPlatform.DisplayName:UIFramework')"
message: $t('pleaseInputBy', {key: $t('AppPlatform.DisplayName:PlatformType')}), :rules="{
trigger: 'blur' required: true,
}" message: $t('pleaseInputBy', {key: $t('AppPlatform.DisplayName:UIFramework')}),
> trigger: 'blur'
<el-select }"
v-model="layout.platformType" >
style="width: 100%;" <el-select
class="filter-item" v-model="layout.framework"
clearable style="width: 100%;"
:placeholder="$t('pleaseSelectBy', {name: $t('AppPlatform.DisplayName:PlatformType')})" class="filter-item"
> clearable
<el-option :placeholder="$t('pleaseSelectBy', {name: $t('AppPlatform.DisplayName:UIFramework')})"
v-for="platformType in platformTypes" >
:key="platformType.key" <el-option
:label="platformType.key" v-for="framework in uiFrameworks"
:value="platformType.value" :key="framework"
/> :label="framework"
</el-select> :value="framework"
</el-form-item> />
<el-form-item </el-select>
v-if="!isEdit" </el-form-item>
:label="$t('AppPlatform.DisplayName:DataDictionary')" <el-form-item
:rules="{ v-if="!isEdit"
required: true :label="$t('AppPlatform.DisplayName:DataDictionary')"
}" :rules="{
> required: true
<el-select }"
v-model="dataId" >
style="width: 100%;" <el-select
class="filter-item" v-model="dataId"
clearable style="width: 100%;"
:placeholder="$t('pleaseSelectBy', {name: $t('AppPlatform.DisplayName:DataDictionary')})" class="filter-item"
> clearable
<el-option :placeholder="$t('pleaseSelectBy', {name: $t('AppPlatform.DisplayName:DataDictionary')})"
v-for="data in datas" >
:key="data.name" <el-option
:label="data.displayName" v-for="data in datas"
:value="data.id" :key="data.name"
/> :label="data.displayName"
</el-select> :value="data.id"
</el-form-item> />
<el-form-item </el-select>
prop="name" </el-form-item>
:label="$t(('AppPlatform.DisplayName:Name'))" <el-form-item
:rules="{ prop="name"
required: true, :label="$t(('AppPlatform.DisplayName:Name'))"
message: $t('pleaseInputBy', {key: $t('AppPlatform.DisplayName:Name')}), :rules="{
trigger: 'blur' required: true,
}" message: $t('pleaseInputBy', {key: $t('AppPlatform.DisplayName:Name')}),
> trigger: 'blur'
<el-input }"
v-model="layout.name" >
/> <el-input
</el-form-item> v-model="layout.name"
<el-form-item />
prop="displayName" </el-form-item>
:label="$t(('AppPlatform.DisplayName:DisplayName'))" <el-form-item
:rules="{ prop="displayName"
required: true, :label="$t(('AppPlatform.DisplayName:DisplayName'))"
message: $t('pleaseInputBy', {key: $t('AppPlatform.DisplayName:DisplayName')}), :rules="{
trigger: 'blur' required: true,
}" message: $t('pleaseInputBy', {key: $t('AppPlatform.DisplayName:DisplayName')}),
> trigger: 'blur'
<el-input }"
v-model="layout.displayName" >
/> <el-input
</el-form-item> v-model="layout.displayName"
<el-form-item />
prop="path" </el-form-item>
:label="$t(('AppPlatform.DisplayName:Path'))" <el-form-item
:rules="{ prop="path"
required: true, :label="$t(('AppPlatform.DisplayName:Path'))"
message: $t('pleaseInputBy', {key: $t('AppPlatform.DisplayName:Path')}), :rules="{
trigger: 'blur' required: true,
}" message: $t('pleaseInputBy', {key: $t('AppPlatform.DisplayName:Path')}),
> trigger: 'blur'
<el-input }"
v-model="layout.path" >
/> <el-input
</el-form-item> v-model="layout.path"
<el-form-item />
prop="redirect" </el-form-item>
:label="$t(('AppPlatform.DisplayName:Redirect'))" <el-form-item
> prop="redirect"
<el-input :label="$t(('AppPlatform.DisplayName:Redirect'))"
v-model="layout.redirect" >
/> <el-input
</el-form-item> v-model="layout.redirect"
<el-form-item />
prop="description" </el-form-item>
:label="$t(('AppPlatform.DisplayName:Description'))" <el-form-item
> prop="description"
<el-input :label="$t(('AppPlatform.DisplayName:Description'))"
v-model="layout.description" >
type="textarea" <el-input
/> v-model="layout.description"
</el-form-item> type="textarea"
/>
<el-form-item> </el-form-item>
<el-button
class="cancel" <el-form-item>
type="info" <el-button
@click="onFormClosed(false)" class="cancel"
> type="info"
{{ $t('AbpUi.Cancel') }} @click="onFormClosed(false)"
</el-button> >
<el-button {{ $t('AbpUi.Cancel') }}
class="confirm" </el-button>
type="primary" <el-button
icon="el-icon-check" class="confirm"
@click="onSave" type="primary"
> icon="el-icon-check"
{{ $t('AbpUi.Save') }} @click="onSave"
</el-button> >
</el-form-item> {{ $t('AbpUi.Save') }}
</el-form> </el-button>
</el-dialog> </el-form-item>
</template> </el-form>
</el-dialog>
<script lang="ts"> </template>
import { Component, Mixins, Prop, Watch } from 'vue-property-decorator'
import LocalizationMiXin from '@/mixins/LocalizationMiXin' <script lang="ts">
import { Component, Mixins, Prop, Watch } from 'vue-property-decorator'
import { Form } from 'element-ui' import LocalizationMiXin from '@/mixins/LocalizationMiXin'
import DataService, { Data } from '@/api/data-dictionary'
import LayoutService, { import { Form } from 'element-ui'
Layout, import DataService, { Data } from '@/api/data-dictionary'
LayoutCreateOrUpdate, import LayoutService, {
LayoutCreate, Layout,
LayoutUpdate, LayoutCreateOrUpdate,
PlatformTypes LayoutCreate,
} from '@/api/layout' LayoutUpdate
} from '@/api/layout'
@Component({
name: 'CreateOrUpdateLayoutDialog' @Component({
}) name: 'CreateOrUpdateLayoutDialog'
export default class CreateOrUpdateLayoutDialog extends Mixins(LocalizationMiXin) { })
@Prop({ default: false }) export default class CreateOrUpdateLayoutDialog extends Mixins(LocalizationMiXin) {
private showDialog!: boolean @Prop({ default: false })
private showDialog!: boolean
@Prop({ default: null })
private layoutId!: string @Prop({ default: null })
private layoutId!: string
private layout = new Layout()
private datas = new Array<Data>() @Prop({ default: [] })
private platformTypes = PlatformTypes private uiFrameworks!: string[]
private dataId = ''
private layout = new Layout()
get isEdit() { private datas = new Array<Data>()
if (this.layoutId) { private dataId = ''
return true
} get isEdit() {
return false if (this.layoutId) {
} return true
}
get title() { return false
if (this.isEdit) { }
return this.l('AppPlatform.Layout:EditByName', { 0: this.layout.displayName })
} get title() {
return this.l('AppPlatform.Layout:AddNew') if (this.isEdit) {
} return this.l('AppPlatform.Layout:EditByName', { 0: this.layout.displayName })
}
@Watch('showDialog') return this.l('AppPlatform.Layout:AddNew')
private onShowDialogChanged() { }
this.handleGetLayout()
} @Watch('showDialog')
private onShowDialogChanged() {
mounted() { this.handleGetLayout()
this.handleGetDataDictionarys() }
}
mounted() {
private handleGetDataDictionarys() { this.handleGetDataDictionarys()
DataService }
.getAll()
.then(res => { private handleGetDataDictionarys() {
this.datas = res.items DataService
}) .getAll()
} .then(res => {
this.datas = res.items
private handleGetLayout() { })
if (this.showDialog && this.layoutId) { }
LayoutService
.get(this.layoutId) private handleGetLayout() {
.then(res => { if (this.showDialog && this.layoutId) {
this.layout = res LayoutService
}) .get(this.layoutId)
} else { .then(res => {
this.layout = new Layout() this.layout = res
} })
} } else {
this.layout = new Layout()
private onSave() { }
const formLayout = this.$refs.formLayout as Form }
formLayout
.validate(valid => { private onSave() {
if (valid) { const formLayout = this.$refs.formLayout as Form
if (this.isEdit) { formLayout
const update = new LayoutUpdate() .validate(valid => {
this.updateMenuByInput(update) if (valid) {
LayoutService if (this.isEdit) {
.update(this.layoutId, update) const update = new LayoutUpdate()
.then(res => { this.updateMenuByInput(update)
this.layout = res LayoutService
this.$message.success(this.l('successful')) .update(this.layoutId, update)
this.onFormClosed(true) .then(res => {
}) this.layout = res
} else { this.$message.success(this.l('successful'))
if (!this.dataId) { this.onFormClosed(true)
this.$message.warning(this.l('pleaseSelectBy', { key: this.l('AppPlatform.DisplayName:DataDictionary') })) })
return } else {
} if (!this.dataId) {
const create = new LayoutCreate() this.$message.warning(this.l('pleaseSelectBy', { key: this.l('AppPlatform.DisplayName:DataDictionary') }))
this.updateMenuByInput(create) return
create.dataId = this.dataId }
LayoutService const create = new LayoutCreate()
.create(create) this.updateMenuByInput(create)
.then(res => { create.dataId = this.dataId
this.layout = res create.framework = this.layout.framework
this.$message.success(this.l('successful')) LayoutService
this.onFormClosed(true) .create(create)
}) .then(res => {
} this.layout = res
} this.$message.success(this.l('successful'))
}) this.onFormClosed(true)
} })
}
private onFormClosed(changed: boolean) { }
const formLayout = this.$refs.formLayout as Form })
formLayout.resetFields() }
this.$emit('closed', changed)
} private onFormClosed(changed: boolean) {
const formLayout = this.$refs.formLayout as Form
private updateMenuByInput(update: LayoutCreateOrUpdate) { formLayout.resetFields()
update.name = this.layout.name this.$emit('closed', changed)
update.path = this.layout.path }
update.displayName = this.layout.displayName
update.description = this.layout.description private updateMenuByInput(update: LayoutCreateOrUpdate) {
update.redirect = this.layout.redirect update.name = this.layout.name
update.platformType = this.layout.platformType update.path = this.layout.path
} update.displayName = this.layout.displayName
} update.description = this.layout.description
</script> update.redirect = this.layout.redirect
}
<style scoped> }
.confirm { </script>
position: absolute;
right: 10px; <style scoped>
width:100px; .confirm {
} position: absolute;
.cancel { right: 10px;
position: absolute; width:100px;
right: 120px; }
width:100px; .cancel {
} position: absolute;
</style> right: 120px;
width:100px;
}
</style>

486
vueJs/src/views/container/layouts/index.vue

@ -1,237 +1,249 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<div class="filter-container"> <div class="filter-container">
<el-form inline> <el-form inline>
<el-form-item <el-form-item
label-width="100px" label-width="100px"
:label="$t('AppPlatform.DisplayName:Filter')" :label="$t('AppPlatform.DisplayName:Filter')"
> >
<el-input <el-input
v-model="dataFilter.filter" v-model="dataFilter.filter"
/> />
</el-form-item> </el-form-item>
<el-form-item <el-form-item
label-width="100px" label-width="100px"
:label="$t('AppPlatform.DisplayName:PlatformType')" :label="$t('AppPlatform.DisplayName:UIFramework')"
> >
<el-select <el-select
v-model="dataFilter.platformType" v-model="dataFilter.framework"
class="filter-item" class="filter-item"
clearable clearable
:placeholder="$t('pleaseSelectBy', {name: $t('AppPlatform.DisplayName:PlatformType')})" :placeholder="$t('pleaseSelectBy', {name: $t('AppPlatform.DisplayName:UIFramework')})"
> >
<el-option <el-option
v-for="item in platformTypes" v-for="framework in uiFrameworks"
:key="item.key" :key="framework"
:label="item.key" :label="framework"
:value="item.value" :value="framework"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-button <el-button
class="filter-item" class="filter-item"
style="width: 150px; margin-left: 10px;" style="width: 150px; margin-left: 10px;"
type="primary" type="primary"
@click="refreshPagedData" @click="refreshPagedData"
> >
<i class="el-icon-search" /> <i class="el-icon-search" />
{{ $t('AppPlatform.DisplayName:SecrchLayout') }} {{ $t('AppPlatform.DisplayName:SecrchLayout') }}
</el-button> </el-button>
<el-button <el-button
class="filter-item" class="filter-item"
style="width: 150px; margin-left: 10px;" style="width: 150px; margin-left: 10px;"
type="success" type="success"
@click="handleAddLayout" @click="handleAddLayout"
> >
<i class="ivu-icon ivu-icon-md-add" /> <i class="ivu-icon ivu-icon-md-add" />
{{ $t('AppPlatform.Layout:AddNew') }} {{ $t('AppPlatform.Layout:AddNew') }}
</el-button> </el-button>
</el-form> </el-form>
</div> </div>
<el-table <el-table
v-loading="dataLoading" v-loading="dataLoading"
row-key="id" row-key="id"
:data="dataList" :data="dataList"
border border
fit fit
highlight-current-row highlight-current-row
style="width: 100%;" style="width: 100%;"
@sort-change="handleSortChange" @sort-change="handleSortChange"
> >
<el-table-column <el-table-column
:label="$t('AppPlatform.DisplayName:Name')" :label="$t('AppPlatform.DisplayName:Name')"
prop="Name" prop="Name"
sortable sortable
width="200px" width="200px"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.name }}</span> <span>{{ row.name }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('AppPlatform.DisplayName:Path')" :label="$t('AppPlatform.DisplayName:Path')"
prop="path" prop="path"
sortable sortable
width="250px" width="250px"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<el-tag> <el-tag>
{{ row.path }} {{ row.path }}
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('AppPlatform.DisplayName:DisplayName')" :label="$t('AppPlatform.DisplayName:DisplayName')"
prop="displayName" prop="displayName"
sortable sortable
width="250px" width="250px"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.displayName }}</span> <span>{{ row.displayName }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('AppPlatform.DisplayName:Description')" :label="$t('AppPlatform.DisplayName:Description')"
prop="description" prop="description"
sortable sortable
width="250px" width="250px"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.description }}</span> <span>{{ row.description }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('AppPlatform.DisplayName:Redirect')" :label="$t('AppPlatform.DisplayName:Redirect')"
prop="redirect" prop="redirect"
sortable sortable
width="250px" width="250px"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.redirect }}</span> <span>{{ row.redirect }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('operaActions')" :label="$t('operaActions')"
align="center" align="center"
min-width="200px" min-width="200px"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<el-button <el-button
:disabled="!checkPermission(['Platform.Layout.Update'])" :disabled="!checkPermission(['Platform.Layout.Update'])"
size="mini" size="mini"
type="primary" type="primary"
icon="el-icon-edit" icon="el-icon-edit"
@click="handleEditLayout(row.id)" @click="handleEditLayout(row.id)"
/> />
<el-button <el-button
:disabled="!checkPermission(['Platform.Layout.Delete'])" :disabled="!checkPermission(['Platform.Layout.Delete'])"
size="mini" size="mini"
type="danger" type="danger"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleRemoveLayout(row)" @click="handleRemoveLayout(row)"
/> />
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination <pagination
v-show="dataTotal>0" v-show="dataTotal>0"
:total="dataTotal" :total="dataTotal"
:page.sync="currentPage" :page.sync="currentPage"
:limit.sync="pageSize" :limit.sync="pageSize"
@pagination="refreshPagedData" @pagination="refreshPagedData"
@sort-change="handleSortChange" @sort-change="handleSortChange"
/> />
<create-or-update-layout-dialog <create-or-update-layout-dialog
:show-dialog="showEditDialog" :show-dialog="showEditDialog"
:layout-id="editLayoutId" :layout-id="editLayoutId"
@closed="onLayoutEditDialogClosed" :ui-frameworks="uiFrameworks"
/> @closed="onLayoutEditDialogClosed"
</div> />
</template> </div>
</template>
<script lang="ts">
import { dateFormat, abpPagerFormat } from '@/utils' <script lang="ts">
import { checkPermission } from '@/utils/permission' import { dateFormat, abpPagerFormat } from '@/utils'
import LayoutService, { Layout, GetLayoutByPaged, PlatformTypes } from '@/api/layout' import { checkPermission } from '@/utils/permission'
import DataListMiXin from '@/mixins/DataListMiXin' import LayoutService, { Layout, GetLayoutByPaged } from '@/api/layout'
import { Component, Mixins } from 'vue-property-decorator' import DataListMiXin from '@/mixins/DataListMiXin'
import Pagination from '@/components/Pagination/index.vue' import { Component, Mixins } from 'vue-property-decorator'
import CreateOrUpdateLayoutDialog from './components/CreateOrUpdateLayoutDialog.vue' import Pagination from '@/components/Pagination/index.vue'
import CreateOrUpdateLayoutDialog from './components/CreateOrUpdateLayoutDialog.vue'
@Component({
name: 'Layouts', import DataService from '@/api/data-dictionary'
components: {
Pagination, @Component({
CreateOrUpdateLayoutDialog name: 'Layouts',
}, components: {
filters: { Pagination,
dateTimeFormatFilter(dateTime: Date) { CreateOrUpdateLayoutDialog
return dateFormat(new Date(dateTime), 'YYYY-mm-dd HH:MM:SS:NS') },
} filters: {
}, dateTimeFormatFilter(dateTime: Date) {
methods: { return dateFormat(new Date(dateTime), 'YYYY-mm-dd HH:MM:SS:NS')
checkPermission }
} },
}) methods: {
export default class extends Mixins(DataListMiXin) { checkPermission
public dataFilter = new GetLayoutByPaged() }
private showEditDialog = false })
private editLayoutId = '' export default class extends Mixins(DataListMiXin) {
public dataFilter = new GetLayoutByPaged()
private platformTypes = PlatformTypes private showEditDialog = false
private editLayoutId = ''
mounted() {
this.refreshPagedData() private uiFrameworks: string[] = []
}
mounted() {
protected processDataFilter() { this.refreshPagedData()
this.dataFilter.skipCount = abpPagerFormat(this.currentPage, this.pageSize) this.getUIFrameworks()
} }
protected getPagedList(filter: any) { protected processDataFilter() {
return LayoutService.getList(filter) this.dataFilter.skipCount = abpPagerFormat(this.currentPage, this.pageSize)
} }
private handleRemoveLayout(layout: Layout) { protected getPagedList(filter: any) {
this.$confirm(this.l('questingDeleteByMessage', { message: layout.displayName }), return LayoutService.getList(filter)
this.l('AppPlatform.Layout:Delete'), { }
callback: (action) => {
if (action === 'confirm') { private getUIFrameworks() {
LayoutService DataService
.delete(layout.id) .getByName('UI Framewark')
.then(() => { .then(res => {
this.$message.success(this.l('successful')) this.uiFrameworks = res.items.map(item => item.name)
this.refreshPagedData() })
}) }
}
} private handleRemoveLayout(layout: Layout) {
}) this.$confirm(this.l('questingDeleteByMessage', { message: layout.displayName }),
} this.l('AppPlatform.Layout:Delete'), {
callback: (action) => {
private handleAddLayout() { if (action === 'confirm') {
this.editLayoutId = '' LayoutService
this.showEditDialog = true .delete(layout.id)
} .then(() => {
this.$message.success(this.l('successful'))
private handleEditLayout(id: string) { this.refreshPagedData()
this.editLayoutId = id })
this.showEditDialog = true }
} }
})
private onLayoutEditDialogClosed(changed: boolean) { }
this.showEditDialog = false
if (changed) { private handleAddLayout() {
this.refreshPagedData() this.editLayoutId = ''
} this.showEditDialog = true
} }
}
</script> private handleEditLayout(id: string) {
this.editLayoutId = id
<style lang="scss" scoped> this.showEditDialog = true
.data-filter-collapse-title { }
font-size: 15px;
} private onLayoutEditDialogClosed(changed: boolean) {
</style> this.showEditDialog = false
if (changed) {
this.refreshPagedData()
}
}
}
</script>
<style lang="scss" scoped>
.data-filter-collapse-title {
font-size: 15px;
}
</style>

583
vueJs/src/views/container/menus/index.vue

@ -1,286 +1,297 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<div class="filter-container"> <div class="filter-container">
<el-form inline> <el-form inline>
<el-form-item <el-form-item
label-width="100px" label-width="100px"
:label="$t('AppPlatform.DisplayName:Filter')" :label="$t('AppPlatform.DisplayName:Filter')"
> >
<el-input <el-input
v-model="dataQueryFilter.filter" v-model="dataQueryFilter.filter"
/> />
</el-form-item> </el-form-item>
<el-form-item <el-form-item
label-width="100px" label-width="100px"
:label="$t('AppPlatform.DisplayName:PlatformType')" :label="$t('AppPlatform.DisplayName:UIFramework')"
> >
<el-select <el-select
v-model="dataQueryFilter.platformType" v-model="dataQueryFilter.framework"
class="filter-item" class="filter-item"
clearable clearable
:placeholder="$t('pleaseSelectBy', {name: $t('AppPlatform.DisplayName:PlatformType')})" :placeholder="$t('pleaseSelectBy', {name: $t('AppPlatform.DisplayName:UIFramework')})"
> >
<el-option <el-option
v-for="item in platformTypes" v-for="framework in uiFrameworks"
:key="item.key" :key="framework"
:label="item.key" :label="framework"
:value="item.value" :value="framework"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
label-width="100px" label-width="100px"
:label="$t('AppPlatform.DisplayName:Layout')" :label="$t('AppPlatform.DisplayName:Layout')"
> >
<el-select <el-select
v-model="dataQueryFilter.layoutId" v-model="dataQueryFilter.layoutId"
class="filter-item" class="filter-item"
clearable clearable
:placeholder="$t('pleaseSelectBy', {name: $t('AppPlatform.DisplayName:Layout')})" :placeholder="$t('pleaseSelectBy', {name: $t('AppPlatform.DisplayName:Layout')})"
> >
<el-option <el-option
v-for="layout in layouts" v-for="layout in layouts"
:key="layout.id" :key="layout.id"
:label="layout.displayName" :label="layout.displayName"
:value="layout.id" :value="layout.id"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-button <el-button
class="filter-item" class="filter-item"
style="width: 150px; margin-left: 10px;" style="width: 150px; margin-left: 10px;"
type="primary" type="primary"
@click="resetList" @click="resetList"
> >
<i class="el-icon-search" /> <i class="el-icon-search" />
{{ $t('AppPlatform.DisplayName:SecrchMenu') }} {{ $t('AppPlatform.DisplayName:SecrchMenu') }}
</el-button> </el-button>
<el-button <el-button
class="filter-item" class="filter-item"
style="width: 150px; margin-left: 10px;" style="width: 150px; margin-left: 10px;"
type="success" type="success"
@click="handleAddMenu('')" @click="handleAddMenu('')"
> >
<i class="ivu-icon ivu-icon-md-add" /> <i class="ivu-icon ivu-icon-md-add" />
{{ $t('AppPlatform.Menu:AddNew') }} {{ $t('AppPlatform.Menu:AddNew') }}
</el-button> </el-button>
</el-form> </el-form>
</div> </div>
<el-table <el-table
v-loading="dataLoading" v-loading="dataLoading"
row-key="id" row-key="id"
:data="dataList" :data="dataList"
border border
fit fit
highlight-current-row highlight-current-row
style="width: 100%;" style="width: 100%;"
@sort-change="handleSortChange" @sort-change="handleSortChange"
> >
<el-table-column <el-table-column
:label="$t('AppPlatform.DisplayName:Name')" :label="$t('AppPlatform.DisplayName:Name')"
prop="Name" prop="Name"
sortable sortable
width="200px" width="200px"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.name }}</span> <span>{{ row.name }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('AppPlatform.DisplayName:Path')" :label="$t('AppPlatform.DisplayName:Path')"
prop="path" prop="path"
sortable sortable
width="250px" width="250px"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<el-tag> <el-tag>
{{ row.path }} {{ row.path }}
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('AppPlatform.DisplayName:Component')" :label="$t('AppPlatform.DisplayName:Component')"
prop="component" prop="component"
sortable sortable
width="250px" width="250px"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<el-tag> <el-tag>
{{ row.component }} {{ row.component }}
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('AppPlatform.DisplayName:DisplayName')" :label="$t('AppPlatform.DisplayName:DisplayName')"
prop="displayName" prop="displayName"
sortable sortable
width="250px" width="250px"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.displayName }}</span> <span>{{ row.displayName }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('AppPlatform.DisplayName:Description')" :label="$t('AppPlatform.DisplayName:Description')"
prop="description" prop="description"
sortable sortable
width="250px" width="250px"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.description }}</span> <span>{{ row.description }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('AppPlatform.DisplayName:Redirect')" :label="$t('AppPlatform.DisplayName:Redirect')"
prop="redirect" prop="redirect"
sortable sortable
width="180px" width="180px"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.redirect }}</span> <span>{{ row.redirect }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('operaActions')" :label="$t('operaActions')"
align="center" align="center"
min-width="200px" min-width="200px"
fixed="right" fixed="right"
> >
<template slot-scope="{row}"> <template slot-scope="{row}">
<el-button <el-button
:disabled="!checkPermission(['Platform.Menu.Create'])" :disabled="!checkPermission(['Platform.Menu.Create'])"
size="mini" size="mini"
type="success" type="success"
@click="handleAddMenu(row.id)" @click="handleAddMenu(row.id)"
> >
<i class="ivu-icon ivu-icon-md-add" /> <i class="ivu-icon ivu-icon-md-add" />
</el-button> </el-button>
<el-button <el-button
:disabled="!checkPermission(['Platform.Menu.Update'])" :disabled="!checkPermission(['Platform.Menu.Update'])"
size="mini" size="mini"
type="primary" type="primary"
icon="el-icon-edit" icon="el-icon-edit"
@click="handleEditMenu(row.id)" @click="handleEditMenu(row.id)"
/> />
<el-button <el-button
:disabled="!checkPermission(['Platform.Menu.Delete'])" :disabled="!checkPermission(['Platform.Menu.Delete'])"
size="mini" size="mini"
type="danger" type="danger"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleRemoveMenu(row)" @click="handleRemoveMenu(row)"
/> />
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<create-or-update-menu-dialog <create-or-update-menu-dialog
:show-dialog="showEditDialog" :show-dialog="showEditDialog"
:menu-id="editMenuId" :menu-id="editMenuId"
:parent-id="parentMenuId" :parent-id="parentMenuId"
@closed="onMenuEditDialogClosed" :ui-frameworks="uiFrameworks"
/> @closed="onMenuEditDialogClosed"
</div> />
</template> </div>
</template>
<script lang="ts">
import { dateFormat, generateTree } from '@/utils' <script lang="ts">
import { checkPermission } from '@/utils/permission' import { dateFormat, generateTree } from '@/utils'
import LayoutService, { PlatformTypes, Layout } from '@/api/layout' import { checkPermission } from '@/utils/permission'
import MenuService, { Menu, GetAllMenu } from '@/api/menu' import LayoutService, { Layout } from '@/api/layout'
import DataListMiXin from '@/mixins/DataListMiXin' import MenuService, { Menu, GetAllMenu } from '@/api/menu'
import Component, { mixins } from 'vue-class-component' import DataService from '@/api/data-dictionary'
import Pagination from '@/components/Pagination/index.vue' import DataListMiXin from '@/mixins/DataListMiXin'
import CreateOrUpdateMenuDialog from './components/CreateOrUpdateMenuDialog.vue' import Component, { mixins } from 'vue-class-component'
import Pagination from '@/components/Pagination/index.vue'
@Component({ import CreateOrUpdateMenuDialog from './components/CreateOrUpdateMenuDialog.vue'
name: 'Menus',
components: { @Component({
Pagination, name: 'Menus',
CreateOrUpdateMenuDialog components: {
}, Pagination,
filters: { CreateOrUpdateMenuDialog
dateTimeFormatFilter(dateTime: Date) { },
return dateFormat(new Date(dateTime), 'YYYY-mm-dd HH:MM:SS:NS') filters: {
} dateTimeFormatFilter(dateTime: Date) {
}, return dateFormat(new Date(dateTime), 'YYYY-mm-dd HH:MM:SS:NS')
methods: { }
checkPermission },
} methods: {
}) checkPermission
export default class extends mixins(DataListMiXin) { }
public dataQueryFilter = new GetAllMenu() })
private showEditDialog = false export default class extends mixins(DataListMiXin) {
private editMenuId = '' public dataQueryFilter = new GetAllMenu()
private parentMenuId = '' private showEditDialog = false
private layouts = new Array<Layout>() private editMenuId = ''
private parentMenuId = ''
private platformTypes = PlatformTypes private layouts = new Array<Layout>()
mounted() { private uiFrameworks: string[] = []
this.handleGetLayouts()
this.refreshData() mounted() {
} this.getUIFrameworks()
this.handleGetLayouts()
protected refreshData() { this.refreshData()
this.dataLoading = true }
MenuService
.getAll(this.dataQueryFilter) protected refreshData() {
.then(res => { this.dataLoading = true
this.dataList = generateTree(res.items) MenuService
this.onDataLoadCompleted() .getAll(this.dataQueryFilter)
}) .then(res => {
.finally(() => { this.dataList = generateTree(res.items)
this.dataLoading = false this.onDataLoadCompleted()
}) })
} .finally(() => {
this.dataLoading = false
private handleGetLayouts() { })
LayoutService }
.getAllList()
.then(res => { private getUIFrameworks() {
this.layouts = res.items DataService
}) .getByName('UI Framewark')
} .then(res => {
this.uiFrameworks = res.items.map(item => item.name)
private handleRemoveMenu(menu: Menu) { })
this.$confirm(this.l('questingDeleteByMessage', { message: menu.displayName }), }
this.l('AppPlatform.Menu:Delete'), {
callback: (action) => { private handleGetLayouts() {
if (action === 'confirm') { LayoutService
MenuService .getAllList()
.delete(menu.id) .then(res => {
.then(() => { this.layouts = res.items
this.$message.success(this.l('successful')) })
this.refreshData() }
})
} private handleRemoveMenu(menu: Menu) {
} this.$confirm(this.l('questingDeleteByMessage', { message: menu.displayName }),
}) this.l('AppPlatform.Menu:Delete'), {
} callback: (action) => {
if (action === 'confirm') {
private handleAddMenu(parentId: string) { MenuService
this.editMenuId = '' .delete(menu.id)
this.parentMenuId = parentId .then(() => {
this.showEditDialog = true this.$message.success(this.l('successful'))
} this.refreshData()
})
private handleEditMenu(id: string) { }
this.editMenuId = id }
this.showEditDialog = true })
} }
private onMenuEditDialogClosed(changed: boolean) { private handleAddMenu(parentId: string) {
this.showEditDialog = false this.editMenuId = ''
if (changed) { this.parentMenuId = parentId
this.refreshData() this.showEditDialog = true
} }
}
} private handleEditMenu(id: string) {
</script> this.editMenuId = id
this.showEditDialog = true
<style lang="scss" scoped> }
.data-filter-collapse-title {
font-size: 15px; private onMenuEditDialogClosed(changed: boolean) {
} this.showEditDialog = false
</style> if (changed) {
this.refreshData()
}
}
}
</script>
<style lang="scss" scoped>
.data-filter-collapse-title {
font-size: 15px;
}
</style>

240
vueJs/vue.config.js

@ -1,120 +1,120 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires // eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path') const path = require('path')
// If your port is set to 80, // If your port is set to 80,
// use administrator privileges to execute the command line. // use administrator privileges to execute the command line.
// For example, on Mac: sudo npm run / sudo yarn // For example, on Mac: sudo npm run / sudo yarn
const devServerPort = 9527 // TODO: get this variable from setting.ts const devServerPort = 9527 // TODO: get this variable from setting.ts
const name = 'Vue Typescript Admin' // TODO: get this variable from setting.ts const name = 'Vue Typescript Admin' // TODO: get this variable from setting.ts
module.exports = { module.exports = {
publicPath: process.env.NODE_ENV === 'production' ? '/' : '/vue-typescript-admin-template/', publicPath: process.env.NODE_ENV === 'production' ? '/' : '/vue-typescript-admin-template/',
lintOnSave: process.env.NODE_ENV === 'development', lintOnSave: process.env.NODE_ENV === 'development',
productionSourceMap: false, productionSourceMap: false,
devServer: { devServer: {
port: devServerPort, port: devServerPort,
open: true, open: true,
overlay: { overlay: {
warnings: false, warnings: false,
errors: true errors: true
}, },
progress: false, progress: false,
proxy: { proxy: {
// change xxx-api/login => /mock-api/v1/login // change xxx-api/login => /mock-api/v1/login
// detail: https://cli.vuejs.org/config/#devserver-proxy // detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_IDENTITY_SERVER]: { [process.env.VUE_APP_BASE_IDENTITY_SERVER]: {
// IdentityServer4 address // IdentityServer4 address
target: 'http://127.0.0.1:44385', target: 'http://10.21.15.28:44385',
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_BASE_IDENTITY_SERVER]: '' ['^' + process.env.VUE_APP_BASE_IDENTITY_SERVER]: ''
} }
}, },
[process.env.VUE_APP_SIGNALR_SERVER]: { [process.env.VUE_APP_SIGNALR_SERVER]: {
// api gateway address websocket protocol // api gateway address websocket protocol
target: 'ws://127.0.0.1:30000', target: 'ws://10.21.15.28:30000',
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_SIGNALR_SERVER]: '' ['^' + process.env.VUE_APP_SIGNALR_SERVER]: ''
}, },
logLevel: 'debug' logLevel: 'debug'
}, },
[process.env.VUE_APP_BASE_API]: { [process.env.VUE_APP_BASE_API]: {
// api gateway address // api gateway address
target: 'http://127.0.0.1:30000', target: 'http://10.21.15.28:30000',
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: '' ['^' + process.env.VUE_APP_BASE_API]: ''
}, },
logLevel: 'debug' logLevel: 'debug'
} }
} }
}, },
pwa: { pwa: {
name: name, name: name,
workboxPluginMode: 'InjectManifest', workboxPluginMode: 'InjectManifest',
workboxOptions: { workboxOptions: {
swSrc: path.resolve(__dirname, 'src/pwa/service-worker.js') swSrc: path.resolve(__dirname, 'src/pwa/service-worker.js')
} }
}, },
pluginOptions: { pluginOptions: {
'style-resources-loader': { 'style-resources-loader': {
preProcessor: 'scss', preProcessor: 'scss',
patterns: [ patterns: [
path.resolve(__dirname, 'src/styles/_variables.scss'), path.resolve(__dirname, 'src/styles/_variables.scss'),
path.resolve(__dirname, 'src/styles/_mixins.scss') path.resolve(__dirname, 'src/styles/_mixins.scss')
] ]
} }
}, },
chainWebpack(config) { chainWebpack(config) {
// provide the app's title in webpack's name field, so that // provide the app's title in webpack's name field, so that
// it can be accessed in index.html to inject the correct title. // it can be accessed in index.html to inject the correct title.
config.set('name', name) config.set('name', name)
// https://webpack.js.org/configuration/devtool/#development // https://webpack.js.org/configuration/devtool/#development
config config
.when(process.env.NODE_ENV === 'development', .when(process.env.NODE_ENV === 'development',
config => config.devtool('cheap-eval-source-map') config => config.devtool('cheap-eval-source-map')
) )
// remove vue-cli-service's progress output // remove vue-cli-service's progress output
config.plugins.delete('progress') config.plugins.delete('progress')
// replace with another progress output plugin to solve the this bug: // replace with another progress output plugin to solve the this bug:
// https://github.com/vuejs/vue-cli/issues/4557 // https://github.com/vuejs/vue-cli/issues/4557
config.plugin('simple-progress-webpack-plugin') config.plugin('simple-progress-webpack-plugin')
.use(require.resolve('simple-progress-webpack-plugin'), [{ .use(require.resolve('simple-progress-webpack-plugin'), [{
format: 'compact' format: 'compact'
}]) }])
config config
.when(process.env.NODE_ENV !== 'development', .when(process.env.NODE_ENV !== 'development',
config => { config => {
config config
.optimization.splitChunks({ .optimization.splitChunks({
chunks: 'all', chunks: 'all',
cacheGroups: { cacheGroups: {
libs: { libs: {
name: 'chunk-libs', name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/, test: /[\\/]node_modules[\\/]/,
priority: 10, priority: 10,
chunks: 'initial' // only package third parties that are initially dependent chunks: 'initial' // only package third parties that are initially dependent
}, },
elementUI: { elementUI: {
name: 'chunk-elementUI', // split elementUI into a single package name: 'chunk-elementUI', // split elementUI into a single package
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
}, },
commons: { commons: {
name: 'chunk-commons', name: 'chunk-commons',
test: path.resolve(__dirname, 'src/components'), test: path.resolve(__dirname, 'src/components'),
minChunks: 3, // minimum common number minChunks: 3, // minimum common number
priority: 5, priority: 5,
reuseExistingChunk: true reuseExistingChunk: true
} }
} }
}) })
config.optimization.runtimeChunk('single') config.optimization.runtimeChunk('single')
} }
) )
} }
} }

Loading…
Cancel
Save