package com.red.circle.console.app.service.app.user;

import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.other.inner.endpoint.live.ActiveVoiceRoomClient;
import com.red.circle.other.inner.model.cmd.user.OnlineCountQryCmd;
import com.red.circle.other.inner.model.dto.user.ActiveUserCountryCodeDTO;
import com.red.circle.other.inner.endpoint.user.user.UserExpandClient;
import com.red.circle.other.inner.endpoint.user.user.UserOnlineClient;
import java.time.LocalDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户扩展信息 服务实现类
 * </p>
 *
 * @author pengliang
 * @since 2019-11-08
 */

@Service
@RequiredArgsConstructor
public class DatavServiceImpl implements
    DatavService {

  private final UserExpandClient userExpandClient;
  private final UserOnlineClient onlineUserService;
  private final ActiveVoiceRoomClient activeVoiceRoomClient;

  @Override
  public List<ActiveUserCountryCodeDTO> latestActiveUserCountryCode(LocalDateTime lastActiveTime) {
    return ResponseAssert.requiredSuccess(
        userExpandClient.findLatestActiveUserCountryCode(lastActiveTime));
  }

  @Override
  public Integer onlineTotal(OnlineCountQryCmd onlineCountQuery) {
    return Integer.parseInt(String.valueOf(
        ResponseAssert.requiredSuccess(onlineUserService.onlineTotal(onlineCountQuery))));
  }

  @Override
  public Long count(String sysOrigin) {
    return ResponseAssert.requiredSuccess(activeVoiceRoomClient.count(sysOrigin));
  }
}
