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

import java.util.Collections;
import java.util.List;

import com.github.pagehelper.PageHelper;
import com.ruoyi.bst.teamUser.service.TeamUserService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.system.notice.domain.Notice;
import com.ruoyi.system.notice.domain.NoticeQuery;
import com.ruoyi.system.notice.domain.NoticeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.bst.teamUser.mapper.TeamUserMapper;
import com.ruoyi.bst.teamUser.domain.TeamUser;
import com.ruoyi.bst.teamUser.domain.TeamUserVO;
import com.ruoyi.bst.teamUser.domain.TeamUserQuery;

/**
 * 拼桌用户Service业务层处理
 *
 * @author ruoyi
 * @date 2025-05-22
 */
@Service
public class TeamUserServiceImpl implements TeamUserService
{
    @Autowired
    private TeamUserMapper teamUserMapper;

    /**
     * 查询拼桌用户
     *
     * @param id 拼桌用户主键
     * @return 拼桌用户
     */
    @Override
    public TeamUserVO selectTeamUserById(Long id)
    {
        return teamUserMapper.selectTeamUserById(id);
    }

    /**
     * 查询拼桌用户列表
     *
     * @param teamUser 拼桌用户
     * @return 拼桌用户
     */
    @Override
    public List<TeamUserVO> selectTeamUserList(TeamUserQuery teamUser)
    {
        return teamUserMapper.selectTeamUserList(teamUser);
    }

    /**
     * 新增拼桌用户
     *
     * @param teamUser 拼桌用户
     * @return 结果
     */
    @Override
    public int insertTeamUser(TeamUser teamUser)
    {
        teamUser.setCreateTime(DateUtils.getNowDate());
        return teamUserMapper.insertTeamUser(teamUser);
    }

    /**
     * 修改拼桌用户
     *
     * @param teamUser 拼桌用户
     * @return 结果
     */
    @Override
    public int updateTeamUser(TeamUser teamUser)
    {
        return teamUserMapper.updateTeamUser(teamUser);
    }

    /**
     * 批量删除拼桌用户
     *
     * @param ids 需要删除的拼桌用户主键
     * @return 结果
     */
    @Override
    public int deleteTeamUserByIds(Long[] ids)
    {
        return teamUserMapper.deleteTeamUserByIds(ids);
    }

    /**
     * 删除拼桌用户信息
     *
     * @param id 拼桌用户主键
     * @return 结果
     */
    @Override
    public int deleteTeamUserById(Long id)
    {
        return teamUserMapper.deleteTeamUserById(id);
    }

    @Override
    public TeamUserVO selectOne(TeamUserQuery query) {
        PageHelper.startPage(1, 1);
        List<TeamUserVO> teamUserList = this.selectTeamUserList(query);
        return CollectionUtils.firstElement(teamUserList);
    }

    @Override
    public List<TeamUserVO> selectTeamUserListByTeamId(Long teamId) {
        return teamUserMapper.selectTeamUserListByTeamId(teamId);
    }
}
