package com.fs.aiChat.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fs.aiChat.domain.DoctorAiChatLog;
import com.fs.aiChat.domain.InterestAiChatMsg;
import com.fs.aiChat.domain.InterestAiSession;
import com.fs.aiChat.domain.SessionRoleInfo;
import com.fs.his.domain.FsInterestAiMsg;
import com.fs.his.domain.FsInterestAiRole;
import com.fs.his.domain.FsInterestAiSession;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface InterestAiChatSessionMapper extends BaseMapper<DoctorAiChatLog> {

    /**
     * 查询用户对话列表
     * @param userId
     * @return
     */
    List<InterestAiSession> getSessionListByUserId(Long userId);

    /**
     * 根据roleid获取会话角色信息
     * @param roleId
     * @return
     */
    SessionRoleInfo getSessionRoleInfoByRoleId(Long roleId);

    /**
     * 获取聊天记录
     * @param sessionId
     * @return
     */
    List<InterestAiChatMsg> getSessionChatList(String sessionId);

    /**
     * 获取会话
     * @param roleId
     * @param userId
     * @return
     */
    @Select("  select session_id,chat_id,user_id,role_id,role_name, status, nick_name,avatar,create_time,update_time\n" +
            "            from fs_interest_ai_session where role_id = #{roleId} and user_id = #{userId} limit 1")
    FsInterestAiSession getInterestAiSessionByRoleIdAndUserId(@Param(value =  "roleId")Long roleId,@Param(value = "userId") Long userId);


    int insertFsInterestAiSession(FsInterestAiSession fsInterestAiSession);

    int insertFsInterestAiMsg(FsInterestAiMsg fsInterestAiMsg);

    List<SessionRoleInfo> getRecommendRoleList(String userId);


    FsInterestAiRole selectFsInterestAiRoleByRoleId(Long roleId);
}
