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

import com.red.circle.console.app.dto.clienobject.app.activity.register.ResidentRegisterRewardConfigCO;
import com.red.circle.console.app.dto.cmd.app.activity.register.ResidentRegisterRewardConfigSaveCmd;
import com.red.circle.console.app.service.app.activity.ResidentRegisterRewardService;
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 常驻注册奖励后台接口.
 */
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/resident-activity/register-reward")
public class ResidentRegisterRewardRestController {

  private final ResidentRegisterRewardService residentRegisterRewardService;

  @GetMapping("/config")
  public ResidentRegisterRewardConfigCO getConfig(String sysOrigin) {
    return residentRegisterRewardService.getConfig(sysOrigin);
  }

  @OpsOperationReqLog(value = "保存注册奖励配置")
  @PostMapping("/config/save")
  public void saveConfig(@RequestBody @Validated ResidentRegisterRewardConfigSaveCmd cmd) {
    residentRegisterRewardService.saveConfig(cmd);
  }

  @OpsOperationReqLog(value = "重置注册奖励配置")
  @PostMapping("/config/reset")
  public void resetConfig(@RequestParam("sysOrigin") String sysOrigin) {
    residentRegisterRewardService.resetConfig(sysOrigin);
  }
}
