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

import com.red.circle.console.app.service.app.dynamic.DynamicPopularConfigService;
import com.red.circle.framework.web.controller.BaseController;
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.validation.annotation.Validated;
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
 * @since 2022-4-27
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/dynamic/popular/config")
public class DynamicPopularConfigRestController extends BaseController {

  private final DynamicPopularConfigService dynamicPopularConfigService;

  /**
   * 获得配置
   */
  @GetMapping
  public DynamicPopularConfigDTO config() {

    return dynamicPopularConfigService.config();
  }

  /**
   * 更新配置
   */
  @PostMapping
  public void addOrUpdate(@RequestBody @Validated DynamicPopularConfigCmd cmd) {
    dynamicPopularConfigService.addOrUpdate(cmd);
  }
}
