package com.red.circle.wallet.adapter.app;

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.wallet.app.dto.clientobject.BeanToGoldCO;
import com.red.circle.wallet.app.service.WalletBeanService;
import java.math.BigDecimal;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 豆子钱包.
 *
 * @author pengliang on 2023/9/19
 * @eo.api-type http
 * @eo.groupName 钱包服务.豆子钱包
 * @eo.path /wallet/bean
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/bean", produces = MediaType.APPLICATION_JSON_VALUE)
public class BeanRestController extends BaseController {

  private final WalletBeanService walletBeanService;

  /**
   * 豆子余额.
   *
   * @eo.name 豆子余额.
   * @eo.url /balance
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/balance")
  public BigDecimal getBalance(@Validated AppUserIdCmd cmd) {
    return walletBeanService.getBalance(cmd);
  }

  /**
   * 豆子兑换金币.
   *
   * @eo.name 豆子兑换金币.
   * @eo.url /to-gold
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/exchange-gold")
  public BeanToGoldCO toGold(AppExtCommand cmd) {
    return walletBeanService.exchangeGold(cmd);
  }

  /**
   * 豆子兑换金币.
   *
   * @eo.name 豆子兑换金币.
   * @eo.url /get-exchange
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/get-exchange")
  public BeanToGoldCO getExchange(AppExtCommand cmd) {
    return walletBeanService.getExchange(cmd);
  }

}
