Browse Source

feat(print-designer): add backend template management module

pull/1637/head
i2nets 2 weeks ago
parent
commit
f685ff65f6
  1. 26
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN.Abp.PrintDesigner.Application.Contracts.csproj
  2. 11
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerApplicationContractsModule.cs
  3. 5
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementCreateDto.cs
  4. 29
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementCreateOrUpdateDto.cs
  5. 6
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementDeleteDto.cs
  6. 38
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementDto.cs
  7. 8
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementGetPagedListInput.cs
  8. 8
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementPermissionDto.cs
  9. 6
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementUpdateDto.cs
  10. 10
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementUpsertDto.cs
  11. 56
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/ICustomElementAppService.cs
  12. 50
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Permissions/PrintDesignerPermissionDefinitionProvider.cs
  13. 24
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Permissions/PrintDesignerPermissions.cs
  14. 7
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/PrintDesignerRemoteServiceConsts.cs
  15. 5
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateCreateDto.cs
  16. 29
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateCreateOrUpdateDto.cs
  17. 7
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateDeleteDto.cs
  18. 38
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateDto.cs
  19. 8
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateGetPagedListInput.cs
  20. 8
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplatePermissionDto.cs
  21. 6
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateUpdateDto.cs
  22. 10
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateUpsertDto.cs
  23. 61
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/ITemplateAppService.cs
  24. 25
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN.Abp.PrintDesigner.Application.csproj
  25. 19
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerApplicationModule.cs
  26. 208
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementAppService.cs
  27. 24
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementGetPagedListSpecification.cs
  28. 13
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/PrintDesignerAppServiceBase.cs
  29. 94
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/PrintDesignerApplicationMappers.cs
  30. 221
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/Templates/TemplateAppService.cs
  31. 24
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/Templates/TemplateGetPagedListSpecification.cs
  32. 32
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/System/Linq/Expressions/ExpressionFuncExtensions.cs
  33. 27
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN.Abp.PrintDesigner.Domain.Shared.csproj
  34. 35
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerDomainSharedModule.cs
  35. 7
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementConsts.cs
  36. 8
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/Localization/PrintDesignerResource.cs
  37. 28
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/Localization/Resources/en.json
  38. 28
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/Localization/Resources/zh-Hans.json
  39. 28
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/PrintDesignerErrorCodes.cs
  40. 7
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/Templates/TemplateConsts.cs
  41. 26
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN.Abp.PrintDesigner.Domain.csproj
  42. 18
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerDomainModule.cs
  43. 69
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElement.cs
  44. 56
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementData.cs
  45. 57
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementDataSeeder.cs
  46. 20
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/ICustomElementDataSeeder.cs
  47. 27
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/ICustomElementRepository.cs
  48. 12
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/PrintDesignerDbProperties.cs
  49. 2
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/PrintDesignerDomainMappers.cs
  50. 20
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/ITemplateDataSeeder.cs
  51. 27
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/ITemplateRepository.cs
  52. 69
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/Template.cs
  53. 56
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/TemplateData.cs
  54. 57
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/TemplateDataSeeder.cs
  55. 24
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore.csproj
  56. 56
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/CustomElements/EfCoreCustomElementRepository.cs
  57. 39
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/AbpPrintDesignerEntityFrameworkCoreModule.cs
  58. 14
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/IPrintDesignerDbContext.cs
  59. 26
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/PrintDesignerDbContext.cs
  60. 81
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/PrintDesignerDbContextModelCreatingExtensions.cs
  61. 17
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/PrintDesignerModelBuilderConfigurationOptions.cs
  62. 56
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/Templates/EfCoreTemplateRepository.cs
  63. 25
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN.Abp.PrintDesigner.HttpApi.csproj
  64. 40
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerHttpApiModule.cs
  65. 63
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementController.cs
  66. 70
      aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN/Abp/PrintDesigner/Templates/TemplateController.cs

26
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN.Abp.PrintDesigner.Application.Contracts.csproj

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\configureawait.props" />
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0;net9.0;net10.0</TargetFrameworks>
<AssemblyName>LINGYUN.Abp.PrintDesigner.Application.Contracts</AssemblyName>
<PackageId>LINGYUN.Abp.PrintDesigner.Application.Contracts</PackageId>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Authorization" />
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.PrintDesigner.Domain.Shared\LINGYUN.Abp.PrintDesigner.Domain.Shared.csproj" />
</ItemGroup>
</Project>

11
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerApplicationContractsModule.cs

@ -0,0 +1,11 @@
using Volo.Abp.Application;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.PrintDesigner;
[DependsOn(
typeof(AbpDddApplicationContractsModule),
typeof(AbpPrintDesignerDomainSharedModule))]
public class AbpPrintDesignerApplicationContractsModule : AbpModule
{
}

5
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementCreateDto.cs

@ -0,0 +1,5 @@
namespace LINGYUN.Abp.PrintDesigner.CustomElements.Dtos;
public class CustomElementCreateDto : CustomElementCreateOrUpdateDto
{
}

29
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementCreateOrUpdateDto.cs

@ -0,0 +1,29 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
namespace LINGYUN.Abp.PrintDesigner.CustomElements.Dtos;
public abstract class CustomElementCreateOrUpdateDto
{
/// <summary>
/// 元素名称
/// </summary>
[Required]
[DynamicStringLength(typeof(CustomElementConsts), nameof(CustomElementConsts.MaxNameLength))]
public string Name { get; set; } = default!;
/// <summary>
/// 描述
/// </summary>
[DynamicStringLength(typeof(CustomElementConsts), nameof(CustomElementConsts.MaxDescriptionLength))]
public string? Description { get; set; }
/// <summary>
/// 元素定义
/// </summary>
[Required]
public Dictionary<string, object?> Element { get; set; } = new Dictionary<string, object?>();
/// <summary>
/// 元素扩展参数
/// </summary>
public Dictionary<string, object?> Ext { get; set; } = new Dictionary<string, object?>();
}

6
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementDeleteDto.cs

@ -0,0 +1,6 @@
namespace LINGYUN.Abp.PrintDesigner.CustomElements.Dtos;
public class CustomElementDeleteDto
{
public bool Success { get; set; }
}

38
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementDto.cs

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities;
namespace LINGYUN.Abp.PrintDesigner.CustomElements.Dtos;
public class CustomElementDto : AuditedEntityDto<Guid>, IHasConcurrencyStamp
{
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; } = default!;
/// <summary>
/// 描述
/// </summary>
public string? Description { get; set; }
/// <summary>
/// 时间戳(毫秒)
/// </summary>
public long? UpdatedAt { get; set; }
/// <summary>
/// 元素数据
/// </summary>
public Dictionary<string, object?>? Element { get; set; }
/// <summary>
/// 扩展数据容器
/// </summary>
public Dictionary<string, object?> Ext { get; set; } = new Dictionary<string, object?>();
/// <summary>
/// 用于控制前端操作按钮权限
/// </summary>
public CustomElementPermissionDto? Permissions { get; set; }
/// <summary>
/// 并发令牌
/// </summary>
public string ConcurrencyStamp { get; set; } = default!;
}

8
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementGetPagedListInput.cs

@ -0,0 +1,8 @@
using Volo.Abp.Application.Dtos;
namespace LINGYUN.Abp.PrintDesigner.CustomElements.Dtos;
public class CustomElementGetPagedListInput : PagedAndSortedResultRequestDto
{
public string? Filter { get; set; }
}

8
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementPermissionDto.cs

@ -0,0 +1,8 @@
namespace LINGYUN.Abp.PrintDesigner.CustomElements.Dtos;
public class CustomElementPermissionDto
{
public bool Editable { get; set; }
public bool Deletable { get; set; }
public bool Copyable { get; set; }
}

6
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementUpdateDto.cs

@ -0,0 +1,6 @@
namespace LINGYUN.Abp.PrintDesigner.CustomElements.Dtos;
public class CustomElementUpdateDto : CustomElementCreateOrUpdateDto
{
public string? ConcurrencyStamp { get; set; }
}

10
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementUpsertDto.cs

@ -0,0 +1,10 @@
using System;
namespace LINGYUN.Abp.PrintDesigner.CustomElements.Dtos;
public class CustomElementUpsertDto : CustomElementCreateOrUpdateDto
{
public Guid? Id { get; set; }
public string? ConcurrencyStamp { get; set; }
}

56
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/ICustomElementAppService.cs

@ -0,0 +1,56 @@
using LINGYUN.Abp.PrintDesigner.CustomElements.Dtos;
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
namespace LINGYUN.Abp.PrintDesigner.CustomElements;
public interface ICustomElementAppService : IApplicationService
{
/// <summary>
/// 获取全部自定义元素列表
/// </summary>
/// <returns></returns>
Task<ListResultDto<CustomElementDto>> GetAllAsync();
/// <summary>
/// 获取自定义元素列表
/// </summary>
/// <param name="input">查询过滤参数</param>
/// <returns></returns>
Task<PagedResultDto<CustomElementDto>> GetListAsync(CustomElementGetPagedListInput input);
/// <summary>
/// 获取自定义元素详情
/// </summary>
/// <param name="id">自定义元素Id</param>
/// <returns></returns>
Task<CustomElementDto> GetAsync(Guid id);
/// <summary>
/// 新增自定义元素
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task<CustomElementDto> CreateAsync(CustomElementCreateDto input);
/// <summary>
/// 编辑自定义元素
/// </summary>
/// <param name="id">自定义元素Id</param>
/// <param name="input"></param>
/// <returns></returns>
Task<CustomElementDto> UpdateAsync(Guid id, CustomElementUpdateDto input);
/// <summary>
/// 新增或编辑自定义元素
/// </summary>
/// <remarks>
/// 兼容upsert接口
/// </remarks>
/// <param name="input"></param>
/// <returns></returns>
Task<CustomElementDto> UpsertAsync(CustomElementUpsertDto input);
/// <summary>
/// 删除自定义元素
/// </summary>
/// <param name="id">自定义元素Id</param>
/// <returns></returns>
Task<CustomElementDeleteDto> DeleteAsync(Guid id);
}

50
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Permissions/PrintDesignerPermissionDefinitionProvider.cs

@ -0,0 +1,50 @@
using LINGYUN.Abp.PrintDesigner.Localization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;
namespace LINGYUN.Abp.PrintDesigner.Permissions;
public class PrintDesignerPermissionDefinitionProvider : PermissionDefinitionProvider
{
public override void Define(IPermissionDefinitionContext context)
{
var group = context.AddGroup(PrintDesignerPermissions.GroupName, L("Permission:PrintDesigner"));
var customElement = group.AddPermission(
PrintDesignerPermissions.CustomElement.Default,
L("Permission:CustomElement"));
customElement.AddChild(
PrintDesignerPermissions.CustomElement.Create,
L("Permission:Create"));
customElement.AddChild(
PrintDesignerPermissions.CustomElement.Delete,
L("Permission:Delete"));
customElement.AddChild(
PrintDesignerPermissions.CustomElement.Update,
L("Permission:Update"));
customElement.AddChild(
PrintDesignerPermissions.CustomElement.Copy,
L("Permission:Copy"));
var template = group.AddPermission(
PrintDesignerPermissions.Template.Default,
L("Permission:Template"));
template.AddChild(
PrintDesignerPermissions.Template.Create,
L("Permission:Create"));
template.AddChild(
PrintDesignerPermissions.Template.Delete,
L("Permission:Delete"));
template.AddChild(
PrintDesignerPermissions.Template.Update,
L("Permission:Update"));
template.AddChild(
PrintDesignerPermissions.Template.Copy,
L("Permission:Copy"));
}
private static LocalizableString L(string name)
{
return LocalizableString.Create<PrintDesignerResource>(name);
}
}

24
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Permissions/PrintDesignerPermissions.cs

@ -0,0 +1,24 @@
namespace LINGYUN.Abp.PrintDesigner.Permissions;
public static class PrintDesignerPermissions
{
public const string GroupName = "PrintDesigner";
public static class CustomElement
{
public const string Default = GroupName + ".CustomElements";
public const string Create = Default + ".Create";
public const string Update = Default + ".Update";
public const string Delete = Default + ".Delete";
public const string Copy = Default + ".Copy";
}
public static class Template
{
public const string Default = GroupName + ".Templates";
public const string Create = Default + ".Create";
public const string Update = Default + ".Update";
public const string Delete = Default + ".Delete";
public const string Copy = Default + ".Copy";
}
}

7
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/PrintDesignerRemoteServiceConsts.cs

@ -0,0 +1,7 @@
namespace LINGYUN.Abp.PrintDesigner;
public static class PrintDesignerRemoteServiceConsts
{
public const string RemoteServiceName = "PrintDesigner";
public const string ModuleName = "print-designer";
}

5
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateCreateDto.cs

@ -0,0 +1,5 @@
namespace LINGYUN.Abp.PrintDesigner.Templates.Dtos;
public class TemplateCreateDto : TemplateCreateOrUpdateDto
{
}

29
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateCreateOrUpdateDto.cs

@ -0,0 +1,29 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
namespace LINGYUN.Abp.PrintDesigner.Templates.Dtos;
public abstract class TemplateCreateOrUpdateDto
{
/// <summary>
/// 名称
/// </summary>
[Required]
[DynamicStringLength(typeof(TemplateConsts), nameof(TemplateConsts.MaxNameLength))]
public string Name { get; set; } = default!;
/// <summary>
/// 描述
/// </summary>
[DynamicStringLength(typeof(TemplateConsts), nameof(TemplateConsts.MaxDescriptionLength))]
public string? Description { get; set; }
/// <summary>
/// 模板设计数据
/// </summary>
[Required]
public Dictionary<string, object?> Data { get; set; } = new Dictionary<string, object?>();
/// <summary>
/// 模板扩展参数容器
/// </summary>
public Dictionary<string, object?> Ext { get; set; } = new Dictionary<string, object?>();
}

7
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateDeleteDto.cs

@ -0,0 +1,7 @@
namespace LINGYUN.Abp.PrintDesigner.Templates.Dtos;
public class TemplateDeleteDto
{
public bool Success { get; set; }
}

38
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateDto.cs

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities;
namespace LINGYUN.Abp.PrintDesigner.Templates.Dtos;
public class TemplateDto : AuditedEntityDto<Guid>, IHasConcurrencyStamp
{
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; } = default!;
/// <summary>
/// 描述
/// </summary>
public string? Description { get; set; }
/// <summary>
/// 时间戳(毫秒)
/// </summary>
public long? UpdatedAt { get; set; }
/// <summary>
/// 模板设计数据
/// </summary>
public Dictionary<string, object?>? Data { get; set; }
/// <summary>
/// 扩展数据容器
/// </summary>
public Dictionary<string, object?> Ext { get; set; } = new Dictionary<string, object?>();
/// <summary>
/// 用于控制前端操作按钮权限
/// </summary>
public TemplatePermissionDto? Permissions { get; set; }
/// <summary>
/// 并发令牌
/// </summary>
public string ConcurrencyStamp { get; set; } = default!;
}

8
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateGetPagedListInput.cs

@ -0,0 +1,8 @@
using Volo.Abp.Application.Dtos;
namespace LINGYUN.Abp.PrintDesigner.Templates.Dtos;
public class TemplateGetPagedListInput : PagedAndSortedResultRequestDto
{
public string? Filter { get; set; }
}

8
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplatePermissionDto.cs

@ -0,0 +1,8 @@
namespace LINGYUN.Abp.PrintDesigner.Templates.Dtos;
public class TemplatePermissionDto
{
public bool Editable { get; set; }
public bool Deletable { get; set; }
public bool Copyable { get; set; }
}

6
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateUpdateDto.cs

@ -0,0 +1,6 @@
namespace LINGYUN.Abp.PrintDesigner.Templates.Dtos;
public class TemplateUpdateDto : TemplateCreateOrUpdateDto
{
public string? ConcurrencyStamp { get; set; }
}

10
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateUpsertDto.cs

@ -0,0 +1,10 @@
using System;
namespace LINGYUN.Abp.PrintDesigner.Templates.Dtos;
public class TemplateUpsertDto : TemplateCreateOrUpdateDto
{
public Guid? Id { get; set; }
public string? ConcurrencyStamp { get; set; }
}

61
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/ITemplateAppService.cs

@ -0,0 +1,61 @@
using LINGYUN.Abp.PrintDesigner.Templates.Dtos;
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
namespace LINGYUN.Abp.PrintDesigner.Templates;
public interface ITemplateAppService : IApplicationService
{
/// <summary>
/// 获取全部模板列表
/// </summary>
/// <returns></returns>
Task<ListResultDto<TemplateDto>> GetAllAsync();
/// <summary>
/// 获取模板列表
/// </summary>
/// <returns></returns>
Task<PagedResultDto<TemplateDto>> GetListAsync(TemplateGetPagedListInput input);
/// <summary>
/// 获取模板详情
/// </summary>
/// <param name="id">模板Id</param>
/// <returns></returns>
Task<TemplateDto> GetAsync(Guid id);
/// <summary>
/// 获取模板详情
/// </summary>
/// <param name="name">模板名称</param>
/// <returns></returns>
Task<TemplateDto> GetByNameAsync(string name);
/// <summary>
/// 新增模板
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task<TemplateDto> CreateAsync(TemplateCreateDto input);
/// <summary>
/// 编辑模板
/// </summary>
/// <param name="id">模板Id</param>
/// <param name="input"></param>
/// <returns></returns>
Task<TemplateDto> UpdateAsync(Guid id, TemplateUpdateDto input);
/// <summary>
/// 新增或编辑模板
/// </summary>
/// <remarks>
/// 兼容upsert接口
/// </remarks>
/// <param name="input"></param>
/// <returns></returns>
Task<TemplateDto> UpsertAsync(TemplateUpsertDto input);
/// <summary>
/// 删除模板
/// </summary>
/// <param name="id">模板Id</param>
/// <returns></returns>
Task<TemplateDeleteDto> DeleteAsync(Guid id);
}

25
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN.Abp.PrintDesigner.Application.csproj

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\configureawait.props" />
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<AssemblyName>LINGYUN.Abp.PrintDesigner.Application</AssemblyName>
<PackageId>LINGYUN.Abp.PrintDesigner.Application</PackageId>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Ddd.Application" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.PrintDesigner.Application.Contracts\LINGYUN.Abp.PrintDesigner.Application.Contracts.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.PrintDesigner.Domain\LINGYUN.Abp.PrintDesigner.Domain.csproj" />
</ItemGroup>
</Project>

19
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerApplicationModule.cs

@ -0,0 +1,19 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Application;
using Volo.Abp.Authorization;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.PrintDesigner;
[DependsOn(
typeof(AbpAuthorizationModule),
typeof(AbpDddApplicationModule),
typeof(AbpPrintDesignerDomainModule),
typeof(AbpPrintDesignerApplicationContractsModule))]
public class AbpPrintDesignerApplicationModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddMapperlyObjectMapper<AbpPrintDesignerApplicationModule>();
}
}

208
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementAppService.cs

@ -0,0 +1,208 @@
using LINGYUN.Abp.PrintDesigner.CustomElements.Dtos;
using LINGYUN.Abp.PrintDesigner.Permissions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Data;
using Volo.Abp.Json;
namespace LINGYUN.Abp.PrintDesigner.CustomElements;
[Authorize(PrintDesignerPermissions.CustomElement.Default)]
public class CustomElementAppService : PrintDesignerAppServiceBase, ICustomElementAppService
{
private readonly IJsonSerializer _jsonSerializer;
private readonly ICustomElementRepository _customElementRepository;
public CustomElementAppService(
IJsonSerializer jsonSerializer,
ICustomElementRepository customElementRepository)
{
_jsonSerializer = jsonSerializer;
_customElementRepository = customElementRepository;
}
[Authorize(PrintDesignerPermissions.CustomElement.Create)]
public async virtual Task<CustomElementDto> CreateAsync(CustomElementCreateDto input)
{
if (await _customElementRepository.FindByNameAsync(input.Name) != null)
{
throw new BusinessException(
PrintDesignerErrorCodes.CustomElement.NameAlreadyExists,
$"A custom element definition named {input.Name} already exists.!")
.WithData("Name", input.Name);
}
var customElement = new CustomElement(
GuidGenerator.Create(),
input.Name,
input.Description,
CurrentTenant.Id);
var elementData = _jsonSerializer.Serialize(input.Element);
var extendedData = _jsonSerializer.Serialize(input.Ext);
customElement.SetData(elementData, extendedData);
customElement = await _customElementRepository.InsertAsync(customElement);
await CurrentUnitOfWork!.SaveChangesAsync();
var customElementDto = ObjectMapper.Map<CustomElement, CustomElementDto>(customElement);
await SetCustomElementPermissions(customElementDto);
return customElementDto;
}
[Authorize(PrintDesignerPermissions.CustomElement.Delete)]
public async virtual Task<CustomElementDeleteDto> DeleteAsync(Guid id)
{
bool success;
try
{
var customElement = await _customElementRepository.GetAsync(id);
await _customElementRepository.DeleteAsync(customElement);
success = true;
}
catch (Exception ex)
{
Logger.LogWarning(ex, "Deleting custom element: {id} failed: {message}!", id, ex.Message);
success = false;
}
return new CustomElementDeleteDto
{
Success = success,
};
}
public async virtual Task<CustomElementDto> GetAsync(Guid id)
{
var customElement = await _customElementRepository.GetAsync(id);
var customElementDto = ObjectMapper.Map<CustomElement, CustomElementDto>(customElement);
await SetCustomElementPermissions(customElementDto);
return customElementDto;
}
public async virtual Task<ListResultDto<CustomElementDto>> GetAllAsync()
{
var customElements = await _customElementRepository.GetListAsync();
var customElementDtos = ObjectMapper.Map<List<CustomElement>, List<CustomElementDto>>(customElements);
await SetCustomElementsPermissions(customElementDtos);
return new ListResultDto<CustomElementDto>(customElementDtos);
}
public async virtual Task<PagedResultDto<CustomElementDto>> GetListAsync(CustomElementGetPagedListInput input)
{
var specification = new CustomElementGetPagedListSpecification(input);
var totalCount = await _customElementRepository.GetCountAsync(specification);
var customElements = await _customElementRepository.GetListAsync(specification,
input.Sorting, input.MaxResultCount, input.SkipCount);
var customElementDtos = ObjectMapper.Map<List<CustomElement>, List<CustomElementDto>>(customElements);
await SetCustomElementsPermissions(customElementDtos);
return new PagedResultDto<CustomElementDto>(totalCount, customElementDtos);
}
[Authorize(PrintDesignerPermissions.CustomElement.Update)]
public async virtual Task<CustomElementDto> UpdateAsync(Guid id, CustomElementUpdateDto input)
{
var customElement = await _customElementRepository.GetAsync(id);
if (!string.Equals(customElement.Name, input.Name, StringComparison.CurrentCultureIgnoreCase))
{
if (await _customElementRepository.FindByNameAsync(input.Name) != null)
{
throw new BusinessException(
PrintDesignerErrorCodes.CustomElement.NameAlreadyExists,
$"A custom element definition named {input.Name} already exists.!")
.WithData("Name", input.Name);
}
customElement.SetName(input.Name);
}
var elementData = _jsonSerializer.Serialize(input.Element);
var extendedData = _jsonSerializer.Serialize(input.Ext);
customElement.SetData(elementData, extendedData);
customElement.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp);
customElement = await _customElementRepository.UpdateAsync(customElement);
await CurrentUnitOfWork!.SaveChangesAsync();
var customElementDto = ObjectMapper.Map<CustomElement, CustomElementDto>(customElement);
await SetCustomElementPermissions(customElementDto);
return customElementDto;
}
public async virtual Task<CustomElementDto> UpsertAsync(CustomElementUpsertDto input)
{
if (input.Id.HasValue &&
await _customElementRepository.FindAsync(input.Id.Value) != null)
{
await AuthorizationService.CheckAsync(PrintDesignerPermissions.CustomElement.Update);
return await UpdateAsync(
input.Id.Value,
new CustomElementUpdateDto
{
Name = input.Name,
Description = input.Description,
Element = input.Element,
Ext = input.Ext,
ConcurrencyStamp = input.ConcurrencyStamp,
});
}
else
{
await AuthorizationService.CheckAsync(PrintDesignerPermissions.CustomElement.Create);
return await CreateAsync(
new CustomElementCreateDto
{
Name = input.Name,
Description = input.Description,
Element = input.Element,
Ext = input.Ext,
});
}
}
protected async virtual Task SetCustomElementPermissions(CustomElementDto customElementDto)
{
customElementDto.Permissions ??= new CustomElementPermissionDto();
customElementDto.Permissions.Editable = await AuthorizationService.IsGrantedAsync(PrintDesignerPermissions.CustomElement.Update);
customElementDto.Permissions.Deletable = await AuthorizationService.IsGrantedAsync(PrintDesignerPermissions.CustomElement.Delete);
customElementDto.Permissions.Copyable = await AuthorizationService.IsGrantedAsync(PrintDesignerPermissions.CustomElement.Copy);
}
protected async virtual Task SetCustomElementsPermissions(List<CustomElementDto> customElementDtos)
{
var editable = await AuthorizationService.IsGrantedAsync(PrintDesignerPermissions.CustomElement.Update);
var deletable = await AuthorizationService.IsGrantedAsync(PrintDesignerPermissions.CustomElement.Delete);
var copyable = await AuthorizationService.IsGrantedAsync(PrintDesignerPermissions.CustomElement.Copy);
foreach (var customElementDto in customElementDtos)
{
customElementDto.Permissions ??= new CustomElementPermissionDto();
customElementDto.Permissions.Editable = editable;
customElementDto.Permissions.Deletable = deletable;
customElementDto.Permissions.Copyable = copyable;
}
}
}

24
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementGetPagedListSpecification.cs

@ -0,0 +1,24 @@
using LINGYUN.Abp.PrintDesigner.CustomElements.Dtos;
using System;
using System.Linq.Expressions;
using Volo.Abp.Specifications;
namespace LINGYUN.Abp.PrintDesigner.CustomElements;
public class CustomElementGetPagedListSpecification : Specification<CustomElement>
{
protected CustomElementGetPagedListInput Input { get; }
public CustomElementGetPagedListSpecification(CustomElementGetPagedListInput input)
{
Input = input;
}
public override Expression<Func<CustomElement, bool>> ToExpression()
{
Expression<Func<CustomElement, bool>> expression = _ => true;
return expression
.AndIf(!Input.Filter.IsNullOrWhiteSpace(), x =>
x.Name.Contains(Input.Filter!) ||
(x.Description != null && x.Description.Contains(Input.Filter!)));
}
}

13
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/PrintDesignerAppServiceBase.cs

@ -0,0 +1,13 @@
using LINGYUN.Abp.PrintDesigner.Localization;
using Volo.Abp.Application.Services;
namespace LINGYUN.Abp.PrintDesigner;
public abstract class PrintDesignerAppServiceBase : ApplicationService
{
protected PrintDesignerAppServiceBase()
{
LocalizationResource = typeof(PrintDesignerResource);
ObjectMapperContext = typeof(AbpPrintDesignerApplicationModule);
}
}

94
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/PrintDesignerApplicationMappers.cs

@ -0,0 +1,94 @@
using LINGYUN.Abp.PrintDesigner.CustomElements.Dtos;
using LINGYUN.Abp.PrintDesigner.Templates.Dtos;
using LINGYUN.Abp.PrintDesigner.CustomElements;
using LINGYUN.Abp.PrintDesigner.Templates;
using Riok.Mapperly.Abstractions;
using System;
using System.Collections.Generic;
using Volo.Abp.Json;
using Volo.Abp.Mapperly;
using Volo.Abp.ObjectExtending;
namespace LINGYUN.Abp.PrintDesigner.Admin;
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
[MapExtraProperties(DefinitionChecks = MappingPropertyDefinitionChecks.None)]
public partial class CustomElementToCustomElementDtoMapper : MapperBase<CustomElement, CustomElementDto>
{
private readonly IJsonSerializer _jsonSerializer;
public CustomElementToCustomElementDtoMapper(IJsonSerializer jsonSerializer)
{
_jsonSerializer = jsonSerializer;
}
[MapperIgnoreTarget(nameof(CustomElementDto.Ext))]
[MapperIgnoreTarget(nameof(CustomElementDto.Element))]
[MapperIgnoreTarget(nameof(CustomElementDto.UpdatedAt))]
[MapperIgnoreTarget(nameof(CustomElementDto.Permissions))]
public override partial CustomElementDto Map(CustomElement source);
[MapperIgnoreTarget(nameof(CustomElementDto.Ext))]
[MapperIgnoreTarget(nameof(CustomElementDto.Element))]
[MapperIgnoreTarget(nameof(CustomElementDto.UpdatedAt))]
[MapperIgnoreTarget(nameof(CustomElementDto.Permissions))]
public override partial void Map(CustomElement source, CustomElementDto destination);
public override void AfterMap(CustomElement source, CustomElementDto destination)
{
destination.UpdatedAt = new DateTimeOffset(source.CreationTime).ToUnixTimeMilliseconds();
destination.Element = new Dictionary<string, object?>();
destination.Ext = new Dictionary<string, object?>();
if (source.Data != null)
{
if (!source.Data.ElementData.IsNullOrWhiteSpace())
{
destination.Element = _jsonSerializer.Deserialize<Dictionary<string, object?>>(source.Data.ElementData);
}
if (!source.Data.ExtendedData.IsNullOrWhiteSpace())
{
destination.Ext = _jsonSerializer.Deserialize<Dictionary<string, object?>>(source.Data.ExtendedData);
}
}
}
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
[MapExtraProperties(DefinitionChecks = MappingPropertyDefinitionChecks.None)]
public partial class TemplateToTemplateDtoMapper : MapperBase<Template, TemplateDto>
{
private readonly IJsonSerializer _jsonSerializer;
public TemplateToTemplateDtoMapper(IJsonSerializer jsonSerializer)
{
_jsonSerializer = jsonSerializer;
}
[MapperIgnoreTarget(nameof(TemplateDto.Data))]
[MapperIgnoreTarget(nameof(TemplateDto.Ext))]
[MapperIgnoreTarget(nameof(TemplateDto.UpdatedAt))]
[MapperIgnoreTarget(nameof(TemplateDto.Permissions))]
public override partial TemplateDto Map(Template source);
[MapperIgnoreTarget(nameof(TemplateDto.Data))]
[MapperIgnoreTarget(nameof(TemplateDto.Ext))]
[MapperIgnoreTarget(nameof(TemplateDto.UpdatedAt))]
[MapperIgnoreTarget(nameof(TemplateDto.Permissions))]
public override partial void Map(Template source, TemplateDto destination);
public override void AfterMap(Template source, TemplateDto destination)
{
destination.UpdatedAt = new DateTimeOffset(source.CreationTime).ToUnixTimeMilliseconds();
destination.Data = new Dictionary<string, object?>();
destination.Ext = new Dictionary<string, object?>();
if (source.Data != null)
{
if (!source.Data.DesignerData.IsNullOrWhiteSpace())
{
destination.Data = _jsonSerializer.Deserialize<Dictionary<string, object?>>(source.Data.DesignerData);
}
if (!source.Data.ExtendedData.IsNullOrWhiteSpace())
{
destination.Ext = _jsonSerializer.Deserialize<Dictionary<string, object?>>(source.Data.ExtendedData);
}
}
}
}

221
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/Templates/TemplateAppService.cs

@ -0,0 +1,221 @@
using LINGYUN.Abp.PrintDesigner.Permissions;
using LINGYUN.Abp.PrintDesigner.Templates.Dtos;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Data;
using Volo.Abp.Json;
namespace LINGYUN.Abp.PrintDesigner.Templates;
[Authorize(PrintDesignerPermissions.Template.Default)]
public class TemplateAppService : PrintDesignerAppServiceBase, ITemplateAppService
{
private readonly IJsonSerializer _jsonSerializer;
private readonly ITemplateRepository _templateRepository;
public TemplateAppService(
IJsonSerializer jsonSerializer,
ITemplateRepository templateRepository)
{
_jsonSerializer = jsonSerializer;
_templateRepository = templateRepository;
}
[Authorize(PrintDesignerPermissions.Template.Create)]
public async virtual Task<TemplateDto> CreateAsync(TemplateCreateDto input)
{
if (await _templateRepository.FindByNameAsync(input.Name) != null)
{
throw new BusinessException(
PrintDesignerErrorCodes.Template.NameAlreadyExists,
$"A template definition named {input.Name} already exists.!")
.WithData("Name", input.Name);
}
var template = new Template(
GuidGenerator.Create(),
input.Name,
input.Description,
CurrentTenant.Id);
var elementData = _jsonSerializer.Serialize(input.Data);
var extendedData = _jsonSerializer.Serialize(input.Ext);
template.SetData(elementData, extendedData);
template = await _templateRepository.InsertAsync(template);
await CurrentUnitOfWork!.SaveChangesAsync();
var templateDto = ObjectMapper.Map<Template, TemplateDto>(template);
await SetTemplatePermissions(templateDto);
return templateDto;
}
[Authorize(PrintDesignerPermissions.Template.Delete)]
public async virtual Task<TemplateDeleteDto> DeleteAsync(Guid id)
{
bool success;
try
{
var template = await _templateRepository.GetAsync(id);
await _templateRepository.DeleteAsync(template);
success = true;
}
catch (Exception ex)
{
Logger.LogWarning(ex, "Delete template: {id} failed: {message}!", id, ex.Message);
success = false;
}
return new TemplateDeleteDto
{
Success = success,
};
}
public async virtual Task<TemplateDto> GetAsync(Guid id)
{
var template = await _templateRepository.GetAsync(id);
var templateDto = ObjectMapper.Map<Template, TemplateDto>(template);
await SetTemplatePermissions(templateDto);
return templateDto;
}
public async virtual Task<TemplateDto> GetByNameAsync(string name)
{
var template = await _templateRepository.FindByNameAsync(name, includeDetails: true)
?? throw new BusinessException(PrintDesignerErrorCodes.Template.NameNotFound)
.WithData("Name", name);
var templateDto = ObjectMapper.Map<Template, TemplateDto>(template);
await SetTemplatePermissions(templateDto);
return templateDto;
}
public async virtual Task<ListResultDto<TemplateDto>> GetAllAsync()
{
var templates = await _templateRepository.GetListAsync();
var templateDtos = ObjectMapper.Map<List<Template>, List<TemplateDto>>(templates);
await SetTemplatesPermissions(templateDtos);
return new ListResultDto<TemplateDto>(templateDtos);
}
public async virtual Task<PagedResultDto<TemplateDto>> GetListAsync(TemplateGetPagedListInput input)
{
var specification = new TemplateGetPagedListSpecification(input);
var totalCount = await _templateRepository.GetCountAsync(specification);
var templates = await _templateRepository.GetListAsync(specification,
input.Sorting, input.MaxResultCount, input.SkipCount);
var templateDtos = ObjectMapper.Map<List<Template>, List<TemplateDto>>(templates);
await SetTemplatesPermissions(templateDtos);
return new PagedResultDto<TemplateDto>(totalCount, templateDtos);
}
[Authorize(PrintDesignerPermissions.Template.Update)]
public async virtual Task<TemplateDto> UpdateAsync(Guid id, TemplateUpdateDto input)
{
var template = await _templateRepository.GetAsync(id);
if (!string.Equals(template.Name, input.Name, StringComparison.CurrentCultureIgnoreCase))
{
if (await _templateRepository.FindByNameAsync(input.Name) != null)
{
throw new BusinessException(
PrintDesignerErrorCodes.Template.NameAlreadyExists,
$"A template definition named {input.Name} already exists.!")
.WithData("Name", input.Name);
}
template.SetName(input.Name);
}
var elementData = _jsonSerializer.Serialize(input.Data);
var extendedData = _jsonSerializer.Serialize(input.Ext);
template.SetData(elementData, extendedData);
template.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp);
template = await _templateRepository.UpdateAsync(template);
await CurrentUnitOfWork!.SaveChangesAsync();
var templateDto = ObjectMapper.Map<Template, TemplateDto>(template);
await SetTemplatePermissions(templateDto);
return templateDto;
}
public async virtual Task<TemplateDto> UpsertAsync(TemplateUpsertDto input)
{
if (input.Id.HasValue &&
await _templateRepository.FindAsync(input.Id.Value) != null)
{
await AuthorizationService.CheckAsync(PrintDesignerPermissions.Template.Update);
return await UpdateAsync(
input.Id.Value,
new TemplateUpdateDto
{
Name = input.Name,
Data = input.Data,
Ext = input.Ext,
Description = input.Description,
ConcurrencyStamp = input.ConcurrencyStamp,
});
}
else
{
await AuthorizationService.CheckAsync(PrintDesignerPermissions.Template.Create);
return await CreateAsync(
new TemplateCreateDto
{
Name = input.Name,
Data = input.Data,
Ext = input.Ext,
Description = input.Description,
});
}
}
protected async virtual Task SetTemplatePermissions(TemplateDto templateDto)
{
templateDto.Permissions ??= new TemplatePermissionDto();
templateDto.Permissions.Editable = await AuthorizationService.IsGrantedAsync(PrintDesignerPermissions.Template.Update);
templateDto.Permissions.Deletable = await AuthorizationService.IsGrantedAsync(PrintDesignerPermissions.Template.Delete);
templateDto.Permissions.Copyable = await AuthorizationService.IsGrantedAsync(PrintDesignerPermissions.Template.Copy);
}
protected async virtual Task SetTemplatesPermissions(List<TemplateDto> templateDtos)
{
var editable = await AuthorizationService.IsGrantedAsync(PrintDesignerPermissions.Template.Update);
var deletable = await AuthorizationService.IsGrantedAsync(PrintDesignerPermissions.Template.Delete);
var copyable = await AuthorizationService.IsGrantedAsync(PrintDesignerPermissions.Template.Copy);
foreach (var templateDto in templateDtos)
{
templateDto.Permissions ??= new TemplatePermissionDto();
templateDto.Permissions.Editable = editable;
templateDto.Permissions.Deletable = deletable;
templateDto.Permissions.Copyable = copyable;
}
}
}

24
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/Templates/TemplateGetPagedListSpecification.cs

@ -0,0 +1,24 @@
using LINGYUN.Abp.PrintDesigner.Templates.Dtos;
using System;
using System.Linq.Expressions;
using Volo.Abp.Specifications;
namespace LINGYUN.Abp.PrintDesigner.Templates;
public class TemplateGetPagedListSpecification : Specification<Template>
{
protected TemplateGetPagedListInput Input { get; }
public TemplateGetPagedListSpecification(TemplateGetPagedListInput input)
{
Input = input;
}
public override Expression<Func<Template, bool>> ToExpression()
{
Expression<Func<Template, bool>> expression = _ => true;
return expression
.AndIf(!Input.Filter.IsNullOrWhiteSpace(), x =>
x.Name.Contains(Input.Filter!) ||
(x.Description != null && x.Description.Contains(Input.Filter!)));
}
}

32
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/System/Linq/Expressions/ExpressionFuncExtensions.cs

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

27
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN.Abp.PrintDesigner.Domain.Shared.csproj

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\configureawait.props" />
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0;net9.0;net10.0</TargetFrameworks>
<AssemblyName>LINGYUN.Abp.PrintDesigner.Domain.Shared</AssemblyName>
<PackageId>LINGYUN.Abp.PrintDesigner.Domain.Shared</PackageId>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<None Remove="LINGYUN\Abp\PrintDesigner\Localization\Resources\*.json" />
<EmbeddedResource Include="LINGYUN\Abp\PrintDesigner\Localization\Resources\*.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Validation" />
<PackageReference Include="Volo.Abp.MultiTenancy.Abstractions" />
</ItemGroup>
</Project>

35
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerDomainSharedModule.cs

@ -0,0 +1,35 @@
using LINGYUN.Abp.PrintDesigner.Localization;
using Volo.Abp.Localization;
using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Modularity;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Validation;
using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.Abp.PrintDesigner;
[DependsOn(
typeof(AbpValidationModule),
typeof(AbpMultiTenancyAbstractionsModule))]
public class AbpPrintDesignerDomainSharedModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpPrintDesignerDomainSharedModule>();
});
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Add<PrintDesignerResource>()
.AddVirtualJson("/LINGYUN/Abp/PrintDesigner/Localization/Resources");
});
Configure<AbpExceptionLocalizationOptions>(options =>
{
options.MapCodeNamespace(PrintDesignerErrorCodes.Namespace, typeof(PrintDesignerResource));
});
}
}

7
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementConsts.cs

@ -0,0 +1,7 @@
namespace LINGYUN.Abp.PrintDesigner.CustomElements;
public static class CustomElementConsts
{
public static int MaxNameLength { get; set; } = 64;
public static int MaxDescriptionLength { get; set; } = 256;
}

8
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/Localization/PrintDesignerResource.cs

@ -0,0 +1,8 @@
using Volo.Abp.Localization;
namespace LINGYUN.Abp.PrintDesigner.Localization;
[LocalizationResourceName("PrintDesigner")]
public class PrintDesignerResource
{
}

28
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/Localization/Resources/en.json

@ -0,0 +1,28 @@
{
"culture": "en",
"texts": {
"Features:PrintDesigner": "Print Designer",
"Permission:PrintDesigner": "Print Designer",
"Permission:ManageSettings": "Manage Settings",
"Permission:CustomElement": "Manage Custom Element",
"Permission:Template": "Manage Template",
"Permission:Create": "Create",
"Permission:Delete": "Delete",
"Permission:Update": "Update",
"Permission:Copy": "Copy",
"PrintDesigner:001001": "A custom element definition named {Name} already exists.!",
"PrintDesigner:002001": "A template definition named {Name} already exists.!",
"PrintDesigner:002002": "{Name} template not found!",
"Templates": "Template Management",
"DisplayName:Name": "Name",
"DisplayName:Description": "Description",
"DisplayName:TemplateId": "Template Id",
"DisplayName:CreationTime": "Creation Time",
"Templates:AddNew": "Add New Template",
"Templates:Market": "Template Market",
"Templates:Design": "Design Template",
"Templates:Create": "Create Template",
"Templates:Edit": "Edit Template",
"Templates:Print": "Print Template"
}
}

28
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/Localization/Resources/zh-Hans.json

@ -0,0 +1,28 @@
{
"culture": "zh-Hans",
"texts": {
"Features:PrintDesigner": "PrintDesigner",
"Permission:PrintDesigner": "PrintDesigner",
"Permission:ManageSettings": "管理设置",
"Permission:CustomElement": "管理自定义元素",
"Permission:Template": "管理模板",
"Permission:Create": "新增",
"Permission:Delete": "删除",
"Permission:Update": "编辑",
"Permission:Copy": "复制",
"PrintDesigner:001001": "已经存在名为 {Name} 的自定义元素定义!",
"PrintDesigner:002001": "已经存在名为 {Name} 的模板定义!",
"PrintDesigner:002002": "{Name} 模板不存在!",
"Templates": "模板管理",
"DisplayName:Name": "名称",
"DisplayName:Description": "描述",
"DisplayName:TemplateId": "模板Id",
"DisplayName:CreationTime": "创建时间",
"Templates:AddNew": "添加新模板",
"Templates:Market": "模板市场",
"Templates:Design": "设计模板",
"Templates:Create": "新增模板",
"Templates:Edit": "编辑模板",
"Templates:Print": "打印模板"
}
}

28
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/PrintDesignerErrorCodes.cs

@ -0,0 +1,28 @@
namespace LINGYUN.Abp.PrintDesigner;
public static class PrintDesignerErrorCodes
{
public const string Namespace = "PrintDesigner";
public static class CustomElement
{
public const string Prefix = Namespace + ":001";
/// <summary>
/// 已经存在名为 {Name} 的自定义元素定义!
/// </summary>
public const string NameAlreadyExists = Prefix + "001";
}
public static class Template
{
public const string Prefix = Namespace + ":002";
/// <summary>
/// 已经存在名为 {Name} 的模板定义!
/// </summary>
public const string NameAlreadyExists = Prefix + "001";
/// <summary>
/// {Name} 模板不存在!
/// </summary>
public const string NameNotFound = Prefix + "002";
}
}

7
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/Templates/TemplateConsts.cs

@ -0,0 +1,7 @@
namespace LINGYUN.Abp.PrintDesigner.Templates;
public static class TemplateConsts
{
public static int MaxNameLength { get; set; } = 64;
public static int MaxDescriptionLength { get; set; } = 256;
}

26
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN.Abp.PrintDesigner.Domain.csproj

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\configureawait.props" />
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<AssemblyName>LINGYUN.Abp.PrintDesigner.Domain</AssemblyName>
<PackageId>LINGYUN.Abp.PrintDesigner.Domain</PackageId>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Ddd.Domain" />
<PackageReference Include="Volo.Abp.Mapperly" />
<PackageReference Include="Volo.Abp.Json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.PrintDesigner.Domain.Shared\LINGYUN.Abp.PrintDesigner.Domain.Shared.csproj" />
</ItemGroup>
</Project>

18
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerDomainModule.cs

@ -0,0 +1,18 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Json;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.PrintDesigner;
[DependsOn(
typeof(AbpJsonModule),
typeof(AbpMapperlyModule),
typeof(AbpPrintDesignerDomainSharedModule))]
public class AbpPrintDesignerDomainModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddMapperlyObjectMapper<AbpPrintDesignerDomainModule>();
}
}

69
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElement.cs

@ -0,0 +1,69 @@
using System;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;
namespace LINGYUN.Abp.PrintDesigner.CustomElements;
/// <summary>
/// 自定义元素
/// </summary>
public class CustomElement : AuditedAggregateRoot<Guid>, IMultiTenant
{
public Guid? TenantId { get; private set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; private set; } = default!;
/// <summary>
/// 描述
/// </summary>
public string? Description { get; set; }
/// <summary>
/// 元素数据
/// </summary>
public virtual CustomElementData? Data { get; private set; }
protected CustomElement()
{
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties();
}
public CustomElement(
Guid id,
string name,
string? description = null,
Guid? tenantId = null)
: base(id)
{
SetName(name);
Description = Check.Length(description, nameof(description), CustomElementConsts.MaxDescriptionLength);
TenantId = tenantId;
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties();
}
/// <summary>
/// 设置名称
/// </summary>
/// <param name="name"></param>
public void SetName(string name)
{
Name = Check.NotNullOrWhiteSpace(name, nameof(name), CustomElementConsts.MaxNameLength);
}
/// <summary>
/// 设置元素数据
/// </summary>
/// <param name="elementData"></param>
/// <param name="extendedData"></param>
public void SetData(string elementData, string? extendedData = null)
{
Data ??= new CustomElementData(Id, TenantId);
Data.SetDesignerData(elementData);
Data.SetExtendedData(extendedData);
}
}

56
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementData.cs

@ -0,0 +1,56 @@
using System;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities;
using Volo.Abp.MultiTenancy;
namespace LINGYUN.Abp.PrintDesigner.CustomElements;
public class CustomElementData : AggregateRoot<long>, IMultiTenant
{
public Guid? TenantId { get; private set; }
/// <summary>
/// 元素Id
/// </summary>
public Guid ElementId { get; private set; }
/// <summary>
/// 元素数据
/// </summary>
public string? ElementData { get; private set; }
/// <summary>
/// 扩展字段
/// </summary>
public string? ExtendedData { get; private set; }
protected CustomElementData()
{
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties();
}
internal CustomElementData(
Guid elementId,
Guid? tenantId = null)
{
ElementId = elementId;
TenantId = tenantId;
}
/// <summary>
/// 设置元素数据
/// </summary>
/// <param name="elementData"></param>
public void SetDesignerData(string elementData)
{
ElementData = Check.NotNullOrWhiteSpace(elementData, nameof(elementData));
}
/// <summary>
/// 设置扩展字段容器数据
/// </summary>
/// <param name="extendedData"></param>
public void SetExtendedData(string? extendedData = null)
{
ExtendedData = extendedData;
}
}

57
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementDataSeeder.cs

@ -0,0 +1,57 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.Json;
using Volo.Abp.MultiTenancy;
namespace LINGYUN.Abp.PrintDesigner.CustomElements;
public class CustomElementDataSeeder : ICustomElementDataSeeder, ITransientDependency
{
private readonly ICurrentTenant _currentTenant;
private readonly IGuidGenerator _guidGenerator;
private readonly IJsonSerializer _jsonSerializer;
private readonly ICustomElementRepository _customElementRepository;
public CustomElementDataSeeder(
ICurrentTenant currentTenant,
IGuidGenerator guidGenerator,
IJsonSerializer jsonSerializer,
ICustomElementRepository customElementRepository)
{
_currentTenant = currentTenant;
_guidGenerator = guidGenerator;
_jsonSerializer = jsonSerializer;
_customElementRepository = customElementRepository;
}
public async virtual Task SeedAsync(
string name,
string? designerData = null,
string? extendedData = null,
CancellationToken cancellationToken = default)
{
if (await _customElementRepository.FindByNameAsync(name, cancellationToken: cancellationToken) == null)
{
var customElement = new CustomElement(
_guidGenerator.Create(),
name,
tenantId: _currentTenant.Id);
customElement.SetData(designerData ?? "{}", extendedData ?? "{}");
await _customElementRepository.InsertAsync(customElement, cancellationToken: cancellationToken);
}
}
public async virtual Task SeedAsync(
string name,
Dictionary<string, object>? designerData = null,
Dictionary<string, object>? extendedData = null,
CancellationToken cancellationToken = default)
{
var data = _jsonSerializer.Serialize(designerData ?? new Dictionary<string, object>());
var extData = _jsonSerializer.Serialize(extendedData ?? new Dictionary<string, object>());
await SeedAsync(name, data, extData, cancellationToken);
}
}

20
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/ICustomElementDataSeeder.cs

@ -0,0 +1,20 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace LINGYUN.Abp.PrintDesigner.CustomElements;
public interface ICustomElementDataSeeder
{
Task SeedAsync(
string name,
string? designerData = null,
string? extendedData = null,
CancellationToken cancellationToken = default);
Task SeedAsync(
string name,
Dictionary<string, object>? designerData = null,
Dictionary<string, object>? extendedData = null,
CancellationToken cancellationToken = default);
}

27
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/ICustomElementRepository.cs

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Specifications;
namespace LINGYUN.Abp.PrintDesigner.CustomElements;
public interface ICustomElementRepository : IBasicRepository<CustomElement, Guid>
{
Task<CustomElement?> FindByNameAsync(
string name,
bool includeDetails = false,
CancellationToken cancellationToken = default);
Task<int> GetCountAsync(
ISpecification<CustomElement> specification,
CancellationToken cancellationToken = default);
Task<List<CustomElement>> GetListAsync(
ISpecification<CustomElement> specification,
string? sorting = nameof(CustomElement.Name),
int maxResultCount = 10,
int skipCount = 0,
CancellationToken cancellationToken = default);
}

12
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/PrintDesignerDbProperties.cs

@ -0,0 +1,12 @@
using Volo.Abp.Data;
namespace LINGYUN.Abp.PrintDesigner;
public static class PrintDesignerDbProperties
{
public static string DbTablePrefix { get; set; } = AbpCommonDbProperties.DbTablePrefix + "PrintDesigner";
public static string? DbSchema { get; set; } = AbpCommonDbProperties.DbSchema;
public const string ConnectionStringName = "AbpPrintDesigner";
}

2
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/PrintDesignerDomainMappers.cs

@ -0,0 +1,2 @@
namespace LINGYUN.Abp.PrintDesigner;

20
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/ITemplateDataSeeder.cs

@ -0,0 +1,20 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace LINGYUN.Abp.PrintDesigner.Templates;
public interface ITemplateDataSeeder
{
Task SeedAsync(
string name,
string? designerData = null,
string? extendedData = null,
CancellationToken cancellationToken = default);
Task SeedAsync(
string name,
Dictionary<string, object>? designerData = null,
Dictionary<string, object>? extendedData = null,
CancellationToken cancellationToken = default);
}

27
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/ITemplateRepository.cs

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Specifications;
namespace LINGYUN.Abp.PrintDesigner.Templates;
public interface ITemplateRepository : IBasicRepository<Template, Guid>
{
Task<Template?> FindByNameAsync(
string name,
bool includeDetails = false,
CancellationToken cancellationToken = default);
Task<int> GetCountAsync(
ISpecification<Template> specification,
CancellationToken cancellationToken = default);
Task<List<Template>> GetListAsync(
ISpecification<Template> specification,
string? sorting = nameof(Template.Name),
int maxResultCount = 10,
int skipCount = 0,
CancellationToken cancellationToken = default);
}

69
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/Template.cs

@ -0,0 +1,69 @@
using System;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;
namespace LINGYUN.Abp.PrintDesigner.Templates;
/// <summary>
/// 模板
/// </summary>
public class Template : AuditedAggregateRoot<Guid>, IMultiTenant
{
public Guid? TenantId { get; private set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; private set; } = default!;
/// <summary>
/// 描述
/// </summary>
public string? Description { get; set; }
/// <summary>
/// 模板数据
/// </summary>
public virtual TemplateData? Data { get; private set; }
protected Template()
{
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties();
}
public Template(
Guid id,
string name,
string? description = null,
Guid? tenantId = null)
: base(id)
{
SetName(name);
Description = Check.Length(description, nameof(description), TemplateConsts.MaxDescriptionLength);
TenantId = tenantId;
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties();
}
/// <summary>
/// 设置名称
/// </summary>
/// <param name="name"></param>
public void SetName(string name)
{
Name = Check.NotNullOrWhiteSpace(name, nameof(name), TemplateConsts.MaxNameLength);
}
/// <summary>
/// 设置模板数据
/// </summary>
/// <param name="designerData"></param>
/// <param name="extendedData"></param>
public void SetData(string designerData, string? extendedData = null)
{
Data ??= new TemplateData(Id, TenantId);
Data.SetDesignerData(designerData);
Data.SetExtendedData(extendedData);
}
}

56
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/TemplateData.cs

@ -0,0 +1,56 @@
using System;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities;
using Volo.Abp.MultiTenancy;
namespace LINGYUN.Abp.PrintDesigner.Templates;
public class TemplateData : AggregateRoot<long>, IMultiTenant
{
public Guid? TenantId { get; private set; }
/// <summary>
/// 模板Id
/// </summary>
public Guid TemplateId { get; private set; }
/// <summary>
/// 模板设计数据
/// </summary>
public string? DesignerData { get; private set; }
/// <summary>
/// 扩展字段
/// </summary>
public string? ExtendedData { get; private set; }
protected TemplateData()
{
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties();
}
internal TemplateData(
Guid templateId,
Guid? tenantId = null)
{
TemplateId = templateId;
TenantId = tenantId;
}
/// <summary>
/// 设置模板设计数据
/// </summary>
/// <param name="designerData"></param>
public void SetDesignerData(string designerData)
{
DesignerData = Check.NotNullOrWhiteSpace(designerData, nameof(designerData));
}
/// <summary>
/// 设置扩展字段容器数据
/// </summary>
/// <param name="extendedData"></param>
public void SetExtendedData(string? extendedData = null)
{
ExtendedData = extendedData;
}
}

57
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/TemplateDataSeeder.cs

@ -0,0 +1,57 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.Json;
using Volo.Abp.MultiTenancy;
namespace LINGYUN.Abp.PrintDesigner.Templates;
public class TemplateDataSeeder : ITemplateDataSeeder, ITransientDependency
{
private readonly ICurrentTenant _currentTenant;
private readonly IGuidGenerator _guidGenerator;
private readonly IJsonSerializer _jsonSerializer;
private readonly ITemplateRepository _templateRepository;
public TemplateDataSeeder(
ICurrentTenant currentTenant,
IGuidGenerator guidGenerator,
IJsonSerializer jsonSerializer,
ITemplateRepository templateRepository)
{
_currentTenant = currentTenant;
_guidGenerator = guidGenerator;
_jsonSerializer = jsonSerializer;
_templateRepository = templateRepository;
}
public async virtual Task SeedAsync(
string name,
string? designerData = null,
string? extendedData = null,
CancellationToken cancellationToken = default)
{
if (await _templateRepository.FindByNameAsync(name, cancellationToken: cancellationToken) == null)
{
var template = new Template(
_guidGenerator.Create(),
name,
tenantId: _currentTenant.Id);
template.SetData(designerData ?? "{}", extendedData ?? "{}");
await _templateRepository.InsertAsync(template, cancellationToken: cancellationToken);
}
}
public async virtual Task SeedAsync(
string name,
Dictionary<string, object>? designerData = null,
Dictionary<string, object>? extendedData = null,
CancellationToken cancellationToken = default)
{
var data = _jsonSerializer.Serialize(designerData ?? new Dictionary<string, object>());
var extData = _jsonSerializer.Serialize(extendedData ?? new Dictionary<string, object>());
await SeedAsync(name, data, extData, cancellationToken);
}
}

24
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore.csproj

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\configureawait.props" />
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<AssemblyName>LINGYUN.Abp.PrintDesigner.EntityFrameworkCore</AssemblyName>
<PackageId>LINGYUN.Abp.PrintDesigner.EntityFrameworkCore</PackageId>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.EntityFrameworkCore" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.PrintDesigner.Domain\LINGYUN.Abp.PrintDesigner.Domain.csproj" />
</ItemGroup>
</Project>

56
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/CustomElements/EfCoreCustomElementRepository.cs

@ -0,0 +1,56 @@
using LINGYUN.Abp.PrintDesigner.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Specifications;
namespace LINGYUN.Abp.PrintDesigner.CustomElements;
public class EfCoreCustomElementRepository : EfCoreRepository<IPrintDesignerDbContext, CustomElement, Guid>, ICustomElementRepository
{
public EfCoreCustomElementRepository(
IDbContextProvider<IPrintDesignerDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
public async virtual Task<CustomElement?> FindByNameAsync(
string name,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetQueryableAsync())
.IncludeIf(includeDetails, x => x.Data)
.Where(x => x.Name == name)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
}
public async virtual Task<int> GetCountAsync(
ISpecification<CustomElement> specification,
CancellationToken cancellationToken = default)
{
return await (await GetQueryableAsync())
.Where(specification.ToExpression())
.CountAsync(GetCancellationToken(cancellationToken));
}
public async virtual Task<List<CustomElement>> GetListAsync(
ISpecification<CustomElement> specification,
string? sorting = nameof(CustomElement.Name),
int maxResultCount = 10,
int skipCount = 0,
CancellationToken cancellationToken = default)
{
return await (await GetQueryableAsync())
.Where(specification.ToExpression())
.OrderBy(!sorting.IsNullOrWhiteSpace() ? sorting : nameof(CustomElement.Name))
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
}

39
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/AbpPrintDesignerEntityFrameworkCoreModule.cs

@ -0,0 +1,39 @@
using LINGYUN.Abp.PrintDesigner.CustomElements;
using LINGYUN.Abp.PrintDesigner.Templates;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.DependencyInjection;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.PrintDesigner.EntityFrameworkCore;
[DependsOn(
typeof(AbpPrintDesignerDomainModule),
typeof(AbpEntityFrameworkCoreModule))]
public class AbpPrintDesignerEntityFrameworkCoreModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<PrintDesignerDbContext>(options =>
{
options.AddRepository<CustomElement, EfCoreCustomElementRepository>();
options.AddRepository<Template, EfCoreTemplateRepository>();
options.AddDefaultRepositories<IPrintDesignerDbContext>();
});
Configure<AbpEntityOptions>(options =>
{
options.Entity<CustomElement>(e =>
{
e.DefaultWithDetailsFunc = x => x.Include(t => t.Data);
});
options.Entity<Template>(e =>
{
e.DefaultWithDetailsFunc = x => x.Include(t => t.Data);
});
});
}
}

14
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/IPrintDesignerDbContext.cs

@ -0,0 +1,14 @@
using LINGYUN.Abp.PrintDesigner.CustomElements;
using LINGYUN.Abp.PrintDesigner.Templates;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Abp.PrintDesigner.EntityFrameworkCore;
[ConnectionStringName(PrintDesignerDbProperties.ConnectionStringName)]
public interface IPrintDesignerDbContext : IEfCoreDbContext
{
DbSet<CustomElement> CustomElements { get; }
DbSet<Template> Templates { get; }
}

26
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/PrintDesignerDbContext.cs

@ -0,0 +1,26 @@
using LINGYUN.Abp.PrintDesigner.CustomElements;
using LINGYUN.Abp.PrintDesigner.Templates;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Abp.PrintDesigner.EntityFrameworkCore;
[ConnectionStringName(PrintDesignerDbProperties.ConnectionStringName)]
public class PrintDesignerDbContext : AbpDbContext<PrintDesignerDbContext>, IPrintDesignerDbContext
{
public DbSet<CustomElement> CustomElements { get; set; }
public DbSet<Template> Templates { get; set; }
public PrintDesignerDbContext(
DbContextOptions<PrintDesignerDbContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigurePrintDesigner();
}
}

81
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/PrintDesignerDbContextModelCreatingExtensions.cs

@ -0,0 +1,81 @@
using LINGYUN.Abp.PrintDesigner.CustomElements;
using LINGYUN.Abp.PrintDesigner.Templates;
using Microsoft.EntityFrameworkCore;
using System;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling;
namespace LINGYUN.Abp.PrintDesigner.EntityFrameworkCore;
public static class PrintDesignerDbContextModelCreatingExtensions
{
public static void ConfigurePrintDesigner(
this ModelBuilder builder,
Action<PrintDesignerModelBuilderConfigurationOptions>? optionsAction = null)
{
Check.NotNull(builder, nameof(builder));
var options = new PrintDesignerModelBuilderConfigurationOptions(
PrintDesignerDbProperties.DbTablePrefix,
PrintDesignerDbProperties.DbSchema
);
optionsAction?.Invoke(options);
builder.Entity<CustomElement>(e =>
{
e.ToTable(options.TablePrefix + "CustomElements", options.Schema);
e.Property(p => p.Name)
.HasMaxLength(CustomElementConsts.MaxNameLength)
.HasColumnName(nameof(CustomElement.Name))
.IsRequired();
e.Property(p => p.Description)
.HasMaxLength(CustomElementConsts.MaxDescriptionLength)
.HasColumnName(nameof(CustomElement.Description));
e.ConfigureByConvention();
e.HasOne(p => p.Data)
.WithOne()
.HasPrincipalKey<CustomElement>(pk => pk.Id)
.HasForeignKey<CustomElementData>(pk => pk.ElementId)
.IsRequired();
e.HasIndex(x => x.Name).IsUnique();
});
builder.Entity<CustomElementData>(e =>
{
e.ToTable(options.TablePrefix + "CustomElementDatas", options.Schema);
e.ConfigureByConvention();
});
builder.Entity<Template>(e =>
{
e.ToTable(options.TablePrefix + "Templates", options.Schema);
e.Property(p => p.Name)
.HasMaxLength(TemplateConsts.MaxNameLength)
.HasColumnName(nameof(Template.Name))
.IsRequired();
e.Property(p => p.Description)
.HasMaxLength(TemplateConsts.MaxDescriptionLength)
.HasColumnName(nameof(Template.Description));
e.ConfigureByConvention();
e.HasOne(p => p.Data)
.WithOne()
.HasPrincipalKey<Template>(pk => pk.Id)
.HasForeignKey<TemplateData>(pk => pk.TemplateId);
e.HasIndex(x => x.Name).IsUnique();
});
builder.Entity<TemplateData>(e =>
{
e.ToTable(options.TablePrefix + "TemplateDatas", options.Schema);
e.ConfigureByConvention();
});
}
}

17
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/PrintDesignerModelBuilderConfigurationOptions.cs

@ -0,0 +1,17 @@
using JetBrains.Annotations;
using Volo.Abp.EntityFrameworkCore.Modeling;
namespace LINGYUN.Abp.PrintDesigner.EntityFrameworkCore;
public class PrintDesignerModelBuilderConfigurationOptions : AbpModelBuilderConfigurationOptions
{
public PrintDesignerModelBuilderConfigurationOptions(
[NotNull] string tablePrefix = "",
[CanBeNull] string? schema = null)
: base(
tablePrefix,
schema)
{
}
}

56
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/Templates/EfCoreTemplateRepository.cs

@ -0,0 +1,56 @@
using LINGYUN.Abp.PrintDesigner.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Specifications;
namespace LINGYUN.Abp.PrintDesigner.Templates;
public class EfCoreTemplateRepository : EfCoreRepository<IPrintDesignerDbContext, Template, Guid>, ITemplateRepository
{
public EfCoreTemplateRepository(
IDbContextProvider<IPrintDesignerDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
public async virtual Task<Template?> FindByNameAsync(
string name,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetQueryableAsync())
.IncludeIf(includeDetails, x => x.Data)
.Where(x => x.Name == name)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
}
public async virtual Task<int> GetCountAsync(
ISpecification<Template> specification,
CancellationToken cancellationToken = default)
{
return await (await GetQueryableAsync())
.Where(specification.ToExpression())
.CountAsync(GetCancellationToken(cancellationToken));
}
public async virtual Task<List<Template>> GetListAsync(
ISpecification<Template> specification,
string? sorting = nameof(Template.Name),
int maxResultCount = 10,
int skipCount = 0,
CancellationToken cancellationToken = default)
{
return await (await GetQueryableAsync())
.Where(specification.ToExpression())
.OrderBy(!sorting.IsNullOrWhiteSpace() ? sorting : nameof(Template.Name))
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
}

25
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN.Abp.PrintDesigner.HttpApi.csproj

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\configureawait.props" />
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<AssemblyName>LINGYUN.Abp.PrintDesigner.HttpApi</AssemblyName>
<PackageId>LINGYUN.Abp.PrintDesigner.HttpApi</PackageId>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.PrintDesigner.Application.Contracts\LINGYUN.Abp.PrintDesigner.Application.Contracts.csproj" />
</ItemGroup>
</Project>

40
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerHttpApiModule.cs

@ -0,0 +1,40 @@
using LINGYUN.Abp.PrintDesigner.Localization;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.Validation.Localization;
namespace LINGYUN.Abp.PrintDesigner;
[DependsOn(
typeof(AbpAspNetCoreMvcModule),
typeof(AbpPrintDesignerApplicationContractsModule))]
public class AbpPrintDesignerHttpApiModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<IMvcBuilder>(mvcBuilder =>
{
mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpPrintDesignerHttpApiModule).Assembly);
});
PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
{
options.AddAssemblyResource(
typeof(PrintDesignerResource),
typeof(AbpPrintDesignerApplicationContractsModule).Assembly);
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Get<PrintDesignerResource>()
.AddBaseTypes(typeof(AbpValidationResource));
});
}
}

63
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementController.cs

@ -0,0 +1,63 @@
using LINGYUN.Abp.PrintDesigner.CustomElements.Dtos;
using LINGYUN.Abp.PrintDesigner.Permissions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc;
namespace LINGYUN.Abp.PrintDesigner.CustomElements;
[Authorize(PrintDesignerPermissions.CustomElement.Default)]
[Area(PrintDesignerRemoteServiceConsts.RemoteServiceName)]
[RemoteService(Name = PrintDesignerRemoteServiceConsts.RemoteServiceName)]
[Route($"api/{PrintDesignerRemoteServiceConsts.ModuleName}/custom-elements")]
public class CustomElementController(ICustomElementAppService _service) : AbpControllerBase, ICustomElementAppService
{
[HttpPost]
[Authorize(PrintDesignerPermissions.CustomElement.Create)]
public virtual Task<CustomElementDto> CreateAsync(CustomElementCreateDto input)
{
return _service.CreateAsync(input);
}
[HttpDelete("{id}")]
[Authorize(PrintDesignerPermissions.CustomElement.Delete)]
public virtual Task<CustomElementDeleteDto> DeleteAsync(Guid id)
{
return _service.DeleteAsync(id);
}
[HttpGet("{id}")]
public virtual Task<CustomElementDto> GetAsync(Guid id)
{
return _service.GetAsync(id);
}
[HttpGet("all")]
public virtual Task<ListResultDto<CustomElementDto>> GetAllAsync()
{
return _service.GetAllAsync();
}
[HttpGet]
public virtual Task<PagedResultDto<CustomElementDto>> GetListAsync(CustomElementGetPagedListInput input)
{
return _service.GetListAsync(input);
}
[HttpPut("{id}")]
[Authorize(PrintDesignerPermissions.CustomElement.Update)]
public virtual Task<CustomElementDto> UpdateAsync(Guid id, CustomElementUpdateDto input)
{
return _service.UpdateAsync(id, input);
}
[HttpPost("upsert")]
public virtual Task<CustomElementDto> UpsertAsync(CustomElementUpsertDto input)
{
return _service.UpsertAsync(input);
}
}

70
aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN/Abp/PrintDesigner/Templates/TemplateController.cs

@ -0,0 +1,70 @@
using LINGYUN.Abp.PrintDesigner.Permissions;
using LINGYUN.Abp.PrintDesigner.Templates.Dtos;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using System;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc;
namespace LINGYUN.Abp.PrintDesigner.Templates;
[Authorize(PrintDesignerPermissions.Template.Default)]
[Area(PrintDesignerRemoteServiceConsts.RemoteServiceName)]
[RemoteService(Name = PrintDesignerRemoteServiceConsts.RemoteServiceName)]
[Route($"api/{PrintDesignerRemoteServiceConsts.ModuleName}/templates")]
public class TemplateController(ITemplateAppService _service) : AbpControllerBase, ITemplateAppService
{
[HttpPost]
[Authorize(PrintDesignerPermissions.Template.Create)]
public virtual Task<TemplateDto> CreateAsync(TemplateCreateDto input)
{
return _service.CreateAsync(input);
}
[HttpDelete("{id}")]
[Authorize(PrintDesignerPermissions.Template.Delete)]
public virtual Task<TemplateDeleteDto> DeleteAsync(Guid id)
{
return _service.DeleteAsync(id);
}
[HttpGet("{id}")]
public virtual Task<TemplateDto> GetAsync(Guid id)
{
return _service.GetAsync(id);
}
[HttpGet("by-name/{name}")]
public virtual Task<TemplateDto> GetByNameAsync(string name)
{
return _service.GetByNameAsync(name);
}
[HttpGet("all")]
public virtual Task<ListResultDto<TemplateDto>> GetAllAsync()
{
return _service.GetAllAsync();
}
[HttpGet]
public virtual Task<PagedResultDto<TemplateDto>> GetListAsync(TemplateGetPagedListInput input)
{
return _service.GetListAsync(input);
}
[HttpPut("{id}")]
[Authorize(PrintDesignerPermissions.Template.Update)]
public virtual Task<TemplateDto> UpdateAsync(Guid id, TemplateUpdateDto input)
{
return _service.UpdateAsync(id, input);
}
[HttpPost("upsert")]
public virtual Task<TemplateDto> UpsertAsync(TemplateUpsertDto input)
{
return _service.UpsertAsync(input);
}
}
Loading…
Cancel
Save