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

import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.other.inner.endpoint.dynamic.DynamicCacheClient;
import com.red.circle.other.inner.model.cmd.dynamic.DynamicPopularConfigCmd;
import com.red.circle.other.inner.model.dto.dynamic.DynamicPopularConfigDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * <p>
 * 动态-热门权重分设置 服务类.
 * </p>
 *
 * @author pengshigang
 * @since 2022-4-15
 */
@Service
@RequiredArgsConstructor
public class DynamicPopularConfigServiceImpl implements DynamicPopularConfigService {

  private final DynamicCacheClient dynamicCacheClient;

  /**
   * 获得配置
   */
  @Override
  public DynamicPopularConfigDTO config() {
    return ResponseAssert.requiredSuccess(dynamicCacheClient.getDynamicPopularConfig());
  }

  /**
   * 更新配置
   */
  @Override
  public void addOrUpdate(@RequestBody @Validated DynamicPopularConfigCmd param) {
    ResponseAssert.requiredSuccess(dynamicCacheClient.updateDynamicPopularConfig(param));
  }
}
