abpframework / abpframework/abp

generate-proxy compatible with multiple appservices for one controller ?

Open
#17,134 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
C#
Stars
14.4k
Forks
3.7k
Avg merge
15h 32m
Merged PRs (30d)
106

Description

Is there an existing issue for this?
  • I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.

For code organization purposes, we separate the methods of the same controller into several appservices.
For example:
Instead of having one service MailMessageService which contains: GetAsync() & UpdateAsync() methods
MailMessageService
----GetAsync()
----UpdateAsync()

We have 2 services GetMailMessageService which contains: GetAsync() and UpdateMailMessageService which contains: UpdateAsync()

GetMailMessageService
----GetAsync()

UpdateMailMessageService
----UpdateAsync()

We overrided the UrlControllerNameNormalizer as follows:

Configure<AbpAspNetCoreMvcOptions>(options =>
        {
            options.ConventionalControllers
            .Create(typeof(MyApplicationModule).Assembly, opts =>
            {
                opts.UrlControllerNameNormalizer = context => context.ControllerName?
                .IgnorePrefixes("Get", "Create", "Update", "Delete");
            });
        });

It works fine when it comes to deleting prefixes and having a well formed endpoint name, but when it comes to generating proxy (angular), it generates only one angular service MailMessageService (with prefix removed), instead of bot GetMailMessageService, UpdateMailMessageService .

Can we take advantage of the generate-proxy command for angular while maintaining consistency in the api endpoints but being able to split our appservices (by separating the CRUD methods for example)?

Describe the solution you'd like

I would like to have 2 different services (GetMailMessageService and UpdateMailMessageService) in the backend, with endpoints names overrided as follows :

Configure<AbpAspNetCoreMvcOptions>(options =>
        {
            options.ConventionalControllers
            .Create(typeof(MyApplicationModule).Assembly, opts =>
            {
                opts.UrlControllerNameNormalizer = context => context.ControllerName?
                .IgnorePrefixes("Get", "Create", "Update", "Delete");
            });
        });

And being able to generate 2 services in the front part, using generate-proxy command:
get-mail-message.service.ts
----getAsync()

update-mail-message.service.ts
----updateAsync()

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the generate-proxy command's Angular service generation and how UrlControllerNameNormalizer is applied through AbpAspNetCoreMvcOptions. Compare the generated service grouping with the separate GetMailMessageService and UpdateMailMessageService examples. Done means both backend appservices retain normalized endpoints while generate-proxy produces separate Angular services for them.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, csharp
Domain
api, frontend, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.