package com.red.circle.wallet.app.command.bank.query;

import com.google.common.collect.Lists;
import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.tool.core.text.StringUtils;
import com.red.circle.other.inner.endpoint.user.region.UserRegionClient;
import com.red.circle.other.inner.model.dto.user.reigon.RegionConfigDTO;
import java.util.List;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 区域提现方式
 *
 * @author zongpubin on 2023/12/8
 */

@Component
@AllArgsConstructor
public class UserBankWithdrawalWaysQryExe {

  private final UserRegionClient userRegionClient;

  public List<String> execute(AppExtCommand cmd) {

    RegionConfigDTO regionConfig = ResponseAssert.requiredSuccess(
        userRegionClient.getSysRegionConfigByUserId(cmd.getReqUserId()));

    if (StringUtils.isNotBlank(regionConfig.getWithdrawalWays())) {
      return StringUtils.splitAsList(regionConfig.getWithdrawalWays(), ",");
    }
    return Lists.newArrayList();
  }
}
