Skip to content

Add IExchangeResultDataConvertor interface for customizable exchange result format - #5

Draft
juwencheng with Copilot wants to merge 2 commits into
mainfrom
copilot/add-exchange-result-data-convertor
Draft

Add IExchangeResultDataConvertor interface for customizable exchange result format#5
juwencheng with Copilot wants to merge 2 commits into
mainfrom
copilot/add-exchange-result-data-convertor

Conversation

Copilot AI commented Mar 17, 2026

Copy link
Copy Markdown

Users had no way to customize the format of exchange rate data appended to API responses — it was hardcoded via ExchangeResultDto.toMap() returning {base, trans, rate, price}.

Changes

  • New IExchangeResultDataConvertor interface (core/convertor/) — single convert(ExchangeResultDto) method returning Map<String, Object>
  • DefaultExchangeResultDataConvertor — default implementation delegating to toMap(), preserving backward compatibility
  • AutoApplyExchangeStrategy — now accepts IExchangeResultDataConvertor via constructor; replaces exchangeResult.toMap() with convertor.convert(exchangeResult)
  • AutoExchangeAutoConfiguration — registers DefaultExchangeResultDataConvertor as @ConditionalOnMissingBean, allowing users to override with a custom @Bean

Usage

Override the default format by providing a custom bean:

@Bean
public IExchangeResultDataConvertor customConvertor() {
    return result -> {
        Map<String, Object> map = new HashMap<>();
        map.put("convertedPrice", result.getPrice());
        map.put("targetCurrency", result.getTransCurrency());
        return map;
    };
}

This replaces the default {base, trans, rate, price} structure with whatever shape the user defines.

Original prompt

This section details on the original issue you should resolve

<issue_title>【新增】增加汇率转换信息的Convert方法,允许自定义追加格式</issue_title>
<issue_description>新增接口IExchangeResultDataConvertor接口,允许用户自定义追加的信息</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

…xchange data format

Co-authored-by: juwencheng <2663764+juwencheng@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Convert method for exchange rate conversion Add IExchangeResultDataConvertor interface for customizable exchange result format Mar 18, 2026
Copilot AI requested a review from juwencheng March 18, 2026 00:03
@juwencheng

Copy link
Copy Markdown
Owner

@cursor review 这个 PR,看看还有什么问题没有

@cursor

cursor Bot commented Jul 11, 2026

Copy link
Copy Markdown

Skipping Bugbot: Bugbot is disabled for this repository. Visit the Bugbot dashboard to update your settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

【新增】增加汇率转换信息的Convert方法,允许自定义追加格式

2 participants