package com.red.circle.mq.rocket.business.producer;

import com.red.circle.component.mq.MessageEvent;
import com.red.circle.component.mq.service.FixedTopic;
import com.red.circle.component.mq.service.SenderService;
import com.red.circle.mq.business.model.event.wallet.WalletReceiptSyncEvent;
import com.red.circle.mq.rocket.business.streams.WalletAssetGoldSyncSinkV2;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 钱包服务消息服务.
 *
 * @author pengliang on 2023/7/3
 */
@Service
@RequiredArgsConstructor
public class WalletMqMessageService {

  private final SenderService senderService;

  /**
   * 钱包同步消息.
   */
  public void sync(WalletReceiptSyncEvent event) {
    senderService.sendEventMessage(MessageEvent.builder()
        .consumeId(Objects.toString(event.getAssetRecordId()))
        .topic(FixedTopic.RC_DEFAULT_APP_ORDINARY)
        .tag(WalletAssetGoldSyncSinkV2.TAG)
        .body(event)
        .build());
  }

}
