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.dto.team.BdRoleEnum;
import com.red.circle.other.infra.database.rds.service.team.BusinessDevelopmentBaseInfoService;
import com.red.circle.other.infra.database.rds.service.team.RoomBdLeadService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * <p>
 * BD角色.
 * </p>
 *
 * @author pengshigang
 * @since 2023-4-7
 */
@Component
@RequiredArgsConstructor
public class BdRoleQryExe {

  private final RoomBdLeadService roomBdLeadService;
  private final BusinessDevelopmentBaseInfoService businessDevelopmentBaseInfoService;

  public String execute(AppExtCommand cmd) {

    if (Boolean.TRUE.equals(roomBdLeadService.checkBdLeader(cmd.requiredReqUserId()))) {
      return BdRoleEnum.BD_LEADER.name();
    }

    if (Boolean.TRUE
        .equals(businessDevelopmentBaseInfoService.checkBD(cmd.requiredReqUserId()))) {
      return BdRoleEnum.BD.name();
    }

    return "";
  }

}
