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

import com.red.circle.console.app.dto.clienobject.app.activity.cp.ResidentCpConfigCO;
import com.red.circle.console.app.dto.cmd.app.activity.cp.ResidentCpConfigSaveCmd;
import com.red.circle.console.app.service.app.activity.ResidentCpActivityService;
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
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;

/**
 * 常驻 CP 后台接口.
 */
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/resident-activity/cp")
public class ResidentCpActivityRestController {

  private final ResidentCpActivityService residentCpActivityService;

  @GetMapping("/config")
  public ResidentCpConfigCO getConfig(String sysOrigin) {
    return residentCpActivityService.getConfig(sysOrigin);
  }

  @OpsOperationReqLog(value = "保存 CP 等级积分配置")
  @PostMapping("/config/save")
  public void saveConfig(@RequestBody @Validated ResidentCpConfigSaveCmd cmd) {
    residentCpActivityService.saveConfig(cmd);
  }
}
