diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApiDescriptionExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApiDescriptionExtensions.cs index fdf33e788d..e0f9bbc6c1 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApiDescriptionExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApiDescriptionExtensions.cs @@ -1,5 +1,4 @@ -using Microsoft.AspNetCore.Mvc.Abstractions; -using Microsoft.AspNetCore.Mvc.ApiExplorer; +using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.AspNetCore.Mvc.Controllers; using Volo.Abp.Reflection; @@ -7,9 +6,9 @@ namespace Volo.Abp.AspNetCore.Mvc; public static class ApiDescriptionExtensions { - public static bool IsRemoteService(this ApiDescription actionDescriptor) + public static bool IsRemoteService(this ApiDescription apiDescriptor) { - if (actionDescriptor.ActionDescriptor is ControllerActionDescriptor controllerActionDescriptor) + if (apiDescriptor.ActionDescriptor is ControllerActionDescriptor controllerActionDescriptor) { var remoteServiceAttr = ReflectionHelper.GetSingleAttributeOfMemberOrDeclaringTypeOrDefault(controllerActionDescriptor.MethodInfo); if (remoteServiceAttr != null && remoteServiceAttr.IsEnabled) @@ -31,4 +30,14 @@ public static class ApiDescriptionExtensions return false; } + + public static bool IsIntegrationService(this ApiDescription apiDescriptor) + { + if (apiDescriptor.ActionDescriptor is ControllerActionDescriptor controllerActionDescriptor) + { + return IntegrationServiceAttribute.IsDefinedOrInherited(controllerActionDescriptor.ControllerTypeInfo); + } + + return false; + } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs index dbc7532aab..f18e9d6c3c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs @@ -103,6 +103,7 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide _options.ControllerNameGenerator(controllerType, setting), FindGroupName(controllerType) ?? apiDescription.GroupName, apiDescription.IsRemoteService(), + apiDescription.IsIntegrationService(), apiDescription.GetProperty()?.ToString(), controllerType, _modelOptions.IgnoredInterfaces diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProxyCommandBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProxyCommandBase.cs index 67c61b2a28..bd48f5c828 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProxyCommandBase.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProxyCommandBase.cs @@ -68,8 +68,19 @@ public abstract class ProxyCommandBase : IConsoleCommand, ITransientDependenc var source = commandLineArgs.Options.GetOrNull(Options.Source.Short, Options.Source.Long); var workDirectory = commandLineArgs.Options.GetOrNull(Options.WorkDirectory.Short, Options.WorkDirectory.Long) ?? Directory.GetCurrentDirectory(); var folder = commandLineArgs.Options.GetOrNull(Options.Folder.Long); + var serviceTypeArg = commandLineArgs.Options.GetOrNull(Options.Module.Short, Options.ServiceType.Long); - return new GenerateProxyArgs(CommandName, workDirectory, module, url, output, target, apiName, source, folder, commandLineArgs.Options); + ServiceType? serviceType = null; + if (!serviceTypeArg.IsNullOrWhiteSpace()) + { + serviceType = serviceTypeArg.ToLower() == "application" + ? ServiceType.Application + : serviceTypeArg.ToLower() == "integration" + ? ServiceType.Integration + : null; + } + + return new GenerateProxyArgs(CommandName, workDirectory, module, url, output, target, apiName, source, folder, serviceType, commandLineArgs.Options); } public virtual string GetUsageInfo() @@ -162,5 +173,11 @@ public abstract class ProxyCommandBase : IConsoleCommand, ITransientDependenc public const string Short = "wd"; public const string Long = "working-directory"; } + + public static class ServiceType + { + public const string Short = "st"; + public const string Long = "service-type"; + } } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs index 5f1698661e..6ee080f41b 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs @@ -30,7 +30,7 @@ public class AngularServiceProxyGenerator : ServiceProxyGeneratorBase ExtraProperties { get; set; } @@ -38,6 +40,7 @@ public class GenerateProxyArgs string apiName, string source, string folder, + ServiceType? serviceType, Dictionary extraProperties = null) { CommandName = Check.NotNullOrWhiteSpace(commandName, nameof(commandName)); @@ -49,6 +52,7 @@ public class GenerateProxyArgs ApiName = apiName; Source = source; Folder = folder; + ServiceType = serviceType; ExtraProperties = extraProperties ?? new Dictionary(); } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/JavaScript/JavaScriptServiceProxyGenerator.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/JavaScript/JavaScriptServiceProxyGenerator.cs index f1f3bef1cc..4871679009 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/JavaScript/JavaScriptServiceProxyGenerator.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/JavaScript/JavaScriptServiceProxyGenerator.cs @@ -28,7 +28,7 @@ public class JavaScriptServiceProxyGenerator : ServiceProxyGeneratorBase : IServiceProxyGenerator wher throw new CliUsageException($"Module name: {args.Module} is invalid"); } + var serviceType = args.ServiceType ?? GetDefaultServiceType(args); + + switch (serviceType) + { + case ServiceType.Application: + moduleDefinition.Controllers.RemoveAll(x => !x.Value.IsRemoteService); + break; + case ServiceType.Integration: + moduleDefinition.Controllers.RemoveAll(x => !x.Value.IsIntegrationService); + break; + } + var apiDescriptionModel = ApplicationApiDescriptionModel.Create(); apiDescriptionModel.AddModule(moduleDefinition); - return apiDescriptionModel; } + protected abstract ServiceType? GetDefaultServiceType(GenerateProxyArgs args); + protected string GetLoggerOutputPath(string path, string workDirectory) { return path.Replace(workDirectory, string.Empty).TrimStart(Path.DirectorySeparatorChar); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/ServiceType.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/ServiceType.cs new file mode 100644 index 0000000000..c0d9979593 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/ServiceType.cs @@ -0,0 +1,8 @@ +namespace Volo.Abp.Cli.ServiceProxying; + +public enum ServiceType : byte +{ + All = 0, + Application = 1, + Integration = 2 +} diff --git a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs index 05021a9115..cb2fce9bbb 100644 --- a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs +++ b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs @@ -14,6 +14,8 @@ public class ControllerApiDescriptionModel public bool IsRemoteService { get; set; } + public bool IsIntegrationService { get; set; } + public string ApiVersion { get; set; } public string Type { get; set; } @@ -27,13 +29,14 @@ public class ControllerApiDescriptionModel } - public static ControllerApiDescriptionModel Create(string controllerName, string groupName, bool isRemoteService, string apiVersion, Type type, [CanBeNull] HashSet ignoredInterfaces = null) + public static ControllerApiDescriptionModel Create(string controllerName, string groupName, bool isRemoteService, bool isIntegrationService, string apiVersion, Type type, [CanBeNull] HashSet ignoredInterfaces = null) { return new ControllerApiDescriptionModel { ControllerName = controllerName, ControllerGroupName = groupName, IsRemoteService = isRemoteService, + IsIntegrationService = isIntegrationService, ApiVersion = apiVersion, Type = type.FullName, Actions = new Dictionary(), diff --git a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs index 48b6cd3cda..bb2c25e3eb 100644 --- a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs +++ b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs @@ -49,10 +49,10 @@ public class ModuleApiDescriptionModel return Controllers[controller.Type] = controller; } - public ControllerApiDescriptionModel GetOrAddController(string name, string groupName, bool isRemoteService, string apiVersion, Type type, [CanBeNull] HashSet ignoredInterfaces = null) + public ControllerApiDescriptionModel GetOrAddController(string name, string groupName, bool isRemoteService, bool isIntegrationService, string apiVersion, Type type, [CanBeNull] HashSet ignoredInterfaces = null) { var key = apiVersion.IsNullOrWhiteSpace() ? type.FullName : $"{apiVersion + "."}{type.FullName}"; - return Controllers.GetOrAdd(key, () => ControllerApiDescriptionModel.Create(name, groupName, isRemoteService, apiVersion, type, ignoredInterfaces)); + return Controllers.GetOrAdd(key, () => ControllerApiDescriptionModel.Create(name, groupName, isRemoteService, isIntegrationService, apiVersion, type, ignoredInterfaces)); } public ModuleApiDescriptionModel CreateSubModel(string[] controllers, string[] actions)