package com.red.circle.console.adapter.app.user;


import com.red.circle.console.app.dto.clienobject.user.UserGoldRunningWaterCO;
import com.red.circle.console.app.dto.clienobject.user.UserGoldRunningWaterClsTmpCO;
import com.red.circle.console.app.service.app.user.UserWalletService;
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.wallet.inner.model.cmd.DeductGoldCmd;
import com.red.circle.wallet.inner.model.cmd.DiamondCmd;
import com.red.circle.wallet.inner.model.cmd.SendGoldCmd;
import com.red.circle.wallet.inner.model.cmd.UserGoldRunningWaterBackQryCmd;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 钱包服务.
 * </p>
 *
 * @author pengliang on 2022-7-22
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/user-wallet")
public class UserWalletRestController extends BaseController {

  private final UserWalletService userWalletService;

  /**
   * 流水列表(使用cls代替).
   */
  @Deprecated
  @GetMapping("/gold/running-water/list")
  public List<UserGoldRunningWaterCO> listQuery(UserGoldRunningWaterBackQryCmd query) {
    return userWalletService.listGoldRunningWater(query);
  }

  /**
   * 流水列表.
   */
  @GetMapping("/gold/running-water/cls")
  public UserGoldRunningWaterClsTmpCO getGoldRunningWaterCls(UserGoldRunningWaterBackQryCmd query) {
    return userWalletService.getGoldRunningWaterCls(query);
  }

  @OpsOperationReqLog("发送金币")
  @PostMapping("/send-gold")
  public void sendGold(@RequestBody @Validated SendGoldCmd param) {
    param.setOperationUserId(param.getReqUserId());
    userWalletService.sendGold(param);
  }

  @OpsOperationReqLog("扣除金币")
  @PostMapping("/deduct-gold")
  public void deductCandy(@RequestBody @Validated DeductGoldCmd param) {
    param.setOperationUserId(param.getReqUserId());
    userWalletService.deductGold(param);
  }

  @OpsOperationReqLog("发送钻石")
  @PostMapping("/send-diamond")
  public void sendDiamond(@RequestBody @Validated DiamondCmd param) {
    param.setOperationUserId(param.getReqUserId());
    userWalletService.sendDiamond(param);
  }

  @OpsOperationReqLog("扣除钻石")
  @PostMapping("/deduct-diamond")
  public void deductDiamond(@RequestBody @Validated DiamondCmd param) {
    param.setOperationUserId(param.getReqUserId());
    userWalletService.deductDiamond(param);
  }

}
