package com.red.circle.other.app.inner.service.activity.impl;

import com.red.circle.other.app.inner.convertor.activity.InviteActivityCountInnerConvertor;
import com.red.circle.other.app.inner.service.activity.InviteActivityCountClientService;
import com.red.circle.other.infra.database.mongo.service.activity.InviteActivityCountService;
import com.red.circle.other.inner.model.dto.activity.InviteExtractRecordCountDTO;
import com.red.circle.other.inner.model.dto.activity.InviteRegisterRecordCountDTO;
import java.time.LocalDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 邀请注册 活动 实现.
 *
 * @author pengliang on 2023/6/4
 */
@Service
@RequiredArgsConstructor
public class InviteActivityCountClientServiceImpl implements InviteActivityCountClientService {

  private final InviteActivityCountService inviteActivityCountService;
  private final InviteActivityCountInnerConvertor inviteActivityCountInnerConvertor;

  @Override
  public void add(InviteRegisterRecordCountDTO count) {
    inviteActivityCountService.add(
        inviteActivityCountInnerConvertor.toInviteRegisterRecordCount(count));
  }

  @Override
  public void inc(Long toUserId, Long quantity) {
    inviteActivityCountService.inc(toUserId, quantity);
  }

  @Override
  public List<InviteRegisterRecordCountDTO> list(Long userId) {
    return inviteActivityCountInnerConvertor.toListInviteRegisterRecordCountDTO(
        inviteActivityCountService.list(userId));
  }

  @Override
  public List<InviteRegisterRecordCountDTO> list(Long userId, Long toUserId,
      LocalDateTime startTime, LocalDateTime endTime) {
    return inviteActivityCountInnerConvertor.toListInviteRegisterRecordCountDTO(
        inviteActivityCountService.list(userId, toUserId, startTime, endTime));
  }

  @Override
  public void addExtract(Long userId, Long quantity, String sysOrigin) {
    inviteActivityCountService.addExtract(userId, quantity, sysOrigin);
  }

  @Override
  public List<InviteExtractRecordCountDTO> listExtract(String sysOriginName) {
    return inviteActivityCountInnerConvertor.toListInviteExtractRecordCountDTO(
        inviteActivityCountService.listExtract(sysOriginName));
  }

}
