package com.fs.qw.mapper;


import com.fs.qw.domain.QwRoom;
import com.fs.qw.vo.QwRoomMember;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 企微群Mapper接口
 *
 * @author fs
 * @date 2023-08-23
 */
public interface QwRoomMemberMapper
{
    /**
     * 查询群成员
     *
     * @param id 群成员ID
     * @return 群成员
     */
    public QwRoomMember selectQwRoomMemberById(Long id);

    /**
     * 查询群成员列表
     *
     * @param qwRoomMember 群成员
     * @return 群成员集合
     */
    public List<QwRoomMember> selectQwRoomMemberList(QwRoomMember qwRoomMember);

    /**
     * 新增群成员
     *
     * @param qwRoomMember 群成员
     * @return 结果
     */
    public int insertQwRoomMember(QwRoomMember qwRoomMember);

    /**
     * 修改群成员
     *
     * @param qwRoomMember 群成员
     * @return 结果
     */
    public int updateQwRoomMember(QwRoomMember qwRoomMember);

    /**
     * 删除群成员
     *
     * @param id 群成员ID
     * @return 结果
     */
    public int deleteQwRoomMemberById(Long id);

    /**
     * 批量删除群成员
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteQwRoomMemberByIds(Long[] ids);


    @Delete("delete from qw_room_member where user_id = #{userId} and room_id = #{roomId}")
    int deleteQwRoomMemberByUserId(@Param("userId") Long userId, @Param("roomId") Long roomId);

    @Select("select * from qw_room_member where user_id = #{userId} and room_id = #{roomId} limit 1")
    QwRoomMember selectQwRoomMemberByUserId(@Param("userId") Long userId, @Param("roomId") Long roomId);

    @Select("select * from qw_room_member where  room_id = #{roomId} ")
    List<QwRoomMember> selectQwRoomMemberByRoomId(@Param("roomId") Long roomId);
}
