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

import com.red.circle.console.app.service.app.props.PropsActivityRewardGroupService;
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.inner.model.cmd.material.PropsActivityRewardGroupParamCmd;
import com.red.circle.other.inner.model.cmd.material.PropsActivityRewardGroupQryCmd;
import com.red.circle.other.inner.model.dto.material.ActivityGroupKeyValueDTO;
import com.red.circle.other.inner.model.dto.material.PropsActivityRewardGroupDTO;
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.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;

/**
 * 活动道具奖励配置 前端控制器.
 *
 * @author pengshigang
 * @since 2021-06-07
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/props/activity/reward/group")
public class PropsActivityRewardGroupRestController extends BaseController {

  private final PropsActivityRewardGroupService propsActivityRewardGroupService;

  /**
   * 分页.
   */
  @GetMapping("/page")
  public PageResult<PropsActivityRewardGroupDTO> pagePropsActivityRewardGroup(PropsActivityRewardGroupQryCmd query) {
    return propsActivityRewardGroupService.pagePropsActivityRewardGroup(query);
  }

  /**
   * 根据组ID获得资源组信息.
   */
  @GetMapping("/{id}")
  public PropsActivityRewardGroupDTO getByGroupId(@PathVariable("id") Long id) {
    return propsActivityRewardGroupService.getByGroupId(id);
  }

  @OpsOperationReqLog(value = "保存-活动道具奖励配置")
  @PostMapping("/save-or-update")
  public String saveOrUpdate(
      @RequestBody @Validated PropsActivityRewardGroupParamCmd propsActivityRewardGroupParam) {
    return propsActivityRewardGroupService.saveOrUpdate(propsActivityRewardGroupParam);
  }

  @OpsOperationReqLog(value = "上下架-活动道具奖励配置")
  @GetMapping("/off/shelf/{id}/{offShelf}")
  public void offShelf(@PathVariable("id") Long id,
      @PathVariable("offShelf") Boolean offShelf) {
    propsActivityRewardGroupService.offShelf(id, offShelf);
  }

  /**
   * 获得活动道具组列表.
   */
  @GetMapping("/get/activity/list")
  public List<ActivityGroupKeyValueDTO> getActivityList() {
    return propsActivityRewardGroupService.getActivityGroupKeyValueList();
  }

}
