package com.zhentao.mapper;

import com.zhentao.entity.ChatFriend;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;

/**
* @author 26621
* @description 针对表【chat_friend(好友关系表)】的数据库操作Mapper
* @createDate 2025-11-27 14:04:39
* @Entity com.zhentao.entity.ChatFriend
*/
@Mapper
public interface ChatFriendMapper extends BaseMapper<ChatFriend> {
    @Select("SELECT id,user_id,friend_id,friend_name,friend_avatar,status,is_deleted,create_time,update_time " +
            "FROM chat_friend WHERE user_id = #{userId} AND friend_id = #{friendId}")
    ChatFriend selectOneall(@Param("userId") Long userId,
                            @Param("friendId") Long friendId);
    // 自定义原生SQL更新（包含is_deleted字段）
    @Update("UPDATE chat_friend SET status=#{status}, is_deleted=#{isDeleted}, update_time=#{updateTime} WHERE id=#{id}")
    int updateByIdone(@Param("id") Long id,
                      @Param("status") Integer status,
                      @Param("isDeleted") Integer isDeleted,
                      @Param("updateTime") Date updateTime);
}




