workcase web ai聊天
This commit is contained in:
@@ -16,6 +16,8 @@ import org.xyzh.api.ai.service.AgentChatService;
|
||||
import org.xyzh.common.auth.utils.LoginUtil;
|
||||
import org.xyzh.common.core.domain.LoginDomain;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.core.page.PageDomain;
|
||||
import org.xyzh.common.core.page.PageRequest;
|
||||
import org.xyzh.common.utils.NonUtils;
|
||||
import org.xyzh.common.utils.validation.ValidationParam;
|
||||
import org.xyzh.common.utils.validation.ValidationResult;
|
||||
@@ -128,7 +130,7 @@ public class ChatController {
|
||||
* @author yslg
|
||||
* @since 2025-12-17
|
||||
*/
|
||||
@GetMapping("/conversations")
|
||||
@PostMapping("/conversation/list")
|
||||
public ResultDomain<TbChat> getChatList(@RequestBody TbChat filter, @RequestHeader("Authorization") String token) {
|
||||
log.info("获取会话列表: agentId={}", filter.getAgentId());
|
||||
|
||||
@@ -142,6 +144,26 @@ public class ChatController {
|
||||
return chatService.getChatList(filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 分页获取对话列表
|
||||
* @param pageRequest 分页请求参数
|
||||
* @author yslg
|
||||
* @since 2025-12-17
|
||||
*/
|
||||
@PostMapping("/conversation/page")
|
||||
public ResultDomain<PageDomain<TbChat>> getChatPage(@RequestBody PageRequest<TbChat> pageRequest, @RequestHeader("Authorization") String token) {
|
||||
log.info("分页获取会话列表: agentId={}", pageRequest.getFilter().getAgentId());
|
||||
|
||||
pageRequest.getFilter().setUserType(false);
|
||||
if(NonUtils.isNotEmpty(token)){
|
||||
LoginDomain loginDomain = LoginUtil.getCurrentLogin();
|
||||
if (NonUtils.isNotEmpty(loginDomain) && loginDomain.getUser().getStatus()!="guest") {
|
||||
pageRequest.getFilter().setUserType(true);
|
||||
}
|
||||
}
|
||||
return chatService.getChatPage(pageRequest);
|
||||
}
|
||||
|
||||
// ====================== 消息管理 ======================
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,9 @@ import org.xyzh.api.ai.dto.TbChatMessage;
|
||||
import org.xyzh.api.ai.service.AgentChatService;
|
||||
import org.xyzh.api.ai.service.AgentService;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.core.page.PageDomain;
|
||||
import org.xyzh.common.core.page.PageParam;
|
||||
import org.xyzh.common.core.page.PageRequest;
|
||||
import org.xyzh.common.redis.service.RedisService;
|
||||
import org.xyzh.common.utils.id.IdUtil;
|
||||
import org.xyzh.common.auth.utils.LoginUtil;
|
||||
@@ -200,6 +203,30 @@ public class AgentChatServiceImpl implements AgentChatService {
|
||||
return ResultDomain.success("查询成功", chatList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<PageDomain<TbChat>> getChatPage(PageRequest<TbChat> pageRequest) {
|
||||
TbChat filter = pageRequest.getFilter();
|
||||
// 判断agent是否是outer(来客才需要校验)
|
||||
if (!filter.getUserType() && !isOuterAgent(filter.getAgentId())) {
|
||||
return ResultDomain.<PageDomain<TbChat>>failure("智能体不可用");
|
||||
}
|
||||
// 获取用户ID
|
||||
String userId = getUserIdByType(filter);
|
||||
if (userId == null) {
|
||||
return ResultDomain.<PageDomain<TbChat>>failure("用户信息获取失败");
|
||||
}
|
||||
filter.setUserId(userId);
|
||||
|
||||
// 分页查询
|
||||
PageParam pageParam = pageRequest.getPageParam();
|
||||
List<TbChat> chatList = chatMapper.selectChatPage(filter, pageParam);
|
||||
long total = chatMapper.countChats(filter);
|
||||
pageParam.setTotal((int) total);
|
||||
|
||||
PageDomain<TbChat> pageDomain = new PageDomain<>(pageParam, chatList);
|
||||
return ResultDomain.<PageDomain<TbChat>>success("查询成功", pageDomain);
|
||||
}
|
||||
|
||||
// ====================== 智能体聊天管理 ======================
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user