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

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.core.response.CommonErrorCode;
import com.red.circle.wallet.app.common.DiamondRegionCommon;
import com.red.circle.wallet.app.dto.clientobject.DiamondConfigCO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 获取钻石兑换配置.
 *
 * @author pengshigang on 2023/7/21
 */
@Component
@RequiredArgsConstructor
public class DiamondConfigQryExe {

  private final DiamondRegionCommon diamondRegionCommon;

  public DiamondConfigCO execute(AppExtCommand cmd) {
    DiamondConfigCO diamondConfig = diamondRegionCommon.getDiamondRegionConfig(
        cmd.requiredReqUserId());

    ResponseAssert.notNull(CommonErrorCode.REGION_NOT_SUPPORTED_ERROR, diamondConfig);
    ResponseAssert.isTrue(CommonErrorCode.REGION_NOT_SUPPORTED_ERROR,
        diamondConfig.getMinExchangeDiamond() > 0);

    return diamondConfig;
  }


}
