Commit 31c51157 authored by youxiaoji's avatar youxiaoji

+ [增加表单提交后会话删除功能]

parent 1dc90ff8
package pangea.hiagent.web.repository;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import pangea.hiagent.model.AgentDialogue;
/**
......@@ -9,4 +11,6 @@ import pangea.hiagent.model.AgentDialogue;
*/
@Mapper
public interface AgentDialogueRepository extends BaseMapper<AgentDialogue> {
@Delete("DELETE FROM agent_dialogue WHERE user_id = #{userId} AND agent_id=#{agentId} ")
public void deleteDialogue(String userId,String agentId);
}
package pangea.hiagent.web.service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pangea.hiagent.web.repository.AgentDialogueRepository;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
......@@ -10,6 +12,9 @@ import java.util.concurrent.ConcurrentMap;
@Service
public class ChatService {
@Autowired
private AgentDialogueRepository agentDialogueRepository;
private final ConcurrentMap<String,String> chatList = new ConcurrentHashMap<>(1024);
public boolean chatExists(String userId,String agentId) {
......@@ -26,6 +31,7 @@ public class ChatService {
String chatId = buildChatId(userId,agentId);
log.info("remove chatId:{}",chatId);
chatList.remove(chatId);
agentDialogueRepository.deleteDialogue(userId,agentId);
}
private String buildChatId(String userId,String agentId) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment