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

import com.red.circle.console.app.service.app.sys.RechargeBlacklistService;
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
import com.red.circle.framework.web.controller.BaseController;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 充值黑名单.
 *
 * @author zongpubin on 2023/11/2
 */
@RestController
@RequestMapping("/recharge-black-list")
@RequiredArgsConstructor
public class RechargeBlacklistResetController extends BaseController {

  private final RechargeBlacklistService rechargeBlacklistService;

  @OpsOperationReqLog(value = "添加充值黑名单")
  @PostMapping
  public void addBlacklistIp(@RequestParam("userId") String userId) {
    rechargeBlacklistService.addRechargeBlack(userId);
  }


  @OpsOperationReqLog(value = "删除充值黑名单")
  @DeleteMapping
  public void deleteBlacklist(@RequestParam("content") String content) {
    rechargeBlacklistService.delKey(content);
  }

  /**
   * 充值黑名单列表
   */
  @GetMapping
  public Set<String> getBlacklist() {
    return rechargeBlacklistService.getKeys();
  }

}
