package com.red.circle.other.app.inner.endpoint.dynamic;

import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.dynamic.DynamicCacheClientService;
import com.red.circle.other.inner.endpoint.dynamic.api.DynamicCacheClientApi;
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.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 动态-缓存.
 *
 * @author pengliang on 2023/6/5
 */
@Validated
@RestController
@RequestMapping(value = DynamicCacheClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class DynamicCacheClientEndpoint implements DynamicCacheClientApi {

  private final DynamicCacheClientService dynamicCacheClientService;


  @Override
  public ResultResponse<DynamicPopularConfigDTO> getDynamicPopularConfig() {
    return ResultResponse.success(dynamicCacheClientService.getDynamicPopularConfig());
  }

  @Override
  public ResultResponse<Void> updateDynamicPopularConfig(DynamicPopularConfigCmd param) {
    dynamicCacheClientService.updateDynamicPopularConfig(param);
    return ResultResponse.success();
  }
}
