Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Help, how to override RADTools generate service? #8764


User avatar
0
uxabp created

Here power tools generate service code.

[AbpAuthorize(AppPermissions.Pages_CustomizeApiKeies)]
    public class CustomizeApiKeiesAppService : AbpZeroTemplateAppServiceBase, ICustomizeApiKeiesAppService
    {
		 private readonly IRepository<CustomizeApiKey> _customizeApiKeyRepository;
		 private readonly IRepository<User,long> _lookup_userRepository;
		 

		  public CustomizeApiKeiesAppService(IRepository<CustomizeApiKey> customizeApiKeyRepository , IRepository<User, long> lookup_userRepository) 
		  {
			_customizeApiKeyRepository = customizeApiKeyRepository;
			_lookup_userRepository = lookup_userRepository;		
		  }
          ........
         [AbpAuthorize(AppPermissions.Pages_CustomizeApiKeies_Create)]
		 protected virtual async Task Create(CreateOrEditCustomizeApiKeyDto input)
         {
            var customizeApiKey = ObjectMapper.Map<CustomizeApiKey>(input);
			if (AbpSession.TenantId != null)
			{
				customizeApiKey.TenantId = (int?) AbpSession.TenantId;
			}
            await _customizeApiKeyRepository.InsertAsync(customizeApiKey);
         }
         ...........
       }

I want to override Create method, but not working. still run CustomizeApiKeiesAppService. Here is my code.

 public class CustomizeApiKeiesAppServiceCustom : CustomizeApiKeiesAppService
	{
		private readonly IRepository<CustomizeApiKey> _customizeApiKeyRepository;
		private readonly IRepository<User, long> _lookup_userRepository;


		public CustomizeApiKeiesAppServiceCustom(IRepository<CustomizeApiKey> customizeApiKeyRepository, IRepository<User, long> lookup_userRepository)
			: base (customizeApiKeyRepository, lookup_userRepository)
		{
			_customizeApiKeyRepository = customizeApiKeyRepository;
			_lookup_userRepository = lookup_userRepository;
		}
        [AbpAuthorize(AppPermissions.Pages_CustomizeApiKeies_Create)]
		protected override async Task Create(CreateOrEditCustomizeApiKeyDto input)
		{
			var customizeApiKey = ObjectMapper.Map<CustomizeApiKey>(input);
            DoSomething();
			await _customizeApiKeyRepository.InsertAsync(customizeApiKey);
		}
        ..........
        }

and PreInitialize()

  public override void PreInitialize()
        {            
            Configuration.ReplaceService<ICustomizeApiKeiesAppService, CustomizeApiKeiesAppServiceCustom>();
            }

Not working.

Help me, please.


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @uxabp,

    That's because your client side code must be changed. There will be two endpoints on the server side, one for CustomizeApiKeiesAppService and other for CustomizeApiKeiesAppServiceCustom.

    Could you share your client side JS code related to this as well ?

  • User Avatar
    0
    uxabp created

    Hi @ismcagdas,

    If modify the client code, the next time use power tools to generate it again, the client code will be overwritten.

    Is there a way to not change the code generated by power tools, override the generated method?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @uxabp,

    Yes, it will be overwritten. Unfortunately there is no automatica way at the moment. For now, Power Tools is designed that way. We are planning to enhance this functionality.