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


import com.red.circle.console.app.service.app.sys.SysGiftPackConfigService;
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.inner.model.cmd.sys.GiftPackConfigQryCmd;
import com.red.circle.other.inner.model.cmd.sys.SysGiftPackParamCmd;
import com.red.circle.other.inner.model.dto.sys.SysGiftPackConfigDTO;
import com.red.circle.other.inner.model.dto.sys.SysGiftPackParamDTO;
import java.math.BigDecimal;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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 houyong
 * @since 2021-03-10
 */
@RestController
@RequestMapping("/sys/gift/pack/config")
@RequiredArgsConstructor
public class SysGiftPackConfigRestController extends BaseController {

  private final SysGiftPackConfigService sysGiftPackConfigService;

  @OpsOperationReqLog(value = "礼包配置")
  @PostMapping
  public void giftPackConfig(@RequestBody SysGiftPackParamCmd sysGiftPackParam) {
    sysGiftPackConfigService.giftPackConfig(sysGiftPackParam);
  }

  @OpsOperationReqLog(value = "新增礼包配置")
  @PostMapping("/add")
  public void addGiftPackConfig(@RequestBody SysGiftPackParamCmd sysGiftPackParam) {
    sysGiftPackConfigService.addGiftPackConfig(sysGiftPackParam);
  }

  /**
   * 礼包详情.
   */
  @GetMapping("/{giftPackId}")
  public SysGiftPackParamDTO getGiftPackConfig(
      @PathVariable("giftPackId") Long giftPackId) {
    return sysGiftPackConfigService.getGiftPackConfig(giftPackId);
  }

  /**
   * 礼包赠送的金币.
   */
  @GetMapping("/gold/{giftPackId}")
  public BigDecimal getGoldByPackId(@PathVariable("giftPackId") Long giftPackId) {
    return sysGiftPackConfigService.getGoldByPackId(giftPackId);
  }

  /**
   * 礼包详情.
   */
  @GetMapping("/info")
  public List<SysGiftPackConfigDTO> getGiftPackConfigInfo(GiftPackConfigQryCmd query) {
    return sysGiftPackConfigService.getGiftPackConfigInfo(query);
  }


}
