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

import com.red.circle.console.app.service.app.props.PropsActivityRuleConfigService;
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.PropsActivityRuleConfigParamCmd;
import com.red.circle.other.inner.model.cmd.material.PropsActivityRuleConfigQryCmd;
import com.red.circle.other.inner.model.dto.material.PropsActivityRuleConfigDTO;
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-18
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/props/activity/rule/config")
public class PropsActivityRuleConfigRestController extends BaseController {

  private final PropsActivityRuleConfigService propsActivityRuleConfigService;

  /**
   * 分页.
   */
  @GetMapping("/page")
  public PageResult<PropsActivityRuleConfigDTO> pagePropsActivityRuleConfig(
      PropsActivityRuleConfigQryCmd propsActivityRuleConfigQuery) {
    return propsActivityRuleConfigService
        .pagePropsActivityRuleConfig(propsActivityRuleConfigQuery);
  }

  @OpsOperationReqLog(value = "保存-活动道具规则配置")
  @PostMapping("/save-or-update")
  public void saveOrUpdate(
      @RequestBody @Validated PropsActivityRuleConfigParamCmd param) {
    propsActivityRuleConfigService.saveOrUpdate(param);
  }

  @OpsOperationReqLog(value = "删除活动道具规则配置")
  @GetMapping("/del/{id}")
  public void deleteById(@PathVariable("id") Long id) {
    propsActivityRuleConfigService.deleteById(id);
  }


}
