Skip to content

Commit

Permalink
Merge pull request #10041 from abpframework/liangshiwei/service-proxy
Browse files Browse the repository at this point in the history
Enhance service proxy file template
  • Loading branch information
maliming committed Sep 16, 2021
2 parents 887ba4f + ac9557e commit db592db
Show file tree
Hide file tree
Showing 77 changed files with 326 additions and 485 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,19 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi
$"{Environment.NewLine}// ReSharper disable once CheckNamespace" +
$"{Environment.NewLine}namespace <namespace>" +
$"{Environment.NewLine}{{" +
$"{Environment.NewLine} public partial class <className>" +
$"{Environment.NewLine} [Dependency(ReplaceServices = true)]" +
$"{Environment.NewLine} [ExposeServices(typeof(<serviceInterface>), typeof(<className>))]" +
$"{Environment.NewLine} public partial class <className> : ClientProxyBase<<serviceInterface>>, <serviceInterface>" +
$"{Environment.NewLine} {{" +
$"{Environment.NewLine} <method placeholder>" +
$"{Environment.NewLine} }}" +
$"{Environment.NewLine}}}" +
$"{Environment.NewLine}";
private readonly string _clientProxyTemplate = "// This file is part of <className>, you can customize it here" +
$"{Environment.NewLine}using Volo.Abp.DependencyInjection;" +
$"{Environment.NewLine}using Volo.Abp.Http.Client.ClientProxying;" +
$"{Environment.NewLine}<using placeholder>" +
$"{Environment.NewLine}" +
$"{Environment.NewLine}// ReSharper disable once CheckNamespace" +
$"{Environment.NewLine}namespace <namespace>" +
$"{Environment.NewLine}{{" +
$"{Environment.NewLine} [Dependency(ReplaceServices = true)]" +
$"{Environment.NewLine} [ExposeServices(typeof(<serviceInterface>), typeof(<className>))]" +
$"{Environment.NewLine} public partial class <className> : ClientProxyBase<<serviceInterface>>, <serviceInterface>" +
$"{Environment.NewLine} public partial class <className>" +
$"{Environment.NewLine} {{" +
$"{Environment.NewLine} }}" +
$"{Environment.NewLine}}}" +
Expand All @@ -58,7 +54,9 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi
"using System.Threading.Tasks;",
"using Volo.Abp.Application.Dtos;",
"using Volo.Abp.Http.Client;",
"using Volo.Abp.Http.Modeling;"
"using Volo.Abp.Http.Modeling;",
"using Volo.Abp.DependencyInjection;",
"using Volo.Abp.Http.Client.ClientProxying;"
};

public CSharpServiceProxyGenerator(
Expand Down Expand Up @@ -130,8 +128,6 @@ private void RemoveClientProxyFile(GenerateProxyArgs args)
var clientProxyBuilder = new StringBuilder(_clientProxyTemplate);
clientProxyBuilder.Replace(ClassName, clientProxyName);
clientProxyBuilder.Replace(Namespace, rootNamespace);
clientProxyBuilder.Replace(ServiceInterface, appServiceTypeName);
clientProxyBuilder.Replace(UsingPlaceholder, $"using {GetTypeNamespace(appServiceTypeFullName)};");

var filePath = Path.Combine(args.WorkDirectory, folder, $"{clientProxyName}.cs");
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
using Volo.Abp.Application.Dtos;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Modeling;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.ClientProxying;
using Volo.Abp.Account;
using Volo.Abp.Identity;

// ReSharper disable once CheckNamespace
namespace Volo.Abp.Account.ClientProxies
{
public partial class AccountClientProxy
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IAccountAppService), typeof(AccountClientProxy))]
public partial class AccountClientProxy : ClientProxyBase<IAccountAppService>, IAccountAppService
{
public virtual async Task<IdentityUserDto> RegisterAsync(RegisterDto input)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
// This file is part of AccountClientProxy, you can customize it here
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.ClientProxying;
using Volo.Abp.Account;

// ReSharper disable once CheckNamespace
namespace Volo.Abp.Account.ClientProxies
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IAccountAppService), typeof(AccountClientProxy))]
public partial class AccountClientProxy : ClientProxyBase<IAccountAppService>, IAccountAppService
public partial class AccountClientProxy
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,103 +4,6 @@
"rootPath": "account",
"remoteServiceName": "AbpAccount",
"controllers": {
"Volo.Abp.Account.Web.Areas.Account.Controllers.AccountController": {
"controllerName": "Account",
"controllerGroupName": "Login",
"type": "Volo.Abp.Account.Web.Areas.Account.Controllers.AccountController",
"interfaces": [],
"actions": {
"LoginByLogin": {
"uniqueName": "LoginByLogin",
"name": "Login",
"httpMethod": "POST",
"url": "api/account/login",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "login",
"typeAsString": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo, Volo.Abp.Account.Web",
"type": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo",
"typeSimple": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "login",
"name": "login",
"jsonName": null,
"type": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo",
"typeSimple": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "Body",
"descriptorName": ""
}
],
"returnValue": {
"type": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.AbpLoginResult",
"typeSimple": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.AbpLoginResult"
},
"allowAnonymous": null,
"implementFrom": "Volo.Abp.Account.Web.Areas.Account.Controllers.AccountController"
},
"Logout": {
"uniqueName": "Logout",
"name": "Logout",
"httpMethod": "GET",
"url": "api/account/logout",
"supportedVersions": [],
"parametersOnMethod": [],
"parameters": [],
"returnValue": {
"type": "System.Void",
"typeSimple": "System.Void"
},
"allowAnonymous": null,
"implementFrom": "Volo.Abp.Account.Web.Areas.Account.Controllers.AccountController"
},
"CheckPasswordByLogin": {
"uniqueName": "CheckPasswordByLogin",
"name": "CheckPassword",
"httpMethod": "POST",
"url": "api/account/check-password",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "login",
"typeAsString": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo, Volo.Abp.Account.Web",
"type": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo",
"typeSimple": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "login",
"name": "login",
"jsonName": null,
"type": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo",
"typeSimple": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "Body",
"descriptorName": ""
}
],
"returnValue": {
"type": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.AbpLoginResult",
"typeSimple": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.AbpLoginResult"
},
"allowAnonymous": null,
"implementFrom": "Volo.Abp.Account.Web.Areas.Account.Controllers.AccountController"
}
}
},
"Volo.Abp.Account.AccountController": {
"controllerName": "Account",
"controllerGroupName": "Account",
Expand Down Expand Up @@ -223,6 +126,103 @@
"implementFrom": "Volo.Abp.Account.IAccountAppService"
}
}
},
"Volo.Abp.Account.Web.Areas.Account.Controllers.AccountController": {
"controllerName": "Account",
"controllerGroupName": "Login",
"type": "Volo.Abp.Account.Web.Areas.Account.Controllers.AccountController",
"interfaces": [],
"actions": {
"LoginByLogin": {
"uniqueName": "LoginByLogin",
"name": "Login",
"httpMethod": "POST",
"url": "api/account/login",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "login",
"typeAsString": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo, Volo.Abp.Account.Web",
"type": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo",
"typeSimple": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "login",
"name": "login",
"jsonName": null,
"type": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo",
"typeSimple": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "Body",
"descriptorName": ""
}
],
"returnValue": {
"type": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.AbpLoginResult",
"typeSimple": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.AbpLoginResult"
},
"allowAnonymous": null,
"implementFrom": "Volo.Abp.Account.Web.Areas.Account.Controllers.AccountController"
},
"Logout": {
"uniqueName": "Logout",
"name": "Logout",
"httpMethod": "GET",
"url": "api/account/logout",
"supportedVersions": [],
"parametersOnMethod": [],
"parameters": [],
"returnValue": {
"type": "System.Void",
"typeSimple": "System.Void"
},
"allowAnonymous": null,
"implementFrom": "Volo.Abp.Account.Web.Areas.Account.Controllers.AccountController"
},
"CheckPasswordByLogin": {
"uniqueName": "CheckPasswordByLogin",
"name": "CheckPassword",
"httpMethod": "POST",
"url": "api/account/check-password",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "login",
"typeAsString": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo, Volo.Abp.Account.Web",
"type": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo",
"typeSimple": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "login",
"name": "login",
"jsonName": null,
"type": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo",
"typeSimple": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.UserLoginInfo",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "Body",
"descriptorName": ""
}
],
"returnValue": {
"type": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.AbpLoginResult",
"typeSimple": "Volo.Abp.Account.Web.Areas.Account.Controllers.Models.AbpLoginResult"
},
"allowAnonymous": null,
"implementFrom": "Volo.Abp.Account.Web.Areas.Account.Controllers.AccountController"
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
using Volo.Abp.Application.Dtos;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Modeling;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.ClientProxying;
using Volo.Blogging.Admin.Blogs;
using Volo.Blogging.Blogs.Dtos;

// ReSharper disable once CheckNamespace
namespace Volo.Blogging.Admin.ClientProxies
{
public partial class BlogManagementClientProxy
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IBlogManagementAppService), typeof(BlogManagementClientProxy))]
public partial class BlogManagementClientProxy : ClientProxyBase<IBlogManagementAppService>, IBlogManagementAppService
{
public virtual async Task<ListResultDto<BlogDto>> GetListAsync()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
// This file is part of BlogManagementClientProxy, you can customize it here
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.ClientProxying;
using Volo.Blogging.Admin.Blogs;

// ReSharper disable once CheckNamespace
namespace Volo.Blogging.Admin.ClientProxies
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IBlogManagementAppService), typeof(BlogManagementClientProxy))]
public partial class BlogManagementClientProxy : ClientProxyBase<IBlogManagementAppService>, IBlogManagementAppService
public partial class BlogManagementClientProxy
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
using Volo.Abp.Application.Dtos;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Modeling;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.ClientProxying;
using Volo.Blogging.Files;

// ReSharper disable once CheckNamespace
namespace Volo.Blogging.ClientProxies
{
public partial class BlogFilesClientProxy
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IFileAppService), typeof(BlogFilesClientProxy))]
public partial class BlogFilesClientProxy : ClientProxyBase<IFileAppService>, IFileAppService
{
public virtual async Task<RawFileDto> GetAsync(string name)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
// This file is part of BlogFilesClientProxy, you can customize it here
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.ClientProxying;
using Volo.Blogging.Files;

// ReSharper disable once CheckNamespace
namespace Volo.Blogging.ClientProxies
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IFileAppService), typeof(BlogFilesClientProxy))]
public partial class BlogFilesClientProxy : ClientProxyBase<IFileAppService>, IFileAppService
public partial class BlogFilesClientProxy
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
using Volo.Abp.Application.Dtos;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Modeling;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.ClientProxying;
using Volo.Blogging.Blogs;
using Volo.Blogging.Blogs.Dtos;

// ReSharper disable once CheckNamespace
namespace Volo.Blogging.ClientProxies
{
public partial class BlogsClientProxy
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IBlogAppService), typeof(BlogsClientProxy))]
public partial class BlogsClientProxy : ClientProxyBase<IBlogAppService>, IBlogAppService
{
public virtual async Task<ListResultDto<BlogDto>> GetListAsync()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
// This file is part of BlogsClientProxy, you can customize it here
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.ClientProxying;
using Volo.Blogging.Blogs;

// ReSharper disable once CheckNamespace
namespace Volo.Blogging.ClientProxies
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IBlogAppService), typeof(BlogsClientProxy))]
public partial class BlogsClientProxy : ClientProxyBase<IBlogAppService>, IBlogAppService
public partial class BlogsClientProxy
{
}
}

0 comments on commit db592db

Please sign in to comment.