package com.red.circle.other.app.command.family;

import com.red.circle.other.infra.database.rds.entity.family.FamilyMemberInfo;
import com.red.circle.other.infra.database.rds.service.family.FamilyMemberInfoService;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * <p>
 * 为了兼容22-12-23由于app调错接口导致的问题.
 * </p>
 *
 * @author pengshigang
 * @since 2021-07-21
 */
@Component
@RequiredArgsConstructor
public class FamilyMemberIdGetUserIdExe {

  private final FamilyMemberInfoService familyMemberInfoService;

  public Long execute(Long memberId) {

    FamilyMemberInfo memberInfo = familyMemberInfoService.getById(memberId);
    if (Objects.isNull(memberInfo)) {
      return null;
    }
    return memberInfo.getMemberUserId();
  }
}
