diff --git a/Admin.NET/Admin.NET.Application/Admin.NET.Application.csproj b/Admin.NET/Admin.NET.Application/Admin.NET.Application.csproj index 16a1ebcb..1b4523b7 100644 --- a/Admin.NET/Admin.NET.Application/Admin.NET.Application.csproj +++ b/Admin.NET/Admin.NET.Application/Admin.NET.Application.csproj @@ -48,11 +48,7 @@ - - - - diff --git a/Admin.NET/Admin.NET.Core/Service/Role/SysRoleTableService.cs b/Admin.NET/Admin.NET.Core/Service/Role/SysRoleTableService.cs index c663e5fb..a49f9112 100644 --- a/Admin.NET/Admin.NET.Core/Service/Role/SysRoleTableService.cs +++ b/Admin.NET/Admin.NET.Core/Service/Role/SysRoleTableService.cs @@ -92,7 +92,7 @@ public class SysRoleTableService : ITransient var ignoreTables = new List { //"DingTalkUser", - //"ApprovalFlow", + //"DataApproval", //"GoViewPro", //"GoViewPro", //"GoViewProData" diff --git a/Admin.NET/Admin.NET.sln b/Admin.NET/Admin.NET.sln index 10512930..5adf7a13 100644 --- a/Admin.NET/Admin.NET.sln +++ b/Admin.NET/Admin.NET.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.14.36429.23 d17.14 +VisualStudioVersion = 17.14.36429.23 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Admin.NET.Application", "Admin.NET.Application\Admin.NET.Application.csproj", "{C3F5AEC5-ACEE-4109-94E3-3F981DC18268}" EndProject @@ -24,8 +24,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Admin.NET.Plugin.DingTalk", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Admin.NET.Plugin.ReZero", "Plugins\Admin.NET.Plugin.ReZero\Admin.NET.Plugin.ReZero.csproj", "{04AB2E76-DE8B-4EFD-9F48-F8D4C0993106}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Admin.NET.Plugin.ApprovalFlow", "Plugins\Admin.NET.Plugin.ApprovalFlow\Admin.NET.Plugin.ApprovalFlow.csproj", "{4124E31B-EA94-4EE3-9EC6-A565F1420AEA}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Admin.NET.Plugin.K3Cloud", "Plugins\Admin.NET.Plugin.K3Cloud\Admin.NET.Plugin.K3Cloud.csproj", "{9EB9C39E-E14F-443E-9AA3-EE417ABCBC1D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Admin.NET.Plugin.PaddleOCR", "Plugins\Admin.NET.Plugin.PaddleOCR\Admin.NET.Plugin.PaddleOCR.csproj", "{1B106C11-E5BF-44AB-A283-1E948A8BD8C2}" @@ -36,6 +34,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Admin.NET.Test", "Admin.NET EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Admin.NET.Plugin.Ai", "Plugins\Admin.NET.Plugin.Ai\Admin.NET.Plugin.Ai.csproj", "{EB254721-C73C-4B1F-B9D7-0D989409F0C8}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Admin.NET.Plugin.DataApproval", "Plugins\Admin.NET.Plugin.DataApproval\Admin.NET.Plugin.DataApproval.csproj", "{BCB22734-58C1-5B78-60E8-EE68E9F24333}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -70,10 +70,6 @@ Global {04AB2E76-DE8B-4EFD-9F48-F8D4C0993106}.Debug|Any CPU.Build.0 = Debug|Any CPU {04AB2E76-DE8B-4EFD-9F48-F8D4C0993106}.Release|Any CPU.ActiveCfg = Release|Any CPU {04AB2E76-DE8B-4EFD-9F48-F8D4C0993106}.Release|Any CPU.Build.0 = Release|Any CPU - {4124E31B-EA94-4EE3-9EC6-A565F1420AEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4124E31B-EA94-4EE3-9EC6-A565F1420AEA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4124E31B-EA94-4EE3-9EC6-A565F1420AEA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4124E31B-EA94-4EE3-9EC6-A565F1420AEA}.Release|Any CPU.Build.0 = Release|Any CPU {9EB9C39E-E14F-443E-9AA3-EE417ABCBC1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9EB9C39E-E14F-443E-9AA3-EE417ABCBC1D}.Debug|Any CPU.Build.0 = Debug|Any CPU {9EB9C39E-E14F-443E-9AA3-EE417ABCBC1D}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -94,6 +90,10 @@ Global {EB254721-C73C-4B1F-B9D7-0D989409F0C8}.Debug|Any CPU.Build.0 = Debug|Any CPU {EB254721-C73C-4B1F-B9D7-0D989409F0C8}.Release|Any CPU.ActiveCfg = Release|Any CPU {EB254721-C73C-4B1F-B9D7-0D989409F0C8}.Release|Any CPU.Build.0 = Release|Any CPU + {BCB22734-58C1-5B78-60E8-EE68E9F24333}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BCB22734-58C1-5B78-60E8-EE68E9F24333}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BCB22734-58C1-5B78-60E8-EE68E9F24333}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BCB22734-58C1-5B78-60E8-EE68E9F24333}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -102,11 +102,11 @@ Global {C4A288D5-0FAA-4F43-9072-B97635D7871D} = {76F70D22-8D53-468E-A3B6-1704666A1D71} {F6A002AD-CF7F-4771-8597-F12A50A93DAA} = {76F70D22-8D53-468E-A3B6-1704666A1D71} {04AB2E76-DE8B-4EFD-9F48-F8D4C0993106} = {76F70D22-8D53-468E-A3B6-1704666A1D71} - {4124E31B-EA94-4EE3-9EC6-A565F1420AEA} = {76F70D22-8D53-468E-A3B6-1704666A1D71} {9EB9C39E-E14F-443E-9AA3-EE417ABCBC1D} = {76F70D22-8D53-468E-A3B6-1704666A1D71} {1B106C11-E5BF-44AB-A283-1E948A8BD8C2} = {76F70D22-8D53-468E-A3B6-1704666A1D71} {12998618-A875-4580-B5B1-0CC50CE85F27} = {76F70D22-8D53-468E-A3B6-1704666A1D71} {EB254721-C73C-4B1F-B9D7-0D989409F0C8} = {76F70D22-8D53-468E-A3B6-1704666A1D71} + {BCB22734-58C1-5B78-60E8-EE68E9F24333} = {76F70D22-8D53-468E-A3B6-1704666A1D71} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {5CD801D7-984A-4F5C-8FA2-211B7A5EA9F3} diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.Ai/Configuration/Ai.json b/Admin.NET/Plugins/Admin.NET.Plugin.Ai/Configuration/Ai.json index 5fb60c94..ed3b6d42 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.Ai/Configuration/Ai.json +++ b/Admin.NET/Plugins/Admin.NET.Plugin.Ai/Configuration/Ai.json @@ -1,4 +1,11 @@ { + "[openapi:AiChat]": { + "Group": "AiChat", + "Title": "AiChat", + "Description": "LLM 大模型", + "Version": "1.0.0", + "Order": 100 + }, "LLM": { "ModelProvider": "DeepSeek", // 当前使用模型,取值为下面Providers的ProductName "InitSystemChatMessage": "你是一个经验丰富的 Admin.NET 人工智能助手,请根据用户的问题给出准确的回答。- **回答请以markdown格式输出**;- **适当加入emoji表达人类情感,使内容更易于理解与传播。**", diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Enum/FlowTypeEnum.cs b/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Enum/FlowTypeEnum.cs deleted file mode 100644 index 3b165cb7..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Enum/FlowTypeEnum.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -namespace Admin.NET.Plugin.ApprovalFlow; - -/// -/// 流程类型枚举 -/// -[Description("流程类型枚举")] -public enum FlowTypeEnum -{ -} \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.Core/Abstractions/Pay/IPayPlugin.cs b/Admin.NET/Plugins/Admin.NET.Plugin.Core/Abstractions/Pay/IPayPlugin.cs deleted file mode 100644 index b8e872c0..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.Core/Abstractions/Pay/IPayPlugin.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - -using PluginCore.IPlugins; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Admin.NET.Plugin.Core.Abstractions.Pay; -public interface IPayPlugin : IPlugin -{ - string Name { get; set; } - string Say(); -} diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.Core/Admin.NET.Plugin.Core.csproj b/Admin.NET/Plugins/Admin.NET.Plugin.Core/Admin.NET.Plugin.Core.csproj deleted file mode 100644 index f3688bb2..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.Core/Admin.NET.Plugin.Core.csproj +++ /dev/null @@ -1,27 +0,0 @@ - - - - net8.0;net9.0 - 1701;1702;8616;1591;8618;8619;8629;8602;8603;8604;8625;8765 - Admin.NET.Plugin.Core.xml - enable - enable - - - - - - - - - - - - - - - - - - - diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.Core/Admin.NET.Plugin.Core.xml b/Admin.NET/Plugins/Admin.NET.Plugin.Core/Admin.NET.Plugin.Core.xml deleted file mode 100644 index e1f8a56e..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.Core/Admin.NET.Plugin.Core.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - Admin.NET.Plugin.Core - - - - diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.Core/GlobalUsing.cs b/Admin.NET/Plugins/Admin.NET.Plugin.Core/GlobalUsing.cs deleted file mode 100644 index 19a76f13..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.Core/GlobalUsing.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Admin.NET.Plugin.ApprovalFlow.csproj b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Admin.NET.Plugin.DataApproval.csproj similarity index 100% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Admin.NET.Plugin.ApprovalFlow.csproj rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Admin.NET.Plugin.DataApproval.csproj diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Configuration/ApprovalFlow.json b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Configuration/DataApproval.json similarity index 67% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Configuration/ApprovalFlow.json rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Configuration/DataApproval.json index 85b05128..3a2043d1 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Configuration/ApprovalFlow.json +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Configuration/DataApproval.json @@ -1,13 +1,13 @@ { "$schema": "https://gitee.com/dotnetchina/Furion/raw/v4/schemas/v4/furion-schema.json", - "[openapi:审批流程]": { - "Group": "审批流程", - "Title": "审批流程", + "[openapi:DataApproval]": { + "Group": "DataApproval", + "Title": "DataApproval", "Description": "对业务实体数据的增删改操作进行流程审批。", "Version": "1.0.0", "Order": 100 }, - "ApprovalFlow": { + "DataApproval": { } } \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Const/ApprovalFlowConst.cs b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Const/DataApprovalConst.cs similarity index 84% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Const/ApprovalFlowConst.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Const/DataApprovalConst.cs index 365309ca..97422a5d 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Const/ApprovalFlowConst.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Const/DataApprovalConst.cs @@ -4,13 +4,13 @@ // // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! -namespace Admin.NET.Plugin.ApprovalFlow; +namespace Admin.NET.Plugin.DataApproval; /// -/// 审批流程相关常量 +/// 数据审批相关常量 /// -[Const("审批流程相关常量")] -public class ApprovalFlowConst +[Const("数据审批相关常量")] +public class DataApprovalConst { /// /// API分组名称 diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Entity/ApprovalForm.cs b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Entity/ApprovalForm.cs similarity index 95% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Entity/ApprovalForm.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Entity/ApprovalForm.cs index 3146cd71..dda487f1 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Entity/ApprovalForm.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Entity/ApprovalForm.cs @@ -1,62 +1,62 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -namespace Admin.NET.Plugin.ApprovalFlow; - -/// -/// 审批流表单 -/// -[SugarTable(null, "审批流表单")] -public class ApprovalForm : EntityBaseData -{ - /// - /// 编号 - /// - [SugarColumn(ColumnDescription = "编号", Length = 32)] - public string? Code { get; set; } - - /// - /// 名称 - /// - [SugarColumn(ColumnDescription = "名称", Length = 32)] - public string? Name { get; set; } - - /// - /// 表单名称 - /// - [SugarColumn(ColumnDescription = "表单名称", Length = 32)] - public string? FormName { get; set; } - - /// - /// 表单属性 - /// - [SugarColumn(ColumnDescription = "表单属性", Length = 32)] - public string? FormType { get; set; } - - /// - /// 表单状态 - /// - [SugarColumn(ColumnDescription = "表单状态")] - public int? FormStatus { get; set; } - - /// - /// 表单结果 - /// - [SugarColumn(ColumnDescription = "表单结果", ColumnDataType = StaticConfig.CodeFirst_BigString)] - public string? FormResult { get; set; } - - /// - /// 状态 - /// - [SugarColumn(ColumnDescription = "状态")] - public int? Status { get; set; } - - /// - /// 备注 - /// - [SugarColumn(ColumnDescription = "备注", Length = 255)] - public string? Remark { get; set; } +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +namespace Admin.NET.Plugin.DataApproval; + +/// +/// 审批流表单 +/// +[SugarTable(null, "审批流表单")] +public class ApprovalForm : EntityBaseData +{ + /// + /// 编号 + /// + [SugarColumn(ColumnDescription = "编号", Length = 32)] + public string? Code { get; set; } + + /// + /// 名称 + /// + [SugarColumn(ColumnDescription = "名称", Length = 32)] + public string? Name { get; set; } + + /// + /// 表单名称 + /// + [SugarColumn(ColumnDescription = "表单名称", Length = 32)] + public string? FormName { get; set; } + + /// + /// 表单属性 + /// + [SugarColumn(ColumnDescription = "表单属性", Length = 32)] + public string? FormType { get; set; } + + /// + /// 表单状态 + /// + [SugarColumn(ColumnDescription = "表单状态")] + public int? FormStatus { get; set; } + + /// + /// 表单结果 + /// + [SugarColumn(ColumnDescription = "表单结果", ColumnDataType = StaticConfig.CodeFirst_BigString)] + public string? FormResult { get; set; } + + /// + /// 状态 + /// + [SugarColumn(ColumnDescription = "状态")] + public int? Status { get; set; } + + /// + /// 备注 + /// + [SugarColumn(ColumnDescription = "备注", Length = 255)] + public string? Remark { get; set; } } \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Entity/ApprovalFormRecord.cs b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Entity/ApprovalFormRecord.cs similarity index 95% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Entity/ApprovalFormRecord.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Entity/ApprovalFormRecord.cs index 78dc14ec..9a06d41c 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Entity/ApprovalFormRecord.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Entity/ApprovalFormRecord.cs @@ -1,56 +1,56 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -namespace Admin.NET.Plugin.ApprovalFlow; - -/// -/// 审批流表单记录 -/// -[SugarTable(null, "审批流表单记录")] -public class ApprovalFormRecord : EntityBaseData -{ - /// - /// 流程Id - /// - [SugarColumn(ColumnDescription = "流程Id")] - public long? FlowId { get; set; } - - /// - /// 表单名称 - /// - [SugarColumn(ColumnDescription = "表单名称", Length = 32)] - public string? FormName { get; set; } - - /// - /// 表单类型 - /// - [SugarColumn(ColumnDescription = "表单类型", Length = 32)] - public string? FormType { get; set; } - - /// - /// 表单状态 - /// - [SugarColumn(ColumnDescription = "表单状态", Length = 11)] - public string? FormStatus { get; set; } - - /// - /// 修改前 - /// - [SugarColumn(ColumnDescription = "修改前", ColumnDataType = StaticConfig.CodeFirst_BigString)] - public string? FormBefore { get; set; } - - /// - /// 修改后 - /// - [SugarColumn(ColumnDescription = "修改后", ColumnDataType = StaticConfig.CodeFirst_BigString)] - public string? FormAfter { get; set; } - - /// - /// 表单结果 - /// - [SugarColumn(ColumnDescription = "表单结果", ColumnDataType = StaticConfig.CodeFirst_BigString)] - public string? FormResult { get; set; } +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +namespace Admin.NET.Plugin.DataApproval; + +/// +/// 审批流表单记录 +/// +[SugarTable(null, "审批流表单记录")] +public class ApprovalFormRecord : EntityBaseData +{ + /// + /// 流程Id + /// + [SugarColumn(ColumnDescription = "流程Id")] + public long? FlowId { get; set; } + + /// + /// 表单名称 + /// + [SugarColumn(ColumnDescription = "表单名称", Length = 32)] + public string? FormName { get; set; } + + /// + /// 表单类型 + /// + [SugarColumn(ColumnDescription = "表单类型", Length = 32)] + public string? FormType { get; set; } + + /// + /// 表单状态 + /// + [SugarColumn(ColumnDescription = "表单状态", Length = 11)] + public string? FormStatus { get; set; } + + /// + /// 修改前 + /// + [SugarColumn(ColumnDescription = "修改前", ColumnDataType = StaticConfig.CodeFirst_BigString)] + public string? FormBefore { get; set; } + + /// + /// 修改后 + /// + [SugarColumn(ColumnDescription = "修改后", ColumnDataType = StaticConfig.CodeFirst_BigString)] + public string? FormAfter { get; set; } + + /// + /// 表单结果 + /// + [SugarColumn(ColumnDescription = "表单结果", ColumnDataType = StaticConfig.CodeFirst_BigString)] + public string? FormResult { get; set; } } \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Entity/ApprovalFlow.cs b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Entity/DataApproval.cs similarity index 91% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Entity/ApprovalFlow.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Entity/DataApproval.cs index 7ef66ca0..9d03efe5 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Entity/ApprovalFlow.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Entity/DataApproval.cs @@ -4,13 +4,13 @@ // // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! -namespace Admin.NET.Plugin.ApprovalFlow; +namespace Admin.NET.Plugin.DataApproval; /// -/// 审批流程信息表 +/// 数据审批信息表 /// -[SugarTable(null, "审批流程信息表")] -public class ApprovalFlow : EntityBaseData +[SugarTable(null, "数据审批信息表")] +public class DataApproval : EntityBaseData { /// /// 编号 diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Entity/ApprovalFlowRecord.cs b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Entity/DataApprovalRecord.cs similarity index 93% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Entity/ApprovalFlowRecord.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Entity/DataApprovalRecord.cs index bc48cbe2..1c2efbbe 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Entity/ApprovalFlowRecord.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Entity/DataApprovalRecord.cs @@ -1,50 +1,50 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -namespace Admin.NET.Plugin.ApprovalFlow; - -/// -/// 审批流流程记录 -/// -[SugarTable(null, "审批流流程记录")] -public class ApprovalFlowRecord : EntityBaseData -{ - /// - /// 表单名称 - /// - [SugarColumn(ColumnDescription = "表单名称", Length = 255)] - public string? FormName { get; set; } - - /// - /// 表单状态 - /// - [SugarColumn(ColumnDescription = "表单状态", Length = 32)] - public string? FormStatus { get; set; } - - /// - /// 表单触发 - /// - [SugarColumn(ColumnDescription = "表单触发", ColumnDataType = StaticConfig.CodeFirst_BigString)] - public string? FormJson { get; set; } - - /// - /// 表单结果 - /// - [SugarColumn(ColumnDescription = "表单结果", ColumnDataType = StaticConfig.CodeFirst_BigString)] - public string? FormResult { get; set; } - - /// - /// 流程结构 - /// - [SugarColumn(ColumnDescription = "流程结构", ColumnDataType = StaticConfig.CodeFirst_BigString)] - public string? FlowJson { get; set; } - - /// - /// 流程结果 - /// - [SugarColumn(ColumnDescription = "流程结果", ColumnDataType = StaticConfig.CodeFirst_BigString)] - public string? FlowResult { get; set; } +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +namespace Admin.NET.Plugin.DataApproval; + +/// +/// 审批流流程记录 +/// +[SugarTable(null, "审批流流程记录")] +public class DataApprovalRecord : EntityBaseData +{ + /// + /// 表单名称 + /// + [SugarColumn(ColumnDescription = "表单名称", Length = 255)] + public string? FormName { get; set; } + + /// + /// 表单状态 + /// + [SugarColumn(ColumnDescription = "表单状态", Length = 32)] + public string? FormStatus { get; set; } + + /// + /// 表单触发 + /// + [SugarColumn(ColumnDescription = "表单触发", ColumnDataType = StaticConfig.CodeFirst_BigString)] + public string? FormJson { get; set; } + + /// + /// 表单结果 + /// + [SugarColumn(ColumnDescription = "表单结果", ColumnDataType = StaticConfig.CodeFirst_BigString)] + public string? FormResult { get; set; } + + /// + /// 流程结构 + /// + [SugarColumn(ColumnDescription = "流程结构", ColumnDataType = StaticConfig.CodeFirst_BigString)] + public string? FlowJson { get; set; } + + /// + /// 流程结果 + /// + [SugarColumn(ColumnDescription = "流程结果", ColumnDataType = StaticConfig.CodeFirst_BigString)] + public string? FlowResult { get; set; } } \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/GlobalUsings.cs b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/GlobalUsings.cs similarity index 98% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/GlobalUsings.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/GlobalUsings.cs index ed9f17ae..904ea938 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/GlobalUsings.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/GlobalUsings.cs @@ -1,20 +1,20 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -global using Admin.NET.Core; -global using Furion; -global using Furion.DependencyInjection; -global using Furion.DynamicApiController; -global using Furion.FriendlyException; -global using Mapster; -global using Microsoft.AspNetCore.Mvc; -global using Microsoft.Extensions.DependencyInjection; -global using SqlSugar; -global using System; -global using System.Collections.Generic; -global using System.ComponentModel; -global using System.ComponentModel.DataAnnotations; +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +global using Admin.NET.Core; +global using Furion; +global using Furion.DependencyInjection; +global using Furion.DynamicApiController; +global using Furion.FriendlyException; +global using Mapster; +global using Microsoft.AspNetCore.Mvc; +global using Microsoft.Extensions.DependencyInjection; +global using SqlSugar; +global using System; +global using System.Collections.Generic; +global using System.ComponentModel; +global using System.ComponentModel.DataAnnotations; global using System.Threading.Tasks; \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Middleware/ApprovalFlowMiddleware.cs b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Middleware/DataApprovalMiddleware.cs similarity index 76% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Middleware/ApprovalFlowMiddleware.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Middleware/DataApprovalMiddleware.cs index 9c167bea..ffebab85 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Middleware/ApprovalFlowMiddleware.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Middleware/DataApprovalMiddleware.cs @@ -1,50 +1,50 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -using Admin.NET.Plugin.ApprovalFlow.Service; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; - -namespace Admin.NET.Plugin.ApprovalFlow; - -/// -/// 扩展审批流中间件 -/// -public static class ApprovalFlowMiddlewareExtensions -{ - /// - /// 使用审批流 - /// - /// - /// - public static IApplicationBuilder UseApprovalFlow(this IApplicationBuilder builder) - { - return builder.UseMiddleware(); - } -} - -/// -/// 审批流中间件 -/// -public class ApprovalFlowMiddleware -{ - private readonly RequestDelegate _next; - private readonly SysApprovalService _sysApprovalService; - - public ApprovalFlowMiddleware(RequestDelegate next) - { - _next = next; - _sysApprovalService = App.GetRequiredService(); - } - - public async Task InvokeAsync(HttpContext context) - { - await _sysApprovalService.MatchApproval(context); - - // 调用下一个中间件 - await _next(context); - } +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using Admin.NET.Plugin.DataApproval.Service; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; + +namespace Admin.NET.Plugin.DataApproval; + +/// +/// 扩展审批流中间件 +/// +public static class DataApprovalMiddlewareExtensions +{ + /// + /// 使用审批流 + /// + /// + /// + public static IApplicationBuilder UseDataApproval(this IApplicationBuilder builder) + { + return builder.UseMiddleware(); + } +} + +/// +/// 审批流中间件 +/// +public class DataApprovalMiddleware +{ + private readonly RequestDelegate _next; + private readonly SysApprovalService _sysApprovalService; + + public DataApprovalMiddleware(RequestDelegate next) + { + _next = next; + _sysApprovalService = App.GetRequiredService(); + } + + public async Task InvokeAsync(HttpContext context) + { + await _sysApprovalService.MatchApproval(context); + + // 调用下一个中间件 + await _next(context); + } } \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/SeedData/SysMenuSeedData.cs b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/SeedData/SysMenuSeedData.cs similarity index 93% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/SeedData/SysMenuSeedData.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/SeedData/SysMenuSeedData.cs index d2ec2ae6..b4d75683 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/SeedData/SysMenuSeedData.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/SeedData/SysMenuSeedData.cs @@ -4,10 +4,10 @@ // // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! -namespace Admin.NET.Plugin.ApprovalFlow; +namespace Admin.NET.Plugin.DataApproval; /// -/// 审批流程菜单表种子数据 +/// 数据审批菜单表种子数据 /// public class SysMenuSeedData : ISqlSugarEntitySeedData { diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/ApprovalFlowService.cs b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/DataApprovalService.cs similarity index 65% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/ApprovalFlowService.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/DataApprovalService.cs index b957d9b2..aeb9ad1d 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/ApprovalFlowService.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/DataApprovalService.cs @@ -1,154 +1,154 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -using System.Text.Json; - -namespace Admin.NET.Plugin.ApprovalFlow.Service; - -/// -/// 审批流程服务 -/// -[ApiDescriptionSettings(ApprovalFlowConst.GroupName, Order = 100, Description = "审批流程")] -public class ApprovalFlowService : IDynamicApiController, ITransient -{ - private readonly SqlSugarRepository _approvalFlowRep; - - public ApprovalFlowService(SqlSugarRepository approvalFlowRep) - { - _approvalFlowRep = approvalFlowRep; - } - - /// - /// 分页查询审批流 - /// - /// - /// - [HttpPost] - [ApiDescriptionSettings(Name = "Page")] - public async Task> Page(ApprovalFlowInput input) - { - return await _approvalFlowRep.AsQueryable() - .WhereIF(!string.IsNullOrWhiteSpace(input.Keyword), u => u.Code.Contains(input.Keyword.Trim()) || u.Name.Contains(input.Keyword.Trim()) || u.Remark.Contains(input.Keyword.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.Code), u => u.Code.Contains(input.Code.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.Remark), u => u.Remark.Contains(input.Remark.Trim())) - .Select() - .ToPagedListAsync(input.Page, input.PageSize); - } - - /// - /// 增加审批流 - /// - /// - /// - [ApiDescriptionSettings(Name = "Add"), HttpPost] - public async Task Add(AddApprovalFlowInput input) - { - var entity = input.Adapt(); - if (input.Code == null) - { - entity.Code = await LastCode(""); - } - await _approvalFlowRep.InsertAsync(entity); - return entity.Id; - } - - /// - /// 更新审批流 - /// - /// - /// - [ApiDescriptionSettings(Name = "Update"), HttpPost] - public async Task Update(UpdateApprovalFlowInput input) - { - var entity = input.Adapt(); - await _approvalFlowRep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); - } - - /// - /// 删除审批流 - /// - /// - /// - [ApiDescriptionSettings(Name = "Delete"), HttpPost] - public async Task Delete(DeleteApprovalFlowInput input) - { - var entity = await _approvalFlowRep.GetByIdAsync(input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D1002); - await _approvalFlowRep.FakeDeleteAsync(entity); // 假删除 - } - - /// - /// 获取审批流 - /// - /// - /// - public async Task GetDetail([FromQuery] QueryByIdApprovalFlowInput input) - { - return await _approvalFlowRep.GetByIdAsync(input.Id); - } - - /// - /// 根据编码获取审批流信息 - /// - /// - /// - public async Task GetInfo([FromQuery] string code) - { - return await _approvalFlowRep.GetFirstAsync(u => u.Code == code); - } - - /// - /// 获取审批流列表 - /// - /// - /// - public async Task> GetList([FromQuery] ApprovalFlowInput input) - { - return await _approvalFlowRep.AsQueryable().Select().ToListAsync(); - } - - /// - /// 获取今天创建的最大编号 - /// - /// - /// - private async Task LastCode(string prefix) - { - var today = DateTime.Now.Date; - var count = await _approvalFlowRep.AsQueryable().Where(u => u.CreateTime >= today).CountAsync(); - return prefix + DateTime.Now.ToString("yyMMdd") + string.Format("{0:d2}", count + 1); - } - - [HttpGet] - [ApiDescriptionSettings(Name = "FlowList")] - [DisplayName("获取审批流结构")] - public async Task FlowList([FromQuery] string code) - { - var result = await _approvalFlowRep.AsQueryable().Where(u => u.Code == code).Select().FirstAsync(); - var FlowJson = result.FlowJson != null ? JsonSerializer.Deserialize(result.FlowJson) : new ApprovalFlowItem(); - var FormJson = result.FormJson != null ? JsonSerializer.Deserialize(result.FormJson) : new ApprovalFormItem(); - return new - { - FlowJson, - FormJson - }; - } - - [HttpGet] - [ApiDescriptionSettings(Name = "FormRoutes")] - [DisplayName("获取审批流规则")] - public async Task> FormRoutes() - { - var results = await _approvalFlowRep.AsQueryable().Select().ToListAsync(); - var list = new List(); - foreach (var item in results) - { - var FormJson = item.FormJson != null ? JsonSerializer.Deserialize(item.FormJson) : new ApprovalFormItem(); - if (item.FormJson != null) list.Add(FormJson.Route); - } - return list; - } +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using System.Text.Json; + +namespace Admin.NET.Plugin.DataApproval.Service; + +/// +/// 数据审批服务 +/// +[ApiDescriptionSettings(DataApprovalConst.GroupName, Order = 100, Description = "数据审批")] +public class DataApprovalService : IDynamicApiController, ITransient +{ + private readonly SqlSugarRepository _DataApprovalRep; + + public DataApprovalService(SqlSugarRepository DataApprovalRep) + { + _DataApprovalRep = DataApprovalRep; + } + + /// + /// 分页查询审批流 + /// + /// + /// + [HttpPost] + [ApiDescriptionSettings(Name = "Page")] + public async Task> Page(DataApprovalInput input) + { + return await _DataApprovalRep.AsQueryable() + .WhereIF(!string.IsNullOrWhiteSpace(input.Keyword), u => u.Code.Contains(input.Keyword.Trim()) || u.Name.Contains(input.Keyword.Trim()) || u.Remark.Contains(input.Keyword.Trim())) + .WhereIF(!string.IsNullOrWhiteSpace(input.Code), u => u.Code.Contains(input.Code.Trim())) + .WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name.Trim())) + .WhereIF(!string.IsNullOrWhiteSpace(input.Remark), u => u.Remark.Contains(input.Remark.Trim())) + .Select() + .ToPagedListAsync(input.Page, input.PageSize); + } + + /// + /// 增加审批流 + /// + /// + /// + [ApiDescriptionSettings(Name = "Add"), HttpPost] + public async Task Add(AddDataApprovalInput input) + { + var entity = input.Adapt(); + if (input.Code == null) + { + entity.Code = await LastCode(""); + } + await _DataApprovalRep.InsertAsync(entity); + return entity.Id; + } + + /// + /// 更新审批流 + /// + /// + /// + [ApiDescriptionSettings(Name = "Update"), HttpPost] + public async Task Update(UpdateDataApprovalInput input) + { + var entity = input.Adapt(); + await _DataApprovalRep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + } + + /// + /// 删除审批流 + /// + /// + /// + [ApiDescriptionSettings(Name = "Delete"), HttpPost] + public async Task Delete(DeleteDataApprovalInput input) + { + var entity = await _DataApprovalRep.GetByIdAsync(input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D1002); + await _DataApprovalRep.FakeDeleteAsync(entity); // 假删除 + } + + /// + /// 获取审批流 + /// + /// + /// + public async Task GetDetail([FromQuery] QueryByIdDataApprovalInput input) + { + return await _DataApprovalRep.GetByIdAsync(input.Id); + } + + /// + /// 根据编码获取审批流信息 + /// + /// + /// + public async Task GetInfo([FromQuery] string code) + { + return await _DataApprovalRep.GetFirstAsync(u => u.Code == code); + } + + /// + /// 获取审批流列表 + /// + /// + /// + public async Task> GetList([FromQuery] DataApprovalInput input) + { + return await _DataApprovalRep.AsQueryable().Select().ToListAsync(); + } + + /// + /// 获取今天创建的最大编号 + /// + /// + /// + private async Task LastCode(string prefix) + { + var today = DateTime.Now.Date; + var count = await _DataApprovalRep.AsQueryable().Where(u => u.CreateTime >= today).CountAsync(); + return prefix + DateTime.Now.ToString("yyMMdd") + string.Format("{0:d2}", count + 1); + } + + [HttpGet] + [ApiDescriptionSettings(Name = "FlowList")] + [DisplayName("获取审批流结构")] + public async Task FlowList([FromQuery] string code) + { + var result = await _DataApprovalRep.AsQueryable().Where(u => u.Code == code).Select().FirstAsync(); + var FlowJson = result.FlowJson != null ? JsonSerializer.Deserialize(result.FlowJson) : new DataApprovalItem(); + var FormJson = result.FormJson != null ? JsonSerializer.Deserialize(result.FormJson) : new ApprovalFormItem(); + return new + { + FlowJson, + FormJson + }; + } + + [HttpGet] + [ApiDescriptionSettings(Name = "FormRoutes")] + [DisplayName("获取审批流规则")] + public async Task> FormRoutes() + { + var results = await _DataApprovalRep.AsQueryable().Select().ToListAsync(); + var list = new List(); + foreach (var item in results) + { + var FormJson = item.FormJson != null ? JsonSerializer.Deserialize(item.FormJson) : new ApprovalFormItem(); + if (item.FormJson != null) list.Add(FormJson.Route); + } + return list; + } } \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/Dto/ApprovalFormItem.cs b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/Dto/ApprovalFormItem.cs similarity index 93% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/Dto/ApprovalFormItem.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/Dto/ApprovalFormItem.cs index e80b4b1c..dff80fbe 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/Dto/ApprovalFormItem.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/Dto/ApprovalFormItem.cs @@ -1,27 +1,27 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -using System.Text.Json.Serialization; - -namespace Admin.NET.Plugin.ApprovalFlow.Service; - -public class ApprovalFormItem -{ - [JsonPropertyName("configId")] - public string ConfigId { get; set; } - - [JsonPropertyName("tableName")] - public string TableName { get; set; } - - [JsonPropertyName("entityName")] - public string EntityName { get; set; } - - [JsonPropertyName("typeName")] - public string TypeName { get; set; } - - [JsonPropertyName("route")] - public string Route => EntityName[..1].ToLower() + EntityName[1..] + "/" + TypeName; +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using System.Text.Json.Serialization; + +namespace Admin.NET.Plugin.DataApproval.Service; + +public class ApprovalFormItem +{ + [JsonPropertyName("configId")] + public string ConfigId { get; set; } + + [JsonPropertyName("tableName")] + public string TableName { get; set; } + + [JsonPropertyName("entityName")] + public string EntityName { get; set; } + + [JsonPropertyName("typeName")] + public string TypeName { get; set; } + + [JsonPropertyName("route")] + public string Route => EntityName[..1].ToLower() + EntityName[1..] + "/" + TypeName; } \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/Dto/ApprovalFlowDto.cs b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/Dto/DataApprovalDto.cs similarity index 96% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/Dto/ApprovalFlowDto.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/Dto/DataApprovalDto.cs index a8fd9a83..7ba54baf 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/Dto/ApprovalFlowDto.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/Dto/DataApprovalDto.cs @@ -4,12 +4,12 @@ // // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! -namespace Admin.NET.Plugin.ApprovalFlow.Service; +namespace Admin.NET.Plugin.DataApproval.Service; /// /// 审批流输出参数 /// -public class ApprovalFlowDto +public class DataApprovalDto { /// /// 主键Id diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/Dto/ApprovalFlowInput.cs b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/Dto/DataApprovalInput.cs similarity index 89% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/Dto/ApprovalFlowInput.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/Dto/DataApprovalInput.cs index dc9328f2..ed2eef19 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/Dto/ApprovalFlowInput.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/Dto/DataApprovalInput.cs @@ -4,12 +4,12 @@ // // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! -namespace Admin.NET.Plugin.ApprovalFlow.Service; +namespace Admin.NET.Plugin.DataApproval.Service; /// /// 审批流基础输入参数 /// -public class ApprovalFlowBaseInput +public class DataApprovalBaseInput { /// /// 编号 @@ -85,7 +85,7 @@ public class ApprovalFlowBaseInput /// /// 审批流分页查询输入参数 /// -public class ApprovalFlowInput : BasePageInput +public class DataApprovalInput : BasePageInput { /// /// 编号 @@ -106,7 +106,7 @@ public class ApprovalFlowInput : BasePageInput /// /// 审批流增加输入参数 /// -public class AddApprovalFlowInput : ApprovalFlowBaseInput +public class AddDataApprovalInput : DataApprovalBaseInput { /// /// 软删除 @@ -118,14 +118,14 @@ public class AddApprovalFlowInput : ApprovalFlowBaseInput /// /// 审批流删除输入参数 /// -public class DeleteApprovalFlowInput : BaseIdInput +public class DeleteDataApprovalInput : BaseIdInput { } /// /// 审批流更新输入参数 /// -public class UpdateApprovalFlowInput : ApprovalFlowBaseInput +public class UpdateDataApprovalInput : DataApprovalBaseInput { /// /// 主键Id @@ -137,6 +137,6 @@ public class UpdateApprovalFlowInput : ApprovalFlowBaseInput /// /// 审批流主键查询输入参数 /// -public class QueryByIdApprovalFlowInput : DeleteApprovalFlowInput +public class QueryByIdDataApprovalInput : DeleteDataApprovalInput { } \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/Dto/ApprovalFlowItem.cs b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/Dto/DataApprovalItem.cs similarity index 87% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/Dto/ApprovalFlowItem.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/Dto/DataApprovalItem.cs index d35fea72..c691a030 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/Dto/ApprovalFlowItem.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/Dto/DataApprovalItem.cs @@ -1,96 +1,96 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -using System.Text.Json.Serialization; - -namespace Admin.NET.Plugin.ApprovalFlow.Service; - -public class ApprovalFlowItem -{ - [JsonPropertyName("nodes")] - public List Nodes { get; set; } - - [JsonPropertyName("edges")] - public List Edges { get; set; } -} - -public class ApprovalFlowNodeItem -{ - [JsonPropertyName("id")] - public string Id { get; set; } - - [JsonPropertyName("type")] - public string Type { get; set; } - - [JsonPropertyName("x")] - public float X { get; set; } - - [JsonPropertyName("y")] - public float Y { get; set; } - - [JsonPropertyName("properties")] - public FlowProperties Properties { get; set; } - - [JsonPropertyName("text")] - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public FlowTextItem Text { get; set; } -} - -public class ApprovalFlowEdgeItem -{ - [JsonPropertyName("id")] - public string Id { get; set; } - - [JsonPropertyName("type")] - public string Type { get; set; } - - [JsonPropertyName("sourceNodeId")] - public string SourceNodeId { get; set; } - - [JsonPropertyName("targetNodeId")] - public string TargetNodeId { get; set; } - - [JsonPropertyName("startPoint")] - public FlowEdgePointItem StartPoint { get; set; } - - [JsonPropertyName("endPoint")] - public FlowEdgePointItem EndPoint { get; set; } - - [JsonPropertyName("properties")] - public FlowProperties Properties { get; set; } - - [JsonPropertyName("text")] - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public FlowTextItem Text { get; set; } - - [JsonPropertyName("pointsList")] - public List PointsList { get; set; } -} - -public class FlowProperties -{ -} - -public class FlowTextItem -{ - [JsonPropertyName("x")] - public float X { get; set; } - - [JsonPropertyName("y")] - public float Y { get; set; } - - [JsonPropertyName("value")] - public string Value { get; set; } -} - -public class FlowEdgePointItem -{ - [JsonPropertyName("x")] - public float X { get; set; } - - [JsonPropertyName("y")] - public float Y { get; set; } +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using System.Text.Json.Serialization; + +namespace Admin.NET.Plugin.DataApproval.Service; + +public class DataApprovalItem +{ + [JsonPropertyName("nodes")] + public List Nodes { get; set; } + + [JsonPropertyName("edges")] + public List Edges { get; set; } +} + +public class DataApprovalNodeItem +{ + [JsonPropertyName("id")] + public string Id { get; set; } + + [JsonPropertyName("type")] + public string Type { get; set; } + + [JsonPropertyName("x")] + public float X { get; set; } + + [JsonPropertyName("y")] + public float Y { get; set; } + + [JsonPropertyName("properties")] + public FlowProperties Properties { get; set; } + + [JsonPropertyName("text")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public FlowTextItem Text { get; set; } +} + +public class DataApprovalEdgeItem +{ + [JsonPropertyName("id")] + public string Id { get; set; } + + [JsonPropertyName("type")] + public string Type { get; set; } + + [JsonPropertyName("sourceNodeId")] + public string SourceNodeId { get; set; } + + [JsonPropertyName("targetNodeId")] + public string TargetNodeId { get; set; } + + [JsonPropertyName("startPoint")] + public FlowEdgePointItem StartPoint { get; set; } + + [JsonPropertyName("endPoint")] + public FlowEdgePointItem EndPoint { get; set; } + + [JsonPropertyName("properties")] + public FlowProperties Properties { get; set; } + + [JsonPropertyName("text")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public FlowTextItem Text { get; set; } + + [JsonPropertyName("pointsList")] + public List PointsList { get; set; } +} + +public class FlowProperties +{ +} + +public class FlowTextItem +{ + [JsonPropertyName("x")] + public float X { get; set; } + + [JsonPropertyName("y")] + public float Y { get; set; } + + [JsonPropertyName("value")] + public string Value { get; set; } +} + +public class FlowEdgePointItem +{ + [JsonPropertyName("x")] + public float X { get; set; } + + [JsonPropertyName("y")] + public float Y { get; set; } } \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/Dto/ApprovalFlowOutput.cs b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/Dto/DataApprovalOutput.cs similarity index 96% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/Dto/ApprovalFlowOutput.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/Dto/DataApprovalOutput.cs index 81f4b49c..3f03978b 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/Dto/ApprovalFlowOutput.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/DataApproval/Dto/DataApprovalOutput.cs @@ -4,12 +4,12 @@ // // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! -namespace Admin.NET.Plugin.ApprovalFlow.Service; +namespace Admin.NET.Plugin.DataApproval.Service; /// /// 审批流输出参数 /// -public class ApprovalFlowOutput +public class DataApprovalOutput { /// /// 主键Id diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/SysApproval/SysApprovalService.cs b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/SysApproval/SysApprovalService.cs similarity index 73% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/SysApproval/SysApprovalService.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/SysApproval/SysApprovalService.cs index 44f6f18f..3b58fbab 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/SysApproval/SysApprovalService.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Service/SysApproval/SysApprovalService.cs @@ -1,81 +1,81 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -using Microsoft.AspNetCore.Http; - -namespace Admin.NET.Plugin.ApprovalFlow.Service; - -public class SysApprovalService : ITransient -{ - private readonly SqlSugarRepository _approvalFlowRep; - private readonly SqlSugarRepository _approvalFormRep; - private readonly ApprovalFlowService _approvalFlowService; - - public SysApprovalService(SqlSugarRepository approvalFlowRep, SqlSugarRepository approvalFormRep, ApprovalFlowService approvalFlowService) - { - _approvalFlowRep = approvalFlowRep; - _approvalFormRep = approvalFormRep; - _approvalFlowService = approvalFlowService; - } - - /// - /// 匹配审批流程 - /// - /// - /// - [NonAction] - public async Task MatchApproval(HttpContext context) - { - var request = context.Request; - var response = context.Response; - - var path = request.Path.ToString().Split("/"); - - var method = request.Method; - var qs = request.QueryString; - var h = request.Headers; - var b = request.Body; - - var requestHeaders = request.Headers; - var responseHeaders = response.Headers; - - var serviceName = path[1]; - if (serviceName.StartsWith("api")) - { - if (path.Length > 3) - { - var funcName = path[2]; - var typeName = path[3]; - - var list = await _approvalFlowService.FormRoutes(); - if (list.Any(u => u.Contains(funcName) && u.Contains(typeName))) - { - var approvalFlow = new ApprovalFlowRecord - { - FormName = funcName, - CreateTime = DateTime.Now, - }; - - // 判断是否需要审批 - await _approvalFlowRep.InsertAsync(approvalFlow); - - var approvalForm = new ApprovalFormRecord - { - FlowId = approvalFlow.Id, - FormName = funcName, - FormType = typeName, - CreateTime = DateTime.Now, - }; - - // 判断是否需要审批 - await _approvalFormRep.InsertAsync(approvalForm); - } - } - } - - await Task.CompletedTask; - } +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using Microsoft.AspNetCore.Http; + +namespace Admin.NET.Plugin.DataApproval.Service; + +public class SysApprovalService : ITransient +{ + private readonly SqlSugarRepository _DataApprovalRep; + private readonly SqlSugarRepository _approvalFormRep; + private readonly DataApprovalService _DataApprovalService; + + public SysApprovalService(SqlSugarRepository DataApprovalRep, SqlSugarRepository approvalFormRep, DataApprovalService DataApprovalService) + { + _DataApprovalRep = DataApprovalRep; + _approvalFormRep = approvalFormRep; + _DataApprovalService = DataApprovalService; + } + + /// + /// 匹配数据审批 + /// + /// + /// + [NonAction] + public async Task MatchApproval(HttpContext context) + { + var request = context.Request; + var response = context.Response; + + var path = request.Path.ToString().Split("/"); + + var method = request.Method; + var qs = request.QueryString; + var h = request.Headers; + var b = request.Body; + + var requestHeaders = request.Headers; + var responseHeaders = response.Headers; + + var serviceName = path[1]; + if (serviceName.StartsWith("api")) + { + if (path.Length > 3) + { + var funcName = path[2]; + var typeName = path[3]; + + var list = await _DataApprovalService.FormRoutes(); + if (list.Any(u => u.Contains(funcName) && u.Contains(typeName))) + { + var DataApproval = new DataApprovalRecord + { + FormName = funcName, + CreateTime = DateTime.Now, + }; + + // 判断是否需要审批 + await _DataApprovalRep.InsertAsync(DataApproval); + + var approvalForm = new ApprovalFormRecord + { + FlowId = DataApproval.Id, + FormName = funcName, + FormType = typeName, + CreateTime = DateTime.Now, + }; + + // 判断是否需要审批 + await _approvalFormRep.InsertAsync(approvalForm); + } + } + } + + await Task.CompletedTask; + } } \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Startup.cs b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Startup.cs similarity index 92% rename from Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Startup.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Startup.cs index f8d7f83a..4fe2599f 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Startup.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.DataApproval/Startup.cs @@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -namespace Admin.NET.Plugin.ApprovalFlow; +namespace Admin.NET.Plugin.DataApproval; [AppStartup(100)] public class Startup : AppStartup @@ -18,6 +18,6 @@ public class Startup : AppStartup public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { - app.UseApprovalFlow(); + app.UseDataApproval(); } } \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.GoView/Configuration/GoView.json b/Admin.NET/Plugins/Admin.NET.Plugin.GoView/Configuration/GoView.json index 76e03c70..d3960ed9 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.GoView/Configuration/GoView.json +++ b/Admin.NET/Plugins/Admin.NET.Plugin.GoView/Configuration/GoView.json @@ -1,9 +1,9 @@ { "$schema": "https://gitee.com/dotnetchina/Furion/raw/v4/schemas/v4/furion-schema.json", - "[openapi:GoView 大屏可视化]": { - "Group": "GoView 大屏可视化", - "Title": "GoView 大屏可视化", + "[openapi:GoView]": { + "Group": "GoView", + "Title": "GoView", "Description": "GoView 是一个高效的拖拽式低代码数据可视化开发平台,将图表或页面元素封装为基础组件,无需编写代码即可制作数据大屏,减少心智负担。", "Version": "2.2.8", "Order": 95 diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Admin.NET.Plugin.PaddleOCR.csproj b/Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Admin.NET.Plugin.PaddleOCR.csproj index 35f74ed6..64586a2d 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Admin.NET.Plugin.PaddleOCR.csproj +++ b/Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Admin.NET.Plugin.PaddleOCR.csproj @@ -24,6 +24,10 @@ + + + + @@ -33,4 +37,10 @@ + + + PreserveNewest + + + diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Configuration/PaddleOCR.json b/Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Configuration/PaddleOCR.json new file mode 100644 index 00000000..02e21ab8 --- /dev/null +++ b/Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Configuration/PaddleOCR.json @@ -0,0 +1,9 @@ +{ + "[openapi:PaddleOCR]": { + "Group": "PaddleOCR", + "Title": "PaddleOCR", + "Description": "文字识别与文档解析", + "Version": "1.0.0", + "Order": 100 + } +} \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Const/ApplicationConst.cs b/Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Const/PaddleOCRConst.cs similarity index 96% rename from Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Const/ApplicationConst.cs rename to Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Const/PaddleOCRConst.cs index c87228c1..f8122140 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Const/ApplicationConst.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Const/PaddleOCRConst.cs @@ -10,7 +10,7 @@ namespace Admin.NET.Plugin.PaddleOCR; /// PaddleOCR 图像识别 /// [Const("PaddleOCR 图像识别")] -public class ApplicationConst +public class PaddleOCRConst { /// /// API分组名称 diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Service/PaddleOCRService.cs b/Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Service/PaddleOCRService.cs index acd95a6f..4cb0c67d 100644 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Service/PaddleOCRService.cs +++ b/Admin.NET/Plugins/Admin.NET.Plugin.PaddleOCR/Service/PaddleOCRService.cs @@ -14,7 +14,7 @@ namespace Admin.NET.Plugin.PaddleOCR.Service; /// /// PaddleOCR 图像识别服务 🧩 /// -[ApiDescriptionSettings(ApplicationConst.GroupName, Description = "PaddleOCR 图像识别")] +[ApiDescriptionSettings(PaddleOCRConst.GroupName, Description = "PaddleOCR 图像识别")] public class PaddleOCRService : IDynamicApiController, ISingleton { private readonly PaddleOCREngine _engine; diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Admin.NET.Plugin.PluginCore.csproj b/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Admin.NET.Plugin.PluginCore.csproj deleted file mode 100644 index 4ab167f6..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Admin.NET.Plugin.PluginCore.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - net8.0;net9.0 - 1701;1702;1591;8632 - enable - disable - True - Admin.NET - Admin.NET 通用权限开发平台 - - - - - true - PreserveNewest - PreserveNewest - true - - - - - - - - - - diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/App_Data/PluginCore.Config.json b/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/App_Data/PluginCore.Config.json deleted file mode 100644 index 6340ddf3..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/App_Data/PluginCore.Config.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Admin": { - "UserName": "admin", - "Password": "ABC12345" - }, - "FrontendMode": "LocalEmbedded", - "RemoteFrontend": "https://cdn.jsdelivr.net/gh/yiyungent/plugincore-admin-frontend@0.3.1/dist-cdn", - "PluginWidgetDebug": false -} \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/App_Data/plugin.config.json b/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/App_Data/plugin.config.json deleted file mode 100644 index 1d0baec1..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/App_Data/plugin.config.json +++ /dev/null @@ -1 +0,0 @@ -{ "EnabledPlugins": [ "Admin.NET.Plugin.Pay.Alipay" ] } \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Controllers/AppCenterController.cs b/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Controllers/AppCenterController.cs deleted file mode 100644 index 3967d58b..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Controllers/AppCenterController.cs +++ /dev/null @@ -1,189 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -using PluginCore.AspNetCore.ResponseModel; -using PluginCore.Models; -using System.Net; - -namespace PluginCore.AspNetCore.Controllers; - -/// -/// 应用中心 -/// 插件 -/// -[Route("api/plugincore/admin/[controller]/[action]")] -// [PluginCoreAdminAuthorize] -[ApiController] -[NonUnify] -public class AppCenterController : ControllerBase -{ - #region Fields - - private static Dictionary _pluginDownloadTasks; - - #endregion Fields - - #region Ctor - - static AppCenterController() - { - _pluginDownloadTasks = new Dictionary(); - } - - public AppCenterController() - { - } - - #endregion Ctor - - #region Actions - - #region 插件列表 - - /// - /// 插件 - /// - /// - /// - [HttpGet, HttpPost] - public async Task> Plugins(string query = "") - { - BaseResponseModel responseDTO = new BaseResponseModel(); - IList pluginRegistryModels = new List(); - try - { - // 1. TODO: 从json文件中读取插件订阅源 registry url - string registryUrl = ""; - // 2. TODO: 向订阅源发送 http get 获取插件列表信息 eg: http://rem-core-plugins-registry.moeci.com/?query=xxx - IList remotePluginIds = new List(); - - // 3. 根据本地已有 PluginId 插件情况 状态赋值 - PluginConfigModel pluginConfigModel = PluginConfigModelFactory.Create(); - // IList localPluginIds = pluginConfigModel.EnabledPlugins.Concat(pluginConfigModel.DisabledPlugins).Concat(pluginConfigModel.UninstalledPlugins).ToList(); - IList localPluginIds = PluginPathProvider.AllPluginFolderName(); - - responseDTO.Code = 1; - responseDTO.Message = "获取远程插件数据成功"; - responseDTO.Data = pluginRegistryModels; - } - catch (Exception ex) - { - responseDTO.Code = -1; - responseDTO.Message = "获取远程插件数据失败: " + ex.Message; - responseDTO.Data = pluginRegistryModels; - } - - return await Task.FromResult(responseDTO); - } - - #endregion 插件列表 - - #region 下载插件 - - [HttpGet, HttpPost] - public async Task> DownloadPlugin(string pluginDownloadUrl = "") - { - BaseResponseModel responseDTO = new BaseResponseModel(); - - #region 效验 - - if (string.IsNullOrEmpty(pluginDownloadUrl)) - { - responseDTO.Code = -1; - responseDTO.Message = "插件下载地址不正确"; - return responseDTO; - } - // TODO: 效验是否本地已经存在相同pluginId的插件 - - #endregion 效验 - - try - { - // 1.执行下载操作, TODO:存在问题,阻塞对性能不好,但不阻塞又不好通知用户插件下载进度,以及可能存在在插件下载过程中,用户再次点击下载 - WebClient webClient = new WebClient(); - // TODO: 插件下载文件路径 - string pluginDownloadFilePath = ""; - //webClient.DownloadFileAsync(new Uri(pluginDownloadFilePath), ""); - Task task = webClient.DownloadFileTaskAsync(pluginDownloadUrl, pluginDownloadFilePath); - - _pluginDownloadTasks.Add(pluginDownloadUrl, task); - - webClient.DownloadFileCompleted += Plugin_DownloadFileCompleted; - webClient.DownloadProgressChanged += Plugin_DownloadProgressChanged; - webClient.Disposed += WebClient_Disposed; - - responseDTO.Code = 1; - responseDTO.Message = "开始下载插件"; - } - catch (Exception ex) - { - responseDTO.Code = -1; - responseDTO.Message = "下载插件失败: " + ex.Message; - } - - return await Task.FromResult(responseDTO); - } - - #endregion 下载插件 - - #region 获取插件下载进度 - - [HttpGet, HttpPost] - public async Task> DownloadPluginProgress() - { - BaseResponseModel responseDTO = new BaseResponseModel(); - try - { - responseDTO.Data = new { }; - - responseDTO.Code = 1; - responseDTO.Message = "获取插件下载进度成功"; - } - catch (Exception ex) - { - responseDTO.Code = -1; - responseDTO.Message = "获取插件下载进度失败: " + ex.Message; - } - - return await Task.FromResult(responseDTO); - } - - #endregion 获取插件下载进度 - - #endregion Actions - - #region Helpers - - /// - /// 插件下载完成 - /// - /// - /// - private void Plugin_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) - { - Console.WriteLine("插件下载完成"); - // 1.从 _pluginDownloadTasks 中移除 - //_pluginDownloadTasks.Remove(); - // 2. 解压插件 - } - - private void Plugin_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) - { - Console.WriteLine($"插件下载进度改变: {e.ProgressPercentage}% {e.BytesReceived}/{e.TotalBytesToReceive}"); - } - - private void WebClient_Disposed(object sender, EventArgs e) - { - if (sender is WebClient webClient) - { - Console.WriteLine(webClient.BaseAddress); - } - - Console.WriteLine(nameof(WebClient_Disposed) + ": " + sender.ToString()); - } - - #endregion Helpers -} \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Controllers/DebugController.cs b/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Controllers/DebugController.cs deleted file mode 100644 index 94c34ae9..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Controllers/DebugController.cs +++ /dev/null @@ -1,268 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -using PluginCore.AspNetCore.Extensions; -using PluginCore.AspNetCore.ResponseModel; -using PluginCore.Interfaces; -using System.Runtime.Loader; - -namespace PluginCore.AspNetCore.Controllers; - -/// -/// [ASP.NET Core — 依赖注入\_啊晚的博客-CSDN博客\_asp.net core 依赖注入](https://blog.csdn.net/weixin_37648525/article/details/127942292) -/// [ASP.NET Core中的依赖注入(3): 服务的注册与提供 - Artech - 博客园](https://www.cnblogs.com/artech/p/asp-net-core-di-register.html) -/// [ASP.NET Core中的依赖注入(5): ServiceProvider实现揭秘 【总体设计 】 - Artech - 博客园](https://www.cnblogs.com/artech/p/asp-net-core-di-service-provider-1.html) -/// [dotnet/ServiceProvider.cs at main · dotnet/dotnet](https://github.com/dotnet/dotnet/blob/main/src/runtime/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs) -/// [Net6 DI源码分析Part2 Engine,ServiceProvider - 一身大膘 - 博客园](https://www.cnblogs.com/hts92/p/15800990.html) -/// [【特别的骚气】asp.net core运行时注入服务,实现类库热插拔 - 四处观察 - 博客园](https://www.cnblogs.com/1996-Chinese-Chen/p/16154218.html) -/// -/// ActivatorUtilities.CreateInstance(serviceProvider, "test"); -/// ActivatorUtilities.GetServiceOrCreateInstance(serviceProvider); -/// -[Route("api/plugincore/admin/[controller]/[action]")] -//[PluginCoreAdminAuthorize] -[ApiController] -[NonUnify] -public class DebugController : ControllerBase -{ - #region Fields - - private readonly IPluginContextManager _pluginContextManager; - - #endregion Fields - - #region Ctor - - public DebugController(IPluginContextManager pluginContextManager) - { - _pluginContextManager = pluginContextManager; - } - - #endregion Ctor - - #region Actions - - [HttpGet, HttpPost] - public async Task> PluginContexts() - { - BaseResponseModel responseModel = new BaseResponseModel(); - try - { - var pluginContextList = _pluginContextManager.All(); - Dictionary> keyValuePairs = new Dictionary>(); - foreach (var pluginContext in pluginContextList) - { - keyValuePairs.Add($"{pluginContext.GetType().ToString()} - {pluginContext.PluginId} - {pluginContext.GetHashCode()}", pluginContext.Assemblies.Select(m => m.FullName).ToList()); - } - - responseModel.Code = 1; - responseModel.Message = "success"; - responseModel.Data = keyValuePairs; - } - catch (Exception ex) - { - responseModel.Code = -1; - responseModel.Message = "error"; - responseModel.Data = ex.ToString(); - } - - return await Task.FromResult(responseModel); - } - - [HttpGet, HttpPost] - public async Task> AssemblyLoadContexts() - { - BaseResponseModel responseModel = new BaseResponseModel(); - try - { - var assemblyLoadContextDefault = AssemblyLoadContext.Default; - var assemblyLoadContextAll = AssemblyLoadContext.All; - var responseDataModel = new AssemblyLoadContextsResponseDataModel(); - responseDataModel.Default = new AssemblyLoadContextsResponseDataModel.AssemblyLoadContextModel - { - Name = assemblyLoadContextDefault.Name, - Type = assemblyLoadContextDefault.GetType().ToString(), - Assemblies = assemblyLoadContextDefault.Assemblies.Select(m => new AssemblyModel { FullName = m.FullName, DefinedTypes = m.DefinedTypes.Select(m => m.FullName).ToList() }).ToList() - }; - responseDataModel.All = assemblyLoadContextAll.Select(item => new AssemblyLoadContextsResponseDataModel.AssemblyLoadContextModel - { - Name = item.Name, - Type = item.GetType().ToString(), - Assemblies = item.Assemblies.Select(m => new AssemblyModel { FullName = m.FullName, DefinedTypes = m.DefinedTypes.Select(m => m.FullName).ToList() }).ToList() - }).ToList(); - - responseModel.Code = 1; - responseModel.Message = "success"; - responseModel.Data = responseDataModel; - } - catch (Exception ex) - { - responseModel.Code = -1; - responseModel.Message = "error"; - responseModel.Data = ex.ToString(); - } - - return await Task.FromResult(responseModel); - } - - [HttpGet, HttpPost] - public async Task> Assemblies() - { - BaseResponseModel responseModel = new BaseResponseModel(); - try - { - var assemblies = AppDomain.CurrentDomain.GetAssemblies(); - List assemblyModels = new List(); - foreach (var item in assemblies) - { - assemblyModels.Add(new AssemblyModel - { - FullName = item.FullName, - DefinedTypes = item.DefinedTypes.Select(m => m.FullName).ToList() - }); - } - - responseModel.Code = 1; - responseModel.Message = "success"; - responseModel.Data = assemblyModels; - } - catch (Exception ex) - { - responseModel.Code = -1; - responseModel.Message = "error"; - responseModel.Data = ex.ToString(); - } - - return await Task.FromResult(responseModel); - } - - [HttpGet, HttpPost] - public async Task> Services([FromServices] IServiceProvider serviceProvider) - { - BaseResponseModel responseModel = new BaseResponseModel(); - try - { - //IServiceProvider serviceProvider = HttpContext.RequestServices; - //var provider = serviceProvider.GetType().GetProperty("RootProvider", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); - //var serviceField = provider.GetType().GetField("_realizedServices", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); - //var serviceValue = serviceField.GetValue(provider); - //var funcType = serviceField.FieldType.GetGenericArguments()[1].GetGenericArguments()[0]; - //ConcurrentDictionary> realizedServices = (ConcurrentDictionary>)serviceValue; - - // 获取所有已经注册的服务 - var allService = serviceProvider.GetAllServiceDescriptors(); - - List serviceModels = new List(); - foreach (var item in allService) - { - serviceModels.Add(new ServiceModel - { - Type = item.Key.ToString(), - ImplementationType = item.Value.ImplementationType?.ToString() ?? "", - Lifetime = item.Value.Lifetime.ToString(), - TypeAssembly = new AssemblyModel - { - FullName = item.Key.Assembly.FullName, - }, - ImplementationTypeAssembly = new AssemblyModel - { - FullName = item.Value.ImplementationType?.Assembly?.FullName ?? "" - } - }); - } - - responseModel.Code = 1; - responseModel.Message = "success"; - responseModel.Data = serviceModels; - } - catch (Exception ex) - { - responseModel.Code = -1; - responseModel.Message = "error"; - responseModel.Data = ex.ToString(); - } - - return await Task.FromResult(responseModel); - } - - #endregion Actions - - public sealed class AssemblyLoadContextsResponseDataModel - { - public AssemblyLoadContextModel Default - { - get; set; - } - - public List All - { - get; set; - } - - public sealed class AssemblyLoadContextModel - { - public string Name - { - get; set; - } - - public string Type - { - get; set; - } - - public List Assemblies - { - get; set; - } - } - } - - public sealed class AssembliesResponseDataModel - { - } - - public sealed class ServiceModel - { - public string Type - { - get; set; - } - - public string ImplementationType - { - get; set; - } - - public string Lifetime - { - get; set; - } - - public AssemblyModel TypeAssembly - { - get; set; - } - - public AssemblyModel ImplementationTypeAssembly - { - get; set; - } - } - - public sealed class AssemblyModel - { - public string FullName - { - get; set; - } - - public List DefinedTypes - { - get; set; - } - } -} \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Controllers/PluginWidgetController.cs b/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Controllers/PluginWidgetController.cs deleted file mode 100644 index b876ee2b..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Controllers/PluginWidgetController.cs +++ /dev/null @@ -1,90 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -using PluginCore.AspNetCore.ResponseModel; -using PluginCore.Interfaces; -using PluginCore.IPlugins; - -namespace PluginCore.AspNetCore.Controllers; - -[Route("api/plugincore/[controller]/[action]")] -[ApiController] -[NonUnify] -public class PluginWidgetController : ControllerBase -{ - #region Fields - - private readonly IPluginFinder _pluginFinder; - - #endregion Fields - - #region Ctor - - public PluginWidgetController(IPluginFinder pluginFinder) - { - _pluginFinder = pluginFinder; - } - - #endregion Ctor - - #region Actions - - #region Widget - - /// - /// Widget - /// - /// - [HttpGet, HttpPost] - public async Task Widget(string widgetKey, string extraPars = "") - { - BaseResponseModel responseModel = new ResponseModel.BaseResponseModel(); - string responseData = ""; - widgetKey = widgetKey.Trim('"', '\''); - string[] extraParsArr = null; - if (!string.IsNullOrEmpty(extraPars)) - { - extraParsArr = extraPars.Split(",", StringSplitOptions.RemoveEmptyEntries); - extraParsArr = extraParsArr.Select(m => m.Trim('"', '\'')).ToArray(); - } - StringBuilder sb = new StringBuilder(); - sb.AppendLine($""); - try - { - List plugins = this._pluginFinder.EnablePlugins().ToList(); - foreach (var item in plugins) - { - string widgetStr = await item.Widget(widgetKey, extraParsArr); - if (!string.IsNullOrEmpty(widgetStr)) - { - // TODO: 配合 PluginCoreConfig.PluginWidgetDebug - // TODO: PluginCoreConfig 改为 Options 模式, 避免手动反复读取文件 效率低 - //sb.AppendLine($""); - - sb.AppendLine(widgetStr); - } - } - } - catch (Exception ex) - { - Utils.LogUtil.Error(ex.ToString()); - sb.AppendLine($""); - } - sb.AppendLine($""); - responseData = sb.ToString(); - - responseModel.Code = 1; - responseModel.Message = "Load Widget Success"; - responseModel.Data = responseData; - - //return await Task.FromResult(responseModel); - return Content(responseData, "text/html;charset=utf-8"); - } - - #endregion Widget - - #endregion Actions -} \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Controllers/PluginsController.cs b/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Controllers/PluginsController.cs deleted file mode 100644 index e23be0a0..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Controllers/PluginsController.cs +++ /dev/null @@ -1,709 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -using PluginCore.AspNetCore.Interfaces; -using PluginCore.AspNetCore.ResponseModel; -using PluginCore.Infrastructure; -using PluginCore.Interfaces; -using PluginCore.IPlugins; -using PluginCore.Models; - -namespace PluginCore.AspNetCore.Controllers; - -[Route("api/plugincore/admin/[controller]/[action]")] -// [PluginCoreAdminAuthorize] -[ApiController] -[NonUnify] -public class PluginsController : ControllerBase -{ - #region Fields - - private readonly IPluginManager _pluginManager; - private readonly IPluginFinder _pluginFinder; - private readonly IPluginApplicationBuilderManager _pluginApplicationBuilderManager; - - #endregion Fields - - #region Ctor - - public PluginsController(IPluginManager pluginManager, IPluginFinder pluginFinder, IPluginApplicationBuilderManager pluginApplicationBuilderManager) - { - _pluginManager = pluginManager; - _pluginFinder = pluginFinder; - _pluginApplicationBuilderManager = pluginApplicationBuilderManager; - } - - #endregion Ctor - - #region Actions - - #region 插件列表 - - /// - /// 加载插件列表 - /// - /// 插件状态 - /// - [HttpGet, HttpPost] - public async Task> List(string status = "all") - { - BaseResponseModel responseData = new ResponseModel.BaseResponseModel(); - var pluginConfigModel = PluginConfigModelFactory.Create(); - - // 获取所有插件信息 - IList pluginInfoModels = PluginInfoModelFactory.CreateAll(); - IList responseModels = new List(); - string[] enablePluginIds = _pluginFinder.EnablePluginIds().ToArray(); - - // 添加插件状态 - responseModels = PluginInfoModelToResponseModel(pluginInfoModels, pluginConfigModel, enablePluginIds); - - #region 筛选插件状态 - - switch (status.ToLower()) - { - case "all": - break; - - case "enabled": - responseModels = responseModels.Where(m => m.Status == PluginStatus.Enabled).ToList(); - break; - - case "disabled": - responseModels = responseModels.Where(m => m.Status == PluginStatus.Disabled).ToList(); - break; - - default: - break; - } - - #endregion 筛选插件状态 - - responseData.Code = 1; - responseData.Message = "加载插件列表成功"; - responseData.Data = responseModels; - - return await Task.FromResult(responseData); - } - - #endregion 插件列表 - - #region 卸载插件 - - [HttpGet, HttpPost] - public async Task> Uninstall(string pluginId) - { - BaseResponseModel responseData = new BaseResponseModel(); - pluginId = pluginId.Trim(); - var pluginConfigModel = PluginConfigModelFactory.Create(); - // 卸载插件 必须 先禁用插件 - - #region 效验 - - if (pluginConfigModel.EnabledPlugins.Contains(pluginId)) - { - responseData.Code = -1; - responseData.Message = "卸载失败: 请先禁用此插件"; - return await Task.FromResult(responseData); - } - string pluginDirStr = Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId); - string pluginWwwrootDirStr = Path.Combine(PluginPathProvider.PluginsWwwRootDir(), pluginId); - if (!Directory.Exists(pluginDirStr) && !Directory.Exists(pluginWwwrootDirStr)) - { - responseData.Code = -2; - responseData.Message = "卸载失败: 此插件不存在"; - return await Task.FromResult(responseData); - } - - #endregion 效验 - - try - { - // PS:卸载插件必须先禁用插件,所以此时插件LoadContext已被移除释放(插件Assemblies已被释放), 此处不需移除LoadContext - - // 1.删除物理文件 - var pluginDir = new DirectoryInfo(pluginDirStr); - if (pluginDir.Exists) - { - pluginDir.Delete(true); - } - // 虽然 已禁用 时 pluginWwwrootDirStr/pluginId 已删除, 但为确保, 还是再删除一次 - var pluginWwwrootDir = new DirectoryInfo(pluginWwwrootDirStr); - if (pluginWwwrootDir.Exists) - { - pluginWwwrootDir.Delete(true); - } - - responseData.Code = 1; - responseData.Message = "卸载成功"; - } - catch (Exception ex) - { - responseData.Code = -1; - responseData.Message = "卸载失败: " + ex.Message; - } - - return await Task.FromResult(responseData); - } - - #endregion 卸载插件 - - #region 启用插件 - - [HttpGet, HttpPost] - public async Task> Enable(string pluginId) - { - BaseResponseModel responseData = new BaseResponseModel(); - var pluginConfigModel = PluginConfigModelFactory.Create(); - // 效验是否存在于 已禁用插件列表 - - #region 效验 - - pluginId = pluginId.Trim(); - var pluginDir = new DirectoryInfo(Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId)); - if (pluginDir != null && !pluginDir.Exists) - { - responseData.Code = -1; - responseData.Message = "启用失败: 此插件不存在"; - return await Task.FromResult(responseData); - } - string[] enablePluginIds = _pluginFinder.EnablePluginIds().ToArray(); - if (enablePluginIds.Contains(pluginId)) - { - responseData.Code = -2; - responseData.Message = "启用失败: 此插件已启用"; - return await Task.FromResult(responseData); - } - - #endregion 效验 - - try - { - // 1. 创建插件程序集加载上下文, 添加到 PluginsLoadContexts - _pluginManager.LoadPlugin(pluginId); - // 2. 添加到 pluginConfigModel.EnabledPlugins - pluginConfigModel.EnabledPlugins.Add(pluginId); - // 4.保存到 plugin.config.json - PluginConfigModelFactory.Save(pluginConfigModel); - - // 5. 找到此插件实例 - IPlugin plugin = _pluginFinder.Plugin(pluginId); - if (plugin == null) - { - // 7.启用不成功, 回滚插件状态: (1)释放插件上下文 (2)更新 plugin.config.json - try - { - _pluginManager.UnloadPlugin(pluginId); - } - catch (Exception ex) - { } - - // 从 pluginConfigModel.EnabledPlugins 移除 - pluginConfigModel.EnabledPlugins.Remove(pluginId); - // 保存到 plugin.config.json - PluginConfigModelFactory.Save(pluginConfigModel); - - responseData.Code = -1; - responseData.Message = "启用失败: 此插件不存在"; - return await Task.FromResult(responseData); - } - // 6.调取插件的 AfterEnable(), 插件开发者可在此回收资源 - var pluginEnableResult = plugin.AfterEnable(); - if (!pluginEnableResult.IsSuccess) - { - // 7.启用不成功, 回滚插件状态: (1)释放插件上下文 (2)更新 plugin.config.json - try - { - _pluginManager.UnloadPlugin(pluginId); - } - catch (Exception ex) - { } - - // 从 pluginConfigModel.EnabledPlugins 移除 - pluginConfigModel.EnabledPlugins.Remove(pluginId); - // 保存到 plugin.config.json - PluginConfigModelFactory.Save(pluginConfigModel); - - responseData.Code = -1; - responseData.Message = "启用失败: 来自插件的错误信息: " + pluginEnableResult.Message; - return await Task.FromResult(responseData); - } - - // 7. ReBuild - this._pluginApplicationBuilderManager.ReBuild(); - - // 8. 尝试复制 插件下的 wwwroot 到 Plugins_wwwroot - string wwwRootDir = PluginPathProvider.WwwRootDir(pluginId); - if (Directory.Exists(wwwRootDir)) - { - string targetDir = PluginPathProvider.PluginWwwRootDir(pluginId); - Utils.FileUtil.CopyFolder(wwwRootDir, targetDir); - } - - responseData.Code = 1; - responseData.Message = "启用成功"; - } - catch (Exception ex) - { - responseData.Code = -2; - responseData.Message = "启用失败: " + ex.Message; - } - - return await Task.FromResult(responseData); - } - - #endregion 启用插件 - - #region 禁用插件 - - [HttpGet, HttpPost] - public async Task> Disable(string pluginId) - { - BaseResponseModel responseData = new BaseResponseModel(); - - #region 效验 - - pluginId = pluginId.Trim(); - var pluginConfigModel = PluginConfigModelFactory.Create(); - // string[] enablePluginIds = _pluginFinder.EnablePluginIds().ToArray(); - // // 效验是否存在于 已启用插件列表 - // if (!enablePluginIds.Contains(pluginId)) - // { - // responseData.Code = -1; - // responseData.Message = "禁用失败: 此插件不存在, 或未启用"; - // return await Task.FromResult(responseData); - // } - - #endregion 效验 - - try - { - // 1. 找到此插件实例 - IPlugin plugin = _pluginFinder.Plugin(pluginId); - if (plugin == null) - { - responseData.Code = -1; - responseData.Message = "禁用失败: 此插件不存在, 或未启用"; - return await Task.FromResult(responseData); - } - try - { - // 2.调取插件的 BeforeDisable(), 插件开发者可在此回收资源 - var pluginDisableResult = plugin.BeforeDisable(); - if (!pluginDisableResult.IsSuccess) - { - responseData.Code = -1; - responseData.Message = "禁用失败: 来自插件的错误信息: " + pluginDisableResult.Message; - return await Task.FromResult(responseData); - } - // 3.移除插件对应的程序集加载上下文 - _pluginManager.UnloadPlugin(pluginId); - // 3.1. ReBuild - this._pluginApplicationBuilderManager.ReBuild(); - if (pluginConfigModel.EnabledPlugins.Contains(pluginId)) - { - // 4.从 pluginConfigModel.EnabledPlugins 移除 - pluginConfigModel.EnabledPlugins.Remove(pluginId); - // 5.保存到 plugin.config.json - PluginConfigModelFactory.Save(pluginConfigModel); - } - } - catch (Exception ex) - { - //Utils.LogUtil.Error(ex.ToString()); - responseData.Code = -1; - responseData.Message = "禁用失败: 此插件不存在, 或未启用"; - return await Task.FromResult(responseData); - } - - // 7. 尝试移除 Plugins_wwwroot/PluginId - string pluginWwwRootDir = PluginPathProvider.PluginWwwRootDir(pluginId); - if (Directory.Exists(pluginWwwRootDir)) - { - Directory.Delete(pluginWwwRootDir, true); - } - - responseData.Code = 1; - responseData.Message = "禁用成功"; - } - catch (Exception ex) - { - responseData.Code = -2; - responseData.Message = "禁用失败: " + ex.Message; - } - - return await Task.FromResult(responseData); - } - - #endregion 禁用插件 - - #region 上传插件 - - /// - /// 上传插件 - /// - /// 注意: 参数名一定为 file, 对应前端传过来时以 file 为名 - /// - [HttpGet, HttpPost] - public async Task> Upload(IFormFile file) - { - BaseResponseModel responseData = new BaseResponseModel(); - - #region 效验 - - if (file == null) - { - responseData.Code = -1; - responseData.Message = "上传的文件不能为空"; - return responseData; - } - //文件后缀 - string fileExtension = Path.GetExtension(file.FileName);//获取文件格式,拓展名 - // 类型标记 - UploadFileType uploadFileType = UploadFileType.NoAllowedType; - switch (fileExtension) - { - case ".zip": - uploadFileType = UploadFileType.Zip; - break; - - case ".nupkg": - uploadFileType = UploadFileType.Nupkg; - break; - } - - if (fileExtension != ".zip" && fileExtension != ".nupkg") - { - responseData.Code = -1; - // nupkg 其实就是 zip - responseData.Message = "只能上传 zip 或 nupkg 格式文件"; - return responseData; - } - // PluginCore.AspNetCore-v1.0.2 起 不再限制插件上传大小 - //判断文件大小 - //var fileSize = file.Length; - //if (fileSize > 1024 * 1024 * 5) // 5M - //{ - // responseData.Code = -1; - // responseData.Message = "上传的文件不能大于5MB"; - // return responseData; - //} - - #endregion 效验 - - try - { - // 1.先上传到 临时插件上传目录, 用Guid.zip作为保存文件名 - string tempZipFilePath = Path.Combine(PluginPathProvider.TempPluginUploadDir(), Guid.NewGuid() + ".zip"); - using (var fs = System.IO.File.Create(tempZipFilePath)) - { - file.CopyTo(fs); //将上传的文件文件流,复制到fs中 - fs.Flush();//清空文件流 - } - // 2.解压 - bool isDecomparessSuccess = false; - if (uploadFileType == UploadFileType.Zip) - { - isDecomparessSuccess = Utils.ZipHelper.DecomparessFile(tempZipFilePath, tempZipFilePath.Replace(".zip", "")); - } - else if (uploadFileType == UploadFileType.Nupkg) - { - isDecomparessSuccess = NupkgService.DecomparessFile(tempZipFilePath, tempZipFilePath.Replace(".zip", "")); - } - - // 3.删除原压缩包 - System.IO.File.Delete(tempZipFilePath); - if (!isDecomparessSuccess) - { - responseData.Code = -1; - responseData.Message = "解压插件压缩包失败"; - return responseData; - } - // 4.读取其中的info.json, 获取 PluginId 值 - PluginInfoModel pluginInfoModel = PluginInfoModelFactory.ReadPluginDir(tempZipFilePath.Replace(".zip", "")); - if (pluginInfoModel == null || string.IsNullOrEmpty(pluginInfoModel.PluginId)) - { - // 记得删除已不再需要的临时插件文件夹 - Directory.Delete(tempZipFilePath.Replace(".zip", ""), true); - - responseData.Code = -1; - responseData.Message = "不合法的插件"; - return responseData; - } - string pluginId = pluginInfoModel.PluginId; - // 5.检索 此 PluginId 是否本地插件已存在 - var pluginConfigModel = PluginConfigModelFactory.Create(); - // 本地已经存在的 PluginId - IList localExistPluginIds = PluginPathProvider.AllPluginFolderName(); - if (localExistPluginIds.Contains(pluginId)) - { - // 记得删除已不再需要的临时插件文件夹 - Directory.Delete(tempZipFilePath.Replace(".zip", ""), true); - - responseData.Code = -1; - responseData.Message = $"本地已有此插件 (PluginId: {pluginId}), 请前往插件列表删除后, 再上传"; - return responseData; - } - // 6.本地无此插件 -> 移动插件文件夹到 Plugins 下, 并以 PluginId 为插件文件夹名 - string pluginsRootPath = PluginPathProvider.PluginsRootPath(); - string newPluginDir = Path.Combine(pluginsRootPath, pluginId); - Directory.Move(tempZipFilePath.Replace(".zip", ""), newPluginDir); - - // 7. 放入 Plugins 中, 默认为 已禁用 - - responseData.Code = 1; - responseData.Message = $"上传插件成功 (PluginId: {pluginId})"; - } - catch (Exception ex) - { - responseData.Code = -1; - responseData.Message = "上传插件失败: " + ex.Message; - ex = ex.InnerException; - while (ex != null) - { - responseData.Message += " - " + ex.InnerException.Message; - ex = ex.InnerException; - } - } - - return await Task.FromResult(responseData); - } - - #endregion 上传插件 - - #region 查看详细 - - [HttpGet, HttpPost] - public async Task> Details(string pluginId) - { - BaseResponseModel responseData = new BaseResponseModel(); - - try - { - #region 效验 - - pluginId = pluginId.Trim(); - var pluginConfigModel = PluginConfigModelFactory.Create(); - string[] localPluginIds = PluginPathProvider.AllPluginFolderName().ToArray(); - - if (!localPluginIds.Contains(pluginId)) - { - responseData.Code = -1; - responseData.Message = $"查看详细失败: 不存在 {pluginId} 插件"; - return await Task.FromResult(responseData); - } - - #endregion 效验 - - PluginInfoModel pluginInfoModel = PluginInfoModelFactory.Create(pluginId); - string[] enablePluginIds = _pluginFinder.EnablePluginIds().ToArray(); - PluginInfoResponseModel pluginInfoResponseModel = PluginInfoModelToResponseModel(new List() { pluginInfoModel }, pluginConfigModel, enablePluginIds).FirstOrDefault(); - - responseData.Code = 1; - responseData.Message = "查看详细成功"; - responseData.Data = pluginInfoResponseModel; - } - catch (Exception ex) - { - responseData.Code = -1; - responseData.Message = "查看详细失败: " + ex.Message; - } - - return await Task.FromResult(responseData); - } - - #endregion 查看详细 - - #region 查看文档 - - [HttpGet, HttpPost] - public async Task> Readme(string pluginId) - { - BaseResponseModel responseData = new BaseResponseModel(); - - try - { - #region 效验 - - pluginId = pluginId.Trim(); - // var pluginConfigModel = PluginConfigModelFactory.Create(); - string[] localPluginIds = PluginPathProvider.AllPluginFolderName().ToArray(); - - if (!localPluginIds.Contains(pluginId)) - { - responseData.Code = -1; - responseData.Message = $"查看文档失败: 不存在 {pluginId} 插件"; - return await Task.FromResult(responseData); - } - - #endregion 效验 - - PluginReadmeModel readmeModel = PluginReadmeModelFactory.Create(pluginId); - PluginReadmeResponseModel readmeResponseModel = new PluginReadmeResponseModel(); - readmeResponseModel.Content = readmeModel?.Content ?? ""; - readmeResponseModel.PluginId = pluginId; - - responseData.Code = 1; - responseData.Message = "查看文档成功"; - responseData.Data = readmeResponseModel; - } - catch (Exception ex) - { - responseData.Code = -1; - responseData.Message = "查看文档失败: " + ex.Message; - } - - return await Task.FromResult(responseData); - } - - #endregion 查看文档 - - #region 设置 - - [HttpGet] - public async Task> Settings(string pluginId) - { - BaseResponseModel responseData = new BaseResponseModel(); - - try - { - #region 效验 - - pluginId = pluginId.Trim(); - // var pluginConfigModel = PluginConfigModelFactory.Create(); - string[] localPluginIds = PluginPathProvider.AllPluginFolderName().ToArray(); - - if (!localPluginIds.Contains(pluginId)) - { - responseData.Code = -1; - responseData.Message = $"查看设置失败: 不存在 {pluginId} 插件"; - return await Task.FromResult(responseData); - } - - #endregion 效验 - - string settingsJsonStr = PluginSettingsModelFactory.Create(pluginId); - - responseData.Code = 1; - responseData.Message = "查看设置成功"; - responseData.Data = settingsJsonStr ?? "无设置项"; - } - catch (Exception ex) - { - responseData.Code = -1; - responseData.Message = "查看设置失败: " + ex.Message; - } - - return await Task.FromResult(responseData); - } - - [HttpPost] - public async Task> Settings(PluginSettingsInputModel inputModel) - { - BaseResponseModel responseData = new BaseResponseModel(); - - try - { - #region 效验 - - inputModel.PluginId = inputModel.PluginId.Trim(); - // var pluginConfigModel = PluginConfigModelFactory.Create(); - string[] localPluginIds = PluginPathProvider.AllPluginFolderName().ToArray(); - - if (!localPluginIds.Contains(inputModel.PluginId)) - { - responseData.Code = -1; - responseData.Message = $"设置失败: 不存在 {inputModel.PluginId} 插件"; - return await Task.FromResult(responseData); - } - - #endregion 效验 - - inputModel.Data = inputModel.Data ?? ""; - PluginSettingsModelFactory.Save(pluginSettingsJsonStr: inputModel.Data, pluginId: inputModel.PluginId); - - responseData.Code = 1; - responseData.Message = "设置成功"; - responseData.Data = inputModel.Data; - } - catch (Exception ex) - { - responseData.Code = -1; - responseData.Message = "设置失败: " + ex.Message; - } - - return await Task.FromResult(responseData); - } - - #endregion 设置 - - #endregion Actions - - #region Helpers - - [NonAction] - private IList PluginInfoModelToResponseModel(IList pluginInfoModels, PluginConfigModel pluginConfigModel, string[] enablePluginIds) - { - // 获取 Plugins 下所有插件 - // DirectoryInfo pluginsDir = new DirectoryInfo(PluginPathProvider.PluginsRootPath()); - // List pluginIds = pluginsDir?.GetDirectories()?.Select(m => m.Name)?.ToList() ?? new List(); - - IList responseModels = new List(); - - #region 添加插件状态信息 - - foreach (var model in pluginInfoModels) - { - PluginInfoResponseModel responseModel = new PluginInfoResponseModel(); - responseModel.Author = model.Author; - responseModel.Description = model.Description; - responseModel.DisplayName = model.DisplayName; - responseModel.PluginId = model.PluginId; - responseModel.SupportedVersions = model.SupportedVersions; - responseModel.Version = model.Version; - responseModel.DependPlugins = model.DependPlugins; - - if (pluginConfigModel.EnabledPlugins.Contains(model.PluginId) && !enablePluginIds.Contains(model.PluginId)) - { - // 错误情况: 配置 标识 已启用, 但实际没有启用成功 - pluginConfigModel.EnabledPlugins.Remove(model.PluginId); - PluginConfigModelFactory.Save(pluginConfigModel); - - responseModel.Status = PluginStatus.Disabled; - } - else if (!pluginConfigModel.EnabledPlugins.Contains(model.PluginId) && enablePluginIds.Contains(model.PluginId)) - { - // 错误情况: 配置没有标识 已启用, 但实际 已启用 - pluginConfigModel.EnabledPlugins.Add(model.PluginId); - PluginConfigModelFactory.Save(pluginConfigModel); - - responseModel.Status = PluginStatus.Enabled; - } - else if (pluginConfigModel.EnabledPlugins.Contains(model.PluginId) && enablePluginIds.Contains(model.PluginId)) - { - responseModel.Status = PluginStatus.Enabled; - } - else - { - responseModel.Status = PluginStatus.Disabled; - } - responseModels.Add(responseModel); - } - - #endregion 添加插件状态信息 - - return responseModels; - } - - public enum UploadFileType - { - NoAllowedType = 0, - Zip = 1, - Nupkg = 2 - } - - #endregion Helpers -} \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Controllers/UserController.cs b/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Controllers/UserController.cs deleted file mode 100644 index 70a8b09a..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Controllers/UserController.cs +++ /dev/null @@ -1,181 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -using Furion.DataEncryption; -using Microsoft.AspNetCore.Authorization; -using PluginCore.AspNetCore.RequestModel.User; -using PluginCore.AspNetCore.ResponseModel; -using PluginCore.Config; - - -namespace PluginCore.AspNetCore.Controllers; - -[Route("api/plugincore/admin/[controller]/[action]")] -[ApiController] -[NonUnify] -public class UserController : ControllerBase -{ - public string RemoteFronted - { - get - { - return PluginCore.Config.PluginCoreConfigFactory.Create().RemoteFrontend; - } - } - - private readonly UserManager _userManager; - private readonly SqlSugarRepository _sysUserRep; - private readonly SysOrgService _sysOrgService; - private readonly SysUserExtOrgService _sysUserExtOrgService; - private readonly SysUserRoleService _sysUserRoleService; - private readonly SysConfigService _sysConfigService; - - public UserController(UserManager userManager, - SqlSugarRepository sysUserRep, - SysOrgService sysOrgService, - SysUserExtOrgService sysUserExtOrgService, - SysUserRoleService sysUserRoleService, - SysConfigService sysConfigService) - { - _userManager = userManager; - _sysUserRep = sysUserRep; - _sysOrgService = sysOrgService; - _sysUserExtOrgService = sysUserExtOrgService; - _sysUserRoleService = sysUserRoleService; - _sysConfigService = sysConfigService; - } - - /// - /// 登录系统 - /// - /// - /// 用户名/密码:superadmin/123456 - /// - [AllowAnonymous] - [HttpGet, HttpPost] - [DisplayName("登录系统")] - public async Task> Login([FromBody] LoginRequestModel input) - { - BaseResponseModel responseModel = new BaseResponseModel(); - - // 账号是否存在 - var user = await _sysUserRep.AsQueryable().Includes(t => t.SysOrg).Filter(null, true).FirstAsync(u => u.Account.Equals(input.UserName)); - _ = user ?? throw Oops.Oh(ErrorCodeEnum.D0009); - - // 账号是否被冻结 - if (user.Status == StatusEnum.Disable) - throw Oops.Oh(ErrorCodeEnum.D1017); - - // 租户是否被禁用 - var tenant = await _sysUserRep.ChangeRepository>().GetFirstAsync(u => u.Id == user.TenantId); - if (tenant != null && tenant.Status == StatusEnum.Disable) - throw Oops.Oh(ErrorCodeEnum.Z1003); - - // 密码是否正确 - if (CryptogramUtil.CryptoType == CryptogramEnum.MD5.ToString()) - { - if (user.Password != MD5Encryption.Encrypt(input.Password)) - throw Oops.Oh(ErrorCodeEnum.D1000); - } - else - { - if (CryptogramUtil.Decrypt(user.Password) != input.Password) - throw Oops.Oh(ErrorCodeEnum.D1000); - } - - var tokenExpire = await _sysConfigService.GetTokenExpire(); - var refreshTokenExpire = await _sysConfigService.GetRefreshTokenExpire(); - - // 生成Token令牌 - var accessToken = JWTEncryption.Encrypt(new Dictionary - { - { ClaimConst.UserId, user.Id }, - { ClaimConst.TenantId, user.TenantId }, - { ClaimConst.Account, user.Account }, - { ClaimConst.RealName, user.RealName }, - { ClaimConst.AccountType, user.AccountType }, - { ClaimConst.OrgId, user.OrgId }, - { ClaimConst.OrgName, user.SysOrg?.Name }, - //{ ClaimConst.OrgType, user.SysOrg?.OrgType }, - }, tokenExpire); - - // 生成刷新Token令牌 - var refreshToken = JWTEncryption.GenerateRefreshToken(accessToken, refreshTokenExpire); - - responseModel.Code = 1; - responseModel.Message = "登录成功"; - responseModel.Data = new - { - token = accessToken, - userName = user.NickName, - RefreshToken = refreshToken - }; - return await Task.FromResult(responseModel); - } - - [HttpGet, HttpPost] - public async Task> Logout() - { - BaseResponseModel responseModel = new BaseResponseModel() - { - Code = 1, - Message = "退出登录成功" - }; - - return await Task.FromResult(responseModel); - } - - [HttpGet, HttpPost] - public async Task> Info() - { - BaseResponseModel responseModel = new BaseResponseModel(); - - try - { - string adminUserName = PluginCoreConfigFactory.Create().Admin.UserName; - - responseModel.Code = 1; - responseModel.Message = "成功"; - responseModel.Data = new - { - name = adminUserName, - //avatar = this.RemoteFronted + "/images/avatar.gif" - avatar = "" - }; - } - catch (Exception ex) - { - responseModel.Code = -1; - responseModel.Message = "失败: " + ex.Message; - } - - return await Task.FromResult(responseModel); - } - - [HttpGet, HttpPost] - public async Task> Update([FromBody] UpdateRequestModel requestModel) - { - BaseResponseModel responseModel = new BaseResponseModel(); - - try - { - PluginCoreConfig pluginCoreConfig = PluginCoreConfigFactory.Create(); - pluginCoreConfig.Admin.UserName = requestModel.UserName; - pluginCoreConfig.Admin.Password = requestModel.Password; - PluginCoreConfigFactory.Save(pluginCoreConfig); - - responseModel.Code = 1; - responseModel.Message = "修改成功, 需要重新登录"; - } - catch (Exception ex) - { - responseModel.Code = -1; - responseModel.Message = "失败: " + ex.Message; - } - - return await Task.FromResult(responseModel); - } -} \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Entity/SysPluginCore.cs b/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Entity/SysPluginCore.cs deleted file mode 100644 index 0a6eae2c..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Entity/SysPluginCore.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -namespace Admin.NET.Plugin.PluginCore; - -/// -/// 系统动态插件表 -/// -[SugarTable(null, "系统动态插件表")] -[SysTable] -public class SysPluginCore : EntityTenant -{ - /// - /// 插件ID - /// - [SugarColumn(ColumnDescription = "插件ID", Length = 128)] - [Required] - public virtual string PluginId { get; set; } - - /// - /// 名称 - /// - [SugarColumn(ColumnDescription = "名称", Length = 64)] - [Required, MaxLength(64)] - public virtual string DisplayName { get; set; } - - /// - /// 作者 - /// - [SugarColumn(ColumnDescription = "作者", Length = 64)] - [Required, MaxLength(64)] - public virtual string Author { get; set; } - - /// - /// 版本 - /// - [SugarColumn(ColumnDescription = "版本", Length = 64)] - [Required, MaxLength(64)] - public virtual string Version { get; set; } - - /// - /// 描述 - /// - [SugarColumn(ColumnDescription = "描述", Length = 512)] - [MaxLength(512)] - public string? Description { get; set; } - - /// - /// 排序 - /// - [SugarColumn(ColumnDescription = "排序")] - public int OrderNo { get; set; } = 100; - - /// - /// 状态 - /// - [SugarColumn(ColumnDescription = "状态")] - public StatusEnum Status { get; set; } = StatusEnum.Enable; - - /// - /// 备注 - /// - [SugarColumn(ColumnDescription = "备注", Length = 128)] - [MaxLength(128)] - public string? Remark { get; set; } -} \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/GlobalUsings.cs b/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/GlobalUsings.cs deleted file mode 100644 index 9b331497..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/GlobalUsings.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -global using Admin.NET.Core; -global using Admin.NET.Core.Service; -global using Furion; -global using Furion.DependencyInjection; -global using Furion.DynamicApiController; -global using Furion.FriendlyException; -global using Mapster; -global using Microsoft.AspNetCore.Http; -global using Microsoft.AspNetCore.Mvc; -global using Microsoft.Extensions.DependencyInjection; -global using Newtonsoft.Json; -global using SqlSugar; -global using System.ComponentModel; -global using System.ComponentModel.DataAnnotations; -global using System.Data; -global using System.Linq.Dynamic.Core; -global using System.Text; diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/SeedData/SysMenuSeedData.cs b/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/SeedData/SysMenuSeedData.cs deleted file mode 100644 index 3e755c45..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/SeedData/SysMenuSeedData.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -namespace Admin.NET.Plugin.PluginCore; - -/// -/// 系统菜单表种子数据 -/// -[IncreSeed] -public class SysMenu_PluginCore_SeedData : ISqlSugarEntitySeedData -{ - /// - /// 种子数据 - /// - /// - public IEnumerable HasData() - { - return - [ - new SysMenu{ Id=1310000000802, Pid=1310000000301, Title="应用插件", Path="/platform/pluginCore", Name="sysPluginCore", Component="/system/pluginCore/index", Icon="ele-Connection", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=210 }, - new SysMenu{ Id=1310000000803, Pid=1310000000802, Title="启用", Permission="sysPluginCore/enable", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 }, - new SysMenu{ Id=1310000000804, Pid=1310000000802, Title="卸载", Permission="sysPluginCore/delete", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=110 }, - new SysMenu{ Id=1310000000805, Pid=1310000000802, Title="禁用", Permission="sysPluginCore/disable", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=120 }, - new SysMenu{ Id=1310000000806, Pid=1310000000802, Title="详细", Permission="sysPluginCore/details", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=130 }, - new SysMenu{ Id=1310000000807, Pid=1310000000802, Title="文档", Permission="sysPluginCore/readme", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=140 }, - new SysMenu{ Id=1310000000808, Pid=1310000000802, Title="设置", Permission="sysPluginCore/setting", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=150 }, - ]; - } -} \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Service/Plugin/Dto/PluginCoreInput.cs b/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Service/Plugin/Dto/PluginCoreInput.cs deleted file mode 100644 index bd948bd8..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Service/Plugin/Dto/PluginCoreInput.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -namespace Admin.NET.Plugin.PluginCore; - -public class PagePluginCoreInput : BasePageInput -{ - /// - /// 名称 - /// - public string Name { get; set; } - - /// - /// 编码 - /// - public string Code { get; set; } -} - -public class AddPluginCoreInput : SysPluginCore -{ -} - -public class UpdatePluginCoreInput : AddPluginCoreInput -{ -} - -public class DeletePluginCoreInput : BaseIdInput -{ -} - -public class EnablePluginCoreInput : BaseIdInput -{ -} - -public class UpdatePluginCoreSettingInput : BaseIdInput -{ - public string Data { get; set; } -} \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Service/Plugin/SysPluginCoreService.cs b/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Service/Plugin/SysPluginCoreService.cs deleted file mode 100644 index 3c5e1814..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Service/Plugin/SysPluginCoreService.cs +++ /dev/null @@ -1,695 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -using PluginCore; -using PluginCore.AspNetCore.Interfaces; -using PluginCore.AspNetCore.ResponseModel; -using PluginCore.Infrastructure; -using PluginCore.Interfaces; -using PluginCore.IPlugins; -using PluginCore.Models; -using PluginCore.Utils; - -namespace Admin.NET.Plugin.PluginCore; - -/// -/// 系统动态插件服务 -/// -[ApiDescriptionSettings(Order = 245)] -public class SysPluginCoreService : IDynamicApiController, ITransient -{ - #region Fields - - private readonly IPluginManager _pluginManager; - private readonly IPluginFinder _pluginFinder; - private readonly IPluginApplicationBuilderManager _pluginApplicationBuilderManager; - - #endregion Fields - - private readonly IDynamicApiRuntimeChangeProvider _provider; - private readonly SqlSugarRepository _sysPluginRep; - - public SysPluginCoreService(IPluginManager pluginManager, IPluginFinder pluginFinder, IPluginApplicationBuilderManager pluginApplicationBuilderManager, IDynamicApiRuntimeChangeProvider provider, - SqlSugarRepository sysPluginRep) - { - _pluginManager = pluginManager; - _pluginFinder = pluginFinder; - _pluginApplicationBuilderManager = pluginApplicationBuilderManager; - _provider = provider; - _sysPluginRep = sysPluginRep; - } - - /// - /// 获取动态插件列表 - /// - /// - /// - [DisplayName("获取动态插件列表")] - public async Task> Page(PagePluginInput input) - { - return await _sysPluginRep.AsQueryable() - .WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.DisplayName.Contains(input.Name)) - .OrderBy(u => u.OrderNo) - .ToPagedListAsync(input.Page, input.PageSize); - } - - /// - /// 查看详细 - /// - /// - /// - [ApiDescriptionSettings(Name = "Details"), HttpGet] - [DisplayName("查看详细")] - public async Task Details(long id) - { - var pluginCore = await _sysPluginRep.GetByIdAsync(id); - if (pluginCore == null) throw Oops.Oh("查询插件ID失败"); ; - - // 先移除再添加动态程序集/接口 - - try - { - #region 效验 - - var pluginId = pluginCore.PluginId; - var pluginConfigModel = PluginConfigModelFactory.Create(); - string[] localPluginIds = PluginPathProvider.AllPluginFolderName().ToArray(); - - if (!localPluginIds.Contains(pluginId)) - { - throw Oops.Oh($"查看详细失败: 不存在 {pluginId} 插件"); - } - - #endregion 效验 - - PluginInfoModel pluginInfoModel = PluginInfoModelFactory.Create(pluginId); - string[] enablePluginIds = _pluginFinder.EnablePluginIds().ToArray(); - PluginInfoResponseModel pluginInfoResponseModel = PluginInfoModelToResponseModel(new List() { pluginInfoModel }, pluginConfigModel, enablePluginIds).FirstOrDefault(); - - return pluginInfoResponseModel; - } - catch (Exception ex) - { - throw Oops.Oh("查看详细失败: " + ex.Message); - } - } - - #region 查看文档 - - /// - /// 查看文档 - /// - /// - /// - [ApiDescriptionSettings(Name = "Readme"), HttpGet] - [DisplayName("查看文档")] - public async Task Readme(long id) - { - var pluginCore = await _sysPluginRep.GetByIdAsync(id); - if (pluginCore == null) throw Oops.Oh("查询插件ID失败"); ; - - try - { - #region 效验 - - var pluginId = pluginCore.PluginId; - var pluginConfigModel = PluginConfigModelFactory.Create(); - string[] localPluginIds = PluginPathProvider.AllPluginFolderName().ToArray(); - - if (!localPluginIds.Contains(pluginId)) - { - throw Oops.Oh($"查看详细失败: 不存在 {pluginId} 插件"); - } - - #endregion 效验 - - PluginReadmeModel readmeModel = PluginReadmeModelFactory.Create(pluginId); - PluginReadmeResponseModel readmeResponseModel = new PluginReadmeResponseModel(); - readmeResponseModel.Content = readmeModel?.Content ?? ""; - readmeResponseModel.PluginId = pluginId; - - return readmeResponseModel; - } - catch (Exception ex) - { - throw Oops.Oh("查看详细失败: " + ex.Message); - } - } - - #endregion 查看文档 - - /// - /// 卸载动态插件 - /// - /// - /// - [ApiDescriptionSettings(Name = "Uninstall"), HttpPost] - [DisplayName("卸载动态插件")] - public async Task Uninstall(DeletePluginCoreInput input) - { - var pluginCore = await _sysPluginRep.GetByIdAsync(input.Id); - if (pluginCore == null) throw Oops.Oh("查询插件ID失败"); - - // 卸载插件 必须 先禁用插件 - - #region 效验 - - var pluginId = pluginCore.PluginId; - var pluginConfigModel = PluginConfigModelFactory.Create(); - if (pluginConfigModel.EnabledPlugins.Contains(pluginId)) - { - throw Oops.Oh("卸载失败: 请先禁用此插件"); - } - string pluginDirStr = Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId); - string pluginWwwrootDirStr = Path.Combine(PluginPathProvider.PluginsWwwRootDir(), pluginId); - if (!Directory.Exists(pluginDirStr) && !Directory.Exists(pluginWwwrootDirStr)) - { - throw Oops.Oh("卸载失败: 此插件不存在"); - } - - #endregion 效验 - - try - { - // PS:卸载插件必须先禁用插件,所以此时插件LoadContext已被移除释放(插件Assemblies已被释放), 此处不需移除LoadContext - - // 1.删除物理文件 - var pluginDir = new DirectoryInfo(pluginDirStr); - if (pluginDir.Exists) - { - pluginDir.Delete(true); - } - // 虽然 已禁用 时 pluginWwwrootDirStr/pluginId 已删除, 但为确保, 还是再删除一次 - var pluginWwwrootDir = new DirectoryInfo(pluginWwwrootDirStr); - if (pluginWwwrootDir.Exists) - { - pluginWwwrootDir.Delete(true); - } - - await _sysPluginRep.DeleteAsync(u => u.Id == input.Id); - } - catch (Exception ex) - { - throw Oops.Oh("卸载失败: " + ex.Message); - } - } - - #region 设置 - - /// - /// 插件设置设置 - /// - /// - /// - [ApiDescriptionSettings(Name = "Settings"), HttpGet] - [DisplayName("插件设置设置")] - public async Task Settings(long id) - { - var pluginCore = await _sysPluginRep.GetByIdAsync(id); - if (pluginCore == null) throw Oops.Oh("查询插件ID失败"); ; - - try - { - #region 效验 - - var pluginId = pluginCore.PluginId; - var pluginConfigModel = PluginConfigModelFactory.Create(); - string[] localPluginIds = PluginPathProvider.AllPluginFolderName().ToArray(); - - if (!localPluginIds.Contains(pluginId)) - { - throw Oops.Oh($"查看详细失败: 不存在 {pluginId} 插件"); - } - - #endregion 效验 - - string settingsJsonStr = PluginSettingsModelFactory.Create(pluginId); - - return settingsJsonStr ?? "无设置项"; - } - catch (Exception ex) - { - throw Oops.Oh("查看设置失败: " + ex.Message); - } - } - - /// - /// 插件设置设置 - /// - /// - /// - [ApiDescriptionSettings(Name = "Settings"), HttpPost] - [DisplayName("插件设置设置")] - public async Task Settings(UpdatePluginCoreSettingInput input) - { - var pluginCore = await _sysPluginRep.GetByIdAsync(input.Id); - if (pluginCore == null) throw Oops.Oh("查询插件ID失败"); ; - - try - { - #region 效验 - - var pluginId = pluginCore.PluginId; - var pluginConfigModel = PluginConfigModelFactory.Create(); - string[] localPluginIds = PluginPathProvider.AllPluginFolderName().ToArray(); - - if (!localPluginIds.Contains(pluginId)) - { - throw Oops.Oh($"查看详细失败: 不存在 {pluginId} 插件"); - } - - #endregion 效验 - - input.Data = input.Data ?? ""; - PluginSettingsModelFactory.Save(pluginSettingsJsonStr: input.Data, pluginId: pluginCore.PluginId); - } - catch (Exception ex) - { - throw Oops.Oh("设置失败: " + ex.Message); - } - } - - #endregion 设置 - - /// - /// 启用插件 - /// - /// - /// - [ApiDescriptionSettings(Name = "Enable"), HttpPost] - [DisplayName("启用插件")] - public async Task Enable(EnablePluginCoreInput input) - { - var pluginCore = await _sysPluginRep.GetByIdAsync(input.Id); - if (pluginCore == null) return; - - // 移除动态程序集/接口 - var pluginConfigModel = PluginConfigModelFactory.Create(); - // 效验是否存在于 已禁用插件列表 - - #region 效验 - - var pluginId = pluginCore.PluginId; - var pluginDir = new DirectoryInfo(Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId)); - if (pluginDir != null && !pluginDir.Exists) - { - throw Oops.Oh("启用失败: 此插件不存在"); - } - string[] enablePluginIds = _pluginFinder.EnablePluginIds().ToArray(); - if (enablePluginIds.Contains(pluginId)) - { - throw Oops.Oh("启用失败: 此插件已启用"); - } - - #endregion 效验 - - try - { - // 1. 创建插件程序集加载上下文, 添加到 PluginsLoadContexts - _pluginManager.LoadPlugin(pluginId); - // 2. 添加到 pluginConfigModel.EnabledPlugins - pluginConfigModel.EnabledPlugins.Add(pluginId); - // 4.保存到 plugin.config.json - PluginConfigModelFactory.Save(pluginConfigModel); - - // 5. 找到此插件实例 - IPlugin plugin = _pluginFinder.Plugin(pluginId); - if (plugin == null) - { - // 7.启用不成功, 回滚插件状态: (1)释放插件上下文 (2)更新 plugin.config.json - try - { - _pluginManager.UnloadPlugin(pluginId); - } - catch (Exception ex) - { } - - // 从 pluginConfigModel.EnabledPlugins 移除 - pluginConfigModel.EnabledPlugins.Remove(pluginId); - // 保存到 plugin.config.json - PluginConfigModelFactory.Save(pluginConfigModel); - - throw Oops.Oh("启用失败: 此插件不存在"); - } - // 6.调取插件的 AfterEnable(), 插件开发者可在此回收资源 - var pluginEnableResult = plugin.AfterEnable(); - if (!pluginEnableResult.IsSuccess) - { - // 7.启用不成功, 回滚插件状态: (1)释放插件上下文 (2)更新 plugin.config.json - try - { - _pluginManager.UnloadPlugin(pluginId); - } - catch (Exception ex) - { } - - // 从 pluginConfigModel.EnabledPlugins 移除 - pluginConfigModel.EnabledPlugins.Remove(pluginId); - // 保存到 plugin.config.json - PluginConfigModelFactory.Save(pluginConfigModel); - throw Oops.Oh("启用失败: 来自插件的错误信息: " + pluginEnableResult.Message); - } - - // 7. ReBuild - this._pluginApplicationBuilderManager.ReBuild(); - - // 8. 尝试复制 插件下的 wwwroot 到 Plugins_wwwroot - string wwwRootDir = PluginPathProvider.WwwRootDir(pluginId); - if (Directory.Exists(wwwRootDir)) - { - string targetDir = PluginPathProvider.PluginWwwRootDir(pluginId); - FileUtil.CopyFolder(wwwRootDir, targetDir); - } - - //9.载入Furion动态插件 - var pluginMainAssembly = _pluginManager.GetPluginAssembly(pluginId); - // 将程序集添加进动态 WebAPI 应用部件 - _provider.AddAssembliesWithNotifyChanges(pluginMainAssembly); - - await _sysPluginRep.UpdateAsync(u => new SysPluginCore() { Status = StatusEnum.Enable }, u => u.Id == input.Id); - } - catch (Exception ex) - { - throw Oops.Oh("启用失败: " + ex.Message); - } - } - - /// - /// 禁用插件 - /// - /// - /// - [ApiDescriptionSettings(Name = "Disable"), HttpPost] - [DisplayName("禁用插件")] - public async Task Disable(EnablePluginCoreInput input) - { - var pluginCore = await _sysPluginRep.GetByIdAsync(input.Id); - if (pluginCore == null) return; - - // 移除动态程序集/ - - #region 效验 - - var pluginId = pluginCore.PluginId; - var pluginConfigModel = PluginConfigModelFactory.Create(); - // string[] enablePluginIds = _pluginFinder.EnablePluginIds().ToArray(); - // // 效验是否存在于 已启用插件列表 - // if (!enablePluginIds.Contains(pluginId)) - // { - // responseData.Code = -1; - // responseData.Message = "禁用失败: 此插件不存在, 或未启用"; - // return await Task.FromResult(responseData); - // } - - #endregion 效验 - - try - { - // 1. 找到此插件实例 - IPlugin plugin = _pluginFinder.Plugin(pluginId); - if (plugin == null) - { - throw Oops.Oh("禁用失败: 此插件不存在, 或未启用"); - } - try - { - // 2.调取插件的 BeforeDisable(), 插件开发者可在此回收资源 - var pluginDisableResult = plugin.BeforeDisable(); - if (!pluginDisableResult.IsSuccess) - { - throw Oops.Oh("禁用失败: 来自插件的错误信息: " + pluginDisableResult.Message); - } - // 3.移除插件对应的程序集加载上下文 - _pluginManager.UnloadPlugin(pluginId); - // 3.1. ReBuild - this._pluginApplicationBuilderManager.ReBuild(); - if (pluginConfigModel.EnabledPlugins.Contains(pluginId)) - { - // 4.从 pluginConfigModel.EnabledPlugins 移除 - pluginConfigModel.EnabledPlugins.Remove(pluginId); - // 5.保存到 plugin.config.json - PluginConfigModelFactory.Save(pluginConfigModel); - } - } - catch (Exception ex) - { - LogUtil.Error(ex.ToString()); - throw Oops.Oh("禁用失败: 此插件不存在, 或未启用"); - } - - // 7. 尝试移除 Plugins_wwwroot/PluginId - string pluginWwwRootDir = PluginPathProvider.PluginWwwRootDir(pluginId); - if (Directory.Exists(pluginWwwRootDir)) - { - Directory.Delete(pluginWwwRootDir, true); - } - //8.移除Furion动态插件 - - //9.载入Furion动态插件 - var pluginMainAssembly = _pluginManager.GetPluginAssembly(pluginId); - // 将程序集添加进动态 WebAPI 应用部件 - _provider.RemoveAssembliesWithNotifyChanges(pluginMainAssembly); - - await _sysPluginRep.UpdateAsync(u => new SysPluginCore() { Status = StatusEnum.Disable }, u => u.Id == input.Id); - } - catch (Exception ex) - { - throw Oops.Oh("禁用失败: " + ex.Message); - } - } - - /// - /// 上传文件 - /// - /// - /// - /// - [DisplayName("上传文件")] - public async Task UploadFile([Required] IFormFile file, [FromQuery] string? path) - { - var sysFile = await HandleUploadFile(file, path); - //return new FileOutput - //{ - //}; - } - - /// - /// 上传文件 - /// - /// 文件 - /// 路径 - /// - [NonAction] - private async Task HandleUploadFile(IFormFile file, string savePath) - { - if (file == null) throw Oops.Oh(ErrorCodeEnum.D8000); - - var path = savePath; - - BaseResponseModel responseData = new BaseResponseModel(); - - #region 效验 - - if (file == null) - { - throw Oops.Oh("上传的文件不能为空"); - //responseData.Code = -1; - //responseData.Message = "上传的文件不能为空"; - //return responseData; - } - //文件后缀 - string fileExtension = Path.GetExtension(file.FileName);//获取文件格式,拓展名 - // 类型标记 - UploadFileType uploadFileType = UploadFileType.NoAllowedType; - switch (fileExtension) - { - case ".zip": - uploadFileType = UploadFileType.Zip; - break; - - case ".nupkg": - uploadFileType = UploadFileType.Nupkg; - break; - } - - if (fileExtension != ".zip" && fileExtension != ".nupkg") - { - throw Oops.Oh("只能上传 zip 或 nupkg 格式文件"); - //responseData.Code = -1; - //// nupkg 其实就是 zip - //responseData.Message = "只能上传 zip 或 nupkg 格式文件"; - //return responseData; - } - // PluginCore.AspNetCore-v1.0.2 起 不再限制插件上传大小 - //判断文件大小 - //var fileSize = file.Length; - //if (fileSize > 1024 * 1024 * 5) // 5M - //{ - // responseData.Code = -1; - // responseData.Message = "上传的文件不能大于5MB"; - // return responseData; - //} - - #endregion 效验 - - try - { - // 1.先上传到 临时插件上传目录, 用Guid.zip作为保存文件名 - string tempZipFilePath = Path.Combine(PluginPathProvider.TempPluginUploadDir(), Guid.NewGuid() + ".zip"); - using (var fs = System.IO.File.Create(tempZipFilePath)) - { - file.CopyTo(fs); //将上传的文件文件流,复制到fs中 - fs.Flush();//清空文件流 - } - // 2.解压 - bool isDecomparessSuccess = false; - if (uploadFileType == UploadFileType.Zip) - { - isDecomparessSuccess = ZipHelper.DecomparessFile(tempZipFilePath, tempZipFilePath.Replace(".zip", "")); - } - else if (uploadFileType == UploadFileType.Nupkg) - { - isDecomparessSuccess = NupkgService.DecomparessFile(tempZipFilePath, tempZipFilePath.Replace(".zip", "")); - } - - // 3.删除原压缩包 - System.IO.File.Delete(tempZipFilePath); - if (!isDecomparessSuccess) - { - throw Oops.Oh("解压插件压缩包失败"); - - //responseData.Code = -1; - //responseData.Message = "解压插件压缩包失败"; - //return responseData; - } - // 4.读取其中的info.json, 获取 PluginId 值 - PluginInfoModel pluginInfoModel = PluginInfoModelFactory.ReadPluginDir(tempZipFilePath.Replace(".zip", "")); - if (pluginInfoModel == null || string.IsNullOrEmpty(pluginInfoModel.PluginId)) - { - // 记得删除已不再需要的临时插件文件夹 - Directory.Delete(tempZipFilePath.Replace(".zip", ""), true); - throw Oops.Oh("不合法的插件"); - - //responseData.Code = -1; - //responseData.Message = "不合法的插件"; - //return responseData; - } - string pluginId = pluginInfoModel.PluginId; - // 5.检索 此 PluginId 是否本地插件已存在 - var pluginConfigModel = PluginConfigModelFactory.Create(); - // 本地已经存在的 PluginId - IList localExistPluginIds = PluginPathProvider.AllPluginFolderName(); - if (localExistPluginIds.Contains(pluginId)) - { - // 记得删除已不再需要的临时插件文件夹 - Directory.Delete(tempZipFilePath.Replace(".zip", ""), true); - throw Oops.Oh($"本地已有此插件 (PluginId: {pluginId}), 请前往插件列表删除后, 再上传"); - - //responseData.Code = -1; - //responseData.Message = $"本地已有此插件 (PluginId: {pluginId}), 请前往插件列表删除后, 再上传"; - //return responseData; - } - // 6.本地无此插件 -> 移动插件文件夹到 Plugins 下, 并以 PluginId 为插件文件夹名 - string pluginsRootPath = PluginPathProvider.PluginsRootPath(); - string newPluginDir = Path.Combine(pluginsRootPath, pluginId); - Directory.Move(tempZipFilePath.Replace(".zip", ""), newPluginDir); - - // 7. 放入 Plugins 中, 默认为 已禁用 - - var pluginCore = new SysPluginCore(); - pluginCore.PluginId = pluginId; - pluginCore.DisplayName = pluginInfoModel.DisplayName; - pluginCore.Description = pluginInfoModel.Description; - pluginCore.Author = pluginInfoModel.Author; - pluginCore.Version = pluginInfoModel.Version; - pluginCore.Status = StatusEnum.Disable; - await _sysPluginRep.InsertAsync(pluginCore.Adapt()); - - responseData.Code = 1; - responseData.Message = $"上传插件成功 (PluginId: {pluginId})"; - } - catch (Exception ex) - { - throw Oops.Oh("上传插件失败: " + ex.Message); - - //responseData.Code = -1; - //responseData.Message = "上传插件失败: " + ex.Message; - //ex = ex.InnerException; - //while (ex != null) - //{ - // responseData.Message += " - " + ex.InnerException.Message; - // ex = ex.InnerException; - //} - } - - return responseData; - } - - #region Helpers - - [NonAction] - private IList PluginInfoModelToResponseModel(IList pluginInfoModels, PluginConfigModel pluginConfigModel, string[] enablePluginIds) - { - // 获取 Plugins 下所有插件 - // DirectoryInfo pluginsDir = new DirectoryInfo(PluginPathProvider.PluginsRootPath()); - // List pluginIds = pluginsDir?.GetDirectories()?.Select(m => m.Name)?.ToList() ?? new List(); - - IList responseModels = new List(); - - #region 添加插件状态信息 - - foreach (var model in pluginInfoModels) - { - PluginInfoResponseModel responseModel = new PluginInfoResponseModel(); - responseModel.Author = model.Author; - responseModel.Description = model.Description; - responseModel.DisplayName = model.DisplayName; - responseModel.PluginId = model.PluginId; - responseModel.SupportedVersions = model.SupportedVersions; - responseModel.Version = model.Version; - responseModel.DependPlugins = model.DependPlugins; - - if (pluginConfigModel.EnabledPlugins.Contains(model.PluginId) && !enablePluginIds.Contains(model.PluginId)) - { - // 错误情况: 配置 标识 已启用, 但实际没有启用成功 - pluginConfigModel.EnabledPlugins.Remove(model.PluginId); - PluginConfigModelFactory.Save(pluginConfigModel); - - responseModel.Status = PluginStatus.Disabled; - } - else if (!pluginConfigModel.EnabledPlugins.Contains(model.PluginId) && enablePluginIds.Contains(model.PluginId)) - { - // 错误情况: 配置没有标识 已启用, 但实际 已启用 - pluginConfigModel.EnabledPlugins.Add(model.PluginId); - PluginConfigModelFactory.Save(pluginConfigModel); - - responseModel.Status = PluginStatus.Enabled; - } - else if (pluginConfigModel.EnabledPlugins.Contains(model.PluginId) && enablePluginIds.Contains(model.PluginId)) - { - responseModel.Status = PluginStatus.Enabled; - } - else - { - responseModel.Status = PluginStatus.Disabled; - } - responseModels.Add(responseModel); - } - - #endregion 添加插件状态信息 - - return responseModels; - } - - public enum UploadFileType - { - NoAllowedType = 0, - Zip = 1, - Nupkg = 2 - } - - #endregion Helpers -} \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Startup.cs b/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Startup.cs deleted file mode 100644 index 3f087971..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/Startup.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; - -namespace Admin.NET.Plugin.PluginCore; - -[AppStartup(100)] -public class Startup : AppStartup -{ - public void ConfigureServices(IServiceCollection services) - { - RunOptions.Default - .AddComponent() - .UseComponent(); - } - - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - } -} \ No newline at end of file diff --git a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/StartupServiceComponent.cs b/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/StartupServiceComponent.cs deleted file mode 100644 index 9076e720..00000000 --- a/Admin.NET/Plugins/Admin.NET.Plugin.PluginCore/StartupServiceComponent.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using PluginCore; -using PluginCore.AspNetCore.Extensions; -using PluginCore.Interfaces; -using PluginCore.Models; - -namespace Admin.NET.Plugin.PluginCore; - -// 模拟 ConfigureService -public sealed class StartupServiceComponent : IServiceComponent -{ - public void Load(IServiceCollection services, ComponentContext componentContext) - { - // 1. 添加 PluginCore - services.AddPluginCore(); - IPluginManager pluginManager = App.GetService(); - IDynamicApiRuntimeChangeProvider provider = App.GetService(); - - #region 获取 PluginConfigModel - - PluginConfigModel pluginConfigModel = PluginConfigModelFactory.Create(); - - #endregion 获取 PluginConfigModel - - // 已启用的插件 - - #region 加载 已启用插件的Assemblies - - IList enabledPluginIds = pluginConfigModel.EnabledPlugins; - foreach (var pluginId in enabledPluginIds) - { - //9.载入Furion动态插件 - var pluginMainAssembly = pluginManager.GetPluginAssembly(pluginId); - // 将程序集添加进动态 WebAPI 应用部件 - provider.AddAssembliesWithNotifyChanges(pluginMainAssembly); - } - - #endregion 加载 已启用插件的Assemblies - } -} - -// 模拟 Configure -public sealed class StartupApplicationComponent : IApplicationComponent -{ - public void Load(IApplicationBuilder app, IWebHostEnvironment env, ComponentContext componentContext) - { - // 2. 使用 PluginCore - app.UsePluginCore(); - } -} \ No newline at end of file diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/AdminUI/PluginCoreAdminUIBuilderExtensions.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/AdminUI/PluginCoreAdminUIBuilderExtensions.cs deleted file mode 100644 index 5e68b54d..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/AdminUI/PluginCoreAdminUIBuilderExtensions.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.FileProviders; -using Microsoft.Extensions.Options; - -namespace PluginCore.AspNetCore.AdminUI -{ - public static class PluginCoreAdminUIBuilderExtensions - { - - /// - /// Register the SwaggerUI middleware with provided options - /// - public static IApplicationBuilder UsePluginCoreAdminUI(this IApplicationBuilder app, PluginCoreAdminUIOptions options) - { - #region Old - 区分 - //Config.PluginCoreConfig pluginCoreConfig = Config.PluginCoreConfigFactory.Create(); - - //switch (pluginCoreConfig.FrontendMode?.ToLower()) - //{ - // case "localembedded": - // app.UseMiddleware(options); - // break; - // case "localfolder": - - // #region LocalFolder - // //string contentRootPath = Directory.GetCurrentDirectory(); - - // // https://docs.microsoft.com/zh-CN/aspnet/core/fundamentals/static-files?view=aspnetcore-5.0 - // //var options = new DefaultFilesOptions() - // //{ - // // RequestPath = "/PluginCore/Admin", - // //}; - // //// TODO: 404: 无效, 失败, 改为使用 Controller 手动指定 - // ////options.DefaultFileNames.Add("PluginCoreAdmin/index.html"); - // //app.UseDefaultFiles(options); - - // // 注意: 为了无需重启Web,而更新是否本地前端配置, 因此此项保持常驻开启 - // // 因此, 需要保证 PluginCoreAdmin 文件夹存在 - // string pluginCoreAdminDir = PluginPathProvider.PluginCoreAdminDir(); - // app.UseStaticFiles(new StaticFileOptions - // { - // FileProvider = new PhysicalFileProvider( - // pluginCoreAdminDir), - // RequestPath = "/PluginCore/Admin" - // }); - // #endregion - - // break; - // case "remotecdn": - - // break; - // default: - // app.UseMiddleware(options); - // break; - //} - - //return app; - #endregion - - - return app.UseMiddleware(options); - } - - /// - /// Register the SwaggerUI middleware with optional setup action for DI-injected options - /// - public static IApplicationBuilder UsePluginCoreAdminUI( - this IApplicationBuilder app) - { - PluginCoreAdminUIOptions options = new PluginCoreAdminUIOptions() - { - - }; - - return app.UsePluginCoreAdminUI(options); - } - - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/AdminUI/PluginCoreAdminUIMiddleware.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/AdminUI/PluginCoreAdminUIMiddleware.cs deleted file mode 100644 index b1a57525..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/AdminUI/PluginCoreAdminUIMiddleware.cs +++ /dev/null @@ -1,149 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.StaticFiles; -using Microsoft.Extensions.FileProviders; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace PluginCore.AspNetCore.AdminUI -{ - public class PluginCoreAdminUIMiddleware - { - private const string EmbeddedFileNamespace = "PluginCore.AspNetCore.node_modules.plugincore_admin_frontend.dist"; - - private readonly PluginCoreAdminUIOptions _options; - private readonly StaticFileMiddleware _staticFileMiddleware; - - - public PluginCoreAdminUIMiddleware( - RequestDelegate next, - IWebHostEnvironment hostingEnv, - ILoggerFactory loggerFactory, - PluginCoreAdminUIOptions options) - { - _options = options ?? new PluginCoreAdminUIOptions(); - - _staticFileMiddleware = CreateStaticFileMiddleware(next, hostingEnv, loggerFactory, options); - } - - public async Task Invoke(HttpContext httpContext) - { - var httpMethod = httpContext.Request.Method; - var path = httpContext.Request.Path.Value; - - // If the RoutePrefix is requested (with or without trailing slash), redirect to index URL - if (httpMethod == "GET" && Regex.IsMatch(path, $"^/?{Regex.Escape(_options.RoutePrefix)}/?$", RegexOptions.IgnoreCase)) - { - // Use relative redirect to support proxy environments - var relativeIndexUrl = string.IsNullOrEmpty(path) || path.EndsWith("/") - ? "index.html" - : $"{path.Split('/').Last()}/index.html"; - - RespondWithRedirect(httpContext.Response, relativeIndexUrl); - return; - } - - if (httpMethod == "GET" && Regex.IsMatch(path, $"^/{Regex.Escape(_options.RoutePrefix)}/?index.html$", RegexOptions.IgnoreCase)) - { - await RespondWithIndexHtml(httpContext.Response); - return; - } - - await _staticFileMiddleware.Invoke(httpContext); - } - - private StaticFileMiddleware CreateStaticFileMiddleware( - RequestDelegate next, - IWebHostEnvironment hostingEnv, - ILoggerFactory loggerFactory, - PluginCoreAdminUIOptions options) - { - Config.PluginCoreConfig pluginCoreConfig = Config.PluginCoreConfigFactory.Create(); - IFileProvider fileProvider = null; - switch (pluginCoreConfig.FrontendMode?.ToLower()) - { - case "localembedded": - fileProvider = new EmbeddedFileProvider(typeof(PluginCoreAdminUIMiddleware).GetTypeInfo().Assembly, - EmbeddedFileNamespace); - break; - case "localfolder": - string absoluteRootPath = PluginPathProvider.PluginCoreAdminDir(); - fileProvider = new PhysicalFileProvider(absoluteRootPath); - break; - case "remotecdn": - fileProvider = new PluginCoreAdminUIRemoteFileProvider(pluginCoreConfig.RemoteFrontend); - break; - default: - fileProvider = new EmbeddedFileProvider(typeof(PluginCoreAdminUIMiddleware).GetTypeInfo().Assembly, - EmbeddedFileNamespace); - break; - } - - var staticFileOptions = new StaticFileOptions - { - RequestPath = string.IsNullOrEmpty(options.RoutePrefix) ? string.Empty : $"/{options.RoutePrefix}", - FileProvider = fileProvider, - }; - - return new StaticFileMiddleware(next, hostingEnv, Options.Create(staticFileOptions), loggerFactory); - } - - private void RespondWithRedirect(HttpResponse response, string location) - { - response.StatusCode = 301; - response.Headers["Location"] = location; - } - - private async Task RespondWithIndexHtml(HttpResponse response) - { - response.StatusCode = 200; - response.ContentType = "text/html;charset=utf-8"; - - using (var stream = _options.IndexStream()) - { - // Inject arguments before writing to response - var htmlBuilder = new StringBuilder(new StreamReader(stream).ReadToEnd()); - foreach (var entry in GetIndexArguments()) - { - htmlBuilder.Replace(entry.Key, entry.Value); - } - - await response.WriteAsync(htmlBuilder.ToString(), Encoding.UTF8); - } - } - - private IDictionary GetIndexArguments() - { - return new Dictionary() - { - //{ "%(DocumentTitle)", _options.DocumentTitle }, - //{ "%(HeadContent)", _options.HeadContent }, - //{ "%(ConfigObject)", JsonSerializer.Serialize(_options.ConfigObject, _jsonSerializerOptions) }, - //{ "%(OAuthConfigObject)", JsonSerializer.Serialize(_options.OAuthConfigObject, _jsonSerializerOptions) }, - //{ "%(Interceptors)", JsonSerializer.Serialize(_options.Interceptors) }, - }; - } - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/AdminUI/PluginCoreAdminUIOptions.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/AdminUI/PluginCoreAdminUIOptions.cs deleted file mode 100644 index 2e175191..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/AdminUI/PluginCoreAdminUIOptions.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Net.Http; -using System.Reflection; -using System.Text; - -namespace PluginCore.AspNetCore.AdminUI -{ - public class PluginCoreAdminUIOptions - { - /// - /// Gets or sets a route prefix for accessing the swagger-ui - /// - public string RoutePrefix { get; set; } = "PluginCore/Admin"; - - /// - /// Gets or sets a Stream function for retrieving the swagger-ui page - /// - public Func IndexStream - { - get - { - Func funcStream = null; - ; - Config.PluginCoreConfig pluginCoreConfig = Config.PluginCoreConfigFactory.Create(); - switch (pluginCoreConfig.FrontendMode?.ToLower()) - { - case "localembedded": - funcStream = () => typeof(PluginCoreAdminUIOptions).GetTypeInfo().Assembly - .GetManifestResourceStream("PluginCore.AspNetCore.node_modules.plugincore_admin_frontend.dist.index.html"); - break; - case "localfolder": - string absoluteRootPath = PluginPathProvider.PluginCoreAdminDir(); - string indexFilePath = Path.Combine(absoluteRootPath, "index.html"); - - funcStream = () => (Stream)new FileStream(indexFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 1, FileOptions.Asynchronous | FileOptions.SequentialScan); - break; - case "remotecdn": - string remoteFrontendRootPath = pluginCoreConfig.RemoteFrontend; - string indexFileRemotePath = remoteFrontendRootPath + "/" + "index.html"; - - funcStream = () => new HttpClient().GetStreamAsync(indexFileRemotePath).Result; - break; - default: - funcStream = () => typeof(PluginCoreAdminUIOptions).GetTypeInfo().Assembly - .GetManifestResourceStream("PluginCore.AspNetCore.node_modules.plugincore_admin_frontend.dist.index.html"); - break; - } - - return funcStream; - } - } - - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/AdminUI/PluginCoreAdminUIRemoteFileProvider.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/AdminUI/PluginCoreAdminUIRemoteFileProvider.cs deleted file mode 100644 index 32e87e10..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/AdminUI/PluginCoreAdminUIRemoteFileProvider.cs +++ /dev/null @@ -1,131 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Net.Http; -using System.Text; -using Microsoft.Extensions.FileProviders; -using Microsoft.Extensions.Primitives; - -namespace PluginCore.AspNetCore.AdminUI -{ - public class PluginCoreAdminUIRemoteFileProvider : IFileProvider - { - protected string RootUrl { get; set; } - - public PluginCoreAdminUIRemoteFileProvider(string rootUrl) - { - this.RootUrl = rootUrl; - } - - public IDirectoryContents GetDirectoryContents(string subpath) - { - return (IDirectoryContents)NotFoundDirectoryContents.Singleton; - } - - public IFileInfo GetFileInfo(string subpath) - { - if (string.IsNullOrEmpty(subpath)) - return (IFileInfo)new NotFoundFileInfo(subpath); - - IFileInfo fileInfo = new PluginCoreAdminUIFileInfo(this.RootUrl, subpath); - - return fileInfo; - } - - public IChangeToken Watch(string filter) - { - throw new NotImplementedException(); - } - - - public class PluginCoreAdminUIFileInfo : IFileInfo - { - protected string RootUrl { get; set; } - - protected string SubPath { get; set; } - - private string _name; - - public PluginCoreAdminUIFileInfo(string rootUrl, string subpath) - { - this.RootUrl = rootUrl; - this.SubPath = subpath; - this._name = this.SubPath.Substring(this.SubPath.LastIndexOf("/") + 1); - } - - public Stream CreateReadStream() - { - HttpClient httpClient = new HttpClient(); - - return httpClient.GetStreamAsync($"{this.RootUrl}/{this.SubPath}").Result; - } - - public bool Exists - { - get - { - bool isExist = false; - if (this.Name == "index.html") - { - isExist = true; - } - - return isExist; - } - } - public bool IsDirectory - { - get - { - return false; - } - } - - public DateTimeOffset LastModified - { - get - { - return new DateTimeOffset(DateTime.Now); - } - } - - public long Length - { - get - { - return 111; - } - } - - public string Name - { - get - { - return this._name; - } - } - - public string PhysicalPath - { - get - { - return ""; - } - } - } - - } - - - -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authentication/PluginCoreAuthenticationHandler.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authentication/PluginCoreAuthenticationHandler.cs deleted file mode 100644 index 58f6ea2c..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authentication/PluginCoreAuthenticationHandler.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Security.Claims; -using System.Text; -using System.Text.Encodings.Web; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authentication; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using PluginCore.AspNetCore.Authorization; - -namespace PluginCore.AspNetCore.Authentication -{ - /// - /// https://stackoverflow.com/questions/52287542/invalidoperationexception-no-authenticationscheme-was-specified-and-there-was - /// - public class PluginCoreAuthenticationHandler : AuthenticationHandler - { - private readonly AccountManager _accountManager; - - public PluginCoreAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, AccountManager accountManager) : base(options, logger, encoder, clock) - { - this._accountManager = accountManager; - } - - protected override async Task HandleAuthenticateAsync() - { - string token = this._accountManager.CurrentToken(); - if (string.IsNullOrEmpty(token)) - { - return AuthenticateResult.NoResult(); - } - - bool isAdmin = AccountManager.IsAdminToken(token); - - if (!isAdmin) - { - return AuthenticateResult.Fail($"token is not admin"); - } - else - { - var id = new ClaimsIdentity( - // new Claim[] { new Claim("PluginCore.Token", token) }, // not safe , just as an example , should custom claims on your own - claims: new Claim[] { new Claim(type: IPlugins.Constants.AspNetCoreAuthenticationClaimType, value: token) }, // not safe , just as an example , should custom claims on your own - authenticationType: Scheme.Name - ); - ClaimsPrincipal principal = new ClaimsPrincipal(identity: id); - var ticket = new AuthenticationTicket( - principal: principal, - properties: new AuthenticationProperties(), - authenticationScheme: Scheme.Name); - - // Utils.LogUtil.Info($"通过 Authentication: token: {token}"); - Utils.LogUtil.Info($"Authentication Passed"); - - return AuthenticateResult.Success(ticket); - } - - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authentication/PluginCoreAuthenticationSchemeOptions.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authentication/PluginCoreAuthenticationSchemeOptions.cs deleted file mode 100644 index 4cf4de2f..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authentication/PluginCoreAuthenticationSchemeOptions.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.AspNetCore.Authentication; - -namespace PluginCore.AspNetCore.Authentication -{ - public class PluginCoreAuthenticationSchemeOptions : AuthenticationSchemeOptions - { - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authorization/AccountManager.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authorization/AccountManager.cs deleted file mode 100644 index bb5f9e75..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authorization/AccountManager.cs +++ /dev/null @@ -1,148 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.AspNetCore.Http; -using PluginCore.Utils; - -namespace PluginCore.AspNetCore.Authorization -{ - public class AccountManager - { - private readonly IHttpContextAccessor _httpContextAccessor; - - public Microsoft.AspNetCore.Http.HttpContext HttpContext - { - get - { - return this._httpContextAccessor.HttpContext; - } - } - - public AccountManager(IHttpContextAccessor httpContextAccessor) - { - // Exception: IFeatureCollection has been disposed. Object name: 'Collection'. - // https://stackoverflow.com/questions/59963383/session-setstring-method-throws-exception-ifeaturecollection-has-been-disposed - //HttpContext = ((HttpContextAccessor)httpContextAccessor).HttpContext; - //HttpContext = httpContextAccessor.HttpContext; - // 注意: 不要将 HttpContext 保存起来,应当每次都从 httpContextAccessor 取 - _httpContextAccessor = httpContextAccessor; - } - - public static Config.PluginCoreConfig.AdminModel Admin - { - get - { - return Config.PluginCoreConfigFactory.Create().Admin; - } - set - { - var sourceModel = Config.PluginCoreConfigFactory.Create(); - sourceModel.Admin = value; - Config.PluginCoreConfigFactory.Save(sourceModel); - } - } - - public static string CurrentToken(HttpContext httpContext) - { - string token = null; - HttpRequest request = httpContext.Request; - try - { - // header -> cookie - try - { - // header 中找 token - if (request.Headers.ContainsKey("Authorization")) - { - string authHeader = request.Headers["Authorization"]; - if (!string.IsNullOrEmpty(authHeader) && authHeader.StartsWith("Bearer")) - { - token = authHeader.Substring("Bearer ".Length).Trim(); - } - } - } - catch (Exception ex) - { - //throw ex; - } - if (string.IsNullOrEmpty(token)) - { - // cookie 中找 token - //string tokenCookieName = "token"; - // string tokenCookieName = "PluginCore.Admin.Token"; - string tokenCookieName = IPlugins.Constants.AspNetCoreAuthorizationTokenCookieName; - if (request.Cookies.Keys.Contains(tokenCookieName)) - { - if (request.Cookies[tokenCookieName] != null && string.IsNullOrEmpty(request.Cookies[tokenCookieName]) == false) - { - token = request.Cookies[tokenCookieName]; - } - } - } - } - catch (Exception ex) - { - throw ex; - } - - return token; - } - - public string CurrentToken() - { - return CurrentToken(this.HttpContext); - } - - public static string CreateToken() - { - return CreateToken(Admin.UserName, Admin.Password); - } - - public static string CreateToken(string userName, string password) - { - string token = $"UserName={userName}&Password={password}"; - token = Md5Helper.MD5Encrypt32(token); - - return token; - } - - public static bool IsAdminToken(string token) - { - bool isAdmin = false; - isAdmin = CreateToken().Equals(token); - - return isAdmin; - } - - public bool IsAdmin() - { - return IsAdmin(this.HttpContext); - } - - public static bool IsAdmin(HttpContext httpContext) - { - bool isAdmin = false; - try - { - string currentToken = CurrentToken(httpContext); - isAdmin = IsAdminToken(currentToken); - } - catch (Exception ex) - { - throw ex; - } - - return isAdmin; - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authorization/PluginCoreAdminAuthorizationHandler.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authorization/PluginCoreAdminAuthorizationHandler.cs deleted file mode 100644 index d3c25b36..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authorization/PluginCoreAdminAuthorizationHandler.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; - -namespace PluginCore.AspNetCore.Authorization -{ - public class PluginCoreAdminAuthorizationHandler : AuthorizationHandler - { - private readonly AccountManager _accountManager; - - public PluginCoreAdminAuthorizationHandler(AccountManager accountManager) - { - _accountManager = accountManager; - } - - /// - /// 必须在其中呼叫一次 代表满足 ,否则皆为 不满足此 Requirement - /// - /// - /// - /// - protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, - PluginCoreAdminRequirement requirement) - { - bool isAdmin = this._accountManager.IsAdmin(); - if (!isAdmin) - { - context.Fail(); - } - else - { - // 认证通过后, 可通过下面方式获取 token - var identity = context.User.Identity; - - string token = this._accountManager.CurrentToken(); - - // Utils.LogUtil.Info($"通过 Authorization: token: {token}"); - Utils.LogUtil.Info($"Authorization Granted"); - - context.Succeed(requirement); - } - - await Task.CompletedTask; - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authorization/PluginCoreAdminAuthorizeAttribute.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authorization/PluginCoreAdminAuthorizeAttribute.cs deleted file mode 100644 index dfb1efe5..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authorization/PluginCoreAdminAuthorizeAttribute.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.AspNetCore.Authorization; - -namespace PluginCore.AspNetCore.Authorization -{ - /// - /// 注意: PluginCoreAdmin -> PluginCore.Admin - /// - public class PluginCoreAdminAuthorizeAttribute : AuthorizeAttribute - { - // public PluginCoreAdminAuthorizeAttribute() : base("PluginCore.Admin") - public PluginCoreAdminAuthorizeAttribute() : base(policy: IPlugins.Constants.AspNetCoreAuthorizationPolicyName) - { - // 同时明确指定 认证方案 与 授权策略 - AuthenticationSchemes = PluginCore.IPlugins.Constants.AspNetCoreAuthenticationScheme; - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authorization/PluginCoreAdminRequirement.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authorization/PluginCoreAdminRequirement.cs deleted file mode 100644 index b7f16989..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Authorization/PluginCoreAdminRequirement.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.AspNetCore.Authorization; - -namespace PluginCore.AspNetCore.Authorization -{ - public class PluginCoreAdminRequirement : IAuthorizationRequirement - { - public PluginCoreAdminRequirement() - { - - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/BackgroundServices/BackgroundServicesHelper.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/BackgroundServices/BackgroundServicesHelper.cs deleted file mode 100644 index 96d71c75..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/BackgroundServices/BackgroundServicesHelper.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using Microsoft.Extensions.DependencyInjection; - -namespace PluginCore.AspNetCore.BackgroundServices -{ - public static class BackgroundServicesHelper - { - public static IServiceCollection AddBackgroundServices(this IServiceCollection services) - { - //services.AddScoped(typeof(IHostedService), typeof(TimeBackgroundService)); - // AddHostedService: Microsoft.AspNetCore.App - services.AddHostedService(); // 以这种方式注入就是单例 - - return services; - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/BackgroundServices/PluginTimeJobBackgroundService.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/BackgroundServices/PluginTimeJobBackgroundService.cs deleted file mode 100644 index 9a62fe6f..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/BackgroundServices/PluginTimeJobBackgroundService.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; -using System.Linq; -using System.Threading.Tasks; -using PluginCore.Interfaces; -using PluginCore.IPlugins; -using PluginCore.Utils; - -namespace PluginCore.AspNetCore.BackgroundServices -{ - public class PluginTimeJobBackgroundService : TimeBackgroundService - { - /// - /// 插件与之最近执行时间 - /// 最近执行时间: 10位秒 时间戳 - /// - private readonly Dictionary _pluginAndLastExecuteTimeDic = new Dictionary(); - - private readonly IPluginFinder _pluginFinder; - - private static readonly object _doWorklock = new object(); - - public PluginTimeJobBackgroundService(IPluginFinder pluginFinder) - { - _pluginFinder = pluginFinder; - // 最小间隔 1 秒 - _timerPeriod = TimeSpan.FromSeconds(1); - } - - protected override void DoWork(object state) - { - lock (_doWorklock) - { - //Console.WriteLine("Memory used before collection: {0:N0}", GC.GetTotalMemory(false)); - - var plugins = this._pluginFinder.EnablePlugins().ToList(); - - List enabledPluginKeyList = new List(); - foreach (var item in plugins) - { - string pluginKey = item.GetType().ToString(); - enabledPluginKeyList.Add(pluginKey); - if (this._pluginAndLastExecuteTimeDic.ContainsKey(pluginKey)) - { - long lastExecuteTime = this._pluginAndLastExecuteTimeDic[pluginKey]; - long nowTime = DateTime.Now.ToTimeStamp10(); - if (nowTime - lastExecuteTime >= item.SecondsPeriod) - { - // 调用 - Utils.LogUtil.Info($"{pluginKey}: {nameof(ITimeJobPlugin)}.{nameof(ITimeJobPlugin.ExecuteAsync)}"); - Task task = item?.ExecuteAsync(); - this._pluginAndLastExecuteTimeDic[pluginKey] = DateTime.Now.ToTimeStamp10(); - } - } - else - { - // 调用 - Utils.LogUtil.Info($"{pluginKey}: {nameof(ITimeJobPlugin)}.{nameof(ITimeJobPlugin.ExecuteAsync)}"); - Task task = item?.ExecuteAsync(); - this._pluginAndLastExecuteTimeDic.Add(pluginKey, DateTime.Now.ToTimeStamp10()); - } - } - // 所有插件遍历结束 - // 出现在了 _pluginAndLastExecuteTimeDic 中,但没有出现在 enabledPluginKeyList, 说明为之前启用过,但现在已禁用的插件,需要去除掉 - List keys = this._pluginAndLastExecuteTimeDic.Select(m => m.Key).ToList(); - foreach (string key in keys) - { - if (!enabledPluginKeyList.Contains(key)) - { - this._pluginAndLastExecuteTimeDic.Remove(key); - } - } - - GC.Collect(); - GC.WaitForPendingFinalizers(); - //Console.WriteLine("Memory used after full collection: {0:N0}", GC.GetTotalMemory(true)); - } - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/BackgroundServices/TimeBackgroundService.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/BackgroundServices/TimeBackgroundService.cs deleted file mode 100644 index d3087a14..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/BackgroundServices/TimeBackgroundService.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using Microsoft.Extensions.Hosting; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace PluginCore.AspNetCore.BackgroundServices -{ - public abstract class TimeBackgroundService : IHostedService, IDisposable - { - protected Timer _timer; - protected TimeSpan _timerPeriod; - - public virtual Task StartAsync(CancellationToken cancellationToken) - { - _timer = new Timer(DoWork, null, TimeSpan.Zero, _timerPeriod); - - return Task.CompletedTask; - } - - public virtual Task StopAsync(CancellationToken cancellationToken) - { - _timer?.Change(Timeout.Infinite, 0); - - return Task.CompletedTask; - } - - protected abstract void DoWork(object state); - - public virtual void Dispose() - { - _timer?.Dispose(); - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/CHANGELOG.md b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/CHANGELOG.md deleted file mode 100644 index 4ffa87a0..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/CHANGELOG.md +++ /dev/null @@ -1,280 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines. - ---- -## [unreleased] - -### Documentation - -- **(CHANGELOG.md)** update - ([85bf0d9](https://github.com/yiyungent/PluginCore/commit/85bf0d9bd8e2f9efa7e8c0db3127ec8aaa054bc8)) - github-actions[bot] -- **(CHANGELOG.md)** update - ([a329e4e](https://github.com/yiyungent/PluginCore/commit/a329e4e7ec4048ec445e826f4536402abd832e46)) - github-actions[bot] -- **(CHANGELOG.md)** update - ([0bbfc89](https://github.com/yiyungent/PluginCore/commit/0bbfc8955b7f6338db2125c78ec250e9eeeadcce)) - github-actions[bot] -- **(CHANGELOG.md)** update - ([4f6b47b](https://github.com/yiyungent/PluginCore/commit/4f6b47b3f86bfce4a8f660166837a7322c568d78)) - github-actions[bot] - -### Miscellaneous Chores - -- **(src/plugincore.aspnetcore)** cliff.toml, CHANGELOG.md - ([bf95c28](https://github.com/yiyungent/PluginCore/commit/bf95c287ae9902608c4711e4dec05575c2d0e794)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.4.3](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.4.2..PluginCore.AspNetCore-v1.4.3) - 2024-08-31 - -### Bug Fixes - -- **(PluginCore.AspNetCore/Controllers/PluginsController)** swagger [FromForm] - ([241d9a7](https://github.com/yiyungent/PluginCore/commit/241d9a72973d9cf1a11c11264a91e9370b2a6cda)) - yiyun - -### Features - -- **(src/plugincore.aspnetcore/extensions/plugincorestartupextensions.cs)** 插件 wwwroot 默认页 指定, 无需再手动 - ([469ae81](https://github.com/yiyungent/PluginCore/commit/469ae81fc31adce0c0b0701e2dfa1d98634ee184)) - yiyun - -### Miscellaneous Chores - -- **(PluginCore.AspNetCore.csproj)** 1.4.2 -> 1.4.3 - ([1924e0c](https://github.com/yiyungent/PluginCore/commit/1924e0c179aaac1a1d1f57a8bdebc7578d0b7650)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.4.2](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.4.1..PluginCore.AspNetCore-v1.4.2) - 2024-04-06 - -### Features - -- **(src/plugincore.aspnetcore/backgroundservices/plugintimejobbackgroundservice.cs)** log - ([5da04c2](https://github.com/yiyungent/PluginCore/commit/5da04c20b57a166811ef8af828c5fd0bafab844c)) - yiyun -- **(src/plugincore.aspnetcore/extensions/plugincorestartupextensions.cs)** plugin:startup->appstart - ([71cafe7](https://github.com/yiyungent/PluginCore/commit/71cafe7fa7348b4d8ccb0b342f31ff848c6e77e9)) - yiyun - -### Build - -- **(src/plugincore.aspnetcore/plugincore.aspnetcore.csproj)** 1.4.1 -> 1.4.2 - ([75f17be](https://github.com/yiyungent/PluginCore/commit/75f17becb01b6d833759811e65cf464ea7a745b1)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.4.1](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.4.0..PluginCore.AspNetCore-v1.4.1) - 2024-03-14 - -### Bug Fixes - -- **(src/plugincore.aspnetcore/extensions/plugincorestartupextensions.cs)** log, _serviceProvider - ([7d7a904](https://github.com/yiyungent/PluginCore/commit/7d7a904fd1794e26f278655f6f3f286b92bd1492)) - yiyun - -### Build - -- **(plugincore.aspnetcore.csproj)** 1.4.0 -> 1.4.1 - ([393d861](https://github.com/yiyungent/PluginCore/commit/393d861870c45a70f63421b5451df76e4ed9c808)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.4.0](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.3.4..PluginCore.AspNetCore-v1.4.0) - 2024-02-15 - -### Features - -- **(src/plugincore.aspnetcore)** authentication & Authorize - ([73a673e](https://github.com/yiyungent/PluginCore/commit/73a673e06d2a8d662a44323cf7401e91d814ae90)) - yiyun -- **(src/plugincore.aspnetcore)** 认证与授权: 优化,分离, PluginCoreStartupExtensions 优化 - ([ebab6d8](https://github.com/yiyungent/PluginCore/commit/ebab6d888a303f221e4a45ddaa28107ff4a012c4)) - yiyun -- **(src/plugincore.aspnetcore)** accountManager 部分方法静态化, 提供 HttpContext 传入方式, 相关引用处更新调用 - ([491f334](https://github.com/yiyungent/PluginCore/commit/491f334baabb28e1736b5cc1bd19a0081c54949c)) - yiyun - -### Miscellaneous Chores - -- **(src/plugincore.aspnetcore/extensions/plugincorestartupextensions.cs)** 代码缩进: 美化 - ([6a03628](https://github.com/yiyungent/PluginCore/commit/6a036289ba6f3ae1592b4e4ed58b4fb1bcdc1306)) - yiyun - -### Build - -- **(plugincore.aspnetcore.csproj)** 1.3.4 -> 1.4.0 - ([f786f5e](https://github.com/yiyungent/PluginCore/commit/f786f5eeb5e19558e3e73890a42f56ce812784cc)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.3.4](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.3.3..PluginCore.AspNetCore-v1.3.4) - 2023-12-30 - -### Bug Fixes - -- **(src/plugincore.aspnetcore)** 转向/适配 LogUtil - ([1a7c71d](https://github.com/yiyungent/PluginCore/commit/1a7c71d748fd228f1053de67572a04f466012ab8)) - yiyun -- **(src/plugincore.aspnetcore)** 适配: LogUtil - ([f150d07](https://github.com/yiyungent/PluginCore/commit/f150d07b55326133afdfe2c156464605483feb05)) - yiyun -- **(src/plugincore.aspnetcore)** 适配 LogUtil.Error - ([9c82b16](https://github.com/yiyungent/PluginCore/commit/9c82b161c5507ad1a7b78b1191dba208e8f4be45)) - yiyun -- **(src/plugincore.aspnetcore/middlewares/languagemiddleware.cs)** namespace: 语法降级 - ([a1f83fc](https://github.com/yiyungent/PluginCore/commit/a1f83fce8f1dcf2e5ead3b8a15eae006053af4de)) - yiyun - -### Documentation - -- **(src/plugincore.aspnetcore/readme.txt)** zh -> EN - ([f822b0b](https://github.com/yiyungent/PluginCore/commit/f822b0b79d1afca536bb7e10814226fb65988365)) - yiyun -- **(src/plugincore.aspnetcore/readme.txt)** update - ([0a3210b](https://github.com/yiyungent/PluginCore/commit/0a3210bc073252a1f18d0910dc80aabd1061a66f)) - yiyun - -### Features - -- **(src/**/*.cs)** // License: Apache-2.0 -> // License: GNU LGPLv3 - ([57366d3](https://github.com/yiyungent/PluginCore/commit/57366d3e2afdb8e20e94851aa8a09f1ee61b6d7e)) - yiyun -- **(src/**/*.cs)** // Project: https://moeci.com/PluginCore -> // Project: https://yiyungent.github.io/PluginCore - ([7420480](https://github.com/yiyungent/PluginCore/commit/742048065978c1b8597fab3d52f011db4247fbda)) - yiyun -- **(src/plugincore.aspnetcore)** use Constants - ([6cd128a](https://github.com/yiyungent/PluginCore/commit/6cd128a2ce6da83f8cfee46ae03a7af44380e791)) - yiyun -- **(src/plugincore.aspnetcore)** languageMiddleware: 当前 Language - ([b0d79e7](https://github.com/yiyungent/PluginCore/commit/b0d79e7a0ae469cc295d87ed8a7c97a355cbc7a1)) - yiyun -- **(src/plugincore.aspnetcore)** 适配: LogUtil - ([b09da39](https://github.com/yiyungent/PluginCore/commit/b09da39199d614f40ec533d7a472069c40121fae)) - yiyun -- **(src/plugincore.aspnetcore)** 认证与授权: 日志输出: 中文->英文 - ([1470a99](https://github.com/yiyungent/PluginCore/commit/1470a9913fff6e0df37495d1143f5a55eed995fd)) - yiyun -- **(src/plugincore.aspnetcore/controllers/pluginscontroller.cs)** 启用,禁用: Message: 使用 BasePlugin 源 - ([d6c8a33](https://github.com/yiyungent/PluginCore/commit/d6c8a3361a7573c68031ad6e8bd8aa35c65035d4)) - yiyun -- **(src/plugincore.aspnetcore/extensions/plugincorestartupextensions.cs)** use Constants - ([68952a1](https://github.com/yiyungent/PluginCore/commit/68952a13613d469cefe9fc9fd13ab7525dd93f78)) - yiyun -- **(src/plugincore.aspnetcore/extensions/plugincorestartupextensions.cs)** use constants - ([37798ef](https://github.com/yiyungent/PluginCore/commit/37798efc92f82e5e5f4d696b6de5466809a18d48)) - yiyun -- **(src/plugincore.aspnetcore/extensions/plugincorestartupextensions.cs)** 初始化: Logger - ([6e24a5a](https://github.com/yiyungent/PluginCore/commit/6e24a5a391af60f8ec0ba85e8ea86ea23c49f522)) - yiyun -- **(src/plugincore.aspnetcore/extensions/plugincorestartupextensions.cs)** log 输出 -> 英文 - ([e41b73a](https://github.com/yiyungent/PluginCore/commit/e41b73adda0ca5d9f1f60109ee8b6fe7de39deda)) - yiyun - -### Build - -- **(plugincore.aspnetcore.csproj)** 1.3.3 -> 1.3.4 - ([84550cc](https://github.com/yiyungent/PluginCore/commit/84550cc9159c387cedbc8beda282dfcfea9cdcb1)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.3.3](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.3.2..PluginCore.AspNetCore-v1.3.3) - 2023-12-14 - -### Build - -- **(src/plugincore.aspnetcore/plugincore.aspnetcore.csproj)** packageReference update, 1.3.2->1.3.3 - ([6fc3d1a](https://github.com/yiyungent/PluginCore/commit/6fc3d1ad6359a5f8690babfc6949e0821d5bd6c5)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.3.2](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.3.1..PluginCore.AspNetCore-v1.3.2) - 2023-08-21 - -### Features - -- **(src/plugincore.aspnetcore/extensions/plugincorestartupextensions.cs)** services: PluginFinder - ([144db05](https://github.com/yiyungent/PluginCore/commit/144db05576001a72f9cbd6beea0b3b5baa6a082c)) - yiyun - -### Build - -- **(src/plugincore.aspnetcore/plugincore.aspnetcore.csproj)** 1.3.2 - ([dfdd17d](https://github.com/yiyungent/PluginCore/commit/dfdd17dbcb2fc636cc102ab76497ff5768c64a4e)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.3.1](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.3.0..PluginCore.AspNetCore-v1.3.1) - 2023-02-15 - -### Build - -- **(plugincore.aspnetcore.csproj)** `1.3.1` - ([39e0d03](https://github.com/yiyungent/PluginCore/commit/39e0d037c6f3e0dcf4845b5ca8ae2aa41142a474)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.3.0](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.2.0..PluginCore.AspNetCore-v1.3.0) - 2023-02-15 - -### Bug Fixes - -- **(plugincore.aspnetcore,plugincore)** iList EnabledPlugins->List,IList不支持Remove - ([4d5d30e](https://github.com/yiyungent/PluginCore/commit/4d5d30e66c4c28998a7a6ac96bf3ffb25e4872b4)) - yiyun - -### Features - -- **(plugincore.aspnetcore,plugincore.iplugins,plugincore)** 仅保留已启用/已禁用 状态, IPlugin新方法 - ([e843a5b](https://github.com/yiyungent/PluginCore/commit/e843a5ba9fad4e88290c09bb3282b730c44c5a06)) - yiyun - -### Build - -- **(src/plugincore.aspnetcore/plugincore.aspnetcore.csproj)** `1.3.0` - ([64b9775](https://github.com/yiyungent/PluginCore/commit/64b977569312539aa2775235ae1f0fca5517ddcd)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.2.0](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.1.0..PluginCore.AspNetCore-v1.2.0) - 2023-02-14 - -### Features - -- **(src/plugincore.aspnetcore/controllers/debugcontroller.cs)** pluginContexts:PluginId - ([f82b7b1](https://github.com/yiyungent/PluginCore/commit/f82b7b199420b15fc6f38e8f26c8094ee4be1b88)) - yiyun - -### Build - -- **(src/plugincore.aspnetcore/plugincore.aspnetcore.csproj)** 1.2.0 - ([fe418e0](https://github.com/yiyungent/PluginCore/commit/fe418e0f67dd8ed1fd2d78dc3f4106c8dc1a396b)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.1.0](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.0.4..PluginCore.AspNetCore-v1.1.0) - 2023-02-10 - -### Features - -- **(src/plugincore.aspnetcore/)** update - ([52ee48f](https://github.com/yiyungent/PluginCore/commit/52ee48fe234040fd0cc0a4d21f3c2e1c9483735e)) - yiyun -- **(src/plugincore.aspnetcore/controllers/debugcontroller.cs)** add - ([196823d](https://github.com/yiyungent/PluginCore/commit/196823d6e3b39eb70d1d4bb55d7d4c8433ee64fc)) - yiyun -- **(src/plugincore.aspnetcore/controllers/debugcontroller.cs)** 完成 - ([2a2e213](https://github.com/yiyungent/PluginCore/commit/2a2e2131ee4b25912c16ca0d01ef408702cbfc39)) - yiyun -- **(src/plugincore.aspnetcore/controllers/debugcontroller.cs)** services - ([22edc22](https://github.com/yiyungent/PluginCore/commit/22edc229c1bedc4667a920ef62c11c8e002ba9d2)) - yiyun - -### Build - -- **(src/plugincore.aspnetcore/plugincore.aspnetcore.csproj)** 1.1.0 - ([3bdb176](https://github.com/yiyungent/PluginCore/commit/3bdb17602c3258386711b200917e567c82dc442b)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.0.4](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.0.3..PluginCore.AspNetCore-v1.0.4) - 2023-01-12 - -### Build - -- **(plugincore.aspnetcore.csproj)** 1.0.4 - ([46cf5dd](https://github.com/yiyungent/PluginCore/commit/46cf5dd5f955f6b648323e5216af97dd177e5a4b)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.0.3](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.0.2..PluginCore.AspNetCore-v1.0.3) - 2022-06-03 - -### Bug Fixes - -- **(backgroundservices/plugintimejobbackgroundservice.cs)** 定时任务:强制GC回收,抑制内存++ - ([434e824](https://github.com/yiyungent/PluginCore/commit/434e82403b6aa2050945eeaa1131ea7965bdbc5f)) - yiyun - -### Build - -- **(plugincore.aspnetcore.csproj)** 1.0.3 - ([7da5638](https://github.com/yiyungent/PluginCore/commit/7da5638672571ca0ef057ebf73493260886b903e)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.0.2](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.0.1..PluginCore.AspNetCore-v1.0.2) - 2022-04-19 - -### Features - -- **(plugincore.aspnetcore)** pluginsController: 移除: 插件上传大小限制 - ([90f8d67](https://github.com/yiyungent/PluginCore/commit/90f8d671a840ae8ca3688f4a5cbc22e568a6159e)) - yiyun - -### Style - -- add: copyright: *.cs - ([9643dce](https://github.com/yiyungent/PluginCore/commit/9643dce112861a440d63306cb555accbed3d5111)) - yiyun - -### Build - -- **(plugincore.aspnetcore.csproj)** 1.0.2 - ([b4eb1cc](https://github.com/yiyungent/PluginCore/commit/b4eb1cca9039ff95a516ba6d4000f10d156e03d0)) - yiyun -- **(plugincore.aspnetcore/package.json,package-lock.json)** "plugincore-admin-frontend": "0.3.2" - ([7a70b20](https://github.com/yiyungent/PluginCore/commit/7a70b2003128bf569b4fdd4b7eaa662a92da8ee8)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.0.1](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.0.0..PluginCore.AspNetCore-v1.0.1) - 2022-04-17 - -### Build - -- **(plugincore.aspnetcore.csproj)** 1.0.1 - ([ab348ce](https://github.com/yiyungent/PluginCore/commit/ab348ceca937f1b1f4ba8c83f4816b9a0ae7ea3e)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.0.0](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v0.0.5..PluginCore.AspNetCore-v1.0.0) - 2022-04-17 - -### Bug Fixes - -- **(plugincore)** 临时修复由于 PluginContextManager 单例失败 导致的插件信息丢失 - ([fa613b4](https://github.com/yiyungent/PluginCore/commit/fa613b4c46e41c906fe955eb8f62c3f4937795bc)) - yiyun - -### Features - -- **(plugincore,plugincore.aspnetcore)** aspNetCorePluginManagerBeta,PluginLoadContext,PluginFinder - ([9d65a59](https://github.com/yiyungent/PluginCore/commit/9d65a590e3e0850251f6d815c322c7c5d9c7cf3f)) - yiyun -- **(plugincore.aspnetcore)** add:DebugController.PluginContext - ([cd8de63](https://github.com/yiyungent/PluginCore/commit/cd8de636c8d7e2b125e11c6ce4091567cb97d4bc)) - yiyun -- **(plugincore.aspnetcore)** commonResponseModel -> BaseResponseModel - ([1a0e834](https://github.com/yiyungent/PluginCore/commit/1a0e834b7dfdb45c45770d42b1733f1cb449a6ca)) - yiyun - -### Refactoring - -- **(plugincore.aspnetcore,plugincore)** 未完成 - ([a151bcd](https://github.com/yiyungent/PluginCore/commit/a151bcda125cb7e9b5fe11d44e1389afa7a1db5e)) - yiyun -- **(plugincore.aspnetcore,plugincore)** 重构v2: 未测试 - ([53dde31](https://github.com/yiyungent/PluginCore/commit/53dde31116bd6455d33f7d7006b6fd1430f3694b)) - yiyun -- **(plugincore.aspnetcore,plugincore)** 变量名,属性名,类名规范化 - ([eaadabf](https://github.com/yiyungent/PluginCore/commit/eaadabfd759228da245af1d9bd5b86e557540d28)) - yiyun - -### Build - -- **(plugincore.aspnetcore.csproj)** 1.0.0 - ([9b5caf4](https://github.com/yiyungent/PluginCore/commit/9b5caf4c4cdc543025c5493d35275a836cae61a9)) - yiyun - ---- -## [PluginCore.AspNetCore-v0.0.5](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v0.0.4..PluginCore.AspNetCore-v0.0.5) - 2022-04-16 - -### Build - -- **(plugincore.aspnetcore.csproj)** 0.0.5 - ([3e5cb09](https://github.com/yiyungent/PluginCore/commit/3e5cb0921a9faa33f93169c2d983011a1e8c5b5f)) - yiyun - ---- -## [PluginCore.AspNetCore-v0.0.4](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v0.0.3..PluginCore.AspNetCore-v0.0.4) - 2022-04-16 - -### Build - -- **(plugincore.aspnetcore.csproj)** 0.0.4 - ([adffab3](https://github.com/yiyungent/PluginCore/commit/adffab3fecee6696709c1d325b8c11e5a5389031)) - yiyun - ---- -## [PluginCore.AspNetCore-v0.0.3](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v0.0.2..PluginCore.AspNetCore-v0.0.3) - 2022-04-16 - -### Bug Fixes - -- **(plugincore.aspnetcore/extensions/plugincorestartupextensions.cs)** pluginFinder:TryAddTransient - ([03e9235](https://github.com/yiyungent/PluginCore/commit/03e9235c3c7fe68a3209cb1109792869e78aaa4e)) - yiyun -- **(plugincore.aspnetcore/extensions/plugincorestartupextensions.cs)** 注释错误: 在程序启动时加载所有 已安装并启用 的插件 - ([844826a](https://github.com/yiyungent/PluginCore/commit/844826a630f99c2d866a98e6556404d4b1857e52)) - yiyun - -### Build - -- **(plugincore.aspnetcore.csproj)** 0.0.3 - ([ee81a45](https://github.com/yiyungent/PluginCore/commit/ee81a4536af17a85bbebc07bc0c980af8c00ad63)) - yiyun - ---- -## [PluginCore.AspNetCore-v0.0.2](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v0.0.1..PluginCore.AspNetCore-v0.0.2) - 2022-04-16 - -### Refactoring - -- 1.提取出 PluginCore.AspNetCore,PluginCore.IPlugins.AspNetCore 2.提取出更多接口,可自由替换 - ([fffd8d9](https://github.com/yiyungent/PluginCore/commit/fffd8d91c23fd6e4a4d09cbf91975beb3cf7acf0)) - yiyun - -### Build - -- **(plugincore.aspnetcore.csproj)** 0.0.2 - ([ba7b274](https://github.com/yiyungent/PluginCore/commit/ba7b27496a4ba784c271305489b9f2f8e6f74ad3)) - yiyun - ---- -## [PluginCore.AspNetCore-v0.0.1](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.9.3..PluginCore.AspNetCore-v0.0.1) - 2022-03-26 - -### Features - -- **(plugincore.aspnetcore)** pluginCore.AspNetCore,PluginCore.AspNetCore-nuget-push.yml - ([491f63e](https://github.com/yiyungent/PluginCore/commit/491f63e3362129a2239d87b090aa04cc2e414e9a)) - yiyun - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/AppCenterController.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/AppCenterController.cs deleted file mode 100644 index 762495f5..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/AppCenterController.cs +++ /dev/null @@ -1,207 +0,0 @@ -//=================================================== -// License: GNU LGPLv3 -// Contributors: yiyungent@gmail.com -// Project: https://yiyungent.github.io/PluginCore -// GitHub: https://github.com/yiyungent/PluginCore -//=================================================== - - - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Threading.Tasks; -using PluginCore; -using PluginCore.Models; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using PluginCore.AspNetCore.Authorization; -using PluginCore.AspNetCore.ResponseModel; -//using ResponseModel; - - -namespace PluginCore.AspNetCore.Controllers -{ - /// - /// 应用中心 - /// 插件 - /// - [Route("api/plugincore/admin/[controller]/[action]")] - [PluginCoreAdminAuthorize] - [ApiController] - public class AppCenterController : ControllerBase - { - #region Fields - - private static Dictionary _pluginDownloadTasks; - - #endregion - - #region Ctor - - static AppCenterController() - { - _pluginDownloadTasks = new Dictionary(); - } - - public AppCenterController() - { - - } - #endregion - - #region Actions - - #region 插件列表 - /// - /// 插件 - /// - /// - /// - [HttpGet, HttpPost] - public async Task> Plugins(string query = "") - { - BaseResponseModel responseDTO = new BaseResponseModel(); - IList pluginRegistryModels = new List(); - try - { - // 1. TODO: 从json文件中读取插件订阅源 registry url - string registryUrl = ""; - // 2. TODO: 向订阅源发送 http get 获取插件列表信息 eg: http://rem-core-plugins-registry.moeci.com/?query=xxx - IList remotePluginIds = new List(); - - // 3. 根据本地已有 PluginId 插件情况 状态赋值 - PluginConfigModel pluginConfigModel = PluginConfigModelFactory.Create(); - // IList localPluginIds = pluginConfigModel.EnabledPlugins.Concat(pluginConfigModel.DisabledPlugins).Concat(pluginConfigModel.UninstalledPlugins).ToList(); - IList localPluginIds = PluginPathProvider.AllPluginFolderName(); - - - - responseDTO.Code = 1; - responseDTO.Message = "获取远程插件数据成功"; - responseDTO.Data = pluginRegistryModels; - } - catch (Exception ex) - { - responseDTO.Code = -1; - responseDTO.Message = "获取远程插件数据失败: " + ex.Message; - responseDTO.Data = pluginRegistryModels; - } - - return await Task.FromResult(responseDTO); - } - #endregion - - #region 下载插件 - [HttpGet, HttpPost] - public async Task> DownloadPlugin(string pluginDownloadUrl = "") - { - BaseResponseModel responseDTO = new BaseResponseModel(); - - #region 效验 - if (string.IsNullOrEmpty(pluginDownloadUrl)) - { - responseDTO.Code = -1; - responseDTO.Message = "插件下载地址不正确"; - return responseDTO; - } - // TODO: 效验是否本地已经存在相同pluginId的插件 - - #endregion - - try - { - // 1.执行下载操作, TODO:存在问题,阻塞对性能不好,但不阻塞又不好通知用户插件下载进度,以及可能存在在插件下载过程中,用户再次点击下载 - WebClient webClient = new WebClient(); - // TODO: 插件下载文件路径 - string pluginDownloadFilePath = ""; - //webClient.DownloadFileAsync(new Uri(pluginDownloadFilePath), ""); - Task task = webClient.DownloadFileTaskAsync(pluginDownloadUrl, pluginDownloadFilePath); - - _pluginDownloadTasks.Add(pluginDownloadUrl, task); - - webClient.DownloadFileCompleted += Plugin_DownloadFileCompleted; - webClient.DownloadProgressChanged += Plugin_DownloadProgressChanged; - webClient.Disposed += WebClient_Disposed; - - responseDTO.Code = 1; - responseDTO.Message = "开始下载插件"; - } - catch (Exception ex) - { - responseDTO.Code = -1; - responseDTO.Message = "下载插件失败: " + ex.Message; - } - - return await Task.FromResult(responseDTO); - } - - - - - #endregion - - #region 获取插件下载进度 - [HttpGet, HttpPost] - public async Task> DownloadPluginProgress() - { - BaseResponseModel responseDTO = new BaseResponseModel(); - try - { - responseDTO.Data = new { }; - - - - responseDTO.Code = 1; - responseDTO.Message = "获取插件下载进度成功"; - } - catch (Exception ex) - { - responseDTO.Code = -1; - responseDTO.Message = "获取插件下载进度失败: " + ex.Message; - } - - return await Task.FromResult(responseDTO); - } - #endregion - - #endregion - - #region Helpers - - /// - /// 插件下载完成 - /// - /// - /// - private void Plugin_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) - { - Utils.LogUtil.Info("插件下载完成"); - // 1.从 _pluginDownloadTasks 中移除 - //_pluginDownloadTasks.Remove(); - // 2. 解压插件 - - } - - private void Plugin_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) - { - Utils.LogUtil.Info($"插件下载进度改变: {e.ProgressPercentage}% {e.BytesReceived}/{e.TotalBytesToReceive}"); - } - - private void WebClient_Disposed(object sender, EventArgs e) - { - if (sender is WebClient webClient) - { - Utils.LogUtil.Info(webClient.BaseAddress); - } - - Utils.LogUtil.Info(nameof(WebClient_Disposed) + ": " + sender.ToString()); - } - - #endregion - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/DebugController.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/DebugController.cs deleted file mode 100644 index a3ef7fc5..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/DebugController.cs +++ /dev/null @@ -1,280 +0,0 @@ -using System.Runtime.CompilerServices; -//=================================================== -// License: GNU LGPLv3 -// Contributors: yiyungent@gmail.com -// Project: https://yiyungent.github.io/PluginCore -// GitHub: https://github.com/yiyungent/PluginCore -//=================================================== - - - -using Microsoft.AspNetCore.Mvc; -using PluginCore.AspNetCore.Authorization; -using PluginCore.AspNetCore.ResponseModel; -using PluginCore.Interfaces; -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; -using System.Linq; -using System.Runtime.Loader; -using Microsoft.Extensions.DependencyInjection; -using System.Collections.Concurrent; -using PluginCore.AspNetCore.Extensions; - -namespace PluginCore.AspNetCore.Controllers -{ - /// - /// [ASP.NET Core — 依赖注入\_啊晚的博客-CSDN博客\_asp.net core 依赖注入](https://blog.csdn.net/weixin_37648525/article/details/127942292) - /// [ASP.NET Core中的依赖注入(3): 服务的注册与提供 - Artech - 博客园](https://www.cnblogs.com/artech/p/asp-net-core-di-register.html) - /// [ASP.NET Core中的依赖注入(5): ServiceProvider实现揭秘 【总体设计 】 - Artech - 博客园](https://www.cnblogs.com/artech/p/asp-net-core-di-service-provider-1.html) - /// [dotnet/ServiceProvider.cs at main · dotnet/dotnet](https://github.com/dotnet/dotnet/blob/main/src/runtime/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs) - /// [Net6 DI源码分析Part2 Engine,ServiceProvider - 一身大膘 - 博客园](https://www.cnblogs.com/hts92/p/15800990.html) - /// [【特别的骚气】asp.net core运行时注入服务,实现类库热插拔 - 四处观察 - 博客园](https://www.cnblogs.com/1996-Chinese-Chen/p/16154218.html) - /// - /// ActivatorUtilities.CreateInstance(serviceProvider, "test"); - /// ActivatorUtilities.GetServiceOrCreateInstance(serviceProvider); - /// - /// - [Route("api/plugincore/admin/[controller]/[action]")] - [PluginCoreAdminAuthorize] - [ApiController] - public class DebugController : ControllerBase - { - #region Fields - private readonly IPluginContextManager _pluginContextManager; - #endregion - - #region Ctor - public DebugController(IPluginContextManager pluginContextManager) - { - _pluginContextManager = pluginContextManager; - } - #endregion - - #region Actions - - [HttpGet, HttpPost] - public async Task> PluginContexts() - { - BaseResponseModel responseModel = new BaseResponseModel(); - try - { - var pluginContextList = _pluginContextManager.All(); - Dictionary> keyValuePairs = new Dictionary>(); - foreach (var pluginContext in pluginContextList) - { - keyValuePairs.Add($"{pluginContext.GetType().ToString()} - {pluginContext.PluginId} - {pluginContext.GetHashCode()}", pluginContext.Assemblies.Select(m => m.FullName).ToList()); - } - - responseModel.Code = 1; - responseModel.Message = "success"; - responseModel.Data = keyValuePairs; - } - catch (Exception ex) - { - responseModel.Code = -1; - responseModel.Message = "error"; - responseModel.Data = ex.ToString(); - } - - return await Task.FromResult(responseModel); - } - - [HttpGet, HttpPost] - public async Task> AssemblyLoadContexts() - { - BaseResponseModel responseModel = new BaseResponseModel(); - try - { - var assemblyLoadContextDefault = AssemblyLoadContext.Default; - var assemblyLoadContextAll = AssemblyLoadContext.All; - var responseDataModel = new AssemblyLoadContextsResponseDataModel(); - responseDataModel.Default = new AssemblyLoadContextsResponseDataModel.AssemblyLoadContextModel - { - Name = assemblyLoadContextDefault.Name, - Type = assemblyLoadContextDefault.GetType().ToString(), - Assemblies = assemblyLoadContextDefault.Assemblies.Select(m => new AssemblyModel { FullName = m.FullName, DefinedTypes = m.DefinedTypes.Select(m => m.FullName).ToList() }).ToList() - }; - responseDataModel.All = assemblyLoadContextAll.Select(item => new AssemblyLoadContextsResponseDataModel.AssemblyLoadContextModel - { - Name = item.Name, - Type = item.GetType().ToString(), - Assemblies = item.Assemblies.Select(m => new AssemblyModel { FullName = m.FullName, DefinedTypes = m.DefinedTypes.Select(m => m.FullName).ToList() }).ToList() - }).ToList(); - - responseModel.Code = 1; - responseModel.Message = "success"; - responseModel.Data = responseDataModel; - } - catch (Exception ex) - { - responseModel.Code = -1; - responseModel.Message = "error"; - responseModel.Data = ex.ToString(); - } - - return await Task.FromResult(responseModel); - } - - [HttpGet, HttpPost] - public async Task> Assemblies() - { - BaseResponseModel responseModel = new BaseResponseModel(); - try - { - var assemblies = AppDomain.CurrentDomain.GetAssemblies(); - List assemblyModels = new List(); - foreach (var item in assemblies) - { - assemblyModels.Add(new AssemblyModel - { - FullName = item.FullName, - DefinedTypes = item.DefinedTypes.Select(m => m.FullName).ToList() - }); - } - - responseModel.Code = 1; - responseModel.Message = "success"; - responseModel.Data = assemblyModels; - } - catch (Exception ex) - { - responseModel.Code = -1; - responseModel.Message = "error"; - responseModel.Data = ex.ToString(); - } - - return await Task.FromResult(responseModel); - } - - [HttpGet, HttpPost] - public async Task> Services([FromServices] IServiceProvider serviceProvider) - { - BaseResponseModel responseModel = new BaseResponseModel(); - try - { - //IServiceProvider serviceProvider = HttpContext.RequestServices; - //var provider = serviceProvider.GetType().GetProperty("RootProvider", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); - //var serviceField = provider.GetType().GetField("_realizedServices", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); - //var serviceValue = serviceField.GetValue(provider); - //var funcType = serviceField.FieldType.GetGenericArguments()[1].GetGenericArguments()[0]; - //ConcurrentDictionary> realizedServices = (ConcurrentDictionary>)serviceValue; - - // 获取所有已经注册的服务 - var allService = serviceProvider.GetAllServiceDescriptors(); - - List serviceModels = new List(); - foreach (var item in allService) - { - serviceModels.Add(new ServiceModel - { - Type = item.Key.ToString(), - ImplementationType = item.Value.ImplementationType?.ToString() ?? "", - Lifetime = item.Value.Lifetime.ToString(), - TypeAssembly = new AssemblyModel - { - FullName = item.Key.Assembly.FullName, - }, - ImplementationTypeAssembly = new AssemblyModel - { - FullName = item.Value.ImplementationType?.Assembly?.FullName ?? "" - } - }); - } - - responseModel.Code = 1; - responseModel.Message = "success"; - responseModel.Data = serviceModels; - } - catch (Exception ex) - { - responseModel.Code = -1; - responseModel.Message = "error"; - responseModel.Data = ex.ToString(); - } - - return await Task.FromResult(responseModel); - } - - #endregion - - public sealed class AssemblyLoadContextsResponseDataModel - { - public AssemblyLoadContextModel Default - { - get; set; - } - - public List All - { - get; set; - } - - public sealed class AssemblyLoadContextModel - { - public string Name - { - get; set; - } - public string Type - { - get; set; - } - public List Assemblies - { - get; set; - } - } - } - - public sealed class AssembliesResponseDataModel - { - - } - - public sealed class ServiceModel - { - public string Type - { - get; set; - } - - public string ImplementationType - { - get; set; - } - - public string Lifetime - { - get; set; - } - - public AssemblyModel TypeAssembly - { - get; set; - } - - public AssemblyModel ImplementationTypeAssembly - { - get; set; - } - } - - public sealed class AssemblyModel - { - public string FullName - { - get; set; - } - - public List DefinedTypes - { - get; set; - } - } - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/HomeController.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/HomeController.cs deleted file mode 100644 index 8b093c30..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/HomeController.cs +++ /dev/null @@ -1,73 +0,0 @@ -//=================================================== -// License: GNU LGPLv3 -// Contributors: yiyungent@gmail.com -// Project: https://yiyungent.github.io/PluginCore -// GitHub: https://github.com/yiyungent/PluginCore -//=================================================== - - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; - -namespace PluginCore.AspNetCore.Controllers -{ - [Controller] - public class HomeController : Controller - { - #region Old - //private readonly IWebHostEnvironment _webHostEnvironment; - - //public bool IsLocalFronted - //{ - // get - // { - // return PluginCore.Config.PluginCoreConfigFactory.Create().IsLocalFrontend; - // } - //} - - //public string RemoteFronted - //{ - // get - // { - // return PluginCore.Config.PluginCoreConfigFactory.Create().RemoteFrontend; - // } - //} - - //public HomeController(IWebHostEnvironment webHostEnvironment) - //{ - // this._webHostEnvironment = webHostEnvironment; - //} - - //[Route("PluginCore/Admin")] - //public async Task Home() - //{ - // if (this.IsLocalFronted) - // { - // var localIndexFilePath = Path.Combine( - // this._webHostEnvironment.ContentRootPath, "PluginCoreAdmin", "index.html"); - - // return PhysicalFile(localIndexFilePath, "text/html"); - // } - // else - // { - // string htmlStr = string.Empty; - // HttpClient httpClient = new HttpClient(); - // htmlStr = await httpClient.GetStringAsync(this.RemoteFronted + "/index.html"); - - // return Content(htmlStr, "text/html", Encoding.UTF8); - // } - //} - #endregion - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/PluginWidgetController.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/PluginWidgetController.cs deleted file mode 100644 index 0b00b6d4..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/PluginWidgetController.cs +++ /dev/null @@ -1,103 +0,0 @@ -//=================================================== -// License: GNU LGPLv3 -// Contributors: yiyungent@gmail.com -// Project: https://yiyungent.github.io/PluginCore -// GitHub: https://github.com/yiyungent/PluginCore -//=================================================== - - - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Threading.Tasks; -using PluginCore; -using PluginCore.Models; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using PluginCore.AspNetCore.Authorization; -using PluginCore.AspNetCore.ResponseModel; -using PluginCore.IPlugins; -using System.Text; -using PluginCore.Interfaces; - -namespace PluginCore.AspNetCore.Controllers -{ - [Route("api/plugincore/[controller]/[action]")] - [ApiController] - public class PluginWidgetController : ControllerBase - { - #region Fields - private readonly IPluginFinder _pluginFinder; - #endregion - - #region Ctor - public PluginWidgetController(IPluginFinder pluginFinder) - { - _pluginFinder = pluginFinder; - } - #endregion - - #region Actions - - #region Widget - /// - /// Widget - /// - /// - [HttpGet, HttpPost] - //public async Task> Widget(string widgetKey, string extraPars = "") - public async Task Widget(string widgetKey, string extraPars = "") - { - BaseResponseModel responseModel = new ResponseModel.BaseResponseModel(); - string responseData = ""; - widgetKey = widgetKey.Trim('"', '\''); - string[] extraParsArr = null; - if (!string.IsNullOrEmpty(extraPars)) - { - extraParsArr = extraPars.Split(",", StringSplitOptions.RemoveEmptyEntries); - extraParsArr = extraParsArr.Select(m => m.Trim('"', '\'')).ToArray(); - } - StringBuilder sb = new StringBuilder(); - sb.AppendLine($""); - try - { - List plugins = this._pluginFinder.EnablePlugins().ToList(); - foreach (var item in plugins) - { - string widgetStr = await item.Widget(widgetKey, extraParsArr); - if (!string.IsNullOrEmpty(widgetStr)) - { - // TODO: 配合 PluginCoreConfig.PluginWidgetDebug - // TODO: PluginCoreConfig 改为 Options 模式, 避免手动反复读取文件 效率低 - //sb.AppendLine($""); - - sb.AppendLine(widgetStr); - } - } - - } - catch (Exception ex) - { - Utils.LogUtil.Error(ex, ex.Message); - sb.AppendLine($""); - } - sb.AppendLine($""); - responseData = sb.ToString(); - - responseModel.Code = 1; - responseModel.Message = "Load Widget Success"; - responseModel.Data = responseData; - - //return await Task.FromResult(responseModel); - return Content(responseData, "text/html;charset=utf-8"); - } - #endregion - - #endregion - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/PluginsController.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/PluginsController.cs deleted file mode 100644 index d6ddec27..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/PluginsController.cs +++ /dev/null @@ -1,688 +0,0 @@ -//=================================================== -// License: GNU LGPLv3 -// Contributors: yiyungent@gmail.com -// Project: https://yiyungent.github.io/PluginCore -// GitHub: https://github.com/yiyungent/PluginCore -//=================================================== - - - -using System; -using System.Collections.Generic; -using System.Configuration; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -//using Core.Common; -//using Framework.Authorization; -using PluginCore; -using PluginCore.Models; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using PluginCore.AspNetCore.Authorization; -using PluginCore.Infrastructure; -using PluginCore.IPlugins; -using PluginCore.AspNetCore.ResponseModel; -using PluginCore.Interfaces; -using PluginCore.AspNetCore.Interfaces; - -//using ResponseModel; - -namespace PluginCore.AspNetCore.Controllers -{ - [Route("api/plugincore/admin/[controller]/[action]")] - [PluginCoreAdminAuthorize] - [ApiController] - public class PluginsController : ControllerBase - { - #region Fields - private readonly IPluginManager _pluginManager; - private readonly IPluginFinder _pluginFinder; - private readonly IPluginApplicationBuilderManager _pluginApplicationBuilderManager; - #endregion - - #region Ctor - public PluginsController(IPluginManager pluginManager, IPluginFinder pluginFinder, IPluginApplicationBuilderManager pluginApplicationBuilderManager) - { - _pluginManager = pluginManager; - _pluginFinder = pluginFinder; - _pluginApplicationBuilderManager = pluginApplicationBuilderManager; - } - #endregion - - #region Actions - - #region 插件列表 - /// - /// 加载插件列表 - /// - /// 插件状态 - /// - [HttpGet, HttpPost] - public async Task> List(string status = "all") - { - BaseResponseModel responseData = new ResponseModel.BaseResponseModel(); - var pluginConfigModel = PluginConfigModelFactory.Create(); - - // 获取所有插件信息 - IList pluginInfoModels = PluginInfoModelFactory.CreateAll(); - IList responseModels = new List(); - string[] enablePluginIds = _pluginFinder.EnablePluginIds().ToArray(); - - // 添加插件状态 - responseModels = PluginInfoModelToResponseModel(pluginInfoModels, pluginConfigModel, enablePluginIds); - #region 筛选插件状态 - switch (status.ToLower()) - { - case "all": - break; - case "enabled": - responseModels = responseModels.Where(m => m.Status == PluginStatus.Enabled).ToList(); - break; - case "disabled": - responseModels = responseModels.Where(m => m.Status == PluginStatus.Disabled).ToList(); - break; - default: - break; - } - #endregion - - responseData.Code = 1; - responseData.Message = "加载插件列表成功"; - responseData.Data = responseModels; - - return await Task.FromResult(responseData); - } - #endregion - - #region 卸载插件 - [HttpGet, HttpPost] - public async Task> Uninstall(string pluginId) - { - BaseResponseModel responseData = new BaseResponseModel(); - pluginId = pluginId.Trim(); - var pluginConfigModel = PluginConfigModelFactory.Create(); - // 卸载插件 必须 先禁用插件 - #region 效验 - if (pluginConfigModel.EnabledPlugins.Contains(pluginId)) - { - responseData.Code = -1; - responseData.Message = "卸载失败: 请先禁用此插件"; - return await Task.FromResult(responseData); - } - string pluginDirStr= Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId); - string pluginWwwrootDirStr = Path.Combine(PluginPathProvider.PluginsWwwRootDir(), pluginId); - if (!Directory.Exists(pluginDirStr) && !Directory.Exists(pluginWwwrootDirStr)) - { - responseData.Code = -2; - responseData.Message = "卸载失败: 此插件不存在"; - return await Task.FromResult(responseData); - } - #endregion - - try - { - // PS:卸载插件必须先禁用插件,所以此时插件LoadContext已被移除释放(插件Assemblies已被释放), 此处不需移除LoadContext - - // 1.删除物理文件 - var pluginDir = new DirectoryInfo(pluginDirStr); - if (pluginDir.Exists) { - pluginDir.Delete(true); - } - // 虽然 已禁用 时 pluginWwwrootDirStr/pluginId 已删除, 但为确保, 还是再删除一次 - var pluginWwwrootDir = new DirectoryInfo(pluginWwwrootDirStr); - if (pluginWwwrootDir.Exists) { - pluginWwwrootDir.Delete(true); - } - - responseData.Code = 1; - responseData.Message = "卸载成功"; - } - catch (Exception ex) - { - responseData.Code = -1; - responseData.Message = "卸载失败: " + ex.Message; - } - - return await Task.FromResult(responseData); - } - #endregion - - #region 启用插件 - [HttpGet, HttpPost] - public async Task> Enable(string pluginId) - { - BaseResponseModel responseData = new BaseResponseModel(); - var pluginConfigModel = PluginConfigModelFactory.Create(); - // 效验是否存在于 已禁用插件列表 - #region 效验 - pluginId = pluginId.Trim(); - var pluginDir = new DirectoryInfo(Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId)); - if (pluginDir != null && !pluginDir.Exists) - { - responseData.Code = -1; - responseData.Message = "启用失败: 此插件不存在"; - return await Task.FromResult(responseData); - } - string[] enablePluginIds = _pluginFinder.EnablePluginIds().ToArray(); - if (enablePluginIds.Contains(pluginId)) { - responseData.Code = -2; - responseData.Message = "启用失败: 此插件已启用"; - return await Task.FromResult(responseData); - } - #endregion - - try - { - // 1. 创建插件程序集加载上下文, 添加到 PluginsLoadContexts - _pluginManager.LoadPlugin(pluginId); - // 2. 添加到 pluginConfigModel.EnabledPlugins - pluginConfigModel.EnabledPlugins.Add(pluginId); - // 4.保存到 plugin.config.json - PluginConfigModelFactory.Save(pluginConfigModel); - - // 5. 找到此插件实例 - IPlugin plugin = _pluginFinder.Plugin(pluginId); - if (plugin == null) - { - // 7.启用不成功, 回滚插件状态: (1)释放插件上下文 (2)更新 plugin.config.json - try - { - _pluginManager.UnloadPlugin(pluginId); - } - catch (Exception ex) - { } - - // 从 pluginConfigModel.EnabledPlugins 移除 - pluginConfigModel.EnabledPlugins.Remove(pluginId); - // 保存到 plugin.config.json - PluginConfigModelFactory.Save(pluginConfigModel); - - responseData.Code = -1; - responseData.Message = "启用失败: 此插件不存在"; - return await Task.FromResult(responseData); - } - // 6.调取插件的 AfterEnable(), 插件开发者可在此回收资源 - var pluginEnableResult = plugin.AfterEnable(); - if (!pluginEnableResult.IsSuccess) - { - // 7.启用不成功, 回滚插件状态: (1)释放插件上下文 (2)更新 plugin.config.json - try - { - _pluginManager.UnloadPlugin(pluginId); - } - catch (Exception ex) - { } - - // 从 pluginConfigModel.EnabledPlugins 移除 - pluginConfigModel.EnabledPlugins.Remove(pluginId); - // 保存到 plugin.config.json - PluginConfigModelFactory.Save(pluginConfigModel); - - responseData.Code = -1; - responseData.Message = "启用失败: 来自插件的错误信息: " + pluginEnableResult.Message; - return await Task.FromResult(responseData); - } - - // 7. ReBuild - this._pluginApplicationBuilderManager.ReBuild(); - - // 8. 尝试复制 插件下的 wwwroot 到 Plugins_wwwroot - string wwwRootDir = PluginPathProvider.WwwRootDir(pluginId); - if (Directory.Exists(wwwRootDir)) - { - string targetDir = PluginPathProvider.PluginWwwRootDir(pluginId); - Utils.FileUtil.CopyFolder(wwwRootDir, targetDir); - } - - responseData.Code = 1; - // responseData.Message = "启用成功"; - responseData.Message = pluginEnableResult.Message; - } - catch (Exception ex) - { - responseData.Code = -2; - responseData.Message = "启用失败: " + ex.Message; - Utils.LogUtil.Error(ex, ex.Message); - } - - return await Task.FromResult(responseData); - } - #endregion - - #region 禁用插件 - [HttpGet, HttpPost] - public async Task> Disable(string pluginId) - { - BaseResponseModel responseData = new BaseResponseModel(); - #region 效验 - pluginId = pluginId.Trim(); - var pluginConfigModel = PluginConfigModelFactory.Create(); - // string[] enablePluginIds = _pluginFinder.EnablePluginIds().ToArray(); - // // 效验是否存在于 已启用插件列表 - // if (!enablePluginIds.Contains(pluginId)) - // { - // responseData.Code = -1; - // responseData.Message = "禁用失败: 此插件不存在, 或未启用"; - // return await Task.FromResult(responseData); - // } - #endregion - - try - { - // 1. 找到此插件实例 - IPlugin plugin = _pluginFinder.Plugin(pluginId); - if (plugin == null) - { - responseData.Code = -1; - responseData.Message = "禁用失败: 此插件不存在, 或未启用"; - return await Task.FromResult(responseData); - } - string pluginDisableResultMessage = ""; - try - { - // 2.调取插件的 BeforeDisable(), 插件开发者可在此回收资源 - var pluginDisableResult = plugin.BeforeDisable(); - pluginDisableResultMessage = pluginDisableResult.Message; - if (!pluginDisableResult.IsSuccess) - { - responseData.Code = -1; - responseData.Message = "禁用失败: 来自插件的错误信息: " + pluginDisableResult.Message; - return await Task.FromResult(responseData); - } - // 3.移除插件对应的程序集加载上下文 - _pluginManager.UnloadPlugin(pluginId); - // 3.1. ReBuild - this._pluginApplicationBuilderManager.ReBuild(); - if (pluginConfigModel.EnabledPlugins.Contains(pluginId)) { - // 4.从 pluginConfigModel.EnabledPlugins 移除 - pluginConfigModel.EnabledPlugins.Remove(pluginId); - // 5.保存到 plugin.config.json - PluginConfigModelFactory.Save(pluginConfigModel); - } - } - catch (Exception ex) - { - Utils.LogUtil.Error(ex, ex.Message); - responseData.Code = -1; - responseData.Message = "禁用失败: 此插件不存在, 或未启用"; - return await Task.FromResult(responseData); - } - - // 7. 尝试移除 Plugins_wwwroot/PluginId - string pluginWwwRootDir = PluginPathProvider.PluginWwwRootDir(pluginId); - if (Directory.Exists(pluginWwwRootDir)) - { - Directory.Delete(pluginWwwRootDir, true); - } - - - responseData.Code = 1; - // responseData.Message = "禁用成功"; - responseData.Message = pluginDisableResultMessage; - } - catch (Exception ex) - { - responseData.Code = -2; - responseData.Message = "禁用失败: " + ex.Message; - Utils.LogUtil.Error(ex, ex.Message); - } - - return await Task.FromResult(responseData); - } - #endregion - - #region 上传插件 - /// - /// 上传插件 - /// - /// 注意: 参数名一定为 file, 对应前端传过来时以 file 为名 - /// - [HttpGet, HttpPost] - public async Task> Upload(IFormFile file) - { - BaseResponseModel responseData = new BaseResponseModel(); - - #region 效验 - if (file == null) - { - responseData.Code = -1; - responseData.Message = "上传的文件不能为空"; - return responseData; - } - //文件后缀 - string fileExtension = Path.GetExtension(file.FileName);//获取文件格式,拓展名 - // 类型标记 - UploadFileType uploadFileType = UploadFileType.NoAllowedType; - switch (fileExtension) - { - case ".zip": - uploadFileType = UploadFileType.Zip; - break; - case ".nupkg": - uploadFileType = UploadFileType.Nupkg; - break; - } - - if (fileExtension != ".zip" && fileExtension != ".nupkg") - { - responseData.Code = -1; - // nupkg 其实就是 zip - responseData.Message = "只能上传 zip 或 nupkg 格式文件"; - return responseData; - } - // PluginCore.AspNetCore-v1.0.2 起 不再限制插件上传大小 - //判断文件大小 - //var fileSize = file.Length; - //if (fileSize > 1024 * 1024 * 5) // 5M - //{ - // responseData.Code = -1; - // responseData.Message = "上传的文件不能大于5MB"; - // return responseData; - //} - #endregion - - try - { - // 1.先上传到 临时插件上传目录, 用Guid.zip作为保存文件名 - string tempZipFilePath = Path.Combine(PluginPathProvider.TempPluginUploadDir(), Guid.NewGuid() + ".zip"); - using (var fs = System.IO.File.Create(tempZipFilePath)) - { - file.CopyTo(fs); //将上传的文件文件流,复制到fs中 - fs.Flush();//清空文件流 - } - // 2.解压 - bool isDecomparessSuccess = false; - if (uploadFileType == UploadFileType.Zip) - { - isDecomparessSuccess = Utils.ZipHelper.DecomparessFile(tempZipFilePath, tempZipFilePath.Replace(".zip", "")); - } - else if (uploadFileType == UploadFileType.Nupkg) - { - isDecomparessSuccess = NupkgService.DecomparessFile(tempZipFilePath, tempZipFilePath.Replace(".zip", "")); - } - - // 3.删除原压缩包 - System.IO.File.Delete(tempZipFilePath); - if (!isDecomparessSuccess) - { - responseData.Code = -1; - responseData.Message = "解压插件压缩包失败"; - return responseData; - } - // 4.读取其中的info.json, 获取 PluginId 值 - PluginInfoModel pluginInfoModel = PluginInfoModelFactory.ReadPluginDir(tempZipFilePath.Replace(".zip", "")); - if (pluginInfoModel == null || string.IsNullOrEmpty(pluginInfoModel.PluginId)) - { - // 记得删除已不再需要的临时插件文件夹 - Directory.Delete(tempZipFilePath.Replace(".zip", ""), true); - - responseData.Code = -1; - responseData.Message = "不合法的插件"; - return responseData; - } - string pluginId = pluginInfoModel.PluginId; - // 5.检索 此 PluginId 是否本地插件已存在 - var pluginConfigModel = PluginConfigModelFactory.Create(); - // 本地已经存在的 PluginId - IList localExistPluginIds = PluginPathProvider.AllPluginFolderName(); - if (localExistPluginIds.Contains(pluginId)) - { - // 记得删除已不再需要的临时插件文件夹 - Directory.Delete(tempZipFilePath.Replace(".zip", ""), true); - - responseData.Code = -1; - responseData.Message = $"本地已有此插件 (PluginId: {pluginId}), 请前往插件列表删除后, 再上传"; - return responseData; - } - // 6.本地无此插件 -> 移动插件文件夹到 Plugins 下, 并以 PluginId 为插件文件夹名 - string pluginsRootPath = PluginPathProvider.PluginsRootPath(); - string newPluginDir = Path.Combine(pluginsRootPath, pluginId); - Directory.Move(tempZipFilePath.Replace(".zip", ""), newPluginDir); - - // 7. 放入 Plugins 中, 默认为 已禁用 - - responseData.Code = 1; - responseData.Message = $"上传插件成功 (PluginId: {pluginId})"; - } - catch (Exception ex) - { - responseData.Code = -1; - responseData.Message = "上传插件失败: " + ex.Message; - ex = ex.InnerException; - while (ex != null) - { - responseData.Message += " - " + ex.InnerException.Message; - ex = ex.InnerException; - } - Utils.LogUtil.Error(ex, ex.Message); - } - - return await Task.FromResult(responseData); - } - #endregion - - #region 查看详细 - [HttpGet, HttpPost] - public async Task> Details(string pluginId) - { - BaseResponseModel responseData = new BaseResponseModel(); - - try - { - #region 效验 - pluginId = pluginId.Trim(); - var pluginConfigModel = PluginConfigModelFactory.Create(); - string[] localPluginIds = PluginPathProvider.AllPluginFolderName().ToArray(); - - if (!localPluginIds.Contains(pluginId)) - { - responseData.Code = -1; - responseData.Message = $"查看详细失败: 不存在 {pluginId} 插件"; - return await Task.FromResult(responseData); - } - - #endregion - - PluginInfoModel pluginInfoModel = PluginInfoModelFactory.Create(pluginId); - string[] enablePluginIds = _pluginFinder.EnablePluginIds().ToArray(); - PluginInfoResponseModel pluginInfoResponseModel = PluginInfoModelToResponseModel(new List() { pluginInfoModel }, pluginConfigModel, enablePluginIds).FirstOrDefault(); - - - responseData.Code = 1; - responseData.Message = "查看详细成功"; - responseData.Data = pluginInfoResponseModel; - } - catch (Exception ex) - { - responseData.Code = -1; - responseData.Message = "查看详细失败: " + ex.Message; - } - - return await Task.FromResult(responseData); - } - #endregion - - #region 查看文档 - [HttpGet, HttpPost] - public async Task> Readme(string pluginId) - { - BaseResponseModel responseData = new BaseResponseModel(); - - try - { - #region 效验 - pluginId = pluginId.Trim(); - // var pluginConfigModel = PluginConfigModelFactory.Create(); - string[] localPluginIds = PluginPathProvider.AllPluginFolderName().ToArray(); - - if (!localPluginIds.Contains(pluginId)) - { - responseData.Code = -1; - responseData.Message = $"查看文档失败: 不存在 {pluginId} 插件"; - return await Task.FromResult(responseData); - } - - #endregion - - PluginReadmeModel readmeModel = PluginReadmeModelFactory.Create(pluginId); - PluginReadmeResponseModel readmeResponseModel = new PluginReadmeResponseModel(); - readmeResponseModel.Content = readmeModel?.Content ?? ""; - readmeResponseModel.PluginId = pluginId; - - responseData.Code = 1; - responseData.Message = "查看文档成功"; - responseData.Data = readmeResponseModel; - } - catch (Exception ex) - { - responseData.Code = -1; - responseData.Message = "查看文档失败: " + ex.Message; - } - - return await Task.FromResult(responseData); - } - #endregion - - #region 设置 - [HttpGet] - public async Task> Settings(string pluginId) - { - BaseResponseModel responseData = new BaseResponseModel(); - - try - { - #region 效验 - pluginId = pluginId.Trim(); - // var pluginConfigModel = PluginConfigModelFactory.Create(); - string[] localPluginIds = PluginPathProvider.AllPluginFolderName().ToArray(); - - if (!localPluginIds.Contains(pluginId)) - { - responseData.Code = -1; - responseData.Message = $"查看设置失败: 不存在 {pluginId} 插件"; - return await Task.FromResult(responseData); - } - - #endregion - - string settingsJsonStr = PluginSettingsModelFactory.Create(pluginId); - - - responseData.Code = 1; - responseData.Message = "查看设置成功"; - responseData.Data = settingsJsonStr ?? "无设置项"; - } - catch (Exception ex) - { - responseData.Code = -1; - responseData.Message = "查看设置失败: " + ex.Message; - } - - return await Task.FromResult(responseData); - } - - [HttpPost] - public async Task> Settings(PluginSettingsInputModel inputModel) - { - BaseResponseModel responseData = new BaseResponseModel(); - - try - { - #region 效验 - inputModel.PluginId = inputModel.PluginId.Trim(); - // var pluginConfigModel = PluginConfigModelFactory.Create(); - string[] localPluginIds = PluginPathProvider.AllPluginFolderName().ToArray(); - - if (!localPluginIds.Contains(inputModel.PluginId)) - { - responseData.Code = -1; - responseData.Message = $"设置失败: 不存在 {inputModel.PluginId} 插件"; - return await Task.FromResult(responseData); - } - - #endregion - - inputModel.Data = inputModel.Data ?? ""; - PluginSettingsModelFactory.Save(pluginSettingsJsonStr: inputModel.Data, pluginId: inputModel.PluginId); - - - responseData.Code = 1; - responseData.Message = "设置成功"; - responseData.Data = inputModel.Data; - } - catch (Exception ex) - { - responseData.Code = -1; - responseData.Message = "设置失败: " + ex.Message; - } - - return await Task.FromResult(responseData); - } - #endregion - - #endregion - - - #region Helpers - - [NonAction] - private IList PluginInfoModelToResponseModel(IList pluginInfoModels, PluginConfigModel pluginConfigModel, string[] enablePluginIds) - { - // 获取 Plugins 下所有插件 - // DirectoryInfo pluginsDir = new DirectoryInfo(PluginPathProvider.PluginsRootPath()); - // List pluginIds = pluginsDir?.GetDirectories()?.Select(m => m.Name)?.ToList() ?? new List(); - - IList responseModels = new List(); - #region 添加插件状态信息 - foreach (var model in pluginInfoModels) - { - PluginInfoResponseModel responseModel = new PluginInfoResponseModel(); - responseModel.Author = model.Author; - responseModel.Description = model.Description; - responseModel.DisplayName = model.DisplayName; - responseModel.PluginId = model.PluginId; - responseModel.SupportedVersions = model.SupportedVersions; - responseModel.Version = model.Version; - responseModel.DependPlugins = model.DependPlugins; - - if (pluginConfigModel.EnabledPlugins.Contains(model.PluginId) && !enablePluginIds.Contains(model.PluginId)) { - // 错误情况: 配置 标识 已启用, 但实际没有启用成功 - pluginConfigModel.EnabledPlugins.Remove(model.PluginId); - PluginConfigModelFactory.Save(pluginConfigModel); - - responseModel.Status = PluginStatus.Disabled; - } else if(!pluginConfigModel.EnabledPlugins.Contains(model.PluginId) && enablePluginIds.Contains(model.PluginId)) - { - // 错误情况: 配置没有标识 已启用, 但实际 已启用 - pluginConfigModel.EnabledPlugins.Add(model.PluginId); - PluginConfigModelFactory.Save(pluginConfigModel); - - responseModel.Status = PluginStatus.Enabled; - } else if (pluginConfigModel.EnabledPlugins.Contains(model.PluginId) && enablePluginIds.Contains(model.PluginId)) - { - responseModel.Status = PluginStatus.Enabled; - } - else - { - responseModel.Status = PluginStatus.Disabled; - } - responseModels.Add(responseModel); - } - #endregion - - return responseModels; - } - - public enum UploadFileType - { - NoAllowedType = 0, - Zip = 1, - Nupkg = 2 - } - - #endregion - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/UserController.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/UserController.cs deleted file mode 100644 index fa6193ed..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Controllers忽略/UserController.cs +++ /dev/null @@ -1,143 +0,0 @@ -//=================================================== -// License: GNU LGPLv3 -// Contributors: yiyungent@gmail.com -// Project: https://yiyungent.github.io/PluginCore -// GitHub: https://github.com/yiyungent/PluginCore -//=================================================== - - - -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using PluginCore.AspNetCore.Authorization; -using PluginCore.Config; -using PluginCore.AspNetCore.RequestModel.User; -using PluginCore.AspNetCore.ResponseModel; - -namespace PluginCore.AspNetCore.Controllers -{ - [Route("api/plugincore/admin/[controller]/[action]")] - [ApiController] - public class UserController : ControllerBase - { - private readonly AccountManager _accountManager; - - public string RemoteFronted - { - get - { - return PluginCore.Config.PluginCoreConfigFactory.Create().RemoteFrontend; - } - } - - public UserController(AccountManager accountManager) - { - _accountManager = accountManager; - } - - [HttpGet, HttpPost] - public async Task> Login([FromBody] LoginRequestModel requestModel) - { - BaseResponseModel responseModel = new BaseResponseModel(); - - try - { - string token = AccountManager.CreateToken(requestModel.UserName, requestModel.Password); - bool isAdmin = AccountManager.IsAdminToken(token); - if (!isAdmin) - { - responseModel.Code = -1; - responseModel.Message = "用户名或密码不正确"; - - return await Task.FromResult(responseModel); - } - - responseModel.Code = 1; - responseModel.Message = "登录成功"; - responseModel.Data = new - { - token = token, - userName = requestModel.UserName - }; - } - catch (Exception ex) - { - responseModel.Code = -1; - responseModel.Message = "失败: " + ex.Message; - } - - return await Task.FromResult(responseModel); - } - - [HttpGet, HttpPost] - public async Task> Logout() - { - BaseResponseModel responseModel = new BaseResponseModel() - { - Code = 1, - Message = "退出登录成功" - }; - - return await Task.FromResult(responseModel); - } - - [PluginCoreAdminAuthorize] - [HttpGet, HttpPost] - public async Task> Info() - { - BaseResponseModel responseModel = new BaseResponseModel(); - - try - { - string adminUserName = PluginCoreConfigFactory.Create().Admin.UserName; - - responseModel.Code = 1; - responseModel.Message = "成功"; - responseModel.Data = new - { - name = adminUserName, - //avatar = this.RemoteFronted + "/images/avatar.gif" - avatar = "" - }; - } - catch (Exception ex) - { - responseModel.Code = -1; - responseModel.Message = "失败: " + ex.Message; - } - - return await Task.FromResult(responseModel); - } - - [PluginCoreAdminAuthorize] - [HttpGet, HttpPost] - public async Task> Update([FromBody] UpdateRequestModel requestModel) - { - BaseResponseModel responseModel = new BaseResponseModel(); - - try - { - PluginCoreConfig pluginCoreConfig = PluginCoreConfigFactory.Create(); - pluginCoreConfig.Admin.UserName = requestModel.UserName; - pluginCoreConfig.Admin.Password = requestModel.Password; - PluginCoreConfigFactory.Save(pluginCoreConfig); - - responseModel.Code = 1; - responseModel.Message = "修改成功, 需要重新登录"; - } - catch (Exception ex) - { - responseModel.Code = -1; - responseModel.Message = "失败: " + ex.Message; - } - - return await Task.FromResult(responseModel); - } - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Extensions/IServiceProviderExtensions.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Extensions/IServiceProviderExtensions.cs deleted file mode 100644 index 0c4d8826..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Extensions/IServiceProviderExtensions.cs +++ /dev/null @@ -1,158 +0,0 @@ -// Admin.NET ĿİȨ̱ꡢרȨӦɷıʹñĿӦطɷ֤Ҫ -// -// ĿҪѭ MIT ֤ Apache ֤汾 2.0зַʹá֤λԴĿ¼е LICENSE-MIT LICENSE-APACHE ļ -// -// ñĿΣҰȫַ˺ϷȨȷɷֹĻκλڱĿοһзɾ׺ΣDzеκΣ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using System.Text; -using Microsoft.Extensions.DependencyInjection; - -namespace PluginCore.AspNetCore.Extensions -{ - public static class IServiceProviderExtensions - { - /// - /// Get all registered - /// - /// - /// - public static Dictionary GetAllServiceDescriptors(this IServiceProvider provider) - { - var serviceProvider = provider.GetPropertyValue("RootProvider"); - var result = new Dictionary(); - - var engine = serviceProvider.GetFieldValue("_engine"); - // var callSiteFactory = engine.GetPropertyValue("CallSiteFactory"); - var callSiteFactory = serviceProvider.GetPropertyValue("CallSiteFactory"); - var descriptorLookup = callSiteFactory.GetFieldValue("_descriptorLookup"); - if (descriptorLookup is IDictionary dictionary) - { - foreach (DictionaryEntry entry in dictionary) - { - result.Add((Type)entry.Key, (ServiceDescriptor)entry.Value.GetPropertyValue("Last")); - } - } - - return result; - - #region Old - //if (provider is ServiceProvider serviceProvider) - //{ - // var result = new Dictionary(); - - // var engine = serviceProvider.GetFieldValue("_engine"); - // var callSiteFactory = engine.GetPropertyValue("CallSiteFactory"); - // var descriptorLookup = callSiteFactory.GetFieldValue("_descriptorLookup"); - // if (descriptorLookup is IDictionary dictionary) - // { - // foreach (DictionaryEntry entry in dictionary) - // { - // result.Add((Type)entry.Key, (ServiceDescriptor)entry.Value.GetPropertyValue("Last")); - // } - // } - - // return result; - //} - - //throw new NotSupportedException($"Type '{provider.GetType()}' is not supported!"); - #endregion - } - } - - public static class ReflectionHelper - { - // ########################################################################################## - // Get / Set Field - // ########################################################################################## - - #region Get / Set Field - - public static object GetFieldValue(this object obj, string fieldName) - { - if (obj == null) - throw new ArgumentNullException(nameof(obj)); - Type objType = obj.GetType(); - var fieldInfo = GetFieldInfo(objType, fieldName); - if (fieldInfo == null) - throw new ArgumentOutOfRangeException(fieldName, - $"Couldn't find field {fieldName} in type {objType.FullName}"); - return fieldInfo.GetValue(obj); - } - - public static void SetFieldValue(this object obj, string fieldName, object val) - { - if (obj == null) - throw new ArgumentNullException(nameof(obj)); - Type objType = obj.GetType(); - var fieldInfo = GetFieldInfo(objType, fieldName); - if (fieldInfo == null) - throw new ArgumentOutOfRangeException(fieldName, - $"Couldn't find field {fieldName} in type {objType.FullName}"); - fieldInfo.SetValue(obj, val); - } - - private static FieldInfo GetFieldInfo(Type type, string fieldName) - { - FieldInfo fieldInfo = null; - do - { - fieldInfo = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - type = type.BaseType; - } while (fieldInfo == null && type != null); - - return fieldInfo; - } - - #endregion - - // ########################################################################################## - // Get / Set Property - // ########################################################################################## - - #region Get / Set Property - - public static object GetPropertyValue(this object obj, string propertyName) - { - if (obj == null) - throw new ArgumentNullException(nameof(obj)); - Type objType = obj.GetType(); - var propertyInfo = GetPropertyInfo(objType, propertyName); - if (propertyInfo == null) - throw new ArgumentOutOfRangeException(propertyName, - $"Couldn't find property {propertyName} in type {objType.FullName}"); - return propertyInfo.GetValue(obj, null); - } - - public static void SetPropertyValue(this object obj, string propertyName, object val) - { - if (obj == null) - throw new ArgumentNullException(nameof(obj)); - Type objType = obj.GetType(); - var propertyInfo = GetPropertyInfo(objType, propertyName); - if (propertyInfo == null) - throw new ArgumentOutOfRangeException(propertyName, - $"Couldn't find property {propertyName} in type {objType.FullName}"); - propertyInfo.SetValue(obj, val, null); - } - - private static PropertyInfo GetPropertyInfo(Type type, string propertyName) - { - PropertyInfo propertyInfo = null; - do - { - propertyInfo = type.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - type = type.BaseType; - } while (propertyInfo == null && type != null); - - return propertyInfo; - } - - #endregion - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Extensions/PluginCoreStartupExtensions.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Extensions/PluginCoreStartupExtensions.cs deleted file mode 100644 index 6b03a645..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Extensions/PluginCoreStartupExtensions.cs +++ /dev/null @@ -1,415 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using PluginCore.Models; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Mvc.Infrastructure; -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text.Json; -using System.Text.Json.Serialization; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.FileProviders; -using PluginCore.AspNetCore.Authorization; -using PluginCore.AspNetCore.AdminUI; -using PluginCore.Infrastructure; -using PluginCore.Interfaces; -using PluginCore.AspNetCore.Middlewares; -using PluginCore.AspNetCore.BackgroundServices; -using PluginCore.IPlugins; -using PluginCore.AspNetCore.Interfaces; -using PluginCore.lmplements; -using PluginCore.AspNetCore.lmplements; - -namespace PluginCore.AspNetCore.Extensions -{ - /// - /// - /// - public static class PluginCoreStartupExtensions - { - private static IWebHostEnvironment _webHostEnvironment; - - private static IServiceCollection _services; - - private static IServiceProvider _serviceProvider; - - /// - /// 若需要替换默认实现, 请在 之前, 若在之后, 则无法影响 主程序启动时默认行为 - /// - /// - public static void AddPluginCore(this IServiceCollection services) - { - services.AddPluginCoreServices(); - - services.AddPluginCoreLog(); - - services.AddPluginCorePlugins(); - - #region PluginCore Admin 权限 - // 1. 先 Authentication (我是谁) 2. 再 Authorization (我能做什么) - - // Authentication - //注销内置认证 by tomny - // services.AddPluginCoreAuthentication(); - //注销内置授权 by tomny - // Authorization - //services.AddPluginCoreAuthorization(); - #endregion - - services.AddPluginCoreStartupPlugin(); - - // AddBackgroundServices - services.AddBackgroundServices(); - - // 一定要在最后 - _services = services; - _serviceProvider = services.BuildServiceProvider(); - } - - public static IApplicationBuilder UsePluginCore(this IApplicationBuilder app) - { - // 一定在 PluginCore 添加的中间件中 第一个 - app.UseMiddleware(); - - app.UsePluginCoreLanguageMiddleware(); - //注销内置管理页面 by tomny - // app.UsePluginCoreAdminUI(); - - app.UsePluginCoreStaticFiles(); - - // 发现 UseAuthentication 认证中间件重复添加, 也只会执行一次 认证 - // 但 UseAuthorization 重复添加2次, 则会执行 2次 授权 - //注销内置认证授权 by tomny - //app.UseAuthentication(); - //app.UseAuthorization(); - - #region Plugin Middleware - // Plugin Middleware - //app.UseMiddleware(); - - - // 一定在 PluginCore 添加的中间件中 最后一个 - app.UseMiddleware(); - #endregion - - app.UsePluginCoreStartupPlugin(); - - app.UsePluginCoreAppStart(); - - // Log - app.UsePluginCoreLog(); - - return app; - } - - - public static void AddPluginCoreServices(this IServiceCollection services) - { - #region 注册服务 - - #region 仅适用于 ASP.NET Core - // start: 仅用于 ASP.NET Core - // 用于添加插件Controller 时,通知Controller.Action发生变化 - services.AddSingleton(PluginActionDescriptorChangeProvider.Instance); - services.AddSingleton(PluginActionDescriptorChangeProvider.Instance); - - services.TryAddTransient(); - services.TryAddTransient(); - - services.TryAddTransient(); - services.TryAddTransient(); - // end: 仅用于 ASP.NET Core - #endregion - - #region 通用 - - // v1 旧版 - //services.TryAddTransient(); - //services.TryAddTransient(); - //services.TryAddTransient(); - //services.TryAddTransient(); - - services.TryAddTransient(); - services.TryAddTransient(); - //注销内置插件管理 by tomny - services.TryAddTransient(); - services.TryAddTransient(); - - services.TryAddTransient(); - services.TryAddTransient(); - services.TryAddTransient(); - services.TryAddTransient(); - - // 注意: 它必须单例 - // TODO: 不知道原因, 单例失败, 每次 获取 IPluginFinder 都会获取新的 IPluginContextManager - services.TryAddSingleton(); - services.TryAddSingleton(); - #endregion - - #endregion - - // ************************* 注意: IServiceCollection 是服务列表, 但由 IServiceProvider 来负责解析, AClass 单例 仅在 AServiceProvider 范围内 - _serviceProvider = services.BuildServiceProvider(); - } - - public static void AddPluginCorePlugins(this IServiceCollection services) - { - #region ASP.NET Core - //IPluginManager pluginManager = services.BuildServiceProvider().GetService(); - IPluginManager pluginManager = _serviceProvider.GetService(); - - // 初始化 PluginCore 相关目录 - PluginPathProvider.PluginsRootPath(); - - // 在程序启动时加载所有 已安装并启用 的插件 - - // 获取 PluginConfigModel - #region 获取 PluginConfigModel - PluginConfigModel pluginConfigModel = PluginConfigModelFactory.Create(); - #endregion - - // 已启用的插件 - #region 加载 已启用插件的Assemblies - IList enabledPluginIds = pluginConfigModel.EnabledPlugins; - foreach (var pluginId in enabledPluginIds) - { - pluginManager.LoadPlugin(pluginId); - } - #endregion - - //注销内置Controller的注册 by tomny - // 将本 Assembly 内的 Controller 添加 - // var ass = Assembly.GetExecutingAssembly(); - //IPluginControllerManager pluginControllerManager = services.BuildServiceProvider().GetService(); - // IPluginControllerManager pluginControllerManager = _serviceProvider.GetService(); - //pluginControllerManager.AddControllers(ass); - - - // IWebHostEnvironment - _webHostEnvironment = services.BuildServiceProvider().GetService(); - #endregion - } - - public static void AddPluginCoreAuthentication(this IServiceCollection services) - { - // fixed: https://github.com/yiyungent/PluginCore/issues/4 - // System.InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found. The default schemes can be set using either AddAuthentication(string defaultScheme) or AddAuthentication(Action configureOptions). - #region 添加认证 Authentication - // 没通过 Authentication: 401 Unauthorized - // services.AddAuthentication("PluginCore.Authentication") - // .AddScheme("PluginCore.Authentication", "PluginCore.Authentication", - // options => { }); - // 注意: 不要设置 默认 认证名: Constants.AspNetCoreAuthenticationScheme - // services.AddAuthentication(Constants.AspNetCoreAuthenticationScheme) - // 默认认证名: 默认 - services.AddAuthentication() - // 添加一个新的认证方案 - .AddScheme( - authenticationScheme: Constants.AspNetCoreAuthenticationScheme, - displayName: Constants.AspNetCoreAuthenticationScheme, - options => { }); - #endregion - } - - public static void AddPluginCoreAuthorization(this IServiceCollection services) - { - #region 添加授权策略-所有标记 [PluginCoreAdminAuthorize] 都需要权限检查 - // Only Once, Not recommend - //services.AddSingleton(); - - services.AddAuthorization(options => - { - // options.AddPolicy("PluginCore.Admin", policy => - options.AddPolicy(name: Constants.AspNetCoreAuthorizationPolicyName, policy => - { - // 无法满足 下方任何一项:HTTP 403 错误 - // 3.需要 检查是否拥有当前请求资源的权限 - //policy.Requirements.Add(new PluginCoreAdminRequirement()); - policy.AuthenticationSchemes = new string[] { - Constants.AspNetCoreAuthenticationScheme - }; - policy.RequireAuthenticatedUser(); - policy.RequireClaim(claimType: Constants.AspNetCoreAuthenticationClaimType); - // 必须重启才能使得更改密码生效 - string token = AccountManager.CreateToken(); - policy.RequireClaim(claimType: Constants.AspNetCoreAuthenticationClaimType, allowedValues: new string[] { - token - }); - //policy.RequireAssertion(context => - //{ - // return true; - //}); - }); - }); - #endregion - - // AccountManager - services.AddTransient(); - // HttpContext.Current - services.TryAddSingleton(); - //services.AddHttpContextAccessor(); - } - - public static void AddPluginCoreStartupPlugin(this IServiceCollection services) - { - //IPluginFinder pluginFinder = services.BuildServiceProvider().GetService(); - IPluginFinder pluginFinder = _serviceProvider.GetService(); - - #region IStartupPlugin - - var plugins = pluginFinder.EnablePlugins()?.OrderBy(m => m.ConfigureServicesOrder)?.ToList(); - - foreach (var item in plugins) - { - // 调用 - Utils.LogUtil.Info( - categoryName: $"{nameof(PluginCoreStartupExtensions)}.{nameof(AddPluginCoreStartupPlugin)}", - message: $"{item.GetType().ToString()}: {nameof(IStartupPlugin)}.{nameof(IStartupPlugin.ConfigureServices)}" - ); - - item?.ConfigureServices(services); - } - - #endregion - } - - public static void AddPluginCoreLog(this IServiceCollection services) - { - #region Logger - - IServiceScopeFactory serviceScopeFactory = _serviceProvider.GetService(); - Utils.LogUtil.Initialize(serviceScopeFactory); - - #endregion - } - - public static IApplicationBuilder UsePluginCoreStaticFiles(this IApplicationBuilder app) - { - // TODO: 其实由于目前已实现运行时动态新增/删除 HTTP Middleware, 其实可以不用再像下方这么复制插件 wwwroot 目录到 Plugins_wwwroot/{PluginId} - // 而是在运行时配置, 直接指向 `Plugins/{PluginId}/wwwroot`, 而无需复制/删除 - - // 注意:`UseDefaultFiles`必须在`UseStaticFiles`之前进行调用。因为`DefaultFilesMiddleware`仅仅负责重写Url,实际上默认页文件,仍然是通过`StaticFilesMiddleware`来提供的。 - - string pluginwwwrootDir = PluginPathProvider.PluginsWwwRootDir(); - - #region 插件 wwwroot 默认页 - // 设置目录的默认页 - var defaultFilesOptions = new DefaultFilesOptions(); - defaultFilesOptions.DefaultFileNames.Clear(); - // 指定默认页名称 - defaultFilesOptions.DefaultFileNames.Add("index.html"); - // 指定请求路径 - defaultFilesOptions.RequestPath = "/Plugins"; - // 指定默认页所在的目录 - defaultFilesOptions.FileProvider = new PhysicalFileProvider(pluginwwwrootDir); - app.UseDefaultFiles(defaultFilesOptions); - #endregion - - #region 插件 wwwroot - // 由于没办法在运行时, 动态 UseStaticFiles(), 因此不再为每一个插件都 UseStaticFiles(), - // 而是统一在一个文件夹下, 插件启用时, 将插件的wwwroot复制到 Plugins_wwwroot/{PluginId}, 禁用时, 再删除 - app.UseStaticFiles(new StaticFileOptions - { - FileProvider = new PhysicalFileProvider( - pluginwwwrootDir), - RequestPath = "/Plugins" - }); - #endregion - - return app; - } - - public static IApplicationBuilder UsePluginCoreAppStart(this IApplicationBuilder app) - { - //IPluginFinder pluginFinder = _services.BuildServiceProvider().GetService(); - IPluginFinder pluginFinder = _serviceProvider.GetService(); - - #region AppStart - - var plugins = pluginFinder.EnablePluginsFull()?.ToList(); - var dependencySorter = new PluginCore.Utils.DependencySorter(); - dependencySorter.AddObjects(plugins.Select(m => m.PluginInstance).ToArray()); - foreach (var item in plugins) - { - var dependPlugins = plugins.Where(m => item.PluginInstance.AppStartOrderDependPlugins.Contains(m.PluginId)).Select(m => m.PluginInstance).ToArray(); - dependencySorter.SetDependencies(obj: item.PluginInstance, dependsOnObjects: dependPlugins); - } - var sortedPlugins = dependencySorter.Sort(); - foreach (var item in sortedPlugins) - { - // 调用 - //Utils.LogUtil.PluginBehavior(item, typeof(IPlugin), nameof(IPlugin.AppStart)); - Utils.LogUtil.Info( - categoryName: $"{nameof(PluginCoreStartupExtensions)}.{nameof(UsePluginCoreAppStart)}", - message: $"{item.GetType().ToString()}: {nameof(IPlugin)}.{nameof(IPlugin.AppStart)}" - ); - - item?.AppStart(); - } - - #endregion - - return app; - } - - public static IApplicationBuilder UsePluginCoreStartupPlugin(this IApplicationBuilder app) - { - //IPluginFinder pluginFinder = _services.BuildServiceProvider().GetService(); - IPluginFinder pluginFinder = _serviceProvider.GetService(); - - #region IStartupPlugin - - var startupPlugins = pluginFinder.EnablePlugins()?.OrderBy(m => m.ConfigureOrder)?.ToList(); - - foreach (var item in startupPlugins) - { - // 调用 - //Utils.LogUtil.PluginBehavior(item, typeof(IStartupPlugin), nameof(IStartupPlugin.Configure)); - Utils.LogUtil.Info( - categoryName: $"{nameof(PluginCoreStartupExtensions)}.{nameof(UsePluginCoreStartupPlugin)}", - message: $"{item.GetType().ToString()}: {nameof(IStartupPlugin)}.{nameof(IStartupPlugin.Configure)}" - ); - - item?.Configure(app); - } - - #endregion - - - app.UseMiddleware(); - - return app; - } - - public static IApplicationBuilder UsePluginCoreLog(this IApplicationBuilder app) - { - #region 启动 Log - Config.PluginCoreConfig pluginCoreConfig = Config.PluginCoreConfigFactory.Create(); - - Utils.LogUtil.Info(categoryName: $"{nameof(PluginCoreStartupExtensions)}.{nameof(UsePluginCoreLog)}", $"{nameof(PluginCore.AspNetCore)}"); - Utils.LogUtil.Info(categoryName: $"{nameof(PluginCoreStartupExtensions)}.{nameof(UsePluginCoreLog)}", "Started successfully:"); - Utils.LogUtil.Info(categoryName: $"{nameof(PluginCoreStartupExtensions)}.{nameof(UsePluginCoreLog)}", $"Front-end mode: {pluginCoreConfig.FrontendMode}"); - Utils.LogUtil.Info(categoryName: $"{nameof(PluginCoreStartupExtensions)}.{nameof(UsePluginCoreLog)}", $"Notice: Updating the front-end mode requires restarting the site"); - #endregion - - return app; - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Infrastructure/PluginApplicationBuilder.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Infrastructure/PluginApplicationBuilder.cs deleted file mode 100644 index 979c0fc1..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Infrastructure/PluginApplicationBuilder.cs +++ /dev/null @@ -1,349 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Features; -using Microsoft.Extensions.Internal; - -namespace PluginCore.AspNetCore.Infrastructure -{ - /// - /// Default implementation for . - /// - /// https://github.com/dotnet/aspnetcore/blob/main/src/Http/Http/src/Builder/ApplicationBuilder.cs - /// - public class PluginApplicationBuilder : IApplicationBuilder - { - private const string ServerFeaturesKey = "server.Features"; - private const string ApplicationServicesKey = "application.Services"; - - private readonly List> _components = new List>(); - - private Action _reachEndAction; - - public Action ReachEndAction - { - get - { - return this._reachEndAction; - } - set - { - this._reachEndAction = value; - } - } - - public PluginApplicationBuilder() - { - - } - - /// - /// Initializes a new instance of . - /// - /// The for application services. - public PluginApplicationBuilder(IServiceProvider serviceProvider, Action reachEndAction) - { - Properties = new Dictionary(StringComparer.Ordinal); - ApplicationServices = serviceProvider; - - _reachEndAction = reachEndAction; - } - - /// - /// Initializes a new instance of . - /// - /// The for application services. - /// The server instance that hosts the application. - public PluginApplicationBuilder(IServiceProvider serviceProvider, Action reachEndAction, object server) - : this(serviceProvider, reachEndAction) - { - SetProperty(ServerFeaturesKey, server); - } - - private PluginApplicationBuilder(PluginApplicationBuilder builder) - { - Properties = new CopyOnWriteDictionary(builder.Properties, StringComparer.Ordinal); - } - - /// - /// Gets the for application services. - /// - public IServiceProvider ApplicationServices - { - get - { - //return GetProperty(ApplicationServicesKey)!; - return null; - } - set - { - SetProperty(ApplicationServicesKey, value); - } - } - - /// - /// Gets the for server features. - /// - public IFeatureCollection ServerFeatures - { - get - { - // ! (null 包容)运算符(C# 参考) - // https://docs.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/null-forgiving - // TODO: 报错 - //var result = GetProperty(ServerFeaturesKey)!; - - IFeatureCollection rtn = null; - - return rtn; - } - } - - /// - /// Gets a set of properties for . - /// - public IDictionary Properties { get; } - - //private T? GetProperty(string key) - //{ - - // return Properties.TryGetValue(key, out var value) ? (T?)value : default(T); - //} - - private void SetProperty(string key, T value) - { - Properties[key] = value; - } - - /// - /// Adds the middleware to the application request pipeline. - /// - /// The middleware. - /// An instance of after the operation has completed. - public IApplicationBuilder Use(Func middleware) - { - _components.Add(middleware); - return this; - } - - /// - /// Creates a copy of this application builder. - /// - /// The created clone has the same properties as the current instance, but does not copy - /// the request pipeline. - /// - /// - /// The cloned instance. - public IApplicationBuilder New() - { - return new PluginApplicationBuilder(this); - } - - /// - /// Produces a that executes added middlewares. - /// - /// The . - public RequestDelegate Build() - { - RequestDelegate app = context => - { - #region Old - // If we reach the end of the pipeline, but we have an endpoint, then something unexpected has happened. - // This could happen if user code sets an endpoint, but they forgot to add the UseEndpoint middleware. - //var endpoint = context.GetEndpoint(); - //var endpointRequestDelegate = endpoint?.RequestDelegate; - //if (endpointRequestDelegate != null) - //{ - // var message = - // $"The request reached the end of the pipeline without executing the endpoint: '{endpoint!.DisplayName}'. " + - // $"Please register the EndpointMiddleware using '{nameof(IApplicationBuilder)}.UseEndpoints(...)' if using " + - // $"routing."; - // throw new InvalidOperationException(message); - //} - #endregion - - this._reachEndAction(); - - //context.Response.StatusCode = StatusCodes.Status404NotFound; - return Task.CompletedTask; - }; - - for (var c = _components.Count - 1; c >= 0; c--) - { - app = _components[c](app); - } - - return app; - } - } - - - - /// - /// https://github.com/dotnet/aspnetcore/blob/8b30d862de6c9146f466061d51aa3f1414ee2337/src/Shared/CopyOnWriteDictionary/CopyOnWriteDictionary.cs - /// - /// - /// - internal class CopyOnWriteDictionary : IDictionary where TKey : notnull - { - private readonly IDictionary _sourceDictionary; - private readonly IEqualityComparer _comparer; - private IDictionary? _innerDictionary; - - public CopyOnWriteDictionary( - IDictionary sourceDictionary, - IEqualityComparer comparer) - { - if (sourceDictionary == null) - { - throw new ArgumentNullException(nameof(sourceDictionary)); - } - - if (comparer == null) - { - throw new ArgumentNullException(nameof(comparer)); - } - - _sourceDictionary = sourceDictionary; - _comparer = comparer; - } - - private IDictionary ReadDictionary - { - get - { - return _innerDictionary ?? _sourceDictionary; - } - } - - private IDictionary WriteDictionary - { - get - { - if (_innerDictionary == null) - { - _innerDictionary = new Dictionary(_sourceDictionary, - _comparer); - } - - return _innerDictionary; - } - } - - public virtual ICollection Keys - { - get - { - return ReadDictionary.Keys; - } - } - - public virtual ICollection Values - { - get - { - return ReadDictionary.Values; - } - } - - public virtual int Count - { - get - { - return ReadDictionary.Count; - } - } - - public virtual bool IsReadOnly - { - get - { - return false; - } - } - - public virtual TValue this[TKey key] - { - get - { - return ReadDictionary[key]; - } - set - { - WriteDictionary[key] = value; - } - } - - public virtual bool ContainsKey(TKey key) - { - return ReadDictionary.ContainsKey(key); - } - - public virtual void Add(TKey key, TValue value) - { - WriteDictionary.Add(key, value); - } - - public virtual bool Remove(TKey key) - { - return WriteDictionary.Remove(key); - } - - public virtual bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) - { - return ReadDictionary.TryGetValue(key, out value); - } - - public virtual void Add(KeyValuePair item) - { - WriteDictionary.Add(item); - } - - public virtual void Clear() - { - WriteDictionary.Clear(); - } - - public virtual bool Contains(KeyValuePair item) - { - return ReadDictionary.Contains(item); - } - - public virtual void CopyTo(KeyValuePair[] array, int arrayIndex) - { - ReadDictionary.CopyTo(array, arrayIndex); - } - - public bool Remove(KeyValuePair item) - { - return WriteDictionary.Remove(item); - } - - public virtual IEnumerator> GetEnumerator() - { - return ReadDictionary.GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } - - - -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Infrastructure/PluginCoreHostingStartup.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Infrastructure/PluginCoreHostingStartup.cs deleted file mode 100644 index c133a1b1..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Infrastructure/PluginCoreHostingStartup.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; -using PluginCore.AspNetCore.Extensions; - -[assembly: HostingStartup(typeof(PluginCore.AspNetCore.Infrastructure.PluginCoreHostingStartup))] -namespace PluginCore.AspNetCore.Infrastructure -{ - /// - /// https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/host/platform-specific-configuration?view=aspnetcore-5.0 - /// - public class PluginCoreHostingStartup : IHostingStartup - { - public PluginCoreHostingStartup() - { - - } - - public void Configure(IWebHostBuilder builder) - { - //builder.ConfigureAppConfiguration(config => - //{ - - //}); - - // 注意: 无论是通过 Program.cs 中 webBuilder.UseSetting(WebHostDefaults.HostingStartupAssembliesKey, "PluginCore"); - // 还是 通过环境变量 指定承载启动程序集, 都是先执行 外部的承载启动程序集, 再执行主程序的 Startup.cs, 因此在这时, 有些 service 还没有注册 - - // TODO: 不知道, 重复 Add, Use 会导致什么, 没有做防止重复 - builder.ConfigureServices(services => - { - // fixed: https://github.com/yiyungent/PluginCore/issues/1 - // System.InvalidOperationException: 'Unable to resolve service for type 'Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager' - // TODO: 不确定, 这样是否可行, 事实上之后主程序还会 Add 一次, 不知道是否会导致存在多个 实例 - // 失败: 不是一个实例, 导致无法改变 Controller - //Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager applicationPartManager = - // new Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager(); - //services.AddSingleton(applicationPartManager); - - services.AddPluginCore(); - }); - - builder.Configure(app => - { - app.UsePluginCore(); - }); - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Interfaces/IPluginApplicationBuilderManager.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Interfaces/IPluginApplicationBuilderManager.cs deleted file mode 100644 index 7b8b12ab..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Interfaces/IPluginApplicationBuilderManager.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using Microsoft.AspNetCore.Http; -using System; -using System.Collections.Generic; -using System.Text; - -namespace PluginCore.AspNetCore.Interfaces -{ - public interface IPluginApplicationBuilderManager - { - void ReBuild(); - - RequestDelegate GetBuildResult(); - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Interfaces/IPluginControllerManager.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Interfaces/IPluginControllerManager.cs deleted file mode 100644 index 55c08689..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Interfaces/IPluginControllerManager.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Text; - -namespace PluginCore.AspNetCore.Interfaces -{ - public interface IPluginControllerManager - { - void AddControllers(Assembly assembly); - - void RemoveControllers(string pluginId); - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Middlewares/LanguageMiddleware.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Middlewares/LanguageMiddleware.cs deleted file mode 100644 index ce9dc9d2..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Middlewares/LanguageMiddleware.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using PluginCore.IPlugins; - -namespace PluginCore.AspNetCore.Middlewares -{ - public class LanguageMiddleware - { - private readonly RequestDelegate _next; - - public LanguageMiddleware(RequestDelegate next) - { - _next = next; - } - - public async Task Invoke(HttpContext httpContext) - { - // 从 Cookie 中获取语言标识 - string language = httpContext.Request.Cookies[Constants.AspNetCoreLanguageCookieName]; - - // 存储当前语言到 HttpContext.Items - httpContext.Items[Constants.AspNetCoreLanguageKey] = language; - - // 调用下一个中间件 - await _next(httpContext); - } - } - - public static class LanguageMiddlewareExtensions - { - public static IApplicationBuilder UsePluginCoreLanguageMiddleware(this IApplicationBuilder builder) - { - return builder.UseMiddleware(); - } - } -} diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Middlewares/PluginContentFilterMiddleware.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Middlewares/PluginContentFilterMiddleware.cs deleted file mode 100644 index b92b8a10..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Middlewares/PluginContentFilterMiddleware.cs +++ /dev/null @@ -1,149 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using PluginCore.Interfaces; - -namespace PluginCore.AspNetCore.Middlewares -{ - /// - /// TODO: 未测试 - /// - public class PluginContentFilterMiddleware - { - private readonly RequestDelegate _next; - - private readonly IPluginFinder _pluginFinder; - - public PluginContentFilterMiddleware( - RequestDelegate next, - IWebHostEnvironment hostingEnv, - ILoggerFactory loggerFactory, - IPluginFinder pluginFinder) - { - _next = next; - _pluginFinder = pluginFinder; - } - - - public async Task InvokeAsync(HttpContext httpContext) - { - var httpMethod = httpContext.Request.Method; - var path = httpContext.Request.Path.Value; - - // 在请求下一个 middleware 前过滤 - await RequestBodyFilter(httpContext); - - // Call the next delegate/middleware in the pipeline - await _next(httpContext); - - if (httpMethod == "GET" && path.EndsWith(".css") || path.EndsWith(".js") || path.EndsWith(".html")) - { - // middleware 回退时 过滤 - await ResponseBodyFilter(httpContext); - } - } - - private async Task RequestBodyFilter(HttpContext httpContext) - { - string content = string.Empty; - using (var memoryStream = new MemoryStream()) - { - // Response.Body - await httpContext.Request.Body.CopyToAsync(memoryStream); - - long pos = httpContext.Request.Body.Position; - - using (var reader = new StreamReader(memoryStream, Encoding.UTF8)) - { - content = await reader.ReadToEndAsync(); - } - } - - var plugins = this._pluginFinder.EnablePlugins().ToList(); - - foreach (var item in plugins) - { - // 调用 - content = await item?.RequestBodyFilter(httpContext.Request.Path.Value, content); - } - - // 更新 Request.Body - - #region 方式1 - //var requestStream = new MemoryStream(); - //using (StreamWriter writer = new StreamWriter(requestStream, Encoding.UTF8)) - //{ - // await writer.WriteAsync(content); - //} - //httpContext.Request.Body = requestStream; - #endregion - - - #region 方式2 - httpContext.Request.Body.Seek(0, SeekOrigin.Begin); - byte[] buffer = Encoding.UTF8.GetBytes(content); - await httpContext.Request.Body.WriteAsync(buffer, 0, buffer.Length); - #endregion - } - - private async Task ResponseBodyFilter(HttpContext httpContext) - { - string content = string.Empty; - using (var memoryStream = new MemoryStream()) - { - // Response.Body - await httpContext.Response.Body.CopyToAsync(memoryStream); - - long pos = httpContext.Response.Body.Position; - - using (var reader = new StreamReader(memoryStream, Encoding.UTF8)) - { - content = await reader.ReadToEndAsync(); - } - } - - var plugins = this._pluginFinder.EnablePlugins().ToList(); - - foreach (var item in plugins) - { - // 调用 - content = await item?.ReponseBodyFilter(httpContext.Request.Path.Value, content); - } - - // 更新 ResponseBody - - #region 方式1 - //var responseStream = new MemoryStream(); - //using (StreamWriter writer = new StreamWriter(responseStream, Encoding.UTF8)) - //{ - // await writer.WriteAsync(content); - //} - //httpContext.Response.Body = responseStream; - #endregion - - - #region 方式2 - httpContext.Response.Body.Seek(0, SeekOrigin.Begin); - byte[] buffer = Encoding.UTF8.GetBytes(content); - await httpContext.Response.Body.WriteAsync(buffer, 0, buffer.Length); - #endregion - } - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Middlewares/PluginHttpEndFilterMiddleware.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Middlewares/PluginHttpEndFilterMiddleware.cs deleted file mode 100644 index b5c524e5..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Middlewares/PluginHttpEndFilterMiddleware.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using PluginCore.Interfaces; - -namespace PluginCore.AspNetCore.Middlewares -{ - /// - /// 一定在 PluginCore 添加的中间件中 最后一个 - /// - public class PluginHttpEndFilterMiddleware - { - private readonly RequestDelegate _next; - - private readonly IPluginFinder _pluginFinder; - - public PluginHttpEndFilterMiddleware( - RequestDelegate next, - IWebHostEnvironment hostingEnv, - ILoggerFactory loggerFactory, - IPluginFinder pluginFinder) - { - _next = next; - _pluginFinder = pluginFinder; - } - - - public async Task InvokeAsync(HttpContext httpContext) - { - var httpMethod = httpContext.Request.Method; - var path = httpContext.Request.Path.Value; - - // 在请求下一个 middleware 前过滤 - - // Call the next delegate/middleware in the pipeline - await _next(httpContext); - - // middleware 回退时 过滤 - await Filter(httpContext); - } - - private async Task Filter(HttpContext httpContext) - { - var plugins = this._pluginFinder.EnablePlugins().ToList(); - - foreach (var item in plugins) - { - // 调用 - await item?.HttpEndFilter(httpContext); - } - } - - - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Middlewares/PluginHttpStartFilterMiddleware.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Middlewares/PluginHttpStartFilterMiddleware.cs deleted file mode 100644 index 2192f6b1..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Middlewares/PluginHttpStartFilterMiddleware.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using PluginCore.Interfaces; - -namespace PluginCore.AspNetCore.Middlewares -{ - /// - /// 一定在 PluginCore 添加的中间件中 第一个 - /// - public class PluginHttpStartFilterMiddleware - { - private readonly RequestDelegate _next; - - private readonly IPluginFinder _pluginFinder; - - public PluginHttpStartFilterMiddleware( - RequestDelegate next, - IWebHostEnvironment hostingEnv, - ILoggerFactory loggerFactory, - IPluginFinder pluginFinder) - { - _next = next; - _pluginFinder = pluginFinder; - } - - - public async Task InvokeAsync(HttpContext httpContext) - { - var httpMethod = httpContext.Request.Method; - var path = httpContext.Request.Path.Value; - - // 在请求下一个 middleware 前过滤 - await Filter(httpContext); - - // Call the next delegate/middleware in the pipeline - await _next(httpContext); - - // middleware 回退时 过滤 - } - - private async Task Filter(HttpContext httpContext) - { - var plugins = this._pluginFinder.EnablePlugins().ToList(); - - foreach (var item in plugins) - { - // 调用 - await item?.HttpStartFilter(httpContext); - } - } - - - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Middlewares/PluginStartupXMiddleware.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Middlewares/PluginStartupXMiddleware.cs deleted file mode 100644 index 254d6d2c..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/Middlewares/PluginStartupXMiddleware.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using PluginCore.AspNetCore.Interfaces; -using PluginCore.Infrastructure; - -namespace PluginCore.AspNetCore.Middlewares -{ - public class PluginStartupXMiddleware - { - private readonly RequestDelegate _next; - - public PluginStartupXMiddleware(RequestDelegate next) - { - _next = next; - } - - public static Action ReachedEndAction { get; set; } = () => { _isReachedEnd = true; }; - - private static bool _isReachedEnd; - - public async Task InvokeAsync(HttpContext httpContext, IPluginApplicationBuilderManager pluginApplicationBuilderManager) - { - //bool isReachedEnd = false; - _isReachedEnd = false; - - try - { - RequestDelegate requestDelegate = pluginApplicationBuilderManager.GetBuildResult(); - - await requestDelegate(httpContext); - } - catch (Exception ex) - { - // InvalidOperationException: The request reached the end of the pipeline without executing the endpoint: 'AspNetCore3_1.Controllers.WeatherForecastController.Get (AspNetCore3_1)'. Please register the EndpointMiddleware using 'IApplicationBuilder.UseEndpoints(...)' if using routing. - Utils.LogUtil.Error(ex, ex.Message); - if (ex.InnerException != null) - { - Utils.LogUtil.Error(ex.InnerException, ex.InnerException.Message); - } - } - - if (_isReachedEnd) - { - // Call the next delegate/middleware in the pipeline - await _next(httpContext); - } - else - { - // 没有抵达 End, 说明在插件的 middleware 中已堵塞, 准备返回 响应 - } - - - } - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/PluginCore.AspNetCore.csproj b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/PluginCore.AspNetCore.csproj deleted file mode 100644 index cdcec149..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/PluginCore.AspNetCore.csproj +++ /dev/null @@ -1,107 +0,0 @@ - - - - net8.0;net9.0 - PluginCore.AspNetCore - 1.4.3 - yiyun - yiyun - ASP.NET Core lightweight plugin framework - Copyright (c) 2021-present yiyun - https://github.com/yiyungent/PluginCore - https://github.com/yiyungent/PluginCore/blob/main/LICENSE - PluginCore PluginCore.AspNetCore - true - - - - - - - - - - - - - - - - - - - - - - - - - - bin\Release\netcoreapp3.1\PluginCore.AspNetCore.xml - - - bin\Release\net5.0\PluginCore.AspNetCore.xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(Path)$(VsInstallRoot)\Web\External\; - - - - - - - - - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/RequestModel/User/LoginRequestModel.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/RequestModel/User/LoginRequestModel.cs deleted file mode 100644 index 7e9d3ad3..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/RequestModel/User/LoginRequestModel.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace PluginCore.AspNetCore.RequestModel.User -{ - public class LoginRequestModel - { - public string UserName { get; set; } - - public string Password { get; set; } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/RequestModel/User/UpdateRequestMode.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/RequestModel/User/UpdateRequestMode.cs deleted file mode 100644 index 766f4dbc..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/RequestModel/User/UpdateRequestMode.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace PluginCore.AspNetCore.RequestModel.User -{ - public class UpdateRequestModel - { - public string UserName { get; set; } - - public string Password { get; set; } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/ResponseModel/BaseResponseModel.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/ResponseModel/BaseResponseModel.cs deleted file mode 100644 index b42c4ef1..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/ResponseModel/BaseResponseModel.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -namespace PluginCore.AspNetCore.ResponseModel -{ - public class BaseResponseModel - { - public int Code { get; set; } - - public string Message { get; set; } - - public object Data { get; set; } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/cliff.toml b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/cliff.toml deleted file mode 100644 index aa3089f4..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/cliff.toml +++ /dev/null @@ -1,82 +0,0 @@ -# git-cliff ~ configuration file -# https://git-cliff.org/docs/configuration - -[changelog] -# template for the changelog header -header = """ -# Changelog\n -All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.\n -""" -# template for the changelog body -# https://keats.github.io/tera/docs/#introduction -body = """ ---- -{% if version %}\ - {% if previous.version %}\ - ## [{{ version | trim_start_matches(pat="v") }}]($REPO/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }} - {% else %}\ - ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} - {% endif %}\ -{% else %}\ - ## [unreleased] -{% endif %}\ -{% for group, commits in commits | group_by(attribute="group") %} - ### {{ group | striptags | trim | upper_first }} - {% for commit in commits - | filter(attribute="scope") - | sort(attribute="scope") %} - - **({{commit.scope}})**{% if commit.breaking %} [**breaking**]{% endif %} \ - {{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }} - {%- endfor -%} - {% raw %}\n{% endraw %}\ - {%- for commit in commits %} - {%- if commit.scope -%} - {% else -%} - - {% if commit.breaking %} [**breaking**]{% endif %}\ - {{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }} - {% endif -%} - {% endfor -%} -{% endfor %}\n -""" -# template for the changelog footer -footer = """ - -""" -# remove the leading and trailing whitespace from the templates -trim = true -# postprocessors -postprocessors = [ - { pattern = '\$REPO', replace = "https://github.com/yiyungent/PluginCore" }, # replace repository URL -] - -[git] -# parse the commits based on https://www.conventionalcommits.org -conventional_commits = true -# filter out the commits that are not conventional -filter_unconventional = true -# process each line of a commit as an individual commit -split_commits = false -# regex for preprocessing the commit messages -commit_preprocessors = [ - # { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/orhun/git-cliff/issues/${2}))"}, # replace issue numbers -] -# regex for parsing and grouping commits -commit_parsers = [ - { message = "^feat", group = "Features" }, - { message = "^fix", group = "Bug Fixes" }, - { message = "^doc", group = "Documentation" }, - { message = "^perf", group = "Performance" }, - { message = "^refactor", group = "Refactoring" }, - { message = "^style", group = "Style" }, - { message = "^revert", group = "Revert" }, - { message = "^test", group = "Tests" }, - { message = "^chore\\(version\\):", skip = true }, - { message = "^chore", group = "Miscellaneous Chores" }, - { body = ".*security", group = "Security" }, -] -# filter out the commits that are not matched by commit parsers -filter_commits = false -# sort the tags topologically -topo_order = false -# sort the commits inside sections by oldest/newest order -sort_commits = "oldest" diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/lmplements/AspNetCorePluginManager.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/lmplements/AspNetCorePluginManager.cs deleted file mode 100644 index 41af5e54..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/lmplements/AspNetCorePluginManager.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using PluginCore.AspNetCore.Interfaces; -using PluginCore.Interfaces; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.Loader; -using System.Text; -using PluginCore.lmplements; -using PluginCore.Infrastructure; - -namespace PluginCore.AspNetCore.lmplements -{ - /// - /// 一个插件的所有dll由 一个 管理 - /// 记录管理了所有 插件的 - /// 是对 的封装, 使其更好管理插件加载释放的行为 - /// - public class AspNetCorePluginManager : IPluginManager - { - private readonly IPluginControllerManager _pluginControllerManager; - - public IPluginContextManager PluginContextManager { get; set; } - - public IPluginContextPack PluginContextPack { get; set; } - - public AspNetCorePluginManager(IPluginContextManager pluginContextManager, IPluginContextPack pluginContextPack, IPluginControllerManager pluginControllerManager) - { - this.PluginContextManager = pluginContextManager; - this.PluginContextPack = pluginContextPack; - _pluginControllerManager = pluginControllerManager; - } - - /// - /// 加载插件程序集 - /// - /// - public void LoadPlugin(string pluginId) - { - IPluginContext context = this.PluginContextPack.Pack(pluginId); - Assembly pluginMainAssembly = context.LoadFromAssemblyName(new AssemblyName(pluginId)); - //注销内置Controller的注册 by tomny - // 加载其中的控制器 - //_pluginControllerManager.AddControllers(pluginMainAssembly); - - // 这个插件加载上下文 放入 集合中 - this.PluginContextManager.Add(pluginId, context); - } - - public void UnloadPlugin(string pluginId) - { - this.PluginContextManager.Remove(pluginId); - - // 移除其中的控制器 - _pluginControllerManager.RemoveControllers(pluginId); - } - /// - /// 加载插件程序集 - /// - /// - public Assembly GetPluginAssembly(string pluginId) - { - IPluginContext context = this.PluginContextPack.Pack(pluginId); - Assembly pluginMainAssembly = context.LoadFromAssemblyName(new AssemblyName(pluginId)); - - return pluginMainAssembly; - } - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/lmplements/AspNetCorePluginManagerV1.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/lmplements/AspNetCorePluginManagerV1.cs deleted file mode 100644 index ed9db95c..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/lmplements/AspNetCorePluginManagerV1.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using PluginCore.AspNetCore.Interfaces; -using PluginCore.Interfaces; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.Loader; -using System.Text; -using PluginCore.lmplements; -using PluginCore.Infrastructure; - -namespace PluginCore.AspNetCore.lmplements -{ - - // ********* 虽然 看上去和 AspNetCorePluginManager 一样, 但特别保留, 防止需要不一样的处理, 后续更新维护方便 - - /// - /// 一个插件的所有dll由 一个 管理 - /// 记录管理了所有 插件的 - /// 是对 的封装, 使其更好管理插件加载释放的行为 - /// - public class AspNetCorePluginManagerV1 : IPluginManager - { - private readonly IPluginControllerManager _pluginControllerManager; - - public IPluginContextManager PluginContextManager { get; set; } - - public IPluginContextPack PluginContextPack { get; set; } - - public AspNetCorePluginManagerV1(IPluginContextManager pluginContextManager, IPluginContextPack pluginContextPack, IPluginControllerManager pluginControllerManager) - { - this.PluginContextManager = pluginContextManager; - this.PluginContextPack = pluginContextPack; - _pluginControllerManager = pluginControllerManager; - } - - /// - /// 加载插件程序集 - /// - /// - public void LoadPlugin(string pluginId) - { - // 此插件的 加载上下文 - IPluginContext context = this.PluginContextPack.Pack(pluginId); - - // TODO: 注意: 未测试: 不清除 对于 旧版加载 dll 方式, 再结合 LoadFromAssemblyName 是否有效 - Assembly pluginMainAssembly = context.LoadFromAssemblyName(new AssemblyName(pluginId)); - - //注销内置Controller的注册 by tomny - // 加载其中的控制器 - //_pluginControllerManager.AddControllers(pluginMainAssembly); - - // 这个插件加载上下文 放入 集合中 - this.PluginContextManager.Add(pluginId, context); - } - - public void UnloadPlugin(string pluginId) - { - this.PluginContextManager.Remove(pluginId); - - // 移除其中的控制器 - _pluginControllerManager.RemoveControllers(pluginId); - } - public Assembly GetPluginAssembly(string pluginId) - { - IPluginContext context = this.PluginContextPack.Pack(pluginId); - Assembly pluginMainAssembly = context.LoadFromAssemblyName(new AssemblyName(pluginId)); - - return pluginMainAssembly; - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/lmplements/PluginActionDescriptorChangeProvider.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/lmplements/PluginActionDescriptorChangeProvider.cs deleted file mode 100644 index e678d36f..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/lmplements/PluginActionDescriptorChangeProvider.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using Microsoft.AspNetCore.Mvc.Infrastructure; -using Microsoft.Extensions.Primitives; -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; - -namespace PluginCore.AspNetCore.lmplements -{ - /// - /// 目前采用的第一种方案 - /// 方案一: https://www.codetd.com/article/461093 - /// 方案二: https://www.cnblogs.com/artech/p/dynamic-controllers.html - /// - public class PluginActionDescriptorChangeProvider : IActionDescriptorChangeProvider - { - public static PluginActionDescriptorChangeProvider Instance { get; } = new PluginActionDescriptorChangeProvider(); - - public CancellationTokenSource TokenSource { get; private set; } - - public bool HasChanged { get; set; } - - public IChangeToken GetChangeToken() - { - TokenSource = new CancellationTokenSource(); - return new CancellationChangeToken(TokenSource.Token); - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/lmplements/PluginApplicationBuilderManager.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/lmplements/PluginApplicationBuilderManager.cs deleted file mode 100644 index 1b337c03..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/lmplements/PluginApplicationBuilderManager.cs +++ /dev/null @@ -1,77 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using PluginCore.AspNetCore.Interfaces; -using PluginCore.Interfaces; -using PluginCore.IPlugins; -using PluginCore.AspNetCore.Middlewares; -using PluginCore.AspNetCore.Infrastructure; - -namespace PluginCore.AspNetCore.lmplements -{ - public class PluginApplicationBuilderManager : PluginApplicationBuilderManager - { - public PluginApplicationBuilderManager(IPluginFinder pluginFinder) : base(pluginFinder) - { - } - } - - public class PluginApplicationBuilderManager : IPluginApplicationBuilderManager - where TPluginApplicationBuilder : PluginApplicationBuilder, new() - { - private readonly IPluginFinder _pluginFinder; - - public PluginApplicationBuilderManager(IPluginFinder pluginFinder) - { - _pluginFinder = pluginFinder; - } - - public static RequestDelegate RequestDelegateResult { get; set; } - - - /// - /// 插件 启用, 禁用 时: 重新 Build - /// - public void ReBuild() - { - TPluginApplicationBuilder applicationBuilder = new TPluginApplicationBuilder(); - applicationBuilder.ReachEndAction = PluginStartupXMiddleware.ReachedEndAction; - - var plugins = this._pluginFinder.EnablePlugins()?.OrderBy(m => m.ConfigureOrder)?.ToList(); - foreach (var item in plugins) - { - // 调用 - Utils.LogUtil.Info($"{item.GetType().ToString()} {nameof(IStartupXPlugin)}.{nameof(IStartupXPlugin.Configure)}"); - - item.Configure(applicationBuilder); - } - - RequestDelegateResult = applicationBuilder.Build(); - } - - - public RequestDelegate GetBuildResult() - { - if (RequestDelegateResult == null) - { - ReBuild(); - } - - return RequestDelegateResult; - } - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/lmplements/PluginControllerManager.cs b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/lmplements/PluginControllerManager.cs deleted file mode 100644 index 6631955c..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/lmplements/PluginControllerManager.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using Microsoft.AspNetCore.Mvc.ApplicationParts; -using PluginCore.AspNetCore.Interfaces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace PluginCore.AspNetCore.lmplements -{ - public class PluginControllerManager : IPluginControllerManager - { - private readonly ApplicationPartManager _applicationPartManager; - - public PluginControllerManager(ApplicationPartManager applicationPartManager) - { - _applicationPartManager = applicationPartManager; - } - - /// - /// 从指定 中获取 Controller, 并添加进来 - /// - /// - public void AddControllers(Assembly assembly) - { - AssemblyPart assemblyPart = new AssemblyPart(assembly); - _applicationPartManager.ApplicationParts.Add(assemblyPart); - - ResetControllActions(); - } - - public void RemoveControllers(string pluginId) - { - ApplicationPart last = _applicationPartManager.ApplicationParts.First(m => m.Name == pluginId); - _applicationPartManager.ApplicationParts.Remove(last); - - ResetControllActions(); - } - - /// - /// 通知应用(主程序)Controller.Action 已发生变化 - /// - private void ResetControllActions() - { - PluginActionDescriptorChangeProvider.Instance.HasChanged = true; - // TokenSource 为 null - // 注意: 在程序刚启动时, 未抵达 Controller 时不会触发 IActionDescriptorChangeProvider.GetChangeToken(), 也就会导致 TokenSource 为 null, 在启动时,同时在启动时,插件Controller.Action和主程序一起被添加,此时无需通知改变 - if (PluginActionDescriptorChangeProvider.Instance.TokenSource != null) - { - // 只有在插件列表控制启用,禁用时才需通知改变 - PluginActionDescriptorChangeProvider.Instance.TokenSource.Cancel(); - } - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/nuget-pack.ps1 b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/nuget-pack.ps1 deleted file mode 100644 index c3c10d7a..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/nuget-pack.ps1 +++ /dev/null @@ -1 +0,0 @@ -dotnet pack -c Release \ No newline at end of file diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/package-lock.json b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/package-lock.json deleted file mode 100644 index 741f46cd..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/package-lock.json +++ /dev/null @@ -1,307 +0,0 @@ -{ - "name": "PluginCore", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "PluginCore", - "version": "1.0.0", - "dependencies": { - "plugincore-admin-frontend": "0.3.2" - } - }, - "node_modules/ansi-styles": { - "version": "1.0.0", - "resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-1.0.0.tgz", - "integrity": "sha512-3iF4FIKdxaVYT3JqQuY3Wat/T2t7TRbbQ94Fu50ZUCbLy4TFbTzr90NOHQodQkNqmeEGCw8WbeP78WNi6SKYUA==", - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/async-validator": { - "version": "1.8.5", - "resolved": "https://registry.npmmirror.com/async-validator/-/async-validator-1.8.5.tgz", - "integrity": "sha512-tXBM+1m056MAX0E8TL2iCjg8WvSyXu0Zc8LNtYqrVeyoL3+esHRZ4SieE9fKQyyU09uONjnMEjrNBMqT0mbvmA==", - "dependencies": { - "babel-runtime": "6.x" - } - }, - "node_modules/axios": { - "version": "0.18.1", - "resolved": "https://registry.npmmirror.com/axios/-/axios-0.18.1.tgz", - "integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==", - "deprecated": "Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410", - "dependencies": { - "follow-redirects": "1.5.10", - "is-buffer": "^2.0.2" - } - }, - "node_modules/babel-helper-vue-jsx-merge-props": { - "version": "2.0.3", - "resolved": "https://registry.npmmirror.com/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-2.0.3.tgz", - "integrity": "sha512-gsLiKK7Qrb7zYJNgiXKpXblxbV5ffSwR0f5whkPAaBAR4fhi6bwRZxX9wBlIc5M/v8CCkXUbXZL4N/nSE97cqg==" - }, - "node_modules/babel-runtime": { - "version": "6.26.0", - "resolved": "https://registry.npmmirror.com/babel-runtime/-/babel-runtime-6.26.0.tgz", - "integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==", - "dependencies": { - "core-js": "^2.4.0", - "regenerator-runtime": "^0.11.0" - } - }, - "node_modules/babel-runtime/node_modules/core-js": { - "version": "2.6.12", - "resolved": "https://registry.npmmirror.com/core-js/-/core-js-2.6.12.tgz", - "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", - "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", - "hasInstallScript": true - }, - "node_modules/chalk": { - "version": "0.4.0", - "resolved": "https://registry.npmmirror.com/chalk/-/chalk-0.4.0.tgz", - "integrity": "sha512-sQfYDlfv2DGVtjdoQqxS0cEZDroyG8h6TamA6rvxwlrU5BaSLDx9xhatBYl2pxZ7gmpNaPFVwBtdGdu5rQ+tYQ==", - "dependencies": { - "ansi-styles": "~1.0.0", - "has-color": "~0.1.0", - "strip-ansi": "~0.1.0" - }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/codemirror": { - "version": "5.65.2", - "resolved": "https://registry.npmmirror.com/codemirror/-/codemirror-5.65.2.tgz", - "integrity": "sha512-SZM4Zq7XEC8Fhroqe3LxbEEX1zUPWH1wMr5zxiBuiUF64iYOUH/JI88v4tBag8MiBS8B8gRv8O1pPXGYXQ4ErA==" - }, - "node_modules/core-js": { - "version": "3.6.5", - "resolved": "https://registry.npmmirror.com/core-js/-/core-js-3.6.5.tgz", - "integrity": "sha512-vZVEEwZoIsI+vPEuoF9Iqf5H7/M3eeQqWlQnYa8FSKKePuYTf5MWnxb5SDAzCa60b3JBRS5g9b+Dq7b1y/RCrA==", - "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", - "hasInstallScript": true - }, - "node_modules/debug": { - "version": "3.1.0", - "resolved": "https://registry.npmmirror.com/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/deepmerge": { - "version": "1.5.2", - "resolved": "https://registry.npmmirror.com/deepmerge/-/deepmerge-1.5.2.tgz", - "integrity": "sha512-95k0GDqvBjZavkuvzx/YqVLv/6YYa17fz6ILMSf7neqQITCPbnfEnQvEgMPNjH4kgobe7+WIL0yJEHku+H3qtQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/element-ui": { - "version": "2.13.2", - "resolved": "https://registry.npmmirror.com/element-ui/-/element-ui-2.13.2.tgz", - "integrity": "sha512-r761DRPssMPKDiJZWFlG+4e4vr0cRG/atKr3Eqr8Xi0tQMNbtmYU1QXvFnKiFPFFGkgJ6zS6ASkG+sellcoHlQ==", - "dependencies": { - "async-validator": "~1.8.1", - "babel-helper-vue-jsx-merge-props": "^2.0.0", - "deepmerge": "^1.2.0", - "normalize-wheel": "^1.0.1", - "resize-observer-polyfill": "^1.5.0", - "throttle-debounce": "^1.0.1" - }, - "peerDependencies": { - "vue": "^2.5.17" - } - }, - "node_modules/follow-redirects": { - "version": "1.5.10", - "resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.5.10.tgz", - "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", - "dependencies": { - "debug": "=3.1.0" - }, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/has-color": { - "version": "0.1.7", - "resolved": "https://registry.npmmirror.com/has-color/-/has-color-0.1.7.tgz", - "integrity": "sha512-kaNz5OTAYYmt646Hkqw50/qyxP2vFnTVu5AQ1Zmk22Kk5+4Qx6BpO8+u7IKsML5fOsFk0ZT0AcCJNYwcvaLBvw==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-buffer": { - "version": "2.0.5", - "resolved": "https://registry.npmmirror.com/is-buffer/-/is-buffer-2.0.5.tgz", - "integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==", - "engines": { - "node": ">=4" - } - }, - "node_modules/js-cookie": { - "version": "2.2.0", - "resolved": "https://registry.npmmirror.com/js-cookie/-/js-cookie-2.2.0.tgz", - "integrity": "sha512-7YAJP/LPE/MhDjHIdfIiT665HUSumCwPN2hAmO6OJZ8V3o1mtz2HeQ8BKetEjkh+3nqGxYaq1vPMViUR8kaOXw==" - }, - "node_modules/jsonlint": { - "version": "1.6.3", - "resolved": "https://registry.npmmirror.com/jsonlint/-/jsonlint-1.6.3.tgz", - "integrity": "sha512-jMVTMzP+7gU/IyC6hvKyWpUU8tmTkK5b3BPNuMI9U8Sit+YAWLlZwB6Y6YrdCxfg2kNz05p3XY3Bmm4m26Nv3A==", - "dependencies": { - "JSV": "^4.0.x", - "nomnom": "^1.5.x" - }, - "bin": { - "jsonlint": "lib/cli.js" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/JSV": { - "version": "4.0.2", - "resolved": "https://registry.npmmirror.com/JSV/-/JSV-4.0.2.tgz", - "integrity": "sha512-ZJ6wx9xaKJ3yFUhq5/sk82PJMuUyLk277I8mQeyDgCTjGdjWJIvPfaU5LIXaMuaN2UO1X3kZH4+lgphublZUHw==", - "engines": { - "node": "*" - } - }, - "node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmmirror.com/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" - }, - "node_modules/nomnom": { - "version": "1.8.1", - "resolved": "https://registry.npmmirror.com/nomnom/-/nomnom-1.8.1.tgz", - "integrity": "sha512-5s0JxqhDx9/rksG2BTMVN1enjWSvPidpoSgViZU4ZXULyTe+7jxcCRLB6f42Z0l1xYJpleCBtSyY6Lwg3uu5CQ==", - "deprecated": "Package no longer supported. Contact support@npmjs.com for more info.", - "dependencies": { - "chalk": "~0.4.0", - "underscore": "~1.6.0" - } - }, - "node_modules/normalize-wheel": { - "version": "1.0.1", - "resolved": "https://registry.npmmirror.com/normalize-wheel/-/normalize-wheel-1.0.1.tgz", - "integrity": "sha512-1OnlAPZ3zgrk8B91HyRj+eVv+kS5u+Z0SCsak6Xil/kmgEia50ga7zfkumayonZrImffAxPU/5WcyGhzetHNPA==" - }, - "node_modules/normalize.css": { - "version": "7.0.0", - "resolved": "https://registry.npmmirror.com/normalize.css/-/normalize.css-7.0.0.tgz", - "integrity": "sha512-LYaFZxj2Q1Q9e1VJ0f6laG46Rt5s9URhKyckNaA2vZnL/0gwQHWhM7ALQkp3WBQKM5sXRLQ5Ehrfkp+E/ZiCRg==" - }, - "node_modules/nprogress": { - "version": "0.2.0", - "resolved": "https://registry.npmmirror.com/nprogress/-/nprogress-0.2.0.tgz", - "integrity": "sha512-I19aIingLgR1fmhftnbWWO3dXc0hSxqHQHQb3H8m+K3TnEn/iSeTZZOyvKXWqQESMwuUVnatlCnZdLBZZt2VSA==" - }, - "node_modules/path-to-regexp": { - "version": "2.4.0", - "resolved": "https://registry.npmmirror.com/path-to-regexp/-/path-to-regexp-2.4.0.tgz", - "integrity": "sha512-G6zHoVqC6GGTQkZwF4lkuEyMbVOjoBKAEybQUypI1WTkqinCOrq2x6U2+phkJ1XsEMTy4LjtwPI7HW+NVrRR2w==" - }, - "node_modules/plugincore-admin-frontend": { - "version": "0.3.2", - "resolved": "https://registry.npmmirror.com/plugincore-admin-frontend/-/plugincore-admin-frontend-0.3.2.tgz", - "integrity": "sha512-w8t6J+92Ns/gan/3uLW9Uns6vbAEkOzYBzueCJY5b7i+F7wyvmh0TcOHQscm6VmJQW+d73eaTk4psIcUcHbOng==", - "dependencies": { - "axios": "0.18.1", - "codemirror": "^5.57.0", - "core-js": "3.6.5", - "element-ui": "2.13.2", - "js-cookie": "2.2.0", - "jsonlint": "^1.6.3", - "normalize.css": "7.0.0", - "nprogress": "0.2.0", - "path-to-regexp": "2.4.0", - "script-loader": "^0.7.2", - "vue": "2.6.10", - "vue-i18n": "^8.26.7", - "vue-meditor": "^2.1.1", - "vue-router": "3.0.6", - "vuex": "3.1.0" - }, - "engines": { - "node": ">=8.9", - "npm": ">= 3.0.0" - } - }, - "node_modules/raw-loader": { - "version": "0.5.1", - "resolved": "https://registry.npmmirror.com/raw-loader/-/raw-loader-0.5.1.tgz", - "integrity": "sha512-sf7oGoLuaYAScB4VGr0tzetsYlS8EJH6qnTCfQ/WVEa89hALQ4RQfCKt5xCyPQKPDUbVUAIP1QsxAwfAjlDp7Q==" - }, - "node_modules/regenerator-runtime": { - "version": "0.11.1", - "resolved": "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", - "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" - }, - "node_modules/resize-observer-polyfill": { - "version": "1.5.1", - "resolved": "https://registry.npmmirror.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz", - "integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==" - }, - "node_modules/script-loader": { - "version": "0.7.2", - "resolved": "https://registry.npmmirror.com/script-loader/-/script-loader-0.7.2.tgz", - "integrity": "sha512-UMNLEvgOAQuzK8ji8qIscM3GIrRCWN6MmMXGD4SD5l6cSycgGsCo0tX5xRnfQcoghqct0tjHjcykgI1PyBE2aA==", - "dependencies": { - "raw-loader": "~0.5.1" - } - }, - "node_modules/strip-ansi": { - "version": "0.1.1", - "resolved": "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-0.1.1.tgz", - "integrity": "sha512-behete+3uqxecWlDAm5lmskaSaISA+ThQ4oNNBDTBJt0x2ppR6IPqfZNuj6BLaLJ/Sji4TPZlcRyOis8wXQTLg==", - "bin": { - "strip-ansi": "cli.js" - }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/throttle-debounce": { - "version": "1.1.0", - "resolved": "https://registry.npmmirror.com/throttle-debounce/-/throttle-debounce-1.1.0.tgz", - "integrity": "sha512-XH8UiPCQcWNuk2LYePibW/4qL97+ZQ1AN3FNXwZRBNPPowo/NRU5fAlDCSNBJIYCKbioZfuYtMhG4quqoJhVzg==", - "engines": { - "node": ">=4" - } - }, - "node_modules/underscore": { - "version": "1.6.0", - "resolved": "https://registry.npmmirror.com/underscore/-/underscore-1.6.0.tgz", - "integrity": "sha512-z4o1fvKUojIWh9XuaVLUDdf86RQiq13AC1dmHbTpoyuu+bquHms76v16CjycCbec87J7z0k//SiQVk0sMdFmpQ==" - }, - "node_modules/vue": { - "version": "2.6.10", - "resolved": "https://registry.npmmirror.com/vue/-/vue-2.6.10.tgz", - "integrity": "sha512-ImThpeNU9HbdZL3utgMCq0oiMzAkt1mcgy3/E6zWC/G6AaQoeuFdsl9nDhTDU3X1R6FK7nsIUuRACVcjI+A2GQ==" - }, - "node_modules/vue-i18n": { - "version": "8.27.1", - "resolved": "https://registry.npmmirror.com/vue-i18n/-/vue-i18n-8.27.1.tgz", - "integrity": "sha512-lWrGm4F25qReJ7XxSnFVb2h3PfW54ldnM4C+YLBGGJ75+Myt/kj4hHSTKqsyDLamvNYpvINMicSOdW+7yuqgIQ==" - }, - "node_modules/vue-meditor": { - "version": "2.1.1", - "resolved": "https://registry.npmmirror.com/vue-meditor/-/vue-meditor-2.1.1.tgz", - "integrity": "sha512-xvLqqvS4LzEJ7TqW2mDSzvueMey/WM92o0jfmqZWBTks1/8EAmn0ehqZDlcq/W+1goQpUmWE4m3yJjzQnoZhQQ==" - }, - "node_modules/vue-router": { - "version": "3.0.6", - "resolved": "https://registry.npmmirror.com/vue-router/-/vue-router-3.0.6.tgz", - "integrity": "sha512-Ox0ciFLswtSGRTHYhGvx2L44sVbTPNS+uD2kRISuo8B39Y79rOo0Kw0hzupTmiVtftQYCZl87mwldhh2L9Aquw==" - }, - "node_modules/vuex": { - "version": "3.1.0", - "resolved": "https://registry.npmmirror.com/vuex/-/vuex-3.1.0.tgz", - "integrity": "sha512-mdHeHT/7u4BncpUZMlxNaIdcN/HIt1GsGG5LKByArvYG/v6DvHcOxvDCts+7SRdCoIRGllK8IMZvQtQXLppDYg==" - } - } -} diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/package.json b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/package.json deleted file mode 100644 index 2466cb08..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "PluginCore", - "version": "1.0.0", - "private": true, - "dependencies": { - "plugincore-admin-frontend": "0.3.2" - } -} diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/readme.txt b/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/readme.txt deleted file mode 100644 index 3e8cd20a..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.AspNetCore/readme.txt +++ /dev/null @@ -1,11 +0,0 @@ - - - - - -`PluginCoreAdmin` is the web frontend for the `PluginCore management center (PluginCore Admin)` and should be released together. - -https://github.com/yiyungent/PluginCore - - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/CHANGELOG.md b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/CHANGELOG.md deleted file mode 100644 index e7d4ae57..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/CHANGELOG.md +++ /dev/null @@ -1,54 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines. - ---- -## [unreleased] - -### Documentation - -- **(CHANGELOG.md)** update - ([0bbfc89](https://github.com/yiyungent/PluginCore/commit/0bbfc8955b7f6338db2125c78ec250e9eeeadcce)) - github-actions[bot] -- **(CHANGELOG.md)** update - ([4f6b47b](https://github.com/yiyungent/PluginCore/commit/4f6b47b3f86bfce4a8f660166837a7322c568d78)) - github-actions[bot] - -### Miscellaneous Chores - -- **(cliff.toml)** add - ([5614ef0](https://github.com/yiyungent/PluginCore/commit/5614ef024d644349095e19a0016bb23d989b0c90)) - yiyun - ---- -## [PluginCore.IPlugins.AspNetCore-v0.1.1](https://github.com/yiyungent/PluginCore/compare/PluginCore.IPlugins.AspNetCore-v0.1.0..PluginCore.IPlugins.AspNetCore-v0.1.1) - 2023-12-30 - -### Features - -- **(src/**/*.cs)** // License: Apache-2.0 -> // License: GNU LGPLv3 - ([57366d3](https://github.com/yiyungent/PluginCore/commit/57366d3e2afdb8e20e94851aa8a09f1ee61b6d7e)) - yiyun -- **(src/**/*.cs)** // Project: https://moeci.com/PluginCore -> // Project: https://yiyungent.github.io/PluginCore - ([7420480](https://github.com/yiyungent/PluginCore/commit/742048065978c1b8597fab3d52f011db4247fbda)) - yiyun - -### Build - -- **(plugincore.iplugins.aspnetcore.csproj)** 0.1.0 -> 0.1.1 - ([338e919](https://github.com/yiyungent/PluginCore/commit/338e919c74dcff4199b82c6046a62847cc68beb3)) - yiyun - ---- -## [PluginCore.IPlugins.AspNetCore-v0.1.0](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.0.2..PluginCore.IPlugins.AspNetCore-v0.1.0) - 2023-02-15 - -### Build - -- **(plugincore.iplugins.aspnetcore.csproj)** `0.1.0` - ([162d304](https://github.com/yiyungent/PluginCore/commit/162d304f6b74941701b5b799228a3061ef4ea6c2)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.0.2](https://github.com/yiyungent/PluginCore/compare/PluginCore.IPlugins.AspNetCore-v0.0.1..PluginCore.AspNetCore-v1.0.2) - 2022-04-19 - -### Style - -- add: copyright: *.cs - ([9643dce](https://github.com/yiyungent/PluginCore/commit/9643dce112861a440d63306cb555accbed3d5111)) - yiyun - ---- -## [PluginCore.IPlugins.AspNetCore-v0.0.1](https://github.com/yiyungent/PluginCore/compare/PluginCore-v1.0.0..PluginCore.IPlugins.AspNetCore-v0.0.1) - 2022-04-16 - -### Refactoring - -- 1.提取出 PluginCore.AspNetCore,PluginCore.IPlugins.AspNetCore 2.提取出更多接口,可自由替换 - ([fffd8d9](https://github.com/yiyungent/PluginCore/commit/fffd8d91c23fd6e4a4d09cbf91975beb3cf7acf0)) - yiyun - -### Build - -- **(plugincore.iplugins.aspnetcore.csproj)** 0.0.1 - ([b907263](https://github.com/yiyungent/PluginCore/commit/b9072639d894904add2faf46216e29f902ddf32b)) - yiyun - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/IPlugins/IContentFilterPlugin.cs b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/IPlugins/IContentFilterPlugin.cs deleted file mode 100644 index bc723bf4..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/IPlugins/IContentFilterPlugin.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; - - -namespace PluginCore.IPlugins -{ - /// - /// 目前未有效化,占坑 - /// - public interface IContentFilterPlugin : IPlugin - { - Task RequestBodyFilter(string urlPath, string content); - - Task ReponseBodyFilter(string urlPath, string content); - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/IPlugins/IHttpFilterPlugin.cs b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/IPlugins/IHttpFilterPlugin.cs deleted file mode 100644 index 46c40ac6..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/IPlugins/IHttpFilterPlugin.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; - -namespace PluginCore.IPlugins -{ - /// - /// 实验性: 不确定有效, 发现问题,请 new issue - /// - public interface IHttpFilterPlugin : IPlugin - { - Task HttpEndFilter(HttpContext httpContext); - - Task HttpStartFilter(HttpContext httpContext); - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/IPlugins/IStartupPlugin.cs b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/IPlugins/IStartupPlugin.cs deleted file mode 100644 index 332d3f7b..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/IPlugins/IStartupPlugin.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; - -namespace PluginCore.IPlugins -{ - /// - /// 实验阶段 - /// 无法热插拔: 需要启用插件后, 再 重启站点 - /// - public interface IStartupPlugin : IPlugin - { - /// - /// This method gets called by the runtime. Use this method to add services to the container. - /// - /// - void ConfigureServices(IServiceCollection services); - - int ConfigureServicesOrder { get; } - - /// - /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - /// - /// - /// - void Configure(IApplicationBuilder app); - - int ConfigureOrder { get; } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/IPlugins/IStartupXPlugin.cs b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/IPlugins/IStartupXPlugin.cs deleted file mode 100644 index 2993c18c..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/IPlugins/IStartupXPlugin.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; - -namespace PluginCore.IPlugins -{ - /// - /// 实验阶段 - /// 热插拔: 已有效化 - /// - public interface IStartupXPlugin : IPlugin - { - /// - /// This method gets called by the runtime. Use this method to add services to the container. - /// 未有效化 - /// - /// - void ConfigureServices(IServiceCollection services); - - - int ConfigureServicesOrder { get; } - - /// - /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - /// - /// - /// - void Configure(IApplicationBuilder app); - - int ConfigureOrder { get; } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/PluginCore.IPlugins.AspNetCore.csproj b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/PluginCore.IPlugins.AspNetCore.csproj deleted file mode 100644 index dda157f9..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/PluginCore.IPlugins.AspNetCore.csproj +++ /dev/null @@ -1,40 +0,0 @@ - - - - net8.0;net9.0 - PluginCore.IPlugins.AspNetCore - 0.1.1 - yiyun - yiyun - PluginCore.AspNetCore Plugin Sdk - Copyright (c) 2021-present yiyun - https://github.com/yiyungent/PluginCore - https://github.com/yiyungent/PluginCore/blob/main/LICENSE - PluginCore PluginCore.IPlugins.AspNetCore - true - - - - - - - - - - - - - bin\Release\netstandard2.0\PluginCore.IPlugins.AspNetCore.xml - - - - - - - - - - - - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/cliff.toml b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/cliff.toml deleted file mode 100644 index aa3089f4..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/cliff.toml +++ /dev/null @@ -1,82 +0,0 @@ -# git-cliff ~ configuration file -# https://git-cliff.org/docs/configuration - -[changelog] -# template for the changelog header -header = """ -# Changelog\n -All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.\n -""" -# template for the changelog body -# https://keats.github.io/tera/docs/#introduction -body = """ ---- -{% if version %}\ - {% if previous.version %}\ - ## [{{ version | trim_start_matches(pat="v") }}]($REPO/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }} - {% else %}\ - ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} - {% endif %}\ -{% else %}\ - ## [unreleased] -{% endif %}\ -{% for group, commits in commits | group_by(attribute="group") %} - ### {{ group | striptags | trim | upper_first }} - {% for commit in commits - | filter(attribute="scope") - | sort(attribute="scope") %} - - **({{commit.scope}})**{% if commit.breaking %} [**breaking**]{% endif %} \ - {{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }} - {%- endfor -%} - {% raw %}\n{% endraw %}\ - {%- for commit in commits %} - {%- if commit.scope -%} - {% else -%} - - {% if commit.breaking %} [**breaking**]{% endif %}\ - {{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }} - {% endif -%} - {% endfor -%} -{% endfor %}\n -""" -# template for the changelog footer -footer = """ - -""" -# remove the leading and trailing whitespace from the templates -trim = true -# postprocessors -postprocessors = [ - { pattern = '\$REPO', replace = "https://github.com/yiyungent/PluginCore" }, # replace repository URL -] - -[git] -# parse the commits based on https://www.conventionalcommits.org -conventional_commits = true -# filter out the commits that are not conventional -filter_unconventional = true -# process each line of a commit as an individual commit -split_commits = false -# regex for preprocessing the commit messages -commit_preprocessors = [ - # { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/orhun/git-cliff/issues/${2}))"}, # replace issue numbers -] -# regex for parsing and grouping commits -commit_parsers = [ - { message = "^feat", group = "Features" }, - { message = "^fix", group = "Bug Fixes" }, - { message = "^doc", group = "Documentation" }, - { message = "^perf", group = "Performance" }, - { message = "^refactor", group = "Refactoring" }, - { message = "^style", group = "Style" }, - { message = "^revert", group = "Revert" }, - { message = "^test", group = "Tests" }, - { message = "^chore\\(version\\):", skip = true }, - { message = "^chore", group = "Miscellaneous Chores" }, - { body = ".*security", group = "Security" }, -] -# filter out the commits that are not matched by commit parsers -filter_commits = false -# sort the tags topologically -topo_order = false -# sort the commits inside sections by oldest/newest order -sort_commits = "oldest" diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/nuget-pack.ps1 b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/nuget-pack.ps1 deleted file mode 100644 index c3c10d7a..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins.AspNetCore/nuget-pack.ps1 +++ /dev/null @@ -1 +0,0 @@ -dotnet pack -c Release \ No newline at end of file diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/BasePlugin.cs b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/BasePlugin.cs deleted file mode 100644 index 62a4b1ce..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/BasePlugin.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace PluginCore.IPlugins -{ - public abstract class BasePlugin : IPlugin - { - /// - /// 在启用插件之后: 这时插件Assemblies已被加载(插件上下文已load) - /// - /// - /// 当 IsSuccess 为 False, 主程序之后会回滚插件状态: (1)unload插件上下文 (2)更新plugin.config.json,标记为禁用状态 - /// - public virtual (bool IsSuccess, string Message) AfterEnable() - { - return (true, "启用成功"); - } - - /// - /// 在禁用插件之前: 这时插件Assemblies还未被释放(插件上下文未Unload) - /// - /// - /// 只有当 IsSuccess 为 True, 主程序之后才会释放插件上下文, 并标记为已禁用 - /// 当 IsSuccess 为 False, 主程序不会释放插件上下文,也不会标记为禁用, 插件维持原状态 - /// - public virtual (bool IsSuccess, string Message) BeforeDisable() - { - return (true, "禁用成功"); - } - - /// - /// TODO: 更新未做 - /// - /// - /// - /// - public virtual (bool IsSuccess, string Message) Update(string currentVersion, string targetVersion) - { - return (true, "更新成功"); - } - - public virtual void AppStart() - { - - } - - public virtual List AppStartOrderDependPlugins - { - get - { - return new List(); - } - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/CHANGELOG.md b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/CHANGELOG.md deleted file mode 100644 index 1f548fdf..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/CHANGELOG.md +++ /dev/null @@ -1,141 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines. - ---- -## [unreleased] - -### Documentation - -- **(CHANGELOG.md)** update - ([0bbfc89](https://github.com/yiyungent/PluginCore/commit/0bbfc8955b7f6338db2125c78ec250e9eeeadcce)) - github-actions[bot] -- **(CHANGELOG.md)** update - ([4f6b47b](https://github.com/yiyungent/PluginCore/commit/4f6b47b3f86bfce4a8f660166837a7322c568d78)) - github-actions[bot] - -### Miscellaneous Chores - -- **(cliff.toml)** add - ([5614ef0](https://github.com/yiyungent/PluginCore/commit/5614ef024d644349095e19a0016bb23d989b0c90)) - yiyun - ---- -## [PluginCore.IPlugins-v0.9.1](https://github.com/yiyungent/PluginCore/compare/PluginCore.IPlugins-v0.9.0..PluginCore.IPlugins-v0.9.1) - 2023-12-30 - -### Features - -- **(src/**/*.cs)** // License: Apache-2.0 -> // License: GNU LGPLv3 - ([57366d3](https://github.com/yiyungent/PluginCore/commit/57366d3e2afdb8e20e94851aa8a09f1ee61b6d7e)) - yiyun -- **(src/**/*.cs)** // Project: https://moeci.com/PluginCore -> // Project: https://yiyungent.github.io/PluginCore - ([7420480](https://github.com/yiyungent/PluginCore/commit/742048065978c1b8597fab3d52f011db4247fbda)) - yiyun -- **(src/plugincore.iplugins/constants.cs)** add - ([1278d0f](https://github.com/yiyungent/PluginCore/commit/1278d0f4acaa201869e0eb014156e14c6575cd00)) - yiyun -- **(src/plugincore.iplugins/constants.cs)** add: AspNetCoreAuthenticationScheme - ([697fe42](https://github.com/yiyungent/PluginCore/commit/697fe422408eec364075689c60aa9771113e1bd2)) - yiyun -- **(src/plugincore.iplugins/constants.cs)** add: AspNetCoreLanguageCookieName = "language" - ([e3f1196](https://github.com/yiyungent/PluginCore/commit/e3f119655739a510a6804101c4e5d7067719ff86)) - yiyun -- **(src/plugincore.iplugins/constants.cs)** add: AspNetCoreLanguageKey = "PluginCore.Admin.Language" - ([b50fa81](https://github.com/yiyungent/PluginCore/commit/b50fa81fb9efa87ae8048ab1925d3f79ec7c869c)) - yiyun - -### Miscellaneous Chores - -- **(src/plugincore.iplugins/plugincore.iplugins.csproj)** 0.9.0 -> 0.9.1 - ([d842de1](https://github.com/yiyungent/PluginCore/commit/d842de15552e19f7ba8f75e5ef89c68713ef31a5)) - yiyun - ---- -## [PluginCore.IPlugins-v0.9.0](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.0.2..PluginCore.IPlugins-v0.9.0) - 2023-02-15 - -### Features - -- **(plugincore.aspnetcore,plugincore.iplugins,plugincore)** 仅保留已启用/已禁用 状态, IPlugin新方法 - ([e843a5b](https://github.com/yiyungent/PluginCore/commit/e843a5ba9fad4e88290c09bb3282b730c44c5a06)) - yiyun - -### Build - -- **(src/plugincore.iplugins/plugincore.iplugins.csproj)** 0.9.0 - ([4f07e99](https://github.com/yiyungent/PluginCore/commit/4f07e99d176421853e276c2a83e84433592f5112)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.0.2](https://github.com/yiyungent/PluginCore/compare/PluginCore.IPlugins-v0.8.0..PluginCore.AspNetCore-v1.0.2) - 2022-04-19 - -### Style - -- add: copyright: *.cs - ([9643dce](https://github.com/yiyungent/PluginCore/commit/9643dce112861a440d63306cb555accbed3d5111)) - yiyun - ---- -## [PluginCore.IPlugins-v0.8.0](https://github.com/yiyungent/PluginCore/compare/PluginCore.IPlugins-v0.7.0..PluginCore.IPlugins-v0.8.0) - 2022-04-16 - -### Miscellaneous Chores - -- **(plugincore.iplugins.csproj)** 0.8.0 - ([853e638](https://github.com/yiyungent/PluginCore/commit/853e63850940aeecc0492bb12da54c548321e408)) - yiyun - -### Refactoring - -- 1.提取出 PluginCore.AspNetCore,PluginCore.IPlugins.AspNetCore 2.提取出更多接口,可自由替换 - ([fffd8d9](https://github.com/yiyungent/PluginCore/commit/fffd8d91c23fd6e4a4d09cbf91975beb3cf7acf0)) - yiyun - ---- -## [PluginCore.IPlugins-v0.7.0](https://github.com/yiyungent/PluginCore/compare/PluginCore.IPlugins-v0.6.1..PluginCore.IPlugins-v0.7.0) - 2022-02-09 - -### Features - -- **(helloworldplugin.cs,iwidgetplugin.cs,plugincore)** add: Plugin Widget - ([0f010e9](https://github.com/yiyungent/PluginCore/commit/0f010e9cb9b11c4ccda51c40656dc5fd82a16a01)) - yiyun - -### Miscellaneous Chores - -- **(plugincore.iplugins.csproj)** 0.7.0 - ([87eda42](https://github.com/yiyungent/PluginCore/commit/87eda427bae83181559de92abaa8241f6e94199a)) - yiyun - ---- -## [PluginCore.IPlugins-v0.6.1](https://github.com/yiyungent/PluginCore/compare/PluginCore.IPlugins-v0.6.0..PluginCore.IPlugins-v0.6.1) - 2021-09-01 - -### Features - -- **(pluginsettingsmodelfactory.cs,plugincore.iplugins.csproj)** remove: Newtonsoft.Json - ([84db1d3](https://github.com/yiyungent/PluginCore/commit/84db1d3f2bf9bae71320883b4c92f7e0f565bf15)) - yiyun - -### Miscellaneous Chores - -- **(plugincore.iplugins.csproj)** 0.6.1 - ([97e88ed](https://github.com/yiyungent/PluginCore/commit/97e88edeacd7b2526f5899db67d66165eb3f4dc9)) - yiyun - ---- -## [PluginCore.IPlugins-v0.6.0](https://github.com/yiyungent/PluginCore/compare/PluginCore.IPlugins-v0.5.0..PluginCore.IPlugins-v0.6.0) - 2021-08-21 - -### Features - -- **(testtimejobplugin,plugincore.iplugins,plugincore)** timeJobPlugin 相关 - ([55d4f4c](https://github.com/yiyungent/PluginCore/commit/55d4f4ca7ddd9738216b9434ad1c30ef75f06471)) - yiyun - -### Miscellaneous Chores - -- **(plugincore.iplugins.csproj)** 0.6.0 - ([402abb3](https://github.com/yiyungent/PluginCore/commit/402abb38d25c8677b671e8e4ac3aa3f08fb33f51)) - yiyun - ---- -## [PluginCore.IPlugins-v0.5.0](https://github.com/yiyungent/PluginCore/compare/PluginCore.IPlugins-v0.4.0..PluginCore.IPlugins-v0.5.0) - 2021-08-21 - -### Features - -- **(plugins,plugincore.iplugins,plugincore)** add: order, add: PluginApplicationBuilderManager - ([5e4a5f4](https://github.com/yiyungent/PluginCore/commit/5e4a5f46a4eb3aaca5d978fc1e695d0849e11e5c)) - yiyun - -### Miscellaneous Chores - -- **(plugincore.iplugins.csproj)** 0.5.0 - ([60eaa08](https://github.com/yiyungent/PluginCore/commit/60eaa08c68e46668d9a6d83b2b7664c6843fadd3)) - yiyun - ---- -## [PluginCore.IPlugins-v0.4.0](https://github.com/yiyungent/PluginCore/compare/PluginCore.IPlugins-v0.2.0..PluginCore.IPlugins-v0.4.0) - 2021-08-20 - -### Features - -- **(istartupplugin.cs,istartupxplugin.cs)** 添加注释 - ([d4519b5](https://github.com/yiyungent/PluginCore/commit/d4519b54e9df931c6e75d9ca59742edc5f3185ac)) - yiyun -- **(plugincore)** pluginContentFilterMiddleware, IContentFilterPlugin - ([2597e9c](https://github.com/yiyungent/PluginCore/commit/2597e9c054bde134f9f250071347990be59e8d37)) - yiyun -- **(plugincore,/plugincore.iplugins)** pluginHttpEndFilter - ([c0cd458](https://github.com/yiyungent/PluginCore/commit/c0cd4581df72cdb9f4f678a531e7f04980c9695d)) - yiyun -- **(plugincore,plugincore.iplugins,helloworldplugin)** iStartupXPlugin: 运行时 Configure(app) - ([0d18a6f](https://github.com/yiyungent/PluginCore/commit/0d18a6f9949faa1e92f1d20da35689e8e153bac1)) - yiyun -- **(plugincore.iplugins)** iStartupPlugin.cs, PluginCore.IPlugins.csproj - ([4459fbe](https://github.com/yiyungent/PluginCore/commit/4459fbe5e2cbe369519b7010a7b7d6d4600738cf)) - yiyun -- **(plugincore.iplugins.csproj)** 0.3.0 - ([c8000be](https://github.com/yiyungent/PluginCore/commit/c8000bec4800826afa5db37edfb095a945231591)) - yiyun -- 生成注释xml: PluginCore.IPlugins,PluginCore - ([5878148](https://github.com/yiyungent/PluginCore/commit/5878148244344f412e75fe9446824dd99ca2de47)) - yiyun - -### Miscellaneous Chores - -- **(plugincore.iplugins)** 注释 - ([4fe65ce](https://github.com/yiyungent/PluginCore/commit/4fe65ce4e731e1a67d35f2c202239f062fe45adc)) - yiyun -- **(plugincore.iplugins.csproj)** 0.4.0 - ([a6e8851](https://github.com/yiyungent/PluginCore/commit/a6e8851b75dabb8ca68d8e14124a1332e7c13ad7)) - yiyun - ---- -## [PluginCore.IPlugins-v0.2.0](https://github.com/yiyungent/PluginCore/compare/PluginCore.IPlugins-v0.1.0..PluginCore.IPlugins-v0.2.0) - 2021-08-10 - -### Features - -- **(plugincore.iplugins.csproj)** 0.2.0 - ([d7fb02f](https://github.com/yiyungent/PluginCore/commit/d7fb02fe481e1b2d20a7f7b34f0fa50e95240059)) - yiyun -- plugin 支持加载插件 wwwroot 文件夹下的 html前端等 - ([273f9a4](https://github.com/yiyungent/PluginCore/commit/273f9a44c8727675f60d364fcf59a373958b3575)) - yiyun - ---- -## [PluginCore.IPlugins-v0.1.0] - 2021-08-08 - -### Features - -- pluginCore.IPlugins, plugins: HelloWorldPlugin - ([1e81de2](https://github.com/yiyungent/PluginCore/commit/1e81de2107394f527a94ec5d4c2ae6853d2d5526)) - yiyun -- pluginCore, plugins/HelloWorldPlugin - ([5141afd](https://github.com/yiyungent/PluginCore/commit/5141afded8feba94af581d6132fccb87aafa516c)) - yiyun -- nuget config, v0.1.0 - ([fffc419](https://github.com/yiyungent/PluginCore/commit/fffc419480481b632340eb4e42a0b608c5fff144)) - yiyun - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Constants.cs b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Constants.cs deleted file mode 100644 index ded28eb2..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Constants.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -using System; - -namespace PluginCore.IPlugins -{ - public class Constants - { - public const string AspNetCoreAuthenticationClaimType = "PluginCore.Admin.Token"; - - public const string AspNetCoreAuthenticationScheme = "PluginCore.Admin.Authentication"; - - public const string AspNetCoreAuthorizationPolicyName = "PluginCore.Admin"; - - public const string AspNetCoreAuthorizationTokenCookieName = "PluginCore.Admin.Token"; - - /// - /// zh - /// en - /// - public const string AspNetCoreLanguageCookieName = "language"; - - /// - /// httpContext.Items[Constants.AspNetCoreLanguageKey] - /// - public const string AspNetCoreLanguageKey = "PluginCore.Admin.Language"; - } -} diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/IPlugin.cs b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/IPlugin.cs deleted file mode 100644 index 3d533b6d..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/IPlugin.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace PluginCore.IPlugins -{ - public interface IPlugin - { - /// - /// 在启用插件之后: 这时插件Assemblies已被加载(插件上下文已load) - /// - /// - /// 当 IsSuccess 为 False, 主程序之后会回滚插件状态: (1)unload插件上下文 (2)更新plugin.config.json,标记为禁用状态 - /// - (bool IsSuccess, string Message) AfterEnable(); - - /// - /// 在禁用插件之前: 这时插件Assemblies还未被释放(插件上下文未Unload) - /// - /// - /// 只有当 IsSuccess 为 True, 主程序之后才会释放插件上下文, 并标记为已禁用 - /// 当 IsSuccess 为 False, 主程序不会释放插件上下文,也不会标记为禁用, 插件维持原状态 - /// - (bool IsSuccess, string Message) BeforeDisable(); - - /// - /// TODO: 更新未做 - /// - /// - /// - /// - (bool IsSuccess, string Message) Update(string currentVersion, string targetVersion); - - /// - /// 主应用程序启动时 - /// - void AppStart(); - - /// - /// 启动顺序: 此插件 所依赖的前置插件 - /// - /// - List AppStartOrderDependPlugins { get; } - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/IPlugins/ITimeJobPlugin.cs b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/IPlugins/ITimeJobPlugin.cs deleted file mode 100644 index 19e133c2..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/IPlugins/ITimeJobPlugin.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; - -namespace PluginCore.IPlugins -{ - /// - /// 定时任务 - /// - public interface ITimeJobPlugin : IPlugin - { - /// - /// 间隔秒数 - /// - long SecondsPeriod { get; } - - Task ExecuteAsync(); - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/IPlugins/IWidgetPlugin.cs b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/IPlugins/IWidgetPlugin.cs deleted file mode 100644 index 5530f396..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/IPlugins/IWidgetPlugin.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; - -namespace PluginCore.IPlugins -{ - public interface IWidgetPlugin : IPlugin - { - // 这种方式限定: 不合适, 一个插件, 可能需要注入多个地方 - //string WidgetKey { get; } - - Task Widget(string widgetKey, params string[] extraPars); - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Infrastructure/PluginPathProvider.cs b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Infrastructure/PluginPathProvider.cs deleted file mode 100644 index 1db7d4cc..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Infrastructure/PluginPathProvider.cs +++ /dev/null @@ -1,215 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Reflection; - -namespace PluginCore -{ - public class PluginPathProvider - { - - static PluginPathProvider() - { - // 初始化插件目录 - string appDataDir = Path.Combine(Directory.GetCurrentDirectory(), "App_Data"); - if (!Directory.Exists(appDataDir)) - { - Directory.CreateDirectory(appDataDir); - } - - string pluginConfigJsonFilePath = Path.Combine(Directory.GetCurrentDirectory(), "App_Data", "plugin.config.json"); - string pluginConfigJson = "{\"EnabledPlugins\":[],\"DisabledPlugins\":[],\"UninstalledPlugins\":[]}"; - if (!File.Exists(pluginConfigJsonFilePath)) - { - File.WriteAllText(pluginConfigJsonFilePath, pluginConfigJson, System.Text.Encoding.UTF8); - } - - string tempPluginUploadDir = TempPluginUploadDir(); - if (!Directory.Exists(tempPluginUploadDir)) - { - Directory.CreateDirectory(tempPluginUploadDir); - } - - string pluginsDir = PluginsRootPath(); - if (!Directory.Exists(pluginsDir)) - { - Directory.CreateDirectory(pluginsDir); - } - - string pluginsWwwRootDir = PluginsWwwRootDir(); - if (!Directory.Exists(pluginsWwwRootDir)) - { - Directory.CreateDirectory(pluginsWwwRootDir); - } - - string pluginCoreAdminDir = PluginCoreAdminDir(); - if (!Directory.Exists(pluginCoreAdminDir)) - { - Directory.CreateDirectory(pluginCoreAdminDir); - } - } - - /// - /// 临时插件上传目录路径 - /// eg: F:\Com\me\Repos\Remember.Core\src\Presentation\WebApi\App_Data\TempPluginUpload - /// - /// - public static string TempPluginUploadDir() - { - string tempPluginUploadDir = Path.Combine(Directory.GetCurrentDirectory(), "App_Data", "TempPluginUpload"); - return tempPluginUploadDir; - } - - /// - /// 获取 Plugins 的路径 - /// - /// - public static string PluginsRootPath() - { - string pluginRootPath = Path.Combine(Directory.GetCurrentDirectory(), "Plugins"); - - return pluginRootPath; - } - - /// - /// 获取目标插件文件夹名 - /// - /// 目标插件完整目录路径 - /// - public static string GetPluginFolderNameByDir(string pluginDir) - { - string pluginRootPath = PluginsRootPath(); - string pluginFolderName = pluginDir.Replace(pluginRootPath + Path.DirectorySeparatorChar, ""); - - return pluginFolderName; - } - - /// - /// 所有插件的完整目录路径 - /// - /// - public static IList AllPluginDir() - { - string pluginRootPath = PluginsRootPath(); - string[] pluginDirs = Directory.GetDirectories(pluginRootPath, "*"); - - return pluginDirs; - } - - /// - /// 所有插件的文件夹名 - /// - /// - public static IList AllPluginFolderName() - { - IList pluginFolderNames = new List(); - IList pluginDirs = AllPluginDir(); - foreach (var dir in pluginDirs) - { - string pluginFolderName = GetPluginFolderNameByDir(dir); - pluginFolderNames.Add(pluginFolderName); - } - - return pluginFolderNames; - } - - /// - /// Plugins/{pluginId}/wwwroot - /// - /// - - public static string WwwRootDir(string pluginId) - { - string wwwrootDir = Path.Combine(PluginsRootPath(), pluginId, "wwwroot"); - - return wwwrootDir; - } - - /// - /// Plugins/{currentPluginId}/wwwroot - /// - /// - //public static string CurrentWwwRootDir() - //{ - // string wwwrootDir = Path.Combine(PluginsRootPath(), CurrentPluginId(), "wwwroot"); - - // return wwwrootDir; - //} - - - /// - /// Plugins_wwwroot - /// - /// - public static string PluginsWwwRootDir() - { - string pluginsWwwRootDir = Path.Combine(Directory.GetCurrentDirectory(), "Plugins_wwwroot"); - - return pluginsWwwRootDir; - } - - /// - /// Plugins_wwwroot/pluginId - /// - /// - /// - public static string PluginWwwRootDir(string pluginId) - { - string pluginWwwRootDir = Path.Combine(PluginsWwwRootDir(), pluginId); - - return pluginWwwRootDir; - } - - /// - /// Plugins_wwwroot/currentPluginId - /// - /// - //public static string CurrentPluginWwwRootDir() - //{ - // string pluginId = CurrentPluginId(); - - // string pluginWwwRootDir = PluginWwwRootDir(pluginId); - - // return pluginWwwRootDir; - //} - - public static string PluginCoreAdminDir() - { - string pluginCoreAdminDir = Path.Combine(Directory.GetCurrentDirectory(), "PluginCoreAdmin"); - - return pluginCoreAdminDir; - } - - - /// - /// 规范: - /// PluginId = 插件程序集名 (PluginId.dll) - /// - /// TODO: 无法获取当前 PluginId - /// - /// - //public static string CurrentPluginId() - //{ - // //var ass = Assembly.GetExecutingAssembly(); // 错误: PluginCore.IPlugins - // //var ass = Assembly.GetCallingAssembly(); // 错误: PluginCore.IPlugins - // //var ass = Assembly.GetEntryAssembly(); // 错误: AspNetCore3_1 - - - // string pluginId = ass.GetName().Name; - - // return pluginId; - //} - - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Infrastructure/PluginSettingsModelFactory.cs b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Infrastructure/PluginSettingsModelFactory.cs deleted file mode 100644 index df5bc86d..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Infrastructure/PluginSettingsModelFactory.cs +++ /dev/null @@ -1,164 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using PluginCore.Models; - - -namespace PluginCore -{ - public class PluginSettingsModelFactory - { - // TODO: Linux 文件名下区分大小写, windows不区分, 目前必须为 README.md - private const string SettingsFile = "settings.json"; - - #region 即时读取 - public static T Create - (string pluginId) - where T : PluginSettingsModel - { - PluginSettingsModel rtnModel = new PluginSettingsModel(); - string pluginDir = Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId); - string pluginSettingsFilePath = Path.Combine(pluginDir, SettingsFile); - - if (!File.Exists(pluginSettingsFilePath)) - { - return null; - } - try - { - string settingsStr = File.ReadAllText(pluginSettingsFilePath, Encoding.UTF8); - rtnModel = System.Text.Json.JsonSerializer.Deserialize(settingsStr); - } - catch - { - rtnModel = null; - } - - return rtnModel as T; - } - - public static string Create - (string pluginId) - { - string rtnStr = string.Empty; - string pluginDir = Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId); - string pluginSettingsFilePath = Path.Combine(pluginDir, SettingsFile); - - if (!File.Exists(pluginSettingsFilePath)) - { - return null; - } - try - { - rtnStr = File.ReadAllText(pluginSettingsFilePath, Encoding.UTF8); - } - catch - { - rtnStr = null; - } - - return rtnStr; - } - #endregion - - #region 保存 - public static void Save(T pluginSettingsModel, string pluginId) - where T : PluginSettingsModel - { - if (pluginSettingsModel == null) - { - throw new ArgumentNullException(nameof(pluginSettingsModel)); - } - try - { - string pluginSettingsJsonStr = System.Text.Json.JsonSerializer.Serialize(pluginSettingsModel); - string pluginSettingsFilePath = Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId, SettingsFile); - //File.WriteAllText(pluginSettingsFilePath, pluginSettingsJsonStr, Encoding.UTF8); - // 写的时候加缩进 - File.WriteAllText(pluginSettingsFilePath, ConvertJsonString(pluginSettingsJsonStr), Encoding.UTF8); - } - catch - { } - - } - - public static void Save(string pluginSettingsJsonStr, string pluginId) - { - if (pluginSettingsJsonStr == null) - { - throw new ArgumentNullException(nameof(pluginSettingsJsonStr)); - } - try - { - string pluginSettingsFilePath = Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId, SettingsFile); - //File.WriteAllText(pluginSettingsFilePath, pluginSettingsJsonStr, Encoding.UTF8); - // 写的时候加缩进 - File.WriteAllText(pluginSettingsFilePath, ConvertJsonString(pluginSettingsJsonStr), Encoding.UTF8); - } - catch - { } - - } - #endregion - - #region 格式化JSON字符串 - private static string ConvertJsonString(string str) - { - //格式化json字符串 - #region 使用Newtonsoft.Json格式化 JSON字符串 - //Newtonsoft.Json.JsonSerializer serializer = new Newtonsoft.Json.JsonSerializer(); - //TextReader tr = new StringReader(str); - //Newtonsoft.Json.JsonTextReader jtr = new Newtonsoft.Json.JsonTextReader(tr); - //object obj = serializer.Deserialize(jtr); - //if (obj != null) - //{ - // StringWriter textWriter = new StringWriter(); - // Newtonsoft.Json.JsonTextWriter jsonWriter = new Newtonsoft.Json.JsonTextWriter(textWriter) - // { - // Formatting = Newtonsoft.Json.Formatting.Indented, - // Indentation = 4, - // IndentChar = ' ' - // }; - // serializer.Serialize(jsonWriter, obj); - // return textWriter.ToString(); - //} - //else - //{ - // return str; - //} - #endregion - - #region 使用 System.Text.Json 格式化 JSON字符串 - // https://blog.csdn.net/essity/article/details/84644510 - System.Text.Json.JsonSerializerOptions options = new System.Text.Json.JsonSerializerOptions(); - // 设置支持中文的unicode编码: 这样就不会自动转码,而是原样展现 - options.Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping; - // 启用缩进设置 - options.WriteIndented = true; - - // 注意: object 不会丢失json数据, 但不能使用 dynamic, 会报编译错误 - object jsonObj = System.Text.Json.JsonSerializer.Deserialize(str); - - // Error CS0656 Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create' - // dynamic jsonObj = System.Text.Json.JsonSerializer.Deserialize(str); - - string rtnStr = System.Text.Json.JsonSerializer.Serialize(jsonObj, options); - - return rtnStr; - #endregion - } - #endregion - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Interfaces/IPluginFinder.cs b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Interfaces/IPluginFinder.cs deleted file mode 100644 index 88017687..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Interfaces/IPluginFinder.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; -using PluginCore.IPlugins; - -namespace PluginCore.Interfaces -{ - public interface IPluginFinder - { - #region 实现了指定接口或类型 的启用插件 - - /// - /// 实现了指定接口或类型 的启用插件 - /// - /// 可以是一个接口,一个抽象类,一个普通实现类, 只要实现了 即可 - /// - IEnumerable EnablePlugins() - where TPlugin : IPlugin; // BasePlugin - - /// - /// 实现了指定接口或类型 的启用插件 - /// - /// 可以是一个接口,一个抽象类,一个普通实现类, 只要实现了 即可 - /// - IEnumerable<(TPlugin PluginInstance, string PluginId)> EnablePluginsFull() - where TPlugin : IPlugin; // BasePlugin - - /// - /// 所有启用的插件 的 PluginId - /// - /// - IEnumerable EnablePluginIds() - where TPlugin : IPlugin; // BasePlugin - #endregion - - #region 所有启用的插件 - - /// - /// 所有启用的插件 - /// - /// - IEnumerable EnablePlugins(); - - /// - /// 所有启用的插件 - /// - /// - IEnumerable<(IPlugin PluginInstance, string PluginId)> EnablePluginsFull(); - - /// - /// 所有启用的插件 的 PluginId - /// - /// - IEnumerable EnablePluginIds(); - #endregion - - #region 获取指定 pluginId 的启用插件 - - /// - /// 获取指定 pluginId 的启用插件 - /// - /// - /// 1.插件未启用返回null, 2.找不到此插件上下文返回null 3.找不到插件主dll返回null 4.插件主dll中找不到实现了IPlugin的Type返回null, 5.无法实例化插件返回null - IPlugin Plugin(string pluginId); - #endregion - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Interfaces/IPluginManager.cs b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Interfaces/IPluginManager.cs deleted file mode 100644 index 5ff73a14..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Interfaces/IPluginManager.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Text; - -namespace PluginCore.Interfaces -{ - public interface IPluginManager - { - void LoadPlugin(string pluginId); - - void UnloadPlugin(string pluginId); - /// - /// 加载插件程序集 - /// - /// - Assembly GetPluginAssembly(string pluginId); - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Models/PluginSettingsModel.cs b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Models/PluginSettingsModel.cs deleted file mode 100644 index d2fb4193..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/Models/PluginSettingsModel.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace PluginCore.Models -{ - /// - /// 插件设置模型 - /// 对应插件目录下 settings.json - /// 插件开发者自己的插件设置模型 必须继承该类 - /// - public class PluginSettingsModel - { - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/PluginCore.IPlugins.csproj b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/PluginCore.IPlugins.csproj deleted file mode 100644 index ee83e6df..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/PluginCore.IPlugins.csproj +++ /dev/null @@ -1,29 +0,0 @@ - - - - net8.0;net9.0 - PluginCore.IPlugins - 0.9.1 - yiyun - yiyun - PluginCore 插件开发包 - Copyright (c) 2021-present yiyun - https://github.com/yiyungent/PluginCore - https://github.com/yiyungent/PluginCore/blob/main/LICENSE - PluginCore PluginCore.IPlugin - true - - - - - bin\Release\netstandard2.0\PluginCore.IPlugins.xml - - - - - - - - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/cliff.toml b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/cliff.toml deleted file mode 100644 index aa3089f4..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/cliff.toml +++ /dev/null @@ -1,82 +0,0 @@ -# git-cliff ~ configuration file -# https://git-cliff.org/docs/configuration - -[changelog] -# template for the changelog header -header = """ -# Changelog\n -All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.\n -""" -# template for the changelog body -# https://keats.github.io/tera/docs/#introduction -body = """ ---- -{% if version %}\ - {% if previous.version %}\ - ## [{{ version | trim_start_matches(pat="v") }}]($REPO/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }} - {% else %}\ - ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} - {% endif %}\ -{% else %}\ - ## [unreleased] -{% endif %}\ -{% for group, commits in commits | group_by(attribute="group") %} - ### {{ group | striptags | trim | upper_first }} - {% for commit in commits - | filter(attribute="scope") - | sort(attribute="scope") %} - - **({{commit.scope}})**{% if commit.breaking %} [**breaking**]{% endif %} \ - {{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }} - {%- endfor -%} - {% raw %}\n{% endraw %}\ - {%- for commit in commits %} - {%- if commit.scope -%} - {% else -%} - - {% if commit.breaking %} [**breaking**]{% endif %}\ - {{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }} - {% endif -%} - {% endfor -%} -{% endfor %}\n -""" -# template for the changelog footer -footer = """ - -""" -# remove the leading and trailing whitespace from the templates -trim = true -# postprocessors -postprocessors = [ - { pattern = '\$REPO', replace = "https://github.com/yiyungent/PluginCore" }, # replace repository URL -] - -[git] -# parse the commits based on https://www.conventionalcommits.org -conventional_commits = true -# filter out the commits that are not conventional -filter_unconventional = true -# process each line of a commit as an individual commit -split_commits = false -# regex for preprocessing the commit messages -commit_preprocessors = [ - # { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/orhun/git-cliff/issues/${2}))"}, # replace issue numbers -] -# regex for parsing and grouping commits -commit_parsers = [ - { message = "^feat", group = "Features" }, - { message = "^fix", group = "Bug Fixes" }, - { message = "^doc", group = "Documentation" }, - { message = "^perf", group = "Performance" }, - { message = "^refactor", group = "Refactoring" }, - { message = "^style", group = "Style" }, - { message = "^revert", group = "Revert" }, - { message = "^test", group = "Tests" }, - { message = "^chore\\(version\\):", skip = true }, - { message = "^chore", group = "Miscellaneous Chores" }, - { body = ".*security", group = "Security" }, -] -# filter out the commits that are not matched by commit parsers -filter_commits = false -# sort the tags topologically -topo_order = false -# sort the commits inside sections by oldest/newest order -sort_commits = "oldest" diff --git a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/nuget-pack.ps1 b/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/nuget-pack.ps1 deleted file mode 100644 index c3c10d7a..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore.IPlugins/nuget-pack.ps1 +++ /dev/null @@ -1 +0,0 @@ -dotnet pack -c Release \ No newline at end of file diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/CHANGELOG.md b/Admin.NET/Plugins/PluginCore/PluginCore/CHANGELOG.md deleted file mode 100644 index 58d606ec..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/CHANGELOG.md +++ /dev/null @@ -1,396 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines. - ---- -## [unreleased] - -### Documentation - -- **(CHANGELOG.md)** update - ([0bbfc89](https://github.com/yiyungent/PluginCore/commit/0bbfc8955b7f6338db2125c78ec250e9eeeadcce)) - github-actions[bot] -- **(CHANGELOG.md)** update - ([4f6b47b](https://github.com/yiyungent/PluginCore/commit/4f6b47b3f86bfce4a8f660166837a7322c568d78)) - github-actions[bot] - -### Miscellaneous Chores - -- **(cliff.toml)** add - ([5614ef0](https://github.com/yiyungent/PluginCore/commit/5614ef024d644349095e19a0016bb23d989b0c90)) - yiyun - -### Ci - -- **(changelog.yml)** changelog.yml, PluginCore/CHANGELOG.md - ([34ab464](https://github.com/yiyungent/PluginCore/commit/34ab46467101933f3b4b966fbe9c7a21f510494e)) - yiyun - ---- -## [PluginCore-v2.2.5](https://github.com/yiyungent/PluginCore/compare/PluginCore-v2.2.4..PluginCore-v2.2.5) - 2024-04-06 - -### Bug Fixes - -- **(src/plugincore/lmplements/lazypluginloadcontext.cs)** dll 忽略版本搜索 - ([af8e6e2](https://github.com/yiyungent/PluginCore/commit/af8e6e299726abacdfc0eb125339235a5ee2823d)) - yiyun - -### Build - -- **(src/plugincore/plugincore.csproj)** 2.2.4 -> 2.2.5 - ([f2dad72](https://github.com/yiyungent/PluginCore/commit/f2dad724d336902e64cc5d07c7974fe3d08bb0d7)) - yiyun - ---- -## [PluginCore-v2.2.4](https://github.com/yiyungent/PluginCore/compare/PluginCore-v2.2.3..PluginCore-v2.2.4) - 2024-03-14 - -### Features - -- **(src/plugincore/utils/logutil.cs)** add LogCategoryName - ([9e66363](https://github.com/yiyungent/PluginCore/commit/9e66363b207e1b6b10e11e8e934097530280c37f)) - yiyun - -### Build - -- **(src/plugincore/plugincore.csproj)** 2.2.3 -> 2.2.4 - ([0c20c18](https://github.com/yiyungent/PluginCore/commit/0c20c18c452333540cde8a6036b0c2a8f805b376)) - yiyun - ---- -## [PluginCore-v2.2.3](https://github.com/yiyungent/PluginCore/compare/PluginCore-v2.2.2..PluginCore-v2.2.3) - 2023-12-30 - -### Bug Fixes - -- **(src/plugincore/infrastructure/nupkgservice.cs)** 适配 LogUtil.Error - ([1bbd0ad](https://github.com/yiyungent/PluginCore/commit/1bbd0ad8c2b69accf8f19d28c47857844b42f527)) - yiyun - -### Features - -- **(src/**/*.cs)** // License: Apache-2.0 -> // License: GNU LGPLv3 - ([57366d3](https://github.com/yiyungent/PluginCore/commit/57366d3e2afdb8e20e94851aa8a09f1ee61b6d7e)) - yiyun -- **(src/**/*.cs)** // Project: https://moeci.com/PluginCore -> // Project: https://yiyungent.github.io/PluginCore - ([7420480](https://github.com/yiyungent/PluginCore/commit/742048065978c1b8597fab3d52f011db4247fbda)) - yiyun -- **(src/plugincore)** utils/LogUtil.cs, PluginCore.csproj: 与 ILogger 结合, FrameworkReference - ([d638a76](https://github.com/yiyungent/PluginCore/commit/d638a76fbc5733ec19c7dc24450e18b1c5803f70)) - yiyun -- **(src/plugincore)** 适配: LogUtil - ([7e0de48](https://github.com/yiyungent/PluginCore/commit/7e0de488c570ff869948160c8bee9edfb8f4192f)) - yiyun -- **(src/plugincore/lmplements/plugincontextmanager.cs)** logUtil.Error -> LogUtil.Warn - ([d438fad](https://github.com/yiyungent/PluginCore/commit/d438fadc70749cdcff8d22a50c004541d15cb010)) - yiyun -- **(src/plugincore/utils/logutil.cs)** add 非泛型 - ([e108632](https://github.com/yiyungent/PluginCore/commit/e108632414809f496b9bbc9cd45ac73e58d53d36)) - yiyun -- **(src/plugincore/utils/logutil.cs)** 非泛型: 需指定 categoryName - ([3aa0410](https://github.com/yiyungent/PluginCore/commit/3aa0410b97727651659e15e786572bd7335d5963)) - yiyun -- **(src/plugincore/utils/logutil.cs)** add: Warn, support: (Exception ex, string message) - ([897a910](https://github.com/yiyungent/PluginCore/commit/897a910028fd7dce1410c5ea4ad38b2b2a6a7c03)) - yiyun - -### Build - -- **(plugincore.csproj)** 2.2.2 -> 2.2.3 - ([b0838bc](https://github.com/yiyungent/PluginCore/commit/b0838bc9175c1739972f89fb8c65342d16b112c9)) - yiyun - ---- -## [PluginCore-v2.2.2](https://github.com/yiyungent/PluginCore/compare/PluginCore-v2.2.1..PluginCore-v2.2.2) - 2023-12-14 - -### Bug Fixes - -- **(src/plugincore/lmplements/positivepluginloadcontext.cs)** pluginMainDllFilePath 被打开状态即锁定 - ([4c81402](https://github.com/yiyungent/PluginCore/commit/4c814028fdaa377608cf9eb849bc732a1fcc70cc)) - yiyun - -### Miscellaneous Chores - -- **(src/plugincore/plugincore.csproj)** 2.2.1 -> 2.2.2 - ([dcb3dff](https://github.com/yiyungent/PluginCore/commit/dcb3dffb3062f62ae0ba1e3c8115ae8300aaf9ce)) - yiyun - ---- -## [PluginCore-v2.2.1](https://github.com/yiyungent/PluginCore/compare/PluginCore-v2.2.0..PluginCore-v2.2.1) - 2023-08-21 - -### Features - -- **(src/plugincore/lmplements/pluginfinder*)** pluginFinder.cs, PluginFinderV1.cs - ([721ae36](https://github.com/yiyungent/PluginCore/commit/721ae36750281731f3ae10dfed63c44d013cdc1e)) - yiyun -- **(src/plugincore/lmplements/pluginfinder*)** pluginFinderV2,PluginFinder:PluginFinderV2 - ([6c7ad5f](https://github.com/yiyungent/PluginCore/commit/6c7ad5f56a8649bad33779e6fcc9d2a4aa06271a)) - yiyun - -### Build - -- **(src/plugincore/plugincore.csproj)** 2.2.1 - ([12b322a](https://github.com/yiyungent/PluginCore/commit/12b322a58a148dc908fb3924df9bf8a7fbd129f7)) - yiyun - ---- -## [PluginCore-v2.2.0](https://github.com/yiyungent/PluginCore/compare/PluginCore-v2.1.0..PluginCore-v2.2.0) - 2023-02-15 - -### Bug Fixes - -- **(plugincore.aspnetcore,plugincore)** iList EnabledPlugins->List,IList不支持Remove - ([4d5d30e](https://github.com/yiyungent/PluginCore/commit/4d5d30e66c4c28998a7a6ac96bf3ffb25e4872b4)) - yiyun - -### Features - -- **(plugincore)** pluginInfoModel,PluginConfigModelFactory:前置依赖插件:DependPlugins:建立依赖顺序 - ([f5841ce](https://github.com/yiyungent/PluginCore/commit/f5841ce42c296b93e1e34a6ed9c8a84767beb795)) - yiyun -- **(plugincore.aspnetcore,plugincore.iplugins,plugincore)** 仅保留已启用/已禁用 状态, IPlugin新方法 - ([e843a5b](https://github.com/yiyungent/PluginCore/commit/e843a5ba9fad4e88290c09bb3282b730c44c5a06)) - yiyun - -### Miscellaneous Chores - -- **(src/plugincore/utils/dependencysorter.cs)** // Debug.Assert - ([52421fd](https://github.com/yiyungent/PluginCore/commit/52421fd4d150c8c568c63e8d053fceb66d0a7ff2)) - yiyun - -### Build - -- **(src/plugincore/plugincore.csproj)** `2.2.0` - ([11a2043](https://github.com/yiyungent/PluginCore/commit/11a20435ec261dcbb4b10e7a99ec10d2c80743c7)) - yiyun - ---- -## [PluginCore-v2.1.0](https://github.com/yiyungent/PluginCore/compare/PluginCore-v2.0.2..PluginCore-v2.1.0) - 2023-02-14 - -### Features - -- **(src/plugincore/)** iPluginContext.PluginId - ([45b22e0](https://github.com/yiyungent/PluginCore/commit/45b22e006879043a68dc61ad33800c149784d257)) - yiyun -- **(src/plugincore/lmplements/)** lazyPluginLoadContext,PositivePluginLoadContext - ([d7b9918](https://github.com/yiyungent/PluginCore/commit/d7b9918ff86bded2ad65ae3a2b6251f88a3df185)) - yiyun -- **(src/plugincore/lmplements/)** base(name: pluginId),MainAssemblyName,ReferencedAssemblyNames - ([98be798](https://github.com/yiyungent/PluginCore/commit/98be798bfbd3462d19d96f3dd301d2b916240f70)) - yiyun -- **(src/plugincore/lmplements/pluginloadcontext.cs)** pluginLoadContext : LazyPluginLoadContext - ([8e957ab](https://github.com/yiyungent/PluginCore/commit/8e957ab53b9446eab35e6664f2b4397ff07cc950)) - yiyun - -### Build - -- **(src/plugincore/plugincore.csproj)** 2.1.0 - ([1a24c03](https://github.com/yiyungent/PluginCore/commit/1a24c03b5fa28eb0008e0a82d2e9feaba2d22042)) - yiyun - ---- -## [PluginCore-v2.0.2](https://github.com/yiyungent/PluginCore/compare/PluginCore.AspNetCore-v1.0.2..PluginCore-v2.0.2) - 2023-01-12 - -### Bug Fixes - -- **(pluginloadcontext.cs)** b插件依赖A插件时,B插件无法启用 - ([4eb8dac](https://github.com/yiyungent/PluginCore/commit/4eb8daca89d23602b58b104162fc54910fc39f76)) - yiyun - -### Miscellaneous Chores - -- **(plugincore.csproj)** 2.0.2 - ([b3e5522](https://github.com/yiyungent/PluginCore/commit/b3e5522f02e02f66fcdeed35aed3613b78637ab6)) - yiyun - ---- -## [PluginCore.AspNetCore-v1.0.2](https://github.com/yiyungent/PluginCore/compare/PluginCore-v2.0.1..PluginCore.AspNetCore-v1.0.2) - 2022-04-19 - -### Style - -- add: copyright: *.cs - ([9643dce](https://github.com/yiyungent/PluginCore/commit/9643dce112861a440d63306cb555accbed3d5111)) - yiyun - ---- -## [PluginCore-v2.0.1](https://github.com/yiyungent/PluginCore/compare/PluginCore-v1.0.0..PluginCore-v2.0.1) - 2022-04-17 - -### Bug Fixes - -- **(plugincore)** 临时修复由于 PluginContextManager 单例失败 导致的插件信息丢失 - ([fa613b4](https://github.com/yiyungent/PluginCore/commit/fa613b4c46e41c906fe955eb8f62c3f4937795bc)) - yiyun -- **(plugincore)** pluginLoadContext: LoadFromStream: 使用此方法, 就不会导致dll被锁定 - ([8af287a](https://github.com/yiyungent/PluginCore/commit/8af287a44dc0d61db1cb449b7b3225595ac07f03)) - yiyun - -### Features - -- **(plugincore,plugincore.aspnetcore)** aspNetCorePluginManagerBeta,PluginLoadContext,PluginFinder - ([9d65a59](https://github.com/yiyungent/PluginCore/commit/9d65a590e3e0850251f6d815c322c7c5d9c7cf3f)) - yiyun - -### Refactoring - -- **(plugincore.aspnetcore,plugincore)** 未完成 - ([a151bcd](https://github.com/yiyungent/PluginCore/commit/a151bcda125cb7e9b5fe11d44e1389afa7a1db5e)) - yiyun -- **(plugincore.aspnetcore,plugincore)** 重构v2: 未测试 - ([53dde31](https://github.com/yiyungent/PluginCore/commit/53dde31116bd6455d33f7d7006b6fd1430f3694b)) - yiyun -- **(plugincore.aspnetcore,plugincore)** 变量名,属性名,类名规范化 - ([eaadabf](https://github.com/yiyungent/PluginCore/commit/eaadabfd759228da245af1d9bd5b86e557540d28)) - yiyun - -### Build - -- **(plugincore.csproj)** add:net6.0 ; 2.0.0 - ([3608906](https://github.com/yiyungent/PluginCore/commit/3608906e4860f2514541d7fc0a9d187b2bcd3076)) - yiyun -- **(plugincore.csproj)** 2.0.1 - ([ce4cfa8](https://github.com/yiyungent/PluginCore/commit/ce4cfa87525fb6a2fc4c0f87943213ef13fd34bd)) - yiyun - ---- -## [PluginCore-v1.0.0](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.9.3..PluginCore-v1.0.0) - 2022-04-16 - -### Refactoring - -- 1.提取出 PluginCore.AspNetCore,PluginCore.IPlugins.AspNetCore 2.提取出更多接口,可自由替换 - ([fffd8d9](https://github.com/yiyungent/PluginCore/commit/fffd8d91c23fd6e4a4d09cbf91975beb3cf7acf0)) - yiyun - -### Build - -- **(plugincore.csproj)** 1.0.0 - ([96f6b02](https://github.com/yiyungent/PluginCore/commit/96f6b028b958f415b8013d9786d361f902fa3bea)) - yiyun - ---- -## [PluginCore-v0.9.3](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.9.2..PluginCore-v0.9.3) - 2022-03-15 - -### Bug Fixes - -- **(plugincore,docs)** 更新 PluginCore Admin 前端: `plugincore-admin-frontend-v0.3.1` - ([a9772bb](https://github.com/yiyungent/PluginCore/commit/a9772bb971d19ec05b982d3f2ef2ddfcbc377e6e)) - yiyun - ---- -## [PluginCore-v0.9.2](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.9.1..PluginCore-v0.9.2) - 2022-03-09 - -### Bug Fixes - -- **(authorization/accountmanager.cs)** tokenCookieName = "PluginCore.Admin.Token" - ([c643c3b](https://github.com/yiyungent/PluginCore/commit/c643c3bcee7555118f5004aed64c1f73664ada9c)) - yiyun - ---- -## [PluginCore-v0.9.1](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.9.0..PluginCore-v0.9.1) - 2022-03-08 - -### Bug Fixes - -- **(readme.md,readme_zh.md,releases.md,plugintimejobbackgroundservice.cs,plugincore.csproj)** lock 锁 - ([d233779](https://github.com/yiyungent/PluginCore/commit/d23377993838cdd4fc616b13823964d043b2a526)) - yiyun - ---- -## [PluginCore-v0.9.0](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.8.6..PluginCore-v0.9.0) - 2022-02-09 - -### Features - -- **(helloworldplugin.cs,iwidgetplugin.cs,plugincore)** add: Plugin Widget - ([0f010e9](https://github.com/yiyungent/PluginCore/commit/0f010e9cb9b11c4ccda51c40656dc5fd82a16a01)) - yiyun -- **(pluginwidgetcontroller.cs)** 1.widgetKey.Trim('"', '\'') 2.Content:text/html - ([27ae842](https://github.com/yiyungent/PluginCore/commit/27ae8422c6105328635328cd9170e5aa13243ad1)) - yiyun - -### Build - -- **(plugincore.csproj)** 0.9.0 - ([8f1ca64](https://github.com/yiyungent/PluginCore/commit/8f1ca6470c8c55eb63930e418a6866cc29a5005e)) - yiyun - ---- -## [PluginCore-v0.8.6](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.8.5..PluginCore-v0.8.6) - 2022-02-07 - -### Bug Fixes - -- **(appcentercontroller.cs,pluginscontroller.cs,usercontroller.cs)** add: [HttpGet, HttpPost] - ([85d4f1d](https://github.com/yiyungent/PluginCore/commit/85d4f1d60585173158981dd4f0b2c75dbd43bbe2)) - yiyun - -### Documentation - -- **(readme.md,readme_zh.md,releases.md,src/plugincore/plugincore.csproj)** pluginCore-v0.8.6 - ([345f0f3](https://github.com/yiyungent/PluginCore/commit/345f0f32d3896db03efafc3cad06967fd32d40a2)) - yiyun - ---- -## [PluginCore-v0.8.5](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.8.4..PluginCore-v0.8.5) - 2021-12-16 - -### Miscellaneous Chores - -- **(examples/aspnetcore3_1,plugincore)** pluginsController.cs,DemoModePlugin.csproj - ([f43286a](https://github.com/yiyungent/PluginCore/commit/f43286a10116217d8cb05e1e7dc875669a1159d3)) - yiyun - -### Build - -- **(plugincore)** plugincore-admin-frontend: v0.3.0; PluginCore-v0.8.5 - ([17bdfdb](https://github.com/yiyungent/PluginCore/commit/17bdfdb6026fd8f983a2b685eb9bf03c9504854c)) - yiyun - ---- -## [PluginCore-v0.8.4](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.8.3..PluginCore-v0.8.4) - 2021-09-01 - -### Build - -- **(plugincore.csproj)** 0.8.4 ; PackageReference: PluginCore.IPlugins: 0.6.1 - ([d359350](https://github.com/yiyungent/PluginCore/commit/d359350e7fa9cad5dbacee1d0207926291a2d4f7)) - yiyun - ---- -## [PluginCore-v0.8.3](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.8.2..PluginCore-v0.8.3) - 2021-08-25 - -### Bug Fixes - -- **(plugincore)** pluginManager.cs: SkipDlls: 跳过2: 打包进入1个dll 或 打包进 1个exe - ([c0aa1f5](https://github.com/yiyungent/PluginCore/commit/c0aa1f595e33061f33a1bd6fe89d63dbeadbd0f5)) - yiyun - -### Miscellaneous Chores - -- **(plugincore.csproj)** 0.8.3 - ([0904cdc](https://github.com/yiyungent/PluginCore/commit/0904cdc2267bae2671a9e2bd3b08831a4c2eb4b4)) - yiyun - ---- -## [PluginCore-v0.8.2](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.8.1..PluginCore-v0.8.2) - 2021-08-23 - -### Miscellaneous Chores - -- **(plugincore.csproj)** 0.8.2 - ([11f7757](https://github.com/yiyungent/PluginCore/commit/11f7757747f8990916d60224a8824d54da08d6ef)) - yiyun - ---- -## [PluginCore-v0.8.1](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.8.0..PluginCore-v0.8.1) - 2021-08-23 - -### Bug Fixes - -- **(plugincorestartupextensions.cs,logutil.cs)** utils.LogUtil.PluginBehavior, apply: IStartupPlugin - ([00bfa94](https://github.com/yiyungent/PluginCore/commit/00bfa94a4de5de34bda970ed4524718f250d0fdf)) - yiyun -- userController.cs: avatar url error; upgrade: frontend - ([c842cb7](https://github.com/yiyungent/PluginCore/commit/c842cb7cce2967c37b80a891689ebad610ae2d62)) - yiyun - -### Features - -- **(pluginfinder.cs)** activatedPlugins - ([9076b29](https://github.com/yiyungent/PluginCore/commit/9076b290bfe365b3e111d2280349f62c37aa5402)) - yiyun - -### Miscellaneous Chores - -- **(plugincore.csproj)** 0.8.1 - ([9f37bbf](https://github.com/yiyungent/PluginCore/commit/9f37bbf7fd8fffcb626d7bb5bb419dc551e91dcc)) - yiyun - ---- -## [PluginCore-v0.8.0](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.7.0..PluginCore-v0.8.0) - 2021-08-21 - -### Features - -- **(plugincore)** utils.LogUtil.Info - ([4163a2a](https://github.com/yiyungent/PluginCore/commit/4163a2ac7938ac6fc0741bdf7c1b967d72b55ed0)) - yiyun -- **(testtimejobplugin,plugincore.iplugins,plugincore)** timeJobPlugin 相关 - ([55d4f4c](https://github.com/yiyungent/PluginCore/commit/55d4f4ca7ddd9738216b9434ad1c30ef75f06471)) - yiyun - -### Build - -- **(plugincore.csproj)** pluginCore: 0.8.0; PluginCore.IPlugins: 0.6.0 - ([7213c6d](https://github.com/yiyungent/PluginCore/commit/7213c6d716b8d2191eb102aed268cc3c788a8721)) - yiyun - ---- -## [PluginCore-v0.7.0](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.6.0..PluginCore-v0.7.0) - 2021-08-21 - -### Features - -- **(plugins,plugincore.iplugins,plugincore)** add: order, add: PluginApplicationBuilderManager - ([5e4a5f4](https://github.com/yiyungent/PluginCore/commit/5e4a5f46a4eb3aaca5d978fc1e695d0849e11e5c)) - yiyun -- **(pluginserviceprovide.cs)** add - ([0eb5a28](https://github.com/yiyungent/PluginCore/commit/0eb5a284f89cdca374660623a937178cfec6ebf1)) - yiyun - -### Build - -- **(plugincore.csproj)** 0.7.0, PluginCore.IPlugins: 0.5.0 - ([2992023](https://github.com/yiyungent/PluginCore/commit/2992023e688016d23f99ccf57e3086ff9c9af338)) - yiyun - ---- -## [PluginCore-v0.6.0](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.5.1..PluginCore-v0.6.0) - 2021-08-20 - -### Features - -- **(plugincore,plugincore.iplugins,helloworldplugin)** iStartupXPlugin: 运行时 Configure(app) - ([0d18a6f](https://github.com/yiyungent/PluginCore/commit/0d18a6f9949faa1e92f1d20da35689e8e153bac1)) - yiyun - -### Build - -- **(plugincore.csproj)** 0.6.0 - ([98a4c70](https://github.com/yiyungent/PluginCore/commit/98a4c708234b2379cbcd00868b11e209c275baa0)) - yiyun - ---- -## [PluginCore-v0.5.1](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.4.0..PluginCore-v0.5.1) - 2021-08-19 - -### Bug Fixes - -- **(src/plugincore/controllers/pluginscontroller.cs)** 启用插件: 启用失败时 回滚 - ([49d46c7](https://github.com/yiyungent/PluginCore/commit/49d46c79c3601df3b4899aee38296500c942854b)) - yiyun -- **(src/plugincore/pluginmanager.cs)** 当插件引用dll时, 插件Controller立即使用引用dll时,报错:找不到引用dll - ([d8c79c5](https://github.com/yiyungent/PluginCore/commit/d8c79c5681dc0a2e4a3d36565075c243b6ce44c7)) - yiyun - -### Features - -- **(plugincore)** pluginContentFilterMiddleware, IContentFilterPlugin - ([2597e9c](https://github.com/yiyungent/PluginCore/commit/2597e9c054bde134f9f250071347990be59e8d37)) - yiyun -- **(plugincore,/plugincore.iplugins)** pluginHttpEndFilter - ([c0cd458](https://github.com/yiyungent/PluginCore/commit/c0cd4581df72cdb9f4f678a531e7f04980c9695d)) - yiyun -- localEmbedded: PluginCoreAdmin -> package.json - ([f8be0d2](https://github.com/yiyungent/PluginCore/commit/f8be0d2ce86b26d9f00cf67845daed2853f285f6)) - yiyun -- 生成注释xml: PluginCore.IPlugins,PluginCore - ([5878148](https://github.com/yiyungent/PluginCore/commit/5878148244344f412e75fe9446824dd99ca2de47)) - yiyun -- update: IStartupPlugin success, fix: Plugin.Enable - ([ad950b2](https://github.com/yiyungent/PluginCore/commit/ad950b2802f60da3f950fd3eaf7bf1eee24c84b6)) - yiyun - -### Miscellaneous Chores - -- **(plugincore.csproj)** 0.4.0 -> 0.5.0 - ([658dde4](https://github.com/yiyungent/PluginCore/commit/658dde4156316f340fe4a28df5a8d76c895de872)) - yiyun -- **(src/plugincore/plugincore.csproj)** 0.5.1 - ([f337786](https://github.com/yiyungent/PluginCore/commit/f337786fa11addfbaed948085a946fb1205c4e8e)) - yiyun - -### Build - -- **(plugincore.csproj)** pluginCore.IPlugins: 0.3.0 - ([f29b998](https://github.com/yiyungent/PluginCore/commit/f29b998c926a09fddbfe6c47208b624a87b94b0e)) - yiyun - ---- -## [PluginCore-v0.4.0](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.3.1..PluginCore-v0.4.0) - 2021-08-16 - -### Features - -- **(plugincore.csproj)** 0.4.0 - ([2ef0a92](https://github.com/yiyungent/PluginCore/commit/2ef0a924d5ca4c21245add4d3c05c13909100551)) - yiyun -- 支持 nupkg 格式插件 - ([1aa1d5f](https://github.com/yiyungent/PluginCore/commit/1aa1d5f45208fe273637548cd69f96a770c32c28)) - yiyun -- 支持嵌入式 前端 (打包进dll) - ([7e08cb3](https://github.com/yiyungent/PluginCore/commit/7e08cb33868890227f11645c2b8d4dd022318c94)) - yiyun - ---- -## [PluginCore-v0.3.1](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.3.0..PluginCore-v0.3.1) - 2021-08-10 - -### Bug Fixes - -- authentication: 401 - ([01c5d04](https://github.com/yiyungent/PluginCore/commit/01c5d04e0a11e53c402076a25c1780fc728ccbc3)) - yiyun - -### Features - -- **(plugincore.csproj)** 0.3.1 - ([001ef67](https://github.com/yiyungent/PluginCore/commit/001ef674190418354bf964d7bf042d66717a0828)) - yiyun -- **(plugincoreconfig.cs)** @0.1.3/dist-cdn - ([da3fb7d](https://github.com/yiyungent/PluginCore/commit/da3fb7d5986582c1fde3d27e31fd8b135cd881c4)) - yiyun -- logUtil and apply - ([f0ee2e8](https://github.com/yiyungent/PluginCore/commit/f0ee2e8df4ec3ec17048a0f718340b6e0adb7360)) - yiyun - ---- -## [PluginCore-v0.3.0](https://github.com/yiyungent/PluginCore/compare/PluginCore-v0.2.0..PluginCore-v0.3.0) - 2021-08-10 - -### Features - -- **(plugincore.csproj)** 0.3.0 - ([627ef86](https://github.com/yiyungent/PluginCore/commit/627ef866f464edddb1f836fde83e4cac04d6f4a3)) - yiyun -- plugin 支持加载插件 wwwroot 文件夹下的 html前端等 - ([273f9a4](https://github.com/yiyungent/PluginCore/commit/273f9a44c8727675f60d364fcf59a373958b3575)) - yiyun - ---- -## [PluginCore-v0.2.0](https://github.com/yiyungent/PluginCore/compare/PluginCore.IPlugins-v0.1.0..PluginCore-v0.2.0) - 2021-08-09 - -### Bug Fixes - -- pluginCore Admin: avatar url 404: dist-cdn - ([38ca90c](https://github.com/yiyungent/PluginCore/commit/38ca90c5ff8b5138e1751887b9f60a376158eaad)) - yiyun -- fronted -> frontend - ([c41cfdb](https://github.com/yiyungent/PluginCore/commit/c41cfdbfba02fcfe37981d9aa4c8c05b194363de)) - yiyun - -### Features - -- **(plugincore.csproj)** 0.2.0 - ([4a10e5d](https://github.com/yiyungent/PluginCore/commit/4a10e5d5d5a45a3a763569bb6ef2c46d04a373fe)) - yiyun -- **(plugincorehostingstartup)** failure - ([0803d76](https://github.com/yiyungent/PluginCore/commit/0803d7679313ffa0e9c583d0923bff3412f265d5)) - yiyun -- remoteFronted, remove PluginCoreAdmin - ([81f6982](https://github.com/yiyungent/PluginCore/commit/81f698213cee6383da9d8035165d3881b88bc709)) - yiyun -- 保证 PluginCoreAdmin 文件夹存在 - ([2bf2c0e](https://github.com/yiyungent/PluginCore/commit/2bf2c0e42cbafb03af00ff324f1fb637238de441)) - yiyun - ---- -## [PluginCore.IPlugins-v0.1.0] - 2021-08-08 - -### Bug Fixes - -- api url error, config file with init etc - ([9adb655](https://github.com/yiyungent/PluginCore/commit/9adb6551650b8ede28bec086df13023a2b7d9bf6)) - yiyun - -### Features - -- **(authorization)** authorization, Login - ([5b6f9fa](https://github.com/yiyungent/PluginCore/commit/5b6f9fa989d9739c30ef0d1f0186b876cddc5890)) - yiyun -- **(plugincore/plugincoreadmin)** add - ([802ad74](https://github.com/yiyungent/PluginCore/commit/802ad74efd013f34e9c5f7d5ed3eef8574f2c20b)) - yiyun -- **(pluginframeworkstartupextensions.cs)** useStaticFiles: PluginCoreAdmin - ([b0adb8e](https://github.com/yiyungent/PluginCore/commit/b0adb8e1f31912472946c8c76fe05b5ff85a77b4)) - yiyun -- **(pluginframeworkstartupextensions.cs)** pluginFramework -> PluginCore, app.UseDefaultFiles(); - ([17e1587](https://github.com/yiyungent/PluginCore/commit/17e15879076d36d3d2cf6891181cf823fb78c66d)) - yiyun -- add controllers, examples - ([c7e8553](https://github.com/yiyungent/PluginCore/commit/c7e8553b9bbb6d45eac251e1060acb719fd3dac9)) - yiyun -- 自动初始化插件目录 - ([fe3d162](https://github.com/yiyungent/PluginCore/commit/fe3d162e3a5455d308db55f9b260301f10ff4eee)) - yiyun -- pluginCore.IPlugins, plugins: HelloWorldPlugin - ([1e81de2](https://github.com/yiyungent/PluginCore/commit/1e81de2107394f527a94ec5d4c2ae6853d2d5526)) - yiyun -- pluginCoreConfig, PluginCoreConfigFactory - ([6a0dae2](https://github.com/yiyungent/PluginCore/commit/6a0dae2d222d9f0464b8d158eb87f674529af56e)) - yiyun -- pluginCore, plugins/HelloWorldPlugin - ([5141afd](https://github.com/yiyungent/PluginCore/commit/5141afded8feba94af581d6132fccb87aafa516c)) - yiyun -- logout, Login: pretty - ([5fac6a3](https://github.com/yiyungent/PluginCore/commit/5fac6a3939436d58d860e2529be08a26c7a79946)) - yiyun -- nuget config, v0.1.0 - ([fffc419](https://github.com/yiyungent/PluginCore/commit/fffc419480481b632340eb4e42a0b608c5fff144)) - yiyun - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Config/PluginCoreConfig.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Config/PluginCoreConfig.cs deleted file mode 100644 index 458e8c33..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Config/PluginCoreConfig.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace PluginCore.Config -{ - public class PluginCoreConfig - { - public PluginCoreConfig() - { - this.Admin = new AdminModel(); - } - - public AdminModel Admin { get; set; } - - /// - /// LocalEmbedded - /// LocalFolder - /// RemoteCDN - /// - public string FrontendMode { get; set; } = "LocalEmbedded"; - - public string RemoteFrontend { get; set; } = "https://cdn.jsdelivr.net/gh/yiyungent/plugincore-admin-frontend@0.3.1/dist-cdn"; - - /// - /// 开启后: - /// 1. 页面的 Widget 会显示插件的详细插入点 - /// - public bool PluginWidgetDebug { get; set; } = false; - - public sealed class AdminModel - { - public string UserName { get; set; } = "admin"; - - public string Password { get; set; } = "ABC12345"; - } - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Config/PluginCoreConfigFactory.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Config/PluginCoreConfigFactory.cs deleted file mode 100644 index 8a015acb..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Config/PluginCoreConfigFactory.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Text.Json; -using PluginCore.Models; - -namespace PluginCore.Config -{ - public class PluginCoreConfigFactory - { - private const string FileName = "PluginCore.Config.json"; - - #region 即时读取 - public static PluginCoreConfig Create() - { - PluginCoreConfig pluginCoreConfig = new PluginCoreConfig(); - string pluginCoreConfigFilePath = Path.Combine(Directory.GetCurrentDirectory(), "App_Data", FileName); - string pluginCoreConfigJsonStr = string.Empty; - if (!File.Exists(pluginCoreConfigFilePath)) - { - // 不存在, 则新建初始化默认 - pluginCoreConfigJsonStr = JsonSerializer.Serialize(pluginCoreConfig); - File.WriteAllText(pluginCoreConfigFilePath, pluginCoreConfigJsonStr, Encoding.UTF8); - - return pluginCoreConfig; - } - - pluginCoreConfigJsonStr = File.ReadAllText(pluginCoreConfigFilePath, Encoding.UTF8); - JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions(); - jsonSerializerOptions.PropertyNameCaseInsensitive = true; - pluginCoreConfig = JsonSerializer.Deserialize(pluginCoreConfigJsonStr, jsonSerializerOptions); - - return pluginCoreConfig; - } - #endregion - - #region 保存 - public static void Save(PluginCoreConfig pluginCoreConfig) - { - if (pluginCoreConfig == null) - { - throw new ArgumentNullException(nameof(pluginCoreConfig)); - } - try - { - string pluginCoreConfigJsonStr = JsonSerializer.Serialize(pluginCoreConfig); - string pluginCoreConfigFilePath = Path.Combine(Directory.GetCurrentDirectory(), "App_Data", FileName); - File.WriteAllText(pluginCoreConfigFilePath, pluginCoreConfigJsonStr, Encoding.UTF8); - } - catch (Exception ex) - { } - - } - #endregion - - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Infrastructure/NupkgService.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Infrastructure/NupkgService.cs deleted file mode 100644 index 3cfb112e..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Infrastructure/NupkgService.cs +++ /dev/null @@ -1,147 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; - -namespace PluginCore.Infrastructure -{ - public class NupkgService - { - /// - /// 将 xxx.nupkg 根据当前环境 解压成 对应 插件目录结构 - /// xxx.zip 形式的插件安装包: 直接解压即可 - /// - /// - /// - /// - /// - public static bool DecomparessFile(string sourceFile, string destinationDirectory = null) - { - bool isDecomparessSuccess = false; - - if (!File.Exists(sourceFile)) - { - throw new FileNotFoundException("要解压的文件不存在", sourceFile); - } - - if (string.IsNullOrWhiteSpace(destinationDirectory)) - { - destinationDirectory = Path.GetDirectoryName(sourceFile); - } - - try - { - // 注意: 之前重命名过: Guid.zip - destinationDirectory = destinationDirectory.Replace(".zip", ""); - - isDecomparessSuccess = Utils.ZipHelper.FastDecomparessFile(sourceFile, destinationDirectory); - if (!isDecomparessSuccess) - { - return isDecomparessSuccess; - } - // 到这里已经解压完成, 开始解析 - - var netVersion = Utils.RuntimeUtil.RuntimeNetVersion; - - // netcoreapp3.1 net5.0 - // dll 文件等 - string libDirPath = Path.Combine(destinationDirectory, "lib"); - string netFolderName = string.Empty; - if (netVersion >= new Version("3.1") && Directory.Exists(Path.Combine(libDirPath, $"netcoreapp{netVersion.Major}.{netVersion.Minor}"))) - { - netFolderName = $"netcoreapp{netVersion.Major}.{netVersion.Minor}"; - } - else if (netVersion.Major >= 5 && Directory.Exists(Path.Combine(libDirPath, $"net{netVersion.Major}.{netVersion.Minor}"))) - { - netFolderName = $"net{netVersion.Major}.{netVersion.Minor}"; - } - else if (Directory.Exists(Path.Combine(libDirPath, "netstandard2.0"))) - { - netFolderName = $"netstandard2.0"; - } - else if (Directory.Exists(Path.Combine(libDirPath, "netstandard2.1"))) - { - netFolderName = $"netstandard2.1"; - } - else - { - throw new Exception("暂不支持 .NET Core 3.1 以下版本, 也不支持 .NET Framework "); - } - // 1. ./lib/netcoreapp3.1 - string libNetDirPath = Path.Combine(libDirPath, netFolderName); - // 移动到插件根目录 - //Directory.Move(libNetDirPath, destinationDirectory); // 错误: 这样移动会导致 包含根目录文件夹名 - Utils.FileUtil.CopyFolder(libNetDirPath, destinationDirectory); - // 只需要这些, 其他删除 - Directory.Delete(libDirPath, true); - - Utils.LogUtil.Info($"加载 nupkg 中 dll: {sourceFile} ; {libNetDirPath}"); - - // 2. 普通文件: 例如 wwwroot - // 2.1 ./content - string contentDirPath = Path.Combine(destinationDirectory, "content"); - bool isExistContentDir = Directory.Exists(contentDirPath); - bool isFinishedContent = false; - if (isExistContentDir) - { - DirectoryInfo dir = new DirectoryInfo(contentDirPath); - bool isExistFile = dir.GetFiles()?.Length >= 1 || dir.GetDirectories()?.Length >= 1; - if (isExistFile) - { - Utils.FileUtil.CopyFolder(contentDirPath, destinationDirectory); - isFinishedContent = true; - - Utils.LogUtil.Info($"加载 nupkg 中 非dll: ./content : {sourceFile} ; {contentDirPath}"); - } - } - else - { - // 2.2 ./contentFiles/any/netFolderName - // 在 ./content 中没有找到文件, 再尝试 此文件夹 - if (!isFinishedContent) - { - string contentFilesDirPath = Path.Combine(destinationDirectory, "contentFiles"); - DirectoryInfo dir = new DirectoryInfo(contentFilesDirPath); - int? childDirLength = dir.GetDirectories()?.Length; - if (childDirLength >= 1) - { - DirectoryInfo anyDir = dir.GetDirectories()[0]; - DirectoryInfo netFolderDir = anyDir.GetDirectories(netFolderName)?.FirstOrDefault(); - if (netFolderDir != null) - { - Utils.FileUtil.CopyFolder(netFolderDir.FullName, destinationDirectory); - - Utils.LogUtil.Info($"加载 nupkg 中 非dll: ./contentFiles/any/netFolderName : {sourceFile} ; {netFolderDir.FullName}"); - } - } - } - } - - - - - - } - catch (Exception ex) - { - Utils.LogUtil.Error(ex, ex.Message); - Utils.LogUtil.Error(ex.InnerException?.ToString() ?? ""); - - throw ex; - } - - return isDecomparessSuccess; - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Infrastructure/PluginServiceProvide.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Infrastructure/PluginServiceProvide.cs deleted file mode 100644 index c4451432..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Infrastructure/PluginServiceProvide.cs +++ /dev/null @@ -1,173 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; - -//namespace PluginCore.Infrastructure -//{ -// /// -// /// The default IServiceProvider. -// /// -// public class PluginServiceProvide : IServiceProvider, IDisposable, IServiceProviderEngineCallback, IAsyncDisposable -// { -// private readonly IServiceProviderEngine _engine; - -// private readonly CallSiteValidator _callSiteValidator; - -// internal ServiceProvider(IEnumerable serviceDescriptors, IServiceProviderEngine engine, ServiceProviderOptions options) -// { -// _engine = engine; - -// if (options.ValidateScopes) -// { -// _engine.InitializeCallback(this); -// _callSiteValidator = new CallSiteValidator(); -// } - -// if (options.ValidateOnBuild) -// { -// List exceptions = null; -// foreach (ServiceDescriptor serviceDescriptor in serviceDescriptors) -// { -// try -// { -// _engine.ValidateService(serviceDescriptor); -// } -// catch (Exception e) -// { -// exceptions = exceptions ?? new List(); -// exceptions.Add(e); -// } -// } - -// if (exceptions != null) -// { -// throw new AggregateException("Some services are not able to be constructed", exceptions.ToArray()); -// } -// } -// } - -// /// -// /// Gets the service object of the specified type. -// /// -// /// The type of the service to get. -// /// The service that was produced. -// public object GetService(Type serviceType) => _engine.GetService(serviceType); - -// /// -// public void Dispose() -// { -// _engine.Dispose(); -// } - -// void IServiceProviderEngineCallback.OnCreate(ServiceCallSite callSite) -// { -// _callSiteValidator.ValidateCallSite(callSite); -// } - -// void IServiceProviderEngineCallback.OnResolve(Type serviceType, IServiceScope scope) -// { -// _callSiteValidator.ValidateResolution(serviceType, scope, _engine.RootScope); -// } - -// /// -// public ValueTask DisposeAsync() -// { -// return _engine.DisposeAsync(); -// } -// } - -// internal interface IServiceProviderEngineCallback -// { -// void OnCreate(ServiceCallSite callSite); -// void OnResolve(Type serviceType, IServiceScope scope); -// } - -// /// -// /// Summary description for ServiceCallSite -// /// -// internal abstract class ServiceCallSite -// { -// protected ServiceCallSite(ResultCache cache) -// { -// Cache = cache; -// } - -// public abstract Type ServiceType { get; } -// public abstract Type ImplementationType { get; } -// public abstract CallSiteKind Kind { get; } -// public ResultCache Cache { get; } - -// public bool CaptureDisposable => -// ImplementationType == null || -// typeof(IDisposable).IsAssignableFrom(ImplementationType) || -// typeof(IAsyncDisposable).IsAssignableFrom(ImplementationType); -// } - - -// internal struct ResultCache -// { -// public static ResultCache None { get; } = new ResultCache(CallSiteResultCacheLocation.None, ServiceCacheKey.Empty); - -// internal ResultCache(CallSiteResultCacheLocation lifetime, ServiceCacheKey cacheKey) -// { -// Location = lifetime; -// Key = cacheKey; -// } - -// public ResultCache(ServiceLifetime lifetime, Type type, int slot) -// { -// Debug.Assert(lifetime == ServiceLifetime.Transient || type != null); - -// switch (lifetime) -// { -// case ServiceLifetime.Singleton: -// Location = CallSiteResultCacheLocation.Root; -// break; -// case ServiceLifetime.Scoped: -// Location = CallSiteResultCacheLocation.Scope; -// break; -// case ServiceLifetime.Transient: -// Location = CallSiteResultCacheLocation.Dispose; -// break; -// default: -// Location = CallSiteResultCacheLocation.None; -// break; -// } -// Key = new ServiceCacheKey(type, slot); -// } - -// public CallSiteResultCacheLocation Location { get; set; } - -// public ServiceCacheKey Key { get; set; } -// } - - -// internal enum CallSiteResultCacheLocation -// { -// Root, -// Scope, -// Dispose, -// None -// } - -// internal interface IServiceProviderEngine : IServiceProvider, IDisposable, IAsyncDisposable -// { -// IServiceScope RootScope { get; } -// void InitializeCallback(IServiceProviderEngineCallback callback); -// void ValidateService(ServiceDescriptor descriptor); -// } - -//} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Interfaces/ICollectibleAssemblyLoadContext.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Interfaces/ICollectibleAssemblyLoadContext.cs deleted file mode 100644 index d51d7886..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Interfaces/ICollectibleAssemblyLoadContext.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace PluginCore.Interfaces -{ - /// - /// 暂时无用, 仅作为约束标记 - /// - public interface ICollectibleAssemblyLoadContext - { - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Interfaces/IPluginContext.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Interfaces/IPluginContext.cs deleted file mode 100644 index abbb6724..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Interfaces/IPluginContext.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Runtime.Loader; -using System.Text; - -namespace PluginCore.Interfaces -{ - /// - /// 每个插件的所有 Assembly 打包到此中 - /// - public interface IPluginContext - { - string PluginId { get; } - - IEnumerable Assemblies { get; } - - Assembly LoadFromAssemblyName(AssemblyName assemblyName); - - void Unload(); - - - /// - /// 暂时用不到 - /// - /// - /// - Assembly LoadFromStream(Stream assembly); - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Interfaces/IPluginContextManager.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Interfaces/IPluginContextManager.cs deleted file mode 100644 index 7f57a753..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Interfaces/IPluginContextManager.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using PluginCore.lmplements; -using System; -using System.Collections.Generic; -using System.Runtime.Loader; -using System.Text; - -namespace PluginCore.Interfaces -{ - public interface IPluginContextManager - { - List All(); - - bool Any(string pluginId); - - void Remove(string pluginId); - - IPluginContext Get(string pluginId); - - void Add(string pluginId, IPluginContext context); - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Interfaces/IPluginContextPack.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Interfaces/IPluginContextPack.cs deleted file mode 100644 index d13d82d9..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Interfaces/IPluginContextPack.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Runtime.Loader; -using System.Text; - -namespace PluginCore.Interfaces -{ - public interface IPluginContextPack - { - /// - /// 将 此插件 打包 到一个 中 - /// - /// - /// - IPluginContext Pack(string pluginId); - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginConfigModel.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginConfigModel.cs deleted file mode 100644 index 5ef7582a..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginConfigModel.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace PluginCore.Models -{ - /// - /// 所有插件的配置信息模型 - /// 对应 WebApi/App_Data/plugin.config.json - /// ------------- - /// Plugins = 已启用 + 已禁用 - /// 上传放入 Plugins 后, 默认为 已禁用 - /// - public class PluginConfigModel - { - /// - /// 启用的插件列表: PluginID - /// 属于 插件 已安装 - /// - public List EnabledPlugins { get; set; } - - #region ctor - public PluginConfigModel() - { - this.EnabledPlugins = new List(); - } - #endregion - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginInfoModel.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginInfoModel.cs deleted file mode 100644 index 41290c6a..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginInfoModel.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace PluginCore.Models -{ - /// - /// 插件信息模型 - /// 对应插件目录下 info.json - /// 约定: 插件文件夹名=PluginID - /// 约定: 插件文件夹名=插件主程序集(Assembly)名 .dll - /// eg: plugins/payment payment.dll - /// 约定: 插件文件夹下 logo.png 为插件图标 - /// 约定: 插件文件夹下 README.md 为插件说明文件 - /// 约定: 插件文件夹下 settings.json 为插件设置文件 - /// - public class PluginInfoModel - { - public string PluginId { get; set; } - - public string DisplayName { get; set; } - - public string Description { get; set; } - - public string Author { get; set; } - - public string Version { get; set; } - - public IList SupportedVersions { get; set; } - - /// - /// 前置依赖插件 - /// - /// - public IList DependPlugins { get; set; } - - #region Ctor - public PluginInfoModel() - { - this.SupportedVersions = new List(); - this.DependPlugins = new List(); - } - #endregion - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginInfoResponseModel.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginInfoResponseModel.cs deleted file mode 100644 index 43749a00..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginInfoResponseModel.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace PluginCore.Models -{ - public class PluginInfoResponseModel : PluginInfoModel - { - /// - /// 插件状态 - /// - public PluginStatus Status { get; set; } - } - - public enum PluginStatus - { - Enabled = 0, - Disabled = 1 - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginReadmeModel.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginReadmeModel.cs deleted file mode 100644 index 765cabe9..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginReadmeModel.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace PluginCore.Models -{ - public class PluginReadmeModel - { - public string PluginId { get; set; } - - public string Content { get; set; } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginReadmeResponseModel.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginReadmeResponseModel.cs deleted file mode 100644 index 7cd5a24d..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginReadmeResponseModel.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace PluginCore.Models -{ - public class PluginReadmeResponseModel : PluginReadmeModel - { - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginRegistryResponseModel.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginRegistryResponseModel.cs deleted file mode 100644 index 4fb72283..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginRegistryResponseModel.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace PluginCore.Models -{ - public class PluginRegistryResponseModel : PluginInfoModel - { - public string DownloadUrl { get; set; } - - /// - /// 此属性值由获取后根据本地插件情况赋值 - /// - public PluginStatus Status { get; set; } - - public enum PluginStatus - { - /// - /// 本地无此 PluginId 的插件 - /// - LocalWithout, - - /// - /// 本地已存在此 PluginId 的插件 - /// - LocalExist - } - } - - public class PluginRegistryDTO - { - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginSettingsInputModel.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginSettingsInputModel.cs deleted file mode 100644 index 60500a67..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Models/PluginSettingsInputModel.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace PluginCore.Models -{ - public class PluginSettingsInputModel - { - public string PluginId { get; set; } - - public string Data { get; set; } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/PluginConfigModelFactory.cs b/Admin.NET/Plugins/PluginCore/PluginCore/PluginConfigModelFactory.cs deleted file mode 100644 index e1ba0f77..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/PluginConfigModelFactory.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -using System.Linq; -//=================================================== -// License: GNU LGPLv3 -// Contributors: yiyungent@gmail.com -// Project: https://yiyungent.github.io/PluginCore -// GitHub: https://github.com/yiyungent/PluginCore -//=================================================== - - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Text.Json; -using PluginCore.Models; - -namespace PluginCore -{ - public class PluginConfigModelFactory - { - #region 即时读取 - public static PluginConfigModel Create() - { - PluginConfigModel pluginConfigModel = new PluginConfigModel(); - string pluginConfigFilePath = Path.Combine(Directory.GetCurrentDirectory(), "App_Data", "plugin.config.json"); - string pluginConfigJsonStr = File.ReadAllText(pluginConfigFilePath, Encoding.UTF8); - JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions(); - jsonSerializerOptions.PropertyNameCaseInsensitive = true; - pluginConfigModel = JsonSerializer.Deserialize(pluginConfigJsonStr, jsonSerializerOptions); - pluginConfigModel = EnabledPluginsSort(pluginConfigModel); - - return pluginConfigModel; - } - #endregion - - #region 保存 - public static void Save(PluginConfigModel pluginConfigModel) - { - if (pluginConfigModel == null) - { - throw new ArgumentNullException(nameof(pluginConfigModel)); - } - try - { - pluginConfigModel = EnabledPluginsSort(pluginConfigModel); - string pluginConfigJsonStr = JsonSerializer.Serialize(pluginConfigModel); - string pluginConfigFilePath = Path.Combine(Directory.GetCurrentDirectory(), "App_Data", "plugin.config.json"); - File.WriteAllText(pluginConfigFilePath, pluginConfigJsonStr, Encoding.UTF8); - } - catch (Exception ex) - { } - - } - #endregion - - #region 确保建立正确的依赖顺序 - public static PluginConfigModel EnabledPluginsSort(PluginConfigModel pluginConfigModel) { - var dependencySorter = new PluginCore.Utils.DependencySorter(); - dependencySorter.AddObjects(pluginConfigModel.EnabledPlugins.ToArray()); - foreach (var plugin in pluginConfigModel.EnabledPlugins) - { - try - { - IList dependPlugins = PluginInfoModelFactory.Create(plugin).DependPlugins; - if (dependPlugins != null && dependPlugins.Count >= 1) { - dependencySorter.SetDependencies(obj: plugin, dependsOnObjects: dependPlugins.ToArray()); - } - } - catch (System.Exception ex) - { - } - } - try - { - var sortedPlugins = dependencySorter.Sort(); - if (sortedPlugins != null && sortedPlugins.Length >= 1) { - pluginConfigModel.EnabledPlugins = sortedPlugins.ToList(); - } - } - catch (System.Exception ex) - { - } - - return pluginConfigModel; - } - #endregion - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/PluginCore.csproj b/Admin.NET/Plugins/PluginCore/PluginCore/PluginCore.csproj deleted file mode 100644 index 075f17d3..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/PluginCore.csproj +++ /dev/null @@ -1,48 +0,0 @@ - - - - net8.0;net9.0 - PluginCore - 2.2.5 - yiyun - yiyun - Lightweight plugin framework - Copyright (c) 2021-present yiyun - https://github.com/yiyungent/PluginCore - https://github.com/yiyungent/PluginCore/blob/main/LICENSE - PluginCore - true - - - - 9.0 - enable - - - - - bin\Release\netcoreapp3.1\PluginCore.xml - - - bin\Release\net5.0\PluginCore.xml - - - - - - - - - - - - - - - - - - - - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/PluginInfoModelFactory.cs b/Admin.NET/Plugins/PluginCore/PluginCore/PluginInfoModelFactory.cs deleted file mode 100644 index 4795eec8..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/PluginInfoModelFactory.cs +++ /dev/null @@ -1,107 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.Json; -using PluginCore.Models; - -namespace PluginCore -{ - public class PluginInfoModelFactory - { - private const string InfoJson = "info.json"; - - #region 即时读取指定 plugin info.json - public static PluginInfoModel Create(string pluginId) - { - PluginInfoModel pluginInfoModel = new PluginInfoModel(); - string pluginDir = Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId); - string pluginInfoFilePath = Path.Combine(pluginDir, InfoJson); - - if (!File.Exists(pluginInfoFilePath)) - { - return null; - } - try - { - string pluginInfoJsonStr = File.ReadAllText(pluginInfoFilePath, Encoding.UTF8); - JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions(); - jsonSerializerOptions.PropertyNameCaseInsensitive = true; - pluginInfoModel = JsonSerializer.Deserialize(pluginInfoJsonStr, jsonSerializerOptions); - } - catch (Exception ex) - { - pluginInfoModel = null; - } - - return pluginInfoModel; - } - #endregion - - #region 即时读取插件目录下所有 plugin info.json - public static IList CreateAll() - { - IList pluginInfoModels = new List(); - IList pluginDirs = PluginPathProvider.AllPluginDir(); - foreach (var dir in pluginDirs) - { - // 从 dir 中解析出 pluginId - // 约定: 插件文件夹名=PluginID=插件主.dll - string pluginId = PluginPathProvider.GetPluginFolderNameByDir(dir); - PluginInfoModel model = Create(pluginId); - pluginInfoModels.Add(model); - } - // 去除为 null: 目标插件信息不存在,或者格式错误的 - pluginInfoModels = pluginInfoModels.Where(m => m != null).ToList(); - - return pluginInfoModels; - } - #endregion - - #region 从指定插件目录读取插件信息 - /// - /// 从指定插件目录读取插件信息 - /// 可以用于读取临时插件上传目录中的插件信息 - /// - /// - /// - public static PluginInfoModel ReadPluginDir(string pluginDir) - { - PluginInfoModel pluginInfoModel = new PluginInfoModel(); - string pluginInfoFilePath = Path.Combine(pluginDir, InfoJson); - - if (!File.Exists(pluginInfoFilePath)) - { - return null; - } - try - { - string pluginInfoJsonStr = File.ReadAllText(pluginInfoFilePath, Encoding.UTF8); - JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions(); - jsonSerializerOptions.PropertyNameCaseInsensitive = true; - pluginInfoModel = JsonSerializer.Deserialize(pluginInfoJsonStr, jsonSerializerOptions); - } - catch (Exception ex) - { - pluginInfoModel = null; - } - - return pluginInfoModel; - } - #endregion - - } - - -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/PluginReadmeModelFactory.cs b/Admin.NET/Plugins/PluginCore/PluginCore/PluginReadmeModelFactory.cs deleted file mode 100644 index ce7f5c19..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/PluginReadmeModelFactory.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Text.Json; -using PluginCore.Models; - -namespace PluginCore -{ - /// - /// TODO: 目前这样读取出来的包含了 windows 换行符 \r\n - /// - public class PluginReadmeModelFactory - { - // TODO: Linux 文件名下区分大小写, windows不区分, 目前必须为 README.md - private const string ReadmeFile = "README.md"; - - #region 即时读取 - public static PluginReadmeModel Create(string pluginId) - { - PluginReadmeModel readmeModel = new PluginReadmeModel(); - string pluginDir = Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId); - string pluginReadmeFilePath = Path.Combine(pluginDir, ReadmeFile); - - if (!File.Exists(pluginReadmeFilePath)) - { - return null; - } - try - { - string readmeStr = File.ReadAllText(pluginReadmeFilePath, Encoding.UTF8); - readmeModel.PluginId = pluginId; - readmeModel.Content = readmeStr; - } - catch (Exception ex) - { - readmeModel = null; - } - - return readmeModel; - } - #endregion - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Utils/DateTimeUtil.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Utils/DateTimeUtil.cs deleted file mode 100644 index cfe12985..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Utils/DateTimeUtil.cs +++ /dev/null @@ -1,117 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -// Project: SimCaptcha -// https://github.com/yiyungent/SimCaptcha -// Author: yiyun - -/// -/// JavaScript时间戳:是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总毫秒数。(13 位数字) -/// -/// Unix时间戳:是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数。(10 位数字) -/// -namespace PluginCore.Utils -{ - public static class DateTimeUtil - { - public static DateTime DateTime1970 = new DateTime(1970, 1, 1).ToLocalTime(); - - #region Unix 10位时间戳-总秒数 - /// - /// C# DateTime转换为Unix时间戳 - /// - public static long ToTimeStamp10(this DateTime dateTime) - { - // 相差秒数 - long timeStamp = (long)(dateTime.ToLocalTime() - DateTime1970).TotalSeconds; - - return timeStamp; - } - - /// - /// C# DateTime转换为Unix时间戳 - /// - public static long ToTimeStamp10(this DateTime? dateTime) - { - if (dateTime == null) - { - return 0; - } - // 相差秒数 - long timeStamp = ToTimeStamp10((DateTime)dateTime); - - return timeStamp; - } - - /// - /// Unix时间戳转换为C# DateTime - /// - public static DateTime ToDateTime10(this long timeStamp10) - { - DateTime dateTime = DateTime1970.AddSeconds(timeStamp10).ToLocalTime(); - - return dateTime; - } - #endregion - - #region JavaScript 13位时间戳-总毫秒数 - /// - /// C# DateTime转换为JavaScript时间戳 - /// - public static long ToTimeStamp13(this DateTime dateTime) - { - // 相差毫秒数 - long timeStamp = (long)(dateTime.ToLocalTime() - DateTime1970).TotalMilliseconds; - - return timeStamp; - } - - /// - /// C# DateTime转换为JavaScript时间戳 - /// - public static long ToTimeStamp13(this DateTime? dateTime) - { - if (dateTime == null) - { - return 0; - } - // 相差秒数 - long timeStamp = ToTimeStamp13((DateTime)dateTime); - - return timeStamp; - } - - /// - /// JavaScript时间戳转换为C# DateTime - /// - public static DateTime ToDateTime13(this long timeStamp13) - { - DateTime dateTime = DateTime1970.AddMilliseconds(timeStamp13).ToLocalTime(); - - return dateTime; - } - #endregion - - #region 获取当前Unix时间戳 - public static long NowTimeStamp10() - { - return ToTimeStamp10(DateTime.Now); - } - #endregion - - #region 获取当前JavaScript时间戳 - public static long NowTimeStamp13() - { - return ToTimeStamp13(DateTime.Now); - } - #endregion - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Utils/DependencySorter.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Utils/DependencySorter.cs deleted file mode 100644 index 304c26a9..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Utils/DependencySorter.cs +++ /dev/null @@ -1,193 +0,0 @@ -// Admin.NET ĿİȨ̱ꡢרȨӦɷıʹñĿӦطɷ֤Ҫ -// -// ĿҪѭ MIT ֤ Apache ֤汾 2.0зַʹá֤λԴĿ¼е LICENSE-MIT LICENSE-APACHE ļ -// -// ñĿΣҰȫַ˺ϷȨȷɷֹĻκλڱĿοһзɾ׺ΣDzеκΣ - - -using System; -using System.Collections.Generic; -using System.Diagnostics; - - -namespace PluginCore.Utils -{ - /// - /// https://stackoverflow.com/questions/4106862/how-to-sort-depended-objects-by-dependency/ - /// - /// Definition: http://en.wikipedia.org/wiki/Topological_sorting - /// Source code credited to: http://tawani.blogspot.com/2009/02/topological-sorting-and-cyclic.html - /// Original Java source code: http://www.java2s.com/Code/Java/Collections-Data-Structure/Topologicalsorting.htm - /// - /// ThangTran - /// - /// 2012.03.21 - ThangTran: rewritten based on . - /// - public class DependencySorter - { - //************************************************** - // - // Private members - // - //************************************************** - - #region Private members - - /// - /// Gets the dependency matrix used by this instance. - /// - private readonly Dictionary> _matrix = new Dictionary>(); - - #endregion - - - //************************************************** - // - // Public methods - // - //************************************************** - - #region Public methods - - /// - /// Adds a list of objects that will be sorted. - /// - public void AddObjects(params T[] objects) - { - // --- Begin parameters checking code ----------------------------- - // Debug.Assert(objects != null); - // Debug.Assert(objects.Length > 0); - // --- End parameters checking code ------------------------------- - - // add to matrix - foreach (T obj in objects) - { - // add to dictionary - _matrix.Add(obj, new Dictionary()); - } - } - - /// - /// Sets dependencies of given object. - /// This means depends on these to run. - /// Please make sure objects given in the and are added first. - /// - public void SetDependencies(T obj, params T[] dependsOnObjects) - { - // --- Begin parameters checking code ----------------------------- - // Debug.Assert(dependsOnObjects != null); - // --- End parameters checking code ------------------------------- - - // set dependencies - Dictionary dependencies = _matrix[obj]; - dependencies.Clear(); - - // for each depended objects, add to dependencies - foreach (T dependsOnObject in dependsOnObjects) - { - dependencies.Add(dependsOnObject, null); - } - } - - /// - /// Sorts objects based on this dependencies. - /// Note: because of the nature of algorithm and memory usage efficiency, this method can be used only one time. - /// - public T[] Sort() - { - // prepare result - List result = new List(_matrix.Count); - - // while there are still object to get - while (_matrix.Count > 0) - { - // get an independent object - T independentObject; - if (!this.GetIndependentObject(out independentObject)) - { - // circular dependency found - throw new CircularReferenceException(); - } - - // add to result - result.Add(independentObject); - - // delete processed object - this.DeleteObject(independentObject); - } - - // return result - return result.ToArray(); - } - - #endregion - - - //************************************************** - // - // Private methods - // - //************************************************** - - #region Private methods - - /// - /// Returns independent object or returns NULL if no independent object is found. - /// - private bool GetIndependentObject(out T result) - { - // for each object - foreach (KeyValuePair> pair in _matrix) - { - // if the object contains any dependency - if (pair.Value.Count > 0) - { - // has dependency, skip it - continue; - } - - // found - result = pair.Key; - return true; - } - - // not found - result = default(T); - return false; - } - - /// - /// Deletes given object from the matrix. - /// - private void DeleteObject(T obj) - { - // delete object from matrix - _matrix.Remove(obj); - - // for each object, remove the dependency reference - foreach (KeyValuePair> pair in _matrix) - { - // if current object depends on deleting object - pair.Value.Remove(obj); - } - } - - - #endregion - } - - /// - /// Represents a circular reference exception when sorting dependency objects. - /// - public class CircularReferenceException : Exception - { - /// - /// Initializes a new instance of the class. - /// - public CircularReferenceException() - : base("Circular reference found.") - { - } - } -} - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Utils/FileUtil.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Utils/FileUtil.cs deleted file mode 100644 index 7b09b533..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Utils/FileUtil.cs +++ /dev/null @@ -1,177 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace PluginCore.Utils -{ - public class FileUtil - { - #region 复制大文件 - public static void CopyBigFile(string originalFilePath, string destFilePath) - { - // 定义读文件流 - using (FileStream fsr = new FileStream(originalFilePath, FileMode.Open)) - { - // 定义写文件流 - using (FileStream fsw = new FileStream(destFilePath, FileMode.OpenOrCreate)) - { - // 申请1M内存空间 - byte[] buffer = new byte[1024 * 1024]; - // 无限循环中反复读写,直到读完写完 - while (true) - { - int readCount = fsr.Read(buffer, 0, buffer.Length); - fsw.Write(buffer, 0, readCount); - if (readCount < buffer.Length) - { - break; - } - } - } - } - } - #endregion - - #region 移动大文件 - public static void MoveBigFile(string originalFilePath, string destFilePath) - { - try - { - CopyBigFile(originalFilePath, destFilePath); - File.Delete(originalFilePath); - } - catch (Exception ex) - { - throw ex; - } - } - #endregion - - #region 复制文件夹 - /// - /// 复制文件夹及文件 - /// (不包括源文件夹根目录名称, 只是复制其中内容到目标文件夹) - /// https://www.cnblogs.com/wangjianhui008/p/3234519.html - /// - /// 原文件路径 - /// 目标文件路径 - /// - public static bool CopyFolder(string sourceFolder, string destFolder) - { - try - { - // 如果目标路径不存在,则创建目标路径 - if (!System.IO.Directory.Exists(destFolder)) - { - System.IO.Directory.CreateDirectory(destFolder); - } - // 得到原文件根目录下的所有文件 - string[] files = System.IO.Directory.GetFiles(sourceFolder); - foreach (string file in files) - { - string name = System.IO.Path.GetFileName(file); - string dest = System.IO.Path.Combine(destFolder, name); - System.IO.File.Copy(file, dest);//复制文件 - } - // 得到原文件根目录下的所有文件夹 - string[] folders = System.IO.Directory.GetDirectories(sourceFolder); - foreach (string folder in folders) - { - string name = System.IO.Path.GetFileName(folder); - string dest = System.IO.Path.Combine(destFolder, name); - CopyFolder(folder, dest);//构建目标路径,递归复制文件 - } - return true; - } - catch (Exception e) - { - - return false; - } - - } - #endregion - - #region 计算MD5 - - - /// - /// 获取文件的MD5码 - /// - /// 传入的文件名(含路径及后缀名) - /// - public string GetMD5HashFromFile(string filePath) - { - try - { - FileStream file = new FileStream(filePath, System.IO.FileMode.Open); - System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); - byte[] retVal = md5.ComputeHash(file); - file.Close(); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < retVal.Length; i++) - { - sb.Append(retVal[i].ToString("x2")); - } - return sb.ToString(); - } - catch (Exception ex) - { - throw new Exception("GetMD5HashFromFile() fail,error:" + ex.Message); - } - } - - - public static string GetFileMD5(string filePath) - { - FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read); - int bufferSize = 1048576; - byte[] buff = new byte[bufferSize]; - System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); - md5.Initialize(); - long offset = 0; - while (offset < fs.Length) - { - long readSize = bufferSize; - if (offset + readSize > fs.Length) - readSize = fs.Length - offset; - fs.Read(buff, 0, Convert.ToInt32(readSize)); - if (offset + readSize < fs.Length) - md5.TransformBlock(buff, 0, Convert.ToInt32(readSize), buff, 0); - else - md5.TransformFinalBlock(buff, 0, Convert.ToInt32(readSize)); - offset += bufferSize; - } - if (offset >= fs.Length) - { - fs.Close(); - byte[] result = md5.Hash; - md5.Clear(); - StringBuilder sb = new StringBuilder(32); - for (int i = 0; i < result.Length; i++) - sb.Append(result[i].ToString("X2")); - return sb.ToString(); - } - else - { - fs.Close(); - return null; - } - } - - #endregion - - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Utils/LogUtil.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Utils/LogUtil.cs deleted file mode 100644 index 6504a8ae..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Utils/LogUtil.cs +++ /dev/null @@ -1,237 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Text; -using System.Linq; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.DependencyInjection; - -namespace PluginCore.Utils -{ - public class LogUtil - { - public const string LogCategoryName = nameof(PluginCore); - - private static IServiceScopeFactory _serviceScopeFactory; - - public static void Initialize(IServiceScopeFactory serviceScopeFactory) - { - _serviceScopeFactory = serviceScopeFactory; - } - - public static void Info(string message) - { - if (_serviceScopeFactory == null) - { - return; - } - using (var scope = _serviceScopeFactory.CreateScope()) - { - ILogger? service = scope.ServiceProvider.GetService>(); - if (service != null) - { - service.LogInformation($"{LogCategoryName}: {message}"); - } - } - } - - public static void Info(string categoryName, string message) - { - if (_serviceScopeFactory == null) - { - return; - } - using (var scope = _serviceScopeFactory.CreateScope()) - { - // null - // ILogger? service = scope.ServiceProvider.GetService(); - ILogger? service = scope.ServiceProvider.GetService()?.CreateLogger(categoryName: categoryName) ?? null; - if (service != null) - { - service.LogInformation($"{LogCategoryName}: {message}"); - } - } - } - - public static void Warn(string message) - { - if (_serviceScopeFactory == null) - { - return; - } - using (var scope = _serviceScopeFactory.CreateScope()) - { - ILogger? service = scope.ServiceProvider.GetService>(); - if (service != null) - { - service.LogWarning($"{LogCategoryName}: {message}"); - } - } - } - - public static void Warn(string categoryName, string message) - { - if (_serviceScopeFactory == null) - { - return; - } - using (var scope = _serviceScopeFactory.CreateScope()) - { - // null - // ILogger? service = scope.ServiceProvider.GetService(); - ILogger? service = scope.ServiceProvider.GetService()?.CreateLogger(categoryName: categoryName) ?? null; - if (service != null) - { - service.LogWarning($"{LogCategoryName}: {message}"); - } - } - } - - public static void Warn(Exception ex, string message) - { - if (_serviceScopeFactory == null) - { - return; - } - using (var scope = _serviceScopeFactory.CreateScope()) - { - ILogger? service = scope.ServiceProvider.GetService>(); - if (service != null) - { - service.LogWarning(ex, $"{LogCategoryName}: {message}"); - } - } - } - - public static void Warn(string categoryName, Exception ex, string message) - { - if (_serviceScopeFactory == null) - { - return; - } - using (var scope = _serviceScopeFactory.CreateScope()) - { - // null - // ILogger? service = scope.ServiceProvider.GetService(); - ILogger? service = scope.ServiceProvider.GetService()?.CreateLogger(categoryName: categoryName) ?? null; - if (service != null) - { - service.LogWarning(ex, $"{LogCategoryName}: {message}"); - } - } - } - - public static void Error(string message) - { - if (_serviceScopeFactory == null) - { - return; - } - using (var scope = _serviceScopeFactory.CreateScope()) - { - ILogger? service = scope.ServiceProvider.GetService>(); - if (service != null) - { - service.LogError($"{LogCategoryName}: {message}"); - } - } - } - - public static void Error(string categoryName, string message) - { - if (_serviceScopeFactory == null) - { - return; - } - using (var scope = _serviceScopeFactory.CreateScope()) - { - // null - // ILogger? service = scope.ServiceProvider.GetService(); - ILogger? service = scope.ServiceProvider.GetService()?.CreateLogger(categoryName: categoryName) ?? null; - if (service != null) - { - service.LogError($"{LogCategoryName}: {message}"); - } - } - } - - public static void Error(Exception ex, string message) - { - if (_serviceScopeFactory == null) - { - return; - } - using (var scope = _serviceScopeFactory.CreateScope()) - { - ILogger? service = scope.ServiceProvider.GetService>(); - if (service != null) - { - service.LogError(ex, $"{LogCategoryName}: {message}"); - } - } - } - - public static void Error(string categoryName, Exception ex, string message) - { - if (_serviceScopeFactory == null) - { - return; - } - using (var scope = _serviceScopeFactory.CreateScope()) - { - // null - // ILogger? service = scope.ServiceProvider.GetService(); - ILogger? service = scope.ServiceProvider.GetService()?.CreateLogger(categoryName: categoryName) ?? null; - if (service != null) - { - service.LogError(ex, $"{LogCategoryName}: {message}"); - } - } - } - - public static void PluginBehavior(T plugin, Type iplugin, string methodName) - where T : IPlugins.IPlugin - { - if (_serviceScopeFactory == null) - { - return; - } - // TODO: Bug: 无法区别 相同方法名, 参数不同的 重载方法 - MethodInfo behavior = iplugin.GetMethods().FirstOrDefault(m => m.Name == methodName); - - ParameterInfo[] pars = behavior.GetParameters(); - string parsStr = string.Empty; - if (pars != null && pars.Length > 0) - { - var parTypes = pars.OrderBy(m => m.Position).Select(m => m.ParameterType.Name).ToArray(); - parsStr = string.Join(", ", parTypes); - } - - // A程序集.APlugin - string pluginStr = plugin.GetType().ToString(); - // A程序集.AClass.AMethod() - string message = $"{behavior.DeclaringType.ToString()}.{behavior.Name}({parsStr})"; - - // 2. 日志输出 - using (var scope = _serviceScopeFactory.CreateScope()) - { - ILogger? service = scope.ServiceProvider.GetService>(); - if (service != null) - { - service.LogInformation($"{LogCategoryName}: {message}"); - } - } - } - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Utils/Md5Helper.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Utils/Md5Helper.cs deleted file mode 100644 index 97b660cc..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Utils/Md5Helper.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; - -namespace PluginCore.Utils -{ - public class Md5Helper - { - #region MD5加密为32位16进制字符串 - /// - /// MD5加密为32位16进制字符串 - /// - /// 原输入字符串 - /// 返回加密后的字符串 - public static string MD5Encrypt32(string source) - { - MD5 md5 = MD5.Create(); - byte[] buffer = md5.ComputeHash(Encoding.UTF8.GetBytes(source)); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < buffer.Length; i++) - { - // "x2" 转换为 16进制 - sb.Append(buffer[i].ToString("x2")); - } - return sb.ToString(); - } - #endregion - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Utils/RuntimeUtil.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Utils/RuntimeUtil.cs deleted file mode 100644 index f1019f38..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Utils/RuntimeUtil.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace PluginCore.Utils -{ - public class RuntimeUtil - { - public static Version RuntimeNetVersion - { - get - { - return Environment.Version; - } - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/Utils/ZipHelper.cs b/Admin.NET/Plugins/PluginCore/PluginCore/Utils/ZipHelper.cs deleted file mode 100644 index 47f0c2f6..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/Utils/ZipHelper.cs +++ /dev/null @@ -1,444 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using ICSharpCode.SharpZipLib.Zip; -using System; -using System.Collections.Generic; -using System.IO; - -namespace PluginCore.Utils -{ - public class ZipHelper - { - /// - /// 缓存字节数 - /// - private const int BufferSize = 4096; - - /// - /// 压缩最小等级 - /// - public const int CompressionLevelMin = 0; - - /// - /// 压缩最大等级 - /// - public const int CompressionLevelMax = 9; - - /// - /// 获取所有文件系统对象 - /// - /// 源路径 - /// 顶级文件夹 - /// 字典中Key为完整路径,Value为文件(夹)名称 - private static Dictionary GetAllFileSystemEntities(string source, string topDirectory) - { - Dictionary entitiesDictionary = new Dictionary(); - entitiesDictionary.Add(source, source.Replace(topDirectory, "")); - - if (Directory.Exists(source)) - { - //一次性获取下级所有目录,避免递归 - string[] directories = Directory.GetDirectories(source, "*.*", SearchOption.AllDirectories); - foreach (string directory in directories) - { - entitiesDictionary.Add(directory, directory.Replace(topDirectory, "")); - } - - string[] files = Directory.GetFiles(source, "*.*", SearchOption.AllDirectories); - foreach (string file in files) - { - entitiesDictionary.Add(file, file.Replace(topDirectory, "")); - } - } - - return entitiesDictionary; - } - - /// - /// 校验压缩等级 - /// - /// - /// - private static int CheckCompressionLevel(int compressionLevel) - { - compressionLevel = compressionLevel < CompressionLevelMin ? CompressionLevelMin : compressionLevel; - compressionLevel = compressionLevel > CompressionLevelMax ? CompressionLevelMax : compressionLevel; - return compressionLevel; - } - - #region 字节压缩与解压 - - /// - /// 压缩字节数组 - /// - /// 源字节数组 - /// 压缩等级 - /// 密码 - /// 压缩后的字节数组 - public static byte[] CompressBytes(byte[] sourceBytes, string password = null, int compressionLevel = 6) - { - byte[] result = new byte[] { }; - - if (sourceBytes.Length > 0) - { - try - { - using (MemoryStream tempStream = new MemoryStream()) - { - using (MemoryStream readStream = new MemoryStream(sourceBytes)) - { - using (ZipOutputStream zipStream = new ZipOutputStream(tempStream)) - { - zipStream.Password = password;//设置密码 - zipStream.SetLevel(CheckCompressionLevel(compressionLevel));//设置压缩等级 - - ZipEntry zipEntry = new ZipEntry("ZipBytes"); - zipEntry.DateTime = DateTime.Now; - zipEntry.Size = sourceBytes.Length; - zipStream.PutNextEntry(zipEntry); - int readLength = 0; - byte[] buffer = new byte[BufferSize]; - - do - { - readLength = readStream.Read(buffer, 0, BufferSize); - zipStream.Write(buffer, 0, readLength); - } while (readLength == BufferSize); - - readStream.Close(); - zipStream.Flush(); - zipStream.Finish(); - result = tempStream.ToArray(); - zipStream.Close(); - } - } - } - } - catch (System.Exception ex) - { - throw new Exception("压缩字节数组发生错误", ex); - } - } - - return result; - } - - /// - /// 解压字节数组 - /// - /// 源字节数组 - /// 密码 - /// 解压后的字节数组 - public static byte[] DecompressBytes(byte[] sourceBytes, string password = null) - { - byte[] result = new byte[] { }; - - if (sourceBytes.Length > 0) - { - try - { - using (MemoryStream tempStream = new MemoryStream(sourceBytes)) - { - using (MemoryStream writeStream = new MemoryStream()) - { - using (ZipInputStream zipStream = new ZipInputStream(tempStream)) - { - zipStream.Password = password; - ZipEntry zipEntry = zipStream.GetNextEntry(); - - if (zipEntry != null) - { - byte[] buffer = new byte[BufferSize]; - int readLength = 0; - - do - { - readLength = zipStream.Read(buffer, 0, BufferSize); - writeStream.Write(buffer, 0, readLength); - } while (readLength == BufferSize); - - writeStream.Flush(); - result = writeStream.ToArray(); - writeStream.Close(); - } - zipStream.Close(); - } - } - } - } - catch (System.Exception ex) - { - throw new Exception("解压字节数组发生错误", ex); - } - } - return result; - } - - #endregion - - #region 文件压缩与解压 - - /// - /// 为压缩准备文件系统对象 - /// - /// - /// - private static Dictionary PrepareFileSystementities(IEnumerable sourceFileEntityPathList) - { - Dictionary fileEntityDictionary = new Dictionary();//文件字典 - string parentDirectoryPath = ""; - foreach (string fileEntityPath in sourceFileEntityPathList) - { - string path = fileEntityPath; - //保证传入的文件夹也被压缩进文件 - if (path.EndsWith(@"\")) - { - path = path.Remove(path.LastIndexOf(@"\")); - } - - parentDirectoryPath = Path.GetDirectoryName(path) + @"\"; - - if (parentDirectoryPath.EndsWith(@":\\"))//防止根目录下把盘符压入的错误 - { - parentDirectoryPath = parentDirectoryPath.Replace(@"\\", @"\"); - } - - //获取目录中所有的文件系统对象 - Dictionary subDictionary = GetAllFileSystemEntities(path, parentDirectoryPath); - - //将文件系统对象添加到总的文件字典中 - foreach (string key in subDictionary.Keys) - { - if (!fileEntityDictionary.ContainsKey(key))//检测重复项 - { - fileEntityDictionary.Add(key, subDictionary[key]); - } - } - } - return fileEntityDictionary; - } - - /// - /// 压缩单个文件/文件夹 - /// - /// 源文件/文件夹路径列表 - /// 压缩文件路径 - /// 注释信息 - /// 压缩密码 - /// 压缩等级,范围从0到9,可选,默认为6 - /// - public static bool CompressFile(string path, string zipFilePath, - string comment = null, string password = null, int compressionLevel = 6) - { - return CompressFile(new string[] { path }, zipFilePath, comment, password, compressionLevel); - } - - /// - /// 压缩多个文件/文件夹 - /// - /// 源文件/文件夹路径列表 - /// 压缩文件路径 - /// 注释信息 - /// 压缩密码 - /// 压缩等级,范围从0到9,可选,默认为6 - /// - public static bool CompressFile(IEnumerable sourceList, string zipFilePath, - string comment = null, string password = null, int compressionLevel = 6) - { - bool result = false; - - try - { - //检测目标文件所属的文件夹是否存在,如果不存在则建立 - string zipFileDirectory = Path.GetDirectoryName(zipFilePath); - if (!Directory.Exists(zipFileDirectory)) - { - Directory.CreateDirectory(zipFileDirectory); - } - - Dictionary dictionaryList = PrepareFileSystementities(sourceList); - - using (ZipOutputStream zipStream = new ZipOutputStream(File.Create(zipFilePath))) - { - zipStream.Password = password;//设置密码 - zipStream.SetComment(comment);//添加注释 - zipStream.SetLevel(CheckCompressionLevel(compressionLevel));//设置压缩等级 - - foreach (string key in dictionaryList.Keys)//从字典取文件添加到压缩文件 - { - if (File.Exists(key))//判断是文件还是文件夹 - { - FileInfo fileItem = new FileInfo(key); - - using (FileStream readStream = fileItem.Open(FileMode.Open, - FileAccess.Read, FileShare.Read)) - { - ZipEntry zipEntry = new ZipEntry(dictionaryList[key]); - zipEntry.DateTime = fileItem.LastWriteTime; - zipEntry.Size = readStream.Length; - zipStream.PutNextEntry(zipEntry); - int readLength = 0; - byte[] buffer = new byte[BufferSize]; - - do - { - readLength = readStream.Read(buffer, 0, BufferSize); - zipStream.Write(buffer, 0, readLength); - } while (readLength == BufferSize); - - readStream.Close(); - } - } - else//对文件夹的处理 - { - ZipEntry zipEntry = new ZipEntry(dictionaryList[key] + "/"); - zipStream.PutNextEntry(zipEntry); - } - } - - zipStream.Flush(); - zipStream.Finish(); - zipStream.Close(); - } - - result = true; - } - catch (System.Exception ex) - { - throw new Exception("压缩文件失败", ex); - } - - return result; - } - - /// - /// 解压文件到指定文件夹 - /// - /// 压缩文件 - /// 目标文件夹,如果为空则解压到当前文件夹下 - /// 密码 - /// - public static bool DecomparessFile(string sourceFile, string destinationDirectory = null, string password = null) - { - bool result = false; - - if (!File.Exists(sourceFile)) - { - throw new FileNotFoundException("要解压的文件不存在", sourceFile); - } - - if (string.IsNullOrWhiteSpace(destinationDirectory)) - { - destinationDirectory = Path.GetDirectoryName(sourceFile); - } - - try - { - if (!Directory.Exists(destinationDirectory)) - { - Directory.CreateDirectory(destinationDirectory); - } - - using (ZipInputStream zipStream = new ZipInputStream(File.Open(sourceFile, FileMode.Open, - FileAccess.Read, FileShare.Read))) - { - zipStream.Password = password; - ZipEntry zipEntry = zipStream.GetNextEntry(); - - while (zipEntry != null) - { - if (zipEntry.IsDirectory)//如果是文件夹则创建 - { - Directory.CreateDirectory(Path.Combine(destinationDirectory, - Path.GetDirectoryName(zipEntry.Name))); - } - else - { - string fileName = Path.GetFileName(zipEntry.Name); - if (!string.IsNullOrEmpty(fileName) && fileName.Trim().Length > 0) - { - FileInfo fileItem = new FileInfo(Path.Combine(destinationDirectory, zipEntry.Name)); - if (fileItem.Directory is null) - continue; - if (!Directory.Exists(fileItem.Directory.FullName)) - Directory.CreateDirectory(fileItem.Directory.FullName); - using (FileStream writeStream = fileItem.Create()) - { - byte[] buffer = new byte[BufferSize]; - int readLength = 0; - - do - { - readLength = zipStream.Read(buffer, 0, BufferSize); - writeStream.Write(buffer, 0, readLength); - } while (readLength == BufferSize); - - writeStream.Flush(); - writeStream.Close(); - } - fileItem.LastWriteTime = zipEntry.DateTime; - } - } - zipEntry = zipStream.GetNextEntry();//获取下一个文件 - } - - zipStream.Close(); - } - result = true; - } - catch (System.Exception ex) - { - throw new Exception("文件解压发生错误", ex); - } - - return result; - } - - - public static bool FastDecomparessFile(string sourceFile, string destinationDirectory = null) - { - bool result = false; - - if (!File.Exists(sourceFile)) - { - throw new FileNotFoundException("要解压的文件不存在", sourceFile); - } - - if (string.IsNullOrWhiteSpace(destinationDirectory)) - { - destinationDirectory = Path.GetDirectoryName(sourceFile); - } - - try - { - if (!Directory.Exists(destinationDirectory)) - { - Directory.CreateDirectory(destinationDirectory); - } - - FastZip fastZip = new FastZip(); - string fileFilter = null; - - fastZip.ExtractZip(sourceFile, destinationDirectory, fileFilter); - - result = true; - } - catch (Exception ex) - { - throw new Exception("文件解压发生错误", ex); - } - - return result; - } - - #endregion - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/cliff.toml b/Admin.NET/Plugins/PluginCore/PluginCore/cliff.toml deleted file mode 100644 index aa3089f4..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/cliff.toml +++ /dev/null @@ -1,82 +0,0 @@ -# git-cliff ~ configuration file -# https://git-cliff.org/docs/configuration - -[changelog] -# template for the changelog header -header = """ -# Changelog\n -All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.\n -""" -# template for the changelog body -# https://keats.github.io/tera/docs/#introduction -body = """ ---- -{% if version %}\ - {% if previous.version %}\ - ## [{{ version | trim_start_matches(pat="v") }}]($REPO/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }} - {% else %}\ - ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} - {% endif %}\ -{% else %}\ - ## [unreleased] -{% endif %}\ -{% for group, commits in commits | group_by(attribute="group") %} - ### {{ group | striptags | trim | upper_first }} - {% for commit in commits - | filter(attribute="scope") - | sort(attribute="scope") %} - - **({{commit.scope}})**{% if commit.breaking %} [**breaking**]{% endif %} \ - {{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }} - {%- endfor -%} - {% raw %}\n{% endraw %}\ - {%- for commit in commits %} - {%- if commit.scope -%} - {% else -%} - - {% if commit.breaking %} [**breaking**]{% endif %}\ - {{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }} - {% endif -%} - {% endfor -%} -{% endfor %}\n -""" -# template for the changelog footer -footer = """ - -""" -# remove the leading and trailing whitespace from the templates -trim = true -# postprocessors -postprocessors = [ - { pattern = '\$REPO', replace = "https://github.com/yiyungent/PluginCore" }, # replace repository URL -] - -[git] -# parse the commits based on https://www.conventionalcommits.org -conventional_commits = true -# filter out the commits that are not conventional -filter_unconventional = true -# process each line of a commit as an individual commit -split_commits = false -# regex for preprocessing the commit messages -commit_preprocessors = [ - # { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/orhun/git-cliff/issues/${2}))"}, # replace issue numbers -] -# regex for parsing and grouping commits -commit_parsers = [ - { message = "^feat", group = "Features" }, - { message = "^fix", group = "Bug Fixes" }, - { message = "^doc", group = "Documentation" }, - { message = "^perf", group = "Performance" }, - { message = "^refactor", group = "Refactoring" }, - { message = "^style", group = "Style" }, - { message = "^revert", group = "Revert" }, - { message = "^test", group = "Tests" }, - { message = "^chore\\(version\\):", skip = true }, - { message = "^chore", group = "Miscellaneous Chores" }, - { body = ".*security", group = "Security" }, -] -# filter out the commits that are not matched by commit parsers -filter_commits = false -# sort the tags topologically -topo_order = false -# sort the commits inside sections by oldest/newest order -sort_commits = "oldest" diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/CollectibleAssemblyLoadContext.cs b/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/CollectibleAssemblyLoadContext.cs deleted file mode 100644 index 2ec7e8de..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/CollectibleAssemblyLoadContext.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using PluginCore.Interfaces; -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Runtime.Loader; -using System.Text; - -namespace PluginCore.lmplements -{ - /// - /// 一个可回收的程序集加载上下文 - /// 在整个插件加载上下文的设计上,每个插件都使用一个单独的CollectibleAssemblyLoadContext来加载,所有插件的CollectibleAssemblyLoadContext都放在一个PluginsLoadContext对象中 - /// - public class CollectibleAssemblyLoadContext : AssemblyLoadContext, IPluginContext, ICollectibleAssemblyLoadContext - { - public string PluginId - { - get - { - return this.Name ?? ""; - } - } - - public CollectibleAssemblyLoadContext(string? name) - : base(isCollectible: true, name: name) - { - } - - protected override Assembly Load(AssemblyName name) - { - return null; - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/LazyPluginLoadContext.cs b/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/LazyPluginLoadContext.cs deleted file mode 100644 index db7acd8e..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/LazyPluginLoadContext.cs +++ /dev/null @@ -1,100 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using PluginCore.Interfaces; -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Runtime.Loader; -using System.Text; -using System.Linq; - -namespace PluginCore.lmplements -{ - /// - /// 修改自下方 - /// https://docs.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support - /// 此方法依赖于 插件项目生成的 HelloWorldPlugin.deps.json 与 runtimes 文件夹, - /// 虽然官方文档没写, 但最好还带上 HelloWorldPlugin.runtimeconfig.json - /// 插件项目 .csproj 其它注意, 看文档 - /// - public class LazyPluginLoadContext : CollectibleAssemblyLoadContext, IPluginContext - { - private AssemblyDependencyResolver _resolver; - - /// - /// 加了一个可回收 - /// - /// - public LazyPluginLoadContext(string pluginId, string pluginMainDllFilePath) : base(name: pluginId) - { - _resolver = new AssemblyDependencyResolver(pluginMainDllFilePath); - } - - protected override Assembly Load(AssemblyName assemblyName) - { - // 1. 先尝试 从本插件文件夹中搜索 - string assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName); - if (assemblyPath != null) - { - //return LoadFromAssemblyPath(assemblyPath); - using (var fs = new FileStream(assemblyPath, FileMode.Open)) - { - // 使用此方法, 就不会导致dll被锁定 - // 锁定dll 会导致: 1. 无法通过复制粘贴替换 更新 2. 无法删除 - return LoadFromStream(fs); - } - } - // 2. 再尝试 从其他启用的插件文件夹中搜索 - // 实测: 可在下方搜索, 主程序包括的 assemblyName 与 启用插件加载的 assemblyName 都会位于其中 - var assList = AppDomain.CurrentDomain.GetAssemblies(); - var temp = assList.FirstOrDefault(m => m.GetName().FullName == assemblyName.FullName); - if (temp != null) - { - return temp; - } - // 尝试忽略版本搜索 - var temp2 = assList.FirstOrDefault(m => m.GetName().Name == assemblyName.Name); - if (temp2 != null) - { - return temp2; - } - - // 由于是懒加载, 若 A 插件依赖 B 插件, 而此时在 A 插件调用 B.Test(), - // 而 B.Test() 与 C.dll 有关, 而之前 B 插件未触发 C.dll 中类型, 于是这时还没有加载 C.dll, 于是 assList 这时其中无 C.dll - // 由于 B.Test() 需在 A 中调用, 于是为公用, 因此 C.dll 需在 A 中排除, 不然会由于重复加载-类型不一致而 Method Missing - // 在 A 中 C.dll 与 在 B 中 C.dll 会认为其中类型不一致 - // TODO: 主动扫描一次 - //foreach (var pluginContextKeyValue in PluginContextStore.PluginContexts) - //{ - // //pluginContextKeyValue.Value.Load(assemblyName); - // string pluginId = pluginContextKeyValue.Key; - - //} - - // 3. 最后搜索不到, 返回 null, 即代表使用主程序提供, 如果最后几次都为 null, 则会报错 - // 当启用本插件/触碰到本插件中的一些类型时, 而当主程序中没有提供相关的此 assemblyName 时, 也会触发此方法 来尝试加载 - - return null; - } - - protected override IntPtr LoadUnmanagedDll(string unmanagedDllName) - { - string libraryPath = _resolver.ResolveUnmanagedDllToPath(unmanagedDllName); - if (libraryPath != null) - { - return LoadUnmanagedDllFromPath(libraryPath); - } - - return IntPtr.Zero; - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginContextManager.cs b/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginContextManager.cs deleted file mode 100644 index 06957f8b..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginContextManager.cs +++ /dev/null @@ -1,108 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using PluginCore.Interfaces; -using PluginCore.lmplements; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Loader; -using System.Text; - -namespace PluginCore.lmplements -{ - /// - /// 启用插件时加载进来, 禁用插件时移除释放 - /// 只有已启用的插件才有上下文 - /// https://www.cnblogs.com/lwqlun/p/11395828.html - /// 1.当加载插件的时候,我们需要将当前插件的程序集加载上下文放到_pluginContexts字典中。字典的key是插件的名称,字典的value是插件的程序集加载上下文。 - /// 2.当移除一个插件的时候,我们需要使用Unload方法,来释放当前的程序集加载上下文。 - /// - public class PluginContextManager : IPluginContextManager - { - #region Fields - - private static int _newCount; - - //private Dictionary - // _pluginContexts; - - private Dictionary _pluginContexts - { - get - { - return PluginContextStore.PluginContexts; - } - } - - #endregion - - #region Ctor - public PluginContextManager() - { - //_pluginContexts = new Dictionary(); - - #region 计数 - _newCount++; - if (_newCount > 1) - { -#if DEBUG - Utils.LogUtil.Warn($"警告: {nameof(PluginContextManager)} 被 new {_newCount} 次"); -#endif - } - #endregion - } - #endregion - - #region Methods - - public List All() - { - return _pluginContexts.Select(p => p.Value).ToList(); - } - - public bool Any(string pluginId) - { - return _pluginContexts.ContainsKey(pluginId); - } - - public void Remove(string pluginId) - { - if (_pluginContexts.ContainsKey(pluginId)) - { - _pluginContexts[pluginId].Unload(); - _pluginContexts.Remove(pluginId); - } - } - - public IPluginContext Get(string pluginId) - { - return _pluginContexts[pluginId]; - } - - public void Add(string pluginId, IPluginContext context) - { - _pluginContexts.Add(pluginId, context); - } - #endregion - - } - - /// - /// fixed: 由于 单例失败, 因此临时解决方案 - /// - public static class PluginContextStore - { - public static Dictionary PluginContexts = new Dictionary(); - } - - - -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginContextPack.cs b/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginContextPack.cs deleted file mode 100644 index d59d2d67..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginContextPack.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using PluginCore.Interfaces; -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Runtime.Loader; -using System.Text; - -namespace PluginCore.lmplements -{ - public class PluginContextPack : IPluginContextPack - { - public IPluginContext Pack(string pluginId) - { - #region 加载插件主dll - - // 插件的主dll, 不包括插件项目引用的dll - string pluginMainDllFilePath = Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId, $"{pluginId}.dll"); - // 此插件的 加载上下文 - var context = new PluginLoadContext(pluginId, pluginMainDllFilePath); - Assembly pluginMainAssembly; - // 微软文档推荐 LoadFromAssemblyName - pluginMainAssembly = context.LoadFromAssemblyName(new AssemblyName(Path.GetFileNameWithoutExtension(pluginMainDllFilePath))); - - #region 第2种方法: 未在这种情况下测试 - //using (var fs = new FileStream(pluginMainDllFilePath, FileMode.Open)) - //{ - // // 使用此方法, 就不会导致dll被锁定 - // pluginMainAssembly = context.LoadFromStream(fs); - - // // 加载其中的控制器 - // _pluginControllerManager.AddControllers(pluginMainAssembly); - //} - #endregion - - #endregion - - - return context; - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginContextPackV1.cs b/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginContextPackV1.cs deleted file mode 100644 index 176f549a..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginContextPackV1.cs +++ /dev/null @@ -1,104 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using PluginCore.Interfaces; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.Loader; -using System.Text; - -namespace PluginCore.lmplements -{ - public class PluginContextPackV1 : IPluginContextPack - { - public IList SkipDlls { get; set; } - - public IPluginContext Pack(string pluginId) - { - SkipDlls = new List(); - - #region 跳过1: 程序目录下 以单独dll 出现 - // 获取主程序 已经存在的(不许在再加载的 dll) - string basePath = AppContext.BaseDirectory; - //Console.WriteLine($"PluginCore.PluginManager: basePath: {basePath}"); - // { "Core.dll", "Domain.dll", "Framework.dll", "Services.dll", "Repositories.dll", "PluginCore.dll", ... } - SkipDlls = new DirectoryInfo(basePath).GetFiles("*.dll").Select(m => m.Name).ToList(); - #endregion - - #region 跳过2: 打包进入1个dll 或 打包进 1个exe - // 注意: 用户可能将 dll 打包在 一个dll中, 或打包进 exe, 因此 通过此方式 确保跳过 - // 主程序所有 位于 AssemblyLoadContext.Default - List skipAssembliesName = AssemblyLoadContext.Default.Assemblies - .Select(m => m.GetName()) - .Select(m => m.Name).ToList(); - foreach (var name in skipAssembliesName) - { - this.SkipDlls.Add($"{name}.dll"); - } - #endregion - - - // 此插件的 加载上下文 - var context = new CollectibleAssemblyLoadContext(pluginId); - - // TODO:未测试 加载插件引用的dll: 方法二: - //AssemblyName[] referenceAssemblyNames = pluginMainAssembly.GetReferencedAssemblies(); - //foreach (var assemblyName in referenceAssemblyNames) - //{ - // context.LoadFromAssemblyName(assemblyName); - //} - - // 跳过不需要加载的 dll, eg: ASP.NET Core Shared Framework, 主程序中已有dll - string[] skipDlls = SkipDlls.ToArray(); //new string[] { "Core.dll", "Domain.dll", "Framework.dll", "Services.dll", "Repositories.dll", "PluginCore.dll" }; - - // 注意: 先加载插件引用的dll, 因为可能在插件主dll的Controller中立即使用了引用的dll - - #region 加载插件引用的dll - // 加载插件引用的dll - // eg: xxx/Plugins/HelloWorld - string pluginDirPath = Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId); - var pluginDir = new DirectoryInfo(pluginDirPath); - // 插件引用的所有dll (排除 主dll 和 skipDlls ) - // 注意: 主程序中已有dll 必须跳过, 应为这些默认Context中已经加载, 而如果插件Context再次加载, 则认为这两个是不同Assembly, 导致其中的Type转换失败 - // 这里简单来说,意思就是当在一个自定义LoadContext中加载程序集的时候,如果找不到这个程序集,程序会自动去默认LoadContext中查找,如果默认LoadContext中都找不到,就会返回null。 - // 这里我突然想到会不会是因为DemoPlugin1、DemoPlugin2以及主站点的AssemblyLoadContext都加载了Mystique.Core.dll程序集的缘故,虽然他们加载的是同一个程序集,但是因为LoadContext不同,所以系统认为它是2个程序集。 - // 参考: https://www.cnblogs.com/lwqlun/p/12930713.html - var allReferenceFileInfos = pluginDir.GetFiles("*.dll").Where(p => - p.Name != $"{pluginId}.dll" - && - !skipDlls.Contains(p.Name)); - foreach (FileInfo file in allReferenceFileInfos) - { - using (var sr = new StreamReader(file.OpenRead())) - { - context.LoadFromStream(sr.BaseStream); - } - } - #endregion - - #region 加载插件主dll - // 插件的主dll, 不包括插件项目引用的dll - string pluginMainDllFilePath = Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId, $"{pluginId}.dll"); - Assembly pluginMainAssembly; - using (var fs = new FileStream(pluginMainDllFilePath, FileMode.Open)) - { - // 使用此方法, 就不会导致dll被锁定 - pluginMainAssembly = context.LoadFromStream(fs); - } - #endregion - - - return context; - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginFinder.cs b/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginFinder.cs deleted file mode 100644 index 4219d4d8..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginFinder.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.Loader; -using System.Text; -using Microsoft.Extensions.DependencyInjection; -using PluginCore.Infrastructure; -using PluginCore.Interfaces; -using PluginCore.IPlugins; - -namespace PluginCore.lmplements -{ - - /// - /// 插件发现者: 找启用的插件(1.plugin.config.json中启用 2. 有插件上下文) - /// TODO: 其实是没必要再效验plugin.config.json的,因为只有启用的插件才有上下文, 为了保险,暂时这么做 - /// 注意: 这意味着一个启用的插件需同时满足这两个条件 - /// - /// - /// 依赖解析: IServiceScopeFactory - /// - public class PluginFinder : PluginFinderV2 - { - public PluginFinder(IPluginContextManager pluginContextManager, IServiceScopeFactory serviceScopeFactory) : base(pluginContextManager, serviceScopeFactory) - { - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginFinderV1.cs b/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginFinderV1.cs deleted file mode 100644 index 181a43ef..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginFinderV1.cs +++ /dev/null @@ -1,312 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.Loader; -using System.Text; -using Microsoft.Extensions.DependencyInjection; -using PluginCore.Infrastructure; -using PluginCore.Interfaces; -using PluginCore.IPlugins; - -namespace PluginCore.lmplements -{ - - /// - /// 插件发现者: 找启用的插件(1.plugin.config.json中启用 2. 有插件上下文) - /// TODO: 其实是没必要再效验plugin.config.json的,因为只有启用的插件才有上下文, 为了保险,暂时这么做 - /// 注意: 这意味着一个启用的插件需同时满足这两个条件 - /// - /// - /// 依赖解析: IServiceProvider - /// - public class PluginFinderV1 : IPluginFinder - { - #region Fields - - /// - /// 用来解析插件构造函数需要的服务 - /// - private readonly IServiceProvider _serviceProvider; - - /// - /// TODO: 未使用 - /// Key: 实现了 IPlugin 的插件类 - /// Value: 此插件类 允许的 行为(众多实现了 IPlugin 的钩子接口) - /// - private static ConcurrentDictionary> _pluginAllowedBehavior; - - #endregion - - public IPluginContextManager PluginContextManager { get; set; } - - #region Ctor - public PluginFinderV1(IPluginContextManager pluginContextManager, IServiceProvider serviceProvider) - { - this.PluginContextManager = pluginContextManager; - _serviceProvider = serviceProvider; - } - - static PluginFinderV1() - { - // TODO: 初始化: 默认为信任模式: 插件允许所有行为 - _pluginAllowedBehavior = new ConcurrentDictionary>(); - } - #endregion - - - #region 允许激活行为的 启用插件 - /// - /// TODO: 实现了指定接口或类型 的启用插件 并且 允许激活此行为(接口) - /// - /// TODO: 考虑后,还是没办法限制住插件恶意行为, 因为无法限制插件 修改配置文件 - /// - /// - /// - public IEnumerable ActivatedPlugins() - where TPlugin : IPlugin - { - var enablePlugins = EnablePlugins(); - foreach (var plugin in enablePlugins) - { - // TODO: 检查是否允许 此插件行为 - - - yield return plugin; - } - } - #endregion - - #region 实现了指定接口或类型 的启用插件 - /// - /// 实现了指定接口或类型 的启用插件 - /// - /// 可以是一个接口,一个抽象类,一个普通实现类, 只要实现了 即可 - /// - public IEnumerable<(TPlugin PluginInstance, string PluginId)> EnablePluginsFull() - where TPlugin : IPlugin // BasePlugin - { - // TODO: 目前这里还有问题, 不应该写为 BasePlugin, 不利于扩展, 不利于插件开发者自己实现 Install , Uninstall等 - - // 1.所有启用的插件 PluginId - var pluginConfigModel = PluginConfigModelFactory.Create(); - IList enablePluginIds = pluginConfigModel.EnabledPlugins; - foreach (var pluginId in enablePluginIds) - { - if (this.PluginContextManager.Any(pluginId)) - { - // 2.找到插件对应的Context - var context = this.PluginContextManager.Get(pluginId); - // 3.找插件 主 Assembly - // Assembly.FullName: HelloWorld, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - Assembly pluginMainAssembly = context.Assemblies.Where(m => m.FullName.StartsWith($"{pluginId}, Version=")).FirstOrDefault(); - if (pluginMainAssembly == null) - { - continue; - } - // 4.从插件主Assembly中 找实现了 TPlugin 接口的 Type, 若有多个,只要一个 - Type pluginType = pluginMainAssembly.ExportedTypes.Where(m => - (m.BaseType == typeof(TPlugin) || m.GetInterfaces().Contains(typeof(TPlugin))) - && - !m.IsInterface - && - !m.IsAbstract - ).FirstOrDefault(); - if (pluginType == null) - { - continue; - } - // 5.实例化插件 Type - //(TPlugin)Activator.CreateInstance(pluginType,); - //try to resolve plugin as unregistered service - //object instance = EngineContext.Current.ResolveUnregistered(pluginType); - object instance = ResolveUnregistered(pluginType); - //try to get typed instance - TPlugin typedInstance = (TPlugin)instance; - if (typedInstance == null) - { - continue; - } - - yield return (PluginInstance: typedInstance, PluginId: pluginId); - } - } - - } - - /// - /// 实现了指定接口或类型 的启用插件 - /// - /// 可以是一个接口,一个抽象类,一个普通实现类, 只要实现了 即可 - /// - public IEnumerable EnablePlugins() - where TPlugin : IPlugin // BasePlugin - { - return EnablePluginsFull().Select(m => m.PluginInstance); - } - #endregion - - #region 所有启用的插件 - /// - /// 所有启用的插件 - /// - /// - public IEnumerable EnablePlugins() - { - return EnablePluginsFull().Select(m => m.PluginInstance); - } - - /// - /// 所有启用的插件 - /// - /// - public IEnumerable<(IPlugin PluginInstance, string PluginId)> EnablePluginsFull() - { - return EnablePluginsFull(); - } - - /// - /// 所有启用的插件 的 PluginId - /// - /// - public IEnumerable EnablePluginIds() - where TPlugin : IPlugin // BasePlugin - { - // 1.所有启用的插件 PluginId - var pluginConfigModel = PluginConfigModelFactory.Create(); - IList enablePluginIds = pluginConfigModel.EnabledPlugins; - foreach (var pluginId in enablePluginIds) - { - if (this.PluginContextManager.Any(pluginId)) - { - yield return pluginId; - } - } - } - - /// - /// 所有启用的插件 的 PluginId - /// - /// - public IEnumerable EnablePluginIds() - { - return EnablePluginIds(); - } - #endregion - - #region 获取指定 pluginId 的启用插件 - /// - /// 获取指定 pluginId 的启用插件 - /// - /// - /// 1.插件未启用返回null, 2.找不到此插件上下文返回null 3.找不到插件主dll返回null 4.插件主dll中找不到实现了IPlugin的Type返回null, 5.无法实例化插件返回null - public IPlugin Plugin(string pluginId) - { - // 1.所有启用的插件 PluginId - var pluginConfigModel = PluginConfigModelFactory.Create(); - IList enablePluginIds = pluginConfigModel.EnabledPlugins; - // 插件未启用返回null - if (!enablePluginIds.Contains(pluginId)) - { - return null; - } - - // 找不到此插件上下文返回null - if (!this.PluginContextManager.Any(pluginId)) - { - return null; - } - - // 2.找到插件对应的Context - var context = this.PluginContextManager.Get(pluginId); - // 3.找插件 主 Assembly - // Assembly.FullName: HelloWorld, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - Assembly pluginMainAssembly = context.Assemblies.Where(m => m.FullName.StartsWith($"{pluginId}, Version=")).FirstOrDefault(); - // 找不到插件主dll返回null - if (pluginMainAssembly == null) - { - return null; - } - // 4.从插件主Assembly中 找实现了 TPlugin 接口的 Type, 若有多个,只要一个 - Type pluginType = pluginMainAssembly.ExportedTypes.Where(m => - (m.BaseType == typeof(IPlugin) || m.GetInterfaces().Contains(typeof(IPlugin))) - && - !m.IsInterface - && - !m.IsAbstract - ).FirstOrDefault(); - // 插件主dll中找不到实现了IPlugin的Type返回null - if (pluginType == null) - { - return null; - } - // 5.实例化插件 Type - //(TPlugin)Activator.CreateInstance(pluginType,); - //try to resolve plugin as unregistered service - //object instance = EngineContext.Current.ResolveUnregistered(pluginType); - object instance = ResolveUnregistered(pluginType); - //try to get typed instance - IPlugin typedInstance = (IPlugin)instance; - // 无法实例化插件返回null - if (typedInstance == null) - { - return null; - } - - return typedInstance; - } - #endregion - - #region 获取未IOC注册的类型实例 - /// - /// 获取未IOC注册的类型实例 - /// 此类型的构造函数可以依赖注入, 将通过ASP.NET Core 自带依赖注入系统进行注入 - /// - /// - /// - protected virtual object ResolveUnregistered(Type type) - { - - Exception innerException = null; - foreach (var constructor in type.GetConstructors()) - { - try - { - //try to resolve constructor parameters - var parameters = constructor.GetParameters().Select(parameter => - { - //var service = Resolve(parameter.ParameterType); - var service = _serviceProvider.GetService(parameter.ParameterType); - if (service == null) - throw new Exception("Unknown dependency"); - return service; - }); - - //all is ok, so create instance - return Activator.CreateInstance(type, parameters.ToArray()); - } - catch (Exception ex) - { - innerException = ex; - } - } - - throw new Exception("No constructor was found that had all the dependencies satisfied.", innerException); - - } - #endregion - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginFinderV2.cs b/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginFinderV2.cs deleted file mode 100644 index 946ebeaa..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginFinderV2.cs +++ /dev/null @@ -1,316 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.Loader; -using System.Text; -using Microsoft.Extensions.DependencyInjection; -using PluginCore.Infrastructure; -using PluginCore.Interfaces; -using PluginCore.IPlugins; - -namespace PluginCore.lmplements -{ - - /// - /// 插件发现者: 找启用的插件(1.plugin.config.json中启用 2. 有插件上下文) - /// TODO: 其实是没必要再效验plugin.config.json的,因为只有启用的插件才有上下文, 为了保险,暂时这么做 - /// 注意: 这意味着一个启用的插件需同时满足这两个条件 - /// - /// - /// 依赖解析: IServiceScopeFactory - /// - public class PluginFinderV2 : IPluginFinder - { - #region Fields - - /// - /// 用来解析插件构造函数需要的服务 - /// - private readonly IServiceScopeFactory _serviceScopeFactory; - - /// - /// TODO: 未使用 - /// Key: 实现了 IPlugin 的插件类 - /// Value: 此插件类 允许的 行为(众多实现了 IPlugin 的钩子接口) - /// - private static ConcurrentDictionary> _pluginAllowedBehavior; - - #endregion - - public IPluginContextManager PluginContextManager { get; set; } - - #region Ctor - public PluginFinderV2(IPluginContextManager pluginContextManager, IServiceScopeFactory serviceScopeFactory) - { - this.PluginContextManager = pluginContextManager; - _serviceScopeFactory = serviceScopeFactory; - } - - static PluginFinderV2() - { - // TODO: 初始化: 默认为信任模式: 插件允许所有行为 - _pluginAllowedBehavior = new ConcurrentDictionary>(); - } - #endregion - - - #region 允许激活行为的 启用插件 - /// - /// TODO: 实现了指定接口或类型 的启用插件 并且 允许激活此行为(接口) - /// - /// TODO: 考虑后,还是没办法限制住插件恶意行为, 因为无法限制插件 修改配置文件 - /// - /// - /// - public IEnumerable ActivatedPlugins() - where TPlugin : IPlugin - { - var enablePlugins = EnablePlugins(); - foreach (var plugin in enablePlugins) - { - // TODO: 检查是否允许 此插件行为 - - - yield return plugin; - } - } - #endregion - - #region 实现了指定接口或类型 的启用插件 - /// - /// 实现了指定接口或类型 的启用插件 - /// - /// 可以是一个接口,一个抽象类,一个普通实现类, 只要实现了 即可 - /// - public IEnumerable<(TPlugin PluginInstance, string PluginId)> EnablePluginsFull() - where TPlugin : IPlugin // BasePlugin - { - // TODO: 目前这里还有问题, 不应该写为 BasePlugin, 不利于扩展, 不利于插件开发者自己实现 Install , Uninstall等 - - // 1.所有启用的插件 PluginId - var pluginConfigModel = PluginConfigModelFactory.Create(); - IList enablePluginIds = pluginConfigModel.EnabledPlugins; - foreach (var pluginId in enablePluginIds) - { - if (this.PluginContextManager.Any(pluginId)) - { - // 2.找到插件对应的Context - var context = this.PluginContextManager.Get(pluginId); - // 3.找插件 主 Assembly - // Assembly.FullName: HelloWorld, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - Assembly pluginMainAssembly = context.Assemblies.Where(m => m.FullName.StartsWith($"{pluginId}, Version=")).FirstOrDefault(); - if (pluginMainAssembly == null) - { - continue; - } - // 4.从插件主Assembly中 找实现了 TPlugin 接口的 Type, 若有多个,只要一个 - Type pluginType = pluginMainAssembly.ExportedTypes.Where(m => - (m.BaseType == typeof(TPlugin) || m.GetInterfaces().Contains(typeof(TPlugin))) - && - !m.IsInterface - && - !m.IsAbstract - ).FirstOrDefault(); - if (pluginType == null) - { - continue; - } - // 5.实例化插件 Type - //(TPlugin)Activator.CreateInstance(pluginType,); - //try to resolve plugin as unregistered service - //object instance = EngineContext.Current.ResolveUnregistered(pluginType); - object instance = ResolveUnregistered(pluginType); - //try to get typed instance - TPlugin typedInstance = (TPlugin)instance; - if (typedInstance == null) - { - continue; - } - - yield return (PluginInstance: typedInstance, PluginId: pluginId); - } - } - - } - - /// - /// 实现了指定接口或类型 的启用插件 - /// - /// 可以是一个接口,一个抽象类,一个普通实现类, 只要实现了 即可 - /// - public IEnumerable EnablePlugins() - where TPlugin : IPlugin // BasePlugin - { - return EnablePluginsFull().Select(m => m.PluginInstance); - } - #endregion - - #region 所有启用的插件 - /// - /// 所有启用的插件 - /// - /// - public IEnumerable EnablePlugins() - { - return EnablePluginsFull().Select(m => m.PluginInstance); - } - - /// - /// 所有启用的插件 - /// - /// - public IEnumerable<(IPlugin PluginInstance, string PluginId)> EnablePluginsFull() - { - return EnablePluginsFull(); - } - - /// - /// 所有启用的插件 的 PluginId - /// - /// - public IEnumerable EnablePluginIds() - where TPlugin : IPlugin // BasePlugin - { - // 1.所有启用的插件 PluginId - var pluginConfigModel = PluginConfigModelFactory.Create(); - IList enablePluginIds = pluginConfigModel.EnabledPlugins; - foreach (var pluginId in enablePluginIds) - { - if (this.PluginContextManager.Any(pluginId)) - { - yield return pluginId; - } - } - } - - /// - /// 所有启用的插件 的 PluginId - /// - /// - public IEnumerable EnablePluginIds() - { - return EnablePluginIds(); - } - #endregion - - #region 获取指定 pluginId 的启用插件 - /// - /// 获取指定 pluginId 的启用插件 - /// - /// - /// 1.插件未启用返回null, 2.找不到此插件上下文返回null 3.找不到插件主dll返回null 4.插件主dll中找不到实现了IPlugin的Type返回null, 5.无法实例化插件返回null - public IPlugin Plugin(string pluginId) - { - // 1.所有启用的插件 PluginId - var pluginConfigModel = PluginConfigModelFactory.Create(); - IList enablePluginIds = pluginConfigModel.EnabledPlugins; - // 插件未启用返回null - if (!enablePluginIds.Contains(pluginId)) - { - return null; - } - - // 找不到此插件上下文返回null - if (!this.PluginContextManager.Any(pluginId)) - { - return null; - } - - // 2.找到插件对应的Context - var context = this.PluginContextManager.Get(pluginId); - // 3.找插件 主 Assembly - // Assembly.FullName: HelloWorld, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - Assembly pluginMainAssembly = context.Assemblies.Where(m => m.FullName.StartsWith($"{pluginId}, Version=")).FirstOrDefault(); - // 找不到插件主dll返回null - if (pluginMainAssembly == null) - { - return null; - } - // 4.从插件主Assembly中 找实现了 TPlugin 接口的 Type, 若有多个,只要一个 - Type pluginType = pluginMainAssembly.ExportedTypes.Where(m => - (m.BaseType == typeof(IPlugin) || m.GetInterfaces().Contains(typeof(IPlugin))) - && - !m.IsInterface - && - !m.IsAbstract - ).FirstOrDefault(); - // 插件主dll中找不到实现了IPlugin的Type返回null - if (pluginType == null) - { - return null; - } - // 5.实例化插件 Type - //(TPlugin)Activator.CreateInstance(pluginType,); - //try to resolve plugin as unregistered service - //object instance = EngineContext.Current.ResolveUnregistered(pluginType); - object instance = ResolveUnregistered(pluginType); - //try to get typed instance - IPlugin typedInstance = (IPlugin)instance; - // 无法实例化插件返回null - if (typedInstance == null) - { - return null; - } - - return typedInstance; - } - #endregion - - #region 获取未IOC注册的类型实例 - /// - /// 获取未IOC注册的类型实例 - /// 此类型的构造函数可以依赖注入, 将通过ASP.NET Core 自带依赖注入系统进行注入 - /// - /// - /// - protected virtual object ResolveUnregistered(Type type) - { - - Exception innerException = null; - foreach (var constructor in type.GetConstructors()) - { - try - { - //try to resolve constructor parameters - var parameters = constructor.GetParameters().Select(parameter => - { - //var service = Resolve(parameter.ParameterType); - // var service = _serviceProvider.GetService(parameter.ParameterType); - using (var scope = _serviceScopeFactory.CreateScope()) - { - var service = scope.ServiceProvider.GetService(parameter.ParameterType); - if (service == null) - throw new Exception("Unknown dependency"); - return service; - } - }); - - //all is ok, so create instance - return Activator.CreateInstance(type, parameters.ToArray()); - } - catch (Exception ex) - { - innerException = ex; - } - } - - throw new Exception("No constructor was found that had all the dependencies satisfied.", innerException); - - } - #endregion - - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginLoadContext.cs b/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginLoadContext.cs deleted file mode 100644 index 50da7308..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginLoadContext.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Admin.NET ĿİȨ̱ꡢרȨӦɷıʹñĿӦطɷ֤Ҫ -// -// ĿҪѭ MIT ֤ Apache ֤汾 2.0зַʹá֤λԴĿ¼е LICENSE-MIT LICENSE-APACHE ļ -// -// ñĿΣҰȫַ˺ϷȨȷɷֹĻκλڱĿοһзɾ׺ΣDzеκΣ - - - -using PluginCore.Interfaces; -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Runtime.Loader; -using System.Text; -using System.Linq; - -namespace PluginCore.lmplements -{ - /// - /// LazyPluginLoadContext - /// - public class PluginLoadContext : LazyPluginLoadContext, IPluginContext - { - public PluginLoadContext(string pluginId, string pluginMainDllFilePath) : base(pluginId, pluginMainDllFilePath) - { - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginManager.cs b/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginManager.cs deleted file mode 100644 index 0b5473ac..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PluginManager.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using PluginCore.Infrastructure; -using PluginCore.Interfaces; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.Loader; -using System.Text; - -namespace PluginCore.lmplements -{ - /// - /// 一个插件的所有dll由 一个 管理 - /// 记录管理了所有 插件的 - /// 是对 的封装, 使其更好管理插件加载释放的行为 - /// - public class PluginManager : IPluginManager - { - public IPluginContextManager PluginContextManager { get; set; } - - public IPluginContextPack PluginContextPack { get; set; } - - public PluginManager(IPluginContextManager pluginContextManager, IPluginContextPack pluginContextPack) - { - this.PluginContextManager = pluginContextManager; - this.PluginContextPack = pluginContextPack; - } - - /// - /// 加载插件程序集 - /// - /// - public void LoadPlugin(string pluginId) - { - IPluginContext context = this.PluginContextPack.Pack(pluginId); - - // 这个插件加载上下文 放入 集合中 - this.PluginContextManager.Add(pluginId, context); - } - - public void UnloadPlugin(string pluginId) - { - this.PluginContextManager.Remove(pluginId); - } - public Assembly GetPluginAssembly(string pluginId) - { - IPluginContext context = this.PluginContextPack.Pack(pluginId); - Assembly pluginMainAssembly = context.LoadFromAssemblyName(new AssemblyName(pluginId)); - - return pluginMainAssembly; - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PositivePluginLoadContext.cs b/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PositivePluginLoadContext.cs deleted file mode 100644 index a18d85a6..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/lmplements/PositivePluginLoadContext.cs +++ /dev/null @@ -1,118 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -using System.Reflection.Metadata; -//=================================================== -// License: GNU LGPLv3 -// Contributors: yiyungent@gmail.com -// Project: https://yiyungent.github.io/PluginCore -// GitHub: https://github.com/yiyungent/PluginCore -//=================================================== - - - -using PluginCore.Interfaces; -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Runtime.Loader; -using System.Text; -using System.Linq; - -namespace PluginCore.lmplements -{ - /// - /// 修改自下方 - /// https://docs.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support - /// 此方法依赖于 插件项目生成的 HelloWorldPlugin.deps.json 与 runtimes 文件夹, - /// 虽然官方文档没写, 但最好还带上 HelloWorldPlugin.runtimeconfig.json - /// 插件项目 .csproj 其它注意, 看文档 - /// - public class PositivePluginLoadContext : CollectibleAssemblyLoadContext, IPluginContext - { - private AssemblyDependencyResolver _resolver; - - /// - /// 即 插件的 Entrypoint Assembly - /// - public AssemblyName MainAssemblyName{ get; protected set; } - - public IEnumerable ReferencedAssemblyNames { get; protected set; } - - /// - /// 加了一个可回收 - /// - /// - public PositivePluginLoadContext(string pluginId, string pluginMainDllFilePath) : base(name: pluginId) - { - _resolver = new AssemblyDependencyResolver(pluginMainDllFilePath); - - // 主动加载 存在此插件文件夹的 依赖项 - using (var mainFs = new FileStream(pluginMainDllFilePath, FileMode.Open)) - { - // 使用此方法, 就不会导致dll被锁定 - // 锁定dll 会导致: 1. 无法通过复制粘贴替换 更新 2. 无法删除 - Assembly mainAssembly = LoadFromStream(mainFs); - // 上面 FileStream 处于打开 pluginMainDllFilePath 状态, 不能使用下方方法 - //this.MainAssemblyName = AssemblyName.GetAssemblyName(pluginMainDllFilePath); - this.MainAssemblyName = mainAssembly.GetName(); - AssemblyName[] referencedAssemblies = mainAssembly.GetReferencedAssemblies(); - this.ReferencedAssemblyNames = referencedAssemblies.AsEnumerable(); - - // TODO: - AssemblyFile assemblyFile = new AssemblyFile(); - - foreach (var referencedAssembly in referencedAssemblies) - { - string assemblyPath = _resolver.ResolveAssemblyToPath(referencedAssembly); - if (assemblyPath != null) - { - //return LoadFromAssemblyPath(assemblyPath); - using (var fs = new FileStream(assemblyPath, FileMode.Open)) - { - // 使用此方法, 就不会导致dll被锁定 - // 锁定dll 会导致: 1. 无法通过复制粘贴替换 更新 2. 无法删除 - LoadFromStream(fs); - } - } - } - } - } - - protected override Assembly Load(AssemblyName assemblyName) - { - // 1. 先尝试 从本插件文件夹中搜索 (无需, 因为前面已先主动加载, 再次被调用此方法只能是其它情况: 有不存在于此插件文件夹下的依赖项 被需要) - - // 2. 再尝试 从其他启用的插件文件夹中搜索 - // 实测: 可在下方搜索, 主程序包括的 assemblyName 与 启用插件加载的 assemblyName 都会位于其中 - var assList = AppDomain.CurrentDomain.GetAssemblies(); - var temp = assList.FirstOrDefault(m => m.GetName().FullName == assemblyName.FullName); - if (temp != null) - { - return temp; - } - - // 3. 最后搜索不到, 返回 null, 即代表使用主程序提供, 如果最后几次都为 null, 则会报错 - // 当启用本插件/触碰到本插件中的一些类型时, 而当主程序中没有提供相关的此 assemblyName 时, 也会触发此方法 来尝试加载 - - return null; - } - - protected override IntPtr LoadUnmanagedDll(string unmanagedDllName) - { - string libraryPath = _resolver.ResolveUnmanagedDllToPath(unmanagedDllName); - if (libraryPath != null) - { - return LoadUnmanagedDllFromPath(libraryPath); - } - - return IntPtr.Zero; - } - } -} - - diff --git a/Admin.NET/Plugins/PluginCore/PluginCore/nuget-pack.ps1 b/Admin.NET/Plugins/PluginCore/PluginCore/nuget-pack.ps1 deleted file mode 100644 index c3c10d7a..00000000 --- a/Admin.NET/Plugins/PluginCore/PluginCore/nuget-pack.ps1 +++ /dev/null @@ -1 +0,0 @@ -dotnet pack -c Release \ No newline at end of file diff --git a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay.zip b/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay.zip deleted file mode 100644 index 31169e0c..00000000 Binary files a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay.zip and /dev/null differ diff --git a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Admin.NET.Plugin.Pay.Alipay.csproj b/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Admin.NET.Plugin.Pay.Alipay.csproj deleted file mode 100644 index c74c1007..00000000 --- a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Admin.NET.Plugin.Pay.Alipay.csproj +++ /dev/null @@ -1,62 +0,0 @@ - - - - net8.0;net9.0 - 1701;1702;8616;1591;8618;8619;8629;8602;8603;8604;8625;8765 - Admin.NET.Plugin.Pay.Alipay.xml - enable - - enable - - - - - - - - - - - - - - - - PreserveNewest - - - - - - - runtime - - - - - - - Always - - - Always - - - Always - - - - - - - Always - - - Always - - - - - - - diff --git a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Admin.NET.Plugin.Pay.Alipay.xml b/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Admin.NET.Plugin.Pay.Alipay.xml deleted file mode 100644 index 79a4de2e..00000000 --- a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Admin.NET.Plugin.Pay.Alipay.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - Admin.NET.Plugin.Pay.Alipay - - - - - 在 Build 时, 将会 new Middleware(), 最终将所有 Middleware 包装为一个 - - - - - - - - - 测试,是否运行时添加的Middleware,是否可以依赖注入 - - - - - 系统动态插件服务 - - - - - 获取动态插件列表 - - - - - - diff --git a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/AliPayPlugin.cs b/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/AliPayPlugin.cs deleted file mode 100644 index 812c18a9..00000000 --- a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/AliPayPlugin.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - -using Admin.NET.Plugin.Core.Abstractions.Pay; -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; -using PluginCore.IPlugins; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Admin.NET.Plugin.Pay.Alipay -{ - public class AliPayPlugin : BasePlugin, IStartupPlugin, IPayPlugin - { - - public void ConfigureServices(IServiceCollection services) - { - - } - - public void Configure(IApplicationBuilder app) - { - - } - - public int ConfigureOrder - { - get - { - return 2; - } - } - - - public int ConfigureServicesOrder - { - get - { - return 2; - } - } - public string Name { get; set; } = "alipay"; - public string Say() - { - return "支付宝插件"; - } - - } -} diff --git a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Controllers/AliWebApiController.cs b/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Controllers/AliWebApiController.cs deleted file mode 100644 index 0972d21c..00000000 --- a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Controllers/AliWebApiController.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Admin.NET ĿİȨ̱ꡢרȨӦɷıʹñĿӦطɷ֤Ҫ -// -// ĿҪѭ MIT ֤ Apache ֤汾 2.0зַʹá֤λԴĿ¼е LICENSE-MIT LICENSE-APACHE ļ -// -// ñĿΣҰȫַ˺ϷȨȷɷֹĻκλڱĿοһзɾ׺ΣDzеκΣ - - - -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using System.ComponentModel; - -namespace Admin.NET.Plugin.Pay.Alipay.Controllers -{ - - [Route("api/plugins/[controller]")] - [AllowAnonymous] - public class AliWebApiController : ControllerBase - { - [DisplayName("֧Ϣ")] - [HttpGet] - public IActionResult Get() - { - string str = $"֧Ϣ Hello PluginCore !"; - return Content(str); - } - } - -} diff --git a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Controllers/HomeController.cs b/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Controllers/HomeController.cs deleted file mode 100644 index d8b1d1be..00000000 --- a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Controllers/HomeController.cs +++ /dev/null @@ -1,35 +0,0 @@ - - -using Microsoft.AspNetCore.Mvc; -using PluginCore; -using System.ComponentModel; -using System.Threading.Tasks; - -namespace Admin.NET.Plugin.Pay.Yfzf.Controllers -{ - /// - /// 其实也可以不写这个, 直接访问 Plugins/HelloWorldPlugin/index.html - /// - /// 下面的方法, 是去掉 index.html - /// - /// 若 wwwroot 下有其它需要访问的文件, 如何 css, js, 而你又不想每次新增 action 指定返回, 则 Route 必须 Plugins/{PluginId}, - /// 这样访问 Plugins/HelloWorldPlugin/css/main.css 就会访问到你插件下的 wwwroot/css/main.css - /// - [Route("Plugins/HelloWorldPlugin")] - public class HomeController : Controller - { - - /// - /// 新大陆信息 - /// - /// - [ApiDescriptionSettings(Name = "Index"), HttpGet] - [DisplayName("新大陆信息")] - public async Task Index() - { - string indexFilePath = System.IO.Path.Combine(PluginPathProvider.PluginWwwRootDir("Admin.NET.Plugin.Pay.Yfzf"), "index.html"); - - return PhysicalFile(indexFilePath, "text/html"); - } - } -} diff --git a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/GlobalUsing.cs b/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/GlobalUsing.cs deleted file mode 100644 index 74374ea6..00000000 --- a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/GlobalUsing.cs +++ /dev/null @@ -1,8 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -global using Furion; -global using Microsoft.Extensions.DependencyInjection; diff --git a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/HelloWorldPlugin.cs b/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/HelloWorldPlugin.cs deleted file mode 100644 index c201d754..00000000 --- a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/HelloWorldPlugin.cs +++ /dev/null @@ -1,73 +0,0 @@ - -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! -using Admin.NET.Plugin.Pay.Alipay.Middlewares; -using Microsoft.AspNetCore.Builder; -using PluginCore.IPlugins; - -namespace Admin.NET.Plugin.Pay.Alipay -{ - public class HelloWorldPlugin : BasePlugin, IStartupXPlugin, IWidgetPlugin - { - public override (bool IsSuccess, string Message) AfterEnable() - { - Console.WriteLine($"{nameof(HelloWorldPlugin)}: {nameof(AfterEnable)}"); - return base.AfterEnable(); - } - - public override (bool IsSuccess, string Message) BeforeDisable() - { - Console.WriteLine($"{nameof(HelloWorldPlugin)}: {nameof(BeforeDisable)}"); - return base.BeforeDisable(); - } - - public void ConfigureServices(IServiceCollection services) - { - - } - - public void Configure(IApplicationBuilder app) - { - app.UseMiddleware(); - } - - public int ConfigureOrder - { - get - { - return 2; - } - } - - - public int ConfigureServicesOrder - { - get - { - return 2; - } - } - - public async Task Widget(string widgetKey, params string[] extraPars) - { - string rtnStr = null; - if (widgetKey == "PluginCore.Admin.Footer") - { - if (extraPars != null) - { - Console.WriteLine(string.Join(",", extraPars)); - } - rtnStr = @"
-

HelloWorldPlugin 注入

-
HelloWorldPlugin 挂件
-
"; - - } - - return await Task.FromResult(rtnStr); - } - } -} diff --git a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Middlewares/AlipaySayHelloMiddleware.cs b/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Middlewares/AlipaySayHelloMiddleware.cs deleted file mode 100644 index bf0d4f6c..00000000 --- a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Middlewares/AlipaySayHelloMiddleware.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - - -using Admin.NET.Plugin.Core.Abstractions.Pay; -using Microsoft.AspNetCore.Http; -using PluginCore.Interfaces; -using PluginCore.IPlugins; -using System.Text; - -namespace Admin.NET.Plugin.Pay.Alipay.Middlewares -{ - public class AlipaySayHelloMiddleware - { - private readonly RequestDelegate _next; - - /// - /// 在 Build 时, 将会 new Middleware(), 最终将所有 Middleware 包装为一个 - /// - /// - public AlipaySayHelloMiddleware(RequestDelegate next) - { - _next = next; - } - - - /// - /// - /// - /// - /// 测试,是否运行时添加的Middleware,是否可以依赖注入 - /// - public async Task InvokeAsync(HttpContext httpContext, IPluginFinder pluginFinder) - { - // 测试: 成功 - List plugins = pluginFinder.EnablePlugins()?.ToList(); - // 所有实现了 ITestPlugin 的已启用插件 - var payPlugins = pluginFinder.EnablePlugins().ToList(); - bool isMatch = false; - - isMatch = httpContext.Request.Path.Value.StartsWith("/SayHello"); - - if (isMatch) - { - string sayhello = payPlugins[0].Say(); - await httpContext.Response.WriteAsync($"Hello World! {DateTime.Now:yyyy-MM-dd HH:mm:ss}
" + - $"Say Hello! {sayhello}
" + - $"{httpContext.Request.Path}
" + - $"{httpContext.Request.QueryString.Value}", Encoding.UTF8); - } - else - { - // Call the next delegate/middleware in the pipeline - await _next(httpContext); - } - } - - } -} diff --git a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/README.md b/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/README.md deleted file mode 100644 index 5f9d8314..00000000 --- a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/README.md +++ /dev/null @@ -1,14 +0,0 @@ -## 说明文档(可选) - -- [] 这是一个示例插件 -- [x] 感谢使用 - -## API - -- [/SayHello](/SayHello) - - 通过插件在运行时添加 管道Middleware, 并拦截响应 - -- [/api/plugins/AliWebApi](/api/plugins/AliWebApi) - - 通过插件Controller 响应 - - \ No newline at end of file diff --git a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Services/AlipayPluginCoreService.cs b/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Services/AlipayPluginCoreService.cs deleted file mode 100644 index 2b182674..00000000 --- a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/Services/AlipayPluginCoreService.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - - -using Furion.DependencyInjection; -using Furion.DynamicApiController; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using PluginCore.AspNetCore.Interfaces; -using PluginCore.Interfaces; -using System.ComponentModel; - -namespace Admin.NET.Plugin.Pay.Alipay.Service; - -/// -/// 系统动态插件服务 -/// -[ApiDescriptionSettings("自定义插件", Name = "Alipay", Order = 100, Description = "支付宝支付插件")] -[AllowAnonymous] -public class AlipayPluginCoreService : IDynamicApiController, IScoped -{ - #region Fields - private readonly IPluginManager _pluginManager; - private readonly IPluginFinder _pluginFinder; - private readonly IPluginApplicationBuilderManager _pluginApplicationBuilderManager; - #endregion - private readonly IDynamicApiRuntimeChangeProvider _provider; - - - public AlipayPluginCoreService(IPluginManager pluginManager, IPluginFinder pluginFinder, IPluginApplicationBuilderManager pluginApplicationBuilderManager, IDynamicApiRuntimeChangeProvider provider) - { - _pluginManager = pluginManager; - _pluginFinder = pluginFinder; - _pluginApplicationBuilderManager = pluginApplicationBuilderManager; - _provider = provider; - } - - /// - /// 获取动态插件列表 - /// - /// - /// - [DisplayName("获取动态插件列表")] - [HttpGet] - [ApiDescriptionSettings(Name = "Page")] - public Task Page() - { - return Task.FromResult("測試插件"); - } - - -} \ No newline at end of file diff --git a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/info.json b/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/info.json deleted file mode 100644 index ec71bb1f..00000000 --- a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/info.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "PluginId": "Admin.NET.Plugin.Pay.Alipay", - "DisplayName": "Alipay示例", - "Description": "这是支付宝插件", - "Author": "tomny", - "Version": "0.1.0", - "SupportedVersions": [ "0.0.1" ] -} \ No newline at end of file diff --git a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/settings.json b/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/settings.json deleted file mode 100644 index 9a32e4c3..00000000 --- a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Hello": "哈哈哈哈哈或或或或或或" -} \ No newline at end of file diff --git a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/wwwroot/css/main.css b/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/wwwroot/css/main.css deleted file mode 100644 index 191068ea..00000000 --- a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/wwwroot/css/main.css +++ /dev/null @@ -1,9 +0,0 @@ -* { - margin: 0; - padding: 0; -} - -#app { - width: 100%; - color: deepskyblue; -} \ No newline at end of file diff --git a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/wwwroot/index.html b/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/wwwroot/index.html deleted file mode 100644 index 9bb783d2..00000000 --- a/Admin.NET/Plugins/PluginCore/Test/Admin.NET.Plugin.Pay.Alipay/wwwroot/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - HelloWorldPlugin - - - - -
-

HelloWorldPlugin!

-

插件的前端文件应当放在 wwwroot 文件夹下

-
- - - \ No newline at end of file diff --git a/Web/package.json b/Web/package.json index 84365589..495e41e3 100644 --- a/Web/package.json +++ b/Web/package.json @@ -12,7 +12,7 @@ "lint-fix": "eslint --fix src/", "format": "prettier --write .", "build-api": "cd api_build/ && build.bat", - "build-approvalFlow-api": "cd api_build/ && build.bat approvalFlow", + "build-dataApproval-api": "cd api_build/ && build.bat dataApproval", "build-dingTalk-api": "cd api_build/ && build.bat dingTalk", "build-goView-api": "cd api_build/ && build.bat goView", "genEleIconTypes": "node script/genEleIconTypes.js", diff --git a/Web/src/api-services/dataApproval/api.ts b/Web/src/api-services/dataApproval/api.ts index f64f054f..d30b4f48 100644 --- a/Web/src/api-services/dataApproval/api.ts +++ b/Web/src/api-services/dataApproval/api.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * @@ -11,5 +11,5 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ -export * from './apis/approval-flow-api'; +export * from './apis/data-approval-api'; diff --git a/Web/src/api-services/dataApproval/apis/approval-flow-api.ts b/Web/src/api-services/dataApproval/apis/data-approval-api.ts similarity index 77% rename from Web/src/api-services/dataApproval/apis/approval-flow-api.ts rename to Web/src/api-services/dataApproval/apis/data-approval-api.ts index 87752dfd..719db471 100644 --- a/Web/src/api-services/dataApproval/apis/approval-flow-api.ts +++ b/Web/src/api-services/dataApproval/apis/data-approval-api.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * @@ -17,34 +17,34 @@ import { Configuration } from '../configuration'; // Some imports not used depending on template conditions // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; -import { AddApprovalFlowInput } from '../models'; -import { AdminResultApprovalFlow } from '../models'; -import { AdminResultInt64 } from '../models'; -import { AdminResultListApprovalFlowOutput } from '../models'; -import { AdminResultListString } from '../models'; -import { AdminResultObject } from '../models'; -import { AdminResultSqlSugarPagedListApprovalFlowOutput } from '../models'; -import { ApprovalFlowInput } from '../models'; -import { DeleteApprovalFlowInput } from '../models'; +import { AddDataApprovalInput } from '../models'; +import { AdminNETResultDataApproval } from '../models'; +import { AdminNETResultInt64 } from '../models'; +import { AdminNETResultListDataApprovalOutput } from '../models'; +import { AdminNETResultListString } from '../models'; +import { AdminNETResultObject } from '../models'; +import { AdminNETResultSqlSugarPagedListDataApprovalOutput } from '../models'; +import { DataApprovalInput } from '../models'; +import { DeleteDataApprovalInput } from '../models'; import { Filter } from '../models'; import { FilterLogicEnum } from '../models'; import { FilterOperatorEnum } from '../models'; -import { UpdateApprovalFlowInput } from '../models'; +import { UpdateDataApprovalInput } from '../models'; /** - * ApprovalFlowApi - axios parameter creator + * DataApprovalApi - axios parameter creator * @export */ -export const ApprovalFlowApiAxiosParamCreator = function (configuration?: Configuration) { +export const DataApprovalApiAxiosParamCreator = function (configuration?: Configuration) { return { /** * * @summary 增加审批流 - * @param {AddApprovalFlowInput} [body] + * @param {AddDataApprovalInput} [body] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - apiApprovalFlowAddPost: async (body?: AddApprovalFlowInput, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/approvalFlow/add`; + apiDataApprovalAddPost: async (body?: AddDataApprovalInput, options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/dataApproval/add`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, 'https://example.com'); let baseOptions; @@ -87,12 +87,12 @@ export const ApprovalFlowApiAxiosParamCreator = function (configuration?: Config /** * * @summary 删除审批流 - * @param {DeleteApprovalFlowInput} [body] + * @param {DeleteDataApprovalInput} [body] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - apiApprovalFlowDeletePost: async (body?: DeleteApprovalFlowInput, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/approvalFlow/delete`; + apiDataApprovalDeletePost: async (body?: DeleteDataApprovalInput, options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/dataApproval/delete`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, 'https://example.com'); let baseOptions; @@ -139,12 +139,12 @@ export const ApprovalFlowApiAxiosParamCreator = function (configuration?: Config * @param {*} [options] Override http request option. * @throws {RequiredError} */ - apiApprovalFlowDetailGet: async (id: number, options: AxiosRequestConfig = {}): Promise => { + apiDataApprovalDetailGet: async (id: number, options: AxiosRequestConfig = {}): Promise => { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { - throw new RequiredError('id','Required parameter id was null or undefined when calling apiApprovalFlowDetailGet.'); + throw new RequiredError('id','Required parameter id was null or undefined when calling apiDataApprovalDetailGet.'); } - const localVarPath = `/api/approvalFlow/detail`; + const localVarPath = `/api/dataApproval/detail`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, 'https://example.com'); let baseOptions; @@ -191,8 +191,8 @@ export const ApprovalFlowApiAxiosParamCreator = function (configuration?: Config * @param {*} [options] Override http request option. * @throws {RequiredError} */ - apiApprovalFlowFlowListGet: async (code?: string, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/approvalFlow/flowList`; + apiDataApprovalFlowListGet: async (code?: string, options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/dataApproval/flowList`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, 'https://example.com'); let baseOptions; @@ -238,8 +238,8 @@ export const ApprovalFlowApiAxiosParamCreator = function (configuration?: Config * @param {*} [options] Override http request option. * @throws {RequiredError} */ - apiApprovalFlowFormRoutesGet: async (options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/approvalFlow/formRoutes`; + apiDataApprovalFormRoutesGet: async (options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/dataApproval/formRoutes`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, 'https://example.com'); let baseOptions; @@ -282,8 +282,8 @@ export const ApprovalFlowApiAxiosParamCreator = function (configuration?: Config * @param {*} [options] Override http request option. * @throws {RequiredError} */ - apiApprovalFlowInfoGet: async (code?: string, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/approvalFlow/info`; + apiDataApprovalInfoGet: async (code?: string, options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/dataApproval/info`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, 'https://example.com'); let baseOptions; @@ -345,8 +345,8 @@ export const ApprovalFlowApiAxiosParamCreator = function (configuration?: Config * @param {*} [options] Override http request option. * @throws {RequiredError} */ - apiApprovalFlowListGet: async (code?: string, name?: string, remark?: string, page?: number, pageSize?: number, field?: string, order?: string, descStr?: string, searchFields?: Array, searchKeyword?: string, keyword?: string, filterLogic?: FilterLogicEnum, filterFilters?: Array, filterField?: string, filterOperator?: FilterOperatorEnum, filterValue?: any, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/approvalFlow/list`; + apiDataApprovalListGet: async (code?: string, name?: string, remark?: string, page?: number, pageSize?: number, field?: string, order?: string, descStr?: string, searchFields?: Array, searchKeyword?: string, keyword?: string, filterLogic?: FilterLogicEnum, filterFilters?: Array, filterField?: string, filterOperator?: FilterOperatorEnum, filterValue?: any, options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/dataApproval/list`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, 'https://example.com'); let baseOptions; @@ -449,12 +449,12 @@ export const ApprovalFlowApiAxiosParamCreator = function (configuration?: Config /** * * @summary 分页查询审批流 - * @param {ApprovalFlowInput} [body] + * @param {DataApprovalInput} [body] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - apiApprovalFlowPagePost: async (body?: ApprovalFlowInput, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/approvalFlow/page`; + apiDataApprovalPagePost: async (body?: DataApprovalInput, options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/dataApproval/page`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, 'https://example.com'); let baseOptions; @@ -497,12 +497,12 @@ export const ApprovalFlowApiAxiosParamCreator = function (configuration?: Config /** * * @summary 更新审批流 - * @param {UpdateApprovalFlowInput} [body] + * @param {UpdateDataApprovalInput} [body] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - apiApprovalFlowUpdatePost: async (body?: UpdateApprovalFlowInput, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/approvalFlow/update`; + apiDataApprovalUpdatePost: async (body?: UpdateDataApprovalInput, options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/dataApproval/update`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, 'https://example.com'); let baseOptions; @@ -546,20 +546,20 @@ export const ApprovalFlowApiAxiosParamCreator = function (configuration?: Config }; /** - * ApprovalFlowApi - functional programming interface + * DataApprovalApi - functional programming interface * @export */ -export const ApprovalFlowApiFp = function(configuration?: Configuration) { +export const DataApprovalApiFp = function(configuration?: Configuration) { return { /** * * @summary 增加审批流 - * @param {AddApprovalFlowInput} [body] + * @param {AddDataApprovalInput} [body] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowAddPost(body?: AddApprovalFlowInput, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { - const localVarAxiosArgs = await ApprovalFlowApiAxiosParamCreator(configuration).apiApprovalFlowAddPost(body, options); + async apiDataApprovalAddPost(body?: AddDataApprovalInput, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { + const localVarAxiosArgs = await DataApprovalApiAxiosParamCreator(configuration).apiDataApprovalAddPost(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; return axios.request(axiosRequestArgs); @@ -568,12 +568,12 @@ export const ApprovalFlowApiFp = function(configuration?: Configuration) { /** * * @summary 删除审批流 - * @param {DeleteApprovalFlowInput} [body] + * @param {DeleteDataApprovalInput} [body] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowDeletePost(body?: DeleteApprovalFlowInput, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { - const localVarAxiosArgs = await ApprovalFlowApiAxiosParamCreator(configuration).apiApprovalFlowDeletePost(body, options); + async apiDataApprovalDeletePost(body?: DeleteDataApprovalInput, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { + const localVarAxiosArgs = await DataApprovalApiAxiosParamCreator(configuration).apiDataApprovalDeletePost(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; return axios.request(axiosRequestArgs); @@ -586,8 +586,8 @@ export const ApprovalFlowApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowDetailGet(id: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { - const localVarAxiosArgs = await ApprovalFlowApiAxiosParamCreator(configuration).apiApprovalFlowDetailGet(id, options); + async apiDataApprovalDetailGet(id: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { + const localVarAxiosArgs = await DataApprovalApiAxiosParamCreator(configuration).apiDataApprovalDetailGet(id, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; return axios.request(axiosRequestArgs); @@ -600,8 +600,8 @@ export const ApprovalFlowApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowFlowListGet(code?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { - const localVarAxiosArgs = await ApprovalFlowApiAxiosParamCreator(configuration).apiApprovalFlowFlowListGet(code, options); + async apiDataApprovalFlowListGet(code?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { + const localVarAxiosArgs = await DataApprovalApiAxiosParamCreator(configuration).apiDataApprovalFlowListGet(code, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; return axios.request(axiosRequestArgs); @@ -613,8 +613,8 @@ export const ApprovalFlowApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowFormRoutesGet(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { - const localVarAxiosArgs = await ApprovalFlowApiAxiosParamCreator(configuration).apiApprovalFlowFormRoutesGet(options); + async apiDataApprovalFormRoutesGet(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { + const localVarAxiosArgs = await DataApprovalApiAxiosParamCreator(configuration).apiDataApprovalFormRoutesGet(options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; return axios.request(axiosRequestArgs); @@ -627,8 +627,8 @@ export const ApprovalFlowApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowInfoGet(code?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { - const localVarAxiosArgs = await ApprovalFlowApiAxiosParamCreator(configuration).apiApprovalFlowInfoGet(code, options); + async apiDataApprovalInfoGet(code?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { + const localVarAxiosArgs = await DataApprovalApiAxiosParamCreator(configuration).apiDataApprovalInfoGet(code, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; return axios.request(axiosRequestArgs); @@ -656,8 +656,8 @@ export const ApprovalFlowApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowListGet(code?: string, name?: string, remark?: string, page?: number, pageSize?: number, field?: string, order?: string, descStr?: string, searchFields?: Array, searchKeyword?: string, keyword?: string, filterLogic?: FilterLogicEnum, filterFilters?: Array, filterField?: string, filterOperator?: FilterOperatorEnum, filterValue?: any, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { - const localVarAxiosArgs = await ApprovalFlowApiAxiosParamCreator(configuration).apiApprovalFlowListGet(code, name, remark, page, pageSize, field, order, descStr, searchFields, searchKeyword, keyword, filterLogic, filterFilters, filterField, filterOperator, filterValue, options); + async apiDataApprovalListGet(code?: string, name?: string, remark?: string, page?: number, pageSize?: number, field?: string, order?: string, descStr?: string, searchFields?: Array, searchKeyword?: string, keyword?: string, filterLogic?: FilterLogicEnum, filterFilters?: Array, filterField?: string, filterOperator?: FilterOperatorEnum, filterValue?: any, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { + const localVarAxiosArgs = await DataApprovalApiAxiosParamCreator(configuration).apiDataApprovalListGet(code, name, remark, page, pageSize, field, order, descStr, searchFields, searchKeyword, keyword, filterLogic, filterFilters, filterField, filterOperator, filterValue, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; return axios.request(axiosRequestArgs); @@ -666,12 +666,12 @@ export const ApprovalFlowApiFp = function(configuration?: Configuration) { /** * * @summary 分页查询审批流 - * @param {ApprovalFlowInput} [body] + * @param {DataApprovalInput} [body] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowPagePost(body?: ApprovalFlowInput, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { - const localVarAxiosArgs = await ApprovalFlowApiAxiosParamCreator(configuration).apiApprovalFlowPagePost(body, options); + async apiDataApprovalPagePost(body?: DataApprovalInput, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { + const localVarAxiosArgs = await DataApprovalApiAxiosParamCreator(configuration).apiDataApprovalPagePost(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; return axios.request(axiosRequestArgs); @@ -680,12 +680,12 @@ export const ApprovalFlowApiFp = function(configuration?: Configuration) { /** * * @summary 更新审批流 - * @param {UpdateApprovalFlowInput} [body] + * @param {UpdateDataApprovalInput} [body] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowUpdatePost(body?: UpdateApprovalFlowInput, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { - const localVarAxiosArgs = await ApprovalFlowApiAxiosParamCreator(configuration).apiApprovalFlowUpdatePost(body, options); + async apiDataApprovalUpdatePost(body?: UpdateDataApprovalInput, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise>> { + const localVarAxiosArgs = await DataApprovalApiAxiosParamCreator(configuration).apiDataApprovalUpdatePost(body, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; return axios.request(axiosRequestArgs); @@ -695,30 +695,30 @@ export const ApprovalFlowApiFp = function(configuration?: Configuration) { }; /** - * ApprovalFlowApi - factory interface + * DataApprovalApi - factory interface * @export */ -export const ApprovalFlowApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { +export const DataApprovalApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { return { /** * * @summary 增加审批流 - * @param {AddApprovalFlowInput} [body] + * @param {AddDataApprovalInput} [body] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowAddPost(body?: AddApprovalFlowInput, options?: AxiosRequestConfig): Promise> { - return ApprovalFlowApiFp(configuration).apiApprovalFlowAddPost(body, options).then((request) => request(axios, basePath)); + async apiDataApprovalAddPost(body?: AddDataApprovalInput, options?: AxiosRequestConfig): Promise> { + return DataApprovalApiFp(configuration).apiDataApprovalAddPost(body, options).then((request) => request(axios, basePath)); }, /** * * @summary 删除审批流 - * @param {DeleteApprovalFlowInput} [body] + * @param {DeleteDataApprovalInput} [body] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowDeletePost(body?: DeleteApprovalFlowInput, options?: AxiosRequestConfig): Promise> { - return ApprovalFlowApiFp(configuration).apiApprovalFlowDeletePost(body, options).then((request) => request(axios, basePath)); + async apiDataApprovalDeletePost(body?: DeleteDataApprovalInput, options?: AxiosRequestConfig): Promise> { + return DataApprovalApiFp(configuration).apiDataApprovalDeletePost(body, options).then((request) => request(axios, basePath)); }, /** * @@ -727,8 +727,8 @@ export const ApprovalFlowApiFactory = function (configuration?: Configuration, b * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowDetailGet(id: number, options?: AxiosRequestConfig): Promise> { - return ApprovalFlowApiFp(configuration).apiApprovalFlowDetailGet(id, options).then((request) => request(axios, basePath)); + async apiDataApprovalDetailGet(id: number, options?: AxiosRequestConfig): Promise> { + return DataApprovalApiFp(configuration).apiDataApprovalDetailGet(id, options).then((request) => request(axios, basePath)); }, /** * @@ -737,8 +737,8 @@ export const ApprovalFlowApiFactory = function (configuration?: Configuration, b * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowFlowListGet(code?: string, options?: AxiosRequestConfig): Promise> { - return ApprovalFlowApiFp(configuration).apiApprovalFlowFlowListGet(code, options).then((request) => request(axios, basePath)); + async apiDataApprovalFlowListGet(code?: string, options?: AxiosRequestConfig): Promise> { + return DataApprovalApiFp(configuration).apiDataApprovalFlowListGet(code, options).then((request) => request(axios, basePath)); }, /** * @@ -746,8 +746,8 @@ export const ApprovalFlowApiFactory = function (configuration?: Configuration, b * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowFormRoutesGet(options?: AxiosRequestConfig): Promise> { - return ApprovalFlowApiFp(configuration).apiApprovalFlowFormRoutesGet(options).then((request) => request(axios, basePath)); + async apiDataApprovalFormRoutesGet(options?: AxiosRequestConfig): Promise> { + return DataApprovalApiFp(configuration).apiDataApprovalFormRoutesGet(options).then((request) => request(axios, basePath)); }, /** * @@ -756,8 +756,8 @@ export const ApprovalFlowApiFactory = function (configuration?: Configuration, b * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowInfoGet(code?: string, options?: AxiosRequestConfig): Promise> { - return ApprovalFlowApiFp(configuration).apiApprovalFlowInfoGet(code, options).then((request) => request(axios, basePath)); + async apiDataApprovalInfoGet(code?: string, options?: AxiosRequestConfig): Promise> { + return DataApprovalApiFp(configuration).apiDataApprovalInfoGet(code, options).then((request) => request(axios, basePath)); }, /** * @@ -781,60 +781,60 @@ export const ApprovalFlowApiFactory = function (configuration?: Configuration, b * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowListGet(code?: string, name?: string, remark?: string, page?: number, pageSize?: number, field?: string, order?: string, descStr?: string, searchFields?: Array, searchKeyword?: string, keyword?: string, filterLogic?: FilterLogicEnum, filterFilters?: Array, filterField?: string, filterOperator?: FilterOperatorEnum, filterValue?: any, options?: AxiosRequestConfig): Promise> { - return ApprovalFlowApiFp(configuration).apiApprovalFlowListGet(code, name, remark, page, pageSize, field, order, descStr, searchFields, searchKeyword, keyword, filterLogic, filterFilters, filterField, filterOperator, filterValue, options).then((request) => request(axios, basePath)); + async apiDataApprovalListGet(code?: string, name?: string, remark?: string, page?: number, pageSize?: number, field?: string, order?: string, descStr?: string, searchFields?: Array, searchKeyword?: string, keyword?: string, filterLogic?: FilterLogicEnum, filterFilters?: Array, filterField?: string, filterOperator?: FilterOperatorEnum, filterValue?: any, options?: AxiosRequestConfig): Promise> { + return DataApprovalApiFp(configuration).apiDataApprovalListGet(code, name, remark, page, pageSize, field, order, descStr, searchFields, searchKeyword, keyword, filterLogic, filterFilters, filterField, filterOperator, filterValue, options).then((request) => request(axios, basePath)); }, /** * * @summary 分页查询审批流 - * @param {ApprovalFlowInput} [body] + * @param {DataApprovalInput} [body] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowPagePost(body?: ApprovalFlowInput, options?: AxiosRequestConfig): Promise> { - return ApprovalFlowApiFp(configuration).apiApprovalFlowPagePost(body, options).then((request) => request(axios, basePath)); + async apiDataApprovalPagePost(body?: DataApprovalInput, options?: AxiosRequestConfig): Promise> { + return DataApprovalApiFp(configuration).apiDataApprovalPagePost(body, options).then((request) => request(axios, basePath)); }, /** * * @summary 更新审批流 - * @param {UpdateApprovalFlowInput} [body] + * @param {UpdateDataApprovalInput} [body] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async apiApprovalFlowUpdatePost(body?: UpdateApprovalFlowInput, options?: AxiosRequestConfig): Promise> { - return ApprovalFlowApiFp(configuration).apiApprovalFlowUpdatePost(body, options).then((request) => request(axios, basePath)); + async apiDataApprovalUpdatePost(body?: UpdateDataApprovalInput, options?: AxiosRequestConfig): Promise> { + return DataApprovalApiFp(configuration).apiDataApprovalUpdatePost(body, options).then((request) => request(axios, basePath)); }, }; }; /** - * ApprovalFlowApi - object-oriented interface + * DataApprovalApi - object-oriented interface * @export - * @class ApprovalFlowApi + * @class DataApprovalApi * @extends {BaseAPI} */ -export class ApprovalFlowApi extends BaseAPI { +export class DataApprovalApi extends BaseAPI { /** * * @summary 增加审批流 - * @param {AddApprovalFlowInput} [body] + * @param {AddDataApprovalInput} [body] * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof ApprovalFlowApi + * @memberof DataApprovalApi */ - public async apiApprovalFlowAddPost(body?: AddApprovalFlowInput, options?: AxiosRequestConfig) : Promise> { - return ApprovalFlowApiFp(this.configuration).apiApprovalFlowAddPost(body, options).then((request) => request(this.axios, this.basePath)); + public async apiDataApprovalAddPost(body?: AddDataApprovalInput, options?: AxiosRequestConfig) : Promise> { + return DataApprovalApiFp(this.configuration).apiDataApprovalAddPost(body, options).then((request) => request(this.axios, this.basePath)); } /** * * @summary 删除审批流 - * @param {DeleteApprovalFlowInput} [body] + * @param {DeleteDataApprovalInput} [body] * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof ApprovalFlowApi + * @memberof DataApprovalApi */ - public async apiApprovalFlowDeletePost(body?: DeleteApprovalFlowInput, options?: AxiosRequestConfig) : Promise> { - return ApprovalFlowApiFp(this.configuration).apiApprovalFlowDeletePost(body, options).then((request) => request(this.axios, this.basePath)); + public async apiDataApprovalDeletePost(body?: DeleteDataApprovalInput, options?: AxiosRequestConfig) : Promise> { + return DataApprovalApiFp(this.configuration).apiDataApprovalDeletePost(body, options).then((request) => request(this.axios, this.basePath)); } /** * @@ -842,10 +842,10 @@ export class ApprovalFlowApi extends BaseAPI { * @param {number} id 主键Id * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof ApprovalFlowApi + * @memberof DataApprovalApi */ - public async apiApprovalFlowDetailGet(id: number, options?: AxiosRequestConfig) : Promise> { - return ApprovalFlowApiFp(this.configuration).apiApprovalFlowDetailGet(id, options).then((request) => request(this.axios, this.basePath)); + public async apiDataApprovalDetailGet(id: number, options?: AxiosRequestConfig) : Promise> { + return DataApprovalApiFp(this.configuration).apiDataApprovalDetailGet(id, options).then((request) => request(this.axios, this.basePath)); } /** * @@ -853,20 +853,20 @@ export class ApprovalFlowApi extends BaseAPI { * @param {string} [code] * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof ApprovalFlowApi + * @memberof DataApprovalApi */ - public async apiApprovalFlowFlowListGet(code?: string, options?: AxiosRequestConfig) : Promise> { - return ApprovalFlowApiFp(this.configuration).apiApprovalFlowFlowListGet(code, options).then((request) => request(this.axios, this.basePath)); + public async apiDataApprovalFlowListGet(code?: string, options?: AxiosRequestConfig) : Promise> { + return DataApprovalApiFp(this.configuration).apiDataApprovalFlowListGet(code, options).then((request) => request(this.axios, this.basePath)); } /** * * @summary 获取审批流规则 * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof ApprovalFlowApi + * @memberof DataApprovalApi */ - public async apiApprovalFlowFormRoutesGet(options?: AxiosRequestConfig) : Promise> { - return ApprovalFlowApiFp(this.configuration).apiApprovalFlowFormRoutesGet(options).then((request) => request(this.axios, this.basePath)); + public async apiDataApprovalFormRoutesGet(options?: AxiosRequestConfig) : Promise> { + return DataApprovalApiFp(this.configuration).apiDataApprovalFormRoutesGet(options).then((request) => request(this.axios, this.basePath)); } /** * @@ -874,10 +874,10 @@ export class ApprovalFlowApi extends BaseAPI { * @param {string} [code] * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof ApprovalFlowApi + * @memberof DataApprovalApi */ - public async apiApprovalFlowInfoGet(code?: string, options?: AxiosRequestConfig) : Promise> { - return ApprovalFlowApiFp(this.configuration).apiApprovalFlowInfoGet(code, options).then((request) => request(this.axios, this.basePath)); + public async apiDataApprovalInfoGet(code?: string, options?: AxiosRequestConfig) : Promise> { + return DataApprovalApiFp(this.configuration).apiDataApprovalInfoGet(code, options).then((request) => request(this.axios, this.basePath)); } /** * @@ -900,31 +900,31 @@ export class ApprovalFlowApi extends BaseAPI { * @param {any} [filterValue] 字段值 * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof ApprovalFlowApi + * @memberof DataApprovalApi */ - public async apiApprovalFlowListGet(code?: string, name?: string, remark?: string, page?: number, pageSize?: number, field?: string, order?: string, descStr?: string, searchFields?: Array, searchKeyword?: string, keyword?: string, filterLogic?: FilterLogicEnum, filterFilters?: Array, filterField?: string, filterOperator?: FilterOperatorEnum, filterValue?: any, options?: AxiosRequestConfig) : Promise> { - return ApprovalFlowApiFp(this.configuration).apiApprovalFlowListGet(code, name, remark, page, pageSize, field, order, descStr, searchFields, searchKeyword, keyword, filterLogic, filterFilters, filterField, filterOperator, filterValue, options).then((request) => request(this.axios, this.basePath)); + public async apiDataApprovalListGet(code?: string, name?: string, remark?: string, page?: number, pageSize?: number, field?: string, order?: string, descStr?: string, searchFields?: Array, searchKeyword?: string, keyword?: string, filterLogic?: FilterLogicEnum, filterFilters?: Array, filterField?: string, filterOperator?: FilterOperatorEnum, filterValue?: any, options?: AxiosRequestConfig) : Promise> { + return DataApprovalApiFp(this.configuration).apiDataApprovalListGet(code, name, remark, page, pageSize, field, order, descStr, searchFields, searchKeyword, keyword, filterLogic, filterFilters, filterField, filterOperator, filterValue, options).then((request) => request(this.axios, this.basePath)); } /** * * @summary 分页查询审批流 - * @param {ApprovalFlowInput} [body] + * @param {DataApprovalInput} [body] * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof ApprovalFlowApi + * @memberof DataApprovalApi */ - public async apiApprovalFlowPagePost(body?: ApprovalFlowInput, options?: AxiosRequestConfig) : Promise> { - return ApprovalFlowApiFp(this.configuration).apiApprovalFlowPagePost(body, options).then((request) => request(this.axios, this.basePath)); + public async apiDataApprovalPagePost(body?: DataApprovalInput, options?: AxiosRequestConfig) : Promise> { + return DataApprovalApiFp(this.configuration).apiDataApprovalPagePost(body, options).then((request) => request(this.axios, this.basePath)); } /** * * @summary 更新审批流 - * @param {UpdateApprovalFlowInput} [body] + * @param {UpdateDataApprovalInput} [body] * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof ApprovalFlowApi + * @memberof DataApprovalApi */ - public async apiApprovalFlowUpdatePost(body?: UpdateApprovalFlowInput, options?: AxiosRequestConfig) : Promise> { - return ApprovalFlowApiFp(this.configuration).apiApprovalFlowUpdatePost(body, options).then((request) => request(this.axios, this.basePath)); + public async apiDataApprovalUpdatePost(body?: UpdateDataApprovalInput, options?: AxiosRequestConfig) : Promise> { + return DataApprovalApiFp(this.configuration).apiDataApprovalUpdatePost(body, options).then((request) => request(this.axios, this.basePath)); } } diff --git a/Web/src/api-services/dataApproval/base.ts b/Web/src/api-services/dataApproval/base.ts index b22cbf34..5c0ca6e9 100644 --- a/Web/src/api-services/dataApproval/base.ts +++ b/Web/src/api-services/dataApproval/base.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * diff --git a/Web/src/api-services/dataApproval/configuration.ts b/Web/src/api-services/dataApproval/configuration.ts index 7660b245..d4ef1f19 100644 --- a/Web/src/api-services/dataApproval/configuration.ts +++ b/Web/src/api-services/dataApproval/configuration.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * diff --git a/Web/src/api-services/dataApproval/index.ts b/Web/src/api-services/dataApproval/index.ts index 94bfa3ed..b08ac221 100644 --- a/Web/src/api-services/dataApproval/index.ts +++ b/Web/src/api-services/dataApproval/index.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * diff --git a/Web/src/api-services/dataApproval/models/add-approval-flow-input.ts b/Web/src/api-services/dataApproval/models/add-data-approval-input.ts similarity index 62% rename from Web/src/api-services/dataApproval/models/add-approval-flow-input.ts rename to Web/src/api-services/dataApproval/models/add-data-approval-input.ts index 93b3f423..bee0fa75 100644 --- a/Web/src/api-services/dataApproval/models/add-approval-flow-input.ts +++ b/Web/src/api-services/dataApproval/models/add-data-approval-input.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * @@ -16,15 +16,15 @@ * 审批流增加输入参数 * * @export - * @interface AddApprovalFlowInput + * @interface AddDataApprovalInput */ -export interface AddApprovalFlowInput { +export interface AddDataApprovalInput { /** * 编号 * * @type {string} - * @memberof AddApprovalFlowInput + * @memberof AddDataApprovalInput */ code?: string | null; @@ -32,7 +32,7 @@ export interface AddApprovalFlowInput { * 名称 * * @type {string} - * @memberof AddApprovalFlowInput + * @memberof AddDataApprovalInput */ name?: string | null; @@ -40,7 +40,7 @@ export interface AddApprovalFlowInput { * 表单 * * @type {string} - * @memberof AddApprovalFlowInput + * @memberof AddDataApprovalInput */ formJson?: string | null; @@ -48,7 +48,7 @@ export interface AddApprovalFlowInput { * 流程 * * @type {string} - * @memberof AddApprovalFlowInput + * @memberof AddDataApprovalInput */ flowJson?: string | null; @@ -56,7 +56,7 @@ export interface AddApprovalFlowInput { * 备注 * * @type {string} - * @memberof AddApprovalFlowInput + * @memberof AddDataApprovalInput */ remark?: string | null; @@ -64,7 +64,7 @@ export interface AddApprovalFlowInput { * 创建时间 * * @type {Date} - * @memberof AddApprovalFlowInput + * @memberof AddDataApprovalInput */ createTime?: Date | null; @@ -72,7 +72,7 @@ export interface AddApprovalFlowInput { * 更新时间 * * @type {Date} - * @memberof AddApprovalFlowInput + * @memberof AddDataApprovalInput */ updateTime?: Date | null; @@ -80,7 +80,7 @@ export interface AddApprovalFlowInput { * 创建者Id * * @type {number} - * @memberof AddApprovalFlowInput + * @memberof AddDataApprovalInput */ createUserId?: number | null; @@ -88,7 +88,7 @@ export interface AddApprovalFlowInput { * 创建者姓名 * * @type {string} - * @memberof AddApprovalFlowInput + * @memberof AddDataApprovalInput */ createUserName?: string | null; @@ -96,7 +96,7 @@ export interface AddApprovalFlowInput { * 修改者Id * * @type {number} - * @memberof AddApprovalFlowInput + * @memberof AddDataApprovalInput */ updateUserId?: number | null; @@ -104,7 +104,7 @@ export interface AddApprovalFlowInput { * 修改者姓名 * * @type {string} - * @memberof AddApprovalFlowInput + * @memberof AddDataApprovalInput */ updateUserName?: string | null; @@ -112,7 +112,7 @@ export interface AddApprovalFlowInput { * 创建者部门Id * * @type {number} - * @memberof AddApprovalFlowInput + * @memberof AddDataApprovalInput */ createOrgId?: number | null; @@ -120,7 +120,7 @@ export interface AddApprovalFlowInput { * 创建者部门名称 * * @type {string} - * @memberof AddApprovalFlowInput + * @memberof AddDataApprovalInput */ createOrgName?: string | null; @@ -128,7 +128,7 @@ export interface AddApprovalFlowInput { * 软删除 * * @type {boolean} - * @memberof AddApprovalFlowInput + * @memberof AddDataApprovalInput */ isDelete: boolean; } diff --git a/Web/src/api-services/dataApproval/models/admin-netresult-data-approval.ts b/Web/src/api-services/dataApproval/models/admin-netresult-data-approval.ts new file mode 100644 index 00000000..605a025a --- /dev/null +++ b/Web/src/api-services/dataApproval/models/admin-netresult-data-approval.ts @@ -0,0 +1,69 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import { DataApproval } from './data-approval'; + /** + * 全局返回结果 + * + * @export + * @interface AdminNETResultDataApproval + */ +export interface AdminNETResultDataApproval { + + /** + * 状态码 + * + * @type {number} + * @memberof AdminNETResultDataApproval + */ + code?: number; + + /** + * 类型success、warning、error + * + * @type {string} + * @memberof AdminNETResultDataApproval + */ + type?: string | null; + + /** + * 错误信息 + * + * @type {string} + * @memberof AdminNETResultDataApproval + */ + message?: string | null; + + /** + * @type {DataApproval} + * @memberof AdminNETResultDataApproval + */ + result?: DataApproval; + + /** + * 附加数据 + * + * @type {any} + * @memberof AdminNETResultDataApproval + */ + extras?: any | null; + + /** + * 时间 + * + * @type {Date} + * @memberof AdminNETResultDataApproval + */ + time?: Date; +} diff --git a/Web/src/api-services/dataApproval/models/admin-result-int64.ts b/Web/src/api-services/dataApproval/models/admin-netresult-int64.ts similarity index 56% rename from Web/src/api-services/dataApproval/models/admin-result-int64.ts rename to Web/src/api-services/dataApproval/models/admin-netresult-int64.ts index 9397ba04..22e10542 100644 --- a/Web/src/api-services/dataApproval/models/admin-result-int64.ts +++ b/Web/src/api-services/dataApproval/models/admin-netresult-int64.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * @@ -16,15 +16,15 @@ * 全局返回结果 * * @export - * @interface AdminResultInt64 + * @interface AdminNETResultInt64 */ -export interface AdminResultInt64 { +export interface AdminNETResultInt64 { /** * 状态码 * * @type {number} - * @memberof AdminResultInt64 + * @memberof AdminNETResultInt64 */ code?: number; @@ -32,7 +32,7 @@ export interface AdminResultInt64 { * 类型success、warning、error * * @type {string} - * @memberof AdminResultInt64 + * @memberof AdminNETResultInt64 */ type?: string | null; @@ -40,7 +40,7 @@ export interface AdminResultInt64 { * 错误信息 * * @type {string} - * @memberof AdminResultInt64 + * @memberof AdminNETResultInt64 */ message?: string | null; @@ -48,7 +48,7 @@ export interface AdminResultInt64 { * 数据 * * @type {number} - * @memberof AdminResultInt64 + * @memberof AdminNETResultInt64 */ result?: number; @@ -56,7 +56,7 @@ export interface AdminResultInt64 { * 附加数据 * * @type {any} - * @memberof AdminResultInt64 + * @memberof AdminNETResultInt64 */ extras?: any | null; @@ -64,7 +64,7 @@ export interface AdminResultInt64 { * 时间 * * @type {Date} - * @memberof AdminResultInt64 + * @memberof AdminNETResultInt64 */ time?: Date; } diff --git a/Web/src/api-services/dataApproval/models/admin-netresult-list-data-approval-output.ts b/Web/src/api-services/dataApproval/models/admin-netresult-list-data-approval-output.ts new file mode 100644 index 00000000..1a565520 --- /dev/null +++ b/Web/src/api-services/dataApproval/models/admin-netresult-list-data-approval-output.ts @@ -0,0 +1,71 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import { DataApprovalOutput } from './data-approval-output'; + /** + * 全局返回结果 + * + * @export + * @interface AdminNETResultListDataApprovalOutput + */ +export interface AdminNETResultListDataApprovalOutput { + + /** + * 状态码 + * + * @type {number} + * @memberof AdminNETResultListDataApprovalOutput + */ + code?: number; + + /** + * 类型success、warning、error + * + * @type {string} + * @memberof AdminNETResultListDataApprovalOutput + */ + type?: string | null; + + /** + * 错误信息 + * + * @type {string} + * @memberof AdminNETResultListDataApprovalOutput + */ + message?: string | null; + + /** + * 数据 + * + * @type {Array} + * @memberof AdminNETResultListDataApprovalOutput + */ + result?: Array | null; + + /** + * 附加数据 + * + * @type {any} + * @memberof AdminNETResultListDataApprovalOutput + */ + extras?: any | null; + + /** + * 时间 + * + * @type {Date} + * @memberof AdminNETResultListDataApprovalOutput + */ + time?: Date; +} diff --git a/Web/src/api-services/dataApproval/models/admin-result-list-string.ts b/Web/src/api-services/dataApproval/models/admin-netresult-list-string.ts similarity index 56% rename from Web/src/api-services/dataApproval/models/admin-result-list-string.ts rename to Web/src/api-services/dataApproval/models/admin-netresult-list-string.ts index 31d50118..52cfbac8 100644 --- a/Web/src/api-services/dataApproval/models/admin-result-list-string.ts +++ b/Web/src/api-services/dataApproval/models/admin-netresult-list-string.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * @@ -16,15 +16,15 @@ * 全局返回结果 * * @export - * @interface AdminResultListString + * @interface AdminNETResultListString */ -export interface AdminResultListString { +export interface AdminNETResultListString { /** * 状态码 * * @type {number} - * @memberof AdminResultListString + * @memberof AdminNETResultListString */ code?: number; @@ -32,7 +32,7 @@ export interface AdminResultListString { * 类型success、warning、error * * @type {string} - * @memberof AdminResultListString + * @memberof AdminNETResultListString */ type?: string | null; @@ -40,7 +40,7 @@ export interface AdminResultListString { * 错误信息 * * @type {string} - * @memberof AdminResultListString + * @memberof AdminNETResultListString */ message?: string | null; @@ -48,7 +48,7 @@ export interface AdminResultListString { * 数据 * * @type {Array} - * @memberof AdminResultListString + * @memberof AdminNETResultListString */ result?: Array | null; @@ -56,7 +56,7 @@ export interface AdminResultListString { * 附加数据 * * @type {any} - * @memberof AdminResultListString + * @memberof AdminNETResultListString */ extras?: any | null; @@ -64,7 +64,7 @@ export interface AdminResultListString { * 时间 * * @type {Date} - * @memberof AdminResultListString + * @memberof AdminNETResultListString */ time?: Date; } diff --git a/Web/src/api-services/dataApproval/models/admin-result-object.ts b/Web/src/api-services/dataApproval/models/admin-netresult-object.ts similarity index 56% rename from Web/src/api-services/dataApproval/models/admin-result-object.ts rename to Web/src/api-services/dataApproval/models/admin-netresult-object.ts index 688d0d2a..bbb759c2 100644 --- a/Web/src/api-services/dataApproval/models/admin-result-object.ts +++ b/Web/src/api-services/dataApproval/models/admin-netresult-object.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * @@ -16,15 +16,15 @@ * 全局返回结果 * * @export - * @interface AdminResultObject + * @interface AdminNETResultObject */ -export interface AdminResultObject { +export interface AdminNETResultObject { /** * 状态码 * * @type {number} - * @memberof AdminResultObject + * @memberof AdminNETResultObject */ code?: number; @@ -32,7 +32,7 @@ export interface AdminResultObject { * 类型success、warning、error * * @type {string} - * @memberof AdminResultObject + * @memberof AdminNETResultObject */ type?: string | null; @@ -40,7 +40,7 @@ export interface AdminResultObject { * 错误信息 * * @type {string} - * @memberof AdminResultObject + * @memberof AdminNETResultObject */ message?: string | null; @@ -48,7 +48,7 @@ export interface AdminResultObject { * 数据 * * @type {any} - * @memberof AdminResultObject + * @memberof AdminNETResultObject */ result?: any | null; @@ -56,7 +56,7 @@ export interface AdminResultObject { * 附加数据 * * @type {any} - * @memberof AdminResultObject + * @memberof AdminNETResultObject */ extras?: any | null; @@ -64,7 +64,7 @@ export interface AdminResultObject { * 时间 * * @type {Date} - * @memberof AdminResultObject + * @memberof AdminNETResultObject */ time?: Date; } diff --git a/Web/src/api-services/dataApproval/models/admin-netresult-sql-sugar-paged-list-data-approval-output.ts b/Web/src/api-services/dataApproval/models/admin-netresult-sql-sugar-paged-list-data-approval-output.ts new file mode 100644 index 00000000..c87d7e08 --- /dev/null +++ b/Web/src/api-services/dataApproval/models/admin-netresult-sql-sugar-paged-list-data-approval-output.ts @@ -0,0 +1,69 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import { SqlSugarPagedListDataApprovalOutput } from './sql-sugar-paged-list-data-approval-output'; + /** + * 全局返回结果 + * + * @export + * @interface AdminNETResultSqlSugarPagedListDataApprovalOutput + */ +export interface AdminNETResultSqlSugarPagedListDataApprovalOutput { + + /** + * 状态码 + * + * @type {number} + * @memberof AdminNETResultSqlSugarPagedListDataApprovalOutput + */ + code?: number; + + /** + * 类型success、warning、error + * + * @type {string} + * @memberof AdminNETResultSqlSugarPagedListDataApprovalOutput + */ + type?: string | null; + + /** + * 错误信息 + * + * @type {string} + * @memberof AdminNETResultSqlSugarPagedListDataApprovalOutput + */ + message?: string | null; + + /** + * @type {SqlSugarPagedListDataApprovalOutput} + * @memberof AdminNETResultSqlSugarPagedListDataApprovalOutput + */ + result?: SqlSugarPagedListDataApprovalOutput; + + /** + * 附加数据 + * + * @type {any} + * @memberof AdminNETResultSqlSugarPagedListDataApprovalOutput + */ + extras?: any | null; + + /** + * 时间 + * + * @type {Date} + * @memberof AdminNETResultSqlSugarPagedListDataApprovalOutput + */ + time?: Date; +} diff --git a/Web/src/api-services/dataApproval/models/admin-result-approval-flow.ts b/Web/src/api-services/dataApproval/models/admin-result-approval-flow.ts deleted file mode 100644 index 0588c7e3..00000000 --- a/Web/src/api-services/dataApproval/models/admin-result-approval-flow.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - * - * OpenAPI spec version: 1.0.0 - * - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -import { ApprovalFlow } from './approval-flow'; - /** - * 全局返回结果 - * - * @export - * @interface AdminResultApprovalFlow - */ -export interface AdminResultApprovalFlow { - - /** - * 状态码 - * - * @type {number} - * @memberof AdminResultApprovalFlow - */ - code?: number; - - /** - * 类型success、warning、error - * - * @type {string} - * @memberof AdminResultApprovalFlow - */ - type?: string | null; - - /** - * 错误信息 - * - * @type {string} - * @memberof AdminResultApprovalFlow - */ - message?: string | null; - - /** - * @type {ApprovalFlow} - * @memberof AdminResultApprovalFlow - */ - result?: ApprovalFlow; - - /** - * 附加数据 - * - * @type {any} - * @memberof AdminResultApprovalFlow - */ - extras?: any | null; - - /** - * 时间 - * - * @type {Date} - * @memberof AdminResultApprovalFlow - */ - time?: Date; -} diff --git a/Web/src/api-services/dataApproval/models/admin-result-list-approval-flow-output.ts b/Web/src/api-services/dataApproval/models/admin-result-list-approval-flow-output.ts deleted file mode 100644 index 1c5cc8de..00000000 --- a/Web/src/api-services/dataApproval/models/admin-result-list-approval-flow-output.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - * - * OpenAPI spec version: 1.0.0 - * - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -import { ApprovalFlowOutput } from './approval-flow-output'; - /** - * 全局返回结果 - * - * @export - * @interface AdminResultListApprovalFlowOutput - */ -export interface AdminResultListApprovalFlowOutput { - - /** - * 状态码 - * - * @type {number} - * @memberof AdminResultListApprovalFlowOutput - */ - code?: number; - - /** - * 类型success、warning、error - * - * @type {string} - * @memberof AdminResultListApprovalFlowOutput - */ - type?: string | null; - - /** - * 错误信息 - * - * @type {string} - * @memberof AdminResultListApprovalFlowOutput - */ - message?: string | null; - - /** - * 数据 - * - * @type {Array} - * @memberof AdminResultListApprovalFlowOutput - */ - result?: Array | null; - - /** - * 附加数据 - * - * @type {any} - * @memberof AdminResultListApprovalFlowOutput - */ - extras?: any | null; - - /** - * 时间 - * - * @type {Date} - * @memberof AdminResultListApprovalFlowOutput - */ - time?: Date; -} diff --git a/Web/src/api-services/dataApproval/models/admin-result-sql-sugar-paged-list-approval-flow-output.ts b/Web/src/api-services/dataApproval/models/admin-result-sql-sugar-paged-list-approval-flow-output.ts deleted file mode 100644 index 72a81e90..00000000 --- a/Web/src/api-services/dataApproval/models/admin-result-sql-sugar-paged-list-approval-flow-output.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - * - * OpenAPI spec version: 1.0.0 - * - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -import { SqlSugarPagedListApprovalFlowOutput } from './sql-sugar-paged-list-approval-flow-output'; - /** - * 全局返回结果 - * - * @export - * @interface AdminResultSqlSugarPagedListApprovalFlowOutput - */ -export interface AdminResultSqlSugarPagedListApprovalFlowOutput { - - /** - * 状态码 - * - * @type {number} - * @memberof AdminResultSqlSugarPagedListApprovalFlowOutput - */ - code?: number; - - /** - * 类型success、warning、error - * - * @type {string} - * @memberof AdminResultSqlSugarPagedListApprovalFlowOutput - */ - type?: string | null; - - /** - * 错误信息 - * - * @type {string} - * @memberof AdminResultSqlSugarPagedListApprovalFlowOutput - */ - message?: string | null; - - /** - * @type {SqlSugarPagedListApprovalFlowOutput} - * @memberof AdminResultSqlSugarPagedListApprovalFlowOutput - */ - result?: SqlSugarPagedListApprovalFlowOutput; - - /** - * 附加数据 - * - * @type {any} - * @memberof AdminResultSqlSugarPagedListApprovalFlowOutput - */ - extras?: any | null; - - /** - * 时间 - * - * @type {Date} - * @memberof AdminResultSqlSugarPagedListApprovalFlowOutput - */ - time?: Date; -} diff --git a/Web/src/api-services/dataApproval/models/approval-flow-input.ts b/Web/src/api-services/dataApproval/models/data-approval-input.ts similarity index 61% rename from Web/src/api-services/dataApproval/models/approval-flow-input.ts rename to Web/src/api-services/dataApproval/models/data-approval-input.ts index f2275e9e..38a5cc07 100644 --- a/Web/src/api-services/dataApproval/models/approval-flow-input.ts +++ b/Web/src/api-services/dataApproval/models/data-approval-input.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * @@ -18,13 +18,13 @@ import { Search } from './search'; * 审批流分页查询输入参数 * * @export - * @interface ApprovalFlowInput + * @interface DataApprovalInput */ -export interface ApprovalFlowInput { +export interface DataApprovalInput { /** * @type {Search} - * @memberof ApprovalFlowInput + * @memberof DataApprovalInput */ search?: Search; @@ -32,13 +32,13 @@ export interface ApprovalFlowInput { * 模糊查询关键字 * * @type {string} - * @memberof ApprovalFlowInput + * @memberof DataApprovalInput */ keyword?: string | null; /** * @type {Filter} - * @memberof ApprovalFlowInput + * @memberof DataApprovalInput */ filter?: Filter; @@ -46,7 +46,7 @@ export interface ApprovalFlowInput { * 当前页码 * * @type {number} - * @memberof ApprovalFlowInput + * @memberof DataApprovalInput */ page?: number; @@ -54,7 +54,7 @@ export interface ApprovalFlowInput { * 页码容量 * * @type {number} - * @memberof ApprovalFlowInput + * @memberof DataApprovalInput */ pageSize?: number; @@ -62,7 +62,7 @@ export interface ApprovalFlowInput { * 排序字段 * * @type {string} - * @memberof ApprovalFlowInput + * @memberof DataApprovalInput */ field?: string | null; @@ -70,7 +70,7 @@ export interface ApprovalFlowInput { * 排序方向 * * @type {string} - * @memberof ApprovalFlowInput + * @memberof DataApprovalInput */ order?: string | null; @@ -78,7 +78,7 @@ export interface ApprovalFlowInput { * 降序排序 * * @type {string} - * @memberof ApprovalFlowInput + * @memberof DataApprovalInput */ descStr?: string | null; @@ -86,7 +86,7 @@ export interface ApprovalFlowInput { * 编号 * * @type {string} - * @memberof ApprovalFlowInput + * @memberof DataApprovalInput */ code?: string | null; @@ -94,7 +94,7 @@ export interface ApprovalFlowInput { * 名称 * * @type {string} - * @memberof ApprovalFlowInput + * @memberof DataApprovalInput */ name?: string | null; @@ -102,7 +102,7 @@ export interface ApprovalFlowInput { * 备注 * * @type {string} - * @memberof ApprovalFlowInput + * @memberof DataApprovalInput */ remark?: string | null; } diff --git a/Web/src/api-services/dataApproval/models/approval-flow-output.ts b/Web/src/api-services/dataApproval/models/data-approval-output.ts similarity index 63% rename from Web/src/api-services/dataApproval/models/approval-flow-output.ts rename to Web/src/api-services/dataApproval/models/data-approval-output.ts index 28bd0bbb..8a2e6b24 100644 --- a/Web/src/api-services/dataApproval/models/approval-flow-output.ts +++ b/Web/src/api-services/dataApproval/models/data-approval-output.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * @@ -16,15 +16,15 @@ * 审批流输出参数 * * @export - * @interface ApprovalFlowOutput + * @interface DataApprovalOutput */ -export interface ApprovalFlowOutput { +export interface DataApprovalOutput { /** * 主键Id * * @type {number} - * @memberof ApprovalFlowOutput + * @memberof DataApprovalOutput */ id?: number; @@ -32,7 +32,7 @@ export interface ApprovalFlowOutput { * 编号 * * @type {string} - * @memberof ApprovalFlowOutput + * @memberof DataApprovalOutput */ code?: string | null; @@ -40,7 +40,7 @@ export interface ApprovalFlowOutput { * 名称 * * @type {string} - * @memberof ApprovalFlowOutput + * @memberof DataApprovalOutput */ name?: string | null; @@ -48,7 +48,7 @@ export interface ApprovalFlowOutput { * 表单 * * @type {string} - * @memberof ApprovalFlowOutput + * @memberof DataApprovalOutput */ formJson?: string | null; @@ -56,7 +56,7 @@ export interface ApprovalFlowOutput { * 流程 * * @type {string} - * @memberof ApprovalFlowOutput + * @memberof DataApprovalOutput */ flowJson?: string | null; @@ -64,7 +64,7 @@ export interface ApprovalFlowOutput { * 备注 * * @type {string} - * @memberof ApprovalFlowOutput + * @memberof DataApprovalOutput */ remark?: string | null; @@ -72,7 +72,7 @@ export interface ApprovalFlowOutput { * 创建时间 * * @type {Date} - * @memberof ApprovalFlowOutput + * @memberof DataApprovalOutput */ createTime?: Date | null; @@ -80,7 +80,7 @@ export interface ApprovalFlowOutput { * 更新时间 * * @type {Date} - * @memberof ApprovalFlowOutput + * @memberof DataApprovalOutput */ updateTime?: Date | null; @@ -88,7 +88,7 @@ export interface ApprovalFlowOutput { * 创建者Id * * @type {number} - * @memberof ApprovalFlowOutput + * @memberof DataApprovalOutput */ createUserId?: number | null; @@ -96,7 +96,7 @@ export interface ApprovalFlowOutput { * 创建者姓名 * * @type {string} - * @memberof ApprovalFlowOutput + * @memberof DataApprovalOutput */ createUserName?: string | null; @@ -104,7 +104,7 @@ export interface ApprovalFlowOutput { * 修改者Id * * @type {number} - * @memberof ApprovalFlowOutput + * @memberof DataApprovalOutput */ updateUserId?: number | null; @@ -112,7 +112,7 @@ export interface ApprovalFlowOutput { * 修改者姓名 * * @type {string} - * @memberof ApprovalFlowOutput + * @memberof DataApprovalOutput */ updateUserName?: string | null; @@ -120,7 +120,7 @@ export interface ApprovalFlowOutput { * 创建者部门Id * * @type {number} - * @memberof ApprovalFlowOutput + * @memberof DataApprovalOutput */ createOrgId?: number | null; @@ -128,7 +128,7 @@ export interface ApprovalFlowOutput { * 创建者部门名称 * * @type {string} - * @memberof ApprovalFlowOutput + * @memberof DataApprovalOutput */ createOrgName?: string | null; @@ -136,7 +136,7 @@ export interface ApprovalFlowOutput { * 软删除 * * @type {boolean} - * @memberof ApprovalFlowOutput + * @memberof DataApprovalOutput */ isDelete?: boolean; } diff --git a/Web/src/api-services/dataApproval/models/approval-flow.ts b/Web/src/api-services/dataApproval/models/data-approval.ts similarity index 63% rename from Web/src/api-services/dataApproval/models/approval-flow.ts rename to Web/src/api-services/dataApproval/models/data-approval.ts index 3eb53cb3..b1bcfc58 100644 --- a/Web/src/api-services/dataApproval/models/approval-flow.ts +++ b/Web/src/api-services/dataApproval/models/data-approval.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * @@ -13,18 +13,18 @@ */ /** - * 审批流程信息表 + * 数据审批信息表 * * @export - * @interface ApprovalFlow + * @interface DataApproval */ -export interface ApprovalFlow { +export interface DataApproval { /** * 雪花Id * * @type {number} - * @memberof ApprovalFlow + * @memberof DataApproval */ id?: number; @@ -32,7 +32,7 @@ export interface ApprovalFlow { * 创建时间 * * @type {Date} - * @memberof ApprovalFlow + * @memberof DataApproval */ createTime?: Date; @@ -40,7 +40,7 @@ export interface ApprovalFlow { * 更新时间 * * @type {Date} - * @memberof ApprovalFlow + * @memberof DataApproval */ updateTime?: Date | null; @@ -48,7 +48,7 @@ export interface ApprovalFlow { * 创建者Id * * @type {number} - * @memberof ApprovalFlow + * @memberof DataApproval */ createUserId?: number | null; @@ -56,7 +56,7 @@ export interface ApprovalFlow { * 创建者姓名 * * @type {string} - * @memberof ApprovalFlow + * @memberof DataApproval */ createUserName?: string | null; @@ -64,7 +64,7 @@ export interface ApprovalFlow { * 修改者Id * * @type {number} - * @memberof ApprovalFlow + * @memberof DataApproval */ updateUserId?: number | null; @@ -72,7 +72,7 @@ export interface ApprovalFlow { * 修改者姓名 * * @type {string} - * @memberof ApprovalFlow + * @memberof DataApproval */ updateUserName?: string | null; @@ -80,23 +80,23 @@ export interface ApprovalFlow { * 软删除 * * @type {boolean} - * @memberof ApprovalFlow + * @memberof DataApproval */ isDelete?: boolean; /** - * 创建者部门Id + * 创建者机构Id * * @type {number} - * @memberof ApprovalFlow + * @memberof DataApproval */ createOrgId?: number | null; /** - * 创建者部门名称 + * 创建者机构名称 * * @type {string} - * @memberof ApprovalFlow + * @memberof DataApproval */ createOrgName?: string | null; @@ -104,7 +104,7 @@ export interface ApprovalFlow { * 编号 * * @type {string} - * @memberof ApprovalFlow + * @memberof DataApproval */ code?: string | null; @@ -112,7 +112,7 @@ export interface ApprovalFlow { * 名称 * * @type {string} - * @memberof ApprovalFlow + * @memberof DataApproval */ name?: string | null; @@ -120,7 +120,7 @@ export interface ApprovalFlow { * 表单 * * @type {string} - * @memberof ApprovalFlow + * @memberof DataApproval */ formJson?: string | null; @@ -128,7 +128,7 @@ export interface ApprovalFlow { * 流程 * * @type {string} - * @memberof ApprovalFlow + * @memberof DataApproval */ flowJson?: string | null; @@ -136,7 +136,7 @@ export interface ApprovalFlow { * 状态 * * @type {number} - * @memberof ApprovalFlow + * @memberof DataApproval */ status?: number | null; @@ -144,7 +144,7 @@ export interface ApprovalFlow { * 备注 * * @type {string} - * @memberof ApprovalFlow + * @memberof DataApproval */ remark?: string | null; } diff --git a/Web/src/api-services/dataApproval/models/delete-approval-flow-input.ts b/Web/src/api-services/dataApproval/models/delete-approval-flow-input.ts deleted file mode 100644 index 54e6e4bf..00000000 --- a/Web/src/api-services/dataApproval/models/delete-approval-flow-input.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - * - * OpenAPI spec version: 1.0.0 - * - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - /** - * 审批流删除输入参数 - * - * @export - * @interface DeleteApprovalFlowInput - */ -export interface DeleteApprovalFlowInput { - - /** - * 主键Id - * - * @type {number} - * @memberof DeleteApprovalFlowInput - */ - id: number; -} diff --git a/Web/src/api-services/dataApproval/models/delete-data-approval-input.ts b/Web/src/api-services/dataApproval/models/delete-data-approval-input.ts new file mode 100644 index 00000000..4b375c81 --- /dev/null +++ b/Web/src/api-services/dataApproval/models/delete-data-approval-input.ts @@ -0,0 +1,30 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + /** + * 审批流删除输入参数 + * + * @export + * @interface DeleteDataApprovalInput + */ +export interface DeleteDataApprovalInput { + + /** + * 主键Id + * + * @type {number} + * @memberof DeleteDataApprovalInput + */ + id: number; +} diff --git a/Web/src/api-services/dataApproval/models/filter-logic-enum.ts b/Web/src/api-services/dataApproval/models/filter-logic-enum.ts index 9ba294de..af87b177 100644 --- a/Web/src/api-services/dataApproval/models/filter-logic-enum.ts +++ b/Web/src/api-services/dataApproval/models/filter-logic-enum.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * diff --git a/Web/src/api-services/dataApproval/models/filter-operator-enum.ts b/Web/src/api-services/dataApproval/models/filter-operator-enum.ts index dc78a6e9..a8014736 100644 --- a/Web/src/api-services/dataApproval/models/filter-operator-enum.ts +++ b/Web/src/api-services/dataApproval/models/filter-operator-enum.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * diff --git a/Web/src/api-services/dataApproval/models/filter.ts b/Web/src/api-services/dataApproval/models/filter.ts index b5cebb19..6ee232f0 100644 --- a/Web/src/api-services/dataApproval/models/filter.ts +++ b/Web/src/api-services/dataApproval/models/filter.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * @@ -34,6 +34,7 @@ export interface Filter { * * @type {Array} * @memberof Filter + * @example [] */ filters?: Array | null; diff --git a/Web/src/api-services/dataApproval/models/index.ts b/Web/src/api-services/dataApproval/models/index.ts index 62728819..ca5280d0 100644 --- a/Web/src/api-services/dataApproval/models/index.ts +++ b/Web/src/api-services/dataApproval/models/index.ts @@ -1,17 +1,17 @@ -export * from './add-approval-flow-input'; -export * from './admin-result-approval-flow'; -export * from './admin-result-int64'; -export * from './admin-result-list-approval-flow-output'; -export * from './admin-result-list-string'; -export * from './admin-result-object'; -export * from './admin-result-sql-sugar-paged-list-approval-flow-output'; -export * from './approval-flow'; -export * from './approval-flow-input'; -export * from './approval-flow-output'; -export * from './delete-approval-flow-input'; +export * from './add-data-approval-input'; +export * from './admin-netresult-data-approval'; +export * from './admin-netresult-int64'; +export * from './admin-netresult-list-data-approval-output'; +export * from './admin-netresult-list-string'; +export * from './admin-netresult-object'; +export * from './admin-netresult-sql-sugar-paged-list-data-approval-output'; +export * from './data-approval'; +export * from './data-approval-input'; +export * from './data-approval-output'; +export * from './delete-data-approval-input'; export * from './filter'; export * from './filter-logic-enum'; export * from './filter-operator-enum'; export * from './search'; -export * from './sql-sugar-paged-list-approval-flow-output'; -export * from './update-approval-flow-input'; +export * from './sql-sugar-paged-list-data-approval-output'; +export * from './update-data-approval-input'; diff --git a/Web/src/api-services/dataApproval/models/search.ts b/Web/src/api-services/dataApproval/models/search.ts index acd0a5cf..e0dc29d4 100644 --- a/Web/src/api-services/dataApproval/models/search.ts +++ b/Web/src/api-services/dataApproval/models/search.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * @@ -25,6 +25,7 @@ export interface Search { * * @type {Array} * @memberof Search + * @example [] */ fields?: Array | null; diff --git a/Web/src/api-services/dataApproval/models/sql-sugar-paged-list-approval-flow-output.ts b/Web/src/api-services/dataApproval/models/sql-sugar-paged-list-approval-flow-output.ts deleted file mode 100644 index c830131d..00000000 --- a/Web/src/api-services/dataApproval/models/sql-sugar-paged-list-approval-flow-output.ts +++ /dev/null @@ -1,79 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - * - * OpenAPI spec version: 1.0.0 - * - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -import { ApprovalFlowOutput } from './approval-flow-output'; - /** - * 分页泛型集合 - * - * @export - * @interface SqlSugarPagedListApprovalFlowOutput - */ -export interface SqlSugarPagedListApprovalFlowOutput { - - /** - * 页码 - * - * @type {number} - * @memberof SqlSugarPagedListApprovalFlowOutput - */ - page?: number; - - /** - * 页容量 - * - * @type {number} - * @memberof SqlSugarPagedListApprovalFlowOutput - */ - pageSize?: number; - - /** - * 总条数 - * - * @type {number} - * @memberof SqlSugarPagedListApprovalFlowOutput - */ - total?: number; - - /** - * 总页数 - * - * @type {number} - * @memberof SqlSugarPagedListApprovalFlowOutput - */ - totalPages?: number; - - /** - * 当前页集合 - * - * @type {Array} - * @memberof SqlSugarPagedListApprovalFlowOutput - */ - items?: Array | null; - - /** - * 是否有上一页 - * - * @type {boolean} - * @memberof SqlSugarPagedListApprovalFlowOutput - */ - hasPrevPage?: boolean; - - /** - * 是否有下一页 - * - * @type {boolean} - * @memberof SqlSugarPagedListApprovalFlowOutput - */ - hasNextPage?: boolean; -} diff --git a/Web/src/api-services/dataApproval/models/sql-sugar-paged-list-data-approval-output.ts b/Web/src/api-services/dataApproval/models/sql-sugar-paged-list-data-approval-output.ts new file mode 100644 index 00000000..f5dece49 --- /dev/null +++ b/Web/src/api-services/dataApproval/models/sql-sugar-paged-list-data-approval-output.ts @@ -0,0 +1,87 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import { DataApprovalOutput } from './data-approval-output'; + /** + * 分页泛型集合 + * + * @export + * @interface SqlSugarPagedListDataApprovalOutput + */ +export interface SqlSugarPagedListDataApprovalOutput { + + /** + * 页码 + * + * @type {number} + * @memberof SqlSugarPagedListDataApprovalOutput + */ + page?: number; + + /** + * 页容量 + * + * @type {number} + * @memberof SqlSugarPagedListDataApprovalOutput + */ + pageSize?: number; + + /** + * 总条数 + * + * @type {number} + * @memberof SqlSugarPagedListDataApprovalOutput + */ + total?: number; + + /** + * 总页数 + * + * @type {number} + * @memberof SqlSugarPagedListDataApprovalOutput + */ + totalPages?: number; + + /** + * 当前页集合 + * + * @type {Array} + * @memberof SqlSugarPagedListDataApprovalOutput + */ + items?: Array | null; + + /** + * 是否有上一页 + * + * @type {boolean} + * @memberof SqlSugarPagedListDataApprovalOutput + */ + hasPrevPage?: boolean; + + /** + * 是否有下一页 + * + * @type {boolean} + * @memberof SqlSugarPagedListDataApprovalOutput + */ + hasNextPage?: boolean; + + /** + * 统计数据 + * + * @type {any} + * @memberof SqlSugarPagedListDataApprovalOutput + */ + totalInfo?: any | null; +} diff --git a/Web/src/api-services/dataApproval/models/update-approval-flow-input.ts b/Web/src/api-services/dataApproval/models/update-data-approval-input.ts similarity index 62% rename from Web/src/api-services/dataApproval/models/update-approval-flow-input.ts rename to Web/src/api-services/dataApproval/models/update-data-approval-input.ts index af9d92e4..52927263 100644 --- a/Web/src/api-services/dataApproval/models/update-approval-flow-input.ts +++ b/Web/src/api-services/dataApproval/models/update-data-approval-input.ts @@ -1,8 +1,8 @@ /* tslint:disable */ /* eslint-disable */ /** - * 审批流程 - * 对业务实体数据的增删改操作进行流程审批。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * DataApproval + *
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! * * OpenAPI spec version: 1.0.0 * @@ -16,15 +16,15 @@ * 审批流更新输入参数 * * @export - * @interface UpdateApprovalFlowInput + * @interface UpdateDataApprovalInput */ -export interface UpdateApprovalFlowInput { +export interface UpdateDataApprovalInput { /** * 编号 * * @type {string} - * @memberof UpdateApprovalFlowInput + * @memberof UpdateDataApprovalInput */ code?: string | null; @@ -32,7 +32,7 @@ export interface UpdateApprovalFlowInput { * 名称 * * @type {string} - * @memberof UpdateApprovalFlowInput + * @memberof UpdateDataApprovalInput */ name?: string | null; @@ -40,7 +40,7 @@ export interface UpdateApprovalFlowInput { * 表单 * * @type {string} - * @memberof UpdateApprovalFlowInput + * @memberof UpdateDataApprovalInput */ formJson?: string | null; @@ -48,7 +48,7 @@ export interface UpdateApprovalFlowInput { * 流程 * * @type {string} - * @memberof UpdateApprovalFlowInput + * @memberof UpdateDataApprovalInput */ flowJson?: string | null; @@ -56,7 +56,7 @@ export interface UpdateApprovalFlowInput { * 备注 * * @type {string} - * @memberof UpdateApprovalFlowInput + * @memberof UpdateDataApprovalInput */ remark?: string | null; @@ -64,7 +64,7 @@ export interface UpdateApprovalFlowInput { * 创建时间 * * @type {Date} - * @memberof UpdateApprovalFlowInput + * @memberof UpdateDataApprovalInput */ createTime?: Date | null; @@ -72,7 +72,7 @@ export interface UpdateApprovalFlowInput { * 更新时间 * * @type {Date} - * @memberof UpdateApprovalFlowInput + * @memberof UpdateDataApprovalInput */ updateTime?: Date | null; @@ -80,7 +80,7 @@ export interface UpdateApprovalFlowInput { * 创建者Id * * @type {number} - * @memberof UpdateApprovalFlowInput + * @memberof UpdateDataApprovalInput */ createUserId?: number | null; @@ -88,7 +88,7 @@ export interface UpdateApprovalFlowInput { * 创建者姓名 * * @type {string} - * @memberof UpdateApprovalFlowInput + * @memberof UpdateDataApprovalInput */ createUserName?: string | null; @@ -96,7 +96,7 @@ export interface UpdateApprovalFlowInput { * 修改者Id * * @type {number} - * @memberof UpdateApprovalFlowInput + * @memberof UpdateDataApprovalInput */ updateUserId?: number | null; @@ -104,7 +104,7 @@ export interface UpdateApprovalFlowInput { * 修改者姓名 * * @type {string} - * @memberof UpdateApprovalFlowInput + * @memberof UpdateDataApprovalInput */ updateUserName?: string | null; @@ -112,7 +112,7 @@ export interface UpdateApprovalFlowInput { * 创建者部门Id * * @type {number} - * @memberof UpdateApprovalFlowInput + * @memberof UpdateDataApprovalInput */ createOrgId?: number | null; @@ -120,7 +120,7 @@ export interface UpdateApprovalFlowInput { * 创建者部门名称 * * @type {string} - * @memberof UpdateApprovalFlowInput + * @memberof UpdateDataApprovalInput */ createOrgName?: string | null; @@ -128,7 +128,7 @@ export interface UpdateApprovalFlowInput { * 软删除 * * @type {boolean} - * @memberof UpdateApprovalFlowInput + * @memberof UpdateDataApprovalInput */ isDelete?: boolean; @@ -136,7 +136,7 @@ export interface UpdateApprovalFlowInput { * 主键Id * * @type {number} - * @memberof UpdateApprovalFlowInput + * @memberof UpdateDataApprovalInput */ id: number; } diff --git a/Web/src/views/dataApproval/component/LogicFlow/Property/PropertyDialog.vue b/Web/src/views/dataApproval/component/LogicFlow/Property/PropertyDialog.vue index 864136eb..1decb8a6 100644 --- a/Web/src/views/dataApproval/component/LogicFlow/Property/PropertyDialog.vue +++ b/Web/src/views/dataApproval/component/LogicFlow/Property/PropertyDialog.vue @@ -7,7 +7,7 @@