package com.red.circle.other.app.command.team.query;

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.other.infra.database.mongo.entity.team.team.TeamProfile;
import com.red.circle.other.infra.database.mongo.service.team.team.TeamApplicationProcessService;
import com.red.circle.other.infra.database.mongo.service.team.team.TeamProfileService;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 团队是否存在消息.
 *
 * @author pengliang on 2024/1/18
 */
@Component
@RequiredArgsConstructor
public class TeamExistsMessageTipsQryExe {

  private final TeamProfileService teamProfileService;
  private final TeamApplicationProcessService teamApplicationProcessService;

  public Boolean execute(AppExtCommand cmd) {
    TeamProfile teamProfile = teamProfileService.getByOwnUserId(cmd.requiredReqUserId());
    if (Objects.isNull(teamProfile)) {
      return Boolean.FALSE;
    }
    return teamApplicationProcessService.existTeamWaitByTeamId(teamProfile.getId());
  }

}
