diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN.Abp.PrintDesigner.Application.Contracts.csproj b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN.Abp.PrintDesigner.Application.Contracts.csproj
new file mode 100644
index 000000000..55b93d3fe
--- /dev/null
+++ b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN.Abp.PrintDesigner.Application.Contracts.csproj
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+ netstandard2.0;netstandard2.1;net8.0;net9.0;net10.0
+ LINGYUN.Abp.PrintDesigner.Application.Contracts
+ LINGYUN.Abp.PrintDesigner.Application.Contracts
+ false
+ false
+ false
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerApplicationContractsModule.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerApplicationContractsModule.cs
new file mode 100644
index 000000000..b4fa966e6
--- /dev/null
+++ b/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
+{
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementCreateDto.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementCreateDto.cs
new file mode 100644
index 000000000..1f3b6b387
--- /dev/null
+++ b/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
+{
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementCreateOrUpdateDto.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementCreateOrUpdateDto.cs
new file mode 100644
index 000000000..ef56305d0
--- /dev/null
+++ b/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
+{
+ ///
+ /// 元素名称
+ ///
+ [Required]
+ [DynamicStringLength(typeof(CustomElementConsts), nameof(CustomElementConsts.MaxNameLength))]
+ public string Name { get; set; } = default!;
+ ///
+ /// 描述
+ ///
+ [DynamicStringLength(typeof(CustomElementConsts), nameof(CustomElementConsts.MaxDescriptionLength))]
+ public string? Description { get; set; }
+ ///
+ /// 元素定义
+ ///
+ [Required]
+ public Dictionary Element { get; set; } = new Dictionary();
+ ///
+ /// 元素扩展参数
+ ///
+ public Dictionary Ext { get; set; } = new Dictionary();
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementDeleteDto.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementDeleteDto.cs
new file mode 100644
index 000000000..ec67b1036
--- /dev/null
+++ b/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; }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementDto.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementDto.cs
new file mode 100644
index 000000000..a62349621
--- /dev/null
+++ b/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, IHasConcurrencyStamp
+{
+ ///
+ /// 名称
+ ///
+ public string Name { get; set; } = default!;
+ ///
+ /// 描述
+ ///
+ public string? Description { get; set; }
+ ///
+ /// 时间戳(毫秒)
+ ///
+ public long? UpdatedAt { get; set; }
+ ///
+ /// 元素数据
+ ///
+ public Dictionary? Element { get; set; }
+ ///
+ /// 扩展数据容器
+ ///
+ public Dictionary Ext { get; set; } = new Dictionary();
+ ///
+ /// 用于控制前端操作按钮权限
+ ///
+ public CustomElementPermissionDto? Permissions { get; set; }
+ ///
+ /// 并发令牌
+ ///
+ public string ConcurrencyStamp { get; set; } = default!;
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementGetPagedListInput.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementGetPagedListInput.cs
new file mode 100644
index 000000000..0d23210f4
--- /dev/null
+++ b/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; }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementPermissionDto.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementPermissionDto.cs
new file mode 100644
index 000000000..84624bcd4
--- /dev/null
+++ b/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; }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementUpdateDto.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementUpdateDto.cs
new file mode 100644
index 000000000..7703fa908
--- /dev/null
+++ b/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; }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementUpsertDto.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/Dtos/CustomElementUpsertDto.cs
new file mode 100644
index 000000000..121c3615e
--- /dev/null
+++ b/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; }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/ICustomElementAppService.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/CustomElements/ICustomElementAppService.cs
new file mode 100644
index 000000000..4ff6fc387
--- /dev/null
+++ b/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
+{
+ ///
+ /// 获取全部自定义元素列表
+ ///
+ ///
+ Task> GetAllAsync();
+ ///
+ /// 获取自定义元素列表
+ ///
+ /// 查询过滤参数
+ ///
+ Task> GetListAsync(CustomElementGetPagedListInput input);
+ ///
+ /// 获取自定义元素详情
+ ///
+ /// 自定义元素Id
+ ///
+ Task GetAsync(Guid id);
+ ///
+ /// 新增自定义元素
+ ///
+ ///
+ ///
+ Task CreateAsync(CustomElementCreateDto input);
+ ///
+ /// 编辑自定义元素
+ ///
+ /// 自定义元素Id
+ ///
+ ///
+ Task UpdateAsync(Guid id, CustomElementUpdateDto input);
+ ///
+ /// 新增或编辑自定义元素
+ ///
+ ///
+ /// 兼容upsert接口
+ ///
+ ///
+ ///
+ Task UpsertAsync(CustomElementUpsertDto input);
+ ///
+ /// 删除自定义元素
+ ///
+ /// 自定义元素Id
+ ///
+ Task DeleteAsync(Guid id);
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Permissions/PrintDesignerPermissionDefinitionProvider.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Permissions/PrintDesignerPermissionDefinitionProvider.cs
new file mode 100644
index 000000000..91dd66968
--- /dev/null
+++ b/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(name);
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Permissions/PrintDesignerPermissions.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Permissions/PrintDesignerPermissions.cs
new file mode 100644
index 000000000..0b6ed45c0
--- /dev/null
+++ b/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";
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/PrintDesignerRemoteServiceConsts.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/PrintDesignerRemoteServiceConsts.cs
new file mode 100644
index 000000000..d0d9ebf07
--- /dev/null
+++ b/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";
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateCreateDto.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateCreateDto.cs
new file mode 100644
index 000000000..91ee2b736
--- /dev/null
+++ b/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
+{
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateCreateOrUpdateDto.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateCreateOrUpdateDto.cs
new file mode 100644
index 000000000..0e3ddc1c5
--- /dev/null
+++ b/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
+{
+ ///
+ /// 名称
+ ///
+ [Required]
+ [DynamicStringLength(typeof(TemplateConsts), nameof(TemplateConsts.MaxNameLength))]
+ public string Name { get; set; } = default!;
+ ///
+ /// 描述
+ ///
+ [DynamicStringLength(typeof(TemplateConsts), nameof(TemplateConsts.MaxDescriptionLength))]
+ public string? Description { get; set; }
+ ///
+ /// 模板设计数据
+ ///
+ [Required]
+ public Dictionary Data { get; set; } = new Dictionary();
+ ///
+ /// 模板扩展参数容器
+ ///
+ public Dictionary Ext { get; set; } = new Dictionary();
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateDeleteDto.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateDeleteDto.cs
new file mode 100644
index 000000000..3dcde9353
--- /dev/null
+++ b/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; }
+}
+
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateDto.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateDto.cs
new file mode 100644
index 000000000..a0e1c68b6
--- /dev/null
+++ b/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, IHasConcurrencyStamp
+{
+ ///
+ /// 名称
+ ///
+ public string Name { get; set; } = default!;
+ ///
+ /// 描述
+ ///
+ public string? Description { get; set; }
+ ///
+ /// 时间戳(毫秒)
+ ///
+ public long? UpdatedAt { get; set; }
+ ///
+ /// 模板设计数据
+ ///
+ public Dictionary? Data { get; set; }
+ ///
+ /// 扩展数据容器
+ ///
+ public Dictionary Ext { get; set; } = new Dictionary();
+ ///
+ /// 用于控制前端操作按钮权限
+ ///
+ public TemplatePermissionDto? Permissions { get; set; }
+ ///
+ /// 并发令牌
+ ///
+ public string ConcurrencyStamp { get; set; } = default!;
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateGetPagedListInput.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateGetPagedListInput.cs
new file mode 100644
index 000000000..0adf06314
--- /dev/null
+++ b/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; }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplatePermissionDto.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplatePermissionDto.cs
new file mode 100644
index 000000000..5a0db342a
--- /dev/null
+++ b/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; }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateUpdateDto.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateUpdateDto.cs
new file mode 100644
index 000000000..8856bfb2e
--- /dev/null
+++ b/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; }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateUpsertDto.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/Dtos/TemplateUpsertDto.cs
new file mode 100644
index 000000000..e11c75f0b
--- /dev/null
+++ b/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; }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/ITemplateAppService.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application.Contracts/LINGYUN/Abp/PrintDesigner/Templates/ITemplateAppService.cs
new file mode 100644
index 000000000..478ba1561
--- /dev/null
+++ b/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
+{
+ ///
+ /// 获取全部模板列表
+ ///
+ ///
+ Task> GetAllAsync();
+ ///
+ /// 获取模板列表
+ ///
+ ///
+ Task> GetListAsync(TemplateGetPagedListInput input);
+ ///
+ /// 获取模板详情
+ ///
+ /// 模板Id
+ ///
+ Task GetAsync(Guid id);
+ ///
+ /// 获取模板详情
+ ///
+ /// 模板名称
+ ///
+ Task GetByNameAsync(string name);
+ ///
+ /// 新增模板
+ ///
+ ///
+ ///
+ Task CreateAsync(TemplateCreateDto input);
+ ///
+ /// 编辑模板
+ ///
+ /// 模板Id
+ ///
+ ///
+ Task UpdateAsync(Guid id, TemplateUpdateDto input);
+ ///
+ /// 新增或编辑模板
+ ///
+ ///
+ /// 兼容upsert接口
+ ///
+ ///
+ ///
+ Task UpsertAsync(TemplateUpsertDto input);
+ ///
+ /// 删除模板
+ ///
+ /// 模板Id
+ ///
+ Task DeleteAsync(Guid id);
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN.Abp.PrintDesigner.Application.csproj b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN.Abp.PrintDesigner.Application.csproj
new file mode 100644
index 000000000..140a8733d
--- /dev/null
+++ b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN.Abp.PrintDesigner.Application.csproj
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+ net10.0
+ LINGYUN.Abp.PrintDesigner.Application
+ LINGYUN.Abp.PrintDesigner.Application
+ false
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerApplicationModule.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerApplicationModule.cs
new file mode 100644
index 000000000..035b21432
--- /dev/null
+++ b/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();
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementAppService.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementAppService.cs
new file mode 100644
index 000000000..33be885dd
--- /dev/null
+++ b/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 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);
+
+ await SetCustomElementPermissions(customElementDto);
+
+ return customElementDto;
+ }
+
+ [Authorize(PrintDesignerPermissions.CustomElement.Delete)]
+ public async virtual Task 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 GetAsync(Guid id)
+ {
+ var customElement = await _customElementRepository.GetAsync(id);
+
+ var customElementDto = ObjectMapper.Map(customElement);
+
+ await SetCustomElementPermissions(customElementDto);
+
+ return customElementDto;
+ }
+
+ public async virtual Task> GetAllAsync()
+ {
+ var customElements = await _customElementRepository.GetListAsync();
+
+ var customElementDtos = ObjectMapper.Map, List>(customElements);
+
+ await SetCustomElementsPermissions(customElementDtos);
+
+ return new ListResultDto(customElementDtos);
+ }
+
+ public async virtual Task> 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>(customElements);
+
+ await SetCustomElementsPermissions(customElementDtos);
+
+ return new PagedResultDto(totalCount, customElementDtos);
+ }
+
+ [Authorize(PrintDesignerPermissions.CustomElement.Update)]
+ public async virtual Task 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);
+
+ await SetCustomElementPermissions(customElementDto);
+
+ return customElementDto;
+ }
+
+ public async virtual Task 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 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;
+ }
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementGetPagedListSpecification.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementGetPagedListSpecification.cs
new file mode 100644
index 000000000..fcb11f141
--- /dev/null
+++ b/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
+{
+ protected CustomElementGetPagedListInput Input { get; }
+ public CustomElementGetPagedListSpecification(CustomElementGetPagedListInput input)
+ {
+ Input = input;
+ }
+ public override Expression> ToExpression()
+ {
+ Expression> expression = _ => true;
+
+ return expression
+ .AndIf(!Input.Filter.IsNullOrWhiteSpace(), x =>
+ x.Name.Contains(Input.Filter!) ||
+ (x.Description != null && x.Description.Contains(Input.Filter!)));
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/PrintDesignerAppServiceBase.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/PrintDesignerAppServiceBase.cs
new file mode 100644
index 000000000..8fada0294
--- /dev/null
+++ b/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);
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/PrintDesignerApplicationMappers.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/PrintDesignerApplicationMappers.cs
new file mode 100644
index 000000000..356fd7621
--- /dev/null
+++ b/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
+{
+ 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();
+ destination.Ext = new Dictionary();
+ if (source.Data != null)
+ {
+ if (!source.Data.ElementData.IsNullOrWhiteSpace())
+ {
+ destination.Element = _jsonSerializer.Deserialize>(source.Data.ElementData);
+ }
+ if (!source.Data.ExtendedData.IsNullOrWhiteSpace())
+ {
+ destination.Ext = _jsonSerializer.Deserialize>(source.Data.ExtendedData);
+ }
+ }
+ }
+}
+
+[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
+[MapExtraProperties(DefinitionChecks = MappingPropertyDefinitionChecks.None)]
+public partial class TemplateToTemplateDtoMapper : MapperBase
+{
+ 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();
+ destination.Ext = new Dictionary();
+ if (source.Data != null)
+ {
+ if (!source.Data.DesignerData.IsNullOrWhiteSpace())
+ {
+ destination.Data = _jsonSerializer.Deserialize>(source.Data.DesignerData);
+ }
+ if (!source.Data.ExtendedData.IsNullOrWhiteSpace())
+ {
+ destination.Ext = _jsonSerializer.Deserialize>(source.Data.ExtendedData);
+ }
+ }
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/Templates/TemplateAppService.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/Templates/TemplateAppService.cs
new file mode 100644
index 000000000..0534a8b20
--- /dev/null
+++ b/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 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);
+
+ await SetTemplatePermissions(templateDto);
+
+ return templateDto;
+ }
+
+ [Authorize(PrintDesignerPermissions.Template.Delete)]
+ public async virtual Task 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 GetAsync(Guid id)
+ {
+ var template = await _templateRepository.GetAsync(id);
+
+ var templateDto = ObjectMapper.Map(template);
+
+ await SetTemplatePermissions(templateDto);
+
+ return templateDto;
+ }
+
+ public async virtual Task 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);
+
+ await SetTemplatePermissions(templateDto);
+
+ return templateDto;
+ }
+
+ public async virtual Task> GetAllAsync()
+ {
+ var templates = await _templateRepository.GetListAsync();
+
+ var templateDtos = ObjectMapper.Map, List>(templates);
+
+ await SetTemplatesPermissions(templateDtos);
+
+ return new ListResultDto(templateDtos);
+ }
+
+ public async virtual Task> 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>(templates);
+
+ await SetTemplatesPermissions(templateDtos);
+
+ return new PagedResultDto(totalCount, templateDtos);
+ }
+
+ [Authorize(PrintDesignerPermissions.Template.Update)]
+ public async virtual Task 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);
+
+ await SetTemplatePermissions(templateDto);
+
+ return templateDto;
+ }
+
+ public async virtual Task 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 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;
+ }
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/Templates/TemplateGetPagedListSpecification.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/LINGYUN/Abp/PrintDesigner/Templates/TemplateGetPagedListSpecification.cs
new file mode 100644
index 000000000..d9605a528
--- /dev/null
+++ b/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
+{
+ protected TemplateGetPagedListInput Input { get; }
+ public TemplateGetPagedListSpecification(TemplateGetPagedListInput input)
+ {
+ Input = input;
+ }
+ public override Expression> ToExpression()
+ {
+ Expression> expression = _ => true;
+
+ return expression
+ .AndIf(!Input.Filter.IsNullOrWhiteSpace(), x =>
+ x.Name.Contains(Input.Filter!) ||
+ (x.Description != null && x.Description.Contains(Input.Filter!)));
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/System/Linq/Expressions/ExpressionFuncExtensions.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Application/System/Linq/Expressions/ExpressionFuncExtensions.cs
new file mode 100644
index 000000000..fd7a017ea
--- /dev/null
+++ b/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> AndIf(
+ this Expression> first,
+ bool condition,
+ Expression> second)
+ {
+ if (condition)
+ {
+ return ExpressionFuncExtender.And(first, second);
+ }
+
+ return first;
+ }
+
+ public static Expression> OrIf(
+ this Expression> first,
+ bool condition,
+ Expression> second)
+ {
+ if (condition)
+ {
+ return ExpressionFuncExtender.Or(first, second);
+ }
+
+ return first;
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN.Abp.PrintDesigner.Domain.Shared.csproj b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN.Abp.PrintDesigner.Domain.Shared.csproj
new file mode 100644
index 000000000..ce795a406
--- /dev/null
+++ b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN.Abp.PrintDesigner.Domain.Shared.csproj
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+ netstandard2.0;netstandard2.1;net8.0;net9.0;net10.0
+ LINGYUN.Abp.PrintDesigner.Domain.Shared
+ LINGYUN.Abp.PrintDesigner.Domain.Shared
+ false
+ false
+ false
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerDomainSharedModule.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerDomainSharedModule.cs
new file mode 100644
index 000000000..157cb984b
--- /dev/null
+++ b/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(options =>
+ {
+ options.FileSets.AddEmbedded();
+ });
+
+ Configure(options =>
+ {
+ options.Resources
+ .Add()
+ .AddVirtualJson("/LINGYUN/Abp/PrintDesigner/Localization/Resources");
+ });
+
+ Configure(options =>
+ {
+ options.MapCodeNamespace(PrintDesignerErrorCodes.Namespace, typeof(PrintDesignerResource));
+ });
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementConsts.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementConsts.cs
new file mode 100644
index 000000000..ceddd0523
--- /dev/null
+++ b/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;
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/Localization/PrintDesignerResource.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/Localization/PrintDesignerResource.cs
new file mode 100644
index 000000000..7b3fcb09c
--- /dev/null
+++ b/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
+{
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/Localization/Resources/en.json b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/Localization/Resources/en.json
new file mode 100644
index 000000000..5e05ee3ac
--- /dev/null
+++ b/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"
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/Localization/Resources/zh-Hans.json b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/Localization/Resources/zh-Hans.json
new file mode 100644
index 000000000..f0de3aa8d
--- /dev/null
+++ b/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": "打印模板"
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/PrintDesignerErrorCodes.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/PrintDesignerErrorCodes.cs
new file mode 100644
index 000000000..f61c09e46
--- /dev/null
+++ b/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";
+ ///
+ /// 已经存在名为 {Name} 的自定义元素定义!
+ ///
+ public const string NameAlreadyExists = Prefix + "001";
+ }
+
+ public static class Template
+ {
+ public const string Prefix = Namespace + ":002";
+ ///
+ /// 已经存在名为 {Name} 的模板定义!
+ ///
+ public const string NameAlreadyExists = Prefix + "001";
+ ///
+ /// {Name} 模板不存在!
+ ///
+ public const string NameNotFound = Prefix + "002";
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/Templates/TemplateConsts.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain.Shared/LINGYUN/Abp/PrintDesigner/Templates/TemplateConsts.cs
new file mode 100644
index 000000000..887cfe98f
--- /dev/null
+++ b/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;
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN.Abp.PrintDesigner.Domain.csproj b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN.Abp.PrintDesigner.Domain.csproj
new file mode 100644
index 000000000..fafa1f520
--- /dev/null
+++ b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN.Abp.PrintDesigner.Domain.csproj
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+ net10.0
+ LINGYUN.Abp.PrintDesigner.Domain
+ LINGYUN.Abp.PrintDesigner.Domain
+ false
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerDomainModule.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerDomainModule.cs
new file mode 100644
index 000000000..ca8277bfe
--- /dev/null
+++ b/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();
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElement.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElement.cs
new file mode 100644
index 000000000..af4e74890
--- /dev/null
+++ b/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;
+///
+/// 自定义元素
+///
+public class CustomElement : AuditedAggregateRoot, IMultiTenant
+{
+ public Guid? TenantId { get; private set; }
+ ///
+ /// 名称
+ ///
+ public string Name { get; private set; } = default!;
+ ///
+ /// 描述
+ ///
+ public string? Description { get; set; }
+ ///
+ /// 元素数据
+ ///
+ 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();
+ }
+
+ ///
+ /// 设置名称
+ ///
+ ///
+ public void SetName(string name)
+ {
+ Name = Check.NotNullOrWhiteSpace(name, nameof(name), CustomElementConsts.MaxNameLength);
+ }
+
+ ///
+ /// 设置元素数据
+ ///
+ ///
+ ///
+ public void SetData(string elementData, string? extendedData = null)
+ {
+ Data ??= new CustomElementData(Id, TenantId);
+
+ Data.SetDesignerData(elementData);
+ Data.SetExtendedData(extendedData);
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementData.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementData.cs
new file mode 100644
index 000000000..1eef485a4
--- /dev/null
+++ b/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, IMultiTenant
+{
+ public Guid? TenantId { get; private set; }
+ ///
+ /// 元素Id
+ ///
+ public Guid ElementId { get; private set; }
+ ///
+ /// 元素数据
+ ///
+ public string? ElementData { get; private set; }
+ ///
+ /// 扩展字段
+ ///
+ public string? ExtendedData { get; private set; }
+
+ protected CustomElementData()
+ {
+ ExtraProperties = new ExtraPropertyDictionary();
+ this.SetDefaultsForExtraProperties();
+ }
+
+ internal CustomElementData(
+ Guid elementId,
+ Guid? tenantId = null)
+ {
+ ElementId = elementId;
+ TenantId = tenantId;
+ }
+
+ ///
+ /// 设置元素数据
+ ///
+ ///
+ public void SetDesignerData(string elementData)
+ {
+ ElementData = Check.NotNullOrWhiteSpace(elementData, nameof(elementData));
+ }
+
+ ///
+ /// 设置扩展字段容器数据
+ ///
+ ///
+ public void SetExtendedData(string? extendedData = null)
+ {
+ ExtendedData = extendedData;
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementDataSeeder.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementDataSeeder.cs
new file mode 100644
index 000000000..aa7676d19
--- /dev/null
+++ b/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? designerData = null,
+ Dictionary? extendedData = null,
+ CancellationToken cancellationToken = default)
+ {
+ var data = _jsonSerializer.Serialize(designerData ?? new Dictionary());
+ var extData = _jsonSerializer.Serialize(extendedData ?? new Dictionary());
+ await SeedAsync(name, data, extData, cancellationToken);
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/ICustomElementDataSeeder.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/ICustomElementDataSeeder.cs
new file mode 100644
index 000000000..dac143500
--- /dev/null
+++ b/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? designerData = null,
+ Dictionary? extendedData = null,
+ CancellationToken cancellationToken = default);
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/ICustomElementRepository.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/CustomElements/ICustomElementRepository.cs
new file mode 100644
index 000000000..aef398d36
--- /dev/null
+++ b/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
+{
+ Task FindByNameAsync(
+ string name,
+ bool includeDetails = false,
+ CancellationToken cancellationToken = default);
+
+ Task GetCountAsync(
+ ISpecification specification,
+ CancellationToken cancellationToken = default);
+
+ Task> GetListAsync(
+ ISpecification specification,
+ string? sorting = nameof(CustomElement.Name),
+ int maxResultCount = 10,
+ int skipCount = 0,
+ CancellationToken cancellationToken = default);
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/PrintDesignerDbProperties.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/PrintDesignerDbProperties.cs
new file mode 100644
index 000000000..d8f0723f3
--- /dev/null
+++ b/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";
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/PrintDesignerDomainMappers.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/PrintDesignerDomainMappers.cs
new file mode 100644
index 000000000..15efaea47
--- /dev/null
+++ b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/PrintDesignerDomainMappers.cs
@@ -0,0 +1,2 @@
+namespace LINGYUN.Abp.PrintDesigner;
+
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/ITemplateDataSeeder.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/ITemplateDataSeeder.cs
new file mode 100644
index 000000000..4655e2702
--- /dev/null
+++ b/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? designerData = null,
+ Dictionary? extendedData = null,
+ CancellationToken cancellationToken = default);
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/ITemplateRepository.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/ITemplateRepository.cs
new file mode 100644
index 000000000..ffd03f1be
--- /dev/null
+++ b/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
+{
+ Task FindByNameAsync(
+ string name,
+ bool includeDetails = false,
+ CancellationToken cancellationToken = default);
+
+ Task GetCountAsync(
+ ISpecification specification,
+ CancellationToken cancellationToken = default);
+
+ Task> GetListAsync(
+ ISpecification specification,
+ string? sorting = nameof(Template.Name),
+ int maxResultCount = 10,
+ int skipCount = 0,
+ CancellationToken cancellationToken = default);
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/Template.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/Template.cs
new file mode 100644
index 000000000..eed108515
--- /dev/null
+++ b/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;
+///
+/// 模板
+///
+public class Template : AuditedAggregateRoot, IMultiTenant
+{
+ public Guid? TenantId { get; private set; }
+ ///
+ /// 名称
+ ///
+ public string Name { get; private set; } = default!;
+ ///
+ /// 描述
+ ///
+ public string? Description { get; set; }
+ ///
+ /// 模板数据
+ ///
+ 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();
+ }
+
+ ///
+ /// 设置名称
+ ///
+ ///
+ public void SetName(string name)
+ {
+ Name = Check.NotNullOrWhiteSpace(name, nameof(name), TemplateConsts.MaxNameLength);
+ }
+
+ ///
+ /// 设置模板数据
+ ///
+ ///
+ ///
+ public void SetData(string designerData, string? extendedData = null)
+ {
+ Data ??= new TemplateData(Id, TenantId);
+
+ Data.SetDesignerData(designerData);
+ Data.SetExtendedData(extendedData);
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/TemplateData.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/TemplateData.cs
new file mode 100644
index 000000000..44e42f836
--- /dev/null
+++ b/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, IMultiTenant
+{
+ public Guid? TenantId { get; private set; }
+ ///
+ /// 模板Id
+ ///
+ public Guid TemplateId { get; private set; }
+ ///
+ /// 模板设计数据
+ ///
+ public string? DesignerData { get; private set; }
+ ///
+ /// 扩展字段
+ ///
+ public string? ExtendedData { get; private set; }
+
+ protected TemplateData()
+ {
+ ExtraProperties = new ExtraPropertyDictionary();
+ this.SetDefaultsForExtraProperties();
+ }
+
+ internal TemplateData(
+ Guid templateId,
+ Guid? tenantId = null)
+ {
+ TemplateId = templateId;
+ TenantId = tenantId;
+ }
+
+ ///
+ /// 设置模板设计数据
+ ///
+ ///
+ public void SetDesignerData(string designerData)
+ {
+ DesignerData = Check.NotNullOrWhiteSpace(designerData, nameof(designerData));
+ }
+
+ ///
+ /// 设置扩展字段容器数据
+ ///
+ ///
+ public void SetExtendedData(string? extendedData = null)
+ {
+ ExtendedData = extendedData;
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/TemplateDataSeeder.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.Domain/LINGYUN/Abp/PrintDesigner/Templates/TemplateDataSeeder.cs
new file mode 100644
index 000000000..7528a9978
--- /dev/null
+++ b/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? designerData = null,
+ Dictionary? extendedData = null,
+ CancellationToken cancellationToken = default)
+ {
+ var data = _jsonSerializer.Serialize(designerData ?? new Dictionary());
+ var extData = _jsonSerializer.Serialize(extendedData ?? new Dictionary());
+ await SeedAsync(name, data, extData, cancellationToken);
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore.csproj b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore.csproj
new file mode 100644
index 000000000..292d75bde
--- /dev/null
+++ b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore.csproj
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+ net10.0
+ LINGYUN.Abp.PrintDesigner.EntityFrameworkCore
+ LINGYUN.Abp.PrintDesigner.EntityFrameworkCore
+ false
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/CustomElements/EfCoreCustomElementRepository.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/CustomElements/EfCoreCustomElementRepository.cs
new file mode 100644
index 000000000..6a0218bea
--- /dev/null
+++ b/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, ICustomElementRepository
+{
+ public EfCoreCustomElementRepository(
+ IDbContextProvider dbContextProvider)
+ : base(dbContextProvider)
+ {
+ }
+
+ public async virtual Task 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 GetCountAsync(
+ ISpecification specification,
+ CancellationToken cancellationToken = default)
+ {
+ return await (await GetQueryableAsync())
+ .Where(specification.ToExpression())
+ .CountAsync(GetCancellationToken(cancellationToken));
+ }
+
+ public async virtual Task> GetListAsync(
+ ISpecification 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));
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/AbpPrintDesignerEntityFrameworkCoreModule.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/AbpPrintDesignerEntityFrameworkCoreModule.cs
new file mode 100644
index 000000000..ab2aebbcc
--- /dev/null
+++ b/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(options =>
+ {
+ options.AddRepository();
+ options.AddRepository();
+
+ options.AddDefaultRepositories();
+ });
+
+ Configure(options =>
+ {
+ options.Entity(e =>
+ {
+ e.DefaultWithDetailsFunc = x => x.Include(t => t.Data);
+ });
+
+ options.Entity(e =>
+ {
+ e.DefaultWithDetailsFunc = x => x.Include(t => t.Data);
+ });
+ });
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/IPrintDesignerDbContext.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/IPrintDesignerDbContext.cs
new file mode 100644
index 000000000..e35dcaffd
--- /dev/null
+++ b/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 CustomElements { get; }
+ DbSet Templates { get; }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/PrintDesignerDbContext.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/PrintDesignerDbContext.cs
new file mode 100644
index 000000000..8b3e03bec
--- /dev/null
+++ b/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, IPrintDesignerDbContext
+{
+ public DbSet CustomElements { get; set; }
+ public DbSet Templates { get; set; }
+
+ public PrintDesignerDbContext(
+ DbContextOptions options) : base(options)
+ {
+ }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ base.OnModelCreating(modelBuilder);
+
+ modelBuilder.ConfigurePrintDesigner();
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/PrintDesignerDbContextModelCreatingExtensions.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/PrintDesignerDbContextModelCreatingExtensions.cs
new file mode 100644
index 000000000..823f160bf
--- /dev/null
+++ b/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? optionsAction = null)
+ {
+ Check.NotNull(builder, nameof(builder));
+
+ var options = new PrintDesignerModelBuilderConfigurationOptions(
+ PrintDesignerDbProperties.DbTablePrefix,
+ PrintDesignerDbProperties.DbSchema
+ );
+ optionsAction?.Invoke(options);
+
+ builder.Entity(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(pk => pk.Id)
+ .HasForeignKey(pk => pk.ElementId)
+ .IsRequired();
+
+ e.HasIndex(x => x.Name).IsUnique();
+ });
+ builder.Entity(e =>
+ {
+ e.ToTable(options.TablePrefix + "CustomElementDatas", options.Schema);
+
+ e.ConfigureByConvention();
+ });
+
+ builder.Entity(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(pk => pk.Id)
+ .HasForeignKey(pk => pk.TemplateId);
+
+ e.HasIndex(x => x.Name).IsUnique();
+ });
+ builder.Entity(e =>
+ {
+ e.ToTable(options.TablePrefix + "TemplateDatas", options.Schema);
+
+ e.ConfigureByConvention();
+ });
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/PrintDesignerModelBuilderConfigurationOptions.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/EntityFrameworkCore/PrintDesignerModelBuilderConfigurationOptions.cs
new file mode 100644
index 000000000..1d19e79b6
--- /dev/null
+++ b/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)
+ {
+
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/Templates/EfCoreTemplateRepository.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.EntityFrameworkCore/LINGYUN/Abp/PrintDesigner/Templates/EfCoreTemplateRepository.cs
new file mode 100644
index 000000000..9b2d5ece1
--- /dev/null
+++ b/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, ITemplateRepository
+{
+ public EfCoreTemplateRepository(
+ IDbContextProvider dbContextProvider)
+ : base(dbContextProvider)
+ {
+ }
+
+ public async virtual Task 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 GetCountAsync(
+ ISpecification specification,
+ CancellationToken cancellationToken = default)
+ {
+ return await (await GetQueryableAsync())
+ .Where(specification.ToExpression())
+ .CountAsync(GetCancellationToken(cancellationToken));
+ }
+
+ public async virtual Task> GetListAsync(
+ ISpecification 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));
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN.Abp.PrintDesigner.HttpApi.csproj b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN.Abp.PrintDesigner.HttpApi.csproj
new file mode 100644
index 000000000..249c86807
--- /dev/null
+++ b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN.Abp.PrintDesigner.HttpApi.csproj
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+ net10.0
+ LINGYUN.Abp.PrintDesigner.HttpApi
+ LINGYUN.Abp.PrintDesigner.HttpApi
+ false
+ false
+ false
+ True
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerHttpApiModule.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN/Abp/PrintDesigner/AbpPrintDesignerHttpApiModule.cs
new file mode 100644
index 000000000..ae8edb297
--- /dev/null
+++ b/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(mvcBuilder =>
+ {
+ mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpPrintDesignerHttpApiModule).Assembly);
+ });
+
+ PreConfigure(options =>
+ {
+ options.AddAssemblyResource(
+ typeof(PrintDesignerResource),
+ typeof(AbpPrintDesignerApplicationContractsModule).Assembly);
+ });
+ }
+
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+ Configure(options =>
+ {
+ options.Resources
+ .Get()
+ .AddBaseTypes(typeof(AbpValidationResource));
+ });
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementController.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN/Abp/PrintDesigner/CustomElements/CustomElementController.cs
new file mode 100644
index 000000000..f9ba9ba84
--- /dev/null
+++ b/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 CreateAsync(CustomElementCreateDto input)
+ {
+ return _service.CreateAsync(input);
+ }
+
+ [HttpDelete("{id}")]
+ [Authorize(PrintDesignerPermissions.CustomElement.Delete)]
+ public virtual Task DeleteAsync(Guid id)
+ {
+ return _service.DeleteAsync(id);
+ }
+
+ [HttpGet("{id}")]
+ public virtual Task GetAsync(Guid id)
+ {
+ return _service.GetAsync(id);
+ }
+
+ [HttpGet("all")]
+ public virtual Task> GetAllAsync()
+ {
+ return _service.GetAllAsync();
+ }
+
+ [HttpGet]
+ public virtual Task> GetListAsync(CustomElementGetPagedListInput input)
+ {
+ return _service.GetListAsync(input);
+ }
+
+ [HttpPut("{id}")]
+ [Authorize(PrintDesignerPermissions.CustomElement.Update)]
+ public virtual Task UpdateAsync(Guid id, CustomElementUpdateDto input)
+ {
+ return _service.UpdateAsync(id, input);
+ }
+
+ [HttpPost("upsert")]
+ public virtual Task UpsertAsync(CustomElementUpsertDto input)
+ {
+ return _service.UpsertAsync(input);
+ }
+}
diff --git a/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN/Abp/PrintDesigner/Templates/TemplateController.cs b/aspnet-core/modules/print-designer/LINGYUN.Abp.PrintDesigner.HttpApi/LINGYUN/Abp/PrintDesigner/Templates/TemplateController.cs
new file mode 100644
index 000000000..a6c4ab797
--- /dev/null
+++ b/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 CreateAsync(TemplateCreateDto input)
+ {
+ return _service.CreateAsync(input);
+ }
+
+ [HttpDelete("{id}")]
+ [Authorize(PrintDesignerPermissions.Template.Delete)]
+ public virtual Task DeleteAsync(Guid id)
+ {
+ return _service.DeleteAsync(id);
+ }
+
+ [HttpGet("{id}")]
+ public virtual Task GetAsync(Guid id)
+ {
+ return _service.GetAsync(id);
+ }
+
+ [HttpGet("by-name/{name}")]
+ public virtual Task GetByNameAsync(string name)
+ {
+ return _service.GetByNameAsync(name);
+ }
+
+ [HttpGet("all")]
+ public virtual Task> GetAllAsync()
+ {
+ return _service.GetAllAsync();
+ }
+
+ [HttpGet]
+ public virtual Task> GetListAsync(TemplateGetPagedListInput input)
+ {
+ return _service.GetListAsync(input);
+ }
+
+ [HttpPut("{id}")]
+ [Authorize(PrintDesignerPermissions.Template.Update)]
+ public virtual Task UpdateAsync(Guid id, TemplateUpdateDto input)
+ {
+ return _service.UpdateAsync(id, input);
+ }
+
+ [HttpPost("upsert")]
+ public virtual Task UpsertAsync(TemplateUpsertDto input)
+ {
+ return _service.UpsertAsync(input);
+ }
+}