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

import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.other.inner.endpoint.user.user.RequestBlacklistClient;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 请求黑名单
 *
 * @author lisizhe on 2023/11/3
 */

@Service
@RequiredArgsConstructor
public class RequestBlacklistServiceImpl implements RequestBlacklistService {

  private final RequestBlacklistClient requestBlacklistClient;


  @Override
  public void addIp(String ip) {
    requestBlacklistClient.addIp(ip);
  }

  @Override
  public void addPhoneModel(String phoneModel) {
    requestBlacklistClient.addPhoneModel(phoneModel);
  }

  @Override
  public void delKey(String key) {
    requestBlacklistClient.delKey(key);
  }

  @Override
  public boolean matchIpOrPhoneModel(String ip, String phoneModel) {
    return ResponseAssert.requiredSuccess(
        requestBlacklistClient.matchIpOrPhoneModel(ip, phoneModel));
  }

  @Override
  public Set<String> getKeys() {
    return ResponseAssert.requiredSuccess(requestBlacklistClient.getKeys());
  }
}
