package com.red.circle.other.app.service.user.relation;

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd;
import com.red.circle.other.app.command.user.ProcessUserCardApplyCmdExe;
import com.red.circle.other.app.command.user.UserCardDismissCmdExe;
import com.red.circle.other.app.command.user.UserFriendCardSendApplyExe;
import com.red.circle.other.app.command.user.query.UserCountMessageQryExe;
import com.red.circle.other.app.command.user.query.UserFriendCardAgreePageQryExe;
import com.red.circle.other.app.command.user.query.UserFriendCardApplyPageQryExe;
import com.red.circle.other.app.command.user.query.UserFriendCardPageQryExe;
import com.red.circle.other.app.command.user.query.UserFriendCardsByUserIdQryExe;
import com.red.circle.other.app.command.user.query.UserFriendCardsQryExe;
import com.red.circle.other.app.dto.clientobject.user.relation.friendcard.UserFriendCardApplyCO;
import com.red.circle.other.app.dto.clientobject.user.relation.friendcard.UserFriendCardCO;
import com.red.circle.other.app.dto.clientobject.user.relation.friendcard.UserFriendCardCountMessageCO;
import com.red.circle.other.app.dto.clientobject.user.relation.friendcard.UserFriendCardStoreCO;
import com.red.circle.other.app.dto.cmd.user.relation.cp.ProcessApplyCmd;
import com.red.circle.other.app.dto.cmd.user.relation.friendcard.FriendshipCardApplyCmd;
import com.red.circle.other.app.dto.cmd.user.relation.friendcard.FriendshipCardApplyDismissCmd;
import com.red.circle.other.app.dto.cmd.user.relation.friendcard.FriendshipCardPageCmd;
import java.util.List;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户友谊关系卡 .
 * </p>
 *
 * @author pengshigang
 * @since 2022-06-09
 */
@Service
@RequiredArgsConstructor
public class UserFriendCardServiceImpl implements UserFriendCardService {

  private final UserCardDismissCmdExe userCardDismissCmdExe;
  private final UserFriendCardsQryExe userFriendCardsQryExe;
  private final UserCountMessageQryExe userCountMessageQryExe;
  private final UserFriendCardPageQryExe userFriendCardPageQryExe;
  private final UserFriendCardSendApplyExe userFriendCardSendApplyExe;
  private final ProcessUserCardApplyCmdExe processUserCardApplyCmdExe;
  private final UserFriendCardApplyPageQryExe userFriendCardApplyPageQryExe;
  private final UserFriendCardsByUserIdQryExe userFriendCardsByUserIdQryExe;
  private final UserFriendCardAgreePageQryExe userFriendCardAgreePageQueryExe;

  @Override
  public List<UserFriendCardStoreCO> cards(AppExtCommand cmd) {
    return userFriendCardsQryExe.execute(cmd);
  }

  @Override
  public List<UserFriendCardCO> userCards(AppUserIdCmd cmd) {
    return userFriendCardsByUserIdQryExe.execute(cmd);
  }

  @Override
  public List<UserFriendCardCO> pageUserByType(FriendshipCardPageCmd cmd) {
    return userFriendCardPageQryExe.execute(cmd);
  }

  @Override
  public void sendApply(FriendshipCardApplyCmd cmd) {
    userFriendCardSendApplyExe.execute(cmd);
  }

  @Override
  public void processApply(ProcessApplyCmd cmd) {
    processUserCardApplyCmdExe.execute(cmd);
  }

  @Override
  public void dismissApply(FriendshipCardApplyDismissCmd cmd) {
    userCardDismissCmdExe.execute(cmd);
  }

  @Override
  public List<UserFriendCardApplyCO> pageApply(FriendshipCardPageCmd cmd) {

    if (Objects.isNull(cmd.getCheckApply()) || cmd.getCheckApply()) {
      return userFriendCardApplyPageQryExe.execute(cmd);
    }
    return userFriendCardAgreePageQueryExe.execute(cmd);

  }

  @Override
  public UserFriendCardCountMessageCO countMessageInfo(AppExtCommand cmd) {
    return userCountMessageQryExe.execute(cmd);
  }
}
