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

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.common.business.dto.cmd.IdLongCmd;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.wallet.app.dto.clientobject.UserWithdrawInfoCO;
import com.red.circle.wallet.app.dto.cmd.UserWithdrawInfoAddCmd;
import com.red.circle.wallet.app.dto.cmd.UserWithdrawInfoUpdateCmd;
import com.red.circle.wallet.app.service.UserWithdrawInfoApiService;
import java.util.List;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户提现信息服务.
 *
 * @author tf
 * @eo.api-type http
 * @eo.groupName 钱包服务.提现信息
 * @eo.path /wallet/withdraw-info
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping(value = "/withdraw-info", produces = MediaType.APPLICATION_JSON_VALUE)
public class UserWithdrawInfoRestController extends BaseController {

  private final UserWithdrawInfoApiService userWithdrawInfoApiService;

  /**
   * 根据用户id获得提现信息列表.
   *
   * @eo.name 根据用户id获得提现信息列表.
   * @eo.url /list
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/list")
  public List<UserWithdrawInfoCO> listWithdrawInfo(AppExtCommand cmd) {
    return userWithdrawInfoApiService.listWithdrawInfo(cmd);
  }

  /**
   * 根据id删除提现信息.
   *
   * @eo.name 根据id删除提现信息.
   * @eo.url /delete
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/delete")
  public void deleteById(@RequestBody @Validated IdLongCmd cmd) {
    userWithdrawInfoApiService.deleteById(cmd);
  }

  /**
   * 使用提现信息.
   *
   * @eo.name 使用提现信息.
   * @eo.url /use
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/use")
  public void use(@RequestBody @Validated IdLongCmd cmd) {
    userWithdrawInfoApiService.use(cmd);
  }

  /**
   * 添加用户提现信息.
   *
   * @eo.name 添加用户提现信息.
   * @eo.url /add
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/add")
  public void add(@RequestBody @Validated UserWithdrawInfoAddCmd cmd) {
    userWithdrawInfoApiService.add(cmd);
  }

  /**
   * 修改用户提现信息.
   *
   * @eo.name 修改用户提现信息.
   * @eo.url /update
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/update")
  public void update(@RequestBody @Validated UserWithdrawInfoUpdateCmd cmd) {
    userWithdrawInfoApiService.update(cmd);
  }

}
