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

import com.red.circle.console.app.service.app.sys.SysInviteUserConfigService;
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.inner.model.cmd.user.SysInviteUserConfigCmd;
import com.red.circle.other.inner.model.dto.user.SysInviteUserConfigDTO;
import lombok.RequiredArgsConstructor;
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 pengshigang on 2022/5/24
 */
@RestController
@RequestMapping("/sys/invite/user/config")
@RequiredArgsConstructor
public class SysInviteUserConfigResetController extends BaseController {

  private final SysInviteUserConfigService sysInviteUserConfigService;

  @OpsOperationReqLog(value = "修改邀请用户规则")
  @PostMapping
  public void config(@RequestBody SysInviteUserConfigCmd config) {
    sysInviteUserConfigService.updateConfig(config);
  }

  /**
   * 邀请用户规则
   */
  @GetMapping
  public SysInviteUserConfigDTO config(String sysOrigin) {
    return sysInviteUserConfigService.getConfig(sysOrigin);
  }

}
