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

import com.red.circle.console.app.dto.clienobject.app.activity.invite.InviteCampaignConfigCO;
import com.red.circle.console.app.dto.clienobject.app.activity.invite.InviteCampaignInviteeCO;
import com.red.circle.console.app.dto.clienobject.app.activity.invite.InviteCampaignInviterCO;
import com.red.circle.console.app.dto.cmd.app.activity.invite.InviteCampaignConfigSaveCmd;
import com.red.circle.console.app.dto.cmd.app.activity.invite.InviteCampaignInviteePageQryCmd;
import com.red.circle.console.app.dto.cmd.app.activity.invite.InviteCampaignInviterPageQryCmd;
import com.red.circle.console.app.service.app.activity.ResidentInviteActivityService;
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.web.controller.BaseController;
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;

/**
 * 常驻邀请活动后台接口.
 */
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/resident-activity/invite")
public class ResidentInviteActivityRestController extends BaseController {

  private final ResidentInviteActivityService residentInviteActivityService;

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

  @OpsOperationReqLog(value = "保存邀请活动配置")
  @PostMapping("/config/save")
  public void saveConfig(@RequestBody @Validated InviteCampaignConfigSaveCmd cmd) {
    residentInviteActivityService.saveConfig(cmd);
  }

  @GetMapping("/inviter/page")
  public PageResult<InviteCampaignInviterCO> pageInviter(InviteCampaignInviterPageQryCmd cmd) {
    return residentInviteActivityService.pageInviter(cmd);
  }

  @GetMapping("/invitee/page")
  public PageResult<InviteCampaignInviteeCO> pageInvitee(InviteCampaignInviteePageQryCmd cmd) {
    return residentInviteActivityService.pageInvitee(cmd);
  }
}
