package com.ruoyi.bst.teamUser.service.impl;

import com.ruoyi.bst.teamUser.domain.TeamUser;
import com.ruoyi.bst.teamUser.domain.TeamUserQuery;
import com.ruoyi.bst.teamUser.domain.TeamUserVO;
import com.ruoyi.bst.teamUser.domain.enums.UserStatus;
import com.ruoyi.bst.teamUser.service.TeamUserService;
import com.ruoyi.bst.teamUser.service.TeamUserValidator;
import com.ruoyi.common.utils.ServiceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TeamUserValidatorImpl implements TeamUserValidator {

    @Autowired
    private TeamUserService teamUserService;

    @Override
    public boolean canJoinTeam(Long userId) {
        TeamUserQuery query = new TeamUserQuery();
        query.setUserId(userId);
        query.setStatus(UserStatus.JOINED.getCode());
        TeamUserVO vo = teamUserService.selectOne(query);
        return vo == null;
    }
}
