package com.red.circle.other.app.command.user.query;

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.tool.core.text.StringUtils;
import com.red.circle.other.app.dto.clientobject.user.user.SysExchangeGoldTableCO;
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
import com.red.circle.other.infra.database.mongo.service.user.region.SysRegionAssistConfigService;
import com.red.circle.other.inner.enums.user.RegionAssistTypeEnum;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 用户区域金币兑换表.
 *
 * @author pengliang on 2023/6/11
 */
@Component
@RequiredArgsConstructor
public class UserRegionExchangeGoldTableQryExe {

  private final UserRegionGateway userRegionGateway;
  private final SysRegionAssistConfigService sysRegionAssistConfigService;

  public List<SysExchangeGoldTableCO> execute(AppExtCommand cmd) {
    String regionId = userRegionGateway.getRegionId(cmd.requiredReqUserId());

    if (StringUtils.isBlank(regionId)) {
      return CollectionUtils.newArrayList();
    }

    return sysRegionAssistConfigService
        .listByTypeByRegionId(RegionAssistTypeEnum.WITHDRAW_PROPORTION_TIPS, regionId,
            SysExchangeGoldTableCO.class);
  }
}
